0.4.0 • Published 10 months ago

revu-cli v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

revu is a comprehensive command-line tool designed to streamline the code review process. Leveraging the advanced capabilities of GPT-4 and the GitHub API, it can analyze and provide insightful reviews on pull requests, local changes, and individual files. Additionally, revu offers an intuitive commit message generator that uses local diffs and commit history to propose appropriate commit messages. Its flexible nature aims to cover various aspects of code review, offering an efficient toolset for developers.

⚠️ Disclaimer: This is a test project. The reviews generated by this tool may not always be accurate, useful, or make sense. Always perform manual code reviews to ensure the quality of your code.

Getting Started

Prerequisites

  • You'll need to have Node.js and npm installed on your machine.
  • An OpenAI API key for using GPT-4 and a GitHub token for accessing the GitHub API.

Switching to GPT-4 Model

revu is initially set to use the GPT-3.5-turbo model. If you wish to switch to GPT-4, you can do so by modifying your revu.json config file:

  1. Run the config command if you haven't done so already. This will generate the revu.json config file:
revu config
  1. Locate your revu.json config file. By default, it is saved in the .revu directory in your home directory (~/.revu).
  2. Find the llm section and then the openai subsection within it.
  3. Change the value of openaiModel from gpt-3.5-turbo to gpt-4.
  4. Save and close your revu.json config file.

Remember that using GPT-4 may result in increased API costs. Please refer to OpenAI's pricing for more information.

Installation

You can install revu globally using npm by running the following command:

npm i -g revu-cli

Alternatively, you can clone the repository and install the dependencies locally:

  1. Clone the repository:
git clone https://github.com/phmz/revu-cli.git
  1. Navigate to the project directory:
cd revu-cli
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Usage

Before using revu, you need to set up the configuration with your OpenAI API key and GitHub token. You can do this with the following command:

revu 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 revu, run the help command:

revu help

This will display a list of all the available commands, their descriptions, and options you can use with revu.

Environment Variables

revu can also be configured using environment variables. If an environment variable is not provided, revu 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).

Local Code Review

revu can analyze local changes in two ways:

1. Analyzing all local changes

If you want to analyze your local changes, navigate to the root directory of your local Git repository and run the following command:

revu local

revu will then analyze your local changes and provide you with a review.

2. Analyzing a specific file

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:

revu local --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.

Generate Commit Message

revu can propose commit messages based on local diffs and commit history. To use this feature, run the following command:

revu commit

revu will prompt you to select the files you wish to commit. Once the files are selected, revu 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, revu will ask you if you wish to continue the commit process.

Pull Request Review

If you want to analyze a pull request, run the following command:

revu 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:

revu pr phmz/revu 42

revu will then fetch the pull request details, analyze the changes, and provide you with a review.

Ignoring Files

The revu CLI 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.

Via Configuration File

You can define an array of ignorePatterns under the git section in your revu.json configuration file, like so:

{
  "git": {
    "ignorePatterns": [".*lock.*", "another_pattern", "..."]
  }
}

Via Environment Variable

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,...

Development

revu is built with TypeScript. Contributions are welcome!

Code style

This project uses ESLint for linting.

You can run the linter with:

npm run lint
0.4.0

10 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.0

11 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.1

12 months ago

0.0.0

12 months ago