git-commit-msg-ai 2.2.0__py3-none-any.whl → 2.3.0__py3-none-any.whl
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/ai_client.py +7 -3
- git_commit_msg_ai/cli.py +31 -13
- {git_commit_msg_ai-2.2.0.dist-info → git_commit_msg_ai-2.3.0.dist-info}/METADATA +6 -5
- {git_commit_msg_ai-2.2.0.dist-info → git_commit_msg_ai-2.3.0.dist-info}/RECORD +8 -8
- {git_commit_msg_ai-2.2.0.dist-info → git_commit_msg_ai-2.3.0.dist-info}/WHEEL +0 -0
- {git_commit_msg_ai-2.2.0.dist-info → git_commit_msg_ai-2.3.0.dist-info}/entry_points.txt +0 -0
- {git_commit_msg_ai-2.2.0.dist-info → git_commit_msg_ai-2.3.0.dist-info}/licenses/LICENSE +0 -0
- {git_commit_msg_ai-2.2.0.dist-info → git_commit_msg_ai-2.3.0.dist-info}/top_level.txt +0 -0
git_commit_msg_ai/ai_client.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import textwrap
|
|
3
|
-
from typing import Final
|
|
3
|
+
from typing import Final, cast
|
|
4
4
|
|
|
5
5
|
import anthropic
|
|
6
|
-
from anthropic.types import CacheControlEphemeralParam, TextBlockParam
|
|
6
|
+
from anthropic.types import CacheControlEphemeralParam, MessageParam, TextBlockParam
|
|
7
7
|
|
|
8
8
|
from git_commit_msg_ai.exceptions import AIError
|
|
9
9
|
|
|
@@ -46,17 +46,21 @@ def generate_commit_message(
|
|
|
46
46
|
*,
|
|
47
47
|
recent_commits: list[str] | None = None,
|
|
48
48
|
branch_name: str | None = None,
|
|
49
|
+
conversation_history: list[dict[str, str]] | None = None,
|
|
49
50
|
) -> str:
|
|
50
51
|
try:
|
|
51
52
|
anthropic_client = anthropic.Anthropic()
|
|
52
53
|
|
|
53
54
|
user_message = _build_user_message(diff, recent_commits, branch_name)
|
|
55
|
+
messages: list[MessageParam] = [{"role": "user", "content": user_message}]
|
|
56
|
+
if conversation_history:
|
|
57
|
+
messages.extend(cast(list[MessageParam], conversation_history))
|
|
54
58
|
logger.debug(f"Calling Anthropic API: model={MODEL} max_tokens={MAX_TOKENS}")
|
|
55
59
|
anthropic_api_response = anthropic_client.messages.create(
|
|
56
60
|
model=MODEL,
|
|
57
61
|
max_tokens=MAX_TOKENS,
|
|
58
62
|
system=_build_system_prompt(types),
|
|
59
|
-
messages=
|
|
63
|
+
messages=messages,
|
|
60
64
|
)
|
|
61
65
|
except anthropic.AuthenticationError:
|
|
62
66
|
raise AIError("Anthropic API key is missing or invalid. Set the ANTHROPIC_API_KEY environment variable.")
|
git_commit_msg_ai/cli.py
CHANGED
|
@@ -33,19 +33,37 @@ def main() -> None:
|
|
|
33
33
|
commit_message = ai_client.generate_commit_message(diff, app_config.types, recent_commits=recent_commits, branch_name=branch_name)
|
|
34
34
|
print(commit_message)
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
conversation_history: list[dict[str, str]] = [{"role": "assistant", "content": commit_message}]
|
|
37
|
+
|
|
38
|
+
while True:
|
|
39
|
+
print()
|
|
40
|
+
user_selection = input("[a]ccept / [e]dit / [r]eject / [f]eedback: ").strip().lower()
|
|
41
|
+
|
|
42
|
+
if user_selection == "a":
|
|
43
|
+
git_ops.commit(commit_message)
|
|
44
|
+
break
|
|
45
|
+
elif user_selection == "e":
|
|
46
|
+
updated_commit_message = editor.open_in_editor(commit_message)
|
|
47
|
+
git_ops.commit(updated_commit_message)
|
|
48
|
+
break
|
|
49
|
+
elif user_selection == "r":
|
|
50
|
+
print("User rejected the generated commit message. No commit made.")
|
|
51
|
+
break
|
|
52
|
+
elif user_selection == "f":
|
|
53
|
+
feedback = input("Feedback: ").strip()
|
|
54
|
+
conversation_history.append({"role": "user", "content": feedback})
|
|
55
|
+
commit_message = ai_client.generate_commit_message(
|
|
56
|
+
diff,
|
|
57
|
+
app_config.types,
|
|
58
|
+
recent_commits=recent_commits,
|
|
59
|
+
branch_name=branch_name,
|
|
60
|
+
conversation_history=list(conversation_history),
|
|
61
|
+
)
|
|
62
|
+
print(commit_message)
|
|
63
|
+
conversation_history.append({"role": "assistant", "content": commit_message})
|
|
64
|
+
else:
|
|
65
|
+
print("Invalid selection.")
|
|
66
|
+
sys.exit(1)
|
|
49
67
|
except GitCommitAIError as error:
|
|
50
68
|
logger.error(str(error))
|
|
51
69
|
print(f"Error: {error}", file=sys.stderr)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-commit-msg-ai
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: AI-powered git commit message generator following Conventional Commits
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -118,12 +118,13 @@ The tool will:
|
|
|
118
118
|
3. Print the message and prompt you to choose:
|
|
119
119
|
|
|
120
120
|
```
|
|
121
|
-
[a]ccept / [e]dit / [r]eject:
|
|
121
|
+
[a]ccept / [e]dit / [r]eject / [f]eedback:
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
- **a** - commits immediately with the generated message
|
|
125
125
|
- **e** - opens the message in your `$EDITOR` (defaults to `notepad` on Windows, `vi` on Linux/macOS), lets you modify it, then commits
|
|
126
126
|
- **r** - exits without committing
|
|
127
|
+
- **f** - prompts you for natural-language feedback, regenerates the message incorporating that feedback, and loops back so you can keep refining until satisfied
|
|
127
128
|
|
|
128
129
|
The tool automatically reads the current branch name and recent commit history and includes them in the request to the AI. This helps the AI match the commit style already established in the project. No configuration is required to enable this; see [Configuration](#configuration) to control how many recent commits are included.
|
|
129
130
|
|
|
@@ -214,11 +215,11 @@ Pushing a version tag (e.g. `v1.5.2`) triggers the CD pipeline:
|
|
|
214
215
|
# 1. Bump the version in pyproject.toml
|
|
215
216
|
# 2. Commit and push
|
|
216
217
|
git add pyproject.toml
|
|
217
|
-
git commit -m "chore: bump version to 2.
|
|
218
|
+
git commit -m "chore: bump version to 2.3.0"
|
|
218
219
|
git push origin main
|
|
219
220
|
# 3. Tag and push - this triggers the CD pipeline
|
|
220
|
-
git tag v2.
|
|
221
|
-
git push origin v2.
|
|
221
|
+
git tag v2.3.0
|
|
222
|
+
git push origin v2.3.0
|
|
222
223
|
```
|
|
223
224
|
|
|
224
225
|
## Debugging
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
git_commit_msg_ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
git_commit_msg_ai/ai_client.py,sha256=
|
|
3
|
-
git_commit_msg_ai/cli.py,sha256=
|
|
2
|
+
git_commit_msg_ai/ai_client.py,sha256=zgGrhVlLpTKkr4Z_7IbBvdJWIVObJvWCc8_DnUubiiY,3756
|
|
3
|
+
git_commit_msg_ai/cli.py,sha256=9RkXcTmeVn686b9F7upCgq8QQCpzHg8nnmwl1WpaqVg,3060
|
|
4
4
|
git_commit_msg_ai/config.py,sha256=5TqQR7VGzpev2_4a2tlsKD00tdFeOoJ1_XDIBhy_gDA,4513
|
|
5
5
|
git_commit_msg_ai/editor.py,sha256=wW7TJ4zVvvN7ThLtrJthAf9FjdmIDTbBS7V5pIW490s,2143
|
|
6
6
|
git_commit_msg_ai/exceptions.py,sha256=7Hwluf3zHMjs4lpGktWS-Lwgo8y_4Xbb1WqzPQHkkUA,352
|
|
7
7
|
git_commit_msg_ai/git_ops.py,sha256=Ve4ngXj0B3sYI4fKjIm-jKKe982Ohr9nbv1ZhNRGWFk,2329
|
|
8
|
-
git_commit_msg_ai-2.
|
|
9
|
-
git_commit_msg_ai-2.
|
|
10
|
-
git_commit_msg_ai-2.
|
|
11
|
-
git_commit_msg_ai-2.
|
|
12
|
-
git_commit_msg_ai-2.
|
|
13
|
-
git_commit_msg_ai-2.
|
|
8
|
+
git_commit_msg_ai-2.3.0.dist-info/licenses/LICENSE,sha256=BBR2CbV1SRenzTi4vvRx5wTIg32q898vdAyaLDN5wDc,1068
|
|
9
|
+
git_commit_msg_ai-2.3.0.dist-info/METADATA,sha256=EMAfQQAYvBnhM5jheLvG4dxqhS0zORFCExr-8m3dExg,9094
|
|
10
|
+
git_commit_msg_ai-2.3.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
11
|
+
git_commit_msg_ai-2.3.0.dist-info/entry_points.txt,sha256=KTu6wUhl0p3nf27k8L4vpSH_hpeRQpwzMPSmKv7K5Cs,65
|
|
12
|
+
git_commit_msg_ai-2.3.0.dist-info/top_level.txt,sha256=XYQC2BXvrcREGKEG7sm9nbwO7ifqcUSVgU7SW8BTURs,18
|
|
13
|
+
git_commit_msg_ai-2.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|