Files
cursor__plugins/advisor/hooks/stop-hook.sh
Eric Zakariasson 659a6363c0 feat(advisor): add Advisor plugin (Grok 4.6 consults at key checkpoints) (#314)
Adds an Advisor plugin: the main model consults a stronger model before
major decisions, when stuck on an error, and before declaring a task done.
The advisor gets a full briefing plus the conversation transcript path,
returns a verdict with guidance, and the main model keeps doing the work.
The default advisor is the latest Grok (Grok 4.6) at its highest reasoning
effort; /advisor <model> accepts any model available to subagents.

- skill `advisor`: /advisor [model|off|status|ask ...|nudge on|off],
  checkpoint protocol, briefing template, usable as a Custom Mode
- agent `advisor-subagent`: read-only, pinned to grok-4.6[effort=xhigh]
- hooks: track edits since the last consult, log consults to
  .cursor/advisor/log.md, nudge a pre-completion consult once per batch
  of edits; state is bound to the conversation that enabled it
- registered in marketplace.json and the root README
2026-09-04 12:22:22 +00:00

49 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# stop hook for Advisor.
# If files changed since the last advisor consult and the turn ended without one,
# ask the agent (once per batch of edits) to run the pre-completion consult.
#
# Input: { "status": "completed"|"aborted"|"error", "loop_count": N, ...common }
# Output: { "followup_message": "<text>" } to continue, or exit 0 with no output
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
HOOK_INPUT=$(cat)
advisor_require_enabled
advisor_bind_conversation "$HOOK_INPUT" || exit 0
STATUS=$(jq -r '.status // empty' <<< "$HOOK_INPUT")
if [[ "$STATUS" != "completed" ]]; then
exit 0
fi
NUDGE=$(jq -r 'if .nudge == false then "false" else "true" end' "$STATE_FILE")
if [[ "$NUDGE" != "true" ]]; then
exit 0
fi
if [[ ! -f "$PENDING_FILE" ]]; then
exit 0
fi
# The agent stopped to ask the user something. Stay quiet and leave the marker
# armed so the reminder fires after the user answers and the work resumes.
if [[ -f "$LAST_RESPONSE_FILE" ]]; then
LAST_CHAR=$(tr -d '[:space:]' < "$LAST_RESPONSE_FILE" | tail -c 1)
if [[ "$LAST_CHAR" == "?" ]]; then
exit 0
fi
fi
rm -f "$PENDING_FILE"
MODEL=$(jq -r '.model // "the configured advisor model"' "$STATE_FILE")
MESSAGE="[Advisor] Files changed since the last advisor consult and the turn ended without one. If this work is done, or you were about to declare it done, run the pre-completion consult now per the advisor skill: build the briefing, spawn the \`advisor-subagent\` subagent (model: $MODEL), act on the verdict, and report it in one line. If the change was trivial, or you are waiting on the user, say so in one line and stop."
jq -n --arg msg "$MESSAGE" '{"followup_message": $msg}'
exit 0