claude-commit 0.3.0__tar.gz → 0.3.2__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.
- {claude_commit-0.3.0/src/claude_commit.egg-info → claude_commit-0.3.2}/PKG-INFO +2 -2
- {claude_commit-0.3.0 → claude_commit-0.3.2}/README.md +1 -1
- {claude_commit-0.3.0 → claude_commit-0.3.2}/pyproject.toml +1 -1
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit/main.py +104 -74
- {claude_commit-0.3.0 → claude_commit-0.3.2/src/claude_commit.egg-info}/PKG-INFO +2 -2
- {claude_commit-0.3.0 → claude_commit-0.3.2}/LICENSE +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/setup.cfg +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit/__init__.py +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit/config.py +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit.egg-info/SOURCES.txt +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit.egg-info/dependency_links.txt +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit.egg-info/entry_points.txt +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit.egg-info/requires.txt +0 -0
- {claude_commit-0.3.0 → claude_commit-0.3.2}/src/claude_commit.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: claude-commit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: AI-powered git commit message generator using Claude Agent SDK
|
|
5
5
|
Author-email: Johannlai <johannli666@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -97,7 +97,7 @@ For custom Claude API endpoints or proxies, set these environment variables:
|
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
99
|
# Required: Set custom endpoint and credentials
|
|
100
|
-
export ANTHROPIC_BASE_URL="https://your-endpoint.com
|
|
100
|
+
export ANTHROPIC_BASE_URL="https://your-endpoint.com"
|
|
101
101
|
export ANTHROPIC_AUTH_TOKEN="your-auth-token"
|
|
102
102
|
|
|
103
103
|
# Optional: Specify custom model name
|
|
@@ -68,7 +68,7 @@ For custom Claude API endpoints or proxies, set these environment variables:
|
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
70
|
# Required: Set custom endpoint and credentials
|
|
71
|
-
export ANTHROPIC_BASE_URL="https://your-endpoint.com
|
|
71
|
+
export ANTHROPIC_BASE_URL="https://your-endpoint.com"
|
|
72
72
|
export ANTHROPIC_AUTH_TOKEN="your-auth-token"
|
|
73
73
|
|
|
74
74
|
# Optional: Specify custom model name
|
|
@@ -36,9 +36,12 @@ console = Console()
|
|
|
36
36
|
|
|
37
37
|
SYSTEM_PROMPT = """You are an expert software engineer tasked with analyzing code changes and writing excellent git commit messages.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
<goal>
|
|
40
|
+
Generate a clear, accurate, and meaningful commit message that captures the essence of the changes.
|
|
41
|
+
</goal>
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
<available_tools>
|
|
44
|
+
You have access to these tools for analyzing the codebase:
|
|
42
45
|
|
|
43
46
|
1. **Bash**: Run git commands and shell commands
|
|
44
47
|
- `git log`, `git status`, `git diff`, `git show`
|
|
@@ -76,17 +79,27 @@ Available tools you can use:
|
|
|
76
79
|
- Can search for specific code patterns: `{"file_path": "file.py", "old_string": "pattern to find"}`
|
|
77
80
|
- Useful when you need to understand multi-line changes or context around changes
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
**Pro tip**: Grep is faster than reading entire files. Use it to quickly assess impact before deciding which files to read in detail.
|
|
83
|
+
</available_tools>
|
|
84
|
+
|
|
85
|
+
<analysis_approach>
|
|
86
|
+
Follow this approach (you decide what's necessary based on the changes):
|
|
87
|
+
|
|
88
|
+
1. **IMPORTANT**: First check recent commit history to understand the existing commit message style
|
|
89
|
+
- Run: `git log -10 --oneline` or `git log -10 --pretty=format:"%s"`
|
|
81
90
|
- Check if the project uses gitmoji (emojis like 🎉, ✨, 🐛, etc.)
|
|
82
91
|
- Check if messages are in Chinese, English, or other languages
|
|
83
92
|
- Check if they use conventional commits (feat:, fix:, etc.) or other formats
|
|
84
93
|
- Note any specific patterns or conventions used
|
|
85
|
-
|
|
94
|
+
|
|
95
|
+
2. Examine what files changed
|
|
96
|
+
- Run: `git status` and `git diff` (or `git diff --cached` for staged changes)
|
|
97
|
+
|
|
86
98
|
3. For significant changes, READ the modified files to understand:
|
|
87
99
|
- The purpose and context of changed functions/classes
|
|
88
100
|
- How the changes fit into the larger codebase
|
|
89
101
|
- The intent behind the modifications
|
|
102
|
+
|
|
90
103
|
4. **USE GREP extensively** to understand code relationships (examples):
|
|
91
104
|
- Modified function `process_data()`? → `grep -n "process_data("` to see where it's called
|
|
92
105
|
- New class `UserManager`? → `grep -n "class.*Manager"` to find similar patterns
|
|
@@ -94,28 +107,28 @@ Analysis approach (you decide what's necessary):
|
|
|
94
107
|
- Refactoring? → `grep --output_mode count "old_pattern"` to understand scope
|
|
95
108
|
- Want context? → `grep -C 5 "function_name"` to see surrounding code
|
|
96
109
|
- Find test files? → `grep -n "test_function_name"` or use glob `**/test_*.py`
|
|
97
|
-
5. Consider the scope: is this a feature, fix, refactor, docs, chore, etc.?
|
|
98
110
|
|
|
99
|
-
|
|
111
|
+
5. Consider the scope: is this a feature, fix, refactor, docs, chore, etc.?
|
|
112
|
+
</analysis_approach>
|
|
100
113
|
|
|
101
|
-
|
|
114
|
+
<commit_message_guidelines>
|
|
115
|
+
**Format Requirements**:
|
|
102
116
|
- **MUST FOLLOW THE EXISTING FORMAT**: Match the style, language, and conventions used in recent commits
|
|
103
|
-
- If no clear pattern exists in history, use conventional commits format
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
- chore!: for breaking chore changes
|
|
117
|
+
- If no clear pattern exists in history, use conventional commits format:
|
|
118
|
+
* feat: for new features
|
|
119
|
+
* fix: for bug fixes
|
|
120
|
+
* docs: for documentation changes, add .md to the end of the file name
|
|
121
|
+
* refactor: for code refactoring
|
|
122
|
+
* test: for test changes
|
|
123
|
+
* chore: for chore changes
|
|
124
|
+
* style: for style changes
|
|
125
|
+
* perf: for performance improvements
|
|
126
|
+
* build: for build changes
|
|
127
|
+
* ci: for CI/CD changes
|
|
128
|
+
* revert: for reverting changes
|
|
129
|
+
* feat!, fix!, perf!, chore!: for breaking changes
|
|
130
|
+
|
|
131
|
+
**Structure Requirements**:
|
|
119
132
|
- First line: < 50 chars (or follow existing convention), imperative mood, summarize the main change
|
|
120
133
|
- **IMPORTANT**: Use multi-line format with bullet points for detailed changes:
|
|
121
134
|
```
|
|
@@ -125,29 +138,23 @@ Commit message guidelines:
|
|
|
125
138
|
- Second change detail
|
|
126
139
|
- Third change detail
|
|
127
140
|
```
|
|
141
|
+
|
|
142
|
+
**Content Requirements**:
|
|
128
143
|
- Be specific and meaningful (avoid vague terms like "update", "change", "modify")
|
|
129
144
|
- Focus on WHAT changed and WHY (the intent), not HOW (implementation details)
|
|
130
145
|
- Base your message on deep understanding, not just diff surface analysis
|
|
146
|
+
</commit_message_guidelines>
|
|
131
147
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Conventional commits style(Remember to follow the existing format):
|
|
148
|
+
<examples>
|
|
149
|
+
**Conventional commits style** (Remember to follow the existing format):
|
|
135
150
|
```
|
|
136
|
-
# for new features
|
|
137
151
|
feat: add user authentication system
|
|
138
152
|
|
|
139
153
|
- Implement JWT-based authentication with refresh tokens
|
|
140
154
|
- Add login and registration endpoints
|
|
141
155
|
- Create user session management
|
|
142
156
|
- Add password hashing with bcrypt
|
|
143
|
-
|
|
144
|
-
# for bug fixes
|
|
145
|
-
fix: correct formatting issue
|
|
146
|
-
|
|
147
|
-
- Preserve empty lines in commit messages
|
|
148
|
-
|
|
149
|
-
# for document changes
|
|
150
|
-
docs: update README.md
|
|
157
|
+
```
|
|
151
158
|
|
|
152
159
|
```
|
|
153
160
|
fix: prevent memory leak in connection pool
|
|
@@ -157,7 +164,13 @@ fix: prevent memory leak in connection pool
|
|
|
157
164
|
- Improve error handling for failed connections
|
|
158
165
|
```
|
|
159
166
|
|
|
160
|
-
|
|
167
|
+
```
|
|
168
|
+
fix: correct formatting issue
|
|
169
|
+
|
|
170
|
+
- Preserve empty lines in commit messages
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**With gitmoji** (✨ for feature, 🐛 for bug, ♻️ for refactor):
|
|
161
174
|
```
|
|
162
175
|
✨ add user authentication system
|
|
163
176
|
|
|
@@ -166,7 +179,7 @@ With gitmoji,(✨, 🐛, ♻️, etc. ✨ for feature, 🐛 for bug, ♻️ for
|
|
|
166
179
|
- Create user session management
|
|
167
180
|
```
|
|
168
181
|
|
|
169
|
-
In Chinese
|
|
182
|
+
**In Chinese**:
|
|
170
183
|
```
|
|
171
184
|
新增:用户认证系统
|
|
172
185
|
|
|
@@ -174,13 +187,16 @@ In Chinese:
|
|
|
174
187
|
- 添加登录和注册接口
|
|
175
188
|
- 创建用户会话管理
|
|
176
189
|
```
|
|
190
|
+
</examples>
|
|
177
191
|
|
|
178
|
-
|
|
192
|
+
<output_format>
|
|
193
|
+
At the end of your analysis, output your final commit message in this exact format:
|
|
179
194
|
|
|
180
195
|
COMMIT_MESSAGE:
|
|
181
196
|
<your commit message here>
|
|
182
197
|
|
|
183
198
|
Everything between COMMIT_MESSAGE: and the end will be used as the commit message.
|
|
199
|
+
</output_format>
|
|
184
200
|
"""
|
|
185
201
|
|
|
186
202
|
|
|
@@ -188,7 +204,7 @@ async def generate_commit_message(
|
|
|
188
204
|
repo_path: Optional[Path] = None,
|
|
189
205
|
staged_only: bool = True,
|
|
190
206
|
verbose: bool = False,
|
|
191
|
-
max_diff_lines: int =
|
|
207
|
+
max_diff_lines: int = 5000,
|
|
192
208
|
) -> Optional[str]:
|
|
193
209
|
"""
|
|
194
210
|
Generate a commit message based on current git changes.
|
|
@@ -213,51 +229,65 @@ async def generate_commit_message(
|
|
|
213
229
|
# Build the analysis prompt - give AI freedom to explore
|
|
214
230
|
prompt = f"""Analyze the git repository changes and generate an excellent commit message.
|
|
215
231
|
|
|
216
|
-
|
|
232
|
+
<context>
|
|
217
233
|
- Working directory: {repo_path.absolute()}
|
|
218
234
|
- Analysis scope: {"staged changes only (git diff --cached)" if staged_only else "all uncommitted changes (git diff)"}
|
|
219
|
-
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
|
|
235
|
+
- Max diff lines to analyze: {max_diff_lines} (if diff is larger, use targeted strategies)
|
|
236
|
+
- Available tools: Bash, Read, Grep, Glob, and Edit
|
|
237
|
+
</context>
|
|
238
|
+
|
|
239
|
+
<task>
|
|
240
|
+
Follow these steps to generate an excellent commit message:
|
|
241
|
+
|
|
242
|
+
1. **Check commit history style** (choose ONE approach):
|
|
243
|
+
- Run `git log -3 --oneline` to see recent commits
|
|
244
|
+
- This shows you: gitmoji usage, language (Chinese/English), format (conventional commits, etc.)
|
|
245
|
+
- **MUST follow the same style/format/language as existing commits**
|
|
246
|
+
|
|
247
|
+
2. **Analyze the changes**:
|
|
248
|
+
- Run `git status` to see which files changed
|
|
249
|
+
- Run `git diff --stat` first to get an overview (shows file names and line counts)
|
|
250
|
+
- Only run full `git diff` if you need to see detailed changes
|
|
251
|
+
- **IMPORTANT**: If diff is large (>{max_diff_lines} lines), use targeted strategies below instead
|
|
252
|
+
|
|
253
|
+
3. **Understand the context** (use efficiently):
|
|
254
|
+
- For significant changes, READ modified files to understand their purpose
|
|
255
|
+
- Use GREP to understand code relationships WITHOUT reading entire files
|
|
256
|
+
- Use GLOB to find related files if needed
|
|
257
|
+
|
|
258
|
+
4. **Generate the commit message** in MULTI-LINE FORMAT:
|
|
235
259
|
```
|
|
236
|
-
|
|
260
|
+
type: brief summary (< 50 chars)
|
|
237
261
|
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
-
|
|
262
|
+
- First change detail
|
|
263
|
+
- Second change detail
|
|
264
|
+
- Third change detail
|
|
241
265
|
```
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
-
|
|
247
|
-
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
-
|
|
254
|
-
|
|
266
|
+
</task>
|
|
267
|
+
|
|
268
|
+
<efficient_strategies>
|
|
269
|
+
**For large diffs** (>{max_diff_lines} lines):
|
|
270
|
+
- Use `git diff --stat` for overview, then `git diff <specific_file>` for key files only
|
|
271
|
+
- Use `grep` to search for specific patterns instead of reading full diff
|
|
272
|
+
- Focus on the most impactful changes first
|
|
273
|
+
|
|
274
|
+
**Use GREP extensively** to understand code relationships:
|
|
275
|
+
- Modified function `process_data()`? → `grep -n "process_data("` to see where it's called
|
|
276
|
+
- New class `UserManager`? → `grep -n "class.*Manager"` to find similar patterns
|
|
277
|
+
- Imports changed? → `grep -n "from new_module import"` to see usage
|
|
278
|
+
- Want context? → `grep -C 3 "function_name"` to see surrounding code
|
|
279
|
+
- Count usage? → `grep --output_mode count "pattern"` to understand scope
|
|
280
|
+
</efficient_strategies>
|
|
281
|
+
|
|
282
|
+
<output>
|
|
255
283
|
When you're confident you understand the changes, output your commit message in this exact format:
|
|
256
284
|
|
|
257
285
|
COMMIT_MESSAGE:
|
|
258
286
|
<your commit message>
|
|
259
287
|
|
|
260
288
|
Everything after "COMMIT_MESSAGE:" will be extracted as the final commit message.
|
|
289
|
+
</output>
|
|
290
|
+
|
|
261
291
|
Begin your analysis now.
|
|
262
292
|
"""
|
|
263
293
|
try:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: claude-commit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: AI-powered git commit message generator using Claude Agent SDK
|
|
5
5
|
Author-email: Johannlai <johannli666@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -97,7 +97,7 @@ For custom Claude API endpoints or proxies, set these environment variables:
|
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
99
|
# Required: Set custom endpoint and credentials
|
|
100
|
-
export ANTHROPIC_BASE_URL="https://your-endpoint.com
|
|
100
|
+
export ANTHROPIC_BASE_URL="https://your-endpoint.com"
|
|
101
101
|
export ANTHROPIC_AUTH_TOKEN="your-auth-token"
|
|
102
102
|
|
|
103
103
|
# Optional: Specify custom model name
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|