prwizard is a powerful and user-friendly tool for automating code review and streamlining the pull request process. It is designed to enhance collaboration and efficiency in software development workflows.
- Automated Code Review: prwizard automatically reviews code changes, identifies potential issues, and provides detailed feedback to ensure code quality.
- Pull Request Diff Review: Effortlessly review pull request diffs with clear and concise feedback, enhancing the review process.
- Smart Commit Message Generation: Generate precise and meaningful commit messages for code changes based on Git diffs and commit history.
- Make sure you have Node.js and npm installed on your machine.
- You'll also need OpenAI API key and GitHub access token to use this tool.
Note: OpenAI charges for its API. Make sure you have active credits on your OpenAI account (or have a premium account). If you want free credits worth $5, create a new OpenAI account with a different phone number.
prwizard is set to use the GPT-3.5-turbo model by default. If you wish to switch to GPT-4, you can do so by modifying your prwizard.json
config file:
- Run the config command if you haven't done so already. This will generate the
prwizard.json
config file:
prwizard config
- Locate your
prwizard.json
config file. By default, it is saved in the.prwizard
directory in your home directory (~/.prwizard
). - Find the
llm
section and then theopenai
subsection within it. - Change the value of
openaiModel
fromgpt-3.5-turbo
togpt-4
. - Save and close your
prwizard.json
config file.
Remember that using GPT-4 may result in increased API costs. Please refer to OpenAI's pricing for more information.
You can install prwizard globally using npm by running the following command:
npm i -g prwizard
Before using prwizard, you need to set up the configuration with your OpenAI API key and GitHub token. You can do this with the following command:
prwizard config
This will prompt you to enter your OpenAI API key and GitHub token.
For a comprehensive list of all available commands and options in prwizard, run the help command:
prwizard -h
This will display a list of all the available commands, their descriptions, and options you can use with prwizard.
prwizard can also be configured using environment variables. If an environment variable is not provided, prwizard will use the default value.
Here are the available environment variables:
GIT_MAX_COMMIT_HISTORY
: Maximum number of commit history entries to fetch (default: 10).GIT_IGNORE_PATTERNS
: A comma-separated list of regular expression patterns of files to ignore (default: []).GITHUB_API_URL
: Custom URL for the GitHub API (default: https://api.github.com).GITHUB_TOKEN
: GitHub personal access token.OPENAI_API_URL
: Custom URL for the OpenAI API (default: https://api.openai.com).OPENAI_API_KEY
: OpenAI API key for accessing the OpenAI API.OPENAI_MODEL
: OpenAI model to use (default: gpt-3.5-turbo).OPENAI_TEMPERATURE
: Temperature parameter for OpenAI model (default: 0).
prwizard can analyze local changes in two ways:
If you want to analyze your local changes, navigate to the root directory of your local Git repository and run the following command:
prwizard review
prwizard will then analyze your local changes and provide a review.
If you want to analyze a specific file in your local directory, navigate to the root directory of your local Git repository and run the following command:
prwizard review --directory <directory> --filename <filename>
Replace <directory>
with the relative path of the directory to search and <filename>
with the name of the file to review.
prwizard can propose commit messages based on local diffs and commit history. To use this feature, run the following command:
prwizard commit
prwizard will prompt you to select the files you wish to commit. Once the files are selected, prwizard fetches the commit history and proposes a commit message. If you agree with the suggested commit message, you can proceed to commit your changes right away. If there are unselected files left, prwizard will ask you if you wish to continue the commit process.
If you want to analyze a pull request, run the following command:
prwizard pr <repository> <pull_request_number>
Replace <repository>
with the repository to review in the format owner/repository
, and <pull_request_number>
with the number of the pull request to review. For example:
prwizard pr necro-01/prwizard 18
prwizard will then fetch the pull request details, analyze the changes, and provide you with a review.
This command will only work if your git repository has at least one active pull request. You might get unwanted errors if no active PRs are found.
prwizard tool allows you to ignore certain files during your review process by using regular expression patterns. You can define these patterns either through a configuration file or via an environment variable. The CLI tool will ignore files that match any of the provided patterns.
You can define an array of ignorePatterns
under the git
section in your prwizard.json
configuration file, like so:
{
"git": {
"ignorePatterns": [".*lock.*", "another_pattern", "..."]
}
}
Alternatively, you can use the GIT_IGNORE_PATTERNS
environment variable to define a comma-separated list of regular expression patterns:
export GIT_IGNORE_PATTERNS=.*lock.*,another_pattern,...