1.0.2 • Published 5 months ago

commit-summarize v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

AI-Powered Commit Message Script

This Node.js script automatically generates concise and descriptive Git commit messages using OpenAI's API. It analyzes your staged changes and provides a meaningful commit message in two parts:

  1. Summary: A brief overview (no more than 50 characters).
  2. Description: Bullet points outlining the changes.

🚀 Features

  • Extracts staged Git changes
  • Functional programming style using Ramda for cleaner code
  • Utilizes OpenAI GPT-4 for generating commit messages
  • Support to use local model(deepseek-r1 on ollama) with USE_LOCAL_MODEL=true.
  • Security
    • Sanitize diffs and filenames.
    • Restrict to safe file types
    • Remove comments.
    • Confirmation diff before send.
    • Enable to use local model with ollama, avoid code exposure.
    • Anonymize variable names On the way

📦 Installation & Usage

  1. Install it globally.

    npm install -g commit-summarize
  2. Install the required packages:

    export USE_LOCAL_MODEL=true && commit-summarize
    or
    export OPEN_API_KEY_COMMIT=YOUR_KEY && commit-summarize

    Or clone the repository and run it locally.

  3. Clone the repository:

    git clone https://github.com/chienweiluo/commit-summarize.git
    cd commit-summarize
  4. Install the required packages.
  5. Copy the index.cjs to your project and run it.
    node index.cjs
  6. Run the script:

    • If you want to use OpenAI API, you can set the following environment variable:
      export OPEN_API_KEY_COMMIT=YOUR_KEY && node index.cjs
    • If you want to use local model (deepseek-r1 on ollama), you can set the following environment variable:
      export USE_LOCAL_MODEL=true && node index.cjs
      After running the script, it will ask you to confirm the diff.
  7. Check the diff and answer the yes/no question to confirm the diff.

  8. Wait for the script to generate the commit message. like this:

**Summary:** Update environment variable handling and logging

**Description:**
- Changed the environment variable from `XXX` to `YYY`.
- Updated console log message for empty changed files for improved clarity.
...

🛠️ Code Reference

The main idea of this script is inspired by an article from August. Many thanks to him for his outstanding articles.

Related Links

AI Git Commit by August@letswritetw

How To Get Your Own OpenAI API Key

Open AI API Doc

Reddit: readline

Nodejs: readline interface

DeepSeek API

Ollama github

📄 License

This project is licensed under the MIT License.

This document is generated by AI.

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago