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

commit-whisperer

v1.0.0

Published

An AI genius for generating meaningful git commit messages from repository state and user instructions.

Downloads

74

Readme

commit-whisperer NPM version NPM monthly downloads NPM total downloads

An AI genius for generating meaningful git commit messages from repository state and user instructions.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.

Install

Install with npm:

$ npm install --save commit-whisperer

What is Commit Whisperer?

Commit Whisperer is a CLI and API for crafting meaningful commit messages using AI.

By analyzing the current state of your project and any provided instructions, it helps generate commit messages that accurately describe your changes.

API

Installation

To use Commit Whisperer, first ensure you have it installed as a dependency in your project:

npm install commit-whisperer --save-dev
# or
pnpm i commit-whisperer -D
# or
yarn add commit-whisperer --dev

Usage

import { whisper } from 'commit-whisperer';

whisper

The whisper function is the primary method provided by Commit Whisperer. It generates a commit message based on the project's state and user input.

Parameters

  • cwd (string, optional): The current working directory. Defaults to process.cwd().
  • useGitState (boolean, optional): Whether to include the git state in the message generation. Defaults to true.
  • usePackageJson (boolean, optional): Whether to include package.json details. Defaults to true.
  • message (string, optional): An initial message or instructions to guide the commit message generation.
  • instructions (string, optional): Specific instructions for the commit message.
  • diff (boolean, optional): Whether to include the git diff in the message. Defaults to false.
  • orgId (string, optional): OpenAI organization ID. Defaults to process.env.OPENAI_ORG_ID.
  • apiKey (string, optional): OpenAI API key. Defaults to process.env.OPENAI_API_KEY.
  • openaiConfig (object, optional): Additional configuration passed directly to the OpenAI API. Useful for customizing parameters like temperature, model, or overriding the default messages array.
  • formatContent (function, optional): Custom function to format the content sent to OpenAI.

Returns

A promise that resolves to an OpenAI response object with an additional content property containing the generated commit message.

Examples

const response = await whisper({ message: 'First commit' });
console.log(response.content);

git diff

Pass git diff to the LLM as context:

const response = await whisper({
  message: 'First commit',
  diff: true
});

console.log(response.content);

CLI Usage

Installation

npm install -g commit-whisperer
# or
pnpm add -g commit-whisperer
# or
yarn global add commit-whisperer

Usage

Commit Whisperer can be used from the command line using either the commit-whisperer or cw command:

cw [options] [text]
# or
commit-whisperer [options] [text]

Options

  • -M, --max-tokens: Maximum number of tokens for the response (default: 1000)
  • -m, --model: OpenAI model to use (default: gpt-4o)
  • -t, --temperature: Temperature for response generation (default: 0.8)
  • -s, --stream: Stream the output as it's generated (default: true)
  • -d, --debug: Enable debug mode to show timing information (boolean)
  • -D, --diff: Include git diff in the context (boolean)
  • -h, --help: Display help message

Examples

Generate a commit message with default settings:

cw "Update documentation"

Include git diff in the commit message context:

cw "Describe changes" -D

Use a different model with custom temperature:

cw -m o1-preview -t 0.5 "Refactor authentication"

Configuration

Commit Whisperer relies on OpenAI's API to generate commit messages. Ensure you have set your OpenAI API key and organization ID in your environment variables:

  • OPENAI_API_KEY: Your OpenAI API key.
  • OPENAI_ORG_ID (optional): Your OpenAI organization ID.

Advanced Usage

You can extend the functionality of Commit Whisperer by providing custom formatting functions and OpenAI configurations through the formatContent and openaiConfig parameters respectively.

About

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Author

Jon Schlinkert

License

Copyright © 2024, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on November 07, 2024.