auto-update-daily-20260202
1#!/usr/bin/env bash
2# Review a GitHub PR/issue with Claude on a remote machine via shpool
3# Usage: gh-news-review [-d|--detach] [-y|--yolo] <url>
4# -d, --detach Start session in background and return immediately
5# -y, --yolo Skip permission prompts (auto-accept all tool calls)
6
7set -euo pipefail
8
9DETACH=false
10YOLO=false
11
12while [[ $# -gt 0 ]]; do
13 case "$1" in
14 -d | --detach)
15 DETACH=true
16 shift
17 ;;
18 -y | --yolo)
19 YOLO=true
20 shift
21 ;;
22 -*)
23 echo "Unknown option: $1" >&2
24 echo "Usage: gh-news-review [-d|--detach] [-y|--yolo] <url>" >&2
25 exit 1
26 ;;
27 *)
28 break
29 ;;
30 esac
31done
32
33URL="${1:-}"
34if [[ -z "$URL" ]]; then
35 echo "Usage: gh-news-review [-d|--detach] [-y|--yolo] <url>" >&2
36 exit 1
37fi
38
39# Extract session name from URL (e.g., pull-123 or issues-456)
40SESSION_NAME="review-$(echo "$URL" | grep -oE '(pull|issues)/[0-9]+' | tr '/' '-')"
41
42if [[ -z "$SESSION_NAME" || "$SESSION_NAME" == "review-" ]]; then
43 echo "Error: Could not extract PR/issue number from URL: $URL" >&2
44 exit 1
45fi
46
47# Detect if this is a nixpkgs PR for more specific instructions
48IS_NIXPKGS=false
49if [[ "$URL" == *"NixOS/nixpkgs"* ]]; then
50 IS_NIXPKGS=true
51fi
52
53# Build the prompt based on the type of review
54if [[ "$IS_NIXPKGS" == "true" ]]; then
55 PROMPT="Review $URL using the Nixpkgs skill (~/.config/claude/skills), and the Review workflow. Use GPT-5.2-Codex or Opus 4.5 model if available.
56
57For nixpkgs PRs:
581. Load and follow the Nixpkgs skill workflow
592. Use nixpkgs-review to build and test the changes when appropriate
603. When approving, use a concise message (e.g., 'LGTM, tested with nixpkgs-review')
614. If I'm a maintainer of the touched packages, use the auto-merge-pr script to build, approve, and trigger merge-bot
62
63At the end, save the session (in ~/.config/claude/history/sessions/)"
64else
65 PROMPT="Review $URL, and load the proper skill as needed (e.g. nixpkgs skills and workflows if it is a pr from NixOS/nixpkgs)"
66fi
67
68# Build cr command with optional yolo mode
69CR_CMD="cr"
70if [[ "$YOLO" == "true" ]]; then
71 CR_CMD="cr --dangerously-skip-permissions"
72fi
73
74# Encode prompt in base64 to avoid all quoting issues
75PROMPT_B64=$(printf '%s' "$PROMPT" | base64 -w0)
76
77if [[ "$DETACH" == "true" ]]; then
78 # Write a temp script on remote and execute it in shpool
79 # Using heredoc avoids all nested quoting issues
80 # shellcheck disable=SC2029,SC2087 # Intentional client-side expansion
81 ssh aomi.sbr.pm "cat > /tmp/review-cmd-$SESSION_NAME.sh && chmod +x /tmp/review-cmd-$SESSION_NAME.sh && nohup shpool attach -f -c '/run/current-system/sw/bin/bash -l /tmp/review-cmd-$SESSION_NAME.sh' $SESSION_NAME > /dev/null 2>&1 &" <<EOF
82cd ~/src/nixpkgs
83$CR_CMD "\$(echo '$PROMPT_B64' | base64 -d)"
84EOF
85 echo "Started review session: $SESSION_NAME"
86 echo "Attach with: ssh -t aomi.sbr.pm 'shpool attach $SESSION_NAME'"
87else
88 # Interactive: write temp script and run
89 # shellcheck disable=SC2029,SC2087 # Intentional client-side expansion
90 ssh aomi.sbr.pm "cat > /tmp/review-cmd-$SESSION_NAME.sh && chmod +x /tmp/review-cmd-$SESSION_NAME.sh" <<EOF
91cd ~/src/nixpkgs
92$CR_CMD "\$(echo '$PROMPT_B64' | base64 -d)"
93EOF
94 exec ssh -t aomi.sbr.pm "shpool attach -f -c '/run/current-system/sw/bin/bash -l /tmp/review-cmd-$SESSION_NAME.sh' $SESSION_NAME"
95fi