@trashcodermaker/pi-pr-review-handler 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,171 +1,48 @@
1
- # PR Review Handler
1
+ # @trashcodermaker/pi-pr-review-handler
2
2
 
3
- > Systematically process GitHub PR review comments: triage for validity, fix code, and post replies.
3
+ > Pi package — systematically process GitHub PR review comments: triage, fix, reply.
4
4
 
5
- 📦 **Repository**: <https://github.com/JI4JUN/pr-review-handler>
6
-
7
- [![Build Status](https://img.shields.io/github/actions/workflow/status/JI4JUN/pr-review-handler/ci.yml?style=flat-square&label=Build)](https://github.com/JI4JUN/pr-review-handler/actions)
8
- [![npm version](https://img.shields.io/npm/v/@trashcodermaker/pi-pr-review-handler?style=flat-square)](https://www.npmjs.com/package/@trashcodermaker/pi-pr-review-handler)
9
- [![License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](LICENSE)
10
-
11
- ⭐ If you like this project, [star it on GitHub](https://github.com/JI4JUN/pr-review-handler) — it helps a lot!
12
-
13
- [Overview](#overview) • [Getting started](#getting-started) • [How it works](#how-it-works) • [Usage](#usage) • [Requirements](#requirements) • [Supported platforms](#supported-platforms)
14
-
15
- [中文版](./README.zh.md)
16
-
17
- ## Overview
18
-
19
- Code review is part of every healthy PR workflow, but turning review threads into actual fixes and thoughtful replies can be tedious and error-prone.
20
-
21
- **PR Review Handler** automates that workflow. It fetches unresolved GitHub PR review threads, evaluates each comment for validity, applies minimal code fixes, drafts replies that match the reviewer's language and tone, and optionally pushes changes and requests re-review.
22
-
23
- It can be used as an npm package, a Pi package, a Pi skill, or embedded into other agent environments. The project ships agent specifications in `agents/` so each platform can run the pipeline with its own task/dispatch mechanism.
24
-
25
- ## Getting started
26
-
27
- ### Install as an npm package
5
+ Install with Pi:
28
6
 
29
7
  ```bash
30
- npm install @trashcodermaker/pi-pr-review-handler
8
+ pi install npm:@trashcodermaker/pi-pr-review-handler
31
9
  ```
32
10
 
33
- ### Install as a Pi package
11
+ Pi auto-discovers the skill under `skills/pr-review-handler/`. Once installed, invoke it from your Pi session with natural language like "handle the reviews on my PR" or `/skill:pr-review-handler`.
34
12
 
35
- ```bash
36
- pi install @trashcodermaker/pi-pr-review-handler
37
- ```
38
-
39
- ### Install from skill.sh
40
-
41
- ```bash
42
- npx skills add JI4JUN/pr-review-handler
43
- ```
13
+ ## What it does
44
14
 
45
- ### From source
15
+ Fetches unresolved GitHub PR review threads, evaluates each comment for validity, applies minimal code fixes, drafts replies that match the reviewer's language and tone, and optionally pushes changes and requests re-review.
46
16
 
47
- ```bash
48
- git clone https://github.com/JI4JUN/pr-review-handler.git
49
- cd pr-review-handler
50
- npm install
51
- ```
17
+ ## Requirements
52
18
 
53
- > [!IMPORTANT]
54
- > Ensure GitHub CLI (`gh`) is installed and authenticated before using this skill or package. Most commands depend on it to read PR data and post replies.
19
+ - GitHub CLI (`gh`) installed and authenticated
20
+ - A Git working tree clean enough to create review-fix commits
21
+ - Node.js / TypeScript project if you want the final `tsc --noEmit` check
55
22
 
56
23
  ## How it works
57
24
 
58
- The handler runs a multi-phase pipeline. Each phase has a clear responsibility, and the flow stops at checkpoints where human confirmation is requested.
59
-
60
25
  ```
61
- Phase 0: Setup
62
- Phase 1: Triage ← parallel, read-only
63
- Phase 2: Fix ← serial, minimal changes
64
- Phase 3: Reply ← orchestrator drafts inline
65
- Phase 4: Post & Push
66
- Phase 5: Report
26
+ Phase 0: Setup → Phase 1: Triage (parallel) → Phase 2: Fix (serial)
27
+ Phase 3: Reply Phase 4: Post & Push → Phase 5: Report
67
28
  ```
68
29
 
69
- ### Phase 0: Setup
70
-
71
- Identifies the target PR from the current branch or an explicit PR link, fetches unresolved review threads, and fetches review-level feedback. This phase prepares everything needed for triage without modifying code.
72
-
73
- ### Phase 1: Triage
74
-
75
- Reads the referenced code and each review thread, then classifies every comment as:
76
-
77
- - `valid-fix` — a real issue that requires code changes
78
- - `valid-nofix` — the concern is valid, but no code change is needed
79
- - `invalid` — the premise doesn't apply to current code, or the suggested fix would be harmful
80
-
81
- If there are many threads and the platform supports parallel agents, triage runs in parallel for speed.
82
-
83
- > [!TIP]
84
- > Triage is intentionally conservative. If a comment is unclear, mark it `invalid` with the reason `unclear — needs human review`.
30
+ Checkpoints pause for confirmation after triage verdicts and before posting replies.
85
31
 
86
- ### Phase 2: Fix
32
+ ## Other platforms
87
33
 
88
- For each `valid-fix` thread, a specialized implementation agent applies the smallest possible change that satisfies the review. The agent traces references first, updates callers and tests when signatures change, and avoids unrelated cleanup or refactors.
89
-
90
- All fixes are committed locally, but **never pushed** during this phase.
91
-
92
- After all fixes:
34
+ This is the Pi-scoped package. If you use Claude Code, Cursor, Gemini CLI, OpenCode, or another harness, install the generic package instead:
93
35
 
94
36
  ```bash
95
- npx tsc --noEmit
37
+ npm install pr-review-handler
96
38
  ```
97
39
 
98
- If type checking fails, the pipeline identifies the offending commit, reverts it, fixes the issue, and recommits before continuing.
99
-
100
- ### Phase 3: Reply
101
-
102
- The orchestrator drafts one reply per thread based on:
103
-
104
- - Original thread data
105
- - Triage verdicts
106
- - Actual diff: `git diff origin/{branch}...HEAD`
107
- - Failure records from Phase 2
108
-
109
- Replies are matched to the reviewer's language and tone, kept concise, and never defensive.
110
-
111
- ### Phase 4: Post & Push
112
-
113
- Approved replies are posted to GitHub, and all local review-fix commits are pushed in one step.
40
+ Or grab the skill directly:
114
41
 
115
- Optionally, the handler can also:
116
-
117
- - Request re-review from the original reviewers
118
- - Dismiss resolved review threads with an "Addressed" message
119
-
120
- ### Phase 5: Report
121
-
122
- A concise summary is printed at the end:
123
-
124
- ```
125
- ✅ Triage: N/N threads processed
126
- ✅ Fixes: M/K valid-fix threads applied (committed locally, pushed)
127
- ❌ Failed: {thread} — {reason}
128
- ✅ Replies: P/P threads drafted and posted
42
+ ```bash
43
+ npx skills add JI4JUN/pr-review-handler
129
44
  ```
130
45
 
131
- ## Usage
132
-
133
- ### In an agent
134
-
135
- When installed as a skill, invoke it from your agent with natural language. Examples:
136
-
137
- - "帮我处理这个 PR 的 review:<https://github.com/owner/repo/pull/123>"
138
- - "回复 reviewer 的评论"
139
- - "看看 PR 里那些 unresolved threads"
140
- - "review 提的问题要修一下"
141
- - "CI 过了,但 review 还没回"
142
- - "someone left comments on my PR"
143
- - "帮我看看那些人提的意见"
144
-
145
- ### From the command line
146
-
147
- If you want to drive the workflow manually, you can use the GitHub CLI commands directly. The skill and package primarily wrap these operations into an agent-friendly pipeline.
148
-
149
- ## Requirements
150
-
151
- - GitHub CLI (`gh`) installed and authenticated
152
- - A Git working tree clean enough to create review-fix commits
153
- - Node.js / TypeScript project if you want the final `tsc --noEmit` check
154
-
155
- ## Supported platforms
156
-
157
- | Platform | Support |
158
- | --- | --- |
159
- | npm / Node.js | ✅ Install as a published package |
160
- | Pi | ✅ Supported as a package and as a skill |
161
- | Claude Code | ✅ Task-based agent dispatch |
162
- | Cursor | ✅ Background agent dispatch |
163
- | Other agent clients | ✅ Inline fallback using the agent specs in `agents/` |
164
-
165
- ## Notes
46
+ ## License
166
47
 
167
- - Agent specs are provided in `agents/` for reuse across platforms.
168
- - When a platform supports parallel agents, triage can run in parallel; otherwise it runs inline.
169
- - There are two checkpoints where execution pauses for confirmation: after triage verdicts, and before posting replies.
170
- - Pushes only happen once, after replies are approved.
171
- - The implementation phase is serial by default to avoid conflicting file changes.
48
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trashcodermaker/pi-pr-review-handler",
3
- "version": "1.0.9",
4
- "description": "Systematically process GitHub PR review comments: triage for validity, fix code, and post replies.",
3
+ "version": "1.1.0",
4
+ "description": "Systematically process GitHub PR review comments: triage for validity, fix code, and post replies. Pi package — install with `pi install npm:@trashcodermaker/pi-pr-review-handler`.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -10,21 +10,24 @@
10
10
  "pi-skill",
11
11
  "pr-review",
12
12
  "github",
13
- "code-review"
13
+ "code-review",
14
+ "agentskills"
14
15
  ],
15
16
  "publishConfig": {
16
17
  "access": "public"
17
18
  },
18
19
  "files": [
19
- "SKILL.md",
20
- "agents",
20
+ "skills",
21
21
  "README.md",
22
- "README.zh.md",
23
22
  "LICENSE"
24
23
  ],
24
+ "scripts": {
25
+ "prepublishOnly": "node ../../scripts/sync-skill.mjs ."
26
+ },
25
27
  "repository": {
26
28
  "type": "git",
27
- "url": "https://github.com/JI4JUN/pr-review-handler.git"
29
+ "url": "https://github.com/JI4JUN/pr-review-handler.git",
30
+ "directory": "packages/pi"
28
31
  },
29
32
  "homepage": "https://github.com/JI4JUN/pr-review-handler#readme",
30
33
  "bugs": {
@@ -37,17 +37,19 @@ Checkpoints: after Phase 1 (user confirms verdicts) and after Phase 3 (user appr
37
37
 
38
38
  ### Platform mapping
39
39
 
40
- Each role maps to a different agent depending on the platform. Agent specs for reference are in `agents/` relative to this skill.
40
+ Agent specs live in `agents/` relative to this skill (`agents/triage-agent.md`, `agents/implementation-agent.md`). Every platform uses the same specs what differs is the dispatch mechanism.
41
41
 
42
- | Role | Pi | Claude Code | Cursor | No-agent fallback |
43
- |------|-----|-------------|--------|-------------------|
44
- | Triage | `pr-review.triage` | Task tool | background agent | inline (read spec, execute yourself) |
45
- | Implementation | `pr-review.implementation` | Task tool | background agent | inline (read spec, execute yourself) |
46
- | Reply | inline (orchestrator) | inline | inline | inline |
42
+ | Platform | Dispatch mechanism |
43
+ |----------|-------------------|
44
+ | Pi | `subagent` tool (fresh context per thread) |
45
+ | Claude Code | Task tool |
46
+ | Cursor | background agent |
47
+ | Gemini CLI / OpenCode / others | native subtask mechanism if available |
48
+ | No subtask available | inline (read the spec, execute the steps yourself) |
47
49
 
48
- **Pi users**: runtime agents are registered in `.agents/agents/pr-review/` at the project root. They include full system prompts, tool constraints, and output format dispatch with task prompt containing only the input data (thread info, verdict data).
50
+ **Dispatch pattern**: read the relevant agent spec, embed its instructions into the task prompt along with the thread-specific input data (thread info for triage, verdict data for implementation), and launch one subtask per thread. Triage is read-only so subtasks run in parallel; implementation writes files so it runs serially.
49
51
 
50
- **Other platforms**: read the agent specs in `agents/` relative to this skill (`agents/triage-agent.md`, `agents/implementation-agent.md`), embed the instructions into the task prompt, and dispatch using your available subtask mechanism. If no subtask mechanism exists, execute inline.
52
+ **Inline fallback**: if your platform has no subtask mechanism, you (the orchestrator) read each spec and perform its steps yourself, one thread at a time. The specs are written as direct instructions, so inline execution is straightforward.
51
53
 
52
54
  ## Phase 0: Setup
53
55
 
@@ -142,9 +144,7 @@ comments:
142
144
  - <reply 2, if any>
143
145
  ```
144
146
 
145
- The agent already has its role instructions and output format built in. Do not embed role instructions in the task prompt only pass the thread-specific data above.
146
-
147
- Collect structured verdicts from all agents.
147
+ Embed the Triage Agent spec (`agents/triage-agent.md`) into the task prompt so the subtask has the full role instructions and output format, then append the thread-specific data above. Collect structured verdicts from all agents.
148
148
 
149
149
  ### Checkpoint 1: User confirmation
150
150
 
@@ -189,7 +189,7 @@ suggested_fix: <what to change>
189
189
  prior_changes: <list of previous fixes in this PR, if any>
190
190
  ```
191
191
 
192
- The agent already has its role instructions and output format built in. Pass only the verdict data above.
192
+ Embed the Implementation Agent spec (`agents/implementation-agent.md`) into the task prompt so the subtask has the full role instructions, then append the verdict data above.
193
193
 
194
194
  After each agent completes:
195
195
 
package/README.zh.md DELETED
@@ -1,171 +0,0 @@
1
- # PR Review Handler
2
-
3
- > 系统地处理 GitHub PR review 评论:判断有效性、修复代码、发布回复。
4
-
5
- 📦 **仓库地址**: <https://github.com/JI4JUN/pr-review-handler>
6
-
7
- [![Build Status](https://img.shields.io/github/actions/workflow/status/JI4JUN/pr-review-handler/ci.yml?style=flat-square&label=Build)](https://github.com/JI4JUN/pr-review-handler/actions)
8
- [![npm version](https://img.shields.io/npm/v/@trashcodermaker/pi-pr-review-handler?style=flat-square)](https://www.npmjs.com/package/@trashcodermaker/pi-pr-review-handler)
9
- [![License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](LICENSE)
10
-
11
- ⭐ 如果这个项目对你有帮助,欢迎在 [GitHub](https://github.com/JI4JUN/pr-review-handler) 上点个 star!
12
-
13
- [项目简介](#项目简介) • [快速开始](#快速开始) • [工作原理](#工作原理) • [使用方法](#使用方法) • [环境要求](#环境要求) • [支持的平台](#支持的平台)
14
-
15
- [English version](./README.md)
16
-
17
- ## 项目简介
18
-
19
- Code Review 是健康 PR 流程的一部分,但把 review 评论转化为实际修复和得体温回复往往既繁琐又容易出错。
20
-
21
- **PR Review Handler** 用自动化流程解决这个问题。它会抓取 GitHub PR 中未关闭的 review 线程,逐条判断评论是否成立,对有效问题做最小化代码修复,生成与评论者语言、语气一致的回复,并在确认后推送变更、请求 re-review。
22
-
23
- 它可以作为 npm 包、Pi 包、Pi skill,或嵌入到其他 agent 环境使用。项目在 `agents/` 中提供 agent 规格,因此不同平台可以用自己的任务/调度机制运行同一套流水线。
24
-
25
- ## 快速开始
26
-
27
- ### 作为 npm 包安装
28
-
29
- ```bash
30
- npm install @trashcodermaker/pi-pr-review-handler
31
- ```
32
-
33
- ### 作为 Pi 包安装
34
-
35
- ```bash
36
- pi install @trashcodermaker/pi-pr-review-handler
37
- ```
38
-
39
- ### 通过 skill.sh 安装
40
-
41
- ```bash
42
- npx skills add JI4JUN/pr-review-handler
43
- ```
44
-
45
- ### 从源码安装
46
-
47
- ```bash
48
- git clone https://github.com/JI4JUN/pr-review-handler.git
49
- cd pr-review-handler
50
- npm install
51
- ```
52
-
53
- > [!IMPORTANT]
54
- > 使用本 skill 或包之前,请确保已安装并登录 GitHub CLI(`gh`)。读取 PR 数据、发布回复等核心操作都依赖它。
55
-
56
- ## 工作原理
57
-
58
- 整个流程由多个阶段组成,每个阶段职责清晰;在需要人工确认的位置会设置 checkpoint 暂停执行。
59
-
60
- ```
61
- Phase 0: Setup
62
- Phase 1: Triage ← 并行,只读
63
- Phase 2: Fix ← 串行,最小修改
64
- Phase 3: Reply ← 由编排器直接起草
65
- Phase 4: Post & Push
66
- Phase 5: Report
67
- ```
68
-
69
- ### Phase 0: Setup
70
-
71
- 根据当前分支或显式 PR 链接定位目标 PR,抓取未关闭的 review 线程,并补充抓取 review 级别的整体反馈。本阶段只做数据准备,不修改代码。
72
-
73
- ### Phase 1: Triage
74
-
75
- 读取评论所指代码和完整 review 线程后,逐条将评论分类为:
76
-
77
- - `valid-fix` — 存在真实问题,需要代码修改
78
- - `valid-nofix` — 问题成立,但不需要改代码
79
- - `invalid` — 前提不适用于当前代码,或建议的修复反而有害
80
-
81
- 如果线程很多且平台支持并行 agent,Triage 会并行执行以提高速度。
82
-
83
- > [!TIP]
84
- > Triage 默认偏保守。如果某条评论含义不清,可直接标记为 `invalid`,原因写 `unclear — needs human review`。
85
-
86
- ### Phase 2: Fix
87
-
88
- 对每条 `valid-fix` 线程,由专门的 implementation agent 施加满足 review 要求的最小改动。修改前先追踪引用关系;如果改动影响函数签名、类型或导出,会同步更新调用方和测试;不顺手做无关的重构或清理。
89
-
90
- 本阶段所有修复都会提交到本地,但 **不会推送**。
91
-
92
- 全部修复完成后会执行:
93
-
94
- ```bash
95
- npx tsc --noEmit
96
- ```
97
-
98
- 如果类型检查失败,流程会自动定位引入错误的提交,回滚、修复后重新提交,再继续后续阶段。
99
-
100
- ### Phase 3: Reply
101
-
102
- 编排器基于以下信息逐条起草回复:
103
-
104
- - 原始线程数据
105
- - Triage 结论
106
- - 实际变更:`git diff origin/{branch}...HEAD`
107
- - Phase 2 中的失败记录
108
-
109
- 回复会尽量匹配评论者的语言和语气,保持简洁,避免防御性措辞。
110
-
111
- ### Phase 4: Post & Push
112
-
113
- 将用户确认后的回复发布到 GitHub,并把本地的 review-fix 提交统一推送。
114
-
115
- 可选地,流程还可以:
116
-
117
- - 向原 reviewer 请求 re-review
118
- - 将已处理的 review 线程标记为“Addressed”并关闭
119
-
120
- ### Phase 5: Report
121
-
122
- 最后输出简要总结:
123
-
124
- ```
125
- ✅ Triage: N/N 条线程已处理
126
- ✅ Fixes: M/K 条 valid-fix 已应用(本地提交并推送)
127
- ❌ Failed: {thread} — {reason}
128
- ✅ Replies: P/P 条回复已起草并发布
129
- ```
130
-
131
- ## 使用方法
132
-
133
- ### 在 agent 中调用
134
-
135
- 安装为 skill 后,直接用自然语言发起请求即可。常见触发方式包括:
136
-
137
- - "帮我处理这个 PR 的 review:<https://github.com/owner/repo/pull/123>"
138
- - "回复 reviewer 的评论"
139
- - "看看 PR 里那些 unresolved threads"
140
- - "review 提的问题要修一下"
141
- - "CI 过了,但 review 还没回"
142
- - "someone left comments on my PR"
143
- - "帮我看看那些人提的意见"
144
-
145
- ### 命令行手动驱动
146
-
147
- 如果你希望手动控制流程,也可以直接基于 GitHub CLI 命令执行。本 skill 和包的主要价值,是把这些命令封装成 agent 可理解、可执行的结构化流水线。
148
-
149
- ## 环境要求
150
-
151
- - 已安装并登录 GitHub CLI(`gh`)
152
- - Git 工作区足够干净,可以创建 review-fix 提交
153
- - 若想执行最后的 `tsc --noEmit` 检查,项目应为 Node.js / TypeScript 项目
154
-
155
- ## 支持的平台
156
-
157
- | 平台 | 支持情况 |
158
- | --- | --- |
159
- | npm / Node.js | ✅ 可作为已发布包安装 |
160
- | Pi | ✅ 支持作为 package 和 skill 使用 |
161
- | Claude Code | ✅ 通过 Task 机制分发 agent |
162
- | Cursor | ✅ 通过 background agent 分发 |
163
- | 其他 agent 客户端 | ✅ 使用 `agents/` 中的 agent 规格,以内联方式运行 |
164
-
165
- ## 备注
166
-
167
- - 项目在 `agents/` 中提供可复用的 agent 规格。
168
- - 若平台支持并行 agent,Triage 可并行执行;否则以内联方式运行。
169
- - 流程中有两处会暂停等待确认:一次在 Triage 结论出来后,一次在发布回复前。
170
- - 推送仅在回复确认后执行一次。
171
- - Fix 阶段默认串行执行,以避免并发修改带来的冲突。