comit-cli 1.0.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.
Files changed (48) hide show
  1. comit_cli-1.0.0/PKG-INFO +524 -0
  2. comit_cli-1.0.0/README.md +484 -0
  3. comit_cli-1.0.0/pyproject.toml +69 -0
  4. comit_cli-1.0.0/setup.cfg +4 -0
  5. comit_cli-1.0.0/src/comit/__init__.py +1 -0
  6. comit_cli-1.0.0/src/comit/ai/__init__.py +39 -0
  7. comit_cli-1.0.0/src/comit/ai/base.py +42 -0
  8. comit_cli-1.0.0/src/comit/ai/factory.py +59 -0
  9. comit_cli-1.0.0/src/comit/ai/gemini_provider.py +125 -0
  10. comit_cli-1.0.0/src/comit/ai/groq_provider.py +121 -0
  11. comit_cli-1.0.0/src/comit/ai/ollama_provider.py +107 -0
  12. comit_cli-1.0.0/src/comit/ai/openai_provider.py +107 -0
  13. comit_cli-1.0.0/src/comit/cli.py +446 -0
  14. comit_cli-1.0.0/src/comit/commit/__init__.py +21 -0
  15. comit_cli-1.0.0/src/comit/commit/context.py +60 -0
  16. comit_cli-1.0.0/src/comit/commit/validator.py +270 -0
  17. comit_cli-1.0.0/src/comit/config.py +279 -0
  18. comit_cli-1.0.0/src/comit/git.py +281 -0
  19. comit_cli-1.0.0/src/comit/prompts.py +148 -0
  20. comit_cli-1.0.0/src/comit/review/__init__.py +29 -0
  21. comit_cli-1.0.0/src/comit/review/base.py +13 -0
  22. comit_cli-1.0.0/src/comit/review/databases.py +40 -0
  23. comit_cli-1.0.0/src/comit/review/engine.py +92 -0
  24. comit_cli-1.0.0/src/comit/review/generated_files.py +75 -0
  25. comit_cli-1.0.0/src/comit/review/git_files.py +54 -0
  26. comit_cli-1.0.0/src/comit/review/large_files.py +38 -0
  27. comit_cli-1.0.0/src/comit/review/models.py +59 -0
  28. comit_cli-1.0.0/src/comit/review/private_keys.py +69 -0
  29. comit_cli-1.0.0/src/comit/review/secrets.py +230 -0
  30. comit_cli-1.0.0/src/comit/review/sensitive_files.py +79 -0
  31. comit_cli-1.0.0/src/comit/ui.py +412 -0
  32. comit_cli-1.0.0/src/comit_cli.egg-info/PKG-INFO +524 -0
  33. comit_cli-1.0.0/src/comit_cli.egg-info/SOURCES.txt +46 -0
  34. comit_cli-1.0.0/src/comit_cli.egg-info/dependency_links.txt +1 -0
  35. comit_cli-1.0.0/src/comit_cli.egg-info/entry_points.txt +3 -0
  36. comit_cli-1.0.0/src/comit_cli.egg-info/requires.txt +29 -0
  37. comit_cli-1.0.0/src/comit_cli.egg-info/top_level.txt +1 -0
  38. comit_cli-1.0.0/tests/test_ai.py +277 -0
  39. comit_cli-1.0.0/tests/test_clean_installation.py +191 -0
  40. comit_cli-1.0.0/tests/test_cli.py +681 -0
  41. comit_cli-1.0.0/tests/test_config.py +192 -0
  42. comit_cli-1.0.0/tests/test_git.py +363 -0
  43. comit_cli-1.0.0/tests/test_git_ai_subcmd.py +113 -0
  44. comit_cli-1.0.0/tests/test_packaging.py +74 -0
  45. comit_cli-1.0.0/tests/test_prompts.py +175 -0
  46. comit_cli-1.0.0/tests/test_review.py +438 -0
  47. comit_cli-1.0.0/tests/test_ui.py +126 -0
  48. comit_cli-1.0.0/tests/test_validator.py +209 -0
