smart-commit-cli 0.1.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.
- smart_commit/__init__.py +6 -0
- smart_commit/ai/__init__.py +7 -0
- smart_commit/ai/client.py +123 -0
- smart_commit/ai/reviewer.py +91 -0
- smart_commit/ai.py +136 -0
- smart_commit/analysis/__init__.py +7 -0
- smart_commit/analysis/ast_parser.py +173 -0
- smart_commit/analysis/dependency_graph.py +114 -0
- smart_commit/analysis/diff_parser.py +172 -0
- smart_commit/analysis/summarizer.py +101 -0
- smart_commit/analysis/symbol_extractor.py +88 -0
- smart_commit/benchmark.py +88 -0
- smart_commit/cache.py +65 -0
- smart_commit/cli.py +391 -0
- smart_commit/clustering/__init__.py +7 -0
- smart_commit/clustering/graph_clustering.py +78 -0
- smart_commit/clustering/heuristic.py +178 -0
- smart_commit/clustering/semantic.py +201 -0
- smart_commit/clustering.py +186 -0
- smart_commit/commit_messages.py +232 -0
- smart_commit/committer.py +91 -0
- smart_commit/config.py +88 -0
- smart_commit/constants.py +92 -0
- smart_commit/diff_parser.py +158 -0
- smart_commit/embeddings/__init__.py +7 -0
- smart_commit/embeddings/generator.py +128 -0
- smart_commit/embeddings/similarity.py +159 -0
- smart_commit/embeddings.py +108 -0
- smart_commit/exceptions.py +102 -0
- smart_commit/execution/__init__.py +6 -0
- smart_commit/execution/committer.py +102 -0
- smart_commit/git/__init__.py +8 -0
- smart_commit/git/safety.py +75 -0
- smart_commit/git/scanner.py +182 -0
- smart_commit/git/service.py +129 -0
- smart_commit/git_service.py +302 -0
- smart_commit/logger.py +99 -0
- smart_commit/models.py +73 -0
- smart_commit/plugins/__init__.py +6 -0
- smart_commit/plugins/base.py +135 -0
- smart_commit/plugins/django.py +40 -0
- smart_commit/plugins/fastapi.py +39 -0
- smart_commit/plugins/react.py +49 -0
- smart_commit/preview/__init__.py +6 -0
- smart_commit/preview/editor.py +224 -0
- smart_commit/preview/renderer.py +94 -0
- smart_commit/preview.py +131 -0
- smart_commit/summarizer.py +93 -0
- smart_commit/utils.py +83 -0
- smart_commit_cli-0.1.0.dist-info/METADATA +804 -0
- smart_commit_cli-0.1.0.dist-info/RECORD +53 -0
- smart_commit_cli-0.1.0.dist-info/WHEEL +4 -0
- smart_commit_cli-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smart-commit-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-powered Git commit automation
|
|
5
|
+
Author: Smart Commit Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ai,automation,commit,conventional-commits,git,llm
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
|
+
Requires-Dist: gitpython>=3.1.0
|
|
16
|
+
Requires-Dist: litellm>=1.0.0
|
|
17
|
+
Requires-Dist: networkx>=3.0.0
|
|
18
|
+
Requires-Dist: numpy>=1.24.0
|
|
19
|
+
Requires-Dist: pydantic>=2.0.0
|
|
20
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
21
|
+
Requires-Dist: pyyaml>=6.0
|
|
22
|
+
Requires-Dist: rich>=13.0.0
|
|
23
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
24
|
+
Requires-Dist: sentence-transformers>=2.2.0
|
|
25
|
+
Requires-Dist: typer[all]>=0.9.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.0.100; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# Smart Commit v2
|
|
35
|
+
|
|
36
|
+
**The equivalent of Prettier for Git history**
|
|
37
|
+
|
|
38
|
+
Stop thinking about staging files, commit boundaries, and writing messages. Smart Commit analyzes your changes, proposes logical commits, and lets you review before executing.
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
## Vision
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
Your Changes
|
|
46
|
+
↓
|
|
47
|
+
Smart Commit Analysis
|
|
48
|
+
↓
|
|
49
|
+
Logical Commit Groups
|
|
50
|
+
↓
|
|
51
|
+
High-Quality Messages
|
|
52
|
+
↓
|
|
53
|
+
Your Review
|
|
54
|
+
↓
|
|
55
|
+
Perfect Git History
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **🤖 AI-Powered Grouping**: Uses embeddings and ML to understand which files belong together
|
|
61
|
+
- **📝 Automatic Messages**: Generates Conventional Commits without manual writing
|
|
62
|
+
- **👁️ Interactive Preview**: Review all proposed commits before executing
|
|
63
|
+
- **🔄 Multi-Provider LLM**: Works with OpenRouter, OpenAI, Anthropic, Gemini, Groq, Azure, and more
|
|
64
|
+
- **⚡ Local Embeddings**: Uses efficient local embeddings for semantic analysis
|
|
65
|
+
- **🔐 Safety First**: Never modifies history without approval
|
|
66
|
+
- **↩️ Undo Support**: Easily revert the last Smart Commit session
|
|
67
|
+
- **🧩 Plugin System**: Extensible architecture with language-specific plugins
|
|
68
|
+
- **⚙️ Offline Mode**: Works without LLM for pure ML-based clustering
|
|
69
|
+
- **🎯 Conventional Commits**: Automatic type detection (feat, fix, docs, etc.)
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
### Requirements
|
|
74
|
+
- Python 3.12+
|
|
75
|
+
- Git
|
|
76
|
+
|
|
77
|
+
### From PyPI (Coming Soon)
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install smart-commit
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### From Source
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
git clone https://github.com/hamxa296/Smart-Commit.git
|
|
87
|
+
cd Smart-Commit
|
|
88
|
+
pip install -e .
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Quick Start
|
|
92
|
+
|
|
93
|
+
### 1. Initialize
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
smart-commit init
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 2. Configure LLM (Optional)
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
smart-commit config --provider openrouter --model anthropic/claude-sonnet --api-key YOUR_KEY
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Or set environment variables:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
export SMART_COMMIT_PROVIDER=openrouter
|
|
109
|
+
export SMART_COMMIT_MODEL=anthropic/claude-sonnet
|
|
110
|
+
export SMART_COMMIT_API_KEY=your-api-key
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 3. Run
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
smart-commit run
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Pipeline
|
|
120
|
+
|
|
121
|
+
Smart Commit processes changes through 10 stages:
|
|
122
|
+
|
|
123
|
+
```mermaid
|
|
124
|
+
flowchart TD
|
|
125
|
+
A["🔍 Git Status"] --> B["📋 Read Diffs"]
|
|
126
|
+
B --> C["🔎 Static Analysis"]
|
|
127
|
+
C --> D["🌳 AST Analysis"]
|
|
128
|
+
D --> E["📝 Summaries"]
|
|
129
|
+
E --> F["🧠 Embeddings"]
|
|
130
|
+
F --> G["🔗 Similarity Graph"]
|
|
131
|
+
G --> H["🎯 Semantic Clustering"]
|
|
132
|
+
H --> I["✨ LLM Review"]
|
|
133
|
+
I --> J["💬 Commit Messages"]
|
|
134
|
+
J --> K["👁️ Preview UI"]
|
|
135
|
+
K --> L["✅ Git Commit"]
|
|
136
|
+
|
|
137
|
+
style A fill:#e1f5ff
|
|
138
|
+
style H fill:#f3e5f5
|
|
139
|
+
style I fill:#fff3e0
|
|
140
|
+
style L fill:#e8f5e9
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Commands
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Analyze and create commits
|
|
147
|
+
smart-commit run
|
|
148
|
+
|
|
149
|
+
# Preview without executing
|
|
150
|
+
smart-commit preview
|
|
151
|
+
|
|
152
|
+
# Undo last session
|
|
153
|
+
smart-commit undo
|
|
154
|
+
|
|
155
|
+
# Show configuration
|
|
156
|
+
smart-commit config --show
|
|
157
|
+
|
|
158
|
+
# Diagnostic checks
|
|
159
|
+
smart-commit doctor
|
|
160
|
+
|
|
161
|
+
# List plugins
|
|
162
|
+
smart-commit plugins
|
|
163
|
+
|
|
164
|
+
# Show version
|
|
165
|
+
smart-commit version
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Advanced Options
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
smart-commit run --yes # Skip confirmation
|
|
172
|
+
smart-commit run --dry-run # Preview only
|
|
173
|
+
smart-commit run --no-ai # Disable LLM
|
|
174
|
+
smart-commit run --offline # Use only local analysis
|
|
175
|
+
smart-commit run --model gpt-4 # Override model
|
|
176
|
+
smart-commit run --provider openai # Override provider
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Configuration
|
|
180
|
+
|
|
181
|
+
Smart Commit looks for configuration in this order:
|
|
182
|
+
|
|
183
|
+
1. **CLI Options** (`--model`, `--provider`)
|
|
184
|
+
2. **Environment Variables** (`SMART_COMMIT_*`)
|
|
185
|
+
3. **Configuration File** (`~/.smart_commit/config.yaml`)
|
|
186
|
+
4. **Defaults**
|
|
187
|
+
|
|
188
|
+
### Example config.yaml
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
# LLM Settings
|
|
192
|
+
provider: openrouter
|
|
193
|
+
model: anthropic/claude-sonnet
|
|
194
|
+
api_key: your-api-key
|
|
195
|
+
|
|
196
|
+
# Embedding
|
|
197
|
+
embedding_model: all-MiniLM-L6-v2
|
|
198
|
+
|
|
199
|
+
# Clustering
|
|
200
|
+
clustering_method: agglomerative
|
|
201
|
+
similarity_threshold: 0.5
|
|
202
|
+
max_files_per_commit: 8
|
|
203
|
+
|
|
204
|
+
# Behavior
|
|
205
|
+
interactive: true
|
|
206
|
+
auto_push: false
|
|
207
|
+
conventional_commits: true
|
|
208
|
+
use_local_embeddings: true
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Safety & Trust
|
|
212
|
+
|
|
213
|
+
### Safety Features
|
|
214
|
+
|
|
215
|
+
- ✅ **Never** modifies history without approval
|
|
216
|
+
- ✅ **Always** shows preview before executing
|
|
217
|
+
- ✅ **Always** supports undo with `smart-commit undo`
|
|
218
|
+
- ✅ **Validates** all file paths and commit messages
|
|
219
|
+
- ✅ **Warns** about protected branches (main, master, production)
|
|
220
|
+
|
|
221
|
+
### Preview Example
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
Commit 1
|
|
225
|
+
feat(auth): improve login validation and session handling
|
|
226
|
+
Files: 3
|
|
227
|
+
✏️ src/auth/login.ts
|
|
228
|
+
✏️ src/auth/jwt.ts
|
|
229
|
+
✏️ src/middleware/auth.ts
|
|
230
|
+
|
|
231
|
+
Commit 2
|
|
232
|
+
docs: update README with auth changes
|
|
233
|
+
Files: 1
|
|
234
|
+
✏️ README.md
|
|
235
|
+
|
|
236
|
+
Proceed? [y]es [n]o [d]ry-run [e]dit
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Plugin System
|
|
240
|
+
|
|
241
|
+
Plugins provide framework-specific knowledge for better clustering.
|
|
242
|
+
|
|
243
|
+
### Built-in Plugins
|
|
244
|
+
|
|
245
|
+
- **React**: Component/style grouping
|
|
246
|
+
- **Django**: Model/view/migration grouping
|
|
247
|
+
|
|
248
|
+
### Creating a Plugin
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from smart_commit.plugins import Plugin
|
|
252
|
+
|
|
253
|
+
class MyPlugin(Plugin):
|
|
254
|
+
name = "MyFramework"
|
|
255
|
+
version = "0.1.0"
|
|
256
|
+
description = "Custom framework support"
|
|
257
|
+
|
|
258
|
+
def get_ignored_files(self):
|
|
259
|
+
return ["node_modules/**", "venv/**"]
|
|
260
|
+
|
|
261
|
+
def get_commit_hints(self, file_diffs):
|
|
262
|
+
hints = {}
|
|
263
|
+
for file_diff in file_diffs:
|
|
264
|
+
if "service" in file_diff.file_path:
|
|
265
|
+
hints[file_diff.file_path] = "service"
|
|
266
|
+
return hints
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Supported LLM Providers
|
|
270
|
+
|
|
271
|
+
Smart Commit uses [LiteLLM](https://github.com/BerriAI/litellm) for provider agnostic access:
|
|
272
|
+
|
|
273
|
+
| Provider | Model Format | Example |
|
|
274
|
+
|----------|--------------|---------|
|
|
275
|
+
| OpenRouter | `anthropic/claude-sonnet` | `smart-commit run --provider openrouter --model anthropic/claude-sonnet` |
|
|
276
|
+
| OpenAI | `gpt-4` | `smart-commit run --provider openai --model gpt-4` |
|
|
277
|
+
| Anthropic | `claude-sonnet` | `smart-commit run --provider anthropic --model claude-sonnet` |
|
|
278
|
+
| Google | `gemini-pro` | `smart-commit run --provider google --model gemini-pro` |
|
|
279
|
+
| Groq | `mixtral-8x7b-32768` | `smart-commit run --provider groq --model mixtral-8x7b-32768` |
|
|
280
|
+
| Azure | `gpt-4` | `smart-commit run --provider azure --model gpt-4` |
|
|
281
|
+
| Local (Ollama) | `llama2` | `smart-commit run --provider ollama --model llama2` |
|
|
282
|
+
|
|
283
|
+
## Architecture
|
|
284
|
+
|
|
285
|
+
### Project Structure
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
smart_commit/
|
|
289
|
+
├── __init__.py
|
|
290
|
+
├── cli.py # Command-line interface
|
|
291
|
+
├── config.py # Configuration management
|
|
292
|
+
├── constants.py # Constants and enums
|
|
293
|
+
├── exceptions.py # Custom exceptions
|
|
294
|
+
├── logger.py # Logging setup
|
|
295
|
+
├── models.py # Data models
|
|
296
|
+
├── utils.py # Utilities
|
|
297
|
+
│
|
|
298
|
+
├── git/ # Git operations
|
|
299
|
+
│ ├── scanner.py # Repository scanning
|
|
300
|
+
│ ├── service.py # Git commands
|
|
301
|
+
│ └── safety.py # Safety checks
|
|
302
|
+
│
|
|
303
|
+
├── analysis/ # Code analysis
|
|
304
|
+
│ ├── diff_parser.py # Diff parsing
|
|
305
|
+
│ └── summarizer.py # Summary generation
|
|
306
|
+
│
|
|
307
|
+
├── embeddings/ # Semantic embeddings
|
|
308
|
+
│ ├── generator.py # Embedding generation
|
|
309
|
+
│ └── similarity.py # Similarity graph
|
|
310
|
+
│
|
|
311
|
+
├── clustering/ # File clustering
|
|
312
|
+
│ ├── semantic.py # ML-based clustering
|
|
313
|
+
│ └── heuristic.py # Rule-based clustering
|
|
314
|
+
│
|
|
315
|
+
├── ai/ # LLM integration
|
|
316
|
+
│ ├── client.py # LiteLLM wrapper
|
|
317
|
+
│ └── reviewer.py # Cluster review
|
|
318
|
+
│
|
|
319
|
+
├── preview/ # UI and preview
|
|
320
|
+
│ └── renderer.py # Rich UI rendering
|
|
321
|
+
│
|
|
322
|
+
├── execution/ # Commit execution
|
|
323
|
+
│ └── committer.py # Commit and sessions
|
|
324
|
+
│
|
|
325
|
+
└── plugins/ # Plugin system
|
|
326
|
+
└── base.py # Plugin base classes
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Module Responsibilities
|
|
330
|
+
|
|
331
|
+
Each module has a single, clear responsibility:
|
|
332
|
+
|
|
333
|
+
- **git/scanner.py** - Repository state snapshots
|
|
334
|
+
- **analysis/diff_parser.py** - Structured diff extraction
|
|
335
|
+
- **analysis/summarizer.py** - Concise change summaries
|
|
336
|
+
- **embeddings/generator.py** - Local semantic embeddings
|
|
337
|
+
- **embeddings/similarity.py** - Weighted similarity graph
|
|
338
|
+
- **clustering/semantic.py** - ML-based file grouping
|
|
339
|
+
- **clustering/heuristic.py** - Rule-based fallback
|
|
340
|
+
- **ai/client.py** - Multi-provider LLM access
|
|
341
|
+
- **ai/reviewer.py** - LLM cluster analysis
|
|
342
|
+
- **preview/renderer.py** - Rich terminal UI
|
|
343
|
+
- **execution/committer.py** - Safe commit creation
|
|
344
|
+
|
|
345
|
+
## Development
|
|
346
|
+
|
|
347
|
+
### Setup
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
git clone https://github.com/hamxa296/Smart-Commit.git
|
|
351
|
+
cd Smart-Commit
|
|
352
|
+
python -m venv venv
|
|
353
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
354
|
+
pip install -e ".[dev]"
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Run Tests
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
pytest -v
|
|
361
|
+
pytest --cov=smart_commit
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Format Code
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
black smart_commit tests
|
|
368
|
+
ruff check --fix smart_commit tests
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Check Types
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
mypy smart_commit
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## Example Workflow
|
|
378
|
+
|
|
379
|
+
### Before Smart Commit
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
$ git status
|
|
383
|
+
On branch main
|
|
384
|
+
modified: src/auth/login.ts
|
|
385
|
+
modified: src/auth/jwt.ts
|
|
386
|
+
modified: src/api/routes.ts
|
|
387
|
+
modified: docs/README.md
|
|
388
|
+
|
|
389
|
+
$ git add src/auth/login.ts
|
|
390
|
+
$ git add src/auth/jwt.ts
|
|
391
|
+
$ git commit -m "feat(auth): improve login validation"
|
|
392
|
+
|
|
393
|
+
$ git add src/api/routes.ts
|
|
394
|
+
$ git commit -m "fix(api): prevent duplicate requests"
|
|
395
|
+
|
|
396
|
+
$ git add docs/README.md
|
|
397
|
+
$ git commit -m "docs: update README"
|
|
398
|
+
|
|
399
|
+
# Total time: 15-30 minutes
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### With Smart Commit
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
$ smart-commit run
|
|
406
|
+
|
|
407
|
+
Step 1: Scanning repository...
|
|
408
|
+
✓ Found 4 changed file(s)
|
|
409
|
+
✓ +150 additions, -25 deletions
|
|
410
|
+
✓ Branch: main
|
|
411
|
+
|
|
412
|
+
Step 2: Analyzing changes...
|
|
413
|
+
✓ Processed 4 file(s)
|
|
414
|
+
|
|
415
|
+
Step 3: Grouping related changes...
|
|
416
|
+
✓ Created 2 commit group(s)
|
|
417
|
+
|
|
418
|
+
Step 4: AI review...
|
|
419
|
+
✓ AI review complete
|
|
420
|
+
|
|
421
|
+
Step 5: Generating commit messages...
|
|
422
|
+
✓ Generated messages for 2 commit(s)
|
|
423
|
+
|
|
424
|
+
Step 6: Preview
|
|
425
|
+
[Commit 1 preview]
|
|
426
|
+
[Commit 2 preview]
|
|
427
|
+
|
|
428
|
+
Proceed? [y]es [n]o [d]ry-run
|
|
429
|
+
y
|
|
430
|
+
|
|
431
|
+
Step 7: Creating commits...
|
|
432
|
+
✓ Success!
|
|
433
|
+
Created 2 commit(s)
|
|
434
|
+
1. abc1234
|
|
435
|
+
2. def5678
|
|
436
|
+
|
|
437
|
+
# Total time: 30 seconds
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Roadmap
|
|
441
|
+
|
|
442
|
+
- [ ] Interactive commit editing
|
|
443
|
+
- [ ] Learning mode (observes user edits)
|
|
444
|
+
- [ ] IDE extensions (VS Code, JetBrains)
|
|
445
|
+
- [ ] Pull request generation
|
|
446
|
+
- [ ] Changelog generation
|
|
447
|
+
- [ ] Team configurations
|
|
448
|
+
- [ ] Analytics dashboard
|
|
449
|
+
- [ ] GitHub Actions integration
|
|
450
|
+
- [ ] Semantic history visualization
|
|
451
|
+
|
|
452
|
+
## Contributing
|
|
453
|
+
|
|
454
|
+
Contributions are welcome! Areas for help:
|
|
455
|
+
|
|
456
|
+
- [ ] Language-specific AST parsers
|
|
457
|
+
- [ ] Framework plugins (Next.js, FastAPI, etc.)
|
|
458
|
+
- [ ] IDE extensions
|
|
459
|
+
- [ ] Documentation
|
|
460
|
+
- [ ] Testing and bug reports
|
|
461
|
+
|
|
462
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
463
|
+
|
|
464
|
+
## License
|
|
465
|
+
|
|
466
|
+
MIT License - See [LICENSE](LICENSE) file.
|
|
467
|
+
|
|
468
|
+
## Support
|
|
469
|
+
|
|
470
|
+
- 📖 Documentation: [docs/](docs/)
|
|
471
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/hamxa296/Smart-Commit/issues)
|
|
472
|
+
- 💬 Discussions: [GitHub Discussions](https://github.com/hamxa296/Smart-Commit/discussions)
|
|
473
|
+
|
|
474
|
+
## Acknowledgments
|
|
475
|
+
|
|
476
|
+
Smart Commit builds on:
|
|
477
|
+
- [GitPython](https://gitpython.readthedocs.io/) for git operations
|
|
478
|
+
- [Typer](https://typer.tiangolo.com/) for CLI
|
|
479
|
+
- [Rich](https://rich.readthedocs.io/) for terminal UI
|
|
480
|
+
- [Sentence Transformers](https://www.sbert.net/) for embeddings
|
|
481
|
+
- [LiteLLM](https://github.com/BerriAI/litellm) for LLM access
|
|
482
|
+
- [scikit-learn](https://scikit-learn.org/) for clustering
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
**Made with ❤️ to make Git history beautiful**
|
|
487
|
+
|
|
488
|
+
## Installation
|
|
489
|
+
|
|
490
|
+
### Requirements
|
|
491
|
+
- Python 3.12+
|
|
492
|
+
- Git
|
|
493
|
+
|
|
494
|
+
### From PyPI (Coming Soon)
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
pip install smart-commit
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### From Source
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
git clone https://github.com/hamxa296/Smart-Commit.git
|
|
504
|
+
cd Smart-Commit
|
|
505
|
+
pip install -e .
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### Install Dependencies
|
|
509
|
+
|
|
510
|
+
```bash
|
|
511
|
+
pip install -r requirements.txt
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
## Quick Start
|
|
515
|
+
|
|
516
|
+
### Initialize Smart Commit
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
smart-commit init
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Configure Your LLM
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
smart-commit config --provider openrouter --model anthropic/claude-sonnet --api-key YOUR_KEY
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Or set environment variables:
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
export SMART_COMMIT_PROVIDER=openrouter
|
|
532
|
+
export SMART_COMMIT_MODEL=anthropic/claude-sonnet
|
|
533
|
+
export SMART_COMMIT_API_KEY=your-api-key
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### Run Smart Commit
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
smart-commit run
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
This will:
|
|
543
|
+
1. Detect all changed files
|
|
544
|
+
2. Analyze diffs and create summaries
|
|
545
|
+
3. Generate semantic embeddings
|
|
546
|
+
4. Cluster related files
|
|
547
|
+
5. Display a preview of proposed commits
|
|
548
|
+
6. Execute commits upon confirmation
|
|
549
|
+
|
|
550
|
+
## Commands
|
|
551
|
+
|
|
552
|
+
```bash
|
|
553
|
+
# Analyze and create commits
|
|
554
|
+
smart-commit run
|
|
555
|
+
|
|
556
|
+
# Preview without executing
|
|
557
|
+
smart-commit preview
|
|
558
|
+
|
|
559
|
+
# Undo last session
|
|
560
|
+
smart-commit undo
|
|
561
|
+
|
|
562
|
+
# Configure settings
|
|
563
|
+
smart-commit config --show
|
|
564
|
+
|
|
565
|
+
# Diagnostic checks
|
|
566
|
+
smart-commit doctor
|
|
567
|
+
|
|
568
|
+
# Show version
|
|
569
|
+
smart-commit version
|
|
570
|
+
|
|
571
|
+
# Initialize repository
|
|
572
|
+
smart-commit init
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
## Architecture
|
|
576
|
+
|
|
577
|
+
The tool follows a modular pipeline:
|
|
578
|
+
|
|
579
|
+
```
|
|
580
|
+
Repository
|
|
581
|
+
↓
|
|
582
|
+
Git Scanner (git_service.py)
|
|
583
|
+
↓
|
|
584
|
+
Diff Parser (diff_parser.py)
|
|
585
|
+
↓
|
|
586
|
+
File Summarizer (summarizer.py)
|
|
587
|
+
↓
|
|
588
|
+
Embedding Generator (embeddings.py)
|
|
589
|
+
↓
|
|
590
|
+
Semantic Clustering (clustering.py)
|
|
591
|
+
↓
|
|
592
|
+
LLM Cluster Review (ai.py)
|
|
593
|
+
↓
|
|
594
|
+
Commit Message Generator (commit_messages.py)
|
|
595
|
+
↓
|
|
596
|
+
Interactive Preview (preview.py)
|
|
597
|
+
↓
|
|
598
|
+
Git Commit Executor (committer.py)
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
## Configuration
|
|
602
|
+
|
|
603
|
+
Smart Commit looks for configuration in this order:
|
|
604
|
+
|
|
605
|
+
1. `~/.smart_commit/config.yaml`
|
|
606
|
+
2. Environment variables (`SMART_COMMIT_*`)
|
|
607
|
+
3. Default values
|
|
608
|
+
|
|
609
|
+
### Example config.yaml
|
|
610
|
+
|
|
611
|
+
```yaml
|
|
612
|
+
provider: openrouter
|
|
613
|
+
model: anthropic/claude-sonnet
|
|
614
|
+
embedding_model: all-MiniLM-L6-v2
|
|
615
|
+
max_files_per_commit: 8
|
|
616
|
+
interactive: true
|
|
617
|
+
auto_push: false
|
|
618
|
+
conventional_commits: true
|
|
619
|
+
use_local_embeddings: true
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
## Supported LLM Providers
|
|
623
|
+
|
|
624
|
+
Smart Commit uses [LiteLLM](https://github.com/BerriAI/litellm) to support:
|
|
625
|
+
|
|
626
|
+
- OpenRouter
|
|
627
|
+
- OpenAI
|
|
628
|
+
- Anthropic
|
|
629
|
+
- Gemini
|
|
630
|
+
- Groq
|
|
631
|
+
- Azure OpenAI
|
|
632
|
+
- Local models (Ollama, LM Studio, etc.)
|
|
633
|
+
|
|
634
|
+
## Development
|
|
635
|
+
|
|
636
|
+
### Project Structure
|
|
637
|
+
|
|
638
|
+
```
|
|
639
|
+
smart_commit/
|
|
640
|
+
├── __init__.py
|
|
641
|
+
├── cli.py # Command-line interface
|
|
642
|
+
├── config.py # Configuration management
|
|
643
|
+
├── models.py # Data models
|
|
644
|
+
├── utils.py # Utility functions
|
|
645
|
+
├── git_service.py # Git operations
|
|
646
|
+
├── diff_parser.py # Diff parsing
|
|
647
|
+
├── summarizer.py # Summary generation
|
|
648
|
+
├── embeddings.py # Embedding generation
|
|
649
|
+
├── clustering.py # File clustering
|
|
650
|
+
├── ai.py # LLM analysis
|
|
651
|
+
├── commit_messages.py # Message generation
|
|
652
|
+
├── preview.py # Interactive UI
|
|
653
|
+
└── committer.py # Commit execution
|
|
654
|
+
tests/
|
|
655
|
+
├── __init__.py
|
|
656
|
+
├── test_git_service.py
|
|
657
|
+
├── test_diff_parser.py
|
|
658
|
+
└── test_clustering.py
|
|
659
|
+
pyproject.toml
|
|
660
|
+
README.md
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### Development Setup
|
|
664
|
+
|
|
665
|
+
```bash
|
|
666
|
+
# Clone the repository
|
|
667
|
+
git clone https://github.com/hamxa296/Smart-Commit.git
|
|
668
|
+
cd Smart-Commit
|
|
669
|
+
|
|
670
|
+
# Create virtual environment
|
|
671
|
+
python -m venv venv
|
|
672
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
673
|
+
|
|
674
|
+
# Install in development mode with dev dependencies
|
|
675
|
+
pip install -e ".[dev]"
|
|
676
|
+
|
|
677
|
+
# Run tests
|
|
678
|
+
pytest
|
|
679
|
+
|
|
680
|
+
# Run linting
|
|
681
|
+
ruff check smart_commit tests
|
|
682
|
+
black --check smart_commit tests
|
|
683
|
+
|
|
684
|
+
# Format code
|
|
685
|
+
black smart_commit tests
|
|
686
|
+
ruff check --fix smart_commit tests
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
## Milestones
|
|
690
|
+
|
|
691
|
+
### Milestone 1: ✅ Foundation (Complete)
|
|
692
|
+
- Repository detection
|
|
693
|
+
- Changed file discovery
|
|
694
|
+
- Git wrapper
|
|
695
|
+
- Deliverable: Basic repository scanner
|
|
696
|
+
|
|
697
|
+
### Milestone 2: In Progress
|
|
698
|
+
- Diff parser
|
|
699
|
+
- Structured diff representation
|
|
700
|
+
- Deliverable: Readable summaries of code changes
|
|
701
|
+
|
|
702
|
+
### Milestone 3: Planned
|
|
703
|
+
- Rule-based grouping
|
|
704
|
+
- Conventional Commit generation
|
|
705
|
+
- Terminal preview
|
|
706
|
+
- Deliverable: Working MVP
|
|
707
|
+
|
|
708
|
+
### Milestone 4: Planned
|
|
709
|
+
- Embedding generation
|
|
710
|
+
- Semantic clustering
|
|
711
|
+
- Deliverable: Cross-folder logical commit grouping
|
|
712
|
+
|
|
713
|
+
### Milestone 5: Planned
|
|
714
|
+
- LLM cluster refinement
|
|
715
|
+
- AI-generated commit messages
|
|
716
|
+
- Deliverable: High-quality commit history
|
|
717
|
+
|
|
718
|
+
### Milestone 6: Planned
|
|
719
|
+
- Interactive editing
|
|
720
|
+
- Undo support
|
|
721
|
+
- Session management
|
|
722
|
+
- Deliverable: Production-ready CLI
|
|
723
|
+
|
|
724
|
+
### Milestone 7: Planned
|
|
725
|
+
- Learning mode
|
|
726
|
+
- Plugins
|
|
727
|
+
- IDE integration
|
|
728
|
+
- PR generation
|
|
729
|
+
- PyPI packaging
|
|
730
|
+
- Deliverable: Polished, extensible developer tool
|
|
731
|
+
|
|
732
|
+
## Why Smart Commit?
|
|
733
|
+
|
|
734
|
+
### Without Smart Commit
|
|
735
|
+
```
|
|
736
|
+
$ git status
|
|
737
|
+
modified: src/auth/login.ts
|
|
738
|
+
modified: src/api/routes.ts
|
|
739
|
+
modified: README.md
|
|
740
|
+
modified: src/auth/jwt.ts
|
|
741
|
+
|
|
742
|
+
$ git add src/auth/login.ts
|
|
743
|
+
$ git add src/auth/jwt.ts
|
|
744
|
+
$ git commit -m "feat(auth): improve login validation"
|
|
745
|
+
# 15 min later...
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
### With Smart Commit
|
|
749
|
+
```
|
|
750
|
+
$ smart-commit run
|
|
751
|
+
Found 4 changed files
|
|
752
|
+
|
|
753
|
+
✓ Proposed commits:
|
|
754
|
+
1. feat(auth): improve login validation and session handling
|
|
755
|
+
2. docs: update README
|
|
756
|
+
|
|
757
|
+
$ [accept] to execute, [e]dit to modify, [s]plit to separate
|
|
758
|
+
# 30 seconds later...
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
## Contributing
|
|
762
|
+
|
|
763
|
+
We welcome contributions! Areas where help is needed:
|
|
764
|
+
|
|
765
|
+
- [ ] Improve diff parsing for different languages
|
|
766
|
+
- [ ] Add support for more LLM providers
|
|
767
|
+
- [ ] Implement learning mode for user preferences
|
|
768
|
+
- [ ] Create IDE extensions (VS Code, JetBrains)
|
|
769
|
+
- [ ] Optimize clustering algorithm
|
|
770
|
+
- [ ] Add comprehensive test coverage
|
|
771
|
+
- [ ] Documentation improvements
|
|
772
|
+
|
|
773
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
774
|
+
|
|
775
|
+
## License
|
|
776
|
+
|
|
777
|
+
MIT License - See [LICENSE](LICENSE) file for details.
|
|
778
|
+
|
|
779
|
+
## Authors
|
|
780
|
+
|
|
781
|
+
- Smart Commit Contributors
|
|
782
|
+
|
|
783
|
+
## Support
|
|
784
|
+
|
|
785
|
+
- 📖 Documentation: See [docs/](docs/) directory
|
|
786
|
+
- 🐛 Bug Reports: GitHub Issues
|
|
787
|
+
- 💬 Discussions: GitHub Discussions
|
|
788
|
+
- 📧 Email: support@smartcommit.dev
|
|
789
|
+
|
|
790
|
+
## Roadmap
|
|
791
|
+
|
|
792
|
+
- [ ] Interactive commit editing
|
|
793
|
+
- [ ] Learning mode for user preferences
|
|
794
|
+
- [ ] Framework-specific plugins (React, Django, Next.js, etc.)
|
|
795
|
+
- [ ] IDE extensions (VS Code, Cursor, Windsurf, JetBrains)
|
|
796
|
+
- [ ] Pull request generation
|
|
797
|
+
- [ ] CI/CD integration
|
|
798
|
+
- [ ] Team mode with shared configurations
|
|
799
|
+
- [ ] Analytics and insights
|
|
800
|
+
|
|
801
|
+
---
|
|
802
|
+
|
|
803
|
+
**Made with ❤️ for better Git workflows**
|
|
804
|
+
|