pr-feedback-classifier
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR Feedback Classifier
PR 反馈分类器
Fetch and classify all PR review feedback for the current branch's PR.
拉取并分类当前分支对应PR的所有评审反馈。
Arguments
参数
- : Target a specific PR by number (default: current branch's PR)
--pr <number> - : Include resolved threads (for reference)
--include-resolved
Check for flags.
$ARGUMENTS- :通过编号指定目标PR(默认值:当前分支对应的PR)
--pr <number> - :包含已解决的讨论线程(供参考)
--include-resolved
可查看获取所有可用参数标识。
$ARGUMENTSCritical 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
操作步骤
-
Fetch PR info and all comments in a single call:bash
erk exec get-pr-feedback [--pr <number>] [--include-resolved]Passif specified in--pr <number>. Pass$ARGUMENTSif specified in--include-resolved.$ARGUMENTSThis returns JSON with,pr_number,pr_title,pr_url, andreview_threads.discussion_commentsAlso fetch file-level restructuring context:bashgit diff --stat -M -C main...HEADThis reveals renames, copies, and splits. Use this to inform pre-existing detection in step 2. -
Classify each comment using the Comment Classification Model below.
-
Group into batches by complexity.
-
Output structured JSON (schema below).
-
单次调用拉取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字段的JSON数据。discussion_comments同时拉取文件级别的重构上下文:bashgit diff --stat -M -C main...HEAD该命令可以展示文件重命名、复制和拆分的情况。在步骤2的存量问题检测中可参考该信息。 -
使用下方的评论分类模型对每条评论进行分类。
-
按复杂度分组为不同批次。
-
输出结构化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 , regardless of whether it's from a bot or human. The field distinguishes how the user should handle it.
actionable_threadsclassificationDiscussion comments that are purely informational (CI status updates, Graphite stack comments, PR description summaries) are still counted in and do NOT appear in .
informational_countactionable_threads分类决定了线程如何展示给用户,而非是否展示。
- 可执行:要求代码修改、需要修复的违规问题、缺失的测试、要求更新文档、机器人建议添加测试、机器人给出的样式/重构建议(可选/建议执行)
- 告知类:CI生成的样式建议、评审线程中的确认类回复
重要提示: 所有未解决的评审线程都会归入,无论它来自机器人还是人类。字段用于区分用户应该如何处理该线程。
actionable_threadsclassification纯告知类的讨论评论(CI状态更新、Graphite栈评论、PR描述摘要)会被计入,不会出现在中。
informational_countactionable_threadsPre-Existing Detection
存量问题检测
For each thread in , determine the field:
actionable_threadspre_existing-
when ALL of:
pre_existing: true- Author is a bot (suffix)
[bot] - PR involves file restructuring (renames, splits, moves visible in )
git diff --stat -M -C - The flagged pattern would have been equally flaggable in the original file location (generic code quality issue, not specific to the restructuring)
- Author is a bot (
-
when ANY of:
pre_existing: false- Author is human
- The issue is specifically caused by the restructuring (e.g., in a new
__all__, new import paths)__init__.py - No restructuring detected in the PR
对中的每个线程,确定字段的值:
actionable_threadspre_existing-
需要同时满足以下所有条件:
pre_existing: true- 作者是机器人(带后缀)
[bot] - PR包含文件重构(的结果中可见重命名、拆分、移动操作)
git diff --stat -M -C - 被标记的问题在原文件位置也会被标记(属于通用代码质量问题,不是重构特有的问题)
- 作者是机器人(带
-
满足以下任意一个条件即可:
pre_existing: false- 作者是人类
- 问题是重构特有的(比如新中的
__init__.py配置、新的导入路径)__all__ - PR中未检测到重构操作
Complexity
复杂度
- : Single line change at specified location
local - : Multiple changes in one file
single_file - : Changes across multiple files
cross_cutting - : Architectural changes or related refactoring needed
complex
- :指定位置的单行修改
local - :单个文件内的多处修改
single_file - :跨多个文件的修改
cross_cutting - :需要架构调整或相关重构
complex
Batch Ordering
批次排序
- Pre-Existing (Auto-Resolve) (auto_proceed: true): Pre-existing issues in moved/restructured code ()
pre_existing: true - Local Fixes (auto_proceed: true): Single-line changes
- Single-File (auto_proceed: true): Multi-location in one file
- Cross-Cutting (auto_proceed: false): Multiple files
- Complex (auto_proceed: false): Architectural changes
- Informational (auto_proceed: false): Threads classified as — user decides to act or dismiss
informational
- 存量问题(自动解决)(auto_proceed: true):移动/重构代码中的存量问题()
pre_existing: true - 本地修复(auto_proceed: true):单行修改
- 单文件修改(auto_proceed: true):单个文件内的多处修改
- 跨文件修改(auto_proceed: false):涉及多个文件
- 复杂修改(auto_proceed: false):架构调整
- 告知类(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:
- : The ID needed for
thread_iderk exec resolve-review-thread - : The ID needed for
comment_iderk exec reply-to-discussion-comment - :
classificationor"actionable"— determines how the user handles the thread"informational" - :
pre_existingif the issue existed before this PR (bot comment on moved/restructured code). Pre-existing threads usetrueand are placed in the first batch for auto-resolutioncomplexity: "pre_existing" - : References into
item_indices(type=review) oractionable_threads(type=discussion)discussion_actions - : First 200 characters of the comment text
original_comment - : Count of informational discussion comments only (CI status, Graphite stack). Review threads always appear individually in
informational_countwith aactionable_threadsfieldclassification
仅输出以下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所需的IDerk exec resolve-review-thread - :执行
comment_id所需的IDerk exec reply-to-discussion-comment - :
classification或"actionable"— 决定用户如何处理该线程"informational" - :如果问题在本次PR之前就已经存在(移动/重构代码上的机器人评论)则为
pre_existing。存量问题线程的true为complexity,会被归入第一个批次自动解决"pre_existing" - :指向
item_indices(类型=review)或actionable_threads(类型=discussion)的索引discussion_actions - :评论文本的前200个字符
original_comment - :仅统计告知类讨论评论的数量(CI状态、Graphite栈)。评审线程都会单独出现在
informational_count中,并带有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
}