Skip to content

Commit a5c4f1c

Browse files
committed
VSCode CoPilot changes
1 parent 0e0f076 commit a5c4f1c

1 file changed

Lines changed: 7 additions & 79 deletions

File tree

tools/backfill-release-announcement.sh

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@
5858
# the GitHub Models API rate limit (≈15 requests/minute on
5959
# the free tier). Example: DELAY_SECS=5
6060
#
61-
# The script calls the GitHub Models API (openai/gpt-4o-mini) to produce a
61+
# The script calls the GitHub Models API (openai/gpt-4o) to produce a
6262
# user-friendly summary for each PR and adds it to the announcement document.
63+
# For each PR, it fetches the full discussion thread (body, comments, reviews)
64+
# and feeds it directly to the AI along with the current announcement.
6365
# Changes that are not user-facing (CI, build tooling, code style, routine
6466
# dependency bumps) are omitted by the AI automatically.
6567
#
@@ -368,73 +370,6 @@ print("\n\n".join(parts), end="")
368370
'
369371
}
370372

371-
# summarize_pr_thread PR_NUMBER PR_TITLE PR_AUTHOR THREAD_TEXT
372-
# Calls the AI to produce a concise factual summary of the full PR thread.
373-
# Prints the summary to stdout. Returns 1 on failure.
374-
summarize_pr_thread() {
375-
local pr_number="$1"
376-
local pr_title="$2"
377-
local pr_author="$3"
378-
local thread_text="$4"
379-
380-
local summary_prompt
381-
summary_prompt='You are a technical writer summarising a GitHub Pull Request for use in a release announcement.
382-
383-
Given the full PR thread below (description, discussion comments, and code reviews), write a concise factual summary (under 300 words) that captures:
384-
1. **What changed**: the concrete code/feature/behaviour change in its final form
385-
2. **Why**: the motivation or problem being solved
386-
3. **User impact**: how this affects people who use the software
387-
388-
Focus on the FINAL outcome, not the evolution of the discussion. If reviewers suggested changes that were adopted, describe the end result, not the back-and-forth.
389-
390-
Ignore: CI bot comments, merge-conflict chatter, style nits, "LGTM" reviews without substantive body text, and process comments (like labelling or milestone changes).'
391-
392-
local user_content
393-
user_content=$(printf 'PR #%s — %s\nby @%s\n\nFull PR thread:\n%s' \
394-
"$pr_number" "$pr_title" "$pr_author" "$thread_text")
395-
396-
local payload
397-
payload=$(jq -n \
398-
--arg model "$MODEL" \
399-
--arg system "$summary_prompt" \
400-
--arg user "$user_content" \
401-
'{
402-
model: $model,
403-
messages: [
404-
{ role: "system", content: $system },
405-
{ role: "user", content: $user }
406-
],
407-
max_completion_tokens: 2048,
408-
temperature: 0.1
409-
}')
410-
411-
local tmpfile http_code response summary
412-
tmpfile=$(mktemp)
413-
http_code=$(curl -s \
414-
-o "$tmpfile" \
415-
-w '%{http_code}' \
416-
-X POST "$MODELS_ENDPOINT" \
417-
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
418-
-H "Content-Type: application/json" \
419-
-d "$payload") 2>/dev/null || true
420-
421-
response=$(cat "$tmpfile" 2>/dev/null || true)
422-
rm -f "$tmpfile"
423-
424-
if [[ "$http_code" != "200" ]]; then
425-
warn "HTTP ${http_code} from Models API during PR thread summarisation."
426-
return 1
427-
fi
428-
429-
summary=$(jq -r '.choices[0].message.content // empty' <<< "$response")
430-
if [[ -z "$summary" ]]; then
431-
warn "Model returned empty summary."
432-
return 1
433-
fi
434-
435-
printf '%s' "$summary"
436-
}
437-
438373
call_model_api() {
439374
# Arguments:
440375
# $1 current announcement text
@@ -546,26 +481,19 @@ for row in $(jq -r '.[] | @base64' <<< "$PR_JSON"); do
546481
continue
547482
fi
548483

549-
# ── fetch and summarise the full PR thread ────────────────────────────
484+
# ── fetch the full PR thread ───────────────────────────────────────────
550485
info "Fetching full PR thread for #${pr_number}"
551486
thread_text=$(fetch_pr_thread "$pr_number") || true
552487
if [[ -n "$thread_text" ]]; then
553-
info "Fetched PR thread ($(printf '%s' "$thread_text" | wc -c | tr -d ' ') bytes). Summarising…"
554-
pr_summary=$(summarize_pr_thread "$pr_number" "$pr_title" "$pr_author" "$thread_text") || true
555-
if [[ -z "$pr_summary" ]]; then
556-
info "Could not summarise PR thread — using PR body only."
557-
pr_summary="$pr_body"
558-
else
559-
info "Generated PR thread summary."
560-
fi
488+
info "Fetched PR thread ($(printf '%s' "$thread_text" | wc -c | tr -d ' ') bytes)."
561489
else
562490
info "Could not fetch full PR thread — using PR body only."
563-
pr_summary="$pr_body"
491+
thread_text="$pr_body"
564492
fi
565493

566494
# ── build the PR info block ────────────────────────────────────────────
567495
pr_info=$(printf 'PR #%s — %s\nby @%s\n\n%s\n' \
568-
"$pr_number" "$pr_title" "$pr_author" "$pr_summary")
496+
"$pr_number" "$pr_title" "$pr_author" "$thread_text")
569497

570498
# ── call the AI ────────────────────────────────────────────────────────
571499
current_announcement=$(cat "$ANNOUNCEMENT_FILE")

0 commit comments

Comments
 (0)