GitHub CLI 新增 Event Streams 支持,可通过单一命令监听 PR 事件
Wait for pull request events with GitHub CLI
GitHub CLI 在 gh v2.105.0 版本中支持 GitHub Event Streams,开发者与 AI 智能体可通过 gh event listen 命令直接监听 Pull Request 状态变化,无需循环轮询。
该功能用事件流监听替代低效的循环轮询,便于开发者和智能体以更低开销捕获代码审查与状态变更。

GitHub CLI now supports GitHub Event Streams. With gh v2.105.0, you and your agents can wait for a pull request to change with a single command instead of polling it in a loop.
Run gh event listen with a pull request URL and the events you care about, such as a submitted review. It creates the subscription, opens the stream and prints each event as a line of JSON.
- By default, it exits after the first event, so it slots into scripts and agent loops.
- Use
--countto wait for several events,--followto keep listening, and--timeoutto stop waiting. - Use
--jqor--templateto pull out just the fields you need.
You can wait for submitted reviews, pull request state and head changes, merge conflicts and completed check suites. To manage subscriptions directly, use gh event subscription create, list, view, and delete.
Agents discover the new commands on their own: gh pr create, gh pr view, gh run view, gh run watch, and gh api now suggest gh event listen instead of polling.
Availability
The gh event commands are in preview and may change. They require access to Event Streams, which is in preview on GitHub.com. To get access, sign up for the Event Streams waitlist.
To get started, upgrade to gh v2.105.0 or later. For details, see the gh event manual and the Event Streams documentation, or run gh event --help.
Share your feedback in the GitHub Community discussion.
The post Wait for pull request events with GitHub CLI appeared first on The GitHub Blog.
来源:GitHub Changelog · github.blog