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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -0
  3. data/lib/jeeves/version.rb +1 -1
  4. data/lib/jeeves.rb +44 -14
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61da8e275a8df7260004e3b246fb4f4d33f23cc59412fe112a674929c10a4411
4
- data.tar.gz: 22c702ed46e03b77068693e3d0418aca2361736e54b1571e8a44ecb1d6371149
3
+ metadata.gz: e0f5b4a1b2b1914123903412e01e1a556118becda1aba4c21d84efa22098813f
4
+ data.tar.gz: 26fb16c5acd764ba74acb5801c4770f4613baff447dd16e1a59ff3e5d7537588
5
5
  SHA512:
6
- metadata.gz: e160482997643783ec6ecf7402f4d005ece27b989b09ca1674cf9c45af111cb997a2b47dea42da736158d6ef048c5ed194924dfc2f981d26ec26710ff8711030
7
- data.tar.gz: '079e247723887f5677eafbe455d87a600362fcefe69adc9f40410b77b8b7b411bc11815b3439429ee837978d70e207a8ed12e04b230a7b9d74771820ab6adf69'
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
@@ -1,3 +1,3 @@
1
1
  module Jeeves
2
- VERSION = '2.5.0'
2
+ VERSION = '2.6.0'
3
3
  end
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
- opts.on('-d', '--dry-run', 'Generate commit message without committing') do
38
- @options[:dry_run] = true
39
- end
38
+ opts.on('-d', '--dry-run', 'Generate commit message without committing') do
39
+ @options[:dry_run] = true
40
+ end
40
41
 
41
- opts.on('-h', '--help', 'Show this help message') do
42
- puts opts
43
- exit
44
- end
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
- puts "Generated commit message:"
197
- puts "------------------------"
198
- puts commit_message
199
- puts "------------------------"
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeeves-git-commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Bishop