fix-pull-request
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFix Pull Request
修复Pull Request
Goal
目标
- CI failures addressed.
- Conflicts resolved.
- Comment suggestions addressed (fixed/replied).
- Branch published.
- PR description updated (if needed).
- 解决CI构建失败问题
- 解决代码冲突
- 处理评审意见(修复或回复)
- 推送分支至远程仓库
- 更新PR描述(如有需要)
Input
输入
- PR identifier (optional): PR number, PR URL, or ticket ID. Passed through to '
vcs-toolscommand; falls back to the current branch's open PR if omitted.identify-pr
- PR标识符(可选):PR编号、PR链接或工单ID。将传递给的
vcs-tools命令;如果省略,则默认使用当前分支对应的已打开PR。identify-pr
Prerequisites
前置条件
- skill available (
vcs-toolsCLI for GitHub repos,ghCLI for GitLab repos)glab - skill available
gather-merge-blockers - skill available
resolve-conflicts - skill available
perform-task - skill available
fix-feedback - skill available
feedback-loop - skill available
scratch
- 已具备技能(GitHub仓库使用
vcs-toolsCLI,GitLab仓库使用ghCLI)glab - 已具备技能
gather-merge-blockers - 已具备技能
resolve-conflicts - 已具备技能
perform-task - 已具备技能
fix-feedback - 已具备技能
feedback-loop - 已具备技能
scratch
Steps
步骤
Step 1: Identify PR
步骤1:识别PR
Invoke:
Skill(skill: "vcs-tools", args: "identify-pr <input>")Capture from its output, and reuse this value for the rest of this skill.
pr_number调用:
Skill(skill: "vcs-tools", args: "identify-pr <input>")从输出中获取,并在后续步骤中复用该值。
pr_numberStep 2: Gather merge blockers
步骤2:收集合并阻塞项
Invoke:
Skill(skill: "gather-merge-blockers", args: "<pr_number>")Capture , , , , , , and from its output, and reuse these values for the rest of this skill instead of re-deriving them.
urlsource_branchtarget_branchmerge_stateci_failuresreviewsthreads调用:
Skill(skill: "gather-merge-blockers", args: "<pr_number>")从输出中获取、、、、、和,并在后续步骤中复用这些值,无需重新获取。
urlsource_branchtarget_branchmerge_stateci_failuresreviewsthreadsStep 3: Resolve conflicts
步骤3:解决代码冲突
If (captured in Step 2) is not , skip this step.
merge_stateCONFLICTINGInvoke:
Skill(skill: "resolve-conflicts", args: "<target_branch>")This may force-push without Step 6's gate - intentional, since
is mechanical and escalates ambiguity itself. Step 6
gates only the judgment-call fixes from Steps 4-5.
resolve-conflictsCheck its output . If , stop here and report to the user
that conflicts could not be resolved - do not proceed to Step 4.
statusaborted如果步骤2中获取的不是,则跳过此步骤。
merge_stateCONFLICTING调用:
Skill(skill: "resolve-conflicts", args: "<target_branch>")此操作可能会跳过步骤6的校验直接强制推送——这是有意设计的,因为是机械性操作,自身会处理歧义情况。步骤6仅针对步骤4-5中需要主观判断的修复操作进行校验。
resolve-conflicts检查输出的。如果状态为,则停止操作并告知用户无法解决冲突,无需继续执行步骤4。
statusabortedStep 4: Resolve CI failures
步骤4:解决CI构建失败问题
If is empty, skip this step.
ci_failuresForm list:
ci_tasksFrom each item in , form a single task in 's item shape ():
ci_failuresperform-task{id, body}- id: synthesized as
ci-<index> - body: "fixup mode. CI check '<name>' failed with status '<status>'. Logs: <log_file_path>".
Invoke:
Skill(skill: "perform-task", args: "<ci_tasks>")如果为空,则跳过此步骤。
ci_failures构建列表:
ci_tasks从的每个项中,生成符合格式的任务项():
ci_failuresperform-task{id, body}- id:命名为
ci-<index> - body:"fixup mode. CI check '<name>' failed with status '<status>'. Logs: <log_file_path>"
调用:
Skill(skill: "perform-task", args: "<ci_tasks>")Step 5: Address Threads
步骤5:处理评审线程
If and are both empty, skip this step.
threadsreviewsMap and (from ) into 's item shape (), then invoke it in one call:
threadsreviewsgather-merge-blockersfix-feedback{id, body}- Threads: =
id,thread_id=bodyfolded in, then comments concatenated in order (location:authorper comment).body - Reviews: skip entries with or an empty
state: APPROVED- not actionable feedback. For the rest:body= synthesized (e.g.id),review-<index>= the review'sbody(nobody- not anchored to a file/line).location
Invoke:
Skill(skill: "fix-feedback", args: "fixup mode. <items>")如果和均为空,则跳过此步骤。
threadsreviews将输出的和转换为的格式(),然后一次性调用:
gather-merge-blockersthreadsreviewsfix-feedback{id, body}- 线程(Threads):=
id,thread_id= 包含body信息,然后按顺序拼接评论内容(每条评论格式为location:author)。body - 评审(Reviews):跳过或
state: APPROVED为空的条目——这些无需处理。对于其余条目:body= 自定义命名(例如id),review-<index>= 评审的body内容(无需包含body,因为未锚定到文件/行)。location
调用:
Skill(skill: "fix-feedback", args: "fixup mode. <items>")Step 6: Confirm and squash fixups
步骤6:确认并合并修复提交
If Steps 4 and 5 made no changes and Step 3 was skipped, skip this step.
Invoke:
Skill(skill: "feedback-loop", args: "<target_branch>")如果步骤4和5未产生任何变更,且步骤3被跳过,则跳过此步骤。
调用:
Skill(skill: "feedback-loop", args: "<target_branch>")Step 7: Push to remote
步骤7:推送至远程仓库
If Steps 4 and 5 made no changes and Step 3 was skipped, skip this step.
bash
git push origin $(git branch --show-current) --force-with-lease如果步骤4和5未产生任何变更,且步骤3被跳过,则跳过此步骤。
bash
git push origin $(git branch --show-current) --force-with-leaseStep 8: Post replies
步骤8:发布回复
For each thread and review addressed in Step 5, prepare a reply comment,
keyed by its to 's output (/ per
original input ):
idfix-feedbackstatusdescriptionidTone: Brief and factual. No fluff, apologies, or fillers.
- Per (
status's output; use itsfix-feedbackas the source text):description- implemented: Describe the fix. Example: (for fixes) /
"Fixed. Added missing X."(for improvements)."Done. Replaced X with Y." - declined: Explain without confrontational words. .
"Existing convention is relative imports throughout this package" - deferred: or
"Will address in a future PR"."Created <Ticket URL>" - explained: Provide the requested clarification.
- implemented: Describe the fix. Example:
Post all replies concurrently.
-
Threads: write the reply body to a scratch file via:
scratchSkill(skill: "scratch", args: "write pr-reply-<id> md")Pass the returned path asto<reply_file_path>:vcs-toolsSkill(skill: "vcs-tools", args: "post-reply <pr_number> <thread_id> <reply_file_path>")comes from Step 1;<pr_number>comes from the<thread_id>skill's output.gather-merge-blockers -
Reviews: noto anchor to - write a payload file instead (
thread_id) via{body: "<reply text>", event: "COMMENT", comments: []}:scratchSkill(skill: "scratch", args: "write pr-review-reply-<id> json")Pass the returned path asto<payload_file_path>:vcs-toolsSkill(skill: "vcs-tools", args: "submit-review <pr_number> <payload_file_path>")posts the reply as a top-level note without approving or requesting changes.event: "COMMENT"
针对步骤5中处理的每个线程和评审,根据的输出(对应原始输入的/)准备回复评论:
fix-feedbackidstatusdescription语气:简洁、客观。无需冗余内容、道歉或填充语。
- 根据(来自
status的输出;使用其fix-feedback作为回复文本来源):description- implemented:描述修复内容。示例:(针对修复)/
"已修复。添加了缺失的X。"(针对优化)。"已完成。将X替换为Y。" - declined:用非对抗性语言解释。例如。
"本包内统一使用相对导入的约定" - deferred:或
"将在后续PR中处理"。"已创建<工单链接>" - explained:提供所需的说明。
- implemented:描述修复内容。示例:
同时发布所有回复。
-
线程(Threads):通过技能将回复内容写入临时文件:
scratchSkill(skill: "scratch", args: "write pr-reply-<id> md")将返回的路径作为传递给<reply_file_path>:vcs-toolsSkill(skill: "vcs-tools", args: "post-reply <pr_number> <thread_id> <reply_file_path>")来自步骤1;<pr_number>来自<thread_id>技能的输出。gather-merge-blockers -
评审(Reviews):没有可锚定的——通过
thread_id技能写入payload文件(格式为scratch):{body: "<reply text>", event: "COMMENT", comments: []}Skill(skill: "scratch", args: "write pr-review-reply-<id> json")将返回的路径作为传递给<payload_file_path>:vcs-toolsSkill(skill: "vcs-tools", args: "submit-review <pr_number> <payload_file_path>")会将回复作为顶级备注发布,不会触发批准或变更请求操作。event: "COMMENT"
Step 9: Update PR description
步骤9:更新PR描述
If Steps 4 and 5 made no changes, skip this step.
- Summarize the fixes and improvements applied in this iteration.
- Reflect the final state of the PR compared to the previous version.
- Do not include intermediate technical fixes (e.g., squashed fixups).
Write the description to a scratch file via :
scratchSkill(skill: "scratch", args: "write pr-description md")Pass the returned path as to :
<pr_description_file_path>vcs-toolsSkill(skill: "vcs-tools", args: "update-pr-description <pr_number> <pr_description_file_path>")如果步骤4和5未产生任何变更,则跳过此步骤。
- 总结本次迭代中应用的修复和优化内容。
- 说明PR相较于之前版本的最终状态。
- 无需包含中间技术性修复(例如合并修复提交)。
通过技能将描述内容写入临时文件:
scratchSkill(skill: "scratch", args: "write pr-description md")将返回的路径作为传递给:
<pr_description_file_path>vcs-toolsSkill(skill: "vcs-tools", args: "update-pr-description <pr_number> <pr_description_file_path>")Output
输出
PR URL: (captured in Step 2).
Summary: Short report of what was implemented (from Step 9's PR description)
urlPR链接:(步骤2中获取)
摘要:简短报告本次实现的内容(来自步骤9的PR描述)
url