diff --git a/README.md b/README.md index e4f30e3..40e75b3 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ To generate a commit message: kemit ``` -If there are no staged changes, the application will output "Nothing to commit". Otherwise, it will generate and print a commit message based on the staged diff. +If there are no staged changes, the application will output "Nothing to commit." Otherwise, it will generate and print a commit message based on the staged diff. ## Uninstall diff --git a/engine/ollama.go b/engine/ollama.go index e111495..3dce98d 100644 --- a/engine/ollama.go +++ b/engine/ollama.go @@ -49,8 +49,7 @@ func (ollama *ollamaEngine) request(diff, style string) (string, error) { defer resp.Body.Close() var res map[string]interface{} - err = json.NewDecoder(resp.Body).Decode(&res) - if err != nil { + if err = json.NewDecoder(resp.Body).Decode(&res); err != nil { return "", err } diff --git a/engine/prompt.go b/engine/prompt.go index 3f29006..85701d8 100644 --- a/engine/prompt.go +++ b/engine/prompt.go @@ -3,21 +3,33 @@ package engine import "fmt" var basePrePrompt = ` - - Your task is to create clean and comprehensive git commit message. - - Convert 'git diff --staged' command it into a git commit message. - - Use the present tense. - - Lines limit to 50 characters. - - Message should be one paragraph. - - Message should be very clear and short. - - Skip "Update X file" or "Update" at the beginning of the message and go straight to the point. - - Respond using JSON. - - JSON scheme {"commit_message": string} +*** WHAT TO DO *** +1. Your task is to create clean and comprehensive git commit message. +2. Convert 'git diff --staged' command it into a git commit message. +3. Use the present tense. +4. Lines limit to 50 characters. +5. Message should be one paragraph. +6. Message should be very clear and short. +7. Skip "Update X file" or "Update" at the beginning of the message and go straight to the point. +8. Respond using JSON. +9. JSON scheme {"commit_message": string} ` var conventionalCommitPrompt = ` - - Use Conventional commit. - - Conventional commit keywords: fix, feat, build, chore, ci, docs, style, refactor, perf, test. - - Do not preface the commit with anything. +*** Conventional Commit *** +1. Use Conventional commit. +2. Conventional commit keywords: fix, feat, build, chore, ci, docs, style, refactor, perf, test. + - feat: new feature + - fix: bug fix + - build: changes that affect the build system or external dependencies + - ci: changes to our CI configuration files and scripts + - chore: other changes that don't modify src or test files + - docs: documentation only changes + - style: changes that do not affect the meaning of the code (white-space, formatting, etc) + - refactor: code change that neither fixes a bug nor adds feature + - perf: code change that improves performance + - test: adding missing tests or correcting existing tests +3. Do not preface the commit with anything. ` func createPrompt(diff, style string) string { @@ -25,5 +37,5 @@ func createPrompt(diff, style string) string { basePrePrompt = basePrePrompt + conventionalCommitPrompt } - return fmt.Sprintf("%s\n%s", basePrePrompt, diff) + return fmt.Sprintf("git diff: ```%s``` \n %s", diff, basePrePrompt) } diff --git a/main.go b/main.go index 47f8905..e05d132 100644 --- a/main.go +++ b/main.go @@ -69,7 +69,7 @@ func run(cfg *config.Config) { } if diff == "" { - fmt.Println("Nothing to commit") + fmt.Println("Nothing to commit.") } else { // TODO: move this to the enigne pkg ollama := engine.NewOllama(cfg.OllamaHost, cfg.OllamaModel)