git-commit-message 0.4.0__tar.gz → 0.5.1__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.
Files changed (19) hide show
  1. git_commit_message-0.5.1/PKG-INFO +152 -0
  2. git_commit_message-0.4.0/PKG-INFO → git_commit_message-0.5.1/README.md +45 -15
  3. git_commit_message-0.5.1/UNLICENSE +24 -0
  4. git_commit_message-0.5.1/pyproject.toml +54 -0
  5. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message/_cli.py +1 -1
  6. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message/_gpt.py +91 -45
  7. git_commit_message-0.5.1/src/git_commit_message.egg-info/PKG-INFO +152 -0
  8. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message.egg-info/SOURCES.txt +1 -0
  9. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message.egg-info/requires.txt +1 -0
  10. git_commit_message-0.4.0/README.md +0 -66
  11. git_commit_message-0.4.0/pyproject.toml +0 -20
  12. git_commit_message-0.4.0/src/git_commit_message.egg-info/PKG-INFO +0 -74
  13. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/setup.cfg +0 -0
  14. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message/__init__.py +0 -0
  15. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message/__main__.py +0 -0
  16. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message/_git.py +0 -0
  17. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message.egg-info/dependency_links.txt +0 -0
  18. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message.egg-info/entry_points.txt +0 -0
  19. {git_commit_message-0.4.0 → git_commit_message-0.5.1}/src/git_commit_message.egg-info/top_level.txt +0 -0
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-commit-message
3
+ Version: 0.5.1
4
+ Summary: Generate Git commit messages from staged changes using OpenAI GPT
5
+ Maintainer-email: Mina Her <minacle@live.com>
6
+ License: This is free and unencumbered software released into the public domain.
7
+
8
+ Anyone is free to copy, modify, publish, use, compile, sell, or
9
+ distribute this software, either in source code form or as a compiled
10
+ binary, for any purpose, commercial or non-commercial, and by any
11
+ means.
12
+
13
+ In jurisdictions that recognize copyright laws, the author or authors
14
+ of this software dedicate any and all copyright interest in the
15
+ software to the public domain. We make this dedication for the benefit
16
+ of the public at large and to the detriment of our heirs and
17
+ successors. We intend this dedication to be an overt act of
18
+ relinquishment in perpetuity of all present and future rights to this
19
+ software under copyright law.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ OTHER DEALINGS IN THE SOFTWARE.
28
+
29
+ For more information, please refer to <https://unlicense.org/>
30
+
31
+ Project-URL: Homepage, https://github.com/minacle/git-commit-message
32
+ Project-URL: Repository, https://github.com/minacle/git-commit-message
33
+ Project-URL: Issues, https://github.com/minacle/git-commit-message/issues
34
+ Classifier: Development Status :: 3 - Alpha
35
+ Classifier: Environment :: Console
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
38
+ Classifier: Operating System :: OS Independent
39
+ Classifier: Programming Language :: Python
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Programming Language :: Python :: 3 :: Only
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Topic :: Software Development :: Version Control :: Git
44
+ Requires-Python: >=3.13
45
+ Description-Content-Type: text/markdown
46
+ Requires-Dist: babel>=2.17.0
47
+ Requires-Dist: openai>=2.6.1
48
+
49
+ # git-commit-message
50
+
51
+ Staged changes -> GPT commit message generator.
52
+
53
+ [![asciicast](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN.svg)](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN)
54
+
55
+ ## Install (PyPI)
56
+
57
+ Install the latest released version from PyPI:
58
+
59
+ ```sh
60
+ # User environment (recommended)
61
+ python -m pip install --user git-commit-message
62
+
63
+ # Or system/virtualenv as appropriate
64
+ python -m pip install git-commit-message
65
+
66
+ # Or with pipx for isolated CLI installs
67
+ pipx install git-commit-message
68
+
69
+ # Upgrade to the newest version
70
+ python -m pip install --upgrade git-commit-message
71
+ ```
72
+
73
+ Quick check:
74
+
75
+ ```sh
76
+ git-commit-message --help
77
+ ```
78
+
79
+ Set your API key (POSIX sh):
80
+
81
+ ```sh
82
+ export OPENAI_API_KEY="sk-..."
83
+ ```
84
+
85
+ Note (fish): In fish, set it as follows.
86
+
87
+ ```fish
88
+ set -x OPENAI_API_KEY "sk-..."
89
+ ```
90
+
91
+ ## Install (editable)
92
+
93
+ ```sh
94
+ python -m pip install -e .
95
+ ```
96
+
97
+ ## Usage
98
+
99
+ - Print commit message only:
100
+
101
+ ```sh
102
+ git add -A
103
+ git-commit-message "optional extra context about the change"
104
+ ```
105
+
106
+ - Force single-line subject only:
107
+
108
+ ```sh
109
+ git-commit-message --one-line "optional context"
110
+ ```
111
+
112
+ - Limit subject length (default 72):
113
+
114
+ ```sh
115
+ git-commit-message --one-line --max-length 50 "optional context"
116
+ ```
117
+
118
+ - Commit immediately with editor:
119
+
120
+ ```sh
121
+ git-commit-message --commit --edit "refactor parser for speed"
122
+ ```
123
+
124
+ - Select output language/locale (default: en-GB):
125
+
126
+ ```sh
127
+ # American English
128
+ git-commit-message --language en-US "optional context"
129
+
130
+ # Korean
131
+ git-commit-message --language ko-KR
132
+
133
+ # Japanese
134
+ git-commit-message --language ja-JP
135
+ ```
136
+
137
+ Notes:
138
+
139
+ - The model is instructed to write using the selected language/locale.
140
+ - In multi-line mode, the only allowed label ("Rationale:") is also translated into the target language.
141
+
142
+ Environment:
143
+
144
+ - `OPENAI_API_KEY`: required
145
+ - `GIT_COMMIT_MESSAGE_MODEL` or `OPENAI_MODEL`: optional (default: `gpt-5-mini`)
146
+ - `GIT_COMMIT_MESSAGE_LANGUAGE`: optional (default: `en-GB`)
147
+
148
+ ## AI‑generated code notice
149
+
150
+ Parts of this project were created with assistance from AI tools (e.g. large language models).
151
+ All AI‑assisted contributions were reviewed and adapted by maintainers before inclusion.
152
+ If you need provenance for specific changes, please refer to the Git history and commit messages.
@@ -1,18 +1,48 @@
1
- Metadata-Version: 2.4
2
- Name: git-commit-message
3
- Version: 0.4.0
4
- Summary: Generate Git commit messages from staged changes using OpenAI GPT
5
- Requires-Python: >=3.13
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: openai>=2.6.1
8
-
9
1
  # git-commit-message
