babysit-pr

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Hold one PR until it is merge-ready: poll, classify, fix, push, poll again. Terminal states are merged, closed, needs-user. Nothing else ends the loop, not a push, not a green run, not a report.
守护一个 PR,直到其可以合并:轮询、分类、修复、推送、再轮询。终止状态为 merged、closed、needs-user。除此之外,没有任何其他情况会结束循环:不会因为推送、CI 变绿或报告而结束。

Loop

循环

Each pass:
  1. Snapshot.
    bash scripts/pr-state.sh <pr> [--since <lastPushAt>]
    . Carry the previous pass's
    lastPushAt
    into
    --since
    , so only review items newer than your last push surface.
  2. Terminal first.
    state
    is
    MERGED
    or
    CLOSED
    : report it and stop.
  3. Review items before CI. A fix commit retriggers CI, so answering review first avoids spending a rerun on a SHA you are about to replace.
  4. CI. For each check with a failing
    conclusion
    , run
    bash scripts/classify-failure.sh <check-url>
    before touching code.
  5. Push. Commit on the PR head branch, push, then return to step 1 on the new SHA.
  6. Wait.
    bash scripts/watch.sh <pr>
    blocks until the checks settle, then prints a fresh snapshot. Use it instead of sleeping. Cap it with
    BABYSIT_MAX_MINUTES
    , default 60.
每轮:
  1. 快照。 运行
    bash scripts/pr-state.sh <pr> [--since <lastPushAt>]
    。将上一轮的
    lastPushAt
    传入
    --since
    ,这样只会看到上次推送之后新增的审查项。
  2. 先检查终止状态。 如果
    state
    是
    MERGED
    或
    CLOSED
    :报告并停止。
  3. 先处理审查项,再处理 CI。 修复提交会重新触发 CI,所以先回应审查可以避免在即将替换的 SHA 上浪费一次 CI 重新运行。
  4. CI。 对于每个
    conclusion
    为失败的检查,在修改代码之前先运行
    bash scripts/classify-failure.sh <check-url>
    。
  5. 推送。 在 PR 头部分支上提交、推送,然后基于新的 SHA 返回步骤 1。
  6. 等待。 运行
    bash scripts/watch.sh <pr>
    ,它会阻塞直到检查状态稳定,然后打印一份新的快照。用它代替 sleep。可通过
    BABYSIT_MAX_MINUTES
    设置超时,默认 60 分钟。

Rules

