pr副驾驶
一个MCP服务器,通过GitHub Copilot CLI监控GitHub拉取请求。它提供了一个状态机驱动的监控循环,并带有可选的TUI仪表板查看器。
特性
- 自动PR监控 --轮询PR状态(CI检查、审核、评论、合并冲突)
- 状态机架构 --确定性C#逻辑驱动所有决策;LLM代理是一个薄薄的执行者
- TUI仪表板 --实时终端。具有CI状态、评论、批准、进度条和深度链接的Gui查看器
- 评论处理 --逐一或分批处理、解释或忽略审核意见
- CI故障调查 --分析失败的检查日志,提出修复建议,通过Azure DevOps重新运行失败的作业
- 自动合并 --批准后合并+CI绿色(带管理员覆盖选项)
- 下班后意识 --在非工作时间暂停轮询,自动恢复
需求
- --通过repo访问进行身份验证
平台支持
| 平台 | MCP服务器 | TUI查看器 |
|---|---|---|
| Windows(x64) | ✅ | ✅ 需要 Windows 终端 |
| macOS(x64) | ✅ | ✅ 在iTerm(如果已安装)或Terminal.app中启动 |
| macOS(苹果硅) | ✅ | ✅ 在iTerm(如果已安装)或Terminal.app中启动 |
MCP服务器和所有PR监控功能都在这两个平台上工作。TUI仪表板查看器在单独的终端窗口中打开(Windows上的Windows终端,macOS上的iTerm/terminal.app)。
从源头进行建设
可选的
- 剧作家MCP服务器 --允许在Azure DevOps UI中单击“重新运行失败的作业”。没有它,该工具就会退回到通过空提交触发新构建。
安装
快速安装(PowerShell 7+)
# Downloads the correct binary for your platform and runs --setup
irm https://raw.githubusercontent.com/m-nash/pr-copilot/main/install.ps1 | iex来自已发布的二进制文件
从以下网址下载适用于您平台的最新版本 ,提取它,然后运行安装程序:
# Windows
PrCopilot.exe --setup
# macOS
chmod +x PrCopilot
./PrCopilot --setup--setup 将:
- 提取
SKILL.md到~/.copilot/skills/pr-monitor/ - 在中注册MCP服务器
~/.copilot/mcp-config.json
来源
git clone https://github.com/m-nash/pr-copilot.git
cd pr-copilot
# Build and install using the dev script (auto-detects platform)
./Install-Debug.ps1或手动:
# Windows
dotnet publish PrCopilot/src/PrCopilot/PrCopilot.csproj -c Release -r win-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -o ~/.copilot/mcp-servers/pr-copilot
# macOS (Apple Silicon)
dotnet publish PrCopilot/src/PrCopilot/PrCopilot.csproj -c Release -r osx-arm64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -o ~/.copilot/mcp-servers/pr-copilot
# Then run setup
~/.copilot/mcp-servers/pr-copilot/PrCopilot --setup可选:剧作家MCP
对于完整的CI重新运行自动化(在Azure DevOps中单击“重新运行失败的作业”):
copilot -i "mcp add playwright -- npx -y @playwright/mcp@latest --browser msedge"用法
在任何签出PR的Copilot CLI会话中:
> monitor the pr
> monitor this pr https://github.com/owner/repo/pull/123
> monitor pr 456这 pr-monitor 技能在以下情况下自动激活:
git push前往一家公关公开的分行- “监视PR”、“监视PR“、“检查PR状态”等。
- 直接PR链接或PR编号(假设当前回购)
发生了什么
- pr_monitor_start --获取公关信息,启动TUI查看器,开始投票
- 轮询循环 --每30-120秒检查一次CI状态、评论和评论
- 检测到终端状态 --状态机向您提供选择:
- 💬 新评论→ 地址/解释/处理自己 - ❌ CI故障→ 调查/重新运行失败/自行处理 - ✅ 已批准+CI绿色→ 合并/等待更多批准 - ⚠️ 合并冲突→ 管好自己
- 行动之后 --监视自动恢复
CLI标志
| 标志 | 描述 |
|---|---|
--setup | 安装SKILL.md并注册MCP服务器 |
--update | 自我更新到最新的GitHub版本 |
--version | 打印版本并退出 |
--viewer --pr N --log PATH --trigger PATH | 启动TUI查看器(内部使用) |
配置
pr副驾驶支持通过以下方式进行可选配置 args 数组in mcp-config.json。参见 docs/configuration.md 查看可用选项。
建筑
+---------------+ MCP/JSON-RPC +--------------------+
| Copilot CLI || PrCopilot.exe |
| (Agent) | | (MCP Server) |
+---------------+ +--------------------+
| State Machine |
| (C# transitions) |
+--------------------+
| GitHub CLI (gh) |
| (API calls) |
+---------+----------+
| log file
+---------v----------+
| TUI Viewer |
| (Terminal.Gui) |
+--------------------+国家机器(MonitorTransitions)果断地做出所有决定。仅限LLM代理:
- 理解代码(处理注释)
- 写回复(到PR线程)
- 分析日志(调查CI故障)
- 遵循指令(执行状态机所说的)
更新中
# Self-update to the latest release (no need to kill running instances)
PrCopilot --update # macOS
PrCopilot.exe --update # Windows更新重命名正在运行的二进制文件,提取新版本,并在下次启动时进行清理。
发展
# Build
dotnet build PrCopilot/PrCopilot.slnx
# Run tests
dotnet test PrCopilot/PrCopilot.slnx本地安装进行测试
# Build and install without killing running instances (auto-detects platform)
./Install-Debug.ps1
# Then restart your Copilot CLI session手动macOS查看器QA(iTerm)
chmod +x scripts/manual-viewer-mac-test.sh
./scripts/manual-viewer-mac-test.sh脚本启动查看器并提供逼真的内容 STATUS|, TERMINAL|, RESUMING|,以及 STOPPED| 记录行,以便人类可以验证实时UI更新、部分大小调整/颜色更改、终端状态冻结行为以及停止时的自动关闭。
