ai-changelog-generator
v0.4.0
Published
An npm command line tool that generates changelogs in keep-a-changelog format using OpenAI or XAI
Maintainers
Readme
AI Changelog Generator
An npm command line tool that generates changelogs in Keep a Changelog format using AI services (XAI or OpenAI).
Features
- 🤖 AI-Powered: Uses XAI (default) or OpenAI to generate meaningful changelog entries
- 📝 Keep a Changelog Format: Generates changelogs following the standard format
- 🔍 Dry Run Mode: Test the output before writing to files
- 📁 Flexible Output: Create new files or append to existing changelogs
- 🔗 GitHub Links: Adds commit links when a GitHub repository can be detected
- 🔑 Environment Variables: Supports API keys from environment variables
- ⚡ Simple CLI: Supports both
aicandai-changelogcommands
Installation
npm install -g ai-changelog-generatorOr use locally in your project:
npm install ai-changelog-generator
npx ai-changelog --dry-runUsage
Basic Usage
# Generate changelog for version 1.2.0 (uses XAI by default)
ai-changelog --version 1.2.0 --from v1.1.0 --dry-run
# Use OpenAI instead
ai-changelog --version 1.2.0 --from v1.1.0 --provider openai --dry-run
# Dry run - see output without writing to file
ai-changelog -v 1.2.0 -s v1.1.0 -d
# Write to CHANGELOG.md
ai-changelog -v 1.2.0 -s v1.1.0 --writeAdvanced Usage
# Generate changelog for a git range
ai-changelog --version 1.2.0 --from v1.1.0 --to HEAD --write
# Disable commit links
ai-changelog --from v1.1.0 --write --no-git-links
# Specify custom output file
ai-changelog -v 1.2.0 -s v1.1.0 -o MY_CHANGELOG.md
# Provide API key directly
ai-changelog -v 1.2.0 -s v1.1.0 -k your-api-key-here
# Retry transient AI/API failures up to 5 times
ai-changelog -v 1.2.0 -s v1.1.0 --retries 5 --writeAPI Keys
The tool requires API keys for the AI services. You can provide them in two ways:
Environment Variables (Recommended)
For XAI (default):
export XAI_API_KEY="your-xai-api-key"
# or
export XAI_KEY="your-xai-api-key"
# or
export X_API_KEY="your-xai-api-key"For OpenAI:
export OPENAI_API_KEY="your-openai-api-key"Command Line Option
ai-changelog -v 1.2.0 -k your-api-key-hereCommand Line Options
| Option | Alias | Description | Default |
|--------|-------|-------------|---------|
| --version | -v | Version number for the changelog entry | package.json version without prerelease suffix |
| --from | | Start git reference | Last tag |
| --to | | End git reference | HEAD |
| --since | -s | Alias for --from | Last tag |
| --provider | -p | AI provider (xai or openai) | xai |
| --api-key | -k | API key for the AI provider | From env vars |
| --retries | | Number of times to retry AI generation after a failure | 3 |
| --retry-delay-ms | | Initial retry delay in milliseconds with exponential backoff | 1000 |
| --out, --output | -o | Output file path | None |
| --dry-run | -d | Print changelog without writing to file | false |
| --write | | Prepend the generated section to CHANGELOG.md | false |
| --append | -a | Alias for --write | false |
| --no-git-links | | Omit GitHub commit links | false |
| --help | -h | Show help | |
Example Output
The tool generates changelogs in the standard Keep a Changelog format:
## [1.2.0] - 2024-01-15
### Added
- New user authentication system
- Support for multiple file formats
### Changed
- Improved error handling in API requests
- Updated dependencies to latest versions
### Fixed
- Fixed memory leak in file processing
- Resolved issue with special characters in filenames
### Security
- Enhanced input validation
- Updated authentication tokensRequirements
- Node.js >= 16.0.0
- Git repository (the tool reads git log)
- API key for XAI or OpenAI
License
MIT © Tantawowa
