git-aicommit 7.5.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 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:\n' +
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
- temperature: 0.0,
63
- maxTokens: 2000,
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);
@@ -66,7 +72,6 @@ async function getChatCompletion(messages) {
66
72
  const response = await openai.chat.completions.create({
67
73
  model: config.modelName || 'gpt-4.1-mini',
68
74
  messages: messages,
69
- temperature: config.temperature,
70
75
  max_completion_tokens: config.maxTokens,
71
76
  });
72
77
 
@@ -74,7 +79,14 @@ async function getChatCompletion(messages) {
74
79
  }
75
80
 
76
81
  const systemMessage = { role: "system", content: config.systemMessagePromptTemplate };
77
- const userMessage = { role: "user", content: config.humanPromptTemplate.replace("{diff}", diff).replace("{language}", config.language) };
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 };
78
90
 
79
91
  const tokenCount = await calculateMaxTokens({
80
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,15 +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:\n' +
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
- modelName: "gpt-5-mini",
26
- temperature: 0.0,
27
- maxTokens: 2000,
30
+ modelName: "gpt-4.1-mini",
31
+ completionPromptParams: {
32
+ maxTokens: 2000,
33
+ },
28
34
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "git-aicommit",
3
- "version": "7.5.0",
4
- "description": "Generates auto commit messages with OpenAI GPT3 model",
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",