diff --git a/Gemfile.lock b/Gemfile.lock index 1f44785..6c5aaa4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - prreview (0.7.0) + prreview (0.8.0) base64 (~> 0.2) clipboard (~> 2.0) faraday-retry (~> 2.3) @@ -113,6 +113,7 @@ GEM PLATFORMS arm64-darwin-24 + arm64-darwin-25 x86_64-darwin-24 DEPENDENCIES diff --git a/README.md b/README.md index 3c23b58..4293ddd 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Or use more options: ``` prreview --help prreview https://github.com/owner/repo/pull/123 --all-content --prompt "Are there any security issues?" +prreview https://github.com/owner/repo/pull/123 --request-context ``` Now, just paste the PR details into ChatGPT, Claude, or any LLM for review. @@ -49,6 +50,7 @@ However, in the future we might add some optional integrations. - A well-written PR and linked issue description make a big difference — and are good practice anyway. - Run `prreview` after you've thoroughly reviewed the PR. It works best when you understand the changes well. - Don't hesitate to try different LLMs or refresh the response to see if something new comes up. +- Use `--request-context` when you want the LLM to ask for missing files or documentation before reviewing. - Use `--all-content` and other extra options — they can significantly improve results for some PRs. - After the LLM responds, to potentially uncover more issues: - Ask "Anything else?". diff --git a/lib/prreview.rb b/lib/prreview.rb index bbbc481..7ac24f9 100644 --- a/lib/prreview.rb +++ b/lib/prreview.rb @@ -10,13 +10,7 @@ module Prreview class CLI - DEFAULT_PROMPT = <<~PROMPT - Your task is to review this pull request. - Patch lines starting with `-` are deleted. - Patch lines starting with `+` are added. - Focus on new problems, not ones that were already there. - Do you see any problems? - PROMPT + PROMPTS_DIR = File.expand_path('../prompts', __dir__) DEFAULT_LINKED_ISSUES_LIMIT = 5 @@ -59,7 +53,7 @@ def process private def parse_options! - @prompt = DEFAULT_PROMPT + @prompt = load_prompt(:default) @include_content = false @linked_issues_limit = DEFAULT_LINKED_ISSUES_LIMIT @optional_files = [] @@ -80,6 +74,9 @@ def parse_options! parser.on('-o', '--optional PATHS', 'Comma‑separated paths to local files (relative or absolute, e.g. docs/description.md,/etc/hosts)') do |v| @optional_files = v.split(',').map(&:strip) end + parser.on('-c', '--request-context', 'Ask the LLM what extra context it needs before reviewing') do + @prompt = load_prompt(:request_context) + end parser.on_tail('-v', '--version', 'Show version') do puts VERSION exit @@ -334,5 +331,9 @@ def copy_result_to_clipboard Clipboard.copy(@xml) puts 'XML prompt generated and copied to your clipboard.' end + + def load_prompt(name) + File.read(File.join(PROMPTS_DIR, "#{name}.md")) + end end end diff --git a/lib/prreview/version.rb b/lib/prreview/version.rb index 498202d..aa6854d 100644 --- a/lib/prreview/version.rb +++ b/lib/prreview/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Prreview - VERSION = '0.7.0' + VERSION = '0.8.0' end diff --git a/prompts/default.md b/prompts/default.md new file mode 100644 index 0000000..e161bc6 --- /dev/null +++ b/prompts/default.md @@ -0,0 +1,5 @@ +Your task is to review this pull request. +Patch lines starting with `-` are deleted. +Patch lines starting with `+` are added. +Focus on new problems, not ones that were already there. +Do you see any problems? diff --git a/prompts/request_context.md b/prompts/request_context.md new file mode 100644 index 0000000..23f77a2 --- /dev/null +++ b/prompts/request_context.md @@ -0,0 +1,7 @@ +Your task is to review this pull request. +Patch lines starting with `-` are deleted. +Patch lines starting with `+` are added. +Focus on new problems, not ones that were already there. +Identify which extra context would improve your review (files, documentation, decisions, etc). +Ask for specific, grouped items or clarifications. +If nothing else is needed, say you can proceed. diff --git a/spec/prreview_spec.rb b/spec/prreview_spec.rb index 00d730f..a36dc16 100644 --- a/spec/prreview_spec.rb +++ b/spec/prreview_spec.rb @@ -32,4 +32,23 @@ expect(abort_message).to eq('Error: GITHUB_TOKEN is not set.') end end + + describe 'when --request-context is used' do + around do |example| + original_argv = ARGV.dup + ARGV.replace(%w[https://github.com/owner/repo/pull/123 --request-context]) + + example.run + + ARGV.replace(original_argv) + end + + it 'loads the request context prompt' do + cli = described_class.allocate + cli.send(:parse_options!) + + prompt = cli.instance_variable_get(:@prompt) + expect(prompt).to eq(cli.send(:load_prompt, :request_context)) + end + end end