generate_commit_message
Generate Git commit messages from code changes using conventional, simple, or detailed styles to document version history.
Instructions
根据代码变更生成 Git commit message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | Yes | 代码变更内容(git diff 输出) | |
| style | No | 提交信息风格:conventional(约定式)、simple(简洁)、detailed(详细) |
Implementation Reference
- src/server.ts:763-788 (handler)MCP tool handler for 'generate_commit_message': extracts diff and style from args, defines style-specific prompts, constructs a prompt for generating commit message from git diff, calls orchestrator.askDynamicExpert with a fast Git expert role, and returns formatted response.case 'generate_commit_message': { const { diff, style = 'conventional' } = args as { diff: string; style?: string }; const stylePrompts: Record<string, string> = { conventional: '使用约定式提交格式:type(scope): description。type 可以是 feat/fix/docs/style/refactor/test/chore。', simple: '使用简洁风格:一行描述主要变更。', detailed: '使用详细风格:标题 + 空行 + 详细说明(列出所有变更点)。', }; const prompt = `请根据以下代码变更生成 Git commit message。 ${stylePrompts[style] || stylePrompts.conventional} 代码变更: \`\`\`diff ${diff.slice(0, 8000)} \`\`\` 请只输出 commit message,不要其他内容。`; const response = await orchestrator.askDynamicExpert('fast', '你是一位 Git 提交规范专家。', prompt); return { content: [{ type: 'text', text: `# 📝 推荐的 Commit Message\n\n\`\`\`\n${response}\n\`\`\`` }], }; }
- src/server.ts:325-343 (schema)Tool registration and input schema definition for 'generate_commit_message', specifying required 'diff' (git diff output) and optional 'style' enum for commit message format.{ name: 'generate_commit_message', description: '根据代码变更生成 Git commit message', inputSchema: { type: 'object', properties: { diff: { type: 'string', description: '代码变更内容(git diff 输出)', }, style: { type: 'string', enum: ['conventional', 'simple', 'detailed'], description: '提交信息风格:conventional(约定式)、simple(简洁)、detailed(详细)', }, }, required: ['diff'], }, },