规则

  • Published and fresh only. Act on review items whose
    submittedAt
    or
    createdAt
    is newer than
    lastPushAt
    .
    pr-state.sh
    drops
    PENDING
    reviews: a reviewer still drafting has not spoken yet. An item answered before the last push stays answered.
  • Classify a failure, then act on the class.
    classify-failure.sh
    prints
    flaky
    or
    real
    from log evidence, then the first 20 failing lines.
    real
    : patch the branch.
    flaky
    : rerun it with
    gh run rerun <run-id> --failed
    , budget 3 reruns per failing check; budget spent means needs-user. While a failure reads
    flaky
    , leave tests, build scripts, CI config and dependency pins as they are. A patch that only silences infra hides the signal for everyone downstream.
  • Humans get the user's words, not yours. A human reviewer is any
    reviews[].author
    that is neither the PR author nor flagged
    isBot
    . Surface their item to the user with a suggested reply, and wait for explicit confirmation before posting anything to GitHub. Bot items you act on and resolve yourself.
  • Resolve what you fixed. Once the fix is pushed:
    bash scripts/resolve-thread.sh <threadId>
    , using
    threads[].id
    from the snapshot.
  • Merge is the user's call. The sign-off rule (
    .claude/rules/workflow-sign-off.md
    ): staged means done, committed means signed off. Stop at green and report. Run
    gh pr merge <pr> --auto --squash
    only when invoked with
    --merge
    , or when the user says merge in this session.
  • Green is a milestone, not an exit. No failing check,
    mergeable: MERGEABLE
    , no unresolved thread: report "ready to merge", then keep polling. Late review items still land while the PR is open.
  • 只处理已发布且新鲜的审查项。 只对
    submittedAt
    或
    createdAt
    晚于
    lastPushAt
    的审查项采取行动。
    pr-state.sh
    会过滤掉
    PENDING
    状态的审查:审查者还在起草,尚未发表意见。上次推送前已答复的项保持已答复状态。
  • 先归类失败,再按类别行动。
    classify-failure.sh
    会根据日志证据输出
    flaky
    或
    real
    ,以及前 20 行失败日志。如果是
    real
    :修复分支。如果是
    flaky
    :使用
    gh run rerun <run-id> --failed
    重新运行;每个失败的检查预算为 3 次重新运行;预算用尽即视为 needs-user。当失败判定为
    flaky
    时,不要改动测试、构建脚本、CI 配置或依赖锁定。一个仅仅掩盖基础设施问题的补丁会为下游所有人掩盖信号。
  • 人类审查者看到的是用户的话,而不是你的话。 人类审查者是指既不是 PR 作者、也未被标记为
    isBot
    的
    reviews[].author
    。将他们的审查项连同建议回复展示给用户,在获得用户明确确认后再向 GitHub 发布任何内容。Bot 的审查项由你自行处理并解决。
  • 解决你已修复的线程。 推送修复后:运行
    bash scripts/resolve-thread.sh <threadId>
    ,使用快照中的
    threads[].id
    。
  • 合并由用户决定。 签署规则(
    .claude/rules/workflow-sign-off.md
    ):staged 表示完成,committed 表示已签字。停在绿色状态并报告。只有在用户使用
    --merge
    参数调用,或在本会话中明确说 merge 时,才运行
    gh pr merge <pr> --auto --squash
    。
  • 绿色是一个里程碑,而不是出口。 没有失败的检查、
    mergeable: MERGEABLE
    、没有未解决的线程:报告"ready to merge",然后继续轮询。在 PR 仍打开时,后期出现的审查项仍然会被处理。

Reviewer set

审查者集合

pr-state.sh
reads bot logins from
.skilly/config.json
at the git root:
json
{ "review": { "bots": ["chatgpt-codex-connector[bot]", "some-reviewer"] } }
A login ending in
[bot]
also counts. Missing key or missing file means an empty list, and every reviewer but the PR author reads as human. Read the config each run; keep no login in your head.
pr-state.sh
会从 git 根目录下的
.skilly/config.json
读取 bot 登录名:
json
{ "review": { "bots": ["chatgpt-codex-connector[bot]", "some-reviewer"] } }
以
[bot]
结尾的登录名也会被识别。如果缺少该键或文件,则视为空列表,除 PR 作者外的所有审查者都会被视为人类。每次运行都读取配置;不要在心里记住任何登录名。

CI

CI

Checks are whatever the PR reports. The repo's tier in
.skilly/config.json
decides the set (the
verify
skill explains tiers).
verify
is the one check every tier runs, so a red
verify
is always a statement about this branch.
检查项就是 PR 所报告的那些项。
.skilly/config.json
中仓库的 tier 决定了检查集合(
verify
skill 会解释 tier)。
verify
是所有 tier 都会运行的一项检查,因此红色的
verify
始终是对该分支状态的判定。

Commits

提交

Conventional commit, prefix by content:
fix:
when a check was red,
chore:
for a lint or config nit. Add one body line, so the origin of the change stays greppable:
Babysit-pr: fixes review thread <thread-url>
遵循 Conventional Commits 规范,按内容使用前缀:当检查为红色时用
fix:
,对于 lint 或配置小问题用
chore:
。添加一行 body,以便变更来源可被 grep 到:
Babysit-pr: fixes review thread <thread-url>

Report

报告

Close every pass with: head SHA, check tally, mergeability, what was pushed, reruns spent, what is still open.
每轮结束时报告:head SHA、检查统计、可合并性、推送了什么、消耗的重新运行次数、仍待处理的事项。