commitgpt 0.1.2 → 0.3.1
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.
- checksums.yaml +4 -4
- data/README.md +243 -25
- data/commitgpt.gemspec +35 -0
- data/lib/commitgpt/cli.rb +50 -4
- data/lib/commitgpt/commit_ai.rb +434 -43
- data/lib/commitgpt/config_manager.rb +164 -0
- data/lib/commitgpt/provider_presets.rb +19 -0
- data/lib/commitgpt/setup_wizard.rb +314 -0
- data/lib/commitgpt/string.rb +8 -0
- data/lib/commitgpt/version.rb +1 -1
- metadata +21 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -19
- data/CHANGELOG.md +0 -5
- data/CODE_OF_CONDUCT.md +0 -84
- data/Gemfile +0 -16
- data/Gemfile.lock +0 -66
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 39ba14207dd3a3821b77597f628a3a5eb5c4d350bac6f5aac1828feda130f7df
|
|
4
|
+
data.tar.gz: d03c824c7e5f6b31a3e16dc1175def59b85980da67e9767a643242ea5d65b1df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84fed7c25c40981c4ac1c6d29e26c5260b3b79a59e7e7921aec5d0f176d826f07c06d21d354fd7168d3b0a0f17a9bcd834271d17cd5a2db0cf63964de02a4dd0
|
|
7
|
+
data.tar.gz: e443c012f0ddb35f03551a4d7b943dd207c5500f647e6cacf429f20e3ce1e6863eced86f9292232c7ce49a6aa6fb2d088e180d3c59b8bc268e24fd07d980b097
|
data/README.md
CHANGED
|
@@ -8,53 +8,271 @@
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
|
+
|
|
12
|
+
### Method 1: Homebrew (Recommended)
|
|
13
|
+
|
|
14
|
+
The easiest way to install and keep CommitGPT updated.
|
|
15
|
+
|
|
16
|
+
**Install:**
|
|
17
|
+
|
|
11
18
|
```bash
|
|
12
|
-
|
|
19
|
+
brew tap ZPVIP/commitgpt https://github.com/ZPVIP/commitgpt
|
|
20
|
+
brew install commitgpt
|
|
13
21
|
```
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
**Upgrade:**
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
brew update
|
|
27
|
+
brew upgrade commitgpt
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Uninstall:**
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
brew uninstall commitgpt
|
|
34
|
+
# Optional: Remove configuration files manually
|
|
35
|
+
rm -rf ~/.config/commitgpt
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Method 2: RubyGems (For Ruby Developers)
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary>Click to expand RubyGems installation instructions</summary>
|
|
42
|
+
|
|
43
|
+
#### Prerequisites: Install Ruby
|
|
44
|
+
|
|
45
|
+
If you don't have Ruby installed, follow these steps first.
|
|
46
|
+
|
|
47
|
+
<details>
|
|
48
|
+
<summary><strong>macOS</strong></summary>
|
|
49
|
+
|
|
50
|
+
**1. Install Homebrew** (skip if already installed)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
54
|
+
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
|
|
55
|
+
source ~/.zshrc
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**2. Install Ruby dependencies**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
brew install openssl@3 libyaml gmp rust
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
<details>
|
|
67
|
+
<summary><strong>Ubuntu / Debian</strong></summary>
|
|
68
|
+
|
|
69
|
+
**Install Ruby dependencies**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
sudo apt-get update
|
|
73
|
+
sudo apt install build-essential rustc libssl-dev libyaml-dev zlib1g-dev libgmp-dev
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
</details>
|
|
77
|
+
|
|
78
|
+
**Install Ruby with Mise** (version manager)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Install Mise
|
|
82
|
+
curl https://mise.run | sh
|
|
83
|
+
|
|
84
|
+
# For zsh (macOS default)
|
|
85
|
+
echo 'eval "$(~/.local/bin/mise activate)"' >> ~/.zshrc
|
|
86
|
+
source ~/.zshrc
|
|
87
|
+
|
|
88
|
+
# For bash (Ubuntu default)
|
|
89
|
+
# echo 'eval "$(~/.local/bin/mise activate)"' >> ~/.bashrc
|
|
90
|
+
# source ~/.bashrc
|
|
91
|
+
|
|
92
|
+
# Install Ruby
|
|
93
|
+
mise use --global ruby@3
|
|
94
|
+
|
|
95
|
+
# Verify installation
|
|
96
|
+
ruby --version
|
|
97
|
+
#=> 3.4.7
|
|
98
|
+
|
|
99
|
+
# Update RubyGems
|
|
100
|
+
gem update --system
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Install CommitGPT
|
|
104
|
+
|
|
18
105
|
```bash
|
|
19
|
-
|
|
106
|
+
gem install commitgpt
|
|
20
107
|
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
108
|
+
|
|
109
|
+
</details>
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Configuration
|
|
114
|
+
|
|
115
|
+
CommitGPT uses a YAML configuration system (`~/.config/commitgpt/`) to support multiple providers and per-provider settings.
|
|
116
|
+
|
|
117
|
+
### Interactive Setup (Recommended)
|
|
118
|
+
Run the setup wizard to configure your provider:
|
|
119
|
+
```bash
|
|
120
|
+
$ aicm setup
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
You'll be guided to:
|
|
124
|
+
1. Choose an AI provider (Presets: Cerebras, OpenAI, Ollama, Groq, etc.)
|
|
125
|
+
2. Enter your API Key (stored securely in `config.local.yml`)
|
|
126
|
+
3. Select a model interactively
|
|
127
|
+
4. Set maximum diff length
|
|
128
|
+
|
|
129
|
+
**Note:** Please add `~/.config/commitgpt/config.local.yml` to your `.gitignore` if you are syncing your home directory, as it contains your API keys.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Usage
|
|
134
|
+
|
|
135
|
+
### Generate Commit Message
|
|
136
|
+
Stage your changes and run `aicm`:
|
|
25
137
|
```bash
|
|
26
|
-
$ cd /path/to/your/repo
|
|
27
138
|
$ git add .
|
|
28
139
|
$ aicm
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Switch Provider
|
|
143
|
+
Switch between configured providers easily:
|
|
144
|
+
```bash
|
|
145
|
+
$ aicm -p
|
|
146
|
+
# or
|
|
147
|
+
$ aicm --provider
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Select Model
|
|
151
|
+
Interactively list and select a model for your current provider:
|
|
152
|
+
```bash
|
|
153
|
+
$ aicm -m
|
|
154
|
+
# or
|
|
155
|
+
$ aicm --models
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Check Configuration
|
|
159
|
+
View your current configuration (Provider, Model, Base URL, Diff Len):
|
|
160
|
+
```bash
|
|
161
|
+
$ aicm help
|
|
162
|
+
```
|
|
163
|
+
(Use the help command to see current active provider settings)
|
|
164
|
+
|
|
165
|
+
### View Git Diff
|
|
166
|
+
Preview the diff that will be sent to the AI:
|
|
167
|
+
```bash
|
|
168
|
+
$ aicm -v
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Update
|
|
172
|
+
To update to the latest version (if installed via Gem):
|
|
173
|
+
```bash
|
|
174
|
+
$ gem update commitgpt
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Supported Providers
|
|
180
|
+
We support any OpenAI-compatible API. Presets available for:
|
|
181
|
+
- **Cerebras** (Fast & Recommended)
|
|
182
|
+
- **OpenAI** (Official)
|
|
183
|
+
- **Ollama** (Local)
|
|
184
|
+
- **Groq**
|
|
185
|
+
- **DeepSeek**
|
|
186
|
+
- **Anthropic (Claude)**
|
|
187
|
+
- **Google AI (Gemini)**
|
|
188
|
+
- **Mistral**
|
|
189
|
+
- **OpenRouter**
|
|
190
|
+
- **Local setups** (LM Studio, LLaMa.cpp, Llamafile)
|
|
191
|
+
|
|
192
|
+
### Recommended Providers
|
|
29
193
|
|
|
30
|
-
|
|
31
|
-
|
|
194
|
+
**OpenAI** ([https://platform.openai.com](https://platform.openai.com))
|
|
195
|
+
```
|
|
196
|
+
gpt-4o
|
|
197
|
+
gpt-4o-mini
|
|
198
|
+
```
|
|
32
199
|
|
|
33
|
-
|
|
200
|
+
**Cerebras** ([https://cloud.cerebras.ai](https://cloud.cerebras.ai)) ⭐ Recommended
|
|
201
|
+
```
|
|
202
|
+
zai-glm-4.7 # ⭐ Best for commit messages - fast & accurate
|
|
203
|
+
llama3.1-8b
|
|
204
|
+
llama-3.3-70b
|
|
205
|
+
```
|
|
34
206
|
|
|
35
|
-
|
|
36
|
-
[main c082637] Update README.md with contribution instructions and OpenAI API key instructions.
|
|
37
|
-
4 files changed, 24 insertions(+), 19 deletions(-)
|
|
207
|
+
**Groq** ([https://console.groq.com](https://console.groq.com))
|
|
38
208
|
```
|
|
209
|
+
llama-3.3-70b-versatile
|
|
210
|
+
llama-3.1-8b-instant
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## How It Works
|
|
214
|
+
This CLI tool runs a `git diff` command to grab all staged changes, sends this to OpenAI's GPT API (or compatible endpoint), and returns an AI-generated commit message. The tool uses the `/v1/chat/completions` endpoint with optimized prompts/system instructions for generating conventional commit messages.
|
|
39
215
|
|
|
40
216
|
## Special Thanks
|
|
41
|
-
I used
|
|
217
|
+
I used ChatGPT to convert `AICommits` from TypeScript to Ruby. Special thanks to [https://github.com/Nutlope/aicommits](https://github.com/Nutlope/aicommits)
|
|
42
218
|
|
|
43
|
-
|
|
44
|
-
This CLI tool runs a git diff command to grab all the latest changes, sends this to OpenAI's GPT-3, then returns the AI generated commit message. I also want to note that it does cost money since GPT-3 generations aren't free. However, OpenAI gives folks $18 of free credits and commit message generations are cheap so it should be free for a long time.
|
|
219
|
+
---
|
|
45
220
|
|
|
46
|
-
##
|
|
47
|
-
Only supports git diffs of up to 200 lines of code for now
|
|
48
|
-
The generated commit message can't be edited yet, but you can choose `n` and copy the commit command and edit it manually.
|
|
221
|
+
## Development Guide
|
|
49
222
|
|
|
50
|
-
|
|
223
|
+
### Requirements
|
|
224
|
+
- Ruby >= 2.6.0
|
|
225
|
+
- Git
|
|
226
|
+
|
|
227
|
+
### Local Setup
|
|
228
|
+
1. Clone the repository:
|
|
229
|
+
```bash
|
|
230
|
+
git clone https://github.com/ZPVIP/commitgpt.git
|
|
231
|
+
cd commitgpt
|
|
232
|
+
```
|
|
233
|
+
2. Install dependencies:
|
|
234
|
+
```bash
|
|
235
|
+
bundle install
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Local Build and Install
|
|
239
|
+
To test your changes locally (builds the gem and installs it to your system):
|
|
240
|
+
```bash
|
|
241
|
+
gem build commitgpt.gemspec
|
|
242
|
+
gem install ./commitgpt-*.gem
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Publishing
|
|
51
246
|
|
|
247
|
+
#### RubyGems
|
|
248
|
+
To publish a new version to RubyGems.org (requires RubyGems account permissions):
|
|
249
|
+
```bash
|
|
250
|
+
gem push commitgpt-*.gem
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Homebrew (GitHub Distribution)
|
|
254
|
+
We use a custom script to automate the GitHub Release and Homebrew Formula update process. This enables users to install via `brew tap`.
|
|
255
|
+
|
|
256
|
+
**Steps:**
|
|
257
|
+
```bash
|
|
258
|
+
./scripts/release.sh <version>
|
|
259
|
+
# Example: ./scripts/release.sh 0.3.1
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**This script automates:**
|
|
263
|
+
1. Creating and pushing a Git Tag.
|
|
264
|
+
2. Creating a GitHub Release (which generates the source tarball).
|
|
265
|
+
3. Calculating the SHA256 checksum of the tarball.
|
|
266
|
+
4. Updating `Formula/commitgpt.rb` with the new URL and checksum.
|
|
267
|
+
5. Committing and pushing the updated Formula to the repository.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Contributing
|
|
52
272
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ZPVIP/commitgpt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ZPVIP/commitgpt/blob/main/CODE_OF_CONDUCT.md).
|
|
53
273
|
|
|
54
274
|
## License
|
|
55
|
-
|
|
56
275
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
57
276
|
|
|
58
277
|
## Code of Conduct
|
|
59
|
-
|
|
60
278
|
Everyone interacting in the CommitGpt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ZPVIP/commitgpt/blob/master/CODE_OF_CONDUCT.md).
|
data/commitgpt.gemspec
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/commitgpt/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "commitgpt"
|
|
7
|
+
spec.version = CommitGpt::VERSION
|
|
8
|
+
spec.authors = ["Peng Zhang"]
|
|
9
|
+
spec.email = ["zpregister@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "A CLI AI that writes git commit messages for you."
|
|
12
|
+
spec.description = "A CLI that writes your git commit messages for you with AI. Never write a commit message again."
|
|
13
|
+
spec.homepage = "https://github.com/ZPVIP/commitgpt"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.glob("lib/**/*") + Dir.glob("bin/*") + %w[README.md LICENSE commitgpt.gemspec]
|
|
23
|
+
.reject { |f| File.directory?(f) }
|
|
24
|
+
spec.bindir = "bin"
|
|
25
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
|
26
|
+
spec.require_paths = ["lib"]
|
|
27
|
+
|
|
28
|
+
# Uncomment to register a new dependency of your gem
|
|
29
|
+
spec.add_dependency "httparty", "~> 0.18"
|
|
30
|
+
spec.add_dependency "thor", "~> 1.2"
|
|
31
|
+
spec.add_dependency "tty-prompt", "~> 0.23"
|
|
32
|
+
|
|
33
|
+
# For more information and examples about making a new gem, checkout our
|
|
34
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
35
|
+
end
|
data/lib/commitgpt/cli.rb
CHANGED
|
@@ -2,15 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
require "thor"
|
|
4
4
|
require "commitgpt/commit_ai"
|
|
5
|
+
require "commitgpt/setup_wizard"
|
|
5
6
|
|
|
6
7
|
module CommitGpt
|
|
7
8
|
# CommitGpt CLI
|
|
8
9
|
class CLI < Thor
|
|
9
|
-
default_task :
|
|
10
|
+
default_task :generate
|
|
10
11
|
|
|
11
|
-
desc "
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
desc "generate", "AI commits for you!"
|
|
13
|
+
method_option :models, aliases: "-m", type: :boolean, desc: "List/Select available models"
|
|
14
|
+
method_option :verbose, aliases: "-v", type: :boolean, desc: "Show git diff being sent to AI"
|
|
15
|
+
method_option :provider, aliases: "-p", type: :boolean, desc: "Switch active provider"
|
|
16
|
+
def generate
|
|
17
|
+
if options[:provider]
|
|
18
|
+
CommitGpt::SetupWizard.new.switch_provider
|
|
19
|
+
elsif options[:models]
|
|
20
|
+
CommitGpt::SetupWizard.new.change_model
|
|
21
|
+
else
|
|
22
|
+
CommitGpt::CommitAi.new.aicm(verbose: options[:verbose])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc "setup", "Configure AI provider and settings"
|
|
27
|
+
def setup
|
|
28
|
+
CommitGpt::SetupWizard.new.run
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Custom help message
|
|
32
|
+
def self.help(shell, subcommand = false)
|
|
33
|
+
shell.say "Usage:"
|
|
34
|
+
shell.say " aicm # Generate AI commit message (Default)"
|
|
35
|
+
shell.say " aicm setup # Configure AI provider and settings"
|
|
36
|
+
shell.say " aicm help [COMMAND] # Describe available commands"
|
|
37
|
+
shell.say ""
|
|
38
|
+
shell.say "Options:"
|
|
39
|
+
shell.say " -m, --models # Interactive model selection"
|
|
40
|
+
shell.say " -p, --provider # Switch active provider"
|
|
41
|
+
shell.say " -v, --verbose # Show git diff being sent to AI"
|
|
42
|
+
shell.say ""
|
|
43
|
+
|
|
44
|
+
# Show current configuration
|
|
45
|
+
begin
|
|
46
|
+
require "commitgpt/config_manager"
|
|
47
|
+
require "commitgpt/string"
|
|
48
|
+
config = CommitGpt::ConfigManager.get_active_provider_config
|
|
49
|
+
if config
|
|
50
|
+
shell.say "Current Configuration:"
|
|
51
|
+
shell.say " Provider: #{config['name'].green}"
|
|
52
|
+
shell.say " Model: #{config['model'].cyan}"
|
|
53
|
+
shell.say " Base URL: #{config['base_url']}"
|
|
54
|
+
shell.say " Diff Len: #{config['diff_len']}"
|
|
55
|
+
shell.say ""
|
|
56
|
+
end
|
|
57
|
+
rescue StandardError
|
|
58
|
+
# Ignore errors during help display if config is missing/invalid
|
|
59
|
+
end
|
|
14
60
|
end
|
|
15
61
|
end
|
|
16
62
|
end
|