-
Notifications
You must be signed in to change notification settings - Fork 0
ops(peer-call): tools/peer-call/grok.sh — Claude-Code-side caller for Grok via cursor-agent (task #301) #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,156 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||
| # tools/peer-call/grok.sh — Claude-Code-side caller for invoking Grok as a | ||||||||||||||||||||||||||||||||||||||||||||||||
| # peer reviewer via cursor-agent. Lives in Otto's lane (the | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Claude-Code-side invoker); the Grok-side response and Cursor-side | ||||||||||||||||||||||||||||||||||||||||||||||||
| # harness are owned by their respective agents per the multi-harness | ||||||||||||||||||||||||||||||||||||||||||||||||
| # named-agents project. Per Aaron 2026-04-26 "yall got to figure out | ||||||||||||||||||||||||||||||||||||||||||||||||
| # peer mode as peers" — no single agent owns the peer protocol; this | ||||||||||||||||||||||||||||||||||||||||||||||||
| # script is Otto's specific contribution to the collective. | ||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Usage: | ||||||||||||||||||||||||||||||||||||||||||||||||
| # tools/peer-call/grok.sh "prompt text" | ||||||||||||||||||||||||||||||||||||||||||||||||
| # tools/peer-call/grok.sh --thinking "prompt text" | ||||||||||||||||||||||||||||||||||||||||||||||||
| # tools/peer-call/grok.sh --file path/to/file.fs "prompt text" | ||||||||||||||||||||||||||||||||||||||||||||||||
| # tools/peer-call/grok.sh --context-cmd "git diff HEAD~3..HEAD" "prompt text" | ||||||||||||||||||||||||||||||||||||||||||||||||
| # tools/peer-call/grok.sh --json "prompt text" | ||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Routing: this script wraps `cursor-agent --print --model | ||||||||||||||||||||||||||||||||||||||||||||||||
| # grok-4-20-thinking` (default) or `grok-4-20` (with --fast flag). | ||||||||||||||||||||||||||||||||||||||||||||||||
| # The --print flag makes cursor-agent non-interactive (script-friendly). | ||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Per Aaron 2026-04-26 "don't copy paste / make sure you understand | ||||||||||||||||||||||||||||||||||||||||||||||||
| # and write our own" — this implementation is authored from | ||||||||||||||||||||||||||||||||||||||||||||||||
| # `cursor-agent --help` and `cursor-agent --list-models` output | ||||||||||||||||||||||||||||||||||||||||||||||||
| # (Grok models verified: grok-4-20, grok-4-20-thinking), not | ||||||||||||||||||||||||||||||||||||||||||||||||
| # transcribed from Grok ferry-14/16 example drafts. | ||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Per the four-ferry consensus (PR #24): Otto's role is "tests" not | ||||||||||||||||||||||||||||||||||||||||||||||||
| # "owns the peer protocol." This script is Otto's harness-side | ||||||||||||||||||||||||||||||||||||||||||||||||
| # contribution; the protocol convention is what we converge on | ||||||||||||||||||||||||||||||||||||||||||||||||
| # through use, as peers. | ||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Exit codes: | ||||||||||||||||||||||||||||||||||||||||||||||||
| # 0 — Grok responded successfully | ||||||||||||||||||||||||||||||||||||||||||||||||
| # 1 — invocation error (bad arguments, cursor-agent missing, etc.) | ||||||||||||||||||||||||||||||||||||||||||||||||
| # 2 — Grok returned a non-zero exit (response captured to stderr) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # 2 — Grok returned a non-zero exit (response captured to stderr) | |
| # 2 — cursor-agent returned a non-zero exit; output passes through |
Copilot
AI
Apr 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: usage() prints lines 2–28, but the header comment continues past line 28, so --help output is currently truncated mid-paragraph. Consider printing through the end of the header block (e.g., through the Exit codes section) or using start/end markers instead of hard-coded line numbers.
| sed -n '2,28p' "$0" | sed 's/^# \?//' | |
| sed -n '2,35p' "$0" | sed 's/^# \?//' |
Copilot
AI
Apr 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: head -c 20000 -- "$file" uses -- which is not portable to BSD head (macOS often errors on --). Consider using redirection (head -c 20000 <"$file") or omit -- to keep this script runnable on macOS.
| $(head -c 20000 -- "$file") | |
| $(head -c 20000 <"$file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail when file context cannot be read
The --file path is only validated with -f, then read via $(head -c 20000 -- "$file"); because set -e is not enabled, read failures do not abort the script and it can still return success with missing context. In permission/I/O failure cases this produces degraded or misleading peer-review input while signaling exit 0, so this branch should explicitly check readability and propagate head errors.
Useful? React with 👍 / 👎.
Copilot
AI
Apr 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P0: --context-cmd is executed via eval, which expands metacharacters and makes it easy to run something different than the caller intended (and is risky if the command string is constructed from other inputs). Prefer executing without eval (e.g., via bash -lc / sh -c, or by accepting the command as argv tokens) and clearly document that this flag runs a local command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unconditional --force from peer-review invocation
This script is framed as a read-only peer-review caller, but it always passes --force to cursor-agent; Cursor’s own CLI docs describe --force as allowing direct file changes without confirmation. That means a review call can unexpectedly auto-approve write/command actions (for example if mode/tool behavior changes or the model attempts tool use), which is risky for a tool intended to critique rather than mutate the workspace. Make forceful execution an explicit opt-in flag instead of the default.
Useful? React with 👍 / 👎.
Copilot
AI
Apr 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Passing --force to cursor-agent disables its permission prompts; that’s a sharp edge for a tool that may have file/command capabilities depending on Cursor configuration. Consider making --force opt-in (a separate flag) or using a documented “read-only/no-tools” mode if cursor-agent supports it.
| # --force/--yolo so cursor-agent doesn't prompt for command-permission | |
| # (Grok is read-only here; not running shell commands). | |
| exit_code=0 | |
| cursor-agent \ | |
| --print \ | |
| --model "$model" \ | |
| --output-format "$output_format" \ | |
| --mode ask \ | |
| --force \ | |
| -- "$full_prompt" || exit_code=$? | |
| # Keep Cursor permission prompts enabled by default. Callers that need the | |
| # previous non-interactive behaviour must opt in with CURSOR_AGENT_FORCE=1. | |
| exit_code=0 | |
| cursor_agent_args=( | |
| --model "$model" | |
| --output-format "$output_format" | |
| --mode ask | |
| ) | |
| if [ "${CURSOR_AGENT_FORCE:-0}" = "1" ]; then | |
| cursor_agent_args+=(--force) | |
| fi | |
| cursor-agent "${cursor_agent_args[@]}" -- "$full_prompt" || exit_code=$? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: This script includes personal-name attribution for the human maintainer (e.g., "Per Aaron …") in header comments and the prompt preamble. Repo guidance asks to avoid contributor personal names in code/docs and use role refs (e.g., "human maintainer") instead; please replace these mentions accordingly (persona agent names like Otto/Grok are fine).