gemini-review-integrator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gemini Review Integrator

Gemini评审整合工具

Integrate Gemini Code Assist review suggestions into the pr-review-and-document PR comment.
将Gemini Code Assist的评审建议整合到pr-review-and-document的PR评论中。

When to Use

使用场景

Invoke this skill when:
  • A PR has both Gemini Code Assist reviews and a pr-review-and-document comment
  • Need to consolidate all review feedback into a single location
  • Want to track Gemini suggestions alongside Claude's PR review
当以下情况时调用此Skill:
  • PR同时包含Gemini Code Assist评审和pr-review-and-document评论
  • 需要将所有评审反馈整合到单一位置
  • 希望将Gemini建议与Claude的PR评审一起跟踪

Workflow

工作流

Step 1: Get PR Number and Verify Prerequisites (Cache-Aware)

步骤1:获取PR编号并验证前提条件(支持缓存)

bash
PR_NUMBER=$("${CLAUDE_PLUGIN_ROOT}/scripts/get-pr-number.sh")
This uses the branch-to-PR-number cache (
branch-map.json
) with 1-hour TTL, falling back to GitHub API on cache miss.
If no PR exists, inform the user and stop.
Verify pr-review-and-document comment exists:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/find-review-comment.sh "$PR_NUMBER"
If no review comment exists, inform the user to run
pr-review-and-document
skill first.
bash
PR_NUMBER=$("${CLAUDE_PLUGIN_ROOT}/scripts/get-pr-number.sh")
这会使用分支到PR编号的缓存(
branch-map.json
),TTL为1小时,缓存未命中时回退到GitHub API。
如果不存在PR,通知用户并停止操作。
验证pr-review-and-document评论是否存在:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/find-review-comment.sh "$PR_NUMBER"
如果没有评审评论,通知用户先运行
pr-review-and-document
Skill。

Step 2: Fetch Gemini Code Assist Comments

步骤2:获取Gemini Code Assist评论

Fetch all PR review comments (inline code comments):
bash
${CLAUDE_PLUGIN_ROOT}/scripts/fetch-gemini-comments.sh "$PR_NUMBER"
The script returns JSON with Gemini suggestions, including:
  • id
    : Comment ID for deduplication
  • priority
    : high, medium, or low
  • is_security
    : Whether it's a security issue
  • is_outdated
    : Whether the comment is outdated (code changed)
  • file
    : File path
  • line
    : Line number (null if file-level)
  • body
    : Full comment body
  • suggestion
    : Extracted code suggestion (if any)
获取所有PR评审评论(内联代码评论):
bash
${CLAUDE_PLUGIN_ROOT}/scripts/fetch-gemini-comments.sh "$PR_NUMBER"
该脚本返回包含Gemini建议的JSON,包括:
  • id
    :用于去重的评论ID
  • priority
    :高、中或低
  • is_security
    :是否为安全问题
  • is_outdated
    :评论是否过时(代码已更改)
  • file
    :文件路径
  • line
    :行号(如果是文件级评论则为null)
  • body
    :完整评论内容
  • suggestion
    :提取的代码建议(如果有)

Step 3: Filter and Deduplicate

步骤3:过滤与去重

Apply filters to Gemini suggestions:
  1. Exclude outdated comments: Skip comments where
    is_outdated: true
  2. Check existing integration: Parse pr-review-and-document comment metadata for
    gemini_integrated_ids
  3. Skip already integrated: Exclude comments whose IDs are in
    gemini_integrated_ids
对Gemini建议应用以下过滤规则:
  1. 排除过时评论:跳过
    is_outdated: true
    的评论
  2. 检查已整合记录:解析pr-review-and-document评论元数据中的
    gemini_integrated_ids
  3. 跳过已整合内容:排除ID在
    gemini_integrated_ids
    中的评论

Step 4: Categorize Suggestions

步骤4:建议分类

Map Gemini priorities to pr-review-and-document categories:
Gemini PriorityPR Review Category
high
+
is_security
🔴 Critical Issues
high
🟡 Important Issues
medium
+
is_security
🟡 Important Issues
medium
💡 Suggestions
low
💡 Suggestions
将Gemini优先级映射到pr-review-and-document的分类:
Gemini优先级PR评审分类
high
+
is_security
🔴 关键问题
high
🟡 重要问题
medium
+
is_security
🟡 重要问题
medium
💡 建议
low
💡 建议

Step 5: Format Integrated Suggestions

步骤5:格式化整合后的建议

For each new Gemini suggestion, format as:
markdown
<details>
<summary><b>N. ⚠️ [Gemini] Issue Title</b></summary>

**Source:** Gemini Code Assist
**File:** `path/to/file.ts:line`

