npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gpt-diff

v1.0.10

Published

GPT your Git diff

Downloads

5

Readme

GPT Diff

GPT your git diff and get a detailed list of all changes in your current branch's diff.

To use, you need:

  1. an OpenAI API key. See: https://beta.openai.com/account/api-keys
  2. set the environment variable OPENAI_API_KEY to your API key
  3. Then, run gpt-diff in your git repo.

GPT Diff will split up large diffs into smaller chunks and send them to the OpenAI API. It will then combine the results and print them to your terminal as well as your clipboard ready to paste.

To skip the confirmation prompt, use the y flag, gpt-diff y, otherwise you will be ask to confirm the operation, and shown how many requests it will take to complete it.

ATM, rate-limiting is not implemented, but at 40 requests / minute, you mostly should not be affected by it. Try smaller diffs if you are or I'd be happy to merge any contribution be it this or other cool stuff I'd like such as:

[ ] being able to pass in custom API options as args

[ ] pre-fixing or replacing the default prompt

[ ] splitting the results by file or directory

[x] custom diffing (right now it only does git diff)

Usages

# Run it with defaults, requires confirmation, diffs against HEAD
gpt-diff

# Run it with y flag, skips confirmation, diffs against HEAD
gpt-diff y

# Run it with y flag and a custom diff, skips confirmation and diff against custom diff 
gpt-diff y HEAD~1

# Omit the y flag and use a custom diff, requires confirmation and diff against custom diff
gpt-diff HEAD~1

Example output:

$: gpt-diff

This gdsum will require 1 requests. Continue? [y/n] (selecting n will exit) y

Processing chunk 1 with a length of 3000 and max tokens at 2500
Processing chunk 1 with a length of 3000 and max tokens at 2500
Processing chunk 1 with a length of 3000 and max tokens at 2500
Processing chunk 1 with a length of 3000 and max tokens at 2500
Processing chunk 1 with a length of 548 and max tokens at 3726

🌮 index.js:
• Added code to handle if the first argument is an empty string 
• Added code to use the function splitText to split the git diff output into chunks of 3000 characters 
• Added code to warn the user and confirm before continuing 
• Added code to handle each chunk and print the number of requests processed 
• Added code to read the environment variable for the OpenAI API key 
• Added code to check for the .git directory 
🌮 .gitignore:
• Added .DS_Store and .env to .gitignore 
🌮 index.js
• Added try block with prompt and response code 
• Added parameters for openai with temperature, max_tokens, top_p, frequency_penalty and presence_penalty 
• Added the resolve with response text 
• Added the Promise.all and closing of the rl 
🌮 package-lock.json
• Added various dependencies including asynckit, axios, child_process, follow-redirects 
🌮index.js:
• Added new object to node_modules with dependencies, engines and version information
• Added node_modules/follow-redirects with funding, engines and peerDependenciesMeta information 
• Added node_modules/form-data with dependencies, engines and version information
• Added node_modules/mime-db with engines and version information
• Added node_modules/mime-types with dependencies, engines and version information
• Added node_modules/openai with dependencies and version information
• Added "asynckit" to the "dependencies" section Request failed with status code 400 
📦 package.json:
• Added name, version, description, main, scripts, bin, keywords, author, email, license, dependencies, and child_process. 
• Updated dependencies to include openai.

Miscellaneous

  1. Consider adding this to your .bashrc or .zshrc:
# GPT Diff
alias gptd="gpt-diff"
# or...
alias gptd="gpt-diff y"

Known issues

[ ] the copy to clipboard operation doesn't consistently work yet

[ ] a rough calculation of required tokens is used to set a max_tokens option on the API call, based on the length of the diff chunk. This is not always accurate and can result in a 400 error. A more reliable method is needed.