|
58 | 58 | # the GitHub Models API rate limit (≈15 requests/minute on |
59 | 59 | # the free tier). Example: DELAY_SECS=5 |
60 | 60 | # |
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 |
62 | 62 | # 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. |
63 | 65 | # Changes that are not user-facing (CI, build tooling, code style, routine |
64 | 66 | # dependency bumps) are omitted by the AI automatically. |
65 | 67 | # |
@@ -368,73 +370,6 @@ print("\n\n".join(parts), end="") |
368 | 370 | ' |
369 | 371 | } |
370 | 372 |
|
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 | | - |
438 | 373 | call_model_api() { |
439 | 374 | # Arguments: |
440 | 375 | # $1 current announcement text |
@@ -546,26 +481,19 @@ for row in $(jq -r '.[] | @base64' <<< "$PR_JSON"); do |
546 | 481 | continue |
547 | 482 | fi |
548 | 483 |
|
549 | | - # ── fetch and summarise the full PR thread ──────────────────────────── |
| 484 | + # ── fetch the full PR thread ─────────────────────────────────────────── |
550 | 485 | info "Fetching full PR thread for #${pr_number}…" |
551 | 486 | thread_text=$(fetch_pr_thread "$pr_number") || true |
552 | 487 | 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)." |
561 | 489 | else |
562 | 490 | info "Could not fetch full PR thread — using PR body only." |
563 | | - pr_summary="$pr_body" |
| 491 | + thread_text="$pr_body" |
564 | 492 | fi |
565 | 493 |
|
566 | 494 | # ── build the PR info block ──────────────────────────────────────────── |
567 | 495 | 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") |
569 | 497 |
|
570 | 498 | # ── call the AI ──────────────────────────────────────────────────────── |
571 | 499 | current_announcement=$(cat "$ANNOUNCEMENT_FILE") |
|
0 commit comments