Loading...
Loading...
Compare original and translation side by side
/github-triage/github-triagegh auth status # confirm gh is authenticated
git rev-parse --is-inside-work-tree # is PWD a git repository?
git remote -v # enumerate remotesgithub.comhttps://github.com/OWNER/REPO(.git)git@github.com:OWNER/REPO(.git)ssh://git@github.com/OWNER/REPO(.git)OWNER/REPOoriginupstreamOWNER/REPO| Situation | Action |
|---|---|
| Exactly one distinct GitHub repo | Use it as the default — do not prompt. |
| Not a git repo, or zero GitHub remotes | Ask the user for the |
| More than one distinct GitHub repo | Use AskUserQuestion to let the user pick which |
GitHub Enterprise hosts cannot be auto-detected reliably. If the user works on a GHE instance, ask forand have them setOWNER/REPO/ useGH_HOST's configured host. Confirm the resolved repo back to the user before continuing.gh
REPO="OWNER/REPO"-R "$REPO"gh^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$gh auth status # 确认gh已完成认证
git rev-parse --is-inside-work-tree # 当前目录是否为git仓库?
git remote -v # 列出所有远程仓库github.comhttps://github.com/OWNER/REPO(.git)git@github.com:OWNER/REPO(.git)ssh://git@github.com/OWNER/REPO(.git)OWNER/REPOoriginupstreamOWNER/REPO| 场景 | 操作 |
|---|---|
| 仅存在一个独立的GitHub仓库 | 将其设为默认仓库——无需提示。 |
| 当前目录不是git仓库,或无GitHub远程仓库 | 询问用户需梳理的 |
| 存在多个独立的GitHub仓库 | 使用AskUserQuestion让用户选择对应的 |
GitHub Enterprise仓库无法被可靠自动检测。若用户使用GHE实例,需询问并让用户设置OWNER/REPO或使用gh已配置的主机。在继续操作前向用户确认最终选定的仓库。GH_HOST
REPO="OWNER/REPO"-R "$REPO"^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$undefinedundefined
`closingIssuesReferences` lists the issues a PR is linked to close — populated by any
of GitHub's closing keywords (`close`/`closes`/`closed`, `fix`/`fixes`/`fixed`,
`resolve`/`resolves`/`resolved`) in the PR body, or by a manual UI link. It is the
strongest available signal. For issues it does not cover, also search commit messages
on the default branch. Resolve the default branch authoritatively from the selected
repo (not from local `origin/HEAD`, which may be unset or point at the wrong remote):
```bash
default_branch=$(gh repo view "$REPO" --json defaultBranchRef --jq .defaultBranchRef.name)
`closingIssuesReferences`列出了PR关联的待关闭Issue——由PR正文中的GitHub关闭关键字(`close`/`closes`/`closed`、`fix`/`fixes`/`fixed`、`resolve`/`resolves`/`resolved`)或手动UI关联填充。这是最可靠的信号。对于未被该字段覆盖的Issue,还需搜索默认分支上的提交信息。从选定仓库中权威获取默认分支(不要使用本地`origin/HEAD`,它可能未设置或指向错误的远程仓库):
```bash
default_branch=$(gh repo view "$REPO" --json defaultBranchRef --jq .defaultBranchRef.name)undefinedundefinedgh pr ... --jsonmergeable == "MERGEABLE"mergeStateStatus == "CLEAN"CLEANmergeStateStatusBEHINDUNSTABLEBLOCKEDDIRTYDRAFTmergeable == "UNKNOWN"statusCheckRollup__typenameCheckRunconclusionFAILURECANCELLEDTIMED_OUTACTION_REQUIREDSTARTUP_FAILURESTALEStatusContextstateFAILUREERRORCheckRunstatusQUEUEDIN_PROGRESSWAITINGPENDINGStatusContextstatePENDINGEXPECTEDSUCCESSNEUTRALSKIPPEDNEUTRALCLEANNEUTRALmergeStateStatus == "CLEAN"author.is_bot == trueauthor.loginghapp/[bot]app/dependabotdependabot[bot]dependabotdependabotrenovatelatestReviewsstate == "APPROVED"authorAssociationOWNERMEMBERCOLLABORATORauthor.loginreviewDecision == "APPROVED"nulllatestReviewsAPPROVEDCHANGES_REQUESTED| Category | Condition | Offered action |
|---|---|---|
| Mergeable bot PR | allowlisted bot + ready + not draft | Offer incremental, in-order merge |
| Approved & ready | maintainer-approved + ready + not draft | Prompt to merge |
| Never reviewed | non-bot + only the author has reviewed (or no reviews) + not draft | Offer to spawn a review subagent |
| Needs work | draft, hard CI failure, pending CI, conflicts, behind, changes requested, or a bot PR that is not ready | Report only — no action offered |
gh repo view "$REPO" --json mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed # positional repo, not -RBEHINDgh pr view <N> -R "$REPO" --json isDraft,reviewDecision,mergeable,mergeStateStatus,statusCheckRollupgh pr ... --jsonmergeable == "MERGEABLE"mergeStateStatus == "CLEAN"CLEANmergeStateStatusBEHINDUNSTABLEBLOCKEDDIRTYDRAFTmergeable == "UNKNOWN"statusCheckRollup__typenameCheckRunconclusionFAILURECANCELLEDTIMED_OUTACTION_REQUIREDSTARTUP_FAILURESTALEStatusContextstateFAILUREERRORCheckRunstatusQUEUEDIN_PROGRESSWAITINGPENDINGStatusContextstatePENDINGEXPECTEDSUCCESSNEUTRALSKIPPEDNEUTRALCLEANNEUTRALmergeStateStatus == "CLEAN"author.is_bot == trueauthor.loginapp/[bot]app/dependabotdependabot[bot]dependabotdependabotrenovatelatestReviewsstate == "APPROVED"authorAssociationOWNERMEMBERCOLLABORATORauthor.loginreviewDecision == "APPROVED"nulllatestReviewsAPPROVEDCHANGES_REQUESTED| 分类 | 条件 | 提供的操作 |
|---|---|---|
| 可合并的机器人PR | 白名单机器人 + 可合并 + 非草稿 | 提供增量式按顺序合并选项 |
| 已批准且可合并 | 维护者批准 + 可合并 + 非草稿 | 提示用户合并 |
| 从未审核 | 非机器人 + 仅作者审核(或无审核记录) + 非草稿 | 提供生成审核子Agent选项 |
| 需要处理 | 草稿、CI严重失败、CI待处理、冲突、落后于默认分支、需要修改、或不可合并的机器人PR | 仅报告——不提供操作选项 |
gh repo view "$REPO" --json mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed # 使用位置参数指定仓库,而非-Rgh pr view <N> -R "$REPO" --json isDraft,reviewDecision,mergeable,mergeStateStatus,statusCheckRollup
Stop and report if a PR is no longer ready (including `mergeable == "UNKNOWN"`), if the
merge did not land, or if any required check is not green — never force, `--admin`,
`--auto`, or skip a check. For bot PRs, surface the dependency and version jump (e.g.
major bumps) in the gate so the user can decide with context.
**Review subagents** (never-reviewed PRs): when the user opts in, spawn one **Agent**
per PR — all in a single assistant message so they run in parallel. Each subagent
reviews one PR's diff and returns a structured review; write each to
`github-pr-<number>-review.md` in the working directory (overwriting any prior file
for that PR). Reviews are **read-only and never posted to GitHub**. See
[references/reviewing-prs.md](references/reviewing-prs.md) for the subagent prompt,
review rubric, and file format.
After any merges, **re-fetch** the merged-PR list (the Phase 1 `--state merged` query)
so the issue phase can detect issues those merges resolved.
若PR不再可合并(包括`mergeable == "UNKNOWN"`)、合并未完成、或任何必填检查未通过,立即停止并报告——绝不要强制合并、使用`--admin`、`--auto`参数或跳过检查。对于机器人PR,在审批环节展示依赖项和版本变更(例如大版本升级),以便用户结合上下文做出决策。
**审核子Agent**(从未审核的PR):当用户选择该选项时,为每个PR生成一个**Agent**——所有Agent在同一条助手消息中生成,以便并行运行。每个子Agent审核一个PR的差异并返回结构化审核结果;将结果写入工作目录下的`github-pr-<number>-review.md`文件(覆盖该PR的原有文件)。审核结果**仅本地可读,绝不会发布到GitHub**。审核子Agent的提示词、审核准则和文件格式请参考[references/reviewing-prs.md](references/reviewing-prs.md)。
完成任何合并操作后,**重新获取**已合并PR列表(阶段1中的`--state merged`查询),以便Issue阶段能识别这些合并操作解决的Issue。closingIssuesReferences#N#Ngh issue close <N> -R "$REPO" \
-c "Resolved by #<PR> (<short reason>). Closing as the change is now on $default_branch."closingIssuesReferences#<PR>#<N>gh issue comment <N> -R "$REPO" -b "A fix is in progress in #<PR>."body=$(gh pr view <PR> -R "$REPO" --json body --jq .body)
printf '%s\n\nCloses #%s\n' "$body" "<N>" | gh pr edit <PR> -R "$REPO" --body-file -closingIssuesReferences#N#Ngh issue close <N> -R "$REPO" \
-c "Resolved by #<PR> (<short reason>). Closing as the change is now on $default_branch."closingIssuesReferences#<PR>#<N>gh issue comment <N> -R "$REPO" -b "A fix is in progress in #<PR>."$(…)body=$(gh pr view <PR> -R "$REPO" --json body --jq .body)
printf '%s\n\nCloses #%s\n' "$body" "<N>" | gh pr edit <PR> -R "$REPO" --body-file -CriticalHighMediumLowsecuritybugcrashregressionsize/*| Bucket | Estimated changed lines |
|---|---|
| 0–9 |
| 10–29 |
| 30–99 |
| 100–499 |
| 500–999 |
| 1000+ |
unsized — needs investigationCriticalHighMediumLowsecuritybugcrashregressionsize/*| 类别 | 估算变更行数 |
|---|---|
| 0–9 |
| 10–29 |
| 30–99 |
| 100–499 |
| 500–999 |
| 1000+ |
unsized — needs investigationundefinedundefined| Issue | Title | Evidence | Draft comment |
|---|---|---|---|
| #123 | ... | merged PR #130 | "Resolved by #130 …" |
| Issue | 标题 | 依据 | 草稿评论 |
|---|---|---|---|
| #123 | ... | 已合并PR #130 | "Resolved by #130 …" |
| Issue | PR | Gap | Proposed action |
|---|---|---|---|
| #140 | #145 | PR omits | edit PR body to add closing ref |
| #141 | #146 | none | already linked — no action |
| Issue | PR | 空白 | 拟执行操作 |
|---|---|---|---|
| #140 | #145 | PR未包含 | 编辑PR正文添加关闭关联 |
| #141 | #146 | 无 | 已关联——无需操作 |
| Issue | Title | Priority | Size | Est. lines / files | Basis |
|---|---|---|---|---|---|
| #150 | ... | High | size/M | ~60 / 3 | "validation + 2 call sites + test" |
Then ask for approval with **AskUserQuestion**. Per the user's chosen gating
(batch review with iteration), offer options such as:
- **Approve all proposed writes** — execute the closes and cross-links as shown.
- **Revise first** — the user wants to change a subset before executing.
- **Skip writes** — produce the local report only; make no GitHub changes.
If the user chooses **Revise first**, iterate conversationally: let them drop
specific closes, downgrade weak evidence to "leave open / needs review", edit any
draft comment, or adjust a cross-link. Re-present the revised write set and ask
again. **Loop until the user approves the final set.** Execute nothing until then.| Issue | 标题 | 优先级 | 规模 | 估算行数/文件数 | 依据 |
|---|---|---|---|---|---|
| #150 | ... | High | size/M | ~60 / 3 | "验证逻辑 + 2个调用点 + 测试" |
然后通过**AskUserQuestion**请求用户批准。根据用户选择的审批方式(批量审核可迭代),提供如下选项:
- **批准所有拟执行的写入操作**——按展示内容执行关闭和交叉关联操作。
- **先修改**——用户希望修改部分内容后再执行。
- **跳过写入操作**——仅生成本地报告;不修改GitHub内容。
若用户选择**先修改**,进行交互式迭代:让用户取消特定的关闭操作、将依据不足的Issue标记为「保留开放/需审核」、编辑任何草稿评论或调整交叉关联。重新展示修改后的写入操作集并再次请求批准。**循环直到用户批准最终方案**。在批准前不执行任何操作。gh issue close 123 -R "$REPO" -c "Resolved by #130 …"
gh issue comment 140 -R "$REPO" -b "A fix is in progress in #145."gh issue close 123 -R "$REPO" -c "Resolved by #130 …"
gh issue comment 140 -R "$REPO" -b "A fix is in progress in #145."undefinedundefinedKgithub-triage-OWNER-REPO-YYYYMMDD.mddate +%Y%m%dThe threshold applies to the outstanding table — the thing being displayed. 32 is the default; honor a different cutoff if the user requests one.
Kgithub-triage-OWNER-REPO-YYYYMMDD.mddate +%Y%m%d阈值仅适用于未处理表格的展示。默认阈值为32;若用户要求,可使用其他阈值。
disable-model-invocationgh pr mergegh issue closegh issue commentgh pr edit--body-file --F--body "…"$(…)github-pr-<number>-review.mddisable-model-invocationgh pr mergegh issue closegh issue commentgh pr edit--body-file --F--body "…"$(…)github-pr-<number>-review.md| Rationalization | Why it's wrong |
|---|---|
| "The issue is old, it's probably resolved." | Age says nothing about resolution. Old issues are often still valid. |
| "A PR mentions this issue, so close it." | Only a merged PR that actually addresses the issue resolves it. An open or closed-unmerged PR does not. |
| "The feature looks implemented — close it." | Verify in the current code. A partial or differently-scoped implementation does not satisfy the issue. |
| "Closing auto-generates a note, so no comment is needed." | Always leave a human-readable reason citing the resolving PR/commit. |
| "Posting the priority as a label would be helpful." | Priority and size are local-only by explicit instruction. Never post them. |
| "They obviously reference each other already, skip checking." | Verify the bidirectional reference actually exists before claiming it; only skip the write when a link is genuinely present. |
| "There are too many issues, I'll just sample the first 32." | The 32 threshold governs display, not coverage. Triage every open issue; save to disk when the table is large. |
| "This issue is hard to size, I'll guess size/M." | Mark it |
| "All the bot PRs are green, so merge them all at once." | Merge in order, one at a time. Each merge can stale or conflict the next; re-check before every merge. |
| "The author approved their own PR, so it's been reviewed." | An author approving their own PR is not review. "Maintainer-approved" requires an approval from someone else with write access. |
| "CI passed, so the PR is safe to merge." | CI passing is necessary, not sufficient. A never-reviewed PR still gets a review (or stays unmerged); surface major dependency bumps before merging bot PRs. |
| "The subagent recommended approve, so merge it." | The review is advisory and local. Merging is a separate, explicitly-approved action — never chained off a review verdict. |
| "An unrecognized bot opened a green PR, so merge it." | Only merge bots on a trusted allowlist (Dependabot/Renovate/user-named). An unknown App could be hostile or misconfigured. |
" | Require |
| 错误理由 | 错误原因 |
|---|---|
| "这个Issue很旧,可能已经解决了。" | 存在时长与是否解决无关。旧Issue通常仍然有效。 |
| "某个PR提到了这个Issue,所以关闭它。" | 只有已合并且实际解决该问题的PR才能视为已解决。开放或已关闭未合并的PR不算。 |
| "该功能看起来已实现——关闭它。" | 需在当前代码中验证。部分实现或不同范围的实现不满足Issue要求。 |
| "关闭会自动生成说明,无需添加评论。" | 始终需留下引用解决PR/提交记录的可读理由。 |
| "将优先级作为标签发布会很有帮助。" | 根据明确要求,优先级和规模仅本地可见。绝不要发布。 |
| "它们显然已经互相引用了,跳过检查。" | 在声称已关联前需验证双向关联是否确实存在;仅当关联真实存在时才跳过写入操作。 |
| "Issue太多了,我只处理前32个。" | 32的阈值仅控制展示,而非覆盖范围。需梳理所有开放Issue;当表格过大时保存到磁盘。 |
| "这个Issue很难估算规模,我猜是size/M。" | 标记为 |
| "所有机器人PR都正常,一次性合并它们。" | 按顺序逐个合并。每次合并可能导致下一个PR失效或产生冲突;每次合并前重新检查。 |
| "作者批准了自己的PR,所以已经审核过了。" | 作者批准自己的PR不算审核。「维护者批准」需要其他拥有写入权限的人员批准。 |
| "CI通过了,所以PR可以安全合并。" | CI通过是必要条件,但非充分条件。从未审核的PR仍需审核(或保持未合并);合并机器人PR前需展示大版本依赖更新。 |
| "子Agent建议批准,所以合并它。" | 审核结果仅为本地参考。合并是单独的需显式批准的操作——绝不要基于审核结果自动触发。 |
| "一个未知机器人提交了正常的PR,合并它。" | 仅合并白名单中的机器人(Dependabot/Renovate/用户指定)。未知应用可能是恶意或配置错误的。 |
" | 要求 |