jeeves-git-commit 2.4.2 → 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 +21 -1
- data/lib/jeeves/version.rb +1 -1
- data/lib/jeeves.rb +57 -12
- 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
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
<img src="assets/jeeves.png" alt="Jeeves Logo" width="200">
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
Jeeves is a command-line tool that creates AI-powered Git commit messages that
|
|
7
|
+
Jeeves is a command-line tool that creates AI-powered Git commit messages that savagely roasts you and your code.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
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
|
|
@@ -13,7 +14,8 @@ module Jeeves
|
|
|
13
14
|
def initialize
|
|
14
15
|
@options = {
|
|
15
16
|
all: false,
|
|
16
|
-
push: false
|
|
17
|
+
push: false,
|
|
18
|
+
dry_run: false
|
|
17
19
|
}
|
|
18
20
|
setup_config_dir
|
|
19
21
|
end
|
|
@@ -33,16 +35,40 @@ module Jeeves
|
|
|
33
35
|
@options[:push] = true
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
opts.on('-d', '--dry-run', 'Generate commit message without committing') do
|
|
39
|
+
@options[:dry_run] = true
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
opts.on('-h', '--help', 'Show this help message') do
|
|
43
|
+
puts opts
|
|
44
|
+
exit
|
|
45
|
+
end
|
|
40
46
|
end.parse!
|
|
41
47
|
end
|
|
42
48
|
|
|
43
49
|
def run
|
|
44
50
|
parse_options
|
|
45
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
|
|
46
72
|
if @options[:all]
|
|
47
73
|
system('git add -A')
|
|
48
74
|
end
|
|
@@ -58,6 +84,16 @@ module Jeeves
|
|
|
58
84
|
# Get AI-generated commit message
|
|
59
85
|
commit_message = generate_commit_message(diff)
|
|
60
86
|
|
|
87
|
+
# If dry-run mode, just output the message and exit
|
|
88
|
+
if @options[:dry_run]
|
|
89
|
+
puts "\nDry-run mode: Commit message would be:"
|
|
90
|
+
puts "============================================"
|
|
91
|
+
puts commit_message
|
|
92
|
+
puts "============================================"
|
|
93
|
+
puts "No commit was created (dry-run mode)"
|
|
94
|
+
return
|
|
95
|
+
end
|
|
96
|
+
|
|
61
97
|
# Write commit message to temp file for git to use
|
|
62
98
|
temp_file = File.join(Dir.tmpdir, 'jeeves_commit_message')
|
|
63
99
|
File.write(temp_file, commit_message)
|
|
@@ -113,7 +149,7 @@ module Jeeves
|
|
|
113
149
|
end
|
|
114
150
|
end
|
|
115
151
|
|
|
116
|
-
def generate_commit_message(diff)
|
|
152
|
+
def generate_commit_message(diff, suppress_output: false)
|
|
117
153
|
api_key = ENV['OPENROUTER_API_KEY']
|
|
118
154
|
if api_key.nil? || api_key.empty?
|
|
119
155
|
puts "Error: OPENROUTER_API_KEY environment variable not set"
|
|
@@ -121,15 +157,21 @@ module Jeeves
|
|
|
121
157
|
end
|
|
122
158
|
|
|
123
159
|
model = ENV['GIT_COMMIT_MODEL'] || 'x-ai/grok-code-fast-1'
|
|
124
|
-
puts "Using model: #{model}"
|
|
160
|
+
puts "Using model: #{model}" unless suppress_output
|
|
125
161
|
|
|
126
162
|
prompt_file_path = get_prompt_file_path
|
|
127
|
-
puts "Using prompt file: #{prompt_file_path}"
|
|
163
|
+
puts "Using prompt file: #{prompt_file_path}" unless suppress_output
|
|
128
164
|
prompt = File.read(prompt_file_path).gsub('{{DIFF}}', diff)
|
|
129
165
|
|
|
130
166
|
uri = URI.parse('https://openrouter.ai/api/v1/chat/completions')
|
|
131
167
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
132
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
|
|
133
175
|
|
|
134
176
|
request = Net::HTTP::Post.new(uri.request_uri)
|
|
135
177
|
request['Content-Type'] = 'application/json'
|
|
@@ -178,10 +220,13 @@ module Jeeves
|
|
|
178
220
|
|
|
179
221
|
if commit_message && !commit_message.strip.empty?
|
|
180
222
|
commit_message = commit_message.strip
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
|
185
230
|
return commit_message
|
|
186
231
|
else
|
|
187
232
|
puts "Error: API returned empty commit message"
|