名称: pr-triage 描述: “上下文高效的PR评论分流。评估、决定、行动。修复重要问题,静默解决其余部分。” 标签:
- pr
- 审查
- github
- 分流
- 上下文效率
PR评论分流 - 评估 → 决定 → 行动
哲学
回复是次要的,首要的是解决问题。
- 重要问题?修复它 → 回复提交引用 → 解决
- 不重要?静默解决 → 无需回复
- 不要回复每条评论 - 那是噪音
工作流程
┌─────────────────────────────────────────────┐
│ 评估 → 决定 → 行动 │
├─────────────────────────────────────────────┤
│ │
│ 1. 获取未回复(仅元数据) │
│ → 获取没有回复的根评论 │
│ → 约100字节/评论,分页 │
│ │
│ 2. 评估每条评论 │
│ → 仅当路径看起来重要时获取正文 │
│ → 跳过:元数据文件、样式细节 │
│ → 检查:安全、正确性、测试 │
│ │
│ 3. 决定行动 │
│ → 修复:实施更改、回复、解决 │
│ → 解决:静默关闭,不回复 │
│ → 推迟:创建单元、解决 │
│ │
│ 4. 行动 │
│ → 在代码中修复问题 │
│ → 解决线程(不回复) │
│ → 仅在修复了内容时回复 │
│ │
└─────────────────────────────────────────────┘
决策矩阵
| 评论类型 | 行动 | 回复? |
|---|---|---|
| 安全/正确性错误 | 修复 → 回复提交 | ✅ 是 |
| 有效改进,在范围内 | 修复 → 回复提交 | ✅ 是 |
| 有效但超出范围 | 创建单元 → 解决 | ❌ 否 |
| 样式/格式化细节 | 静默解决 | ❌ 否 |
| 元数据文件(.jsonl等) | 静默解决 | ❌ 否 |
| 已修复 | 回复提交 → 解决 | ✅ 是 |
| 不同意建议 | 静默解决 | ❌ 否 |
SDK命令
# 获取未回复根评论(从这里开始)
bun run scripts/pr-comments.ts unreplied owner/repo 42
# 评估:获取特定评论正文
bun run scripts/pr-comments.ts expand owner/repo 123456
# 行动:解决而不回复(首选)
bun run scripts/pr-comments.ts resolve owner/repo 42 123456
# 行动:回复然后解决(仅在修复内容时)
bun run scripts/pr-comments.ts reply owner/repo 42 123456 "✅ 已修复于 abc123"
# 助手
bun run scripts/pr-comments.ts summary owner/repo 42 # 文件级别概览
bun run scripts/pr-comments.ts list owner/repo 42 # 所有元数据
快速分流模式
import { fetchMetadata, fetchBody, resolveThread, reply, getThreadId } from "./scripts/pr-comments.ts";
const comments = await fetchMetadata("owner/repo", 42);
// 找到未回复根评论
const repliedTo = new Set(comments.filter(c => c.inReplyToId).map(c => c.inReplyToId));
const unreplied = comments.filter(c => !c.inReplyToId && !repliedTo.has(c.id));
for (const c of unreplied) {
// 跳过元数据文件 - 静默解决
if (c.path.endsWith('.jsonl') || c.path.includes('.hive/')) {
const threadId = await getThreadId("owner/repo", 42, c.id);
if (threadId) await resolveThread("owner/repo", threadId);
continue;
}
// 评估重要文件
const full = await fetchBody("owner/repo", c.id);
if (full.body.includes('Critical') || full.body.includes('security')) {
// 修复它,然后回复
// ... 实施修复 ...
await reply("owner/repo", 42, c.id, "✅ 已修复于 abc123");
}
// 无论如何解决
const threadId = await getThreadId("owner/repo", 42, c.id);
if (threadId) await resolveThread("owner/repo", threadId);
}
跳过这些(静默解决)
.hive/issues.jsonl- 自动生成的元数据.hive/memories.jsonl- 自动生成的元数据- 更改集格式化建议
- 导入顺序细节
- "添加跟踪问题"用于有意的跳过
- 不认同的样式偏好
修复这些(回复 + 解决)
- 安全漏洞
- 正确性错误
- 缺失错误处理
- 测试覆盖缺口(如果有效)
- 类型安全问题
上下文预算
| 行动 | 上下文成本 |
|---|---|
unreplied |
约100字节/评论 |
expand(1条评论) |
约5KB |
resolve |
0(GraphQL突变) |
reply |
约200字节 |
规则: 每个分流会话获取<10个正文。
参考
scripts/pr-comments.ts- 完整SDK与Zod模式references/gh-api-patterns.md- 原始jq模式、GraphQL、分页