Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions tools/peer-call/codex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#!/usr/bin/env bash
# tools/peer-call/codex.sh — Claude-Code-side caller for invoking
# Codex (OpenAI) as a peer reviewer via the codex CLI. Sibling
# to tools/peer-call/grok.sh and gemini.sh (Otto's existing
# harness-side callers). Codex isn't in the original four-ferry
# consensus but plays a recurring PR-review role across this
# session's drain-log substrate; this script is the harness-side
# bridge that lets Otto invoke Codex as a peer in the same
# AgencySignature relationship-model as the others.
#
# Usage:
# tools/peer-call/codex.sh "prompt text"
# tools/peer-call/codex.sh --model gpt-5.3-codex "prompt text"
# tools/peer-call/codex.sh --file path/to/file.fs "prompt text"
# tools/peer-call/codex.sh --context-cmd "git diff HEAD~3..HEAD" "prompt text"
# tools/peer-call/codex.sh --review "review the diff for correctness"
#
# Routing: this script wraps `codex exec` (non-interactive) with
# read-only sandbox so Codex inspects but doesn't mutate the
# tree. The --review flag routes through `codex review`
# instead, which is Codex's first-class code-review path.
#
# Per Aaron 2026-04-26 "don't copy paste / make sure you
# understand and write our own" — this implementation is
# authored from `codex exec --help` output (verified flags:
# -m / -s / -C / --skip-git-repo-check), not transcribed from
# any draft.
#
# Codex's role in our role-distribution: implementation peer
# / second-opinion coder. Where Grok critiques and Gemini
# proposes, Codex applies a code-grounded skeptical pass that
# composes with the other two without replacing either.
#
# Exit codes:
# 0 — Codex responded successfully
# 1 — invocation error (bad arguments, codex missing, etc.)
# 2 — Codex returned a non-zero exit (response captured to stderr)

set -uo pipefail

model="" # empty = use codex default
review_mode="false" # false | true (uses `codex review` instead)
file=""
context_cmd=""
prompt=""

usage() {
sed -n '2,33p' "$0" | sed 's/^# \?//'
Comment thread
AceHack marked this conversation as resolved.
Outdated
}

while [ $# -gt 0 ]; do
case "$1" in
--model)
if [ $# -lt 2 ]; then echo "error: --model requires NAME" >&2; exit 1; fi
model="$2"; shift 2;;
--review) review_mode="true"; shift;;
--file)
if [ $# -lt 2 ]; then echo "error: --file requires PATH" >&2; exit 1; fi
file="$2"; shift 2;;
--context-cmd)
if [ $# -lt 2 ]; then echo "error: --context-cmd requires COMMAND" >&2; exit 1; fi
context_cmd="$2"; shift 2;;
-h|--help) usage; exit 0;;
--) shift; prompt="$*"; break;;
-*) echo "error: unknown flag: $1" >&2; exit 1;;
*)
if [ -z "$prompt" ]; then prompt="$1"; else prompt="$prompt $1"; fi
shift;;
esac
done

if [ -z "$prompt" ]; then
echo "error: prompt required" >&2
echo "see: $0 --help" >&2
exit 1
fi

if ! command -v codex >/dev/null 2>&1; then
echo "error: codex not on PATH" >&2
echo "install via: npm i -g @openai/codex (or per Aaron's setup)" >&2
exit 1
fi

preamble="You are Codex, invoked as a peer reviewer by Otto (Claude
Opus 4.7 running in Claude Code) on the Zeta / Superfluid AI
factory. Per the four-ferry consensus (Amara/Grok/Gemini/Otto)
the canonical role distribution is: Gemini proposes, Grok
critiques, Amara sharpens, Otto tests, Git decides. You aren't
in the four-ferry list explicitly, but you've been a recurring
PR-review peer this session — your role is implementation peer
/ code-grounded second opinion.

