Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions lua/codecompanion/_extensions/gitcommit/generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,46 +252,49 @@ function Generator._create_prompt(diff, lang, commit_history)

CRITICAL FORMAT REQUIREMENTS:
1. MUST generate exactly ONE commit message, never multiple messages
2. MUST include a title line, followed by a blank line, then bullet point descriptions
3. MUST analyze ALL changes in the diff as a single logical unit
4. MUST respond with ONLY the commit message, no explanations, markdown code blocks, or extra text
5. DO NOT wrap the output in markdown code blocks (```) or any other formatting
2. MUST analyze ALL changes in the diff as a single logical unit
3. MUST respond with ONLY the commit message, no explanations, markdown code blocks, or extra text
4. DO NOT wrap the output in markdown code blocks (```) or any other formatting

MANDATORY FORMAT:
FORMAT:
type(scope): brief description
<blank line>
- description point 1
- description point 2
- description point 3

[Optional body - only if needed]

Allowed types: feat, fix, docs, style, refactor, perf, test, chore
Language: %s

RULES:
- Output the commit message directly without any markdown formatting or code blocks
- The title (first line) must be followed by ONE blank line before the descriptions
- Each description point must start with a dash (-)
- If commit history is provided, follow the established patterns and style from recent commits
- It's best to keep Subject Line under 50 characters.
- Each line of the body should ideally not exceed 72 characters.

REQUIRED EXAMPLES:
feat(auth): add OAuth2 integration

- Implement OAuth2 authentication flow
- Add token refresh mechanism
- Update user session handling
fix(api): resolve data validation issues

- Fix null pointer exception in validator
- Add input sanitization
- Improve error messages
Generate ONE complete commit message for this diff:
- Keep Subject Line under 50 characters, body lines under 72 characters
- DEFAULT TO MINIMAL: prefer fewer bullet points over more
- Body is OPTIONAL: omit if subject line is self-explanatory
- NEVER pad with redundant points - each bullet must add unique value
- If commit history is provided, follow established patterns

COMPLEXITY GUIDE:
- Single file text change, config tweak, typo fix → NO body
- Single logical change (rename, add one function) → 0-1 bullet
- Multiple related changes → 2-3 bullets MAX

EXAMPLES:

fix(config): update timeout value

refactor(api): rename getUserData to fetchUser

- Update all call sites to use new name

feat(auth): add OAuth2 support

- Implement token refresh flow
- Add session persistence

Generate a CONCISE commit message:
```diff
%s
```

Return ONLY the commit message in the exact format shown above.]],
Return ONLY the commit message.]],
history_context,
lang or "English",
diff
Expand Down