@@ -80,14 +80,28 @@ export class CLI {
8080 const token = this . #env. OPENAI_API_KEY ;
8181 const name = flags . name || `${ org } /${ repo } ` ;
8282
83+ let prompt = "" ;
84+ if ( flags . promptFile ) {
85+ try {
86+ const fsp = await import ( "node:fs/promises" ) ;
87+ prompt = await fsp . readFile ( flags . promptFile , "utf8" ) ;
88+ } catch ( err ) {
89+ const message =
90+ err instanceof Error ? err . message : String ( err ) ;
91+ this . #console. error ( `Error reading prompt file: ${ message } ` ) ;
92+ return 1 ;
93+ }
94+ }
95+
8396 try {
8497 const release = await fetchRelease ( `${ org } /${ repo } ` , flags . tag ) ;
8598 const generator = githubToken
8699 ? new ChatCompletionPostGenerator ( githubToken , {
87100 baseUrl : GITHUB_BASE_URL ,
88101 model : GITHUB_MODEL ,
102+ prompt,
89103 } )
90- : new ResponseAPIPostGenerator ( token ) ;
104+ : new ResponseAPIPostGenerator ( token , { prompt } ) ;
91105 const post = await generator . generateSocialPost ( name , release ) ;
92106
93107 this . #console. log ( post ) ;
@@ -97,7 +111,6 @@ export class CLI {
97111 ) ;
98112 return 1 ;
99113 }
100-
101114 return 0 ;
102115 }
103116
@@ -115,11 +128,18 @@ export class CLI {
115128 name : { type : "string" , short : "n" } ,
116129 tag : { type : "string" , short : "t" } ,
117130 help : { type : "boolean" , short : "h" } ,
131+ "prompt-file" : { type : "string" } ,
118132 } ,
119133 allowPositionals : false ,
120134 strict : false ,
121135 } ) ;
122136
137+ // Map kebab-case to camelCase for CLIArgs
138+ if ( "prompt-file" in flags ) {
139+ flags . promptFile = flags [ "prompt-file" ] ;
140+ delete flags [ "prompt-file" ] ;
141+ }
142+
123143 return /** @type {CLIArgs } */ ( flags ) ;
124144 }
125145
@@ -136,6 +156,7 @@ export class CLI {
136156 this . #console. log ( " --repo, -r The repository name" ) ;
137157 this . #console. log ( " --name, -n The name of the project" ) ;
138158 this . #console. log ( " --tag, -t The release tag [default: latest]" ) ;
159+ this . #console. log ( " --prompt-file Path to a custom prompt file" ) ;
139160 this . #console. log ( " --help, -h Show this help message" ) ;
140161 this . #console. log ( "" ) ;
141162 }
0 commit comments