10
2
 
11
3
  Staged changes -> GPT commit message generator.
12
4
 
13
- ## Install (editable)
5
+ [![asciicast](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN.svg)](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN)
6
+
7
+ ## Install (PyPI)
8
+
9
+ Install the latest released version from PyPI:
10
+
11
+ ```sh
12
+ # User environment (recommended)
13
+ python -m pip install --user git-commit-message
14
+
15
+ # Or system/virtualenv as appropriate
16
+ python -m pip install git-commit-message
17
+
18
+ # Or with pipx for isolated CLI installs
19
+ pipx install git-commit-message
20
+
21
+ # Upgrade to the newest version
22
+ python -m pip install --upgrade git-commit-message
23
+ ```
24
+
25
+ Quick check:
26
+
27
+ ```sh
28
+ git-commit-message --help
29
+ ```
30
+
31
+ Set your API key (POSIX sh):
32
+
33
+ ```sh
34
+ export OPENAI_API_KEY="sk-..."
35
+ ```
36
+
37
+ Note (fish): In fish, set it as follows.
14
38
 
15
39
  ```fish
40
+ set -x OPENAI_API_KEY "sk-..."
41
+ ```
42
+
43
+ ## Install (editable)
44
+
45
+ ```sh
16
46
  python -m pip install -e .
17
47
  ```
18
48
 
@@ -20,32 +50,32 @@ python -m pip install -e .
20
50
 
