@@ -221,27 +221,38 @@ export async function buildNotes(from: string, to: string) {
221221
222222 console . log ( "generating changelog since " + from )
223223
224- const opencode = await createOpencode ( { port : 5044 } )
225224 const notes : string [ ] = [ ]
226225
227- try {
228- const lines = await generateChangelog ( commits , opencode )
229- notes . push ( ...lines )
230- console . log ( "---- Generated Changelog ----" )
231- console . log ( notes . join ( "\n" ) )
232- console . log ( "-----------------------------" )
233- } catch ( error ) {
234- if ( error instanceof Error && error . name === "TimeoutError" ) {
235- console . log ( "Changelog generation timed out, using raw commits" )
236- for ( const commit of commits ) {
237- const attribution = commit . author && ! team . includes ( commit . author ) ? ` (@${ commit . author } )` : ""
238- notes . push ( `- ${ commit . message } ${ attribution } ` )
226+ // Check if opencode CLI is available for AI-powered changelog generation
227+ const hasOpencode = await Bun . which ( "opencode" ) !== null
228+
229+ if ( hasOpencode ) {
230+ const opencode = await createOpencode ( { port : 5044 } )
231+ try {
232+ const lines = await generateChangelog ( commits , opencode )
233+ notes . push ( ...lines )
234+ console . log ( "---- Generated Changelog ----" )
235+ console . log ( notes . join ( "\n" ) )
236+ console . log ( "-----------------------------" )
237+ } catch ( error ) {
238+ if ( error instanceof Error && error . name === "TimeoutError" ) {
239+ console . log ( "Changelog generation timed out, using raw commits" )
240+ for ( const commit of commits ) {
241+ const attribution = commit . author && ! team . includes ( commit . author ) ? ` (@${ commit . author } )` : ""
242+ notes . push ( `- ${ commit . message } ${ attribution } ` )
243+ }
244+ } else {
245+ throw error
239246 }
240- } else {
241- throw error
247+ } finally {
248+ opencode . server . close ( )
249+ }
250+ } else {
251+ console . log ( "opencode CLI not available, using raw commit messages" )
252+ for ( const commit of commits ) {
253+ const attribution = commit . author && ! team . includes ( commit . author ) ? ` (@${ commit . author } )` : ""
254+ notes . push ( `- ${ commit . message } ${ attribution } ` )
242255 }
243- } finally {
244- opencode . server . close ( )
245256 }
246257
247258 const contributors = await getContributors ( from , to )
0 commit comments