@@ -9,6 +9,7 @@ local action_state = require("telescope.actions.state")
9
9
local previewers = require (" telescope.previewers" )
10
10
local telescope = require (" telescope.builtin" )
11
11
local backends = require (" commit-ai.backends.gemini" )
12
+ local Prompt = require (" commit-ai.prompt" )
12
13
13
14
local function query_ai (prompt , cb )
14
15
backends .call_ai (prompt , function (response )
@@ -41,38 +42,11 @@ local function generate_commit_suggestions(cb)
41
42
local git_conventions = config .git_conventions
42
43
local format_lines = {}
43
44
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 ))
45
46
end
46
47
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 )
55
49
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
- -- )
76
50
query_ai (prompt , cb )
77
51
end
78
52
0 commit comments