|
| 1 | +# Loji - AI-Powered Changelog Generator |
| 2 | + |
| 3 | +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](https://keepachangelog.com/) format. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Automatically analyze git commits using AI |
| 8 | +- Generate changelogs in the Keep a Changelog format |
| 9 | +- Store commit analysis in a local SQLite database |
| 10 | +- Configure OpenAI API key for personal use |
| 11 | +- Support for different OpenAI models |
| 12 | +- Automatic handling of large commits |
| 13 | +- Batch processing of commits |
| 14 | +- Retry failed commits with different models |
| 15 | + |
| 16 | +## Installation |
| 17 | +You can download this library from [npmjs](https://npmjs.org). |
| 18 | + |
| 19 | +```bash |
| 20 | +npm i loji |
| 21 | +``` |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +### Setting up your OpenAI API key |
| 26 | + |
| 27 | +Before using Loji, you need to set up your OpenAI API key. You can do this in one of three ways: |
| 28 | + |
| 29 | +1. Using the CLI: |
| 30 | + ```bash |
| 31 | + loji config OPENAI_API_KEY -v "your-api-key" |
| 32 | + ``` |
| 33 | + |
| 34 | +2. Creating a `.env` file in your project root: |
| 35 | + ``` |
| 36 | + OPENAI_API_KEY=your-api-key |
| 37 | + ``` |
| 38 | + |
| 39 | +3. Setting the environment variable: |
| 40 | + ```bash |
| 41 | + export OPENAI_API_KEY=your-api-key |
| 42 | + ``` |
| 43 | + |
| 44 | +### Configuring the OpenAI model |
| 45 | + |
| 46 | +You can configure which OpenAI model to use and other parameters: |
| 47 | + |
| 48 | +```bash |
| 49 | +# Set the model (default: gpt-3.5-turbo) |
| 50 | +loji config OPENAI_MODEL -v "gpt-4" |
| 51 | + |
| 52 | +# Set the maximum tokens for responses (default: 150) |
| 53 | +loji config OPENAI_MAX_TOKENS -v "300" |
| 54 | +``` |
| 55 | + |
| 56 | +### Generating a changelog |
| 57 | + |
| 58 | +To generate a changelog for your current repository: |
| 59 | + |
| 60 | +```bash |
| 61 | +loji generate |
| 62 | +``` |
| 63 | + |
| 64 | +This will: |
| 65 | +1. Analyze all commits in your repository |
| 66 | +2. Categorize them using AI |
| 67 | +3. Generate a CHANGELOG.md file |
| 68 | + |
| 69 | +You can specify the batch size for processing commits: |
| 70 | + |
| 71 | +```bash |
| 72 | +loji generate --batch-size 3 |
| 73 | +``` |
| 74 | + |
| 75 | +### Retrying failed commits |
| 76 | + |
| 77 | +If some commits fail to process due to token limits, you can retry them with a different model: |
| 78 | + |
| 79 | +```bash |
| 80 | +loji retry --model gpt-4 --tokens 300 |
| 81 | +``` |
| 82 | + |
| 83 | +This will: |
| 84 | +1. Temporarily switch to the specified model |
| 85 | +2. Process all commits again |
| 86 | +3. Restore your original model settings |
| 87 | + |
| 88 | +### Managing the database |
| 89 | + |
| 90 | +View all entries in the changelog database: |
| 91 | + |
| 92 | +```bash |
| 93 | +loji db:show |
| 94 | +``` |
| 95 | + |
| 96 | +Clear all entries from the database: |
| 97 | + |
| 98 | +```bash |
| 99 | +loji db:clear |
| 100 | +``` |
| 101 | + |
| 102 | +## How it works |
| 103 | + |
| 104 | +Loji uses the Vercel AI SDK to interact with OpenAI's API. It: |
| 105 | + |
| 106 | +1. Analyzes each commit using AI to determine its category and generate a description |
| 107 | +2. Stores the analysis in a local SQLite database |
| 108 | +3. Generates a changelog based on the stored entries |
| 109 | + |
| 110 | +The AI analysis categorizes commits into one of these categories: |
| 111 | +- Added |
| 112 | +- Changed |
| 113 | +- Deprecated |
| 114 | +- Removed |
| 115 | +- Fixed |
| 116 | +- Security |
| 117 | +- Other |
| 118 | + |
| 119 | +### Handling large commits |
| 120 | + |
| 121 | +For large commits with many file changes, Loji automatically: |
| 122 | +1. Truncates the number of files shown to the AI |
| 123 | +2. Limits the number of lines per file |
| 124 | +3. Uses a more efficient prompt format |
| 125 | + |
| 126 | +This helps avoid token limit errors while still providing accurate categorization. |
| 127 | + |
| 128 | +## License |
| 129 | + |
| 130 | +ISC |
0 commit comments