prreview 0.1.0 → 0.3.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/.rspec +3 -0
- data/.ruby-version +1 -1
- data/README.md +32 -3
- data/lib/prreview/version.rb +1 -1
- data/lib/prreview.rb +38 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af7fe1f1ccb8ef35c2eeec1252123861705106dc5439725923915ee20aa21fc6
|
4
|
+
data.tar.gz: 97c37aa978ee7df44aff01eaa890acc5bb2a60eacd17fceb7ad5cc4319f8aa1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 197d7fa53eda6c389cc68ff8eb97cb792e1704e4c808a74746bda25274194498a19b90cfbcd5b1dea89b5a7d7b16190790da198fba5571830ef902c0636e5b71
|
7
|
+
data.tar.gz: 680a13f38effb95f562898efd5b13baad3e6c16334ac2e37f783f4e8dec1ab4b86a3ada77a42b4cbe47c876340a946dd2c379361a36028ef5f2ac52d0bb28e7b
|
data/.rspec
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.4.
|
1
|
+
3.4.3
|
data/README.md
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
## How to use
|
2
2
|
|
3
|
+
Install:
|
4
|
+
|
5
|
+
```sh
|
6
|
+
gem install prreview
|
7
|
+
```
|
8
|
+
|
3
9
|
Run this command with a PR URL:
|
4
10
|
|
5
11
|
```sh
|
6
|
-
|
7
|
-
|
8
|
-
|
12
|
+
prreview -u https://github.com/owner/repo/pull/123
|
13
|
+
```
|
14
|
+
|
15
|
+
Or use more options:
|
16
|
+
|
17
|
+
```
|
18
|
+
prreview --help
|
19
|
+
prreview --url https://github.com/owner/repo/pull/123 --all-content --prompt "Are there any security issues?"
|
9
20
|
```
|
10
21
|
|
11
22
|
Now, just paste the PR details into ChatGPT, Claude, or any LLM for review.
|
@@ -21,6 +32,24 @@ PrReview collects key details about a PR, including:
|
|
21
32
|
|
22
33
|
It then copies everything to your clipboard.
|
23
34
|
|
35
|
+
## Why prompt
|
36
|
+
|
37
|
+
Advantages over LLM integrations:
|
38
|
+
|
39
|
+
- You're free to use the LLM of your choice
|
40
|
+
- You can continue the conversation with the LLM right in the chat, asking to pay attention to a specific part of the PR
|
41
|
+
- The gem is simpler
|
42
|
+
|
43
|
+
However, in the future we might add some optional integrations.
|
44
|
+
|
45
|
+
## Tips
|
46
|
+
|
47
|
+
- A well-written PR and linked issue description make a big difference — and are good practice anyway.
|
48
|
+
- Run `prreview` after you've thoroughly reviewed the PR. It works best when you understand the changes well.
|
49
|
+
- Don't hesitate to try different LLMs or refresh the response to see if something new comes up.
|
50
|
+
- Use `--all-content` and other extra options — they can significantly improve results for some PRs.
|
51
|
+
- After the LLM responds, ask "Anything else?" to potentially uncover more issues.
|
52
|
+
|
24
53
|
## Requirements
|
25
54
|
|
26
55
|
- Ruby
|
data/lib/prreview/version.rb
CHANGED
data/lib/prreview.rb
CHANGED
@@ -38,6 +38,7 @@ module Prreview
|
|
38
38
|
def process
|
39
39
|
fetch_pull_request
|
40
40
|
fetch_issues
|
41
|
+
load_optional_files
|
41
42
|
build_xml
|
42
43
|
copy_result_to_clipboard
|
43
44
|
end
|
@@ -48,6 +49,7 @@ module Prreview
|
|
48
49
|
@prompt = DEFAULT_PROMPT
|
49
50
|
@include_content = false
|
50
51
|
@issues_limit = DEFAULT_ISSUES_LIMIT
|
52
|
+
@optional_files = []
|
51
53
|
|
52
54
|
parser = OptionParser.new do |opts|
|
53
55
|
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} -u URL [options]"
|
@@ -56,6 +58,9 @@ module Prreview
|
|
56
58
|
opts.on('-p', '--prompt PROMPT', 'Custom LLM prompt') { |v| @prompt = v }
|
57
59
|
opts.on('-a', '--all-content', 'Include full file contents') { @include_content = true }
|
58
60
|
opts.on('-l', '--limit LIMIT', Integer, "Limit number of issues fetched (default: #{DEFAULT_ISSUES_LIMIT})") { |v| @issues_limit = v }
|
61
|
+
opts.on('-o', '--optional PATHS', 'Comma‑separated paths to local files (relative or absolute, e.g. docs/description.md,/etc/hosts)') do |v|
|
62
|
+
@optional_files = v.split(',').map(&:strip)
|
63
|
+
end
|
59
64
|
opts.on('-h', '--help', 'Show help') do
|
60
65
|
puts opts
|
61
66
|
exit
|
@@ -105,7 +110,8 @@ module Prreview
|
|
105
110
|
puts "Fetching file content for #{path}"
|
106
111
|
|
107
112
|
content = @client.contents(@full_repo, path:, ref: @pull_request.head.sha)
|
108
|
-
Base64.decode64(content[:content])
|
113
|
+
decoded = Base64.decode64(content[:content])
|
114
|
+
binary?(decoded) ? '(binary file)' : decoded
|
109
115
|
rescue Octokit::NotFound
|
110
116
|
'(file content not found)'
|
111
117
|
end
|
@@ -137,6 +143,21 @@ module Prreview
|
|
137
143
|
puts "Fetched #{@issues.length} issues (limit: #{@issues_limit})"
|
138
144
|
end
|
139
145
|
|
146
|
+
def load_optional_files
|
147
|
+
@optional_file_contents = @optional_files.filter_map do |path|
|
148
|
+
if File.exist?(path)
|
149
|
+
content = File.read(path)
|
150
|
+
{ filename: path, content: content }
|
151
|
+
else
|
152
|
+
warn "File #{path} not found, skipping"
|
153
|
+
nil
|
154
|
+
end
|
155
|
+
rescue StandardError => e
|
156
|
+
warn "Error reading file #{path}: #{e.message}"
|
157
|
+
nil
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
140
161
|
def extract_refs(text, pattern)
|
141
162
|
text.to_enum(:scan, pattern).filter_map do
|
142
163
|
m = Regexp.last_match
|
@@ -174,6 +195,7 @@ module Prreview
|
|
174
195
|
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |x|
|
175
196
|
x.prompt do
|
176
197
|
x.task @prompt
|
198
|
+
x.current_date DateTime.now
|
177
199
|
|
178
200
|
x.pull_request do
|
179
201
|
x.number @pr_number
|
@@ -203,6 +225,17 @@ module Prreview
|
|
203
225
|
end
|
204
226
|
end
|
205
227
|
|
228
|
+
unless @optional_file_contents.empty?
|
229
|
+
x.local_context_files do
|
230
|
+
@optional_file_contents.each do |file|
|
231
|
+
x.file do
|
232
|
+
x.filename file[:filename]
|
233
|
+
x.content file[:content]
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
206
239
|
x.task @prompt
|
207
240
|
end
|
208
241
|
end
|
@@ -210,6 +243,10 @@ module Prreview
|
|
210
243
|
@xml = builder.doc.root.to_xml
|
211
244
|
end
|
212
245
|
|
246
|
+
def binary?(string)
|
247
|
+
string.include?("\x00")
|
248
|
+
end
|
249
|
+
|
213
250
|
def copy_result_to_clipboard
|
214
251
|
Clipboard.copy(@xml)
|
215
252
|
puts 'XML prompt generated and copied to clipboard.'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prreview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgenii Morozov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
- Quint
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: base64
|
@@ -93,6 +93,7 @@ executables:
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
+
- ".rspec"
|
96
97
|
- ".rubocop.yml"
|
97
98
|
- ".ruby-version"
|
98
99
|
- LICENSE
|
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
122
|
- !ruby/object:Gem::Version
|
122
123
|
version: '0'
|
123
124
|
requirements: []
|
124
|
-
rubygems_version: 3.6.
|
125
|
+
rubygems_version: 3.6.7
|
125
126
|
specification_version: 4
|
126
127
|
summary: A CLI tool that formats GitHub PRs for LLM code reviews.
|
127
128
|
test_files: []
|