peterfei/ai-agent-team / .claude/skills/changelog-generator
changelog-generator
Verified智能变更日志生成器 - 自动分析Git提交历史,生成符合规范的CHANGELOG.md。支持语义化版本管理、多种输出格式、增量更新和GitHub/GitLab集成。
| File | Kind | Size |
|---|---|---|
| .gitignore | other | 352 B |
| .npmignore | other | 14 B |
| CHANGELOG.md | markdown | 1.7 KB |
| LICENSE | other | 1.0 KB |
| README.md | markdown | 12.9 KB |
| SKILL.md | skill md | 9.7 KB |
| bin/cli.jsexecutable | script | 17.0 KB |
| docs/PHASE2_IMPLEMENTATION_SUMMARY.md | markdown | 9.8 KB |
| examples/default-config.json | config | 1.7 KB |
| jest.config.js | script | 356 B |
| package.json | manifest | 1.2 KB |
| src/core/ChangelogGenerator.js | script | 8.9 KB |
| src/core/CommitClassifier.js | script | 7.3 KB |
| src/core/GitAnalyzer.js | script | 7.4 KB |
| src/exporters/HTMLExporter.js | script | 15.7 KB |
| src/index.js | script | 389 B |
| src/integrations/GitHubIntegration.js | script | 7.3 KB |
| src/utils/ConfigLoader.js | script | 4.7 KB |
| src/utils/TemplateManager.js | script | 8.5 KB |
| tests/unit/ChangelogGenerator.test.js | script | 7.6 KB |
| tests/unit/CommitClassifier.test.js | script | 6.3 KB |
| tests/unit/GitAnalyzer.test.js | script | 4.5 KB |
| tests/unit/GitHubIntegration.test.js | script | 13.9 KB |
| tests/unit/HTMLExporter.test.js | script | 12.3 KB |
| tests/unit/TemplateManager.test.js | script | 10.4 KB |
src/core/CommitClassifier.js
View on GitHub/**
* CommitClassifier - 提交分类器
* 负责对提交进行分类、分组和排序
*/
class CommitClassifier {
/**
* @param {Object} config - 配置对象
*/
constructor(config) {
this.config = config;
this.types = config.types || this.getDefaultTypes();
this.excludeTypes = config.exclude?.types || [];
this.excludeScopes = config.exclude?.scopes || [];
}
/**
* 获取默认的提交类型配置
* @returns {Array} 类型配置数组
*/
getDefaultTypes() {
return [
{ type: 'feat', section: 'Features', emoji: '✨', priority: 1 },
{ type: 'fix', section: 'Bug Fixes', emoji: '🐛', priority: 2 },
{ type: 'perf', section: 'Performance', emoji: '⚡', priority: 3 },
{ type: 'refactor', section: 'Code Refactoring', emoji: '♻️', priority: 4 },
{ type: 'docs', section: 'Documentation', emoji: '📝', priority: 5 },
{ type: 'test', section: 'Tests', emoji: '✅', priority: 6 },
{ type: 'build', section: 'Build System', emoji: '📦', priority: 7 },
{ type: 'ci', section: 'CI/CD', emoji: '👷', priority: 8 },
{ type: 'style', section: 'Styles', emoji: '💄', priority: 9, hidden: true },
{ type: 'chore', section: 'Chores', emoji: '🔧', priority: 10, hidden: true },
{ type: 'revert', section: 'Reverts', emoji: '⏪', priority: 11 }
];
}
/**
* 分类提交列表
* @param {Array} commits - 提交列表
* @returns {Object} 分类后的提交对象
*/
classify(commits) {
// 过滤和分类
const filtered = commits.filter(commit => this.shouldInclude(commit));
// 按类型分组
const grouped = this.groupByType(filtered);
// 分离破坏性变更
const { breaking, regular } = this.separateBreakingChanges(grouped);
// 排序
const sorted = this.sortGroups(regular);
return {
breaking,
changes: sorted,
stats: this.generateStats(commits, filtered)
};
}
/**
* 判断是否应该包含此提交
* @param {Object} commit - 提交对象
* @returns {boolean}
*/
shouldInclude(commit) {
// 检查是否排除此类型
if (this.excludeTypes.includes(commit.type)) {
return false;
}
// 检查是否排除此 scope
if (commit.scope && this.excludeScopes.includes(commit.scope)) {
return false;
}
// 检查配置中是否标记为 hidden
const typeConfig = this.types.find(t => t.type === commit.type);
if (typeConfig && typeConfig.hidden) {
return false;
}
return true;
}
/**
* 按类型分组
* @param {Array} commits - 提交列表
* @returns {Object} 分组后的对象
*/
groupByType(commits) {
const groups = {};
commits.forEach(commit => {
const type = commit.type || 'other';
if (!groups[type]) {
groups[type] = [];
}
groups[type].push(commit);
});
return groups;
}
/**
* 分离破坏性变更
* @param {Object} grouped - 分组后的提交
* @returns {Object} { breaking: [], regular: {} }
*/
separateBreakingChanges(grouped) {
const breaking = [];
const regular = {};
Object.keys(grouped).forEach(type => {
const commits = grouped[type];
regular[type] = [];
commits.forEach(commit => {
if (commit.isBreaking) {
breaking.push(commit);
} else {
regular[type].push(commit);
}
});
// 如果该类型没有非破坏性提交,删除这个键
if (regular[type].length === 0) {
delete regular[type];
}
});
return { breaking, regular };
}
/**
* 排序分组
* @param {Object} groups - 分组对象
* @returns {Array} 排序后的数组
*/
sortGroups(groups) {
const sorted = [];
// 获取所有类型并按优先级排序
const types = Object.keys(groups).sort((a, b) => {
const configA = this.types.find(t => t.type === a);
const configB = this.types.find(t => t.type === b);
const priorityA = configA ? configA.priority : 999;
const priorityB = configB ? configB.priority : 999;
return priorityA - priorityB;
});
types.forEach(type => {
const typeConfig = this.types.find(t => t.type === type) || {
type,
section: this.capitalize(type),
emoji: '📝',
priority: 999
};
// 按 scope 分组
const byScope = this.groupByScope(groups[type]);
sorted.push({
type,
section: typeConfig.section,
emoji: typeConfig.emoji,
commits: groups[type],
byScope
});
});
return sorted;
}
/**
* 按 scope 分组
* @param {Array} commits - 提交列表
* @returns {Object} 按 scope 分组的对象
*/
groupByScope(commits) {
const byScope = {};
commits.forEach(commit => {
const scope = commit.scope || 'general';
if (!byScope[scope]) {
byScope[scope] = [];
}
byScope[scope].push(commit);
});
return byScope;
}
/**
* 生成统计信息
* @param {Array} allCommits - 所有提交
* @param {Array} includedCommits - 包含的提交
* @returns {Object} 统计对象
*/
generateStats(allCommits, includedCommits) {
const stats = {
total: allCommits.length,
included: includedCommits.length,
excluded: allCommits.length - includedCommits.length,
byType: {},
breaking: 0,
authors: new Set()
};
includedCommits.forEach(commit => {
// 按类型统计
const type = commit.type || 'other';
if (!stats.byType[type]) {
stats.byType[type] = 0;
}
stats.byType[type]++;
// 统计破坏性变更
if (commit.isBreaking) {
stats.breaking++;
}
// 统计作者
stats.authors.add(commit.author);
});
// 转换 Set 为数组
stats.authors = Array.from(stats.authors);
return stats;
}
/**
* 合并相似的提交
* @param {Array} commits - 提交列表
* @returns {Array} 合并后的提交列表
*/
mergeSimilarCommits(commits) {
// TODO: 实现智能合并逻辑
// 例如:将多个相似的小改动合并为一个条目
return commits;
}
/**
* 首字母大写
* @param {string} str - 字符串
* @returns {string}
*/
capitalize(str) {
if (!str) return '';
return str.charAt(0).toUpperCase() + str.slice(1);
}
/**
* 获取类型配置
* @param {string} type - 类型名称
* @returns {Object|null}
*/
getTypeConfig(type) {
return this.types.find(t => t.type === type) || null;
}
/**
* 验证提交格式
* @param {Object} commit - 提交对象
* @returns {Object} 验证结果
*/
validateCommit(commit) {
const errors = [];
const warnings = [];
// 检查类型是否有效
const typeConfig = this.getTypeConfig(commit.type);
if (!typeConfig && commit.type !== 'other') {
warnings.push(`Unknown commit type: ${commit.type}`);
}
// 检查 subject 长度
if (commit.subject && commit.subject.length > 100) {
warnings.push('Subject is too long (>100 characters)');
}
// 检查是否有 subject
if (!commit.subject || commit.subject.trim() === '') {
errors.push('Commit must have a subject');
}
return {
valid: errors.length === 0,
errors,
warnings
};
}
}
module.exports = CommitClassifier;
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |