ikomet 0.1.1__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.
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.4
2
+ Name: ikomet
3
+ Version: 0.1.1
4
+ Summary: AI-powered Conventional Commit message generator using your staged changes
5
+ Author: ajabri
6
+ Author-email: abdelalijabri76@gmail.com
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: gitpython (>=3.1.43,<4.0.0)
15
+ Requires-Dist: groq (>=1.0.0,<2.0.0)
16
+ Requires-Dist: typer[all] (>=0.12.0,<0.13.0)
17
+ Project-URL: Homepage, https://github.com/ajabrii/Komet
18
+ Project-URL: Repository, https://github.com/ajabrii/Komet
19
+ Description-Content-Type: text/markdown
20
+
21
+ # 🚀 Komet
22
+
23
+ **AI-Powered Conventional Commit Message Generator**
24
+
25
+ Komet is a smart CLI tool that leverages Groq's LLM API to automatically generate professional, [Conventional Commits](https://www.conventionalcommits.org/) formatted commit messages from your staged git changes. Say goodbye to bland commit messages and hello to consistent, meaningful version control history.
26
+
27
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
28
+ [![Poetry](https://img.shields.io/badge/poetry-dependency%20management-blueviolet)](https://python-poetry.org/)
29
+ [![Groq](https://img.shields.io/badge/powered%20by-Groq%20LLM-orange)](https://groq.com/)
30
+
31
+ ---
32
+
33
+ ## ✨ Features
34
+
35
+ - **🤖 AI-Powered Analysis**: Uses Groq's fast LLM (Llama 3.3 70B) to understand your code changes
36
+ - **📝 Conventional Commits**: Automatically follows industry-standard commit message format
37
+ - **⚡ Lightning Fast**: Groq's infrastructure provides near-instant responses
38
+ - **🎯 Context-Aware**: Analyzes actual git diffs to generate accurate, meaningful messages
39
+ - **🛡️ Safe & Smart**: Truncates large diffs, validates git repos, and handles edge cases gracefully
40
+ - **🎨 Beautiful CLI**: Built with Typer for a modern, user-friendly command-line experience
41
+
42
+ ---
43
+
44
+ ## 🎬 Demo
45
+
46
+ ```bash
47
+ # Stage your changes
48
+ $ git add src/komet/main.py
49
+
50
+ # Let Komet generate the commit message
51
+ $ komet
52
+
53
+ Suggested commit message:
54
+
55
+ feat(main): add automatic diff truncation for large changesets
56
+
57
+ Use it like this:
58
+ git commit -m 'feat(main): add automatic diff truncation for large changesets'
59
+ ```
60
+
61
+ ---
62
+
63
+ ## 🚀 Installation
64
+
65
+ ### Prerequisites
66
+
67
+ - Python 3.10 or higher
68
+ - Poetry (Python dependency management)
69
+ - Git repository
70
+ - Groq API key ([Get it here](https://console.groq.com/keys))
71
+
72
+ ### Install via Poetry
73
+
74
+ ```bash
75
+ # Clone the repository
76
+ git clone https://github.com/ajabrii/Komet.git
77
+ cd Komet
78
+
79
+ # Install dependencies
80
+ poetry install
81
+
82
+ # Set your Groq API key
83
+ export GROQ_API_KEY=gq_xxxxxxxxxxxxxxxx
84
+
85
+ # Run Komet
86
+ poetry run komet
87
+ ```
88
+
89
+ ### Install as Global Command
90
+
91
+ ```bash
92
+ # Install with pipx (recommended)
93
+ pipx install .
94
+
95
+ # Or install globally with poetry
96
+ poetry build
97
+ pip install dist/komet-0.1.0-py3-none-any.whl
98
+
99
+ # Now use it anywhere
100
+ komet
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 📖 Usage
106
+
107
+ ### Basic Workflow
108
+
109
+ 1. **Stage your changes** as usual:
110
+ ```bash
111
+ git add <files>
112
+ ```
113
+
114
+ 2. **Run Komet**:
115
+ ```bash
116
+ komet
117
+ ```
118
+
119
+ 3. **Copy and commit** with the suggested message:
120
+ ```bash
121
+ git commit -m '<generated-message>'
122
+ ```
123
+
124
+ ### Environment Setup
125
+
126
+ Komet requires a Groq API key. Set it up once:
127
+
128
+ ```bash
129
+ # Temporary (current session only)
130
+ export GROQ_API_KEY=gq_xxxxxxxxxxxxxxxx
131
+
132
+ # Permanent (add to ~/.bashrc, ~/.zshrc, or ~/.profile)
133
+ echo 'export GROQ_API_KEY=gq_xxxxxxxxxxxxxxxx' >> ~/.bashrc
134
+ source ~/.bashrc
135
+ ```
136
+
137
+ ---
138
+
139
+ ## 🏗️ How It Works
140
+
141
+ 1. **Git Diff Extraction**: Komet uses GitPython to read your staged changes (`git diff --cached`)
142
+ 2. **Context Preparation**: The diff is sent to Groq's LLM with a carefully crafted system prompt
143
+ 3. **AI Analysis**: The LLM analyzes the code changes and generates a Conventional Commit message
144
+ 4. **Formatted Output**: The result is displayed with usage instructions
145
+
146
+ ### Conventional Commit Format
147
+
148
+ Komet generates messages following this structure:
149
+
150
+ ```
151
+ <type>(<optional-scope>): <short-description>
152
+
153
+ <optional-body>
154
+
155
+ <optional-footer>
156
+ ```
157
+
158
+ **Supported types**: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
159
+
160
+ ---
161
+
162
+ ## 🛠️ Technology Stack
163
+
164
+ | Technology | Purpose |
165
+ |------------|---------|
166
+ | **Python 3.10+** | Core programming language |
167
+ | **Poetry** | Dependency management and packaging |
168
+ | **Typer** | Modern CLI framework with beautiful output |
169
+ | **GitPython** | Git repository interaction |
170
+ | **Groq SDK** | LLM API integration (Llama 3.3 70B) |
171
+
172
+ ---
173
+
174
+ ## 📁 Project Structure
175
+
176
+ ```
177
+ Komet/
178
+ ├── src/
179
+ │ └── komet/
180
+ │ ├── __init__.py # Package initialization
181
+ │ └── main.py # Core application logic
182
+ ├── pyproject.toml # Poetry configuration & dependencies
183
+ └── README.md # Project documentation
184
+ ```
185
+
186
+ ---
187
+
188
+ ## 🔧 Configuration
189
+
190
+ ### Model Selection
191
+
192
+ Komet uses `llama-3.3-70b-versatile` by default. You can modify [main.py](src/komet/main.py#L79) to use other Groq models:
193
+
194
+ - `llama-3.3-70b-versatile` - Best quality & speed balance (default)
195
+ - `mixtral-8x7b-32768` - Cheaper alternative, still excellent quality
196
+
197
+ ### Diff Size Limits
198
+
199
+ Large diffs are automatically truncated to 15,000 characters to fit within LLM context windows. Adjust in [main.py](src/komet/main.py#L42).
200
+
201
+ ---
202
+
203
+ ## 🤝 Contributing
204
+
205
+ Contributions are welcome! Here's how you can help:
206
+
207
+ 1. Fork the repository
208
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
209
+ 3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
210
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
211
+ 5. Open a Pull Request
212
+
213
+ ---
214
+
215
+ ## 📝 License
216
+
217
+ This project is open source and available under the [MIT License](LICENSE).
218
+
219
+ ---
220
+
221
+ ## 👤 Author
222
+
223
+ **Abdelali Jabri**
224
+ - LinkedIn: [Linkedin](https://www.linkedin.com/in/abdelali-jabri-51729b2b0/)
225
+ - GitHub: [@ajabrii](https://github.com/ajabrii)
226
+ - Email: abdelalijabri76@gmail.com
227
+
228
+ ---
229
+
230
+ ## 🙏 Acknowledgments
231
+
232
+ - [Conventional Commits](https://www.conventionalcommits.org/) - For the commit message specification
233
+ - [Groq](https://groq.com/) - For providing lightning-fast LLM inference
234
+ - [Typer](https://typer.tiangolo.com/) - For the excellent CLI framework
235
+
236
+ ---
237
+
238
+ ## 🌟 Why Komet?
239
+
240
+ In professional software development, clear commit history is crucial for:
241
+ - **Code Reviews**: Understanding what changed and why
242
+ - **Debugging**: Using `git bisect` to find when bugs were introduced
243
+ - **Documentation**: Auto-generating changelogs from commits
244
+ - **Team Collaboration**: Maintaining consistency across team members
245
+
246
+ Komet automates best practices, ensuring every commit tells a clear story.
247
+
248
+ ---
249
+
250
+ **Made with ❤️ by Abdelali Jabri**
@@ -0,0 +1,6 @@
1
+ komet/__init__.py,sha256=Pru0BlFBASFCFo7McHdohtKkUtgMPDwbGfyUZlE2_Vw,21
2
+ komet/main.py,sha256=CA4iS5ZIaBCMu42Mo4TWR55Cjp2JcOvaZoAdf_2tUzE,5923
3
+ ikomet-0.1.1.dist-info/METADATA,sha256=F2s3btUy-dNaFKTgcLN3oZOqTvzitf7FZTm-8HWTj_k,6879
4
+ ikomet-0.1.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
5
+ ikomet-0.1.1.dist-info/entry_points.txt,sha256=h8cBnY8SHCkwOSCZifwKl8HgOsXNAvAEOomrKevEEHA,40
6
+ ikomet-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ komet=komet.main:app
3
+
komet/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
komet/main.py ADDED
@@ -0,0 +1,161 @@
1
+ # src/komet/main.py
2
+
3
+ import os
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ import git # GitPython library to interact with git
8
+ from groq import Groq # Official Groq SDK for calling their API
9
+ import typer # Modern, beautiful CLI framework (like Click but nicer)
10
+
11
+ # Create the main Typer application
12
+ # name="komet" → the command will be called "komet"
13
+ # help=... → shown when user runs: komet --help
14
+ app = typer.Typer(
15
+ name="komet",
16
+ help="Generate a Conventional Commit message from staged changes using Groq LLM",
17
+ add_completion=False, # disables shell completion (we don't need it yet)
18
+ )
19
+
20
+
21
+ def get_staged_diff() -> str:
22
+ """
23
+ Read the staged changes (what `git diff --cached` would show).
24
+ Returns the diff as string or exits with error message.
25
+ """
26
+ # Try to open the current directory (or parent) as git repo
27
+ try:
28
+ repo = git.Repo(Path.cwd(), search_parent_directories=True)
29
+ except git.InvalidGitRepositoryError:
30
+ typer.secho("Error: Not inside a git repository.", fg=typer.colors.RED, err=True)
31
+ raise typer.Exit(code=1)
32
+
33
+ # Check if there are actually staged changes
34
+ if not repo.is_dirty(index=True): # index=True → checks staged area
35
+ typer.secho("No staged changes found.", fg=typer.colors.YELLOW, err=True)
36
+ raise typer.Exit(code=0)
37
+
38
+ # Get the actual diff of staged files
39
+ diff = repo.git.diff("--cached") # same as: git diff --cached
40
+
41
+ # Safety: if somehow diff is empty
42
+ if not diff.strip():
43
+ typer.secho("Staged changes are empty.", fg=typer.colors.YELLOW, err=True)
44
+ raise typer.Exit(code=0)
45
+
46
+ # Optional: prevent sending huge diffs (Groq has large context, but still good practice)
47
+ MAX_DIFF_CHARS = 15000
48
+ if len(diff) > MAX_DIFF_CHARS:
49
+ diff = diff[:MAX_DIFF_CHARS] + "\n\n# ... (diff was truncated to fit context)"
50
+
51
+ return diff
52
+
53
+
54
+ def generate_commit_message(diff_text: str, api_key: str) -> str:
55
+ """
56
+ Send the diff to Groq LLM and ask it to create a Conventional Commit message.
57
+ Returns only the generated message string.
58
+ """
59
+ client = Groq(api_key=api_key)
60
+
61
+ # This is the most important part — controls quality a lot
62
+ system_prompt = """You are a senior software engineer who writes **perfect, team-friendly Conventional Commits** every time.
63
+
64
+ MANDATORY RULES — follow exactly or the output is invalid:
65
+
66
+ 1. Type must be one of: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
67
+ 2. Add scope in (parentheses) when it adds clarity (db, api, auth, ui, cli, config, tests, …)
68
+ 3. Subject line: imperative mood ("add feature", "fix bug", "refactor class") — NEVER past tense
69
+ 4. Subject line length: maximum 72 characters (including type and scope)
70
+ 5. No period at the end of the subject line
71
+ 6. If the change affects public API / breaks compatibility → add footer: BREAKING CHANGE: one sentence explanation
72
+ 7. Optional body: after one blank line — explain WHAT changed and WHY (keep under 4 lines)
73
+ 8. Use bullet points in body only if it really helps readability
74
+ 9. Never include:
75
+ - Emojis
76
+ - Markdown formatting
77
+ - ``` fences
78
+ - Explanations outside the message
79
+ - "Here is the commit message:"
80
+ 10. Output **ONLY** the final commit message — nothing else
81
+
82
+ Few perfect examples:
83
+
84
+ feat: add password reset flow
85
+ fix: correct JWT token validation on refresh
86
+
87
+ docs(readme): update installation instructions with poetry commands
88
+
89
+ refactor(cli): extract diff parsing to separate function
90
+ - Improves testability
91
+ - Reduces main.py complexity
92
+
93
+ BREAKING CHANGE: removed deprecated --old-flag option
94
+
95
+ Your turn — analyze the diff and create the message.
96
+ """
97
+
98
+ user_prompt = f"""Analyze these staged code changes and write the commit message:
99
+
100
+ {diff_text}
101
+ """
102
+
103
+ try:
104
+ response = client.chat.completions.create(
105
+ model="llama-3.3-70b-versatile", # good balance of quality & speed on Groq
106
+ # model="mixtral-8x7b-32768", # cheaper & still very good
107
+ messages=[
108
+ {"role": "system", "content": system_prompt},
109
+ {"role": "user", "content": user_prompt},
110
+ ],
111
+ temperature=0.15, # low = more consistent & deterministic
112
+ max_tokens=180, # enough for message + body
113
+ top_p=0.9,
114
+ )
115
+
116
+ message = response.choices[0].message.content.strip()
117
+ return message
118
+
119
+ except Exception as e:
120
+ typer.secho(f"Groq API error: {str(e)}", fg=typer.colors.RED, err=True)
121
+ raise typer.Exit(code=1)
122
+
123
+
124
+ @app.command()
125
+ def main():
126
+ """
127
+ Main command — called when user just types: komet
128
+ """
129
+ # Get Groq API key from environment (most secure & common way)
130
+ api_key = os.getenv("GROQ_API_KEY")
131
+ if not api_key:
132
+ typer.secho(
133
+ "Error: GROQ_API_KEY environment variable is not set.\n"
134
+ "Get your key at: https://console.groq.com/keys\n"
135
+ "Then run: export GROQ_API_KEY=gq_xxxxxxxxxxxxxxxx",
136
+ fg=typer.colors.RED,
137
+ err=True
138
+ )
139
+ raise typer.Exit(code=1)
140
+
141
+ # 1. Read staged changes
142
+ diff = get_staged_diff()
143
+
144
+ # 2. Ask LLM to generate message
145
+ message = generate_commit_message(diff, api_key)
146
+
147
+ # 3. Print nicely
148
+ typer.echo("\nSuggested commit message:\n")
149
+ typer.secho(message, fg=typer.colors.GREEN, bold=True)
150
+ typer.echo("\nUse it like this:")
151
+ typer.echo(f" git commit -m '{message.splitlines()[0]}'")
152
+ # If message has body → show full multi-line version
153
+ if "\n" in message:
154
+ typer.echo("\nFull version:")
155
+ typer.echo(message)
156
+
157
+
158
+ if __name__ == "__main__":
159
+ # This makes the script runnable directly: python -m komet
160
+ # But normally you'll run it via poetry run komet or after pipx install
161
+ app()