Skip to content

Commit 033271d

Browse files
authored
Merge pull request #2 from aweis89/codex/improve-commit-message-generation
Reduce default `context_lines` to 5 to reduce noisy diff context
2 parents a2e831f + 116f116 commit 033271d

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ require("ai_commit_msg").setup({
133133
-- Show notifications
134134
notifications = true,
135135

136-
-- Number of surrounding lines to include in git diff (default: 10)
137-
context_lines = 10,
136+
-- Number of surrounding lines to include in git diff (default: 5)
137+
context_lines = 5,
138138

139139
-- Cost display format ("compact", "verbose", or false to disable)
140140
cost_display = "compact",
@@ -361,6 +361,10 @@ git config --global core.editor nvim
361361
- If you don't specify `max_tokens`, the model will use its default limit
362362
- For Anthropic models, `max_tokens` is required by the API
363363
(defaults to 1000 if not specified)
364+
- For more predictable messages, keep `context_lines` modest (default `5`;
365+
usually `3-10`) to reduce noisy, unchanged context in large diffs
366+
- If outputs are too verbose, prefer single-line defaults with a custom
367+
`system_prompt` that only allows a body for complex or breaking changes
364368

365369
## License
366370

doc/ai-commit-msg.nvim.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ CONFIGURATION *ai-commit-msg.nvim-ai-commit-msg.nvim-configuration*
162162
-- Show notifications
163163
notifications = true,
164164

165-
-- Number of surrounding lines to include in git diff (default: 10)
166-
context_lines = 10,
165+
-- Number of surrounding lines to include in git diff (default: 5)
166+
context_lines = 5,
167167

168168
-- Cost display format ("compact", "verbose", or false to disable)
169169
cost_display = "compact",
@@ -421,6 +421,10 @@ TIPS *ai-commit-msg.nvim-ai-commit-msg.nvim-tips*
421421
- If you don’t specify `max_tokens`, the model will use its default limit
422422
- For Anthropic models, `max_tokens` is required by the API
423423
(defaults to 1000 if not specified)
424+
- For more predictable messages, keep `context_lines` modest (default `5`;
425+
usually `3-10`) to reduce noisy, unchanged context in large diffs
426+
- If outputs are too verbose, prefer single-line defaults with a custom
427+
`system_prompt` that only allows a body for complex or breaking changes
424428

425429

426430
LICENSE *ai-commit-msg.nvim-ai-commit-msg.nvim-license*

lua/ai_commit_msg/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ M.default = {
4242
},
4343
spinner = true,
4444
notifications = true,
45-
context_lines = 10,
45+
context_lines = 5,
4646
keymaps = {
4747
quit = "q", -- Set to false to disable
4848
},

lua/ai_commit_msg/prompts.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local M = {}
22

33
M.DEFAULT_SYSTEM_PROMPT = [[
4-
# System Prompt: Conventional Commits Auto-Commit Generator (Bullet-Style Bodies)
4+
# System Prompt: Conventional Commit Generator (Concise-First)
55
66
You are to produce a single Conventional Commit message that strictly adheres to
77
Conventional Commits 1.0.0. Multi-line bodies should use plain ASCII bullet
@@ -92,12 +92,19 @@ Validation rules:
9292
- No emojis.
9393
- Keep to ASCII where possible.
9494
95+
Default style preference (important):
96+
- Prefer a single-line header by default.
97+
- Only add a body when it materially improves clarity (complex/multi-area work,
98+
important rationale, notable behavior change, or migration steps).
99+
- If you add a body, keep it compact (usually 2-4 bullets).
100+
95101
When to use multi-line commits (with bullet-style body and/or footers):
96102
- Use a bullet-style body when:
97103
- The change is non-trivial and benefits from concise highlights
98104
- There are user-visible behavior or UX changes
99105
- Complex refactors, performance work, or architectural changes need rationale
100106
- You modified multiple areas and want to call out secondary impacts
107+
- The commit would be ambiguous as a single-line header
101108
- Use footers when:
102109
- There is a breaking change (mandatory: add "!" in header and a BREAKING CHANGE footer)
103110
- You need to reference actual issues, tickets, PRs, or include co-authors (only if specific numbers/names exist)
@@ -117,6 +124,7 @@ Task:
117124
5) Group similar or related changes together - don't list every minor modification separately.
118125
6) If multiple independent changes are present, summarize the primary one; do NOT emit multiple commits.
119126
7) The final output must contain exactly one commit (one header). No prefaces, no postfaces, no explanations.
127+
8) Default to a single-line header unless body/footer information is genuinely useful.
120128
121129
Return ONLY the commit message.
122130
Do NOT include multiple commits. Do NOT include any other text.

0 commit comments

Comments
 (0)