git-commit-msg-ai 1.0.0__tar.gz → 1.2.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.
- {git_commit_msg_ai-1.0.0 → git_commit_msg_ai-1.2.0}/PKG-INFO +5 -2
- git_commit_msg_ai-1.2.0/git_commit_msg_ai/__init__.py +0 -0
- git_commit_msg_ai-1.2.0/git_commit_msg_ai/ai_client.py +32 -0
- git_commit_msg_ai-1.2.0/git_commit_msg_ai/cli.py +22 -0
- git_commit_msg_ai-1.2.0/git_commit_msg_ai/editor.py +19 -0
- git_commit_msg_ai-1.2.0/git_commit_msg_ai/git_ops.py +12 -0
- {git_commit_msg_ai-1.0.0 → git_commit_msg_ai-1.2.0}/git_commit_msg_ai.egg-info/PKG-INFO +5 -2
- {git_commit_msg_ai-1.0.0 → git_commit_msg_ai-1.2.0}/git_commit_msg_ai.egg-info/SOURCES.txt +5 -1
- git_commit_msg_ai-1.2.0/git_commit_msg_ai.egg-info/entry_points.txt +2 -0
- git_commit_msg_ai-1.2.0/git_commit_msg_ai.egg-info/requires.txt +5 -0
- git_commit_msg_ai-1.2.0/git_commit_msg_ai.egg-info/top_level.txt +1 -0
- git_commit_msg_ai-1.2.0/pyproject.toml +33 -0
- git_commit_msg_ai-1.0.0/commit_msg.py +0 -50
- git_commit_msg_ai-1.0.0/git_commit_msg_ai.egg-info/entry_points.txt +0 -2
- git_commit_msg_ai-1.0.0/git_commit_msg_ai.egg-info/requires.txt +0 -1
- git_commit_msg_ai-1.0.0/git_commit_msg_ai.egg-info/top_level.txt +0 -1
- git_commit_msg_ai-1.0.0/pyproject.toml +0 -18
- {git_commit_msg_ai-1.0.0 → git_commit_msg_ai-1.2.0}/README.md +0 -0
- {git_commit_msg_ai-1.0.0 → git_commit_msg_ai-1.2.0}/git_commit_msg_ai.egg-info/dependency_links.txt +0 -0
- {git_commit_msg_ai-1.0.0 → git_commit_msg_ai-1.2.0}/setup.cfg +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-commit-msg-ai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.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
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: mypy; extra == "dev"
|
|
11
|
+
Requires-Dist: ruff; extra == "dev"
|
|
9
12
|
|
|
10
13
|
# git-commit-msg-ai
|
|
11
14
|
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import textwrap
|
|
2
|
+
from typing import Final, cast
|
|
3
|
+
|
|
4
|
+
import anthropic
|
|
5
|
+
|
|
6
|
+
SYSTEM_PROMPT: Final[str] = textwrap.dedent("""\
|
|
7
|
+
You are a Git commit message generator. Output only the commit message, nothing else. Follow the Conventional Commits specification:
|
|
8
|
+
- First line: <type>(<optional scope>)<!>: <short subject> (50 chars max); append ! before the colon if the commit introduces a breaking change
|
|
9
|
+
- Blank line
|
|
10
|
+
- Bullet-point body explaining WHY the changes were made, not what
|
|
11
|
+
- If there is a breaking change, add a blank line after the body followed by "BREAKING CHANGE: <description of what breaks and why>
|
|
12
|
+
Types: feat, fix, docs, style, refactor, test, chore""")
|
|
13
|
+
|
|
14
|
+
MODEL: Final[str] = 'claude-haiku-4-5-20251001'
|
|
15
|
+
MAX_TOKENS: Final[int] = 1024
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def generate_commit_message(diff: str) -> str:
|
|
19
|
+
anthropic_client = anthropic.Anthropic()
|
|
20
|
+
|
|
21
|
+
anthropic_api_response = anthropic_client.messages.create(
|
|
22
|
+
model=MODEL,
|
|
23
|
+
max_tokens=MAX_TOKENS,
|
|
24
|
+
system=SYSTEM_PROMPT,
|
|
25
|
+
messages=[{'role': 'user', 'content': diff}],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
anthropic_api_response_message = anthropic_api_response.content[0]
|
|
29
|
+
commit_message = cast(anthropic.types.TextBlock, anthropic_api_response_message).text.strip()
|
|
30
|
+
|
|
31
|
+
return commit_message
|
|
32
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
commit_message = ai_client.generate_commit_message(diff)
|
|
7
|
+
print(commit_message)
|
|
8
|
+
|
|
9
|
+
print()
|
|
10
|
+
user_selection = input('[a]ccept / [e]dit / [r]eject: ').strip().lower()
|
|
11
|
+
|
|
12
|
+
if user_selection == 'a':
|
|
13
|
+
git_ops.commit(commit_message)
|
|
14
|
+
elif user_selection == 'e':
|
|
15
|
+
updated_commit_message = editor.open_in_editor(commit_message)
|
|
16
|
+
git_ops.commit(updated_commit_message)
|
|
17
|
+
elif user_selection == 'r':
|
|
18
|
+
print('User rejected the generated commit message. No commit made.')
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if __name__ == '__main__':
|
|
22
|
+
main()
|
|
@@ -0,0 +1,19 @@
|
|
|
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 temp_file:
|
|
8
|
+
temp_file.write(initial_text)
|
|
9
|
+
temp_file_path = temp_file.name
|
|
10
|
+
|
|
11
|
+
editor_command = os.environ.get('EDITOR', 'notepad')
|
|
12
|
+
subprocess.run([editor_command, temp_file_path])
|
|
13
|
+
|
|
14
|
+
with open(temp_file_path) as temp_file:
|
|
15
|
+
edited_text = temp_file.read().strip()
|
|
16
|
+
|
|
17
|
+
os.unlink(temp_file_path)
|
|
18
|
+
|
|
19
|
+
return edited_text
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-commit-msg-ai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.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
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: mypy; extra == "dev"
|
|
11
|
+
Requires-Dist: ruff; extra == "dev"
|
|
9
12
|
|
|
10
13
|
# git-commit-msg-ai
|
|
11
14
|
|
|
@@ -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 @@
|
|
|
1
|
+
git_commit_msg_ai
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "git-commit-msg-ai"
|
|
7
|
+
version = "1.2.0"
|
|
8
|
+
description = "AI-powered git commit message generator following Conventional Commits"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = ["anthropic"]
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
git-commit-msg-ai = "git_commit_msg_ai.cli:main"
|
|
16
|
+
|
|
17
|
+
[project.optional-dependencies]
|
|
18
|
+
dev = ["mypy", "ruff"]
|
|
19
|
+
|
|
20
|
+
[tool.ruff]
|
|
21
|
+
target-version = "py39"
|
|
22
|
+
line-length = 320
|
|
23
|
+
|
|
24
|
+
[tool.ruff.lint]
|
|
25
|
+
select = ["E", "F", "I"]
|
|
26
|
+
|
|
27
|
+
[tool.mypy]
|
|
28
|
+
python_version = "3.9"
|
|
29
|
+
strict = true
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
where = ["."]
|
|
33
|
+
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 +0,0 @@
|
|
|
1
|
-
anthropic
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
commit_msg
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "git-commit-msg-ai"
|
|
7
|
-
version = "1.0.0"
|
|
8
|
-
description = "AI-powered git commit message generator following Conventional Commits"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
license = { text = "MIT" }
|
|
11
|
-
requires-python = ">=3.9"
|
|
12
|
-
dependencies = ["anthropic"]
|
|
13
|
-
|
|
14
|
-
[project.scripts]
|
|
15
|
-
git-commit-msg-ai = "commit_msg:main"
|
|
16
|
-
|
|
17
|
-
[tool.setuptools]
|
|
18
|
-
py-modules = ["commit_msg"]
|
|
File without changes
|
{git_commit_msg_ai-1.0.0 → git_commit_msg_ai-1.2.0}/git_commit_msg_ai.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|