@@ -9,6 +9,7 @@ local action_state = require("telescope.actions.state")
99local previewers = require (" telescope.previewers" )
1010local telescope = require (" telescope.builtin" )
1111local backends = require (" commit-ai.backends.gemini" )
12+ local Prompt = require (" commit-ai.prompt" )
1213
1314local function query_ai (prompt , cb )
1415 backends .call_ai (prompt , function (response )
@@ -41,38 +42,11 @@ local function generate_commit_suggestions(cb)
4142 local git_conventions = config .git_conventions
4243 local format_lines = {}
4344 for _ , convention in pairs (git_conventions ) do
44- table.insert (format_lines , string.format (" - %s %s: %s" , convention .icon , convention .prefix , convention .type ))
45+ table.insert (format_lines , string.format (" - %s %s (scope) : %s" , convention .icon , convention .prefix , convention .type ))
4546 end
4647
47- local prompt = string.format (
48- " Analyze this git diff and generate commit messages in plain text.\n " ..
49- " Use exactly this format without additional explanation:\n\n " ..
50- " - <icon> <prefix>: <commit message>\n\n " ..
51- " Options:\n %s\n\n Git diff:\n %s" ,
52- table.concat (format_lines , " \n " ),
53- diff
54- )
48+ local prompt = Prompt .default_prompt (diff , format_lines )
5549
56- -- local prompt = string.format(
57- -- "Analyze this git diff and generate multiple commit messages using exactly one of these formats:\n" ..
58- -- "Format:\n" ..
59- -- "- <icon> <prefix>: <commit message>\n\n" ..
60- -- "Only respond with the commit messages, without any explanations.\n\n" ..
61- -- "- %s %s: Documentation changes\n" ..
62- -- "- %s %s: Bug fix\n" ..
63- -- "- %s %s: New feature\n" ..
64- -- "- %s %s: Chore\n" ..
65- -- "- %s %s: Breaking change\n" ..
66- -- "- %s %s: Enhancement\n\n" ..
67- -- "Git diff:\n%s",
68- -- git_conventions.docs.icon, git_conventions.docs.prefix,
69- -- git_conventions.fix.icon, git_conventions.fix.prefix,
70- -- git_conventions.feat.icon, git_conventions.feat.prefix,
71- -- git_conventions.chore.icon, git_conventions.chore.prefix,
72- -- git_conventions.refactor.icon, git_conventions.refactor.prefix,
73- -- git_conventions.enhance.icon, git_conventions.enhance.prefix,
74- -- diff
75- -- )
7650 query_ai (prompt , cb )
7751end
7852
0 commit comments