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

huskygpt

v0.5.2

Published

Automatically generate unit tests or review your code using openai chatgpt

Downloads

17

Readme

huskygpt

Node.js CLI tools for auto review your code or auto generate unit tests by OpenAI chatgpt3.5 and GPT-4 Plus Account! ✅

NPM Prettier Code Formatting

Demo

  • 🤖 Generate unit tests by gpt-4 model: huskygpt-unit-test
  • ✨ The unit test result: format-test
  • 🌍 Translate source file keep the same format and structure: translate
  • 🖊️ Modify exist code by your input requirements e.g. modify

    Please fix bugs or optimize my code. if the function is complexity, please chunk it. If it's function component, use hooks optimize it. And add en and zh comments for complexity logic steps e.g. // EN: some comments, // ZH: 一些评论.

Key Features

  • 🤖 AI: AI-powered code review, modify, translate and unit test generation
  • Free: Free to use with an OpenAI Session Token, enjoy chatgpt-3.5 or gpt-4 (Plus Account).
  • 🛡️ Security: Security-conscious function and class extraction, customize your SECURITY_REGEX.
  • 🧠 Customizing: Customizable prompts and model selection.
  • 📂 File Reader: Supports reading files from directories or git staged files.

Installation

To install huskygpt, run the following command:

npm install -g huskygpt

Configuration

OpenAI Key (Choose one)

  • Set the OpenAI API Key by npm config set -g
    npm config set OPENAI_API_KEY <YOUR_OPENAI_KEY> -g
  • Set the OpenAI Session Token for free using chatgpt
    • OpenAI session token, 2 setp to get token
    • If you don't set this, will use OPENAI_API_KEY
    1. visit https://chat.openai.com/chat and login
    2. Visit https://chat.openai.com/api/auth/session to get token
    npm config set OPENAI_SESSION_TOKEN <YOUR_OPENAI_SESSION_TOKEN> -g
    1. Copy .env file to your project root directory, and set OPENAI_PROXY_URL.

| Method | Free? | Robust? | Quality? | | --------------------------- | ------ | -------- | ----------------------- | | OpenAI Session Token | ✅ Yes | ☑️ Maybe | ✅️ Real ChatGPT | | OpenAI API Key | ❌ No | ✅ Yes | ✅ Real ChatGPT models |

Local prompt

  1. Create prompt directory in the root directory of your project.
  2. Add review.txt or tests.txt in the prompt directory.

Pre-Commit

  1. husky and lint-stage
    "husky": {
      "hooks": {
        "pre-commit": "huskygpt review && huskygpt test && lint-staged --allow-empty"
      }
    },

.gitignore:

# review
.huskygpt_review.md
.env.local

Usage

  • Run the following command to review your git staged files:
    huskygpt review --model gpt-4 --max-tokens 2048
  • Run the following command to modify your exist code:
    huskygpt modify -r dir -d src/pages/UserRegister/RegisterList.tsx -m gpt-4
  • Run the following command to generate unit test:
    huskygpt test --model gpt-3.5-turbo --max-tokens 2048 --file-extensions .ts,.tsx --read-type dir --read-dir-name src --test-file-type test --test-file-extension .ts --test-file-dir-name tests
  • Run the following command to translate your git staged files:
    huskygpt translate -d example/i18n/test.json

Options

  • -k, --api-key <key>: Set the OpenAI API key.
  • -t, --openai-session-token <token>: OpenAI session token, 2 step to get token, If you don't set this, will use OPENAI_API_KEY, will cause fee by api key.
  • -pu, --openai-proxy-url <url>: Proxy URL to use for OpenAI API requests.
  • -m, --model <model>: OpenAI model to use.
  • -p, --prompt <prompt>: OpenAI prompt to use.
  • -mt, --max-tokens <tokens>: OpenAI max tokens to use.
  • -e, --file-extensions <extensions>: File extensions to read, example: .ts,.tsx
  • -r, --read-type <type>: Read files from directory or git stage, example: dir or git.
  • -s, --read-git-status <name>: Read files from git stage by status default: A,R,M.
  • -d, --read-dir-name <name>: Root name of the directory to read files from, example: src.
  • -f, --test-file-type <type>: Generate test file type, example: test or spec.
  • -n, --test-file-dir-name <name>: Generate test file directory name, example: tests.
  • -o, --test-file-overwrite <value>: Generate test file overwrite, default is true.
  • -w, --review-report-webhook <url>: Webhook URL to send review report.

Environment Variables options

See .env file.

Note

  1. Also can set all options in .env or .env.local, that will be used as default options. Command options will override the default options.
  2. Webhook currently only test in seaTalk, if other channel need to use, please rise PR by yourself or ask me for help.