1.1.0 • Published 8 months ago

ai-reviewer v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

AI Reviewer

AI Reviewer is an intelligent tool designed to automate the review process of pull requests (PRs). It reviews the changes in each PR, generates summaries per file, adds relevant comments, suggestions, and highlights areas that need fixing. This ensures code quality and faster reviews.

Features

  • Automated Workflow Creation: Automatically creates a workflow on installation.
  • PR Review Automation: Reviews pull requests and provides detailed feedback.
  • File-based Summaries: Summarize each files in short description.
  • Comments & Suggestions: Add comments and suggestions on areas of improvement.
  • Fix Recommendations: Suggest potential fixes for code issues.
  • Improves Code Quality: Helps maintain high coding standards with automated reviews.

Installation

To install ai-reviewer and set up the workflow, use the following command:

npm install ai-reviewer --save-dev

Usage

Once installed, ai-reviewer will automatically create a workflow file in your repository.

Adding OpenAI API Key to GitHub Secrets and setting permissions for GITHUB_TOKEN

In order for AI Reviewer to leverage OpenAI's API to provide intelligent comments, suggestions, and summaries, you need to add your OpenAI API key to GitHub Secrets and allow workflow read, write permissions

Adding OpenAI API Key

  1. Obtain Your OpenAI API Key:

    • Go to OpenAI and generate your API key.
  2. Add the Key to GitHub Secrets:

    • Go to your GitHub repository.
    • Navigate to Settings > Secrets and variables > Actions > New repository secret.
    • Add a new secret with the following details:
      • Name: OPENAI_API_KEY
      • Value: Your OpenAI API key (copied from the OpenAI dashboard).
  3. Accessing the API Key in Your Workflow: In your GitHub Actions workflow, ensure that the OpenAI key is used by referencing the secret:

```yaml
jobs:
review:
    runs-on: ubuntu-latest
    steps:
    # Job Previous Steps...
        env:
        OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
```

This ensures that the AI Reviewer tool has access to your OpenAI API key to generate intelligent code reviews.

Setting Permissions for GITHUB_TOKEN

  1. Navigate to Your Repository on GitHub:

    • Go to GitHub and open your repository.
  2. Open Actions Settings:

    • Navigate to Settings > Actions > General.
    • Scroll down to the Workflow permissions section.
  3. Modify Workflow Permissions:

    • Select Read and write permissions.
    • Click the Save button to apply the changes.

Workflow Configuration

The workflow file created by ai-reviewer will be located in the .github/workflows directory. You can customize it as needed.

Here is an example of what the workflow file might look like:

name: OpenAI Code Review

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  ai-review:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '20'
      
      - name: Install dependencies
        run: npm install
      
      - name: Run AI Review and Summary
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SRC_FOLDER_PATTERN: "**/src/**/*.js, **/src/**/*.ts, **/src/**/*.html, **/src/**/*.scss"
          AI_MODEL: "gpt-4o-mini"
        run: node node_modules/ai-reviewer/src/scripts/openai/index.js

Contributing

We welcome contributions to ai-reviewer. Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feat/feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add new feature'). We use @commitlint/config-conventional so make sure following it's guidelines while committing.

  5. Push to the branch (git push origin feature-branch).

  6. Open a pull request.

License

ai-reviewer is licensed under the MIT License. See the LICENSE file for more details.

Contact

For any questions or feedback, please open an issue.

1.1.0

8 months ago

1.0.6-beta.19

8 months ago

1.0.6-beta.15

8 months ago

1.0.6-beta.16

8 months ago

1.0.6-beta.17

8 months ago

1.0.6-beta.18

8 months ago

1.0.6-beta.11

8 months ago

1.0.6-beta.9

8 months ago

1.0.6-beta.12

8 months ago

1.0.6-beta.13

8 months ago

1.0.6-beta.14

8 months ago

1.0.6-beta.10

8 months ago

1.0.6-beta.22

8 months ago

1.0.6-beta.23

8 months ago

1.0.6-beta.24

8 months ago

1.0.6-beta.20

8 months ago

1.0.6-beta.21

8 months ago

1.0.5

10 months ago

1.0.6-beta.8

10 months ago

1.0.6-beta.5

10 months ago

1.0.6-beta.4

10 months ago

1.0.6-beta.7

10 months ago

1.0.6-beta.6

10 months ago

1.0.6-beta.1

10 months ago

1.0.6-beta.3

10 months ago

1.0.6-beta.2

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago