penpot/.github/scripts/pr-review/run-opencode.sh
Michael Panchenko aab5a4752f
✨ Add on-demand pull request reviews (#13272)
* ✨ Add on-demand pull request reviews

Run Claude Code, Copilot CLI and OpenCode Go from PR slash commands in the
official development image. Let maintainers configure a default model and
effort for each reviewer and override both in a comment. Configure MCP
for code navigation and reply to inline questions in their original thread.

AI-assisted-by: gpt-6
Signed-off-by: Michael Panchenko <michael.panchenko@oraios-ai.de>

* ✨ Add a local runner for pull request reviews

Run the CI review scripts for a PR on a local machine and print the
review instead of posting it. Use the local Claude login when no OAuth
token is set, start Serena through uvx when it is not installed, and
show OpenCode errors when it returns no answer.

AI-assisted-by: claude-opus-5-5

* ✨ Add /review and default OpenCode to DeepSeek V4.1 Flash

Accept /review at the start of a comment as an alias for /oc with the
repository defaults, and keep the typed command as the native agent's
mention. Use deepseek-v4.1-flash when no OPENCODE_MODEL is configured.

AI-assisted-by: claude-opus-5-5

* 🔧 Default OpenCode reviews to high effort

Use high effort for DeepSeek V4.1 Flash when no OPENCODE_EFFORT is
configured, in CI and in the local runner.

AI-assisted-by: claude-opus-5-5

---------

Signed-off-by: Michael Panchenko <michael.panchenko@oraios-ai.de>
Co-authored-by: alonso.torres <alonso.torres@kaleidos.net>
2026-11-25 14:56:11 +01:00

10 lines
420 B
Bash

#!/usr/bin/env bash
set -euo pipefail
context="$RUNNER_TEMP/review"
: "${OPENCODE_GO_API_KEY:?Set the OPENCODE_GO_API_KEY Actions secret}"
variant=()
[[ $EFFORT == default ]] || variant=(--variant "$EFFORT")
opencode run --pure --model "$MODEL" "${variant[@]}" --format json < "$context/prompt" |
jq -ers '[.[] | select(.type == "text") | .part.text] | last // error("OpenCode returned no text")' > "$context/answer"