tst-changelog
v1.2.0
Published
AI-powered changelog generator using OpenRouter
Readme
tst-changelog
AI-powered changelog generator using OpenRouter. Analyzes your git commits and staged changes to automatically generate changelog entries following the Keep a Changelog format.
Installation
pnpm add tst-changelog
# or
npm install tst-changelogConfiguration
Create a tst-changelog.yaml file in your project root:
# AI Configuration
ai:
provider: openrouter
model: anthropic/claude-3-haiku
token: ${OPENROUTER_API_KEY} # Supports environment variables
# Changelog Configuration
changelog:
file: CHANGELOG.md
format: keepachangelog
includeDate: true
groupBy: type
# Git Configuration
git:
baseBranch: main
analyzeDepth: 50Usage
CLI
# Basic usage (reads config from ./tst-changelog.yaml)
npx tst-changelog
# With options
npx tst-changelog --config ./custom-config.yaml
npx tst-changelog --dry-run # Preview without modifying files
npx tst-changelog --verbose # Enable detailed outputPre-commit Hook (with Husky)
Add to your .husky/pre-commit:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx tst-changelogProgrammatic Usage
import { loadConfig, GitService, AIService, ChangelogService } from 'tst-changelog';
const config = loadConfig('./tst-changelog.yaml');
const git = new GitService(config.git);
const ai = new AIService(config.ai);
const changelog = new ChangelogService(config.changelog);
const staged = await git.getStagedChanges();
const commits = await git.getUnmergedCommits();
const generated = await ai.generateChangelog(commits, staged);
const content = changelog.update(generated);
changelog.write(content);How It Works
- Reads your configuration from
tst-changelog.yaml - Collects staged git changes and recent commits
- Sends the context to OpenRouter AI for analysis
- Parses conventional commits (feat:, fix:, etc.)
- Generates changelog entries grouped by type
- Updates or creates CHANGELOG.md
- Stages the changelog file for commit
Supported Change Types
Following Keep a Changelog format:
- Added - New features
- Changed - Changes in existing functionality
- Deprecated - Features to be removed
- Removed - Removed features
- Fixed - Bug fixes
- Security - Security improvements
Environment Variables
OPENROUTER_API_KEY- Your OpenRouter API key
License
MIT