21
51
  - Print commit message only:
22
52
 
23
- ```fish
53
+ ```sh
24
54
  git add -A
25
55
  git-commit-message "optional extra context about the change"
26
56
  ```
27
57
 
28
58
  - Force single-line subject only:
29
59
 
30
- ```fish
60
+ ```sh
31
61
  git-commit-message --one-line "optional context"
32
62
  ```
33
63
 
34
64
  - Limit subject length (default 72):
35
65
 
36
- ```fish
66
+ ```sh
37
67
  git-commit-message --one-line --max-length 50 "optional context"
38
68
  ```
39
69
 
40
70
  - Commit immediately with editor:
41
71
 
42
- ```fish
72
+ ```sh
43
73
  git-commit-message --commit --edit "refactor parser for speed"
44
74
  ```
45
75
 
46
76
  - Select output language/locale (default: en-GB):
47
77
 
48
- ```fish
78
+ ```sh
49
79
  # American English
50
80
  git-commit-message --language en-US "optional context"
51
81
 
@@ -65,7 +95,7 @@ Environment:
65
95
 
66
96
  - `OPENAI_API_KEY`: required
67
97
  - `GIT_COMMIT_MESSAGE_MODEL` or `OPENAI_MODEL`: optional (default: `gpt-5-mini`)
68
- - `GIT_COMMIT_MESSAGE_LANGUAGE` or `OPENAI_LANGUAGE`: optional (default: `en-GB`)
98
+ - `GIT_COMMIT_MESSAGE_LANGUAGE`: optional (default: `en-GB`)
69
99
 
70
100
  ## AI‑generated code notice
71
101
 
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org/>
@@ -0,0 +1,54 @@
1
+ [project]
2
+ name = "git-commit-message"
3
+ version = "0.5.1"
4
+ description = "Generate Git commit messages from staged changes using OpenAI GPT"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = [
8
+ "babel>=2.17.0",
9
+ "openai>=2.6.1",
10
+ ]
11
+ maintainers = [{ name = "Mina Her", email = "minacle@live.com" }]
12
+ license = { file = "UNLICENSE" }
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: The Unlicense (Unlicense)",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Software Development :: Version Control :: Git",
24
+ ]
25
+
26
+ [project.scripts]
27
+ git-commit-message = "git_commit_message:main"
28
+
29
+ [build-system]
30
+ requires = ["setuptools>=80", "wheel"]
31
+ build-backend = "setuptools.build_meta"
32
+
33
+ [tool.setuptools]
34
+ package-dir = {"" = "src"}
35
+ packages = ["git_commit_message"]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/minacle/git-commit-message"
39
+ Repository = "https://github.com/minacle/git-commit-message"
40
+ Issues = "https://github.com/minacle/git-commit-message/issues"
41
+
42
+ [tool.pyright]
43
+ # Ensure Pyright/Pylance resolves project imports and uses correct Python version
44
+ pythonVersion = "3.13"
45
+ extraPaths = ["src"]
46
+ typeCheckingMode = "basic"
47
+
48
+ # So that SDK dynamic types or untyped third-party libs don't flood with "unknown" diagnostics
49
+ reportUnknownParameterType = "none"
50
+ reportUnknownArgumentType = "none"
51
+ reportUnknownVariableType = "none"
52
+ reportUnknownMemberType = "none"
53
+ reportUnknownLambdaType = "none"
54
+ reportUnknownCalleeType = "none"
@@ -67,7 +67,7 @@ def _build_parser() -> ArgumentParser:
67
67
  default=None,
68
68
  help=(
69
69
  "Target language/locale IETF tag for the output (default: en-GB). "
70
- "You may also set GIT_COMMIT_MESSAGE_LANGUAGE or OPENAI_LANGUAGE."
70
+ "You may also set GIT_COMMIT_MESSAGE_LANGUAGE."
71
71
  ),
72
72
  )
73
73
 
@@ -1,9 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
- """Generate Git commit messages by calling an OpenAI GPT model."""
3
+ from openai.types.responses import ResponseInputParam
4
+
5
+ """Generate Git commit messages by calling an OpenAI GPT model.
6
+
7
+ Migrated to use OpenAI Responses API (client.responses.create).
8
+ """
4
9
 
