@@ -113,26 +113,38 @@ func chatStructured[T any](model, prompt string, schema openai.ResponseFormatJSO
113
113
}
114
114
115
115
func GenerateCommitMessage (model , context , diff string ) (string , error ) {
116
+ // main prompt
117
+ prompt := "Generate a conventional commit message"
118
+
116
119
// constraints
117
- prompt := "Without wrapping in a code block"
118
- prompt += ", without using build as scope"
119
- prompt += ", without suggesting `feat` for build scripts"
120
- prompt += ", and without suggesting comments or remarks"
120
+ prompt += ", without:\n "
121
+ prompt += "- wrapping in a code block\n "
122
+ prompt += "- using build as scope\n "
123
+ prompt += "- suggesting `feat` for build scripts\n "
124
+ prompt += "- suggesting comments or remarks\n "
121
125
122
- // main prompt
123
- prompt += ", can you generate a conventional commit message"
126
+ // type
127
+ prompt += "\n Using conventional commit types:\n "
128
+ prompt += "- with type in lowercase\n "
129
+ prompt += "- using chore for maintenance commits\n "
124
130
125
131
// scope
126
- prompt += ", with lowercase scope"
132
+ prompt += "\n Using conventional commit scopes:\n "
133
+ prompt += "- in lowercase\n "
134
+
135
+ // subject
136
+ prompt += "\n Using conventional commit message subject:\n "
137
+ prompt += "- in lowercase\n "
127
138
128
139
// message body
129
- prompt += ", with message body as bullet points for the changes"
130
- prompt += ", using the imperative mood (present tense), rather than past tense"
131
- prompt += ", using titlecase for the first letter of the message body"
132
- prompt += ", and breaking lines at 72 characters"
140
+ prompt += "\n Using conventional commit message body:\n "
141
+ prompt += "- as bullet points for the changes\n "
142
+ prompt += "- using the imperative mood (present tense)\n "
143
+ prompt += "- using titlecase for the first letter of the message body\n "
144
+ prompt += "- breaking lines at 72 characters\n "
133
145
134
146
// context and diff
135
- prompt += ", based on the following context and diff:\n "
147
+ prompt += "\n Based on the following context and diff:\n "
136
148
prompt += fmt .Sprintf ("Here is context: %s\n " , context )
137
149
prompt += fmt .Sprintf ("Here is the Git diff:\n %s\n " , diff )
138
150
0 commit comments