Code Monkey home page Code Monkey logo

llm-pr's Introduction

LLM PR Helper

LLM PR Helper is an automated tool designed to simplify the process of creating pull requests for developers. It uses language models via the llm command-line tool to analyze the changes introduced in a Git branch and generates a concise and informative title and body for the pull request.

Table of Contents

  1. Prerequisites
  2. Functionality
  3. Usage
  4. Customization
  5. Issues and Feedback
  6. License

Prerequisites

llm

Install by running one of the commands below:

pip install llm
brew install llm
pipx install llm

After installing:

llm keys set openai
# Follow the prompts to input your OpenAI API key

GitHub CLI (gh) optional

If not installed, the script won't actually create a Pull Request, but will generate and output a title and body.

Installed using preferred method as per the official guide.

macOS

brew install gh

Debian/Ubuntu

sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y

Configuration

Authenticate using gh auth login. The GITHUB_TOKEN environment variable is also supported.

Usage

Set up ~/.config/prompts/ with pr-title-prompt.txt and pr-body-prompt.txt.

To use the script, you may need to make it executable with chmod +x and then you can run it directly from your terminal:

./pr.sh

To ensure the tool is easily accessible from any location on your system, you may create a symbolic link (symlink) to the pr.sh script in a directory that's included in your PATH. Alternatively, add the directory with the script to your PATH.

For an extra cool trick, add a git alias:

git config --global alias.pr '!pr.sh'

then your flow can be like so:

git commit -a
git push
git pr

Customization

The llm tool uses separate .txt files for PR titles and bodies, so they can be adapted to your needs.

pr-title-prompt.txt

Write a concise, informative pull request title:

* It should be a very short summary in imperative mood
* Explain the 'why' behind changes more so than the changes
* Keep the title under 50 characters
* If there are no changes, or the input is blank - then return a blank string

Think carefully before you write your title.

What you write will be passed to create the title of a github pull request

pr-body-prompt.txt

Write a clear, informative pull request message in markdown:

* Remember to mention the files that were changed, and what was changed
* Start with a summary
* Explain the 'why' behind changes
* Include a bulleted list to outline all of the changes
* If there are changes that resolve specified issues add the issues to a list of closed issues
* If there are no changes, or the input is blank - then return a blank string

Think carefully before you write your pull request body.

What you write will be passed to create a github pull request

Issues and Feedback

Report issues or provide feedback at [email protected] or via the issue tracker.

License

Released under the MIT License, see LICENSE.

llm-pr's People

Contributors

detour1999 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.