From 98575cb70e78376751b435858ef0a8cd23c3c35f Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Thu, 26 Nov 2026 18:19:06 +0000 Subject: [PATCH] ci/llm-agents: List version changes in the PR body Show the installed version changes as a table in the update PR's description, with a link to the upstream comparison, rather than pointing reviewers at the commit message. The updater rewrites the description of an existing PR whenever it no longer matches. Co-Authored-By: Claude Opus 5.5 --- ci/update-llm-agents.py | 66 +++++++++++++++++++++++++++++++---------- docs/deployment.md | 5 ++-- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/ci/update-llm-agents.py b/ci/update-llm-agents.py index c51c63d..f8cf9fd 100755 --- a/ci/update-llm-agents.py +++ b/ci/update-llm-agents.py @@ -82,17 +82,45 @@ def find_pull_request(state: str, sort: str | None = None): return pull -def create_pull_request(): - return api("pulls", data={ - "base": BASE, - "head": BRANCH, - "title": TITLE, - "body": ( - "Updates the llm-agents pin when an installed package changes version. " - "See the commit message for the version changes. Close this PR to skip " - "these versions; a later release opens a new one." - ), - }) +def version_changes(before: dict[str, str], after: dict[str, str]) -> list[tuple[str, str, str]]: + return [ + (name, before.get(name, "absent"), after.get(name, "absent")) + for name in sorted(before.keys() | after.keys()) + if before.get(name) != after.get(name) + ] + + +def locked_source(lock: bytes) -> dict[str, str]: + nodes = json.loads(lock)["nodes"] + return nodes[nodes["root"]["inputs"]["llm-agents"]]["locked"] + + +def pull_request_body( + before: dict[str, str], after: dict[str, str], base_lock: bytes, proposed_lock: bytes, +) -> str: + rows = "\n".join( + f"| `{name}` | {old} | {new} |" for name, old, new in version_changes(before, after) + ) + + old, new = locked_source(base_lock), locked_source(proposed_lock) + source = f"`{old['rev'][:12]}` → `{new['rev'][:12]}`" + if new.get("type") == "github": + compare = f"https://github.com/{new['owner']}/{new['repo']}/compare/{old['rev']}...{new['rev']}" + source = f"[{source}]({compare})" + + return ( + f"Updates the `llm-agents` pin ({source}). Installed package versions:\n" + "\n" + f"| Package | `{BASE}` | Proposed |\n" + "| --- | --- | --- |\n" + f"{rows}\n" + "\n" + "Close this PR to skip these versions; a later release opens a new one." + ) + + +def create_pull_request(body: str): + return api("pulls", data={"base": BASE, "head": BRANCH, "title": TITLE, "body": body}) def close_obsolete(pull) -> None: @@ -126,9 +154,7 @@ def declined(after: dict[str, str], reference: Path) -> bool: def publish(previous: str, before: dict[str, str], after: dict[str, str]) -> str: changes = "\n".join( - f"{name} {before.get(name, 'absent')} -> {after.get(name, 'absent')}" - for name in sorted(before.keys() | after.keys()) - if before.get(name) != after.get(name) + f"{name} {old} -> {new}" for name, old, new in version_changes(before, after) ) subprocess.run(["git", "add", "--", str(LOCK)], check=True) @@ -182,15 +208,23 @@ def main() -> None: return pending = None + pending_lock = None if previous and git_output("show", f"{previous}^:{LOCK}") == base_lock: pending_lock = git_output("show", f"{previous}:{LOCK}") reference.write_bytes(pending_lock) pending = after if pending_lock == candidate_lock else versions(reference) - head = previous if pending == after else publish(previous, before, after) + if pending == after: + head, proposed_lock = previous, pending_lock + else: + head, proposed_lock = publish(previous, before, after), candidate_lock + # Keep the description in step with the branch, including after master moves. + body = pull_request_body(before, after, base_lock, proposed_lock) if pull is None: - pull = create_pull_request() + pull = create_pull_request(body) + elif pull["body"] != body: + api(f"pulls/{pull['number']}", method="PATCH", data={"body": body}) print(f"Update PR {pull['html_url']}") # Gitea suppresses events from the Actions token. Dispatch explicitly and diff --git a/docs/deployment.md b/docs/deployment.md index dd7c97e..e4e209c 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -336,8 +336,9 @@ by the x86_64 Linux NixOS and home-manager configurations to derivations exporte `llm-agents`. This discovers the tracked packages without building a whole system. When an installed version changes, CI commits the updated lockfile on the dedicated -`automation/llm-agents` branch. The commit message lists the version changes. New versions -refresh the branch behind the existing open PR. Upstream revisions with the same package +`automation/llm-agents` branch. The PR description tabulates the version changes and links +the upstream comparison, and the commit message lists them too. New versions refresh the branch +behind the existing open PR, and the updater rewrites the description to match. Upstream revisions with the same package versions leave that branch alone. - **Declining:** close the PR without merging. CI won't propose the same versions again, and