@@ -0,0 +1,524 @@
1
+ Metadata-Version: 2.4
2
+ Name: comit-cli
3
+ Version: 1.0.0
4
+ Summary: An AI-powered Git commit assistant that understands your repository's commit style
5
+ Author: Comit Team
6
+ License-Expression: MIT
7
+ Keywords: git,commit,ai,cli,groq,developer-tools
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Software Development :: Version Control :: Git
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: typer>=0.9.0
19
+ Requires-Dist: rich>=13.0.0
20
+ Requires-Dist: python-dotenv>=1.0.0
21
+ Requires-Dist: groq>=0.9.0
22
+ Requires-Dist: prompt-toolkit>=3.0.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest>=7.0.0; extra == "test"
27
+ Provides-Extra: tests
28
+ Requires-Dist: pytest>=7.0.0; extra == "tests"
29
+ Provides-Extra: gemini
30
+ Requires-Dist: google-genai>=0.1.0; extra == "gemini"
31
+ Provides-Extra: openai
32
+ Requires-Dist: openai>=1.0.0; extra == "openai"
33
+ Provides-Extra: ollama
34
+ Requires-Dist: ollama>=0.3.0; extra == "ollama"
35
+ Provides-Extra: all
36
+ Requires-Dist: groq>=0.9.0; extra == "all"
37
+ Requires-Dist: google-genai>=0.1.0; extra == "all"
38
+ Requires-Dist: openai>=1.0.0; extra == "all"
39
+ Requires-Dist: ollama>=0.3.0; extra == "all"
40
+
41
+ # Comit
42
+
43
+ > AI-powered Git commit messages that understand your project's commit style.
44
+
45
+ Comit is a lightweight developer CLI for Git. It analyzes your staged changes and recent commit history, learns your repository's commit conventions, and generates concise, accurate commit messages using your choice of AI provider.
46
+
47
+ ## Features
48
+
49
+ - **Multi-Provider Support** — Use Groq, Google Gemini, OpenAI, or local models with Ollama.
50
+ - **Context-aware** — Analyzes your staged diff and recent commit history to match your repository's style.
51
+ - **Commit message validation** — Deterministically validates generated commit messages against staged files to catch mismatches before committing.
52
+ - **Developer in control** — Review, edit, regenerate, or cancel a suggested commit message before committing.
53
+ - **Push Integration** — Optional safe remote pushing after creating a commit.
54
+ - **Fast-track mode** — Use `-y` to automatically commit the generated message without confirmation.
55
+ - **Settings management** — Configure your provider, model, API keys, and endpoints interactively or via CLI commands.
56
+ - **Safe and non-destructive** — Only analyzes staged changes with `git diff --cached`. Comit never stages files or modifies unstaged changes.
57
+
58
+ ## Supported Providers
59
+
60
+ | Provider | Default Model | Authentication | Setup / Env Variable |
61
+ | :--- | :--- | :--- | :--- |
62
+ | **Groq** *(Default)* | `qwen/qwen3.8-27b` | API Key | `GROQ_API_KEY` |
63
+ | **Google Gemini** | `gemini-2.5-flash` | API Key | `GEMINI_API_KEY` |
64
+ | **OpenAI** | `gpt-4o-mini` | API Key | `OPENAI_API_KEY` |
65
+ | **Ollama** | `llama3.2` | None (Local) | `OLLAMA_HOST` (default: `http://localhost:11434`) |
66
+
67
+ ## Installation
68
+
69
+ ### Requirements
70
+
71
+ - Python 3.11+
72
+ - Git
73
+
74
+ ### Installing from Source (Current Development)
75
+
76
+ Clone the repository and install Comit into your environment:
77
+
78
+ ```bash
79
+ git clone https://github.com/blackin4k/comit.git
80
+ cd comit
81
+ pip install .
82
+ ```
83
+
84
+ For editable development mode:
85
+
86
+ ```bash
87
+ pip install -e .
88
+ ```
89
+
90
+ To install with additional provider SDKs and testing dependencies:
91
+
92
+ ```bash
93
+ # Google Gemini SDK
94
+ pip install -e ".[gemini]"
95
+
96
+ # OpenAI SDK
97
+ pip install -e ".[openai]"
98
+
99
+ # Ollama SDK
100
+ pip install -e ".[ollama]"
101
+
102
+ # All providers and testing tools
103
+ pip install -e ".[all,test]"
104
+ ```
105
+
106
+ ### Installing from PyPI (After Release)
107
+
108
+ Once published to PyPI, Comit can be installed directly:
109
+
110
+ ```bash
111
+ pip install comit-cli
112
+ ```
113
+
114
+ With optional provider extras:
115
+
116
+ ```bash
117
+ pip install "comit-cli[all]"
118
+ ```
119
+
120
+ Note: The PyPI package distribution name is `comit-cli`, while the Python import package remains `comit`, providing both the `comit` and `git ai` CLI entry points.
121
+
122
+ ### Windows PATH Note
123
+
124
+ When installing Python packages with CLI scripts, pip places executables (like `git-ai.exe`) into your Python Scripts directory.
125
+
126
+ Make sure your Python Scripts directory is on your system or user `PATH` so Git discovers the `git ai` extension from any terminal session.
127
+
128
+ Common Python Scripts locations on Windows:
129
+ - System Python: `C:\Users\<Username>\AppData\Local\Programs\Python\Python313\Scripts`
130
+ - Virtual Environment: `<venv_path>\Scripts`
131
+
132
+ ## Quick Start
133
+
134
+ ### 1. Verify Installation
135
+
136
+ ```powershell
137
+ git ai --version
138
+ ```
139
+
140
+ ### 2. Configure Your Provider & API Key
141
+
142
+ Open the interactive settings menu:
143
+
144
+ ```powershell
145
+ git ai settings
146
+ ```
147
+
148
+ Or configure via CLI:
149
+
150
+ ```powershell
151
+ # Select provider (groq, gemini, openai, ollama)
152
+ git ai settings set-provider groq
153
+
154
+ # Set API key for the active provider
155
+ git ai settings set-key
156
+
157
+ # Or specify the provider directly
158
+ git ai settings set-key --provider gemini
159
+ ```
160
+
161
+ ### 3. Generate Commit Messages
162
+
163
+ Stage your files:
164
+
165
+ ```bash
166
+ git add <files>
167
+ ```
168
+
169
+ Run Comit:
170
+
171
+ ```bash
172
+ git ai commit
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Configuration & Settings
178
+
179
+ Comit provides an interactive configuration interface as well as non-interactive subcommands.
180
+
181
+ ### Interactive Settings Menu
182
+
183
+ ```powershell
184
+ git ai settings
185
+ ```
186
+
187
+ Options:
188
+ 1. View configuration
189
+ 2. Select AI provider
190
+ 3. Configure API key / host
191
+ 4. Configure model
192
+ 5. Reset configuration
193
+ 6. Exit
194
+
195
+ ### Settings Commands
196
+
197
+ - **View configuration:**
198
+ ```powershell
199
+ git ai settings show
200
+ ```
201
+
202
+ - **Set AI provider:**
203
+ ```powershell
204
+ git ai settings set-provider gemini
205
+ ```
206
+
207
+ - **Set API key (masked prompt):**
208
+ ```powershell
209
+ git ai settings set-key
210
+ git ai settings set-key --provider openai
211
+ ```
212
+
213
+ - **Set model:**
214
+ ```powershell
215
+ git ai settings set-model qwen/qwen3.8-27b
216
+ git ai settings set-model gpt-4o --provider openai
217
+ ```
218
+
219
+ - **Set Ollama host URL:**
220
+ ```powershell
221
+ git ai settings set-host http://localhost:11434
222
+ ```
223
+
224
+ - **Reset user configuration:**
225
+ ```powershell
226
+ git ai settings reset
227
+ ```
228
+
229
+ ### Configuration Precedence
230
+
231
+ Comit resolves settings in the following order:
232
+
233
+ 1. **Environment variables**:
234
+ - Provider: `COMIT_PROVIDER`
235
+ - Model: `COMIT_MODEL`, `GROQ_MODEL`, `GEMINI_MODEL`, `OPENAI_MODEL`, `OLLAMA_MODEL`
236
+ - API Keys / Endpoints: `GROQ_API_KEY`, `GEMINI_API_KEY`, `OPENAI_API_KEY`, `OLLAMA_HOST`
237
+ 2. **User configuration** (`config.json` stored in `%APPDATA%\comit` on Windows or `~/.config/comit` on Linux/macOS)
238
+ 3. **Application defaults** (Provider: `groq`, Model: `qwen/qwen3.8-27b`)
239
+
240
+ ---
241
+
242
+ ## Usage
243
+
244
+ ### Interactive Mode
245
+
246
+ First, stage your changes:
247
+
248
+ ```bash
249
+ git add <files>
250
+ ```
251
+
252
+ Then run:
253
+
254
+ ```bash
255
+ git ai commit
256
+ ```
257
+
258
+ Comit performs a deterministic safety review of your staged changes, generates a commit suggestion, and validates the message against staged files:
259
+
260
+ ```text
261
+ No issues detected.
262
+
263
+ Generated:
264
+
265
+ feat: add JWT refresh token support
266
+
267
+ > Accept
268
+ Edit
269
+ Regenerate
270
+ Cancel
271
+ ```
272
+
273
+ Navigate with **Up/Down arrow keys** or **k/j**, and press **Enter** to select.
274
+
275
+ If safety issues or sensitive files are detected during review, Comit displays the findings and requests confirmation before proceeding to AI generation:
276
+
277
+ ```text
278
+ Review findings:
279
+
280
+ WARNING
281
+ Sensitive environment or credential file staged
282
+ .env
283
+
284
+ Continue to commit? [y/N]
285
+ ```
286
+
287
+ Choosing `No` stops the commit flow safely without calling the AI or modifying files.
288
+
289
+ ### Actions
290
+
291
+ - **Accept (`a` or `1`)** — Creates the commit using the generated message. After the local commit succeeds, you are asked whether to push to the remote (`[y/N]`, default No).
292
+ - **Edit (`e` or `2`)** — Opens an interactive inline editor with the generated message pre-populated. Press **Enter** to save your changes, or **Esc** / **Ctrl+C** to cancel and keep the original generated message.
293
+ - **Regenerate (`r` or `3`)** — Requests an alternative commit message from the AI provider while avoiding previous attempts.
294
+ - **Cancel (`c`, `q`, or `4`)** — Exits cleanly without creating a commit or modifying staged changes.
295
+
296
+ ---
297
+
298
+ ### Commit Message Validation
299
+
300
+ Before you accept a generated commit message, Comit deterministically validates the message against your staged changes:
301
+ - **Syntax and structure** — Checks Conventional Commit format (`feat`, `fix`, `docs`, `refactor`, `test`, etc.), scopes, and breaking-change notation.
302
+ - **Context matching** — Detects high-confidence mismatches, such as claiming a feature when only documentation or test files are staged, or referencing files absent from staged changes.
303
+
304
+ If a mismatch is detected, Comit displays a warning:
305
+
306
+ ```text
307
+ Generated:
308
+
309
+ feat: add authentication endpoints
310
+
311
+ Validation warning:
312
+
313
+ Commit message type 'feat' does not match documentation-only staged changes.
314
+ All 1 staged file(s) are documentation files.
315
+
316
+ > Accept
317
+ Edit
318
+ Regenerate
319
+ Cancel
320
+ ```
321
+
322
+ You remain in full control to:
323
+ - **Accept anyway** if the generated message accurately reflects your intent.
324
+ - **Edit** the message directly.
325
+ - **Regenerate** a new message from the AI provider.
326
+ - **Cancel** without creating a commit.
327
+
328
+ > **Note:** Commit validation is a deterministic consistency check to catch obvious mismatches before committing. It does not guarantee semantic correctness or full intent understanding of arbitrary code.
329
+
330
+ ---
331
+
332
+ ### Change Review & Safety Analysis
333
+
334
+ Analyze staged changes for potential security and configuration issues before committing:
335
+
336
+ ```bash
337
+ git ai review
338
+ ```
339
+
340
+ Comit performs deterministic, local analysis on your staged changes to detect common problematic files and accidental additions:
341
+ - **Sensitive files** — `.env`, `.env.*`, `credentials.json`, `secrets.yaml`, private keys (ignoring `.env.example` templates).
342
+ - **Hardcoded secrets** — AWS keys, OpenAI/Groq/Google API keys, GitHub tokens, and literal credential assignments in added lines.
343
+ - **Private keys** — PEM format RSA, EC, DSA, and OpenSSH private keys.
344
+ - **Database files** — Binary databases (`.db`, `.sqlite`, `.sqlite3`, `.rdb`).
345
+ - **Large files** — Staged files exceeding 5 MB.
346
+ - **Generated artifacts** — `__pycache__`, `.pyc`, `dist/`, `build/`, `node_modules/`, test caches.
347
+ - **Git internal files** — `.git-credentials`, `.gitconfig`, or staged internal `.git/` files.
348
+
349
+ Example output:
350
+
351
+ ```text
352
+ Review findings:
353
+
354
+ HIGH
355
+ Possible hardcoded secret or API key detected
356
+ src/config.py
357
+ Detected pattern: Groq API Key (gsk...xyz)
358
+
359
+ WARNING
360
+ Sensitive environment or credential file staged
361
+ .env
362
+ ```
363
+
364
+ If no issues are found:
365
+
366
+ ```text
367
+ No issues detected.
368
+ ```
369
+
370
+ > **Note:** `git ai review` is a deterministic helper to assist developers before committing; it is not a full security scanner and does not guarantee security. It does not modify files, stage/unstage files, or create commits.
371
+
372
+ ---
373
+
374
+ ### Pushing Commits
375
+
376
+ Pushing is strictly opt-in and safe.
377
+
378
+ #### 1. Interactive commit with push confirmation
379
+
380
+ ```bash
381
+ git ai commit
382
+ ```
383
+
384
+ After accepting the commit, Comit asks:
385
+
386
+ ```text
387
+ Commit created successfully.
388
+
389
+ feat: add JWT refresh token support
390
+
391
+ Push this commit to the remote? [y/N]
392
+ ```
393
+
394
+ Choosing `N` leaves the commit local:
395
+
396
+ ```text
397
+ Commit created locally. Nothing was pushed.
398
+ ```
399
+
400
+ #### 2. Automatic push after commit
401
+
402
+ ```bash
403
+ git ai commit --push
404
+ ```
405
+
406
+ Reviews the commit message interactively, and pushes automatically to `origin/<branch>` upon acceptance without a secondary prompt.
407
+
408
+ #### 3. Fast mode without push
409
+
410
+ ```bash
411
+ git ai commit -y
412
+ ```
413
+
414
+ Automatically accepts the generated commit message. Does **not** push to the remote.
415
+
416
+ #### 4. Fast mode with automatic push
417
+
418
+ ```bash
419
+ git ai commit -y --push
420
+ ```
421
+
422
+ Automatically accepts the generated message, creates the commit, and pushes to `origin/<branch>`.
423
+
424
+ ---
425
+
426
+ ## Safety Guarantees
427
+
428
+ Comit only reads staged changes:
429
+
430
+ ```bash
431
+ git diff --cached
432
+ ```
433
+
434
+ Comit does NOT:
435
+ - Automatically run `git add`
436
+ - Modify unstaged files
437
+ - Modify working tree files
438
+ - Create a commit without approval (unless `-y` is explicitly passed)
439
+ - Push to a remote without explicit confirmation or `--push`
440
+ - Force push (`git push --force` is never executed)
441
+ - Write API keys or credentials into repository files
442
+
443
+ If no changes are staged, Comit exits without calling the AI provider.
444
+ If no Git remote is configured, Comit reports that no remote exists and leaves your commit local.
445
+
446
+ ---
447
+
448
+ ## Testing & Quality Assurance
449
+
450
+ ### Running Tests
451
+
452
+ Run the complete test suite:
453
+
454
+ ```bash
455
+ pytest
456
+ ```
457
+
458
+ Run tests with verbose output:
459
+
460
+ ```bash
461
+ pytest -v
462
+ ```
463
+
464
+ ### Building and Verifying Distributions
465
+
466
+ Build the source distribution and wheel:
467
+
468
+ ```bash
469
+ python -m build
470
+ ```
471
+
472
+ Validate package metadata with twine:
473
+
474
+ ```bash
475
+ twine check --strict dist/*
476
+ ```
477
+
478
+ ---
479
+
480
+ ## Continuous Integration & Release
481
+
482
+ ### Continuous Integration (CI)
483
+
484
+ The GitHub Actions CI workflow runs automatically on all pushes and pull requests to `main`. It:
485
+ - Tests on both `ubuntu-latest` and `windows-latest`.
486
+ - Validates against supported Python versions (3.11, 3.12, 3.13).
487
+ - Runs the complete automated test suite.
488
+ - Builds source distributions (`.tar.gz`) and binary wheels (`.whl`).
489
+ - Validates distribution metadata with `twine check --strict`.
490
+
491
+ ### Release Process & PyPI Publishing
492
+
493
+ Releases use PyPI Trusted Publishing via OpenID Connect (OIDC). No long-lived API tokens or credentials are stored in repository secrets.
494
+
495
+ #### Release Workflow
496
+
497
+ 1. Update the version in `pyproject.toml` and `src/comit/__init__.py`.
498
+ 2. Push a version tag matching `v*` (for example, `v0.2.0`):
499
+ ```bash
500
+ git tag v0.2.0
501
+ git push origin v0.2.0
502
+ ```
503
+ 3. The release workflow automatically:
504
+ - Builds the wheel and source distribution.
505
+ - Validates package metadata.
506
+ - Publishes verified artifacts to PyPI via OIDC.
507
+
508
+ #### PyPI Trusted Publisher Configuration
509
+
510
+ To configure PyPI Trusted Publishing for this repository:
511
+ 1. Navigate to your PyPI account settings and go to **Publishing**.
512
+ 2. Add a new **GitHub Publisher**:
513
+ - **PyPI Project Name**: `comit-cli`
514
+ - **Owner**: `blackin4k`
515
+ - **Repository Name**: `comit`
516
+ - **Workflow name**: `release.yml`
517
+ - **Environment name**: `pypi`
518
+ 3. In GitHub repository settings, create the `pypi` environment under **Settings > Environments**.
519
+
520
+ ---
521
+
522
+ ## License
523
+
524
+ MIT License.