Injects a reminder to read the project's memory/gotchas-minimax.md when a prompt mentions MiniMax or mm-worktree-task, once per session, with the real resolved path. Supervising MiniMax units has repeatable failure modes (claimed-green dodges, fakes-only tests, a unit routing around a permission gate) and the write-ups only help if they are opened. Never blocks: always exits 0 on missing jq, malformed stdin or an unwritable TMPDIR. Installed into both custom config homes (anthropic + minimax). Claude-Session: https://claude.ai/code/session_014KNyfHmHpMbdMrHZXDRkAp
64 lines
3.4 KiB
Bash
Executable File
64 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# UserPromptSubmit hook — when a prompt mentions MiniMax, remind the supervising
|
|
# session to read the MiniMax supervision gotchas before dispatching or gating work.
|
|
#
|
|
# Why: supervising MiniMax units has a repeatable set of failure modes (agents
|
|
# reporting a green suite that was skipped / stale / un-failable, following a brief
|
|
# into a real defect, stating unreproduced root causes, routing around permission
|
|
# gates). Those are written up per project in memory/gotchas-minimax.md; this hook
|
|
# makes sure the supervising session actually reads them.
|
|
#
|
|
# Fires once per session (a sentinel under $TMPDIR keyed by session_id), so a long
|
|
# MiniMax session is not nagged on every prompt.
|
|
#
|
|
# Input : UserPromptSubmit JSON on stdin ({session_id, prompt, cwd, ...}).
|
|
# Output : nothing when the prompt does not mention minimax or the session already
|
|
# got the reminder; otherwise a hookSpecificOutput.additionalContext JSON.
|
|
# Exit : always 0 — this hook must never block a prompt.
|
|
set -uo pipefail
|
|
|
|
INPUT="$(cat 2>/dev/null || true)"
|
|
[ -n "$INPUT" ] || exit 0
|
|
|
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
|
|
PROMPT="$(printf '%s' "$INPUT" | jq -r '.prompt // ""' 2>/dev/null || true)"
|
|
printf '%s' "$PROMPT" | grep -qiE 'mini[-_ ]?max|mm-worktree-task' || exit 0
|
|
|
|
SID="$(printf '%s' "$INPUT" | jq -r '.session_id // "nosid"' 2>/dev/null || echo nosid)"
|
|
SENTINEL_DIR="${TMPDIR:-/tmp}/claude-minimax-gotchas"
|
|
mkdir -p "$SENTINEL_DIR" 2>/dev/null || exit 0
|
|
SENTINEL="$SENTINEL_DIR/$(printf '%s' "$SID" | tr -c 'A-Za-z0-9._-' '_')"
|
|
[ -e "$SENTINEL" ] && exit 0
|
|
: > "$SENTINEL" 2>/dev/null || exit 0
|
|
|
|
# Prefer the gotchas file of the project the session is actually in.
|
|
CWD="$(printf '%s' "$INPUT" | jq -r '.cwd // ""' 2>/dev/null || true)"
|
|
[ -n "$CWD" ] || CWD="$PWD"
|
|
ROOT="$CWD"
|
|
GOTCHAS=""
|
|
while [ -n "$ROOT" ] && [ "$ROOT" != "/" ]; do
|
|
if [ -f "$ROOT/memory/gotchas-minimax.md" ]; then
|
|
GOTCHAS="$ROOT/memory/gotchas-minimax.md"
|
|
break
|
|
fi
|
|
ROOT="$(dirname "$ROOT")"
|
|
done
|
|
|
|
TESTING=""
|
|
if [ -n "$GOTCHAS" ] && [ -f "$(dirname "$(dirname "$GOTCHAS")")/memory/gotchas-testing.md" ]; then
|
|
TESTING="$(dirname "$(dirname "$GOTCHAS")")/memory/gotchas-testing.md"
|
|
fi
|
|
|
|
if [ -n "$GOTCHAS" ]; then
|
|
MSG="MiniMax mentioned. Before dispatching, briefing or gating a MiniMax unit, read ${GOTCHAS} if you have not already done so this session — it records the supervision failure modes that gating actually caught (claimed-green dodges, following a brief's letter into a defect, unreproduced root causes stated confidently, routing around a permission gate, misattributed rulings)."
|
|
[ -n "$TESTING" ] && MSG="${MSG} If the unit touches code that shells out or talks to a real tool, read ${TESTING} too (fakes-only tests pass while the real thing is broken)."
|
|
MSG="${MSG} Standing rule: re-run every claimed-green suite yourself, after the agent's LAST commit, before merging."
|
|
else
|
|
MSG="MiniMax mentioned. This project has no memory/gotchas-minimax.md; the nearest write-ups are under ~/dev/claude/projects/*/memory/gotchas-minimax.md (hugo-accelerator and agent-runtimes). Standing rules when supervising a MiniMax unit: re-run every claimed-green suite yourself after the agent's LAST commit before merging; require a real-process test wherever the code shells out; and tell the unit never to work around a permission prompt."
|
|
fi
|
|
|
|
jq -n --arg ctx "$MSG" \
|
|
'{hookSpecificOutput:{hookEventName:"UserPromptSubmit",additionalContext:$ctx}}' 2>/dev/null || true
|
|
exit 0
|