clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

main
forge / test / scenarios / critique-fix.sh
critique-fix.sh 2.1K
1# forge critique --fix: what the reviewer changes in the worktree becomes a2# commit on <user>/fix-<id>, stacked on the review. Files Jev judged3# mechanical stay out of the diff, and the reviewer is told which.4. "$(dirname "$0")/../lib.sh"5user dami6user ana7repo dami/greet8G=$FORGE_ROOT/dami/greet.git9clone dami dami/greet "$T/w/seed"10mkdir -p "$T/w/seed/.forge"11cat >"$T/w/seed/.forge/review" <<'EOF'12#!/bin/sh13echo '{"model":"fixer"}'14grep -q '^+++ b/package-lock.json' && echo "the mechanical file is in the diff" >&215echo "skipped: $(cat "$FORGE_REVIEW_SKIPPED")" >&216if [ "$FORGE_REVIEW_FIX" = 1 ] && grep -q 'eval' run.sh; then17 sed 's/eval "\$1"/sh -c "$1"/' run.sh >run.sh.new && mv run.sh.new run.sh18 echo '{"severity":"note","path":"run.sh","line":1,"body":"replaced eval; see the fix branch"}'19fi20EOF21chmod +x "$T/w/seed/.forge/review"22echo '{}' >"$T/w/seed/package-lock.json"23at "$T/w/seed" commit "seed" README24ok push_as dami "$T/w/seed" origin main2526clone_ssh ana dami/greet "$T/w/a"27cl() { (cd "$T/w/a" && FORGE_USER=ana GIT_SSH_COMMAND="$T/ssh" "$FORGE" "$@"); }28at "$T/w/a" git switch -q -c ana/run29printf 'eval "$1"\n' >"$T/w/a/run.sh"30old=$(git -C "$T/w/a" rev-parse HEAD:package-lock.json)31echo '{"v":2}' >"$T/w/a/package-lock.json"32at "$T/w/a" git add -A33at "$T/w/a" git commit -q -m "run"34new=$(git -C "$T/w/a" rev-parse HEAD:package-lock.json)35mkdir -p "$G/forge/jev/file.v1"36printf '{"model":"t","at":0,"answers":{"mechanical":{"noul":0.96}},"tokens":null}' >"$G/forge/jev/file.v1/$old.$new"37ok push_as ana "$T/w/a" origin ana/run38build dami/greet3940ok cl critique --fix41lacks "$T_LOG" 'the mechanical file is in the diff'42has "$T_LOG" 'skipped: package-lock.json'43has "$T_LOG" "the reviewer's fixes are on ana/fix-1, stacked on #1"44eq "$(git --git-dir="$G" show ana/fix-1:run.sh)" 'sh -c "$1"'45eq "$(git --git-dir="$G" rev-parse ana/fix-1^)" "$(git --git-dir="$G" rev-parse ana/run)"46eq "$(git --git-dir="$G" log -1 --format=%s ana/fix-1)" "Fix what the agent review of #1 found"47# The review itself is untouched.48eq "$(git --git-dir="$G" show ana/run:run.sh)" 'eval "$1"'