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.
- 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
You can download this library from npmjs.
npm i loji
Before using Loji, you need to set up your OpenAI API key. You can do this in one of three ways:
-
Using the CLI:
loji config OPENAI_API_KEY -v "your-api-key"
-
Creating a
.env
file in your project root:OPENAI_API_KEY=your-api-key
-
Setting the environment variable:
export OPENAI_API_KEY=your-api-key
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"
To generate a changelog for your current repository:
loji generate
This will:
- Analyze all commits in your repository
- Categorize them using AI
- Generate a CHANGELOG.md file
You can specify the batch size for processing commits:
loji generate --batch-size 3
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:
- Temporarily switch to the specified model
- Process all commits again
- Restore your original model settings
View all entries in the changelog database:
loji db:show
Clear all entries from the database:
loji db:clear
Loji uses the Vercel AI SDK to interact with OpenAI's API. It:
- Analyzes each commit using AI to determine its category and generate a description
- Stores the analysis in a local SQLite database
- 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
For large commits with many file changes, Loji automatically:
- Truncates the number of files shown to the AI
- Limits the number of lines per file
- Uses a more efficient prompt format
This helps avoid token limit errors while still providing accurate categorization.
ISC