A CLI tool to automate PR creation and listing.
Project description
AutoPR: Your AI-Powered GitHub Assistant
AutoPR is a command-line tool that uses AI to help you with common GitHub tasks like managing issues, writing commit messages, creating pull requests, and even reviewing code. It's like having a smart assistant right in your terminal!
What Can AutoPR Do For You?
Here's a look at how AutoPR can make your GitHub workflow smoother and faster.
(Make sure you're in the main directory of your Git project when running these commands!)
1. See What Needs Doing: autopr ls
Want to quickly see what issues are open in your project?
- See all open issues:
autopr ls - See absolutely all issues (open and closed):
autopr ls -a # or autopr ls --all
If there's nothing matching your filters, AutoPR will let you know.
2. Grab an Issue and Get to Work: autopr workon <issue_number>
Ready to tackle an issue? autopr workon gets you set up in a flash.
Command:
autopr workon <issue_number>
# Example: autopr workon 101
Replace <issue_number> with the actual number of the GitHub issue.
What it does for you:
- Finds the Issue: Looks up the issue on GitHub to get its title.
- Creates a Smart Branch Name: Makes a new branch like
feature/101-fix-that-tricky-bugfrom the issue number and title. (It cleans up the title to make it a good branch name – all lowercase, hyphens for spaces, etc.) - Switches to Your New Branch: Runs
git checkout -b ...so you're ready to code. - Remembers What You're Working On: Saves the issue number in
.git/.autopr_current_issue. This helps other AutoPR commands know the context of your work.
Example: If issue #42 is "Fix login button display error":
autopr workon 42
AutoPR will create and switch to a branch like feature/42-fix-login-button-display-error and remember that you're working on issue 42.
3. Commit Your Awesome Changes (with AI Help!): autopr commit
You've staged your changes (git add .), and now it's time to commit. Let AutoPR help you write a great commit message!
Prerequisites:
- You have changes staged for commit.
- You need an
OPENAI_API_KEYset in your environment.export OPENAI_API_KEY='your_api_key_here'
(Tip: Add this to your.zshrcor.bashrcso you don't have to set it every time.)
Command:
autopr commit
What it does for you:
- Checks Your Staged Work: Looks at what you've staged with
git diff --staged. - Asks AI for a Commit Message: Sends this "diff" to an AI (currently GPT-3.5 Turbo) to suggest a commit message.
- Shows You the Suggestion: Prints the AI's idea to your console.
- You Decide: Asks if you want to use it (
y/n).y(yes): AutoPR runsgit commit -m "AI's clever message"for you.n(no): No problem! AutoPR will tell you to commit manually withgit commit.
Example:
After git add my_amazing_feature.py:
autopr commit
AutoPR will show you a suggested message. If you like it, hit y, and you're committed!
4. Create a Pull Request (AI-Assisted Title & Body): autopr pr
Ready to share your work? autopr pr helps you draft a Pull Request with an AI-generated title and description based on your commits and the original issue.
Prerequisites:
- You've committed your changes to your local branch.
- You have that
OPENAI_API_KEYenvironment variable set. - It helps if you started with
autopr workon <issue_number>so AutoPR can link the PR back to the issue.
Command:
autopr pr [--base <target_branch>]
# Example: autopr pr
# Example: autopr pr --base develop
--base <target_branch>: Tell AutoPR where your PR should merge into. If you don't say, it defaults tomain.
What it does for you:
- Gathers Your Commits: Looks at all the commits you've made on your current branch since you branched off from
main(or your specified--basebranch). - Remembers the Issue (if you used
workon): If you usedautopr workon, it will try to fetch the original issue's title and description from GitHub. - Asks AI for a PR Title & Body: Sends your commit messages (and issue details, if found) to an AI (GPT-3.5 Turbo) to draft a title and body for your PR.
- Shows You the Draft: Prints the AI's suggested title and body.
- You Decide: Asks if you want to create the PR on GitHub with this draft (
y/n).y(yes): AutoPR usesgh pr create ...to open the PR on GitHub, linking it to the issue if possible.n(no): No worries! AutoPR will suggest you create the PR manually.
Example:
You've made some commits on your feature/42-new-login-flow branch.
autopr pr
AutoPR will gather your work, ask the AI for a good PR title and body, show them to you, and then create the PR if you say yes!
5. Get an AI Code Review: autopr review <PR_NUMBER>
Want a second pair of (AI) eyes on a Pull Request? autopr review uses AI to analyze the changes and post suggestions directly as comments on GitHub.
Prerequisites:
- You have the
ghCLI installed and logged in (gh auth login). - Yep, you need that
OPENAI_API_KEYagain.
Command:
autopr review <PR_NUMBER>
# Example: autopr review 7
Replace <PR_NUMBER> with the number of the PR you want to review.
What it does for you:
- Fetches the PR's Changes: Uses
gh pr diff <PR_NUMBER>to get all the code changes. - AI Analyzes the Code: Sends the diff to a powerful AI (GPT-4 Turbo Preview) to look for potential improvements or issues.
- Posts Suggestions on GitHub: If the AI has suggestions, AutoPR posts them as comments directly on the relevant lines of code in the PR on GitHub.
- Tells You What Happened: Gives you a summary of how many comments it posted.
Example: To get AI feedback on Pull Request #7:
autopr review 7
AutoPR will fetch the PR, let the AI review it, and post comments on GitHub.
Getting Started: Installation
Ready to try AutoPR?
For Most Users (Install from PyPI)
The easiest way is with pip:
pip install autopr_cli
Then you can run commands like autopr ls.
For Developers (If you want to contribute or tinker)
- Get the Code:
git clone https://github.com/leaopedro/autopr.git cd autopr
- Set up a Virtual Environment (Good Practice!):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install Everything Needed:
pip install -r requirements.txt
Now you can run commands likepython -m autopr.cli ls.
For Developers: Contributing to AutoPR
If you're working on AutoPR itself:
Running Tests
Make sure everything still works:
make test
Keeping Code Tidy (Formatting)
We use Black to format our Python code:
make format
Publishing a New Version (For Maintainers)
We have a Makefile to help with releases. You'll need twine and your PyPI credentials.
- Update Version: Change
__version__inautopr/__init__.py. - Build:
make build(creates distributable files indist/) - Test on TestPyPI (Important!):
make publish-test - Publish for Real on PyPI:
make publish - Full Release (Publish & Tag):
make release(doespublishthen tags the version in Git).- Crucial: After
make release, push the tag:git push origin vX.Y.Z(orgit push --tags).
- Crucial: After
Note: For developer commands like python -m autopr.cli ..., you can create an alias in your shell (e.g., in .zshrc or .bashrc) to make them shorter, like alias dev-autopr="python -m autopr.cli".
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autopr_cli-0.2.28.tar.gz.
File metadata
- Download URL: autopr_cli-0.2.28.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24098046a370b787d874dca7961e236d3679d8591d75784849f69f7925d51879
|
|
| MD5 |
485713d5d8d1d7372342aa063f46b2e4
|
|
| BLAKE2b-256 |
1ed6ffd0928f170eb1ba48a4b97c66fb566ff841ee761da7150cae2c43c7e2c6
|
File details
Details for the file autopr_cli-0.2.28-py3-none-any.whl.
File metadata
- Download URL: autopr_cli-0.2.28-py3-none-any.whl
- Upload date:
- Size: 31.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e377657d78af3324ee4feb5ab1530d2f568c6a8add8204036f738676a7939ba5
|
|
| MD5 |
ed5d1672817874f8a23850db916a48bf
|
|
| BLAKE2b-256 |
52ba117e7ee277817be1e4f06b1d9bfa12bf3b5ff54b89087be63f38d294786a
|