Skip to content

namecoder1/loji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loji - AI-Powered Changelog Generator

Loji is a CLI tool that automatically generates changelogs from git commits using AI. It analyzes your commit history and creates a well-formatted changelog following the Keep a Changelog format.

Features

  • Automatically analyze git commits using AI
  • Generate changelogs in the Keep a Changelog format
  • Store commit analysis in a local SQLite database
  • Configure OpenAI API key for personal use
  • Support for different OpenAI models
  • Automatic handling of large commits
  • Batch processing of commits
  • Retry failed commits with different models

Installation

You can download this library from npmjs.

npm i loji

Usage

Setting up your OpenAI API key

Before using Loji, you need to set up your OpenAI API key. You can do this in one of three ways:

  1. Using the CLI:

    loji config OPENAI_API_KEY -v "your-api-key"
  2. Creating a .env file in your project root:

    OPENAI_API_KEY=your-api-key
    
  3. Setting the environment variable:

    export OPENAI_API_KEY=your-api-key

Configuring the OpenAI model

You can configure which OpenAI model to use and other parameters:

# Set the model (default: gpt-3.5-turbo)
loji config OPENAI_MODEL -v "gpt-4"

# Set the maximum tokens for responses (default: 150)
loji config OPENAI_MAX_TOKENS -v "300"

Generating a changelog

To generate a changelog for your current repository:

loji generate

This will:

  1. Analyze all commits in your repository
  2. Categorize them using AI
  3. Generate a CHANGELOG.md file

You can specify the batch size for processing commits:

loji generate --batch-size 3

Retrying failed commits

If some commits fail to process due to token limits, you can retry them with a different model:

loji retry --model gpt-4 --tokens 300

This will:

  1. Temporarily switch to the specified model
  2. Process all commits again
  3. Restore your original model settings

Managing the database

View all entries in the changelog database:

loji db:show

Clear all entries from the database:

loji db:clear

How it works

Loji uses the Vercel AI SDK to interact with OpenAI's API. It:

  1. Analyzes each commit using AI to determine its category and generate a description
  2. Stores the analysis in a local SQLite database
  3. Generates a changelog based on the stored entries

The AI analysis categorizes commits into one of these categories:

  • Added
  • Changed
  • Deprecated
  • Removed
  • Fixed
  • Security
  • Other

Handling large commits

For large commits with many file changes, Loji automatically:

  1. Truncates the number of files shown to the AI
  2. Limits the number of lines per file
  3. Uses a more efficient prompt format

This helps avoid token limit errors while still providing accurate categorization.

License

ISC

About

AI-powered CLI tool that automates changelog generation for your projects

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published