jeeves-git-commit 2.5.0 → 2.6.0
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 +20 -0
- data/lib/jeeves/version.rb +1 -1
- data/lib/jeeves.rb +44 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f5b4a1b2b1914123903412e01e1a556118becda1aba4c21d84efa22098813f
|
4
|
+
data.tar.gz: 26fb16c5acd764ba74acb5801c4770f4613baff447dd16e1a59ff3e5d7537588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz: '
|
6
|
+
metadata.gz: 1c4cada462d9cd9a59d8733b8835fb500cd7e25623c9540e6e8997ace8b2124f90592cf9e61858318114652465b70d34c116678baa0b58079b88056d41df591e
|
7
|
+
data.tar.gz: '098ca614f0d7dca73414fa5994306502afff551b2bc99097cf67bfc4d05bb7d01ab2651d0cf869b7cb8e53a493ecc94abad174ba65ab6bdb9d436678e0dffb05'
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ Jeeves is a command-line tool that creates AI-powered Git commit messages that s
|
|
11
11
|
- Generate intelligent [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) messages with [gitmoji](https://gitmoji.dev) based on your staged changes that point out what an idiot you are.
|
12
12
|
- Option to automatically stage all changes before committing.
|
13
13
|
- Option to push changes after committing.
|
14
|
+
- Automatically detects piped input and outputs just the commit message for easy scripting.
|
14
15
|
- Customizable AI prompts for tailored commit message generation.
|
15
16
|
- Choose any AI model (chat-gpt 5-mini by default).
|
16
17
|
|
@@ -151,9 +152,12 @@ Options:
|
|
151
152
|
|
152
153
|
- `-a, --all`: Stage all changes before committing
|
153
154
|
- `-p, --push`: Push changes after committing
|
155
|
+
- `-d, --dry-run`: Generate commit message without committing
|
154
156
|
- `--version`: Show version information
|
155
157
|
- `-h, --help`: Show help message
|
156
158
|
|
159
|
+
**Note**: When Jeeves detects piped input, it automatically outputs just the commit message without any formatting or logging. This makes it seamless to use in scripts and pipelines.
|
160
|
+
|
157
161
|
## Examples
|
158
162
|
|
159
163
|
```bash
|
@@ -165,6 +169,22 @@ jeeves -a
|
|
165
169
|
|
166
170
|
# Stage all changes, generate a commit message, and push
|
167
171
|
jeeves -a -p
|
172
|
+
|
173
|
+
# Automatically detects piped input and outputs just the message
|
174
|
+
git diff | jeeves
|
175
|
+
|
176
|
+
# Generate a message for specific files
|
177
|
+
git diff HEAD~1 -- src/*.rb | jeeves
|
178
|
+
|
179
|
+
# Use with other git commands
|
180
|
+
git show HEAD | jeeves
|
181
|
+
|
182
|
+
# Store commit message in a variable (bash)
|
183
|
+
MSG=$(git diff | jeeves)
|
184
|
+
echo "$MSG"
|
185
|
+
|
186
|
+
# Use in a git alias to commit with AI-generated message
|
187
|
+
git config --global alias.ai-commit '!git diff --staged | jeeves | git commit -F -'
|
168
188
|
```
|
169
189
|
|
170
190
|
## License
|
data/lib/jeeves/version.rb
CHANGED
data/lib/jeeves.rb
CHANGED
@@ -4,6 +4,7 @@ require 'uri'
|
|
4
4
|
require 'json'
|
5
5
|
require 'fileutils'
|
6
6
|
require 'tmpdir'
|
7
|
+
require 'openssl'
|
7
8
|
|
8
9
|
module Jeeves
|
9
10
|
class CLI
|
@@ -34,20 +35,40 @@ module Jeeves
|
|
34
35
|
@options[:push] = true
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
opts.on('-d', '--dry-run', 'Generate commit message without committing') do
|
39
|
+
@options[:dry_run] = true
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
opts.on('-h', '--help', 'Show this help message') do
|
43
|
+
puts opts
|
44
|
+
exit
|
45
|
+
end
|
45
46
|
end.parse!
|
46
47
|
end
|
47
48
|
|
48
49
|
def run
|
49
50
|
parse_options
|
50
51
|
|
52
|
+
# Automatically detect stdin input
|
53
|
+
has_stdin_input = !STDIN.tty? || STDIN.closed?
|
54
|
+
|
55
|
+
# Handle stdin mode when auto-detected
|
56
|
+
if has_stdin_input
|
57
|
+
# Read diff from stdin
|
58
|
+
diff = STDIN.read
|
59
|
+
|
60
|
+
if diff.empty?
|
61
|
+
puts "Error: No diff content provided via stdin."
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
|
65
|
+
# Generate commit message and output just the message
|
66
|
+
commit_message = generate_commit_message(diff, suppress_output: true)
|
67
|
+
puts commit_message
|
68
|
+
return
|
69
|
+
end
|
70
|
+
|
71
|
+
# Normal mode: work with git staged changes
|
51
72
|
if @options[:all]
|
52
73
|
system('git add -A')
|
53
74
|
end
|
@@ -128,7 +149,7 @@ module Jeeves
|
|
128
149
|
end
|
129
150
|
end
|
130
151
|
|
131
|
-
def generate_commit_message(diff)
|
152
|
+
def generate_commit_message(diff, suppress_output: false)
|
132
153
|
api_key = ENV['OPENROUTER_API_KEY']
|
133
154
|
if api_key.nil? || api_key.empty?
|
134
155
|
puts "Error: OPENROUTER_API_KEY environment variable not set"
|
@@ -136,15 +157,21 @@ module Jeeves
|
|
136
157
|
end
|
137
158
|
|
138
159
|
model = ENV['GIT_COMMIT_MODEL'] || 'x-ai/grok-code-fast-1'
|
139
|
-
puts "Using model: #{model}"
|
160
|
+
puts "Using model: #{model}" unless suppress_output
|
140
161
|
|
141
162
|
prompt_file_path = get_prompt_file_path
|
142
|
-
puts "Using prompt file: #{prompt_file_path}"
|
163
|
+
puts "Using prompt file: #{prompt_file_path}" unless suppress_output
|
143
164
|
prompt = File.read(prompt_file_path).gsub('{{DIFF}}', diff)
|
144
165
|
|
145
166
|
uri = URI.parse('https://openrouter.ai/api/v1/chat/completions')
|
146
167
|
http = Net::HTTP.new(uri.host, uri.port)
|
147
168
|
http.use_ssl = true
|
169
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
170
|
+
|
171
|
+
# Use system certificate store for SSL verification
|
172
|
+
store = OpenSSL::X509::Store.new
|
173
|
+
store.set_default_paths
|
174
|
+
http.cert_store = store
|
148
175
|
|
149
176
|
request = Net::HTTP::Post.new(uri.request_uri)
|
150
177
|
request['Content-Type'] = 'application/json'
|
@@ -193,10 +220,13 @@ module Jeeves
|
|
193
220
|
|
194
221
|
if commit_message && !commit_message.strip.empty?
|
195
222
|
commit_message = commit_message.strip
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
223
|
+
# Only show the formatted message in normal mode
|
224
|
+
unless suppress_output
|
225
|
+
puts "Generated commit message:"
|
226
|
+
puts "------------------------"
|
227
|
+
puts commit_message
|
228
|
+
puts "------------------------"
|
229
|
+
end
|
200
230
|
return commit_message
|
201
231
|
else
|
202
232
|
puts "Error: API returned empty commit message"
|