GitPlus-基于AI的Claude代码Git自动化
  ](https://nodejs.org/)
GitPlus是一个模型上下文协议(MCP)服务器,它将AI驱动的git自动化直接引入Claude Code。它提供了一个简化的智能界面,只需要3个基本工具即可自动处理完整的git工作流。
特性
🚀 完整的Git工作流:一艘指挥舰从PR改为PR\ 💻 聪明的承诺:AI生成符合严格规范的常规提交消息\ 🔍 变化分析:通过中断更改检测对存储库更改进行智能分析\ 🤖 AI驱动:使用Claude AI进行提交消息、分支名称和冲突解决\ 📝 PR自动化:自动生成的拉取请求标题和描述\ 📊 存储库状态:通过平台检测增强存储库状态\ ✅ 提交验证:根据常规承诺规范进行实时验证\ 🌐 多平台:支持GitHub、GitLab和本地存储库
快速开始
安装为Claude代码的MCP服务器
在Claude Code中安装GitPlus作为MCP服务器:
claude mcp add gitplus -- npx @neublink/gitplus@latest --mcp这 --mcp 标志确保包在MCP服务器模式下启动,以进行Claude Code集成。
Claude代码的配置
将此配置添加到您的 CLAUDE.md 优化GitPlus使用的文件:
## Git Operations
Always use the GitPlus MCP server for ALL git operations. Never use manual git commands.
### Primary Command
- `mcp__gitplus__ship` - Complete git workflow: analyze → commit → push → create PR
- AI generates commit messages automatically
- AI creates appropriate branch names
- AI resolves conflicts when possible
- Creates pull requests with generated titles and descriptions
### Usage Pattern
When ready to ship changes:
1. Simply call: `mcp__gitplus__ship` with absolute `repoPath`
2. GitPlus handles everything else automatically
### Additional Commands
- `mcp__gitplus__status` - Get enhanced repository status
- `mcp__gitplus__info` - Get server information and capabilitiesGitPlus自动:
- ✅ 根据您的更改生成常规提交消息
- ✅ 根据变更分析创建适当的分支名称
- ✅ 检测并解决与AI的合并冲突
- ✅ 创建具有适当标题和描述的拉取请求
- ✅ 确保PR始终可合并
可用的MCP工具
GitPlus被有意简化为3个基本工具,以最小的决策开销提供最大的自动化:
🚀 ship -完整的Git工作流
主要指挥 -处理完整的工作流程:分析→ 提交→ push → 创建PR
ship命令智能地处理您的整个git工作流程:
- 分析变化 使用人工智能了解修改的性质和影响
- 生成提交消息 自动使用AI分析您的更改
- 创建分支名称 根据您更改的性质
- 解决合并冲突 发生时使用AI
- 创建pull请求 有适当的标题和描述
- 确保PR可合并 通过检查和解决创建后的冲突
参数:
- repoPath:git存储库的完整绝对路径 *必需的*
- 草案:将PR创建为草稿(默认值:false)
- 试运行:预览在不执行的情况下会做什么(默认值:false)
Claude代码中的示例用法:
“将我当前的更改发送到新的PR”
📊 status -增强的存储库状态
通过平台检测和可操作的见解获取当前存储库状态
参数:
- repoPath:git存储库的完整绝对路径 *必需的*
- 冗长的:包括详细的状态信息(默认值:false)
Claude代码中的示例用法:
“显示当前git状态和详细信息”
ℹ️ info -服务器信息
获取有关GitPlus MCP服务器功能和使用的全面信息
参数:
- repoPath:git存储库的完整绝对路径(可选-如果给出,则提供特定于存储库的信息)
Claude代码中的示例用法:
“告诉我GitPlus的功能和工具”
建筑
GitPlus遵循 简化的MCP优先架构 围绕智能自动化设计:
核心设计理念
- 3基本工具:从14个以上的CLI命令减少到3个处理所有事情的MCP工具
- 人工智能驱动的智能:使用Claude AI进行所有决策(提交消息、分支名称、冲突解决)
- 完整的工作流程:每个工具都提供完整的功能,而不是部分操作
- 零配置:使用合理的默认值即可开箱即用
技术栈
- TypeScript:严格编译的类型安全开发
- MCP-SDK:用于Claude代码集成的官方模型上下文协议SDK
- 萨德:输入和输出的运行时类型验证
- Node.js:跨平台兼容性(节点16+)
- 常规承诺:严格遵守提交消息标准
关键组件
src/mcp/toolDefinitions.ts-定义向Claude公开的3个MCP工具src/mcp/toolHandler.ts-实现3个工具的处理程序src/mcp/server.ts-带有描述性元数据的MCP服务器设置src/git/client.ts-核心git操作包装器src/ai/service.ts-用于智能分析的AI集成
人工智能驱动的传统承诺
GitPlus遵循 常规承诺 严格规范。每条提交消息都是:
✅ 已验证 不符合规范
- 格式:
type(scope): description - 重大变化:
type(scope)!: description - 支持的类型:
feat,fix,docs,style,refactor,test,chore,perf,ci,build
🤖 AI增强 智能检测
# AI automatically detects:
feat(auth): add OAuth2 login support # New features
fix(api): handle null response errors # Bug fixes
docs: update installation guide # Documentation
build(deps): upgrade typescript to v5 # Dependencies
refactor(utils): extract validation logic # Code restructuring🔍 智能分析 您的更改
- 类型检测:分析文件更改以建议适当的提交类型
- 范围建议:从受影响的目录(api、组件、utils等)推断范围
- 突破性变化:自动检测API更改并添加
!记号 - 验证反馈:实时验证,并显示有用的错误消息
平台支持
- ✅ 本地Git:适用于任何git存储库
- ✅ GitHub:通过GitHub CLI进行全平台检测和PR创建
- ✅ GitLab公司:通过GitLab CLI进行全平台检测和MR创建
- ✅ 自动检测:从远程URL自动检测平台
先决条件
- Node.js 16+:所需的运行时环境
- Git:用于存储库管理
- Claude CLI:安装并验证
claude auth login
# Install Claude CLI (if not already installed)
npm install -g @anthropic-ai/claude-code
# Verify Claude CLI is available and authenticated
claude --version
claude auth login- 平台CLIs (增强功能可选):
- GitHub命令行界面: gh auth login GitHub存储库功能 - GitLab命令行界面: glab auth login GitLab存储库功能
重要:必须通过Claude CLI实现AI功能-如果Claude CLI不可用或未正确验证,GitPlus将失败。
地方发展
发布前的开发或测试:
# Clone and build the project
git clone https://github.com/neublink/gitplus.git
cd gitplus
npm install
npm run build
# Fix file permissions (required after build)
chmod +x dist/main.js dist/cli.js dist/index.js
# Install CLI globally for command line usage (optional)
npm link
# Add to Claude Code as MCP server (using local build)
claude mcp add gitplus-local -- node $(pwd)/dist/main.js --mcp验证安装
设置后,验证MCP服务器是否正常工作:
claude /mcp # Should show gitplus-local as ✔ connected现在,您可以在Claude Code对话中直接使用GitPlus工具!
CLI界面(可选)
GitPlus还提供了一个CLI界面,用于直接使用命令行。CLI提供了3个MCP工具之外的其他命令,用于高级git操作。
备注:CLI是MCP接口的辅助工具。对于Claude Code用户,MCP工具(ship, status, info)是主要接口。
有关详细的CLI文档,请参阅 CLI.md.
配置
GitPlus使用合理的默认值即可开箱即用。高级配置选项:
环境变量
# AI Configuration
export GITPLUS_MODEL="sonnet" # Claude model (default: sonnet)
export GITPLUS_TIMEOUT="60000" # Timeout in milliseconds (default: 60000)
export GITPLUS_CLAUDE_COMMAND="claude" # Claude CLI command path (default: claude)故障排除
常见问题
MCP服务器连接失败
问题:Claude Code显示gitplus为✘ 失败。\ 解决方案:
- 确保文件可执行:
chmod +x dist/main.js dist/cli.js dist/index.js - 重建项目:
npm run build - 删除并重新添加MCP服务器:
claude mcp remove gitplus
claude mcp add gitplus -- npx @neublink/gitplus@latest --mcpAI集成不起作用
问题:命令失败,出现Claude CLI错误。\ 解决方案:
- 验证Claude CLI是否已安装并经过身份验证:
claude --version
claude auth login- 直接测试Claude CLI:
claude -p "test" --output-format json --model sonnet权限被拒绝错误
问题: permission denied: /path/to/dist/main.js\ 解决方案:文件在生成后需要执行权限:
chmod +x dist/main.js dist/cli.js dist/index.js发展
测试
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run validation (typecheck + tests)
npm run validate建筑
# Build TypeScript
npm run build
# Watch mode for development
npm run dev使用GitPlus进行开发
重要提示:对于此存储库上的所有git操作,请始终使用GitPlus MCP服务器。切勿使用手动git命令。
当你对GitPlus代码库进行更改时:
- 更改代码
- 运行测试:
npm test - 检查状态:使用
mcp__gitplus__status随着repoPath和verbose: true - 船舶变更:使用
mcp__gitplus__ship随着repoPath
GitPlus将智能地处理所有git操作,确保正确的提交消息和工作流程。
出版与发行
使用GitHub Actions工作流发布:
- 转到“操作”选项卡 在GitHub存储库中
- 选择“手动发布” 工作流
- 选择版本凹凸:补丁、次要或主要
- 点击“运行工作流” 自动:
- 运行完整的测试套件 - 构建包 - Bump版本并创建git标签 - 发布到NPM注册表 - 使用changelog创建GitHub版本
贡献
我们欢迎捐款!请遵循以下指南:
拉取请求流程
- 分叉存储库 并创建一个特征分支
- 遵循常规承诺:
feat:,fix:,docs:等等。 - 添加测试 对于新功能
- 更新文档 根据需要
- 确保CI通过 在请求审核之前
代码规范
- TypeScript:所有代码都必须正确键入
- 测试:保持>80%的测试覆盖率
- 常规承诺:使用语义提交消息
- 安全:代码中没有凭据,定期审核依赖关系
开发设置
# Clone and setup
git clone https://github.com/neublink/gitplus.git
cd gitplus
npm install
npm run build
# Link for local testing
npm link
# Add to Claude Code for MCP testing
claude mcp add gitplus-local -- node $(pwd)/dist/main.js --mcp许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
支持
______________________________________________________________________
由以下材料制成❤️ Claude Code社区