**Problem:** Description from Gemini comment.

**Suggested Fix:**
```suggestion
code here
</details> ```
Key formatting rules:
  • Prefix title with
    [Gemini]
    to identify source
  • Use
    ⚠️
    status indicator (pending review)
  • Include
    **Source:** Gemini Code Assist
    line
  • Preserve Gemini's suggestion code block if present
每个新的Gemini建议按以下格式处理:
markdown
<details>
<summary><b>N. ⚠️ [Gemini] 问题标题</b></summary>

**来源:** Gemini Code Assist
**文件:** `path/to/file.ts:line`

**问题描述:** Gemini评论中的描述内容。

**建议修复方案:**
```suggestion
代码内容
</details> ```
关键格式规则:
  • 标题前缀添加
    [Gemini]
    以标识来源
  • 使用
    ⚠️
    状态指示器(待评审)
  • 包含
    **来源:** Gemini Code Assist
  • 保留Gemini的建议代码块(如果存在)

Step 6: Update PR Review Comment

步骤6:更新PR评审评论

  1. Fetch existing pr-review-and-document comment body
  2. Parse metadata JSON from
    <!-- pr-review-metadata ... -->
    block
  3. Update metadata:
    • Add
      gemini_integrated_ids
      array with newly integrated comment IDs
    • Increment issue counts in
      issues
      object
    • Update
      updated_at
      timestamp
  4. Insert new Gemini issues into appropriate sections (Critical, Important, Suggestions)
  5. Renumber existing issues to accommodate new entries
Pipe updated content to
cache-write-comment.sh
via
--stdin
:
bash
echo "$UPDATED_CONTENT" | ${CLAUDE_PLUGIN_ROOT}/scripts/cache-write-comment.sh --stdin "$PR_NUMBER"
This updates local cache and syncs to GitHub in one step, without temp files.
  1. 获取现有的pr-review-and-document评论内容
  2. 解析
    <!-- pr-review-metadata ... -->
    块中的元数据JSON
  3. 更新元数据:
    • 添加
      gemini_integrated_ids
      数组,包含新整合的评论ID
    • 递增
      issues
      对象中的问题计数
    • 更新
      updated_at
      时间戳
  4. 将新的Gemini问题插入到对应的分类部分(关键问题、重要问题、建议)
  5. 重新编号现有问题以容纳新条目
通过
--stdin
将更新后的内容传递给
cache-write-comment.sh
bash
echo "$UPDATED_CONTENT" | ${CLAUDE_PLUGIN_ROOT}/scripts/cache-write-comment.sh --stdin "$PR_NUMBER"
这会一步更新本地缓存并同步到GitHub,无需临时文件。

Step 7: Report Integration Results

步骤7:报告整合结果

Summarize what was integrated:
Gemini Review Integration Complete:
- Found: X Gemini comments
- Outdated (skipped): Y
- Already integrated (skipped): Z
- Newly integrated: W
  - Critical: A
  - Important: B
  - Suggestions: C
总结整合内容:
Gemini评审整合完成:
- 发现: X条Gemini评论
- 已过时(已跳过): Y条
- 已整合(已跳过): Z条
- 新整合: W条
  - 关键问题: A条
  - 重要问题: B条
  - 建议: C条

Metadata Schema Extension

元数据扩展 schema

The pr-review-and-document metadata is extended with:
json
{
  "gemini_integrated_ids": [2726014213, 2726014217, ...],
  "gemini_integration_date": "2026-01-26T12:00:00Z"
}
This enables:
  • Tracking which Gemini comments have been integrated
  • Preventing duplicate integration across multiple runs
  • Audit trail for integrated suggestions
pr-review-and-document的元数据扩展如下:
json
{
  "gemini_integrated_ids": [2726014213, 2726014217, ...],
  "gemini_integration_date": "2026-01-26T12:00:00Z"
}
这实现了:
  • 跟踪哪些Gemini评论已被整合
  • 防止多次运行时重复整合
  • 为整合的建议提供审计追踪

Gemini Comment Structure

Gemini评论结构

Gemini Code Assist comments have these characteristics:
Priority Indicators (in body):
  • ![high](...)
    - High priority
  • ![medium](...)
    - Medium priority
  • ![security-medium](...)
    or
    ![security-high](...)
    - Security-related
Outdated Detection:
  • GitHub API field
    position: null
    indicates the code has changed
  • These comments should be skipped as they may no longer apply
Code Suggestions:
  • Enclosed in ````suggestion` blocks
  • Should be preserved in integration
Gemini Code Assist评论具有以下特征:
优先级指示器(在内容中):
  • ![high](...)
    - 高优先级
  • ![medium](...)
    - 中优先级
  • ![security-medium](...)
    ![security-high](...)
    - 安全相关
过时检测:
  • GitHub API字段
    position: null
    表示代码已更改
  • 这些评论应被跳过,因为可能不再适用
代码建议:
  • 包裹在````suggestion`块中
  • 整合时应保留

Handling Multiple Gemini Review Rounds

处理多轮Gemini评审

Gemini may perform multiple review rounds on a PR. The integration handles this by:
  1. ID-based deduplication: Each comment has a unique ID
  2. Cumulative tracking:
    gemini_integrated_ids
    grows with each integration
  3. New comments only: Only comments not in
    gemini_integrated_ids
    are processed
To re-integrate after Gemini runs another review:
  1. Run this skill again
  2. Only new comments will be added
  3. Previously integrated comments remain unchanged
Gemini可能会对PR进行多轮评审。本整合工具通过以下方式处理:
  1. 基于ID的去重: 每个评论都有唯一ID
  2. 累积跟踪:
    gemini_integrated_ids
    随每次整合增长
  3. 仅处理新评论: 仅处理不在
    gemini_integrated_ids
    中的评论
在Gemini完成新一轮评审后重新整合:
  1. 再次运行此Skill
  2. 仅添加新评论
  3. 已整合的评论保持不变

Status Indicators for Gemini Issues

Gemini问题的状态指示器

IndicatorMeaning
⚠️Pending review (newly integrated from Gemini)
Fixed / Resolved
⏭️Deferred / Not applicable
🔴Escalated to blocking
Initial status for all Gemini integrations is
⚠️
(pending review).
指示器含义
⚠️待评审(从Gemini新整合的内容)
已修复/已解决
⏭️已推迟/不适用
🔴升级为阻塞问题
所有Gemini整合内容的初始状态为
⚠️
(待评审)。

Example Integration

整合示例

Before (pr-review-and-document comment):
markdown
undefined
整合前(pr-review-and-document评论):
markdown
undefined

🟡 Important Issues

🟡 重要问题

<details> <summary><b>1. ✅ Some Claude-found issue</b></summary> ... </details> ```
After integration:
markdown
undefined
<details> <summary><b>1. ✅ 某个Claude发现的问题</b></summary> ... </details> ```
整合后:
markdown
undefined

🟡 Important Issues

🟡 重要问题

<details> <summary><b>1. ✅ Some Claude-found issue</b></summary> ... </details> <details> <summary><b>2. ⚠️ [Gemini] Suppress stderr hides errors</b></summary>
Source: Gemini Code Assist File:
.claude/skills/pr-review-and-document/scripts/find-review-comment.sh:19
Problem: Suppressing stderr with
2>/dev/null
can hide important underlying errors.
Suggested Fix:
suggestion
  PR_NUMBER=$(gh pr view --json number -q '.number' || echo "")
</details> ```
<details> <summary><b>1. ✅ 某个Claude发现的问题</b></summary> ... </details> <details> <summary><b>2. ⚠️ [Gemini] 抑制stderr会隐藏错误</b></summary>
来源: Gemini Code Assist 文件:
.claude/skills/pr-review-and-document/scripts/find-review-comment.sh:19
问题描述: 使用
2>/dev/null
抑制stderr会隐藏重要的底层错误。
建议修复方案:
suggestion
  PR_NUMBER=$(gh pr view --json number -q '.number' || echo "")
</details> ```

Validation Checklist

验证检查清单

Before completing integration:
  • PR number correctly identified
  • pr-review-and-document comment exists
  • Gemini comments fetched successfully
  • Outdated comments filtered out
  • Previously integrated comments skipped
  • New comments categorized correctly
  • Metadata updated with integrated IDs
  • Issue counts updated accurately
  • Comment posted successfully
完成整合前需确认:
  • PR编号已正确识别
  • pr-review-and-document评论存在
  • Gemini评论已成功获取
  • 过时评论已过滤
  • 已整合评论已跳过
  • 新评论已正确分类
  • 元数据已更新整合ID
  • 问题计数已准确更新
  • 评论已成功发布

Error Handling

错误处理

ErrorAction
No PR foundInform user, stop
No review commentSuggest running pr-review-and-document first
No Gemini commentsInform user, nothing to integrate
API failureReport error with details
All comments outdatedInform user, nothing to integrate
All comments already integratedInform user, up to date
错误处理动作
未找到PR通知用户,停止操作
无评审评论建议先运行pr-review-and-document
无Gemini评论通知用户,无内容可整合
API调用失败报告错误详情
所有评论均过时通知用户,无内容可整合
所有评论均已整合通知用户,内容已最新