claude-commit 0.2.0__tar.gz → 0.3.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.
- {claude_commit-0.2.0/src/claude_commit.egg-info → claude_commit-0.3.0}/PKG-INFO +5 -1
- {claude_commit-0.2.0 → claude_commit-0.3.0}/README.md +4 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/pyproject.toml +1 -1
- {claude_commit-0.2.0 → claude_commit-0.3.0}/src/claude_commit/main.py +100 -27
- {claude_commit-0.2.0 → claude_commit-0.3.0/src/claude_commit.egg-info}/PKG-INFO +5 -1
- {claude_commit-0.2.0 → claude_commit-0.3.0}/LICENSE +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/setup.cfg +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/src/claude_commit/__init__.py +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/src/claude_commit/config.py +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/src/claude_commit.egg-info/SOURCES.txt +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/src/claude_commit.egg-info/dependency_links.txt +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/src/claude_commit.egg-info/entry_points.txt +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/src/claude_commit.egg-info/requires.txt +0 -0
- {claude_commit-0.2.0 → claude_commit-0.3.0}/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
|
+
Version: 0.3.0
|
|
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
|
|
@@ -35,6 +35,10 @@ Dynamic: license-file
|
|
|
35
35
|
|
|
36
36
|
`claude-commit` uses Claude AI to analyze your code changes and write meaningful commit messages. Claude reads your files, understands the context, and generates commit messages following best practices.
|
|
37
37
|
|
|
38
|
+
## Demo
|
|
39
|
+
|
|
40
|
+
[](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L?autoplay=1&speed=3)
|
|
41
|
+
|
|
38
42
|
## Installation
|
|
39
43
|
|
|
40
44
|
### Prerequisites
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
`claude-commit` uses Claude AI to analyze your code changes and write meaningful commit messages. Claude reads your files, understands the context, and generates commit messages following best practices.
|
|
8
8
|
|
|
9
|
+
## Demo
|
|
10
|
+
|
|
11
|
+
[](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L?autoplay=1&speed=3)
|
|
12
|
+
|
|
9
13
|
## Installation
|
|
10
14
|
|
|
11
15
|
### Prerequisites
|
|
@@ -6,29 +6,28 @@ Analyzes your git repository changes and generates a meaningful commit message
|
|
|
6
6
|
using Claude's AI capabilities.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
import sys
|
|
10
|
-
import asyncio
|
|
11
9
|
import argparse
|
|
10
|
+
import asyncio
|
|
11
|
+
import sys
|
|
12
|
+
import time
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
from typing import Optional
|
|
14
|
-
import time
|
|
15
15
|
|
|
16
|
-
from rich.console import Console
|
|
17
|
-
from rich.panel import Panel
|
|
18
|
-
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
19
16
|
import pyperclip
|
|
20
|
-
|
|
21
17
|
from claude_agent_sdk import (
|
|
22
|
-
query,
|
|
23
|
-
ClaudeAgentOptions,
|
|
24
18
|
AssistantMessage,
|
|
25
|
-
|
|
26
|
-
ToolUseBlock,
|
|
27
|
-
ToolResultBlock,
|
|
28
|
-
ResultMessage,
|
|
19
|
+
ClaudeAgentOptions,
|
|
29
20
|
CLINotFoundError,
|
|
30
21
|
ProcessError,
|
|
22
|
+
ResultMessage,
|
|
23
|
+
TextBlock,
|
|
24
|
+
ToolResultBlock,
|
|
25
|
+
ToolUseBlock,
|
|
26
|
+
query,
|
|
31
27
|
)
|
|
28
|
+
from rich.console import Console
|
|
29
|
+
from rich.panel import Panel
|
|
30
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
32
31
|
|
|
33
32
|
from .config import Config, resolve_alias
|
|
34
33
|
|
|
@@ -40,10 +39,42 @@ SYSTEM_PROMPT = """You are an expert software engineer tasked with analyzing cod
|
|
|
40
39
|
Your goal: Generate a clear, accurate, and meaningful commit message that captures the essence of the changes.
|
|
41
40
|
|
|
42
41
|
Available tools you can use:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
42
|
+
|
|
43
|
+
1. **Bash**: Run git commands and shell commands
|
|
44
|
+
- `git log`, `git status`, `git diff`, `git show`
|
|
45
|
+
- Any shell commands for system inspection
|
|
46
|
+
|
|
47
|
+
2. **Read**: Read file contents to understand context
|
|
48
|
+
- Read modified files to understand their purpose
|
|
49
|
+
- Read related files to understand dependencies
|
|
50
|
+
- Can specify line ranges for large files: `{"file_path": "file.py", "offset": 10, "limit": 50}`
|
|
51
|
+
- Supports images (returns base64 encoded data)
|
|
52
|
+
|
|
53
|
+
3. **Grep** (⭐ POWERFUL - use extensively!): Search patterns across files
|
|
54
|
+
- Search for function/class definitions: `grep -n "def function_name"` or `grep -n "class ClassName"`
|
|
55
|
+
- Find where functions are called: `grep -n "function_name("`
|
|
56
|
+
- Search for imports: `grep -n "from module import"` or `grep -n "import package"`
|
|
57
|
+
- Find variable usage: `grep -n "variable_name"`
|
|
58
|
+
- Search with context: use -A (after), -B (before), -C (context) flags
|
|
59
|
+
- Case-insensitive search: use -i flag
|
|
60
|
+
- Search in specific file types: use --type flag (e.g., `--type py`)
|
|
61
|
+
- Count occurrences: use --output_mode count
|
|
62
|
+
- Limit results: use head_limit parameter
|
|
63
|
+
- **Why Grep is powerful**: It helps you understand code relationships WITHOUT reading entire files
|
|
64
|
+
* See where a modified function is called (usage impact)
|
|
65
|
+
* Find related functions or classes (context)
|
|
66
|
+
* Understand dependencies (imports and references)
|
|
67
|
+
* Discover patterns across the codebase
|
|
68
|
+
|
|
69
|
+
4. **Glob**: Find files matching patterns
|
|
70
|
+
- `*.py`, `**/*.js`, `**/test_*.py`
|
|
71
|
+
- Useful to find related files (e.g., test files, config files)
|
|
72
|
+
|
|
73
|
+
5. **Edit** (⭐ USEFUL for analysis): Make precise edits
|
|
74
|
+
- **NOTE**: You won't actually edit files, but you can use this tool's pattern matching to understand complex changes
|
|
75
|
+
- Helps identify exact strings in files when git diff is unclear
|
|
76
|
+
- Can search for specific code patterns: `{"file_path": "file.py", "old_string": "pattern to find"}`
|
|
77
|
+
- Useful when you need to understand multi-line changes or context around changes
|
|
47
78
|
|
|
48
79
|
Analysis approach (you decide what's necessary):
|
|
49
80
|
1. IMPORTANT: First check recent commit history (git log -10 --oneline or git log -10 --pretty=format:"%s") to understand the existing commit message style
|
|
@@ -56,12 +87,35 @@ Analysis approach (you decide what's necessary):
|
|
|
56
87
|
- The purpose and context of changed functions/classes
|
|
57
88
|
- How the changes fit into the larger codebase
|
|
58
89
|
- The intent behind the modifications
|
|
59
|
-
4.
|
|
90
|
+
4. **USE GREP extensively** to understand code relationships (examples):
|
|
91
|
+
- Modified function `process_data()`? → `grep -n "process_data("` to see where it's called
|
|
92
|
+
- New class `UserManager`? → `grep -n "class.*Manager"` to find similar patterns
|
|
93
|
+
- Imports changed? → `grep -n "from new_module import"` to see usage
|
|
94
|
+
- Refactoring? → `grep --output_mode count "old_pattern"` to understand scope
|
|
95
|
+
- Want context? → `grep -C 5 "function_name"` to see surrounding code
|
|
96
|
+
- Find test files? → `grep -n "test_function_name"` or use glob `**/test_*.py`
|
|
60
97
|
5. Consider the scope: is this a feature, fix, refactor, docs, chore, etc.?
|
|
61
98
|
|
|
99
|
+
**Pro tip**: Grep is faster than reading entire files. Use it to quickly assess impact before deciding which files to read in detail.
|
|
100
|
+
|
|
62
101
|
Commit message guidelines:
|
|
63
|
-
- **FOLLOW THE EXISTING FORMAT**: Match the style, language, and conventions used in recent commits
|
|
102
|
+
- **MUST FOLLOW THE EXISTING FORMAT**: Match the style, language, and conventions used in recent commits
|
|
64
103
|
- If no clear pattern exists in history, use conventional commits format (feat:, fix:, docs:, refactor:, test:, chore:, style:, perf:)
|
|
104
|
+
- feat: for new features
|
|
105
|
+
- fix: for bug fixes
|
|
106
|
+
- docs: for documentation changes
|
|
107
|
+
- refactor: for code refactoring
|
|
108
|
+
- test: for test changes
|
|
109
|
+
- chore: for chore changes
|
|
110
|
+
- style: for style changes
|
|
111
|
+
- perf: for performance improvements
|
|
112
|
+
- build: for build changes
|
|
113
|
+
- ci: for CI/CD changes
|
|
114
|
+
- revert: for reverting changes
|
|
115
|
+
- feat!: for breaking changes
|
|
116
|
+
- fix!: for breaking bug fixes
|
|
117
|
+
- perf!: for breaking performance improvements
|
|
118
|
+
- chore!: for breaking chore changes
|
|
65
119
|
- First line: < 50 chars (or follow existing convention), imperative mood, summarize the main change
|
|
66
120
|
- **IMPORTANT**: Use multi-line format with bullet points for detailed changes:
|
|
67
121
|
```
|
|
@@ -77,15 +131,23 @@ Commit message guidelines:
|
|
|
77
131
|
|
|
78
132
|
Examples of excellent commit messages (multi-line format):
|
|
79
133
|
|
|
80
|
-
Conventional commits style:
|
|
134
|
+
Conventional commits style(Remember to follow the existing format):
|
|
81
135
|
```
|
|
136
|
+
# for new features
|
|
82
137
|
feat: add user authentication system
|
|
83
138
|
|
|
84
139
|
- Implement JWT-based authentication with refresh tokens
|
|
85
140
|
- Add login and registration endpoints
|
|
86
141
|
- Create user session management
|
|
87
142
|
- Add password hashing with bcrypt
|
|
88
|
-
|
|
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
|
|
89
151
|
|
|
90
152
|
```
|
|
91
153
|
fix: prevent memory leak in connection pool
|
|
@@ -95,7 +157,7 @@ fix: prevent memory leak in connection pool
|
|
|
95
157
|
- Improve error handling for failed connections
|
|
96
158
|
```
|
|
97
159
|
|
|
98
|
-
With gitmoji
|
|
160
|
+
With gitmoji,(✨, 🐛, ♻️, etc. ✨ for feature, 🐛 for bug, ♻️ for refactor)
|
|
99
161
|
```
|
|
100
162
|
✨ add user authentication system
|
|
101
163
|
|
|
@@ -154,7 +216,7 @@ async def generate_commit_message(
|
|
|
154
216
|
Context:
|
|
155
217
|
- Working directory: {repo_path.absolute()}
|
|
156
218
|
- Analysis scope: {"staged changes only (git diff --cached)" if staged_only else "all uncommitted changes (git diff)"}
|
|
157
|
-
- You have access to: Bash, Read, Grep, and
|
|
219
|
+
- You have access to: Bash, Read, Grep, Glob, and Edit tools
|
|
158
220
|
|
|
159
221
|
Your task:
|
|
160
222
|
1. **FIRST**: Check the recent commit history (e.g., `git log -3 --oneline` or `git log -3 --pretty=format:"%s"`) to understand the commit message format/style used in this project
|
|
@@ -182,7 +244,12 @@ Recommendations (not requirements - use your judgment):
|
|
|
182
244
|
- Start with `git log -3 --oneline` to check the commit message style
|
|
183
245
|
- Then use `git status` and `git diff {"--cached" if staged_only else ""}` to see what changed
|
|
184
246
|
- For non-trivial changes, READ the modified files to understand their purpose
|
|
185
|
-
-
|
|
247
|
+
- **USE GREP extensively** to understand impact and context:
|
|
248
|
+
* If a function was modified, grep for its usage: `grep -n "function_name("`
|
|
249
|
+
* If a class was added/changed, find related classes: `grep -n "class.*Base"` or similar patterns
|
|
250
|
+
* If imports changed, see where they're used: `grep -n "imported_module"`
|
|
251
|
+
* To understand scope, count usages: `grep --output_mode count "pattern"`
|
|
252
|
+
* Get context around matches: `grep -C 3 "pattern"` (3 lines before/after)
|
|
186
253
|
- Consider the broader context of the codebase
|
|
187
254
|
|
|
188
255
|
When you're confident you understand the changes, output your commit message in this exact format:
|
|
@@ -196,7 +263,13 @@ Begin your analysis now.
|
|
|
196
263
|
try:
|
|
197
264
|
options = ClaudeAgentOptions(
|
|
198
265
|
system_prompt=SYSTEM_PROMPT,
|
|
199
|
-
allowed_tools=[
|
|
266
|
+
allowed_tools=[
|
|
267
|
+
"Bash", # Run shell commands
|
|
268
|
+
"Read", # Read file contents
|
|
269
|
+
"Grep", # Search patterns in files (POWERFUL!)
|
|
270
|
+
"Glob", # Find files by pattern
|
|
271
|
+
"Edit", # Make precise edits to files (useful for analyzing multi-line changes)
|
|
272
|
+
],
|
|
200
273
|
permission_mode="acceptEdits",
|
|
201
274
|
cwd=str(repo_path.absolute()),
|
|
202
275
|
max_turns=10,
|
|
@@ -442,8 +515,8 @@ def handle_alias_command(args):
|
|
|
442
515
|
print("📋 No aliases configured")
|
|
443
516
|
return
|
|
444
517
|
|
|
445
|
-
import platform
|
|
446
518
|
import os
|
|
519
|
+
import platform
|
|
447
520
|
|
|
448
521
|
# Detect shell and platform
|
|
449
522
|
shell = os.environ.get("SHELL", "")
|
|
@@ -609,8 +682,8 @@ def handle_alias_command(args):
|
|
|
609
682
|
|
|
610
683
|
elif args[0] == "uninstall":
|
|
611
684
|
# Remove shell aliases
|
|
612
|
-
import platform
|
|
613
685
|
import os
|
|
686
|
+
import platform
|
|
614
687
|
|
|
615
688
|
shell = os.environ.get("SHELL", "")
|
|
616
689
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: claude-commit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
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
|
|
@@ -35,6 +35,10 @@ Dynamic: license-file
|
|
|
35
35
|
|
|
36
36
|
`claude-commit` uses Claude AI to analyze your code changes and write meaningful commit messages. Claude reads your files, understands the context, and generates commit messages following best practices.
|
|
37
37
|
|
|
38
|
+
## Demo
|
|
39
|
+
|
|
40
|
+
[](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L?autoplay=1&speed=3)
|
|
41
|
+
|
|
38
42
|
## Installation
|
|
39
43
|
|
|
40
44
|
### Prerequisites
|
|
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
|