返回顶部
f

fetch-pr-feedback获取PR反馈

Fetch review comments from a PR and evaluate with receive-feedback skill

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.1.4
安全检测
已通过
95
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

fetch-pr-feedback

获取PR反馈

从当前PR的所有审查者处获取审查评论,进行格式化,并使用接收反馈技能进行评估。默认排除PR作者和当前用户。

使用方法

bash
/beagle-core:fetch-pr-feedback [--pr <编号>] [--include-author]

标志参数:

  • - --pr <编号> - 目标PR编号(默认:当前分支的PR)
  • --include-author - 包含PR作者自己的评论(默认:排除)

操作说明

1. 解析参数

从$ARGUMENTS中提取标志参数:

  • - --pr <编号> 或从当前分支检测
  • --include-author 标志(布尔值,默认为false)

2. 获取PR上下文

bash

如果指定了--pr,直接使用该编号


否则,获取当前分支的PR:


gh pr view --json number,headRefName,url,author --jq {number, headRefName, url, author: .author.login}

获取仓库所有者/名称

gh repo view --json owner,name --jq {owner: .owner.login, name: .name}

获取当前认证用户

gh api user --jq .login

存储为$PRNUMBER、$PRAUTHOR、$OWNER、$REPO、$CURRENT_USER。

注意: $OWNER、$REPO等为占位符。请用前面步骤的实际值替换。

如果当前分支没有对应的PR,则失败并提示:当前分支未找到PR。请使用--pr指定PR编号。

3. 获取评论

获取两种类型的评论,排除$PRAUTHOR和$CURRENTUSER(除非设置了--include-author)。使用--paginate配合jq -s将分页的JSON数组合并为一个。

使用单引号分隔符的heredoc将jq过滤器写入临时文件(防止!=、正则表达式模式和尖括号导致的shell转义问题):

问题评论(摘要/概述帖子):

bash
cat > /tmp/issue_comments.jq << JQEOF
def clean_body:
gsub(.*?; ; s)
| gsub(; ; s)
| gsub(

\\s\\s🧩 分析链[\\s\\S]*?
; ; s)
| gsub(
\\s\\s🤖 AI代理提示[\\s\\S]*?
; ; s)
| gsub(
\\s\\s📝 可提交建议[\\s\\S]*?
; ; s)
| gsub(
\\s过往被审查者.?
; ; s)
| gsub(
\\s近期审查详情[\\s\\S]?
; ; s)
| gsub(
\\s\\s提示\\b.*?
; ; s)
| gsub(\\n?---\\n[\\s\\S]*$; ; s)
| gsub(^\\s+|\\s+$; )
| if length > 4000 then .[:4000] + \n\n[评论已截断] else . end
;
[(add // []) | .[] | select(
.user.login != $pr_author and
.user.login != $current_user
)] |
map({id, user: .user.login, body: (.body | cleanbody), createdat})
JQEOF

gh api --paginate repos/$OWNER/$REPO/issues/$PR_NUMBER/comments | \
jq -s --arg prauthor $PRAUTHOR --arg currentuser $CURRENTUSER \
-f /tmp/issue_comments.jq

审查评论(行级评论):

bash
cat > /tmp/review_comments.jq << JQEOF
def clean_body:
gsub(.*?; ; s)
| gsub(; ; s)
| gsub(

\\s\\s🧩 分析链[\\s\\S]*?
; ; s)
| gsub(
\\s\\s🤖 AI代理提示[\\s\\S]*?
; ; s)
| gsub(
\\s\\s📝 可提交建议[\\s\\S]*?
; ; s)
| gsub(
\\s过往被审查者.?
; ; s)
| gsub(
\\s近期审查详情[\\s\\S]?
; ; s)
| gsub(
\\s\\s提示\\b.*?
; ; s)
| gsub(\\n?---\\n[\\s\\S]*$; ; s)
| gsub(^\\s+|\\s+$; )
| if length > 4000 then .[:4000] + \n\n[评论已截断] else . end
;
[(add // []) | .[] | select(
.user.login != $pr_author and
.user.login != $current_user
)] |
map({
id,
user: .user.login,
path,
line_display: (
.line as $end | .start_line as $start |
if $start and $start != $end then \($start)-\($end)
else \($end // .original_line) end
),
body: (.body | clean_body),
created_at
})
JQEOF

gh api --paginate repos/$OWNER/$REPO/pulls/$PR_NUMBER/comments | \
jq -s --arg prauthor $PRAUTHOR --arg currentuser $CURRENTUSER \
-f /tmp/review_comments.jq

如果设置了--include-author,则省略两个jq过滤器文件中的--arg prauthor参数和.user.login != $prauthor条件。无论是否设置该标志,都保留$current_user排除条件。

4. 格式化反馈文档

噪声去除 — 由步骤3中的cleanbody jq函数处理。顺序很重要:首先移除...块,然后是剩余的HTML注释,接着是已知噪声的

块(分析链、AI代理提示、可提交建议、过往被审查者、近期审查详情、提示),最后是---页脚模板。必须在---页脚模式之前去除
块,因为机器人分析链中包含---分隔符,否则会截断实际发现。保留有实质内容的
块(例如建议修复、提议修复)。去除噪声后超过4000字符的评论将被截断,并添加[评论已截断]标记。

按审查者分组 — 按审查者用户名组织格式化输出:

markdown

PR #$PR_NUMBER 审查反馈

审查者:coderabbitai[bot]

摘要评论

[该审查者的问题评论,每条用---分隔]

行级评论

[该审查者的审查评论,每条格式为:]

文件:path/to/file.ts:42
[清理后的评论内容]



审查者:another-reviewer

摘要评论

...

行级评论

...

如果未找到任何审查者的评论,则输出:此PR上未找到审查评论(已排除PR作者和当前用户)。

5. 使用接收反馈技能进行评估

使用Skill工具加载接收反馈技能:Skill(skill: beagle-core:receive-feedback)

然后处理格式化的反馈文档:

  1. 1. 从格式化文档中解析每个可操作项
  2. 对每个项目执行验证→评估→执行流程
  3. 生成结构化响应摘要

示例

bash

获取当前分支PR的所有审查者评论(默认)


/beagle-core:fetch-pr-feedback

从指定PR获取

/beagle-core:fetch-pr-feedback --pr 123

包含PR作者自己的评论

/beagle-core:fetch-pr-feedback --include-author

组合使用

/beagle-core:fetch-pr-feedback --pr 456 --include-author

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 fetch-pr-feedback-1775928615 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 fetch-pr-feedback-1775928615 技能

通过命令行安装

skillhub install fetch-pr-feedback-1775928615

下载

⬇ 下载 fetch-pr-feedback v1.1.4(免费)

文件大小: 2.92 KB | 发布时间: 2026-4-12 09:57

v1.1.4 最新 2026-4-12 09:57
- Adds detailed instructions for fetching, cleaning, and grouping GitHub PR review comments.
- Supports new `--pr ` and `--include-author` flags for flexible PR targeting and author inclusion.
- Improves comment noise-stripping to handle bot/generated content and large comments for concise feedback.
- Formats feedback by grouping reviewer comments into summary and line-specific sections.
- Returns early if no relevant comments are found.
- Integrates with the receive-feedback skill to evaluate and process actionable review feedback.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部