Back to Skills

merge-resolver

verified

自动合并所有已完成部分,解决冲突,验证集成。仅当执行管理器检测到所有部分完成时调用。

View on GitHub

Marketplace

plugin-market-marketplace

blueif16/amazing-claude-code-plugins

Plugin

infistack

automation

Repository

blueif16/amazing-claude-code-plugins

infistack/skills/merge-resolver/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/blueif16/amazing-claude-code-plugins/blob/main/infistack/skills/merge-resolver/SKILL.md -a claude-code --skill merge-resolver

Installation paths:

Claude
.claude/skills/merge-resolver/
Powered by add-skill CLI

Instructions

# 合并解决器 v2

**所有者:** 仅主协调器

## 职责

1. 接收所有已完成部分的列表
2. 按依赖顺序顺序合并每个部分
3. 自动解决可处理的冲突
4. 记录无法自动解决的冲突
5. 运行完整测试套件验证集成
6. 清理成功合并的 worktrees 和分支
7. 生成最终执行报告

## 触发条件

当 execution-manager 的监控循环检测到所有部分状态为 `completed` 或 `blocked` 时自动触发。

## 执行流程

### Phase 1: 准备和决策

```bash
# 切换到主分支
git checkout main
git pull origin main

# 获取所有已完成部分的分支列表
completed_sections=$(yq '.sections | to_entries | map(select(.value.status == "completed")) | .[].key' meta.yaml)
blocked_sections=$(yq '.sections | to_entries | map(select(.value.status == "blocked")) | .[].key' meta.yaml)

# 合并前先决条件检查
for section in $completed_sections; do
  branch="${project_name}/${section}"

  # 检查分支是否有提交(不仅仅是暂存的更改)
  if ! git log main..${branch} --oneline | grep -q .; then
    echo "⚠️ $section: 分支没有提交,跳过"
    continue
  fi

  # 验证没有 .task/ 文件将被合并
  if git diff main..${branch} --name-only | grep -q "^\.task/"; then
    echo "⚠️ $section: 包含 .task/ 文件,需要清理"
    continue
  fi
done

# 验证主分支状态干净
if ! git status --porcelain | grep -q "^$"; then
  echo "⚠️ 主分支有未提交的更改,先清理"
  exit 1
fi

# 如果有阻塞的部分,询问人工
if [ -n "$blocked_sections" ]; then
  echo "以下部分被阻塞: $blocked_sections"
  echo "是否继续合并已完成的部分? (y/n)"
  read -t 30 response || response="y"  # 30秒超时,默认继续

  if [ "$response" != "y" ]; then
    echo "合并已取消,等待人工处理阻塞部分"
    exit 0
  fi
fi
```

### Phase 2: 顺序合并(按依赖顺序)

```bash
project_name=$(yq '.project' meta.yaml)
merge_success=()
merge_conflicts=()

for section in $completed_sections; do
  branch="${project_name}/${section}"

  echo "正在合并: $section"

  # 预览变更
  git diff main..${branch} --stat

  # 尝试合并(使用 patience 算法获得更好的差异)
  if git merge -X patience ${branch} --no-ff -m "Merge ${section}: auto-merged by InfiStack"; then
    echo "✅ $section 合并成功"
    merge_success+=("$section")

    # 立即清理该 worktree 和分支
    git worktree remove ../worktrees/${section} --force 2>/dev/null || true
    git branch -d ${branch}

    # 更新 meta.yaml
    yq -i ".sections.${section}.merge_status = \"merged\"" meta.yaml
    yq -i ".sections.${section}.mer

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
8461 chars