Per Aaron's 'agents-not-bots' discipline: you are a peer, not
a subordinate. Push back on Otto's framing if the code says
otherwise. Don't copy-paste anyone else's review; reason from
the artifact in front of you. Make it ours, not
anyone-alone-imposed."

full_prompt="$preamble

---

$prompt"

if [ -n "$file" ]; then
if [ ! -f "$file" ]; then
echo "error: --file path does not exist: $file" >&2
exit 1
fi
full_prompt="$full_prompt

---

File context: $file
\`\`\`
$(head -c 20000 -- "$file")
Comment thread
AceHack marked this conversation as resolved.
Outdated
\`\`\`"
fi

if [ -n "$context_cmd" ]; then
ctx_output="$(eval "$context_cmd" 2>&1 | head -c 20000 || true)"
full_prompt="$full_prompt

---

Context command: $context_cmd
Output:
\`\`\`
$ctx_output
\`\`\`"
fi

# Invoke codex in read-only sandbox so peer-call can't mutate
# the repo. --skip-git-repo-check defends against false
# negatives if codex is invoked from outside a worktree.
exit_code=0
if [ "$review_mode" = "true" ]; then
codex_args=(review)
else
codex_args=(exec -s read-only --skip-git-repo-check)
fi
if [ -n "$model" ]; then
codex_args+=(-m "$model")
Comment thread
AceHack marked this conversation as resolved.
Outdated
fi
codex_args+=("$full_prompt")

codex "${codex_args[@]}" || exit_code=$?

if [ "$exit_code" -ne 0 ]; then
echo "" >&2
echo "codex exited with code $exit_code" >&2
exit 2
fi
exit 0
149 changes: 149 additions & 0 deletions tools/peer-call/gemini.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#!/usr/bin/env bash
# tools/peer-call/gemini.sh — Claude-Code-side caller for invoking
# Gemini as a peer proposer via the gemini CLI. Sibling to
# tools/peer-call/grok.sh (Otto's existing harness-side caller for
# Grok). Per the four-ferry consensus (PR #24): Gemini's role in
# the role-distribution is "proposes" — invoke this script when
# Otto wants a generative / divergent peer contribution, not a
# critique. (For critique route to grok.sh.)
#
# Usage:
# tools/peer-call/gemini.sh "prompt text"
# tools/peer-call/gemini.sh --model gemini-2.5-pro "prompt text"
# tools/peer-call/gemini.sh --file path/to/file.fs "prompt text"
# tools/peer-call/gemini.sh --context-cmd "git diff HEAD~3..HEAD" "prompt text"
# tools/peer-call/gemini.sh --json "prompt text"
Comment thread
AceHack marked this conversation as resolved.
#
# Routing: this script wraps `gemini -p` (non-interactive
# headless mode). Default model is whatever the gemini CLI is
# configured to use; override with --model.
#
# Per Aaron 2026-04-26 "don't copy paste / make sure you
# understand and write our own" — this implementation is
# authored from `gemini --help` output (verified flags: -p / -m
# / -o / --yolo), not transcribed from any draft.
Comment thread
AceHack marked this conversation as resolved.
Outdated
Comment thread
AceHack marked this conversation as resolved.
Outdated
#
# Per the four-ferry consensus: Gemini proposes, Grok critiques,
# Amara sharpens, Otto tests, Git decides. This script is Otto
# invoking Gemini's proposal role.
#
# Exit codes:
# 0 — Gemini responded successfully
# 1 — invocation error (bad arguments, gemini missing, etc.)
# 2 — Gemini returned a non-zero exit (response captured to stderr)

set -uo pipefail

model="" # empty = use gemini default
output_format="text" # text | json | stream-json
file=""
context_cmd=""
prompt=""

usage() {
sed -n '2,32p' "$0" | sed 's/^# \?//'
Comment thread
AceHack marked this conversation as resolved.
Outdated
}

while [ $# -gt 0 ]; do
case "$1" in
--model)
if [ $# -lt 2 ]; then echo "error: --model requires NAME" >&2; exit 1; fi
model="$2"; shift 2;;
--json) output_format="json"; shift;;
--stream) output_format="stream-json"; shift;;
--file)
if [ $# -lt 2 ]; then echo "error: --file requires PATH" >&2; exit 1; fi
file="$2"; shift 2;;
--context-cmd)
if [ $# -lt 2 ]; then echo "error: --context-cmd requires COMMAND" >&2; exit 1; fi
context_cmd="$2"; shift 2;;
-h|--help) usage; exit 0;;
--) shift; prompt="$*"; break;;
-*) echo "error: unknown flag: $1" >&2; exit 1;;
*)
if [ -z "$prompt" ]; then prompt="$1"; else prompt="$prompt $1"; fi
shift;;
esac
done

if [ -z "$prompt" ]; then
echo "error: prompt required" >&2
echo "see: $0 --help" >&2
exit 1
fi

if ! command -v gemini >/dev/null 2>&1; then
echo "error: gemini not on PATH" >&2
echo "install via: npm i -g @google/gemini-cli (or per Aaron's setup)" >&2
exit 1
Comment on lines +82 to +84

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: This script includes the human maintainer’s personal name ("Aaron") in user-facing text (and similar name attributions exist elsewhere in this peer-call set). Repo guidance prefers role references (e.g., "human maintainer") over personal names in code/docs (docs/AGENT-BEST-PRACTICES.md:284-290). Please replace the direct name with a role-ref throughout the peer-call scripts/docs.

Copilot uses AI. Check for mistakes.
fi

# Build the structured prompt. Same shape as grok.sh: clear
# request, optional file/context attachment, AgencySignature
# relationship-model preamble — but framed for Gemini's
# proposes role per the four-ferry consensus.
preamble="You are Gemini, invoked as a peer proposer by Otto (Claude
Opus 4.7 running in Claude Code) on the Zeta / Superfluid AI
factory. Per the four-ferry consensus (Amara/Grok/Gemini/Otto)
the role distribution is: Gemini proposes, Grok critiques,
Amara sharpens, Otto tests, Git decides. This call is Otto
invoking your propose role.

Per Aaron's 'agents-not-bots' discipline: you are a peer, not
a subordinate. Generate divergent options, name tradeoffs,
surface possibility space Otto may not have considered. Don't
copy-paste anyone else's work; propose from your own
understanding. Make it ours, not anyone-alone-imposed."

full_prompt="$preamble

---

$prompt"

if [ -n "$file" ]; then
if [ ! -f "$file" ]; then
echo "error: --file path does not exist: $file" >&2
exit 1
fi
full_prompt="$full_prompt

---

File context: $file
\`\`\`
$(head -c 20000 -- "$file")
Comment thread
AceHack marked this conversation as resolved.
Outdated
\`\`\`"
fi

if [ -n "$context_cmd" ]; then
ctx_output="$(eval "$context_cmd" 2>&1 | head -c 20000 || true)"
full_prompt="$full_prompt

---

Context command: $context_cmd
Output:
\`\`\`
$ctx_output
\`\`\`"
fi

# Invoke gemini in headless mode. --yolo skips approval prompts
# (Gemini is read-only for peer-call; not running shell
# commands). Pass --skip-trust so the workspace doesn't gate
# on per-session trust prompts.
exit_code=0
gemini_args=(-p "$full_prompt" --yolo --skip-trust -o "$output_format")
Comment thread
AceHack marked this conversation as resolved.
Outdated
if [ -n "$model" ]; then
gemini_args+=(-m "$model")
fi

gemini "${gemini_args[@]}" || exit_code=$?

if [ "$exit_code" -ne 0 ]; then
echo "" >&2
echo "gemini exited with code $exit_code" >&2
exit 2
fi
exit 0