git-aicommit 7.6.0 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -5
- package/autocommit.js +14 -1
- package/config.js +11 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ export default {
|
|
|
43
43
|
autocommit: true,
|
|
44
44
|
openCommitTextEditor: false,
|
|
45
45
|
language: 'english',
|
|
46
|
+
projectInstruction: null,
|
|
46
47
|
systemMessagePromptTemplate: '' +
|
|
47
48
|
'You are expert software developer, your job is to write clear and concise Git commit messages. ' +
|
|
48
49
|
'Your responsibility is to ensure that these messages accurately describe the changes made in each commit,' +
|
|
@@ -50,19 +51,39 @@ export default {
|
|
|
50
51
|
'Write 1-2 sentences. Output only the commit message without comments or other text.',
|
|
51
52
|
humanPromptTemplate: '' +
|
|
52
53
|
'Read the following git diff for a multiple files and ' +
|
|
53
|
-
'write 1-2 sentences commit message in {language}' +
|
|
54
|
-
'without mentioning lines or files.' +
|
|
55
|
-
'If the reason behind the changed can be deducted from the changed, provide this reason
|
|
54
|
+
'write 1-2 sentences commit message in {language} ' +
|
|
55
|
+
'without mentioning lines or files. ' +
|
|
56
|
+
'If the reason behind the changed can be deducted from the changed, provide this reason.\n' +
|
|
57
|
+
'Current branch: {branch}\n' +
|
|
58
|
+
'{projectInstruction}\n' +
|
|
59
|
+
'{customInstruction}\n' +
|
|
60
|
+
'Git diff:\n' +
|
|
56
61
|
'{diff}',
|
|
57
62
|
excludeFromDiff: [
|
|
58
63
|
'*.lock', '*.lockb', '*-lock.json', '*-lock.yaml'
|
|
59
64
|
],
|
|
60
65
|
diffFilter: 'ACMRTUXB',
|
|
61
66
|
modelName: "gpt-4.1-mini",
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
completionPromptParams: {
|
|
68
|
+
maxTokens: 2000,
|
|
69
|
+
},
|
|
64
70
|
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Prompt Template Variables
|
|
74
|
+
|
|
75
|
+
The `humanPromptTemplate` supports the following variables:
|
|
65
76
|
|
|
77
|
+
- `{diff}` - The git diff of staged changes
|
|
78
|
+
- `{language}` - The language for the commit message (default: 'english')
|
|
79
|
+
- `{branch}` - Current git branch name
|
|
80
|
+
- `{projectInstruction}` - Project-level instructions (configurable via config file)
|
|
81
|
+
- `{customInstruction}` - Custom instruction passed via command line
|
|
82
|
+
|
|
83
|
+
Example usage with custom instruction:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
git-aicommit added fix for issue #123
|
|
66
87
|
```
|
|
67
88
|
|
|
68
89
|
### Command line arguments
|
package/autocommit.js
CHANGED
|
@@ -15,6 +15,9 @@ const config = rc(
|
|
|
15
15
|
},
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
+
// Parse command-line arguments (everything after the script name)
|
|
19
|
+
const customInstruction = process.argv.slice(2).join(' ');
|
|
20
|
+
|
|
18
21
|
try {
|
|
19
22
|
execSync(
|
|
20
23
|
'git rev-parse --is-inside-work-tree',
|
|
@@ -25,6 +28,9 @@ try {
|
|
|
25
28
|
process.exit(1);
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
// Get current git branch name
|
|
32
|
+
const branch = execSync('git rev-parse --abbrev-ref HEAD', {encoding: 'utf8'}).trim();
|
|
33
|
+
|
|
28
34
|
if (!config.openAiKey && !config.azureOpenAiKey) {
|
|
29
35
|
console.error("Please set OPENAI_API_KEY or AZURE_OPENAI_API_KEY");
|
|
30
36
|
process.exit(1);
|
|
@@ -73,7 +79,14 @@ async function getChatCompletion(messages) {
|
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
const systemMessage = { role: "system", content: config.systemMessagePromptTemplate };
|
|
76
|
-
const
|
|
82
|
+
const userPrompt = config.humanPromptTemplate
|
|
83
|
+
.replace("{diff}", diff)
|
|
84
|
+
.replace("{language}", config.language)
|
|
85
|
+
.replace("{branch}", branch)
|
|
86
|
+
.replace("{projectInstruction}", config.projectInstruction || '')
|
|
87
|
+
.replace("{customInstruction}", customInstruction || '');
|
|
88
|
+
|
|
89
|
+
const userMessage = { role: "user", content: userPrompt };
|
|
77
90
|
|
|
78
91
|
const tokenCount = await calculateMaxTokens({
|
|
79
92
|
prompt: diff,
|
package/config.js
CHANGED
|
@@ -7,6 +7,7 @@ export default {
|
|
|
7
7
|
autocommit: true,
|
|
8
8
|
openCommitTextEditor: false,
|
|
9
9
|
language: 'english',
|
|
10
|
+
projectInstruction: null,
|
|
10
11
|
systemMessagePromptTemplate: '' +
|
|
11
12
|
'You are expert software developer, your job is to write clear and concise Git commit messages. ' +
|
|
12
13
|
'Your responsibility is to ensure that these messages accurately describe the changes made in each commit,' +
|
|
@@ -14,14 +15,20 @@ export default {
|
|
|
14
15
|
'Write 1-2 sentences. Output only the commit message without comments or other text.',
|
|
15
16
|
humanPromptTemplate: '' +
|
|
16
17
|
'Read the following git diff for a multiple files and ' +
|
|
17
|
-
'write 1-2 sentences commit message in {language}' +
|
|
18
|
-
'without mentioning lines or files.' +
|
|
19
|
-
'If the reason behind the changed can be deducted from the changed, provide this reason
|
|
18
|
+
'write 1-2 sentences commit message in {language} ' +
|
|
19
|
+
'without mentioning lines or files. ' +
|
|
20
|
+
'If the reason behind the changed can be deducted from the changed, provide this reason.\n' +
|
|
21
|
+
'Current branch: {branch}\n' +
|
|
22
|
+
'{projectInstruction}\n' +
|
|
23
|
+
'{customInstruction}\n' +
|
|
24
|
+
'Git diff:\n' +
|
|
20
25
|
'{diff}',
|
|
21
26
|
excludeFromDiff: [
|
|
22
27
|
'*.lock', '*.lockb', '*-lock.json', '*-lock.yaml'
|
|
23
28
|
],
|
|
24
29
|
diffFilter: 'ACMRTUXB',
|
|
25
30
|
modelName: "gpt-4.1-mini",
|
|
26
|
-
|
|
31
|
+
completionPromptParams: {
|
|
32
|
+
maxTokens: 2000,
|
|
33
|
+
},
|
|
27
34
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-aicommit",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "Generates auto commit messages with OpenAI
|
|
3
|
+
"version": "7.7.0",
|
|
4
|
+
"description": "Generates auto commit messages with OpenAI models",
|
|
5
5
|
"main": "autocommit.js",
|
|
6
6
|
"repository": "https://github.com/shanginn/autocommit",
|
|
7
7
|
"author": "shanginn@gmail.com",
|