ai-reviewer
v1.0.6-beta.8
Published
This package reviews the changes in each PR, generates summaries per file, adds relevant comments, suggestions, and highlights areas that need fixing.
Downloads
30
Maintainers
Readme
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
Obtain Your OpenAI API Key:
- Go to OpenAI and generate your API key.
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).
- Name:
Accessing the API Key in Your Workflow: In your GitHub Actions workflow, ensure that the OpenAI key is used by referencing the secret:
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
Navigate to Your Repository on GitHub:
- Go to GitHub and open your repository.
Open Actions Settings:
- Navigate to
Settings
>Actions
>General
. - Scroll down to the
Workflow permissions
section.
- Navigate to
Modify Workflow Permissions:
- Select
Read and write permissions
. - Click the
Save
button to apply the changes.
- Select
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:
Fork the repository.
Create a new branch (
git checkout -b feat/feature-branch
).Make your changes.
Commit your changes (
git commit -m 'Add new feature'
). We use @commitlint/config-conventional so make sure following it's guidelines while committing.Push to the branch (
git push origin feature-branch
).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.