Files
werkrevisor/tools/dry-run
mhoennigandClaude Opus 5.5 04461a274a werkrevisor 0.5.0: Jev judges the sections and Gherkin scenarios of the PR documents
[engine] mode chooses the review: "llm" (default, unchanged), "classifier" (Jev alone, no LLM)
or "combined" (Jev, then the LLM with Jev's flagged units as hints in the user prompt).
werkrevisor splits each changed PR document into ##/### sections and #### Scenario units,
asks Jev once per unit with the operator's questions, and maps every answer to a problem value:
each question asks for a problem, a score runs from "no problem" to "worst problem".
A clear spec problem is RED, a doubtful one or an oversized unit YELLOW, a Jev error ERROR.
The hints carry file, line, scenario id, question and value, but no PR text.
tools/jev-eval measures the questions offline on local PR documents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 11:18:47 +02:00

44 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Usage: tools/dry-run [-h] <pr-url> [config] [--llm]
#
# Reviews a real Gitea PR without writing to Gitea (--no-publish), also a merged or closed one.
# Without --llm it applies the deterministic rules only (--no-llm) and needs no OpenRouter key.
# With --llm it calls the model and costs money.
# Needs GITEA_BOT_TOKEN (read access is enough) and, with --llm, OPENROUTER_API_KEY in the environment;
# with --llm and an [engine] mode other than "llm" also TYPESAFE_API_KEY.
# The default config is config/hsadmin-ng.toml; a set WERKREVISOR_CONFIG_TOML wins over it.
# Usage lines are appended to build/werkrevisor/usage.jsonl for later measurement.
#
# Example:
# tools/dry-run https://git.example.org/owner/repo/pulls/302
set -euo pipefail
if [[ $# -lt 1 || "$1" =~ ^(-h|-\?|--help)$ ]]; then
awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$0"
exit 0
fi
image="pragent/pr-agent@sha256:7d98954c29289846a08faf00aaea0f1f1375b1676cd8a2ed303e0af07010af7a"
pr_url="$1"
config="${2:-config/hsadmin-ng.toml}"
: "${GITEA_BOT_TOKEN:?GITEA_BOT_TOKEN must be set}"
# Secrets are passed by name, so their values never appear in the process list.
docker_env=(-e GITEA_BOT_TOKEN)
# An inline operator config wins over the config file argument, as in production.
[[ -n "${WERKREVISOR_CONFIG_TOML:-}" ]] && docker_env+=(-e WERKREVISOR_CONFIG_TOML)
werkrevisor_args=(--no-llm)
if [[ "${3:-}" == "--llm" ]]; then
: "${OPENROUTER_API_KEY:?OPENROUTER_API_KEY must be set for --llm}"
docker_env+=(-e OPENROUTER_API_KEY)
[[ -n "${TYPESAFE_API_KEY:-}" ]] && docker_env+=(-e TYPESAFE_API_KEY)
werkrevisor_args=()
fi
mkdir -p build/werkrevisor
docker run --rm \
-v "$PWD":/werkrevisor:ro -v "$PWD/build":/work/build -w /work \
-e PYTHONPATH=/werkrevisor:/app -e PYTHONDONTWRITEBYTECODE=1 -e PYTHONNOUSERSITE=1 \
"${docker_env[@]}" \
--entrypoint python "$image" \
-s -m werkrevisor --config "/werkrevisor/$config" --pr-url "$pr_url" --no-publish --allow-closed "${werkrevisor_args[@]}"