pr-feedback-classifier

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PR Feedback Classifier

PR 反馈分类器

Fetch and classify all PR review feedback for the current branch's PR.
拉取并分类当前分支对应PR的所有评审反馈。

Arguments

参数

  • --pr <number>
    : Target a specific PR by number (default: current branch's PR)
  • --include-resolved
    : Include resolved threads (for reference)
Check
$ARGUMENTS
for flags.
  • --pr <number>
    :通过编号指定目标PR(默认值:当前分支对应的PR)
  • --include-resolved
    :包含已解决的讨论线程(供参考)
可查看
$ARGUMENTS
获取所有可用参数标识。

Critical Constraints

关键约束

DO NOT write Python scripts or any code files. Classify the data using direct AI reasoning only. Writing code to process JSON is unnecessary and pollutes the filesystem.
严禁编写Python脚本或任何代码文件。仅通过AI直接推理完成数据分类。编写代码处理JSON完全没有必要,还会污染文件系统。

Steps

操作步骤

  1. Fetch PR info and all comments in a single call:
    bash
    erk exec get-pr-feedback [--pr <number>] [--include-resolved]
    Pass
    --pr <number>
    if specified in
    $ARGUMENTS
    . Pass
    --include-resolved
    if specified in
    $ARGUMENTS
    .
    This returns JSON with
    pr_number
    ,
    pr_title
    ,
    pr_url
    ,
    review_threads
    , and
    discussion_comments
    .
    Also fetch file-level restructuring context:
    bash
    git diff --stat -M -C main...HEAD
    This reveals renames, copies, and splits. Use this to inform pre-existing detection in step 2.
  2. Classify each comment using the Comment Classification Model below.
  3. Group into batches by complexity.
  4. Output structured JSON (schema below).
  1. 单次调用拉取PR信息和所有评论:
    bash
    erk exec get-pr-feedback [--pr <number>] [--include-resolved]
    如果
    $ARGUMENTS
    中指定了
    --pr <number>
    则传入该参数。如果
    $ARGUMENTS
    中指定了
    --include-resolved
    则传入该参数。
    该命令会返回包含
    pr_number
    pr_title
    pr_url
    review_threads
    discussion_comments
    字段的JSON数据。
    同时拉取文件级别的重构上下文:
    bash
    git diff --stat -M -C main...HEAD
    该命令可以展示文件重命名、复制和拆分的情况。在步骤2的存量问题检测中可参考该信息。
  2. 使用下方的评论分类模型对每条评论进行分类
  3. 按复杂度分组为不同批次
  4. 输出结构化JSON(结构见下文)。

Comment Classification Model

评论分类模型

For each comment, determine:
对每条评论,需要确定以下属性:

Classification

分类

Classification determines how the thread is presented to the user, not whether it appears.
  • Actionable: Code changes requested, violations to fix, missing tests, documentation updates requested, bot suggestions to add tests, bot style/refactoring suggestions (optional/could)
  • Informational: CI-generated style suggestions, acknowledgments on review threads
Important: Every unresolved review thread goes into
actionable_threads
, regardless of whether it's from a bot or human. The
classification
field distinguishes how the user should handle it.
Discussion comments that are purely informational (CI status updates, Graphite stack comments, PR description summaries) are still counted in
informational_count
and do NOT appear in
actionable_threads
.
分类决定了线程如何展示给用户,而非是否展示。
  • 可执行:要求代码修改、需要修复的违规问题、缺失的测试、要求更新文档、机器人建议添加测试、机器人给出的样式/重构建议(可选/建议执行)
  • 告知类:CI生成的样式建议、评审线程中的确认类回复
重要提示: 所有未解决的评审线程都会归入
actionable_threads
,无论它来自机器人还是人类。
classification
字段用于区分用户应该如何处理该线程。
纯告知类的讨论评论(CI状态更新、Graphite栈评论、PR描述摘要)会被计入
informational_count
,不会出现在
actionable_threads
中。

Pre-Existing Detection

存量问题检测

For each thread in
actionable_threads
, determine the
pre_existing
field:
  • pre_existing: true
    when ALL of:
    1. Author is a bot (
      [bot]
      suffix)
    2. PR involves file restructuring (renames, splits, moves visible in
      git diff --stat -M -C
      )
    3. The flagged pattern would have been equally flaggable in the original file location (generic code quality issue, not specific to the restructuring)
  • pre_existing: false
    when ANY of:
    • Author is human
    • The issue is specifically caused by the restructuring (e.g.,
      __all__
      in a new
      __init__.py
      , new import paths)
    • No restructuring detected in the PR
actionable_threads
中的每个线程,确定
pre_existing
字段的值:
  • pre_existing: true
    需要同时满足以下所有条件:
    1. 作者是机器人(带
      [bot]
      后缀)
    2. PR包含文件重构(
      git diff --stat -M -C
      的结果中可见重命名、拆分、移动操作)
    3. 被标记的问题在原文件位置也会被标记(属于通用代码质量问题,不是重构特有的问题)
  • pre_existing: false
    满足以下任意一个条件即可:
    • 作者是人类
    • 问题是重构特有的(比如新
      __init__.py
      中的
      __all__
      配置、新的导入路径)
    • PR中未检测到重构操作

Complexity

复杂度

  • local
    : Single line change at specified location
  • single_file
    : Multiple changes in one file
  • cross_cutting
    : Changes across multiple files
  • complex
    : Architectural changes or related refactoring needed
  • local
    :指定位置的单行修改
  • single_file
    :单个文件内的多处修改
  • cross_cutting
    :跨多个文件的修改
  • complex
    :需要架构调整或相关重构

Batch Ordering

批次排序

  1. Pre-Existing (Auto-Resolve) (auto_proceed: true): Pre-existing issues in moved/restructured code (
    pre_existing: true
    )
  2. Local Fixes (auto_proceed: true): Single-line changes
  3. Single-File (auto_proceed: true): Multi-location in one file
  4. Cross-Cutting (auto_proceed: false): Multiple files
  5. Complex (auto_proceed: false): Architectural changes
  6. Informational (auto_proceed: false): Threads classified as
    informational
    — user decides to act or dismiss
  1. 存量问题(自动解决)(auto_proceed: true):移动/重构代码中的存量问题(
    pre_existing: true
  2. 本地修复(auto_proceed: true):单行修改
  3. 单文件修改(auto_proceed: true):单个文件内的多处修改
  4. 跨文件修改(auto_proceed: false):涉及多个文件
  5. 复杂修改(auto_proceed: false):架构调整
  6. 告知类(auto_proceed: false):分类为
    informational
    的线程 — 用户自行决定处理或忽略

Output Format

输出格式

Output ONLY the following JSON (no prose, no markdown, no code fences):
json
{
  "success": true,
  "pr_number": 5944,
  "pr_title": "Feature: Add new API endpoint",
  "pr_url": "https://github.com/owner/repo/pull/5944",
  "actionable_threads": [
    {
      "thread_id": "PRRT_kwDOPxC3hc5q73Ne",
      "type": "review",
      "path": "src/api.py",
      "line": 42,
      "is_outdated": false,
      "classification": "actionable",
      "pre_existing": false,
      "action_summary": "Add integration tests for new endpoint",
      "complexity": "local",
      "original_comment": "This needs integration tests"
    },
    {
      "thread_id": "PRRT_kwDOPxC3hc5q73Nf",
      "type": "review",
      "path": "src/api.py",
      "line": 55,
      "is_outdated": false,
      "classification": "actionable",
      "pre_existing": true,
      "action_summary": "Bot suggestion: add unit tests for error handling paths",
      "complexity": "pre_existing",
      "original_comment": "Consider adding unit tests for the error handling paths in this endpoint"
    }
  ],
  "discussion_actions": [
    {
      "comment_id": 12345678,
      "action_summary": "Update API documentation",
      "complexity": "cross_cutting",
      "original_comment": "Please update the docs to reflect..."
    }
  ],
  "informational_count": 12,
  "batches": [
    {
      "name": "Pre-Existing (Auto-Resolve)",
      "complexity": "pre_existing",
      "auto_proceed": true,
      "item_indices": [1]
    },
    {
      "name": "Local Fixes",
      "complexity": "local",
      "auto_proceed": true,
      "item_indices": [0]
    },
    {
      "name": "Single-File",
      "complexity": "single_file",
      "auto_proceed": true,
      "item_indices": []
    },
    {
      "name": "Cross-Cutting",
      "complexity": "cross_cutting",
      "auto_proceed": false,
      "item_indices": []
    }
  ],
  "error": null
}
Field notes:
  • thread_id
    : The ID needed for
    erk exec resolve-review-thread
  • comment_id
    : The ID needed for
    erk exec reply-to-discussion-comment
  • classification
    :
    "actionable"
    or
    "informational"
    — determines how the user handles the thread
  • pre_existing
    :
    true
    if the issue existed before this PR (bot comment on moved/restructured code). Pre-existing threads use
    complexity: "pre_existing"
    and are placed in the first batch for auto-resolution
  • item_indices
    : References into
    actionable_threads
    (type=review) or
    discussion_actions
    (type=discussion)
  • original_comment
    : First 200 characters of the comment text
  • informational_count
    : Count of informational discussion comments only (CI status, Graphite stack). Review threads always appear individually in
    actionable_threads
    with a
    classification
    field
仅输出以下JSON(无额外文字、无Markdown格式、无代码围栏):
json
{
  "success": true,
  "pr_number": 5944,
  "pr_title": "Feature: Add new API endpoint",
  "pr_url": "https://github.com/owner/repo/pull/5944",
  "actionable_threads": [
    {
      "thread_id": "PRRT_kwDOPxC3hc5q73Ne",
      "type": "review",
      "path": "src/api.py",
      "line": 42,
      "is_outdated": false,
      "classification": "actionable",
      "pre_existing": false,
      "action_summary": "Add integration tests for new endpoint",
      "complexity": "local",
      "original_comment": "This needs integration tests"
    },
    {
      "thread_id": "PRRT_kwDOPxC3hc5q73Nf",
      "type": "review",
      "path": "src/api.py",
      "line": 55,
      "is_outdated": false,
      "classification": "actionable",
      "pre_existing": true,
      "action_summary": "Bot suggestion: add unit tests for error handling paths",
      "complexity": "pre_existing",
      "original_comment": "Consider adding unit tests for the error handling paths in this endpoint"
    }
  ],
  "discussion_actions": [
    {
      "comment_id": 12345678,
      "action_summary": "Update API documentation",
      "complexity": "cross_cutting",
      "original_comment": "Please update the docs to reflect..."
    }
  ],
  "informational_count": 12,
  "batches": [
    {
      "name": "Pre-Existing (Auto-Resolve)",
      "complexity": "pre_existing",
      "auto_proceed": true,
      "item_indices": [1]
    },
    {
      "name": "Local Fixes",
      "complexity": "local",
      "auto_proceed": true,
      "item_indices": [0]
    },
    {
      "name": "Single-File",
      "complexity": "single_file",
      "auto_proceed": true,
      "item_indices": []
    },
    {
      "name": "Cross-Cutting",
      "complexity": "cross_cutting",
      "auto_proceed": false,
      "item_indices": []
    }
  ],
  "error": null
}
字段说明:
  • thread_id
    :执行
    erk exec resolve-review-thread
    所需的ID
  • comment_id
    :执行
    erk exec reply-to-discussion-comment
    所需的ID
  • classification
    "actionable"
    "informational"
    — 决定用户如何处理该线程
  • pre_existing
    :如果问题在本次PR之前就已经存在(移动/重构代码上的机器人评论)则为
    true
    。存量问题线程的
    complexity
    "pre_existing"
    ,会被归入第一个批次自动解决
  • item_indices
    :指向
    actionable_threads
    (类型=review)或
    discussion_actions
    (类型=discussion)的索引
  • original_comment
    :评论文本的前200个字符
  • informational_count
    :仅统计告知类讨论评论的数量(CI状态、Graphite栈)。评审线程都会单独出现在
    actionable_threads
    中,并带有
    classification
    字段

Error Case

错误场景

If no PR exists for the branch or API fails:
json
{
  "success": false,
  "pr_number": null,
  "pr_title": null,
  "pr_url": null,
  "actionable_threads": [],
  "discussion_actions": [],
  "informational_count": 0,
  "batches": [],
  "error": "No PR found for branch feature-xyz"
}
如果当前分支没有对应的PR或者API调用失败:
json
{
  "success": false,
  "pr_number": null,
  "pr_title": null,
  "pr_url": null,
  "actionable_threads": [],
  "discussion_actions": [],
  "informational_count": 0,
  "batches": [],
  "error": "No PR found for branch feature-xyz"
}

No Comments Case

无评论场景

If PR exists but has no unresolved comments:
json
{
  "success": true,
  "pr_number": 5944,
  "pr_title": "Feature: Add new API endpoint",
  "pr_url": "https://github.com/owner/repo/pull/5944",
  "actionable_threads": [],
  "discussion_actions": [],
  "informational_count": 0,
  "batches": [],
  "error": null
}
如果PR存在但没有未解决的评论:
json
{
  "success": true,
  "pr_number": 5944,
  "pr_title": "Feature: Add new API endpoint",
  "pr_url": "https://github.com/owner/repo/pull/5944",
  "actionable_threads": [],
  "discussion_actions": [],
  "informational_count": 0,
  "batches": [],
  "error": null
}