@@ -206,6 +206,17 @@ function parseFrontmatter(content) {
206206
207207// --- Format the enhanced PR body ---
208208
209+ /**
210+ * Render the enhanced release PR body.
211+ *
212+ * @param {object } args
213+ * @param {string } args.version - Proposed release version (e.g. "4.4.6").
214+ * @param {Array<{text: string, type: string}> } args.packageEntries - Entries parsed from the changesets-generated PR body.
215+ * @param {Array<{text: string, type: string, area: string}> } args.serverEntries - Entries parsed from .server-changes/*.md.
216+ * @param {string } args.rawBody - The original changesets-generated PR body (kept in a collapsed details section).
217+ * @param {{sourceBranch: string, currentLatest: string, willBeLatest: boolean, lineMatch: string|null}|null } args.releaseContext - Release-branch context (only set when SOURCE_BRANCH env is present); drives the "Release prep" header.
218+ * @returns {string } Markdown body.
219+ */
209220function formatPrBody ( { version, packageEntries, serverEntries, rawBody, releaseContext } ) {
210221 const lines = [ ] ;
211222
@@ -340,6 +351,17 @@ function formatPrBody({ version, packageEntries, serverEntries, rawBody, release
340351
341352// --- Main ---
342353
354+ /**
355+ * Build release-branch context for the PR body header.
356+ *
357+ * Reads SOURCE_BRANCH from the environment (set by changesets-pr.yml). When
358+ * present, queries npm for the current `latest` dist-tag of @trigger.dev/sdk,
359+ * compares the proposed version against it, and returns context for rendering
360+ * the "Release prep" header. Returns null when SOURCE_BRANCH is unset (so the
361+ * header is omitted on plain main releases that don't need branch context).
362+ *
363+ * @returns {Promise<{sourceBranch: string, currentLatest: string, willBeLatest: boolean, lineMatch: string|null}|null> }
364+ */
343365async function getReleaseContext ( ) {
344366 const sourceBranch = process . env . SOURCE_BRANCH ;
345367 if ( ! sourceBranch ) return null ;
0 commit comments