git-push-mcp 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -62
- package/lib/git-operator.js +262 -171
- package/lib/mcp-handler.js +341 -252
- package/mcp-server.js +19 -21
- package/mcp.json +117 -118
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,78 +1,83 @@
|
|
|
1
|
-
# Git Push MCP -
|
|
1
|
+
# Git Push MCP - 灵码Git提交助手
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
一个基于自然语言处理的Git操作工具,支持MCP(Model Context Protocol)协议。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 🌟 主要特性
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- 🛡️ **安全可靠** - 完善的错误处理和状态检查
|
|
7
|
+
### 🔧 核心功能
|
|
8
|
+
- **自然语言Git操作**:使用中文指令操作Git(如"提交所有更改"、"推送代码")
|
|
9
|
+
- **智能命令解析**:自动识别提交类型(feat、fix、docs等)
|
|
10
|
+
- **约定式提交**:支持Conventional Commits规范
|
|
11
|
+
- **自动暂存推送**:可配置自动添加文件和推送功能
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
### 🚀 优化特性
|
|
14
|
+
- **智能仓库检测**:通过检查.git目录判断是否为Git仓库,避免不必要的git init调用
|
|
15
|
+
- **自动仓库初始化**:在非Git目录中自动执行git init
|
|
16
|
+
- **现有仓库保护**:检测到已存在.git目录时跳过初始化,防止破坏现有仓库
|
|
17
|
+
- **统一错误处理**:完善的错误处理和日志记录机制
|
|
18
|
+
- **健壮的状态检查**:改进的仓库状态检测逻辑
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
## 📦 安装使用
|
|
17
21
|
|
|
22
|
+
### 全局安装(推荐)
|
|
18
23
|
```bash
|
|
19
|
-
npm install
|
|
24
|
+
npm install -g git-push-mcp
|
|
20
25
|
```
|
|
21
26
|
|
|
22
|
-
###
|
|
23
|
-
|
|
27
|
+
### 配置mcp.json文件:
|
|
24
28
|
```bash
|
|
25
|
-
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"git-push-mcp": {
|
|
32
|
+
"command": "node",
|
|
33
|
+
"args": [
|
|
34
|
+
"C:\\Program Files\\nodejs\\node_modules\\git-push-mcp\\mcp-server.js" // 替换为实际路径git-push-mcp本地安装路径
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
26
39
|
```
|
|
27
40
|
|
|
28
|
-
###
|
|
29
|
-
|
|
41
|
+
### 通义灵码智能体里输入代码提交
|
|
42
|
+

|
|
43
|
+

|
|
44
|
+

|
|
45
|
+
### 本地使用
|
|
30
46
|
```bash
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# 或者直接运行
|
|
35
|
-
node index.js
|
|
36
|
-
```
|
|
47
|
+
# 克隆项目
|
|
48
|
+
git clone <repository-url>
|
|
49
|
+
cd git-push-mcp
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
在交互模式下,你可以使用以下自然语言指令:
|
|
51
|
+
# 安装依赖
|
|
52
|
+
npm install
|
|
41
53
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
> 提交添加了登录功能
|
|
45
|
-
> commit fix bug in user authentication
|
|
46
|
-
> 把所有修改提交上去
|
|
54
|
+
# 运行
|
|
55
|
+
node index.js
|
|
47
56
|
```
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
> 查看当前状态
|
|
52
|
-
> status
|
|
53
|
-
> 有什么变化吗
|
|
54
|
-
```
|
|
58
|
+
## 💡 使用示例
|
|
55
59
|
|
|
56
|
-
###
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
> 把src目录加到暂存区
|
|
60
|
+
### 交互模式
|
|
61
|
+
```bash
|
|
62
|
+
git-push-mcp
|
|
63
|
+
# 然后输入自然语言命令
|
|
61
64
|
```
|
|
62
65
|
|
|
63
|
-
###
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
### 命令行模式
|
|
67
|
+
```bash
|
|
68
|
+
git-push-mcp "查看状态"
|
|
69
|
+
git-push-mcp "提交所有更改"
|
|
70
|
+
git-push-mcp "推送代码到远程"
|
|
68
71
|
```
|
|
69
72
|
|
|
70
|
-
###
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
### 支持的自然语言命令
|
|
74
|
+
- 查看状态 / status
|
|
75
|
+
- 提交所有更改 / commit all
|
|
76
|
+
- 推送代码 / push
|
|
77
|
+
- 查看提交历史 / history
|
|
78
|
+
- 切换分支 / checkout branch
|
|
79
|
+
- 创建新分支 / create branch
|
|
80
|
+
- 查看分支 / branches
|
|
76
81
|
|
|
77
82
|
## 配置选项
|
|
78
83
|
|
|
@@ -185,17 +190,38 @@ git-push-mcp/
|
|
|
185
190
|
2. **新增Git操作**:在 `git-operator.js` 中添加新的方法,并在 `mcp-handler.js` 中注册对应的处理器
|
|
186
191
|
3. **自定义提交类型**:修改 `nlp-processor.js` 中的 `commitTypes` 映射
|
|
187
192
|
|
|
188
|
-
##
|
|
193
|
+
## 🔒 权限要求
|
|
194
|
+
|
|
195
|
+
- 需要Git仓库的读写权限
|
|
196
|
+
- 需要执行Git命令的权限
|
|
197
|
+
- 建议在已初始化的Git仓库中使用
|
|
198
|
+
|
|
199
|
+
## 🐛 故障排除
|
|
200
|
+
|
|
201
|
+
### 常见问题
|
|
202
|
+
|
|
203
|
+
1. **权限被拒绝**
|
|
204
|
+
```bash
|
|
205
|
+
# 确保有足够的目录权限
|
|
206
|
+
chmod +x install.js
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
2. **Git命令失败**
|
|
210
|
+
```bash
|
|
211
|
+
# 确保Git已正确安装
|
|
212
|
+
git --version
|
|
213
|
+
git config --global user.name "Your Name"
|
|
214
|
+
git config --global user.email "your.email@example.com"
|
|
215
|
+
```
|
|
189
216
|
|
|
190
|
-
|
|
191
|
-
-
|
|
192
|
-
-
|
|
193
|
-
- 自动推送功能需谨慎使用
|
|
217
|
+
3. **仓库初始化问题**
|
|
218
|
+
- 工具会自动检测并初始化仓库
|
|
219
|
+
- 如遇权限问题,请手动初始化:`git init`
|
|
194
220
|
|
|
195
|
-
##
|
|
221
|
+
## 📄 许可证
|
|
196
222
|
|
|
197
|
-
|
|
223
|
+
MIT License
|
|
198
224
|
|
|
199
|
-
##
|
|
225
|
+
## 🤝 贡献
|
|
200
226
|
|
|
201
|
-
|
|
227
|
+
欢迎提交Issue和Pull Request来改进这个工具!
|