This script automates pull request (PR) review using a large language model.
It is a command line tool. It is intended to be used locally to validate a PR before pushing and having colleagues review your work. The goal is to catch mistakes early and avoid back-and-forth on PR reviews.
Depending on the context provided, it can catch:
bun --version in your terminal, and follow further directions as neededgit clone https://gitfront.io/r/robertpkoenig/yQGcR37JshKE/pr-check.gitpr-checkpr-check directorybun install.env in the root directory of the projectsample-env.mdprompt/sample/samp/e.baseContext.md file into a new file prompt/context/baseContext.mdprompt/sample/sample.finalInstruction.md file into a new file prompt/instruction/finalInstruction.mdzsh shell, you'd add the following line to your zshrc config file:alias pr-check="bun /path/to/pr-check/src/index.tssource ~./zshrc in terminal for the shortcut to be availablebun /path/to/pr-check/src/index.tsWhen sending a PR for review by the AI, a 'prompt' is generated. This prompt is essentially a text message sent to the AI, including the context of your PR (such as files changed and lines altered) and a final instruction. You can modify both the context and the final instruction as needed.
The context can include rules the AI should follow, things to look out for, or domain knowledge. You could even include, for instance, a database schema that would enable the AI to validate SQL that you have written within your PR.
You can add as many context files as you want. When you run the script, you will be able to select which context files to include in the current review. You will select the context files you wish to consider by checking them in a checkbox.
In addition to custom context files, each prompt includes a final instruction to keep the AI focused, especially in cases of long context descriptions.
If you want to change the code, this code map will help you get oriented.
├── prompt
│ ├── context // Files referenced by the AI when reviewing your PR
│ ├── instruction // Instruction to the AI defining the goal, output format, etc.
│ └── sample // Sample context and instruction files for you to copy and edit
├── src
│ ├── commandline // Helper function for interacting with command line from Bun
│ ├── filesystem // Helper functions for reading context/instruction files
│ ├── git // Helper functions for interacting with git (ie. getting commits)
│ ├── interfaces // Data models used within the application
│ ├── openai // Simple wrapper for OpenAI API
│ ├── parsers // Helper functions for parsing / generating text
│ ├── userinput // Helper functions for the terminal user interface
│ └── validation // Function to prevent users running the script in an invalid state
└── index.ts // The entry point for the application