name: pr-feedback-classifier description: > 获取并分类PR审查反馈,具有上下文隔离。 返回带有线程ID的结构化JSON以便确定性解决。 在解决PR评论前分析时使用。 argument-hint: “[–pr <number>] [–include-resolved]” context: fork agent: general-purpose model: sonnet
PR反馈分类器
获取和分类当前分支PR的所有审查反馈。
参数
--pr <number>: 指定PR号(默认:当前分支的PR)--include-resolved: 包含已解决的线程(供参考)
检查 $ARGUMENTS 获取标志。
步骤
-
获取当前分支和PR信息:
-
如果在
$ARGUMENTS中指定了--pr <number>:gh pr view <number> --json number,title,url -q '{number: .number, title: .title, url: .url}' -
如果未指定
--pr(使用当前分支):git rev-parse --abbrev-ref HEAD gh pr view --json number,title,url -q '{number: .number, title: .title, url: .url}'
-
-
获取所有评论:
# 如果 $ARGUMENTS 中包含 --include-resolved: erk exec get-pr-review-comments [--pr <number>] --include-resolved # 否则: erk exec get-pr-review-comments [--pr <number>] erk exec get-pr-discussion-comments [--pr <number>]注意:当在 $ARGUMENTS 中指定时,传递
--pr <number>给两个exec命令。 -
使用下面的评论分类模型对每个评论进行分类。
-
按复杂性分组为批次。
-
输出结构化JSON(下面的模式)。
评论分类模型
对于每个评论,确定:
分类
分类决定线程如何呈现给用户,而不是是否出现。
- 可操作的:请求代码更改、需要修复的违规、缺失的测试、请求文档更新
- 信息性的:机器人建议(可选/可能)、CI生成的样式建议、审查线程上的确认
重要: 每个未解决的审查线程都进入 actionable_threads,无论来自机器人还是人类。classification 字段区分用户应如何处理。
纯粹信息性的讨论评论(CI状态更新、Graphite堆栈评论、PR描述摘要)仍计入 informational_count,并且不出现在 actionable_threads 中。
复杂性
local:指定位置的单行更改single_file:一个文件中的多个更改cross_cutting:跨多个文件的更改complex:需要架构更改或相关重构
批次排序
- 本地修复 (auto_proceed: true):单行更改
- 单文件 (auto_proceed: true):一个文件中的多位置
- 跨切 (auto_proceed: false):多个文件
- 复杂 (auto_proceed: false):架构更改
- 信息性 (auto_proceed: false):分类为
informational的线程 — 用户决定操作或忽略
输出格式
仅输出以下JSON(无散文、无Markdown、无代码块):
{
"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",
"action_summary": "Add integration tests for new endpoint",
"complexity": "local",
"original_comment": "This needs integration tests"
},
{
"thread_id": "PRRT_kwDOPxC3hc5q73Nf",
"type": "review",
"path": "src/utils.py",
"line": 10,
"is_outdated": false,
"classification": "informational",
"action_summary": "Bot suggestion: extract helper function (optional)",
"complexity": "local",
"original_comment": "Consider extracting this into a helper"
}
],
"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": "Local Fixes",
"complexity": "local",
"auto_proceed": true,
"item_indices": [0]
},
{
"name": "Cross-Cutting",
"complexity": "cross_cutting",
"auto_proceed": false,
"item_indices": [0]
},
{
"name": "Informational",
"complexity": "informational",
"auto_proceed": false,
"item_indices": [1]
}
],
"error": null
}
字段注释:
thread_id: 用于erk exec resolve-review-thread所需的IDcomment_id: 用于erk exec reply-to-discussion-comment所需的IDclassification:"actionable"或"informational"— 决定用户如何处理线程item_indices: 引用actionable_threads(type=review) 或discussion_actions(type=discussion) 中的索引original_comment: 评论文本的前200个字符informational_count: 仅信息性讨论评论的计数(CI状态、Graphite堆栈)。审查线程始终以classification字段出现在actionable_threads中
错误情况
如果分支没有PR或API失败:
{
"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存在但没有未解决评论:
{
"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
}