Package Exports
- huskygpt
Readme
huskygpt
Node.js CLI tools for
auto reviewyour code orauto generateunit tests by OpenAIchatgpt3.5andGPT-4Plus Account! ✅
Demo
- 🤖 Generate unit tests by gpt-4 model:

- ✨ The unit test result:

Key Features
- 🤖
AI: AI-powered code review and unit test generation - ✨
Free: Free to use with anOpenAI Session Token, enjoy chatgpt-3.5 or gpt-4 (Plus Account). - 🛡️
Security: Security-conscious function and class extraction, customize yourSECURITY_REGEX. - 🧠
Customizing: Customizable prompts and model selection. - 📂
File Reader: Supports reading files fromdirectoriesorgit staged files.
Installation
To install huskygpt, run the following command:
npm install -g huskygptConfiguration
OpenAI Key (Choose one)
- ✅ Set the
OpenAI Session Tokenfor free using chatgpt- OpenAI session token, 2 setp to get token
- If you don't set this, will use OPENAI_API_KEY, will cause fee by api key
- visit https://chat.openai.com/chat and login
- Visit https://chat.openai.com/api/auth/session to get token
npm config set OPENAI_SESSION_TOKEN <YOUR_OPENAI_SESSION_TOKEN> -g
- Set the OpenAI API Key by npm config set -g
npm config set OPENAI_API_KEY <YOUR_OPENAI_KEY> -gMethod Free? Robust? Quality? OpenAI Session Token✅ Yes ☑️ Maybe ✅️ Real ChatGPT OpenAI API Key❌ No ✅ Yes ✅ Real ChatGPT models
Local prompt
- Create
promptdirectory in the root directory of your project. - Add
review.txtortests.txtin thepromptdirectory.
Pre-Commit
- husky and lint-stage
"husky": { "hooks": { "pre-commit": "huskygpt review && huskygpt test && lint-staged --allow-empty" } },
Usage
- Run the following command to review your git staged files:
huskygpt review --model gpt-4 --max-tokens 2048 - Run the following command to generate unit tests:
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
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
- Also can set all options in
.envor.env.local, that will be used as default options. Command options will override the default options. - Webhook currently only test in
seaTalk, if other channel need to use, please risePRby yourself or ask me for help.