11import { generateObject } from "ai" ;
22import { z } from "zod" ;
3- import { PostType } from "@repo/supabase" ;
43import { openRouter } from "./ai-gateway" ;
54import { getPRCommits , getPRDetails , getPRFiles } from "./github" ;
5+ import { PostType } from "@changes-page/supabase/types/page" ;
66
77export interface ChangelogInput {
88 pr : Awaited < ReturnType < typeof getPRDetails > > ;
@@ -36,7 +36,7 @@ const MAX_COMMITS = 50;
3636const MAX_FILES = 100 ;
3737
3838export async function generateChangelog (
39- input : ChangelogInput ,
39+ input : ChangelogInput
4040) : Promise < ChangelogOutput > {
4141 const truncatedCommits = input . commits . slice ( 0 , MAX_COMMITS ) ;
4242 const truncatedFiles = [ ...input . files ]
@@ -61,7 +61,11 @@ Generate:
6161
6262<summary-rules>
6363The summary will be posted as a GitHub comment to inform the developer what was done.
64- ${ input . previousDraft ? "This is a REVISION of an existing draft based on user feedback." : "This is a NEW changelog draft." }
64+ ${
65+ input . previousDraft
66+ ? "This is a REVISION of an existing draft based on user feedback."
67+ : "This is a NEW changelog draft."
68+ }
6569
6670${
6771 input . previousDraft
@@ -75,9 +79,13 @@ Keep it to 1-2 sentences. Be specific about the main features/changes covered.
7579</summary-rules>
7680</instructions>
7781
78- ${ input . userInstructions ? `<user-instructions>
82+ ${
83+ input . userInstructions
84+ ? `<user-instructions>
7985"""${ input . userInstructions } """
80- </user-instructions>` : "" } `,
86+ </user-instructions>`
87+ : ""
88+ } `,
8189 prompt : `<input>
8290<pr-title>
8391"""${ input . pr . title } """
@@ -92,7 +100,9 @@ ${truncatedCommits.map((c) => c.commit.message).join("\n")}
92100"""
93101</commits>
94102
95- <files-changed additions="${ input . pr . additions } " deletions="${ input . pr . deletions } ">
103+ <files-changed additions="${ input . pr . additions } " deletions="${
104+ input . pr . deletions
105+ } ">
96106"""
97107${ truncatedFiles . map ( ( f ) => `${ f . status } : ${ f . filename } ` ) . join ( "\n" ) }
98108"""
0 commit comments