@trashcodermaker/pi-pr-review-handler 1.0.8 → 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,169 +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
- [![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)
6
- [![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)
7
- [![License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](LICENSE)
8
-
9
- ⭐ If you like this project, star it on GitHub — it helps a lot!
10
-
11
- [Overview](#overview) • [Getting started](#getting-started) • [How it works](#how-it-works) • [Usage](#usage) • [Requirements](#requirements) • [Supported platforms](#supported-platforms)
12
-
13
- [中文版](./README.zh.md)
14
-
15
- ## Overview
16
-
17
- 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.
18
-
19
- **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.
20
-
21
- 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.
22
-
23
- ## Getting started
24
-
25
- ### Install as an npm package
5
+ Install with Pi:
26
6
 
27
7
  ```bash
28
- npm install @trashcodermaker/pi-pr-review-handler
8
+ pi install npm:@trashcodermaker/pi-pr-review-handler
29
9
  ```
30
10
 
31
- ### Install as a Pi package
32
-
33
- ```bash
34
- pi install @trashcodermaker/pi-pr-review-handler
35
- ```
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`.
36
12
 
37
- ### Install from skill.sh
13
+ ## What it does
38
14
 
39
- ```bash
40
- npx skills add JI4JUN/pr-review-handler
41
- ```
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.
42
16
 
43
- ### From source
44
-
45
- ```bash
46
- git clone https://github.com/JI4JUN/pr-review-handler.git
47
- cd pr-review-handler
48
- npm install
49
- ```
17
+ ## Requirements
50
18
 
51
- > [!IMPORTANT]
52
- > 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
53
22
 
54
23
  ## How it works
55
24
 
56
- The handler runs a multi-phase pipeline. Each phase has a clear responsibility, and the flow stops at checkpoints where human confirmation is requested.
57
-
58
25
  ```
59
- Phase 0: Setup
60
- Phase 1: Triage ← parallel, read-only
61
- Phase 2: Fix ← serial, minimal changes
62
- Phase 3: Reply ← orchestrator drafts inline
63
- Phase 4: Post & Push
64
- 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
65
28
  ```
66
29
 
67
- ### Phase 0: Setup
68
-
69
- 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.
70
-
71
- ### Phase 1: Triage
72
-
73
- Reads the referenced code and each review thread, then classifies every comment as:
74
-
75
- - `valid-fix` — a real issue that requires code changes
76
- - `valid-nofix` — the concern is valid, but no code change is needed
77
- - `invalid` — the premise doesn't apply to current code, or the suggested fix would be harmful
78
-
79
- If there are many threads and the platform supports parallel agents, triage runs in parallel for speed.
80
-
81
- > [!TIP]
82
- > 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.
83
31
 
84
- ### Phase 2: Fix
32
+ ## Other platforms
85
33
 
86
- 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.
87
-
88
- All fixes are committed locally, but **never pushed** during this phase.
89
-
90
- 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:
91
35
 
92
36
  ```bash
93
- npx tsc --noEmit
37
+ npm install pr-review-handler
94
38
  ```
95
39
 
96
- If type checking fails, the pipeline identifies the offending commit, reverts it, fixes the issue, and recommits before continuing.
97
-
98
- ### Phase 3: Reply
99
-
100
- The orchestrator drafts one reply per thread based on:
101
-
102
- - Original thread data
103
- - Triage verdicts
104
- - Actual diff: `git diff origin/{branch}...HEAD`
105
- - Failure records from Phase 2
106
-
107
- Replies are matched to the reviewer's language and tone, kept concise, and never defensive.
108
-
109
- ### Phase 4: Post & Push
110
-
111
- Approved replies are posted to GitHub, and all local review-fix commits are pushed in one step.
40
+ Or grab the skill directly:
112
41
 
113
- Optionally, the handler can also:
114
-
115
- - Request re-review from the original reviewers
116
- - Dismiss resolved review threads with an "Addressed" message
117
-
118
- ### Phase 5: Report
119
-
120
- A concise summary is printed at the end:
121
-
122
- ```
123
- ✅ Triage: N/N threads processed
124
- ✅ Fixes: M/K valid-fix threads applied (committed locally, pushed)
125
- ❌ Failed: {thread} — {reason}
126
- ✅ Replies: P/P threads drafted and posted
42
+ ```bash
43
+ npx skills add JI4JUN/pr-review-handler
127
44
  ```
128
45
 
129
- ## Usage
130
-
131
- ### In an agent
132
-
133
- When installed as a skill, invoke it from your agent with natural language. Examples:
134
-
135
- - "帮我处理这个 PR 的 review:<https://github.com/owner/repo/pull/123>"
136
- - "回复 reviewer 的评论"
137
- - "看看 PR 里那些 unresolved threads"
138
- - "review 提的问题要修一下"
139
- - "CI 过了,但 review 还没回"
140
- - "someone left comments on my PR"
141
- - "帮我看看那些人提的意见"
142
-
143
- ### From the command line
144
-
145
- 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.
146
-
147
- ## Requirements
148
-
149
- - GitHub CLI (`gh`) installed and authenticated
150
- - A Git working tree clean enough to create review-fix commits
151
- - Node.js / TypeScript project if you want the final `tsc --noEmit` check
152
-
153
- ## Supported platforms
154
-
155
- | Platform | Support |
156
- | --- | --- |
157
- | npm / Node.js | ✅ Install as a published package |
158
- | Pi | ✅ Supported as a package and as a skill |
159
- | Claude Code | ✅ Task-based agent dispatch |
160
- | Cursor | ✅ Background agent dispatch |
161
- | Other agent clients | ✅ Inline fallback using the agent specs in `agents/` |
162
-
163
- ## Notes
46
+ ## License
164
47
 
165
- - Agent specs are provided in `agents/` for reuse across platforms.
166
- - When a platform supports parallel agents, triage can run in parallel; otherwise it runs inline.
167
- - There are two checkpoints where execution pauses for confirmation: after triage verdicts, and before posting replies.
168
- - Pushes only happen once, after replies are approved.
169
- - 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.8",
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,169 +0,0 @@
1
- # PR Review Handler
2
-
3
- > 系统地处理 GitHub PR review 评论:判断有效性、修复代码、发布回复。
4
-
5
- [![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)
6
- [![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)
7
- [![License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](LICENSE)
8
-
9
- ⭐ 如果这个项目对你有帮助,欢迎在 GitHub 上点个 star!
10
-
11
- [项目简介](#项目简介) • [快速开始](#快速开始) • [工作原理](#工作原理) • [使用方法](#使用方法) • [环境要求](#环境要求) • [支持的平台](#支持的平台)
12
-
13
- [English version](./README.md)
14
-
15
- ## 项目简介
16
-
17
- Code Review 是健康 PR 流程的一部分,但把 review 评论转化为实际修复和得体温回复往往既繁琐又容易出错。
18
-
19
- **PR Review Handler** 用自动化流程解决这个问题。它会抓取 GitHub PR 中未关闭的 review 线程,逐条判断评论是否成立,对有效问题做最小化代码修复,生成与评论者语言、语气一致的回复,并在确认后推送变更、请求 re-review。
20
-
21
- 它可以作为 npm 包、Pi 包、Pi skill,或嵌入到其他 agent 环境使用。项目在 `agents/` 中提供 agent 规格,因此不同平台可以用自己的任务/调度机制运行同一套流水线。
22
-
23
- ## 快速开始
24
-
25
- ### 作为 npm 包安装
26
-
27
- ```bash
28
- npm install @trashcodermaker/pi-pr-review-handler
29
- ```
30
-
31
- ### 作为 Pi 包安装
32
-
33
- ```bash
34
- pi install @trashcodermaker/pi-pr-review-handler
35
- ```
36
-
37
- ### 通过 skill.sh 安装
38
-
39
- ```bash
40
- npx skills add JI4JUN/pr-review-handler
41
- ```
42
-
43
- ### 从源码安装
44
-
45
- ```bash
46
- git clone https://github.com/JI4JUN/pr-review-handler.git
47
- cd pr-review-handler
48
- npm install
49
- ```
50
-
51
- > [!IMPORTANT]
52
- > 使用本 skill 或包之前,请确保已安装并登录 GitHub CLI(`gh`)。读取 PR 数据、发布回复等核心操作都依赖它。
53
-
54
- ## 工作原理
55
-
56
- 整个流程由多个阶段组成,每个阶段职责清晰;在需要人工确认的位置会设置 checkpoint 暂停执行。
57
-
58
- ```
59
- Phase 0: Setup
60
- Phase 1: Triage ← 并行,只读
61
- Phase 2: Fix ← 串行,最小修改
62
- Phase 3: Reply ← 由编排器直接起草
63
- Phase 4: Post & Push
64
- Phase 5: Report
65
- ```
66
-
67
- ### Phase 0: Setup
68
-
69
- 根据当前分支或显式 PR 链接定位目标 PR,抓取未关闭的 review 线程,并补充抓取 review 级别的整体反馈。本阶段只做数据准备,不修改代码。
70
-
71
- ### Phase 1: Triage
72
-
73
- 读取评论所指代码和完整 review 线程后,逐条将评论分类为:
74
-
75
- - `valid-fix` — 存在真实问题,需要代码修改
76
- - `valid-nofix` — 问题成立,但不需要改代码
77
- - `invalid` — 前提不适用于当前代码,或建议的修复反而有害
78
-
79
- 如果线程很多且平台支持并行 agent,Triage 会并行执行以提高速度。
80
-
81
- > [!TIP]
82
- > Triage 默认偏保守。如果某条评论含义不清,可直接标记为 `invalid`,原因写 `unclear — needs human review`。
83
-
84
- ### Phase 2: Fix
85
-
86
- 对每条 `valid-fix` 线程,由专门的 implementation agent 施加满足 review 要求的最小改动。修改前先追踪引用关系;如果改动影响函数签名、类型或导出,会同步更新调用方和测试;不顺手做无关的重构或清理。
87
-
88
- 本阶段所有修复都会提交到本地,但 **不会推送**。
89
-
90
- 全部修复完成后会执行:
91
-
92
- ```bash
93
- npx tsc --noEmit
94
- ```
95
-
96
- 如果类型检查失败,流程会自动定位引入错误的提交,回滚、修复后重新提交,再继续后续阶段。
97
-
98
- ### Phase 3: Reply
99
-
100
- 编排器基于以下信息逐条起草回复:
101
-
102
- - 原始线程数据
103
- - Triage 结论
104
- - 实际变更:`git diff origin/{branch}...HEAD`
105
- - Phase 2 中的失败记录
106
-
107
- 回复会尽量匹配评论者的语言和语气,保持简洁,避免防御性措辞。
108
-
109
- ### Phase 4: Post & Push
110
-
111
- 将用户确认后的回复发布到 GitHub,并把本地的 review-fix 提交统一推送。
112
-
113
- 可选地,流程还可以:
114
-
115
- - 向原 reviewer 请求 re-review
116
- - 将已处理的 review 线程标记为“Addressed”并关闭
117
-
118
- ### Phase 5: Report
119
-
120
- 最后输出简要总结:
121
-
122
- ```
123
- ✅ Triage: N/N 条线程已处理
124
- ✅ Fixes: M/K 条 valid-fix 已应用(本地提交并推送)
125
- ❌ Failed: {thread} — {reason}
126
- ✅ Replies: P/P 条回复已起草并发布
127
- ```
128
-
129
- ## 使用方法
130
-
131
- ### 在 agent 中调用
132
-
133
- 安装为 skill 后,直接用自然语言发起请求即可。常见触发方式包括:
134
-
135
- - "帮我处理这个 PR 的 review:<https://github.com/owner/repo/pull/123>"
136
- - "回复 reviewer 的评论"
137
- - "看看 PR 里那些 unresolved threads"
138
- - "review 提的问题要修一下"
139
- - "CI 过了,但 review 还没回"
140
- - "someone left comments on my PR"
141
- - "帮我看看那些人提的意见"
142
-
143
- ### 命令行手动驱动
144
-
145
- 如果你希望手动控制流程,也可以直接基于 GitHub CLI 命令执行。本 skill 和包的主要价值,是把这些命令封装成 agent 可理解、可执行的结构化流水线。
146
-
147
- ## 环境要求
148
-
149
- - 已安装并登录 GitHub CLI(`gh`)
150
- - Git 工作区足够干净,可以创建 review-fix 提交
151
- - 若想执行最后的 `tsc --noEmit` 检查,项目应为 Node.js / TypeScript 项目
152
-
153
- ## 支持的平台
154
-
155
- | 平台 | 支持情况 |
156
- | --- | --- |
157
- | npm / Node.js | ✅ 可作为已发布包安装 |
158
- | Pi | ✅ 支持作为 package 和 skill 使用 |
159
- | Claude Code | ✅ 通过 Task 机制分发 agent |
160
- | Cursor | ✅ 通过 background agent 分发 |
161
- | 其他 agent 客户端 | ✅ 使用 `agents/` 中的 agent 规格,以内联方式运行 |
162
-
163
- ## 备注
164
-
165
- - 项目在 `agents/` 中提供可复用的 agent 规格。
166
- - 若平台支持并行 agent,Triage 可并行执行;否则以内联方式运行。
167
- - 流程中有两处会暂停等待确认:一次在 Triage 结论出来后,一次在发布回复前。
168
- - 推送仅在回复确认后执行一次。
169
- - Fix 阶段默认串行执行,以避免并发修改带来的冲突。