The Problem
没有 gitmesh 时,
多 Agent 协作一团乱
多个 Agent 同时改一个仓库,三个最常见的麻烦。
工作区相互覆盖
共享目录里并行编码,文件互相踩踏,git 操作互相打断。
合并顺序混乱
完成时间不可预测,先合的可能冲突后合的。手动协调费时易错。
冲突无人解决
改同一文件产生冲突,上下文不全难定位,一个失败阻塞全流程。
How It Works
多 Agent 协作,
gitmesh 全自动编排
编排服务持有主仓库,为每个 Agent 创建独立 worktree,全程自动编排。
gitmesh orchestrator
repo: main
HEAD
a1b2c3d
merge engine active
conflict detected
src/auth.ts · 2 处冲突
→ routing to Agent B
Agent A · fix-auth
~/mesh/fix-auth
idle
Agent B · refactor-db
~/mesh/refactor-db
idle
Agent C · add-tests
~/mesh/add-tests
idle
Features
为多 Agent 协作
从头设计的 Git 编排层
不是 CI,不是 Agent 框架 — 只管多 Agent 的 git 操作。
多 Worktree 隔离
独立工作目录和分支,并行编码互不影响。
Rebase-First 合并
线性 git 历史,冲突在 worktree 内解决,不污染主干。
智能冲突路由
检测冲突,携带完整上下文路由回对应 Agent 自行解决。
重试循环
冲突解决后自动重试 rebase,直到成功或超限。
失败隔离
单 Agent 失败不阻塞其他,保留 worktree 供人工介入。
事件驱动观测
8 个 typed 事件覆盖全流程,实时观测进度和状态。
Quick Start
10 行代码,
启动多 Agent 协作
Claude SDK / Shell 脚本 / HTTP 回调 — 任意 Agent 实现均可接入。
import { gitmesh } from "gitmesh";
const session = await gitmesh({
cwd: "/path/to/repo",
strategy: "rebase-first",
agents: [
{
name: "fix-auth",
// worktree 就绪,Agent 开始编码
onReady: async (signal) => {
await runAgent({ cwd: signal.worktreePath });
signal.done();
},
// 冲突时路由给 Agent 自行解决
onConflict: async (conflict) => {
return runConflictResolver(conflict);
},
},
],
});
session.on("mesh:merged", (name, commit) => {
console.log(`merged: ${name}`);
});
const summary = await session.done();