Files
cursor__plugins/advisor/hooks/stop-hook.sh
Cursor Agent 6c0b9713f6 feat(advisor): add Advisor plugin for stronger-model consults at key checkpoints
Cursor counterpart of Claude Code's /advisor. The main model consults a
stronger (or different) model before major decisions, when stuck on an
error, and before declaring a task done; the advisor gets a full briefing
plus the transcript path and returns a verdict with guidance.

- 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 claude-opus-5[effort=xhigh]
  by default, overridable per session via the Task model parameter
- hooks: track edits since the last consult, log consults to
  .cursor/advisor/log.md, nudge a pre-completion consult once per batch
  of edits (quiet when the agent ended on a question for the user)
- register in marketplace.json and the root README

Co-authored-by: Eric Zakariasson <ericzakariasson@users.noreply.github.com>
2026-09-04 11:39:23 +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