@@ -73,16 +73,18 @@ public function handle(): int
7373 throw new TaskException ('There are no cached files to commit. Try running `git add` to cache some files. ' );
7474 }
7575
76+ $ type = $ this ->choice ('Please choice commit type ' , $ types = $ this ->configManager ->get ('types ' ), array_key_first ($ types ));
77+
7678 $ message = retry (
7779 $ this ->option ('retry-times ' ),
78- function ($ attempts ) use ($ cachedDiff ): string {
80+ function ($ attempts ) use ($ cachedDiff, $ type ): string {
7981 if ($ attempts > 1 ) {
8082 $ this ->output ->note ('retrying... ' );
8183 }
8284
8385 $ originalMessage = $ this ->generatorManager
8486 ->driver ($ this ->option ('generator ' ))
85- ->generate ($ this ->getPrompt ($ cachedDiff ));
87+ ->generate ($ this ->getPrompt ($ cachedDiff, $ type ));
8688 $ message = $ this ->tryFixMessage ($ originalMessage );
8789 if (! str ($ message )->jsonValidate ()) {
8890 throw new TaskException (sprintf (
@@ -282,9 +284,17 @@ private function getDiffCommand(): array
282284 return array_merge (['git ' , 'diff ' , '--cached ' ], $ this ->option ('diff-options ' ));
283285 }
284286
285- private function getPrompt (string $ cachedDiff ): string
287+ private function getPrompt (string $ cachedDiff, string $ type ): string
286288 {
289+ $ typePrompt = sprintf ($ this ->configManager ->get ('type_prompt ' ), $ type );
290+ if (array_key_first ($ this ->configManager ->get ('types ' )) === $ type ) {
291+ $ type = $ this ->configManager ->get ('type_mark ' );
292+ $ typePrompt = '' ;
293+ }
294+
287295 return (string ) str ($ this ->configManager ->get ("prompts. {$ this ->option ('prompt ' )}" ))
296+ ->replace ($ this ->configManager ->get ('type_mark ' ), $ type )
297+ ->replace ($ this ->configManager ->get ('type_prompt_mark ' ), $ typePrompt )
288298 ->replace ($ this ->configManager ->get ('diff_mark ' ), $ cachedDiff )
289299 ->when ($ this ->option ('verbose ' ), function (Stringable $ prompt ): Stringable {
290300 $ this ->output ->note ((string ) $ prompt );
0 commit comments