git-commit-msg-ai 1.0.0__tar.gz → 1.1.0__tar.gz

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.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-commit-msg-ai
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: AI-powered git commit message generator following Conventional Commits
5
- License: MIT
5
+ License-Expression: MIT
6
6
  Requires-Python: >=3.9
7
7
  Description-Content-Type: text/markdown
8
8
  Requires-Dist: anthropic
File without changes
@@ -0,0 +1,28 @@
1
+ from typing import cast
2
+ import anthropic
3
+
4
+ SYSTEM_PROMPT = (
5
+ 'You are a Git commit message generator. Output only the commit message, nothing else. '
6
+ 'Follow the Conventional Commits specification:\n'
7
+ '- First line: <type>(<optional scope>)<!>: <short subject> (50 chars max); '
8
+ 'append ! before the colon if the commit introduces a breaking change\n'
9
+ '- Blank line\n'
10
+ '- Bullet-point body explaining WHY the changes were made, not what\n'
11
+ '- If there is a breaking change, add a blank line after the body followed by '
12
+ '"BREAKING CHANGE: <description of what breaks and why>\n'
13
+ 'Types: feat, fix, docs, style, refactor, test, chore'
14
+ )
15
+
16
+ MODEL = 'claude-haiku-4-5-20251001'
17
+ MAX_TOKENS = 1024
18
+
19
+
20
+ def generate_commit_message(diff: str) -> str:
21
+ client = anthropic.Anthropic()
22
+ response = client.messages.create(
23
+ model=MODEL,
24
+ max_tokens=MAX_TOKENS,
25
+ system=SYSTEM_PROMPT,
26
+ messages=[{'role': 'user', 'content': diff}],
27
+ )
28
+ return cast(anthropic.types.TextBlock, response.content[0]).text.strip()
@@ -0,0 +1,21 @@
1
+ from git_commit_msg_ai import ai_client, editor, git_ops
2
+
3
+
4
+ def main() -> None:
5
+ diff = git_ops.get_staged_diff()
6
+ msg = ai_client.generate_commit_message(diff)
7
+ print(msg)
8
+
9
+ choice = input('\n[a]ccept / [e]dit / [r]eject: ').strip().lower()
10
+
11
+ if choice == 'a':
12
+ git_ops.commit(msg)
13
+ elif choice == 'e':
14
+ msg = editor.open_in_editor(msg)
15
+ git_ops.commit(msg)
16
+ elif choice == 'r':
17
+ print('User rejected the generated commit message. No commit made.')
18
+
19
+
20
+ if __name__ == '__main__':
21
+ main()
@@ -0,0 +1,14 @@
1
+ import os
2
+ import subprocess
3
+ import tempfile
4
+
5
+
6
+ def open_in_editor(initial_text: str) -> str:
7
+ with tempfile.NamedTemporaryFile(suffix='.txt', mode='w', delete=False) as f:
8
+ f.write(initial_text)
9
+ tmp = f.name
10
+ subprocess.run([os.environ.get('EDITOR', 'notepad'), tmp])
11
+ with open(tmp) as f:
12
+ result = f.read().strip()
13
+ os.unlink(tmp)
14
+ return result
@@ -0,0 +1,9 @@
1
+ import subprocess
2
+
3
+
4
+ def get_staged_diff() -> str:
5
+ return subprocess.check_output(['git', 'diff', '--cached']).decode()
6
+
7
+
8
+ def commit(message: str) -> None:
9
+ subprocess.run(['git', 'commit', '-m', message])
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-commit-msg-ai
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: AI-powered git commit message generator following Conventional Commits
5
- License: MIT
5
+ License-Expression: MIT
6
6
  Requires-Python: >=3.9
7
7
  Description-Content-Type: text/markdown
8
8
  Requires-Dist: anthropic
@@ -1,6 +1,10 @@
1
1
  README.md
2
- commit_msg.py
3
2
  pyproject.toml
3
+ git_commit_msg_ai/__init__.py
4
+ git_commit_msg_ai/ai_client.py
5
+ git_commit_msg_ai/cli.py
6
+ git_commit_msg_ai/editor.py
7
+ git_commit_msg_ai/git_ops.py
4
8
  git_commit_msg_ai.egg-info/PKG-INFO
5
9
  git_commit_msg_ai.egg-info/SOURCES.txt
6
10
  git_commit_msg_ai.egg-info/dependency_links.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ git-commit-msg-ai = git_commit_msg_ai.cli:main
@@ -0,0 +1 @@
1
+ git_commit_msg_ai
@@ -4,15 +4,16 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "git-commit-msg-ai"
7
- version = "1.0.0"
7
+ version = "1.1.0"
8
8
  description = "AI-powered git commit message generator following Conventional Commits"
9
9
  readme = "README.md"
10
- license = { text = "MIT" }
10
+ license = "MIT"
11
11
  requires-python = ">=3.9"
12
12
  dependencies = ["anthropic"]
13
13
 
14
14
  [project.scripts]
15
- git-commit-msg-ai = "commit_msg:main"
15
+ git-commit-msg-ai = "git_commit_msg_ai.cli:main"
16
16
 
17
- [tool.setuptools]
18
- py-modules = ["commit_msg"]
17
+ [tool.setuptools.packages.find]
18
+ where = ["."]
19
+ include = ["git_commit_msg_ai*"]
@@ -1,50 +0,0 @@
1
- import subprocess
2
- import os
3
- import tempfile
4
- from typing import cast
5
- import anthropic
6
-
7
-
8
- def main():
9
- diff = subprocess.check_output(['git', 'diff', '--cached']).decode()
10
-
11
- client = anthropic.Anthropic()
12
- response = client.messages.create(
13
- model='claude-haiku-4-5-20251001',
14
- max_tokens=1024,
15
- system=(
16
- 'You are a Git commit message generator. Output only the commit message, nothing else. '
17
- 'Follow the Conventional Commits specification:\n'
18
- '- First line: <type>(<optional scope>)<!>: <short subject> (50 chars max); '
19
- 'append ! before the colon if the commit introduces a breaking change\n'
20
- '- Blank line\n'
21
- '- Bullet-point body explaining WHY the changes were made, not what\n'
22
- '- If there is a breaking change, add a blank line after the body followed by '
23
- '"BREAKING CHANGE: <description of what breaks and why>\n'
24
- 'Types: feat, fix, docs, style, refactor, test, chore'
25
- ),
26
- messages=[{'role': 'user', 'content': diff}],
27
- )
28
-
29
- msg = cast(anthropic.types.TextBlock, response.content[0]).text.strip()
30
- print(msg)
31
-
32
- choice = input('\n[a]ccept / [e]dit / [r]eject: ').strip().lower()
33
-
34
- if choice == 'a':
35
- subprocess.run(['git', 'commit', '-m', msg])
36
- elif choice == 'e':
37
- with tempfile.NamedTemporaryFile(suffix='.txt', mode='w', delete=False) as f:
38
- f.write(msg)
39
- tmp = f.name
40
- subprocess.run([os.environ.get('EDITOR', 'notepad'), tmp])
41
- with open(tmp) as f:
42
- msg = f.read().strip()
43
- os.unlink(tmp)
44
- subprocess.run(['git', 'commit', '-m', msg])
45
- elif choice == 'r':
46
- print('User rejected the generated commit message. No commit made.')
47
-
48
-
49
- if __name__ == '__main__':
50
- main()
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- git-commit-msg-ai = commit_msg:main