feat: git 工具升级为全操作支持(16 个子操作)

git 工具支持的操作:
- status: 查看状态(分支/修改/暂存/未追踪/删除/重命名)
- log: 提交历史
- diff: 差异查看(支持 staged)
- add: 暂存文件
- commit: 提交
- push/pull: 推送/拉取
- branch: 列出/创建/删除分支
- checkout: 切换分支
- merge: 合并分支
- stash: 暂存更改
- remote: 查看/添加远程仓库
- clone: 克隆仓库
- init: 初始化仓库
- reset: 重置
- tag: 标签管理

全部自动执行,无需用户确认
This commit is contained in:
OpenClaw Agent
2026-04-16 09:55:33 +08:00
parent 396100335a
commit 80158cb5bf
4 changed files with 213 additions and 40 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ import {
handleDiffFiles,
handleReplaceInFiles,
handleReadMultipleFiles,
handleGitStatus,
handleGit,
handleCompress
} from './tool-handlers.js';
import { getAllowedDirs, getBlockedDirs, setAllowedDirs } from './tool-security.js';
@@ -132,7 +132,7 @@ export function setupIPC(): void {
case 'diff_files': return await handleDiffFiles(args as { file1: string; file2: string; context_lines?: number });
case 'replace_in_files': return await handleReplaceInFiles(args as { path: string; glob: string; old_text: string; new_text: string });
case 'read_multiple_files':return await handleReadMultipleFiles(args as { paths: string[]; max_chars_per_file?: number });
case 'git_status': return await handleGitStatus(args as { path?: string });
case 'git': return await handleGit(args as any);
case 'compress': return await handleCompress(args as { action: string; path: string; destination?: string; format?: string });
default: return { success: false, error: `未知工具: ${toolName}` };
}