86d53cdf126afa937f42a7571ee4e1bcb8e8c2bd
- Author
- TheEdgeOfRage <git@theedgeofrage.com>
- Committer
- TheEdgeOfRage <git@theedgeofrage.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/dot_local/bin/executable_pkgbuild-review b/dot_local/bin/executable_pkgbuild-review
2index 11f2366f483bb3d4d9b603f34c95f2c9cf4bab23..8efcaeab499980173f90f9e46c75b8eb5c91bd9a 100755
3--- a/dot_local/bin/executable_pkgbuild-review
4+++ b/dot_local/bin/executable_pkgbuild-review
5@@ -45,9 +45,9 @@ err() { printf 'pkgbuild-review: %s\n' "$*" >&2; }
6
7 verdict_color() {
8 case "$1" in
9- SAFE) printf '%s' "$GREEN" ;;
10+ SAFE) printf '%s' "$GREEN" ;;
11 SUSPICIOUS) printf '%s' "$YELLOW" ;;
12- *) printf '%s' "$RED" ;;
13+ *) printf '%s' "$RED" ;;
14 esac
15 }
16
17@@ -59,98 +59,109 @@ confidence_color() {
18 esac
19 }
20
21-[[ $# -lt 1 ]] && { err "usage: pkgbuild-review <path>"; exit 3; }
22-pkgbuild="$1"
23-
24-# Non-PKGBUILD files (e.g. .SRCINFO): open real editor and exit
25-if [[ "$(basename "$pkgbuild")" != "PKGBUILD" ]]; then
26- exec "$REAL_EDITOR" "$pkgbuild"
27-fi
28-
29-[[ -f "$pkgbuild" ]] || { err "file not found: $pkgbuild"; exit 3; }
30-
31-pkgname=$(grep -m1 '^pkgname=' "$pkgbuild" | cut -d= -f2 | tr -d '"'"'"' ')
32-pkgver=$(grep -m1 '^pkgver=' "$pkgbuild" | cut -d= -f2 | tr -d '"'"'"' ')
33-sha=$(sha256sum "$pkgbuild" | cut -d' ' -f1)
34-cache_file="$CACHE_DIR/$pkgname.sha256"
35-
36-if [[ -f "$cache_file" ]] && [[ "$(cat "$cache_file")" == "$sha" ]]; then
37- printf '[%s %s] Already reviewed. Proceeding.\n' "$pkgname" "$pkgver"
38- exit 0
39-fi
40-
41-printf '[%s %s] Sending to LLM for review...\n' "$pkgname" "$pkgver"
42-
43-payload=$(jq -n \
44- --arg model "$MODEL" \
45- --arg sys "$SYSTEM_PROMPT" \
46- --arg content "$(cat "$pkgbuild")" \
47- '{model: $model, temperature: 0, stream: false,
48- messages: [
49- {role: "system", content: $sys},
50- {role: "user", content: ("Review this PKGBUILD:\n\n<pkgbuild>\n" + $content + "\n</pkgbuild>")}
51- ]}')
52-
53-response=$(curl -sf --max-time 300 \
54- -H "Content-Type: application/json" \
55- -d "$payload" \
56- "$SERVER_URL/v1/chat/completions") || { err "llama-server unreachable or timed out"; exit 2; }
57-
58-content=$(printf '%s' "$response" | jq -r '.choices[0].message.content // empty')
59-[[ -z "$content" ]] && { err "empty response from LLM"; exit 2; }
60-
61-# Strip <think>...</think> block if present (Qwen3.5 thinking mode)
62-content=$(printf '%s' "$content" | sed '/^<think>$/,/^<\/think>$/d')
63-
64-verdict=$(printf '%s' "$content" | grep '^VERDICT:' | awk '{print $2}' | head -1)
65-confidence=$(printf '%s' "$content" | grep '^CONFIDENCE:' | awk '{print $2}' | head -1)
66-[[ -z "$verdict" ]] && verdict="UNKNOWN"
67-
68-printf '\n=== PKGBUILD Review: %s %s ===\n' "$pkgname" "$pkgver"
69-vc=$(verdict_color "$verdict")
70-cc=$(confidence_color "$confidence")
71-while IFS= read -r line; do
72- case "$line" in
73- VERDICT:*) printf "${vc}%s${RESET}\n" "$line" ;;
74- CONFIDENCE:*) printf "${cc}%s${RESET}\n" "$line" ;;
75- *) printf '%s\n' "$line" ;;
76- esac
77-done <<< "$content"
78-printf '=== END REVIEW ===\n\n'
79-
80-while true; do
81- case "$verdict" in
82- SAFE) printf "[%s] ${vc}SAFE${RESET} — [C]ontinue / [e]dit / [a]bort: " "$pkgname" ;;
83- *) printf "[%s] ${vc}%s${RESET} — [c]ontinue / [e]dit / [A]bort: " "$pkgname" "$verdict" ;;
84- esac
85-
86- read -r choice
87-
88- case "${choice,,}" in
89- c)
90- if [[ "$verdict" != "SAFE" ]]; then
91- printf 'Verdict is %s. Type "yes" to override: ' "$verdict"
92- read -r confirm
93- [[ "$confirm" != "yes" ]] && continue
94- fi
95- mkdir -p "$CACHE_DIR"
96- printf '%s' "$sha" > "$cache_file"
97- exit 0
98- ;;
99- "")
100- if [[ "$verdict" == "SAFE" ]]; then
101+review_one() {
102+ local pkgbuild="$1"
103+
104+ # Non-PKGBUILD files (e.g. .SRCINFO): open real editor and return