5
10
  import os
6
- from typing import Final, Any, cast
11
+ from typing import Final
12
+ from babel import Locale
7
13
  from openai import OpenAI
8
14
 
9
15
 
@@ -16,11 +22,12 @@ def _build_system_prompt(
16
22
  subject_max: int | None,
17
23
  language: str,
18
24
  ) -> str:
25
+ display_language: str = _language_display(language)
19
26
  max_len = subject_max or 72
20
27
  if single_line:
21
28
  return (
22
29
  f"You are an expert Git commit message generator. "
23
- f"Always use '{language}' spelling and style. "
30
+ f"Always use '{display_language}' spelling and style. "
24
31
  f"Return a single-line imperative subject only (<= {max_len} chars). "
25
32
  f"Do not include a body, bullet points, or any rationale. Do not include any line breaks. "
26
33
  f"Consider the user-provided auxiliary context if present. "
@@ -28,7 +35,7 @@ def _build_system_prompt(
28
35
  )
29
36
  return (
30
37
  f"You are an expert Git commit message generator. "
31
- f"Always use '{language}' spelling and style. "
38
+ f"Always use '{display_language}' spelling and style. "
32
39
  f"The subject line is mandatory: you MUST start the output with the subject as the very first non-empty line, "
33
40
  f"in imperative mood, and keep it <= {max_len} chars. Insert exactly one blank line after the subject. "
34
41
  f"Never start with bullets, headings, labels, or any other text. Then include a body in this format.\n\n"
@@ -47,6 +54,7 @@ def _build_system_prompt(
47
54
  f"- Prefer imperative mood verbs (Add, Fix, Update, Remove, Refactor, Document, etc.).\n"
48
55
  f"- Focus on what changed and why; avoid copying diff hunks verbatim.\n"
49
56
  f"- The only allowed label is the equivalent of 'Rationale:' translated into the target language; do not add other headings or prefaces.\n"
57
+ f"- All text (subject, bullets, rationale label, rationale content) MUST be in the target language: '{display_language}'. Do not mix other languages.\n"
50
58
  f"- Do not include the '---' delimiter lines, code fences, or any surrounding labels like 'Commit message:'.\n"
51
59
  f"- Do not copy or reuse any example text verbatim; produce original content based on the provided diff and context.\n"
52
60
  f"- If few details are necessary, include at least one bullet summarising the key change.\n"
@@ -56,14 +64,39 @@ def _build_system_prompt(
56
64
  )
57
65
 
58
66
 
59
- def _system_message(
67
+ def _language_display(language: str) -> str:
68
+ """Return a human-friendly language display like 'ko-KR, Korean (South Korea)'."""
69
+
70
+ try:
71
+ locale = Locale.parse(language, sep="-")
72
+ except Exception:
73
+ return language
74
+
75
+ tag_parts = [
76
+ locale.language,
77
+ locale.script,
78
+ locale.territory,
79
+ locale.variant,
80
+ ]
81
+ tag = "-".join(part for part in tag_parts if part)
82
+ if not tag:
83
+ return language
84
+
85
+ english_name = locale.get_display_name("en") or ""
86
+ if not english_name:
87
+ return f"[{tag}]"
88
+
89
+ return f"{english_name.capitalize()} [{tag}]"
90
+
91
+
92
+ def _instructions(
60
93
  *,
61
94
  single_line: bool,
62
95
  subject_max: int | None,
63
96
  language: str,
64
- ) -> dict[str, str]:
65
- """Create the system message dictionary."""
66
- return {"role": "system", "content": _build_system_prompt(single_line=single_line, subject_max=subject_max, language=language)}
97
+ ) -> str:
98
+ """Create the system/developer instructions string for the Responses API."""
99
+ return _build_system_prompt(single_line=single_line, subject_max=subject_max, language=language)
67
100
 
68
101
 
69
102
  class CommitMessageResult:
@@ -131,23 +164,21 @@ def _resolve_language(
131
164
  return (
132
165
  language
133
166
  or os.environ.get("GIT_COMMIT_MESSAGE_LANGUAGE")
134
- or os.environ.get("OPENAI_LANGUAGE")
135
167
  or _DEFAULT_LANGUAGE
136
168
  )
137
169
 
138
170
 
139
- def _build_user_messages(
171
+ def _build_responses_input(
140
172
  *,
141
173
  diff: str,
142
174
  hint: str | None,
143
- ) -> tuple[str, list[dict[str, str]]]:
144
- """Compose user messages, separating auxiliary context and diff.
175
+ ) -> ResponseInputParam:
176
+ """Compose Responses API input items, separating auxiliary context and diff.
145
177
 
146
178
  Returns
147
179
  -------
148
- tuple[str, list[dict[str, str]]]
149
- The first element is the combined string for debugging output; the
150
- second is the list of user messages to send to the Chat Completions API.
180
+ ResponseInputParam
181
+ The list of input items to send to the Responses API.
151
182
  """
152
183
 
153
184
  hint_content: str | None = (
@@ -155,15 +186,35 @@ def _build_user_messages(
155
186
  )
156
187
  diff_content: str = f"# Changes (diff)\n{diff}"
157
188
 
158
- messages: list[dict[str, str]] = []
189
+ input_items: ResponseInputParam = []
159
190
  if hint_content:
160
- messages.append({"role": "user", "content": hint_content})
161
- messages.append({"role": "user", "content": diff_content})
191
+ input_items.append(
192
+ {
193
+ "role": "user",
194
+ "content": [
195
+ {"type": "input_text", "text": hint_content},
196
+ ],
197
+ }
198
+ )
199
+ input_items.append(
200
+ {
201
+ "role": "user",
202
+ "content": [
203
+ {"type": "input_text", "text": diff_content},
204
+ ],
205
+ }
206
+ )
207
+
208
+ return input_items
209
+
162
210
 
163
- combined_prompt: str = "\n\n".join(
164
- [part for part in (hint_content, diff_content) if part is not None]
211
+ def _build_combined_prompt(*, diff: str, hint: str | None) -> str:
212
+ """Compose a combined string of hint and diff for debug/info output."""
213
+ hint_content: str | None = (
214
+ f"# Auxiliary context (user-provided)\n{hint}" if hint else None
165
215
  )
166
- return combined_prompt, messages
216
+ diff_content: str = f"# Changes (diff)\n{diff}"
217
+ return "\n\n".join([part for part in (hint_content, diff_content) if part is not None])
167
218
 
168
219
 
169
220
  def generate_commit_message(
@@ -185,20 +236,17 @@ def generate_commit_message(
185
236
 
186
237
  client = OpenAI(api_key=api_key)
187
238
 
188
- _combined_prompt, user_messages = _build_user_messages(diff=diff, hint=hint)
189
-
190
- # Use Chat Completions API to generate a single response (send hint and diff as separate user messages)
191
- all_messages: list[dict[str, str]] = [
192
- _system_message(single_line=single_line, subject_max=subject_max, language=chosen_language),
193
- *user_messages,
194
- ]
239
+ input_items = _build_responses_input(diff=diff, hint=hint)
195
240
 
196
- resp = client.chat.completions.create(
241
+ # Use Responses API to generate a single response (send hint and diff as separate user inputs)
242
+ resp = client.responses.create(
197
243
  model=chosen_model,
198
- messages=cast(Any, all_messages),
244
+ instructions=_instructions(single_line=single_line, subject_max=subject_max, language=chosen_language),
245
+ input=input_items,
199
246
  )
200
247
 
201
- text: str = (resp.choices[0].message.content or "").strip()
248
+ # Prefer SDK convenience aggregate text if available
249
+ text: str = (resp.output_text or "").strip()
202
250
  if not text:
203
251
  raise RuntimeError("An empty commit message was generated.")
204
252
  return text
@@ -228,31 +276,29 @@ def generate_commit_message_with_info(
228
276
  raise RuntimeError("The OPENAI_API_KEY environment variable is required.")
229
277
 
230
278
  client = OpenAI(api_key=api_key)
231
- combined_prompt, user_messages = _build_user_messages(diff=diff, hint=hint)
232
-
233
- all_messages = [
234
- _system_message(single_line=single_line, subject_max=subject_max, language=chosen_language),
235
- *user_messages,
236
- ]
279
+ combined_prompt = _build_combined_prompt(diff=diff, hint=hint)
280
+ input_items = _build_responses_input(diff=diff, hint=hint)
237
281
 
238
- resp = client.chat.completions.create(
282
+ resp = client.responses.create(
239
283
  model=chosen_model,
240
- messages=cast(Any, all_messages),
284
+ instructions=_instructions(single_line=single_line, subject_max=subject_max, language=chosen_language),
285
+ input=input_items,
241
286
  )
242
287
 
243
- response_text: str = (resp.choices[0].message.content or "").strip()
288
+ response_text: str = (resp.output_text or "").strip()
244
289
  if not response_text:
245
290
  raise RuntimeError("An empty commit message was generated.")
246
291
 
247
- response_id: str | None = getattr(resp, "id", None)
248
- usage = getattr(resp, "usage", None)
292
+ response_id: str | None = resp.id
293
+ usage = resp.usage
249
294
  prompt_tokens: int | None = None
250
295
  completion_tokens: int | None = None
251
296
  total_tokens: int | None = None
252
297
  if usage is not None:
253
- prompt_tokens = getattr(usage, "prompt_tokens", None)
254
- completion_tokens = getattr(usage, "completion_tokens", None)
255
- total_tokens = getattr(usage, "total_tokens", None)
298
+ # Responses API exposes input/output/total token fields.
299
+ total_tokens = usage.total_tokens
300
+ prompt_tokens = usage.input_tokens
301
+ completion_tokens = usage.output_tokens
256
302
 
257
303
  return CommitMessageResult(
258
304
  message=response_text,
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-commit-message
3
+ Version: 0.5.1
4
+ Summary: Generate Git commit messages from staged changes using OpenAI GPT
5
+ Maintainer-email: Mina Her <minacle@live.com>
6
+ License: This is free and unencumbered software released into the public domain.
7
+
8
+ Anyone is free to copy, modify, publish, use, compile, sell, or
9
+ distribute this software, either in source code form or as a compiled
10
+ binary, for any purpose, commercial or non-commercial, and by any
11
+ means.
12
+
13
+ In jurisdictions that recognize copyright laws, the author or authors
14
+ of this software dedicate any and all copyright interest in the
15
+ software to the public domain. We make this dedication for the benefit
16
+ of the public at large and to the detriment of our heirs and
17
+ successors. We intend this dedication to be an overt act of
18
+ relinquishment in perpetuity of all present and future rights to this
19
+ software under copyright law.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ OTHER DEALINGS IN THE SOFTWARE.
28
+
29
+ For more information, please refer to <https://unlicense.org/>
30
+
31
+ Project-URL: Homepage, https://github.com/minacle/git-commit-message
32
+ Project-URL: Repository, https://github.com/minacle/git-commit-message
33
+ Project-URL: Issues, https://github.com/minacle/git-commit-message/issues
34
+ Classifier: Development Status :: 3 - Alpha
35
+ Classifier: Environment :: Console
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
38
+ Classifier: Operating System :: OS Independent
39
+ Classifier: Programming Language :: Python
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Programming Language :: Python :: 3 :: Only
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Topic :: Software Development :: Version Control :: Git
44
+ Requires-Python: >=3.13
45
+ Description-Content-Type: text/markdown
46
+ Requires-Dist: babel>=2.17.0
47
+ Requires-Dist: openai>=2.6.1
48
+
49
+ # git-commit-message
50
+
51
+ Staged changes -> GPT commit message generator.
52
+
53
+ [![asciicast](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN.svg)](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN)
54
+
55
+ ## Install (PyPI)
56
+
57
+ Install the latest released version from PyPI:
58
+
59
+ ```sh
60
+ # User environment (recommended)
61
+ python -m pip install --user git-commit-message
62
+
63
+ # Or system/virtualenv as appropriate
64
+ python -m pip install git-commit-message
65
+
66
+ # Or with pipx for isolated CLI installs
67
+ pipx install git-commit-message
68
+
69
+ # Upgrade to the newest version
70
+ python -m pip install --upgrade git-commit-message
71
+ ```
72
+
73
+ Quick check:
74
+
75
+ ```sh
76
+ git-commit-message --help
77
+ ```
78
+
79
+ Set your API key (POSIX sh):
80
+
81
+ ```sh
82
+ export OPENAI_API_KEY="sk-..."
83
+ ```
84
+
85
+ Note (fish): In fish, set it as follows.
86
+
87
+ ```fish
88
+ set -x OPENAI_API_KEY "sk-..."
89
+ ```
90
+
91
+ ## Install (editable)
92
+
93
+ ```sh
94
+ python -m pip install -e .
95
+ ```
96
+
97
+ ## Usage
98
+
99
+ - Print commit message only:
100
+
101
+ ```sh
102
+ git add -A
103
+ git-commit-message "optional extra context about the change"
104
+ ```
105
+
106
+ - Force single-line subject only:
107
+
108
+ ```sh
109
+ git-commit-message --one-line "optional context"
110
+ ```
111
+
112
+ - Limit subject length (default 72):
113
+
114
+ ```sh
115
+ git-commit-message --one-line --max-length 50 "optional context"
116
+ ```
117
+
118
+ - Commit immediately with editor:
119
+
120
+ ```sh
121
+ git-commit-message --commit --edit "refactor parser for speed"
122
+ ```
123
+
124
+ - Select output language/locale (default: en-GB):
125
+
126
+ ```sh
127
+ # American English
128
+ git-commit-message --language en-US "optional context"
129
+
130
+ # Korean
131
+ git-commit-message --language ko-KR
132
+
133
+ # Japanese
134
+ git-commit-message --language ja-JP
135
+ ```
136
+
137
+ Notes:
138
+
139
+ - The model is instructed to write using the selected language/locale.
140
+ - In multi-line mode, the only allowed label ("Rationale:") is also translated into the target language.
141
+
142
+ Environment:
143
+
144
+ - `OPENAI_API_KEY`: required
145
+ - `GIT_COMMIT_MESSAGE_MODEL` or `OPENAI_MODEL`: optional (default: `gpt-5-mini`)
146
+ - `GIT_COMMIT_MESSAGE_LANGUAGE`: optional (default: `en-GB`)
147
+
148
+ ## AI‑generated code notice
149
+
150
+ Parts of this project were created with assistance from AI tools (e.g. large language models).
151
+ All AI‑assisted contributions were reviewed and adapted by maintainers before inclusion.
152
+ If you need provenance for specific changes, please refer to the Git history and commit messages.
@@ -1,4 +1,5 @@
1
1
  README.md
2
+ UNLICENSE
2
3
  pyproject.toml
3
4
  src/git_commit_message/__init__.py
4
5
  src/git_commit_message/__main__.py
@@ -1,66 +0,0 @@
1
- # git-commit-message
2
-
3
- Staged changes -> GPT commit message generator.
4
-
5
- ## Install (editable)
6
-
7
- ```fish
8
- python -m pip install -e .
9
- ```
10
-
11
- ## Usage
12
-
13
- - Print commit message only:
14
-
15
- ```fish
16
- git add -A
17
- git-commit-message "optional extra context about the change"
18
- ```
19
-
20
- - Force single-line subject only:
21
-
22
- ```fish
23
- git-commit-message --one-line "optional context"
24
- ```
25
-
26
- - Limit subject length (default 72):
27
-
28
- ```fish
29
- git-commit-message --one-line --max-length 50 "optional context"
30
- ```
31
-
32
- - Commit immediately with editor:
33
-
34
- ```fish
35
- git-commit-message --commit --edit "refactor parser for speed"
36
- ```
37
-
38
- - Select output language/locale (default: en-GB):
39
-
40
- ```fish
41
- # American English
42
- git-commit-message --language en-US "optional context"
43
-
44
- # Korean
45
- git-commit-message --language ko-KR
46
-
47
- # Japanese
48
- git-commit-message --language ja-JP
49
- ```
50
-
51
- Notes:
52
-
53
- - The model is instructed to write using the selected language/locale.
54
- - In multi-line mode, the only allowed label ("Rationale:") is also translated into the target language.
55
-
56
- Environment:
57
-
58
- - `OPENAI_API_KEY`: required
59
- - `GIT_COMMIT_MESSAGE_MODEL` or `OPENAI_MODEL`: optional (default: `gpt-5-mini`)
60
- - `GIT_COMMIT_MESSAGE_LANGUAGE` or `OPENAI_LANGUAGE`: optional (default: `en-GB`)
61
-
62
- ## AI‑generated code notice
63
-
64
- Parts of this project were created with assistance from AI tools (e.g. large language models).
65
- All AI‑assisted contributions were reviewed and adapted by maintainers before inclusion.
66
- If you need provenance for specific changes, please refer to the Git history and commit messages.
@@ -1,20 +0,0 @@
1
- [project]
2
- name = "git-commit-message"
3
- version = "0.4.0"
4
- description = "Generate Git commit messages from staged changes using OpenAI GPT"
5
- readme = "README.md"
6
- requires-python = ">=3.13"
7
- dependencies = [
8
- "openai>=2.6.1",
9
- ]
10
-
11
- [project.scripts]
12
- git-commit-message = "git_commit_message:main"
13
-
14
- [build-system]
15
- requires = ["setuptools>=80", "wheel"]
16
- build-backend = "setuptools.build_meta"
17
-
18
- [tool.setuptools]
19
- package-dir = {"" = "src"}
20
- packages = ["git_commit_message"]
@@ -1,74 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: git-commit-message
3
- Version: 0.4.0
4
- Summary: Generate Git commit messages from staged changes using OpenAI GPT
5
- Requires-Python: >=3.13
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: openai>=2.6.1
8
-
9
- # git-commit-message
10
-
11
- Staged changes -> GPT commit message generator.
12
-
13
- ## Install (editable)
14
-
15
- ```fish
16
- python -m pip install -e .
17
- ```
18
-
19
- ## Usage
20
-
21
- - Print commit message only:
22
-
23
- ```fish
24
- git add -A
25
- git-commit-message "optional extra context about the change"
26
- ```
27
-
28
- - Force single-line subject only:
29
-
30
- ```fish
31
- git-commit-message --one-line "optional context"
32
- ```
33
-
34
- - Limit subject length (default 72):
35
-
36
- ```fish
37
- git-commit-message --one-line --max-length 50 "optional context"
38
- ```
39
-
40
- - Commit immediately with editor:
41
-
42
- ```fish
43
- git-commit-message --commit --edit "refactor parser for speed"
44
- ```
45
-
46
- - Select output language/locale (default: en-GB):
47
-
48
- ```fish
49
- # American English
50
- git-commit-message --language en-US "optional context"
51
-
52
- # Korean
53
- git-commit-message --language ko-KR
54
-
55
- # Japanese
56
- git-commit-message --language ja-JP
57
- ```
58
-
59
- Notes:
60
-
61
- - The model is instructed to write using the selected language/locale.
62
- - In multi-line mode, the only allowed label ("Rationale:") is also translated into the target language.
63
-
64
- Environment:
65
-
66
- - `OPENAI_API_KEY`: required
67
- - `GIT_COMMIT_MESSAGE_MODEL` or `OPENAI_MODEL`: optional (default: `gpt-5-mini`)
68
- - `GIT_COMMIT_MESSAGE_LANGUAGE` or `OPENAI_LANGUAGE`: optional (default: `en-GB`)
69
-
70
- ## AI‑generated code notice
71
-
72
- Parts of this project were created with assistance from AI tools (e.g. large language models).
73
- All AI‑assisted contributions were reviewed and adapted by maintainers before inclusion.
74
- If you need provenance for specific changes, please refer to the Git history and commit messages.