AI-powered changelog generator using OpenRouter
npm install tst-changelogAI-powered changelog generator using OpenRouter. Analyzes your git commits and staged changes to automatically generate changelog entries following the Keep a Changelog format.
``bash`
pnpm add tst-changelogor
npm install tst-changelog
Create a tst-changelog.yaml file in your project root:
`yamlAI Configuration
ai:
provider: openrouter
model: anthropic/claude-3-haiku
token: ${OPENROUTER_API_KEY} # Supports environment variables
Usage
$3
`bash
Basic usage (reads config from ./tst-changelog.yaml)
npx tst-changelogWith options
npx tst-changelog --config ./custom-config.yaml
npx tst-changelog --dry-run # Preview without modifying files
npx tst-changelog --verbose # Enable detailed output
`$3
Add to your
.husky/pre-commit:`bash
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"npx tst-changelog
`$3
`typescript
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
1. Reads your configuration from
tst-changelog.yaml
2. Collects staged git changes and recent commits
3. Sends the context to OpenRouter AI for analysis
4. Parses conventional commits (feat:, fix:, etc.)
5. Generates changelog entries grouped by type
6. Updates or creates CHANGELOG.md
7. Stages the changelog file for commitSupported 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 keyMIT