Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
53 changes: 24 additions & 29 deletions lua/codecompanion/_extensions/gitcommit/generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,53 +248,48 @@ function Generator._create_prompt(diff, lang, commit_history)
end

return string.format(
[[You are a commit message generator. Generate exactly ONE complete Conventional Commit message for the provided git diff.%s

CRITICAL FORMAT REQUIREMENTS:
1. MUST generate exactly ONE commit message, never multiple messages
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
[[You are a commit message generator. Generate exactly ONE Conventional Commit message for the provided git diff.%s

FORMAT:
type(scope): brief description
type(scope): specific description of WHAT changed

[Optional body - only if needed]
[Optional body - only for non-obvious changes]

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

RULES:
- 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
CRITICAL RULES:
1. Respond with ONLY the commit message - no markdown blocks, no explanations
2. Description must state WHAT was done, not WHY or the effect
3. AVOID vague verbs: "update", "improve", "clarify", "adjust", "enhance", "fix issues"
USE specific verbs: "add", "remove", "rename", "move", "replace", "extract", "inline"
4. Subject line under 50 chars, body lines under 72 chars
5. Body is OPTIONAL - omit if subject is self-explanatory

BAD (vague):
- refactor(api): improve error handling
- fix(auth): update login logic
- chore(deps): update dependencies

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
GOOD (specific):
- refactor(api): replace try-catch with Result type
- fix(auth): check token expiry before API call
- chore(deps): bump axios from 0.21 to 1.6

EXAMPLES:

fix(config): update timeout value
docs(readme): add installation section

refactor(api): rename getUserData to fetchUser

- Update all call sites to use new name
feat(auth): add OAuth2 token refresh flow

feat(auth): add OAuth2 support
- Store refresh token in secure storage
- Auto-refresh 5 min before expiry

- Implement token refresh flow
- Add session persistence

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

Return ONLY the commit message.]],
```]],
history_context,
lang or "English",
diff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ Skip internal changes that don't affect users.]],
}

M.base_instructions = [[
OUTPUT FORMAT:
- Wrap the entire output in a markdown code block (```markdown ... ```)
- This allows easy copying of the complete release notes

CRITICAL RULES:
- Only include sections that have actual content - skip empty categories entirely
- Do NOT use placeholder text like "[description here]" - write real content or omit
Expand Down Expand Up @@ -173,8 +169,9 @@ function M.create_smart_prompt(commits, style, version_info)
end

table.insert(parts, "\n\n---\n\n")
table.insert(parts, "Generate release notes based on the commits above. ")
table.insert(parts, "Adapt the structure and length to match the actual content.")
table.insert(parts, "Generate release notes based on the commits above.\n\n")
table.insert(parts, "IMPORTANT: Wrap your ENTIRE output in a markdown code block like this:\n")
table.insert(parts, "```markdown\n[your release notes here]\n```")
Comment on lines +172 to +174

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and to consolidate what is logically a single block of text, you can combine these table.insert calls into one call using a multiline string. This makes the prompt instruction easier to read and maintain.

  table.insert(parts, [[Generate release notes based on the commits above.

IMPORTANT: Wrap your ENTIRE output in a markdown code block like this:
```markdown
[your release notes here]
```]])


return table.concat(parts)
end
Expand Down