Skip to content

Commit 4d0682e

Browse files
committed
docs(generator): update commit message prompt instructions
- clarify and expand critical format requirements for commit messages - add mandatory format section with detailed bullet points - provide explicit rules and required examples for output format - update prompt wording for consistency and clarity
1 parent bc751d9 commit 4d0682e

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

lua/codecompanion/_extensions/gitcommit/generator.lua

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,37 +73,49 @@ end
7373
---@return string prompt The formatted prompt
7474
function Generator._create_prompt(diff, lang)
7575
return string.format(
76-
[[You are a commit message generator. Generate exactly ONE Conventional Commit message for the provided git diff.
76+
[[You are a commit message generator. Generate exactly ONE complete Conventional Commit message for the provided git diff.
7777
78-
CRITICAL RULES:
79-
1. Generate ONLY ONE commit message, never multiple messages
80-
2. Analyze ALL changes in the diff as a single logical unit
81-
3. Choose the most significant change type if multiple types exist
82-
4. Respond with ONLY the commit message, no additional text or explanations
78+
CRITICAL FORMAT REQUIREMENTS:
79+
1. MUST generate exactly ONE commit message, never multiple messages
80+
2. MUST include a title line and at least one bullet point description
81+
3. MUST analyze ALL changes in the diff as a single logical unit
82+
4. MUST respond with ONLY the commit message, no explanations or extra text
8383
84-
Format: type(scope): description
84+
MANDATORY FORMAT:
85+
type(scope): brief description
86+
87+
- detailed description point 1
88+
- detailed description point 2 (if needed)
89+
- detailed description point 3 (if needed)
8590
8691
Types: feat, fix, docs, style, refactor, perf, test, chore
8792
Language: %s
8893
89-
Requirements:
90-
- Use imperative mood ("add" not "added")
91-
- Keep description under 50 characters
92-
- Add body with bullet points for complex changes only if necessary
94+
RULES:
95+
- Title: Use imperative mood ("add" not "added"), keep under 50 characters
96+
- Body: At least ONE bullet point describing the changes
97+
- For large diffs: Focus on the most significant changes, group related changes
9398
- Choose the primary type that best represents the overall change
99+
- Even with extensive changes, generate only ONE unified commit message
94100
95-
Example output format:
101+
REQUIRED EXAMPLES:
96102
feat(auth): add OAuth2 integration
97103
98104
- implement Google OAuth provider
99-
- update authentication flow
105+
- update user authentication flow
106+
- add integration tests
107+
108+
fix(api): resolve data validation issues
109+
110+
- fix null pointer exceptions in user data
111+
- improve input validation for API endpoints
100112
101-
Generate ONE commit message for this diff:
113+
Generate ONE complete commit message for this diff:
102114
```diff
103115
%s
104116
```
105117
106-
Response format: Return only the commit message, nothing else.]],
118+
Return ONLY the commit message in the exact format shown above.]],
107119
lang or "English",
108120
diff
109121
)

0 commit comments

Comments
 (0)