prr-kit 2.0.10 → 2.0.12
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/package.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<rule>ALWAYS halt at decision points and wait for user input</rule>
|
|
8
8
|
<rule>ALWAYS load config variables before starting any workflow</rule>
|
|
9
9
|
<rule>Use native file-reading tools for file content — avoid shell commands for reading files</rule>
|
|
10
|
+
<rule>For runtime code execution (file parsing, JSON building, temp file operations), use Node.js — do not assume Python is available</rule>
|
|
10
11
|
</rules>
|
|
11
12
|
|
|
12
13
|
<variable-resolution>
|
|
@@ -149,22 +149,14 @@ Bash heredoc breaks with Unicode characters, emojis, backticks, and nested quote
|
|
|
149
149
|
2. **Execute** it with `node`
|
|
150
150
|
3. Script writes the final JSON to `{temp_dir}/prr-payload.json`
|
|
151
151
|
|
|
152
|
-
**Step A —
|
|
153
|
-
```bash
|
|
154
|
-
node --version 2>/dev/null && echo "use-node" || (python3 --version 2>/dev/null && echo "use-python3") || echo "no-runtime"
|
|
155
|
-
```
|
|
156
|
-
Prefer `node`. Fallback: `python3`, then `python`.
|
|
152
|
+
**Step A — Write the build script using the Write tool** (NOT echo/heredoc/Bash):
|
|
157
153
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Use the Write tool to create `{temp_dir}/build-payload.mjs` (Node.js) or `{temp_dir}/build-payload.py` (Python).
|
|
154
|
+
Use the Write tool to create `{temp_dir}/build-payload.mjs`.
|
|
161
155
|
|
|
162
156
|
The script must:
|
|
163
|
-
- Define all string values (comment bodies, summary) as native string variables — no manual JSON escaping needed,
|
|
157
|
+
- Define all string values (comment bodies, summary) as native string variables — no manual JSON escaping needed, Node.js handles it
|
|
164
158
|
- Build the payload object in memory
|
|
165
|
-
- Write to `{temp_dir}/prr-payload.json` using
|
|
166
|
-
- Node.js: `JSON.stringify(payload, null, 2)`
|
|
167
|
-
- Python: `json.dumps(payload, ensure_ascii=False, indent=2)`
|
|
159
|
+
- Write to `{temp_dir}/prr-payload.json` using `JSON.stringify(payload, null, 2)`
|
|
168
160
|
|
|
169
161
|
**Node.js template** (`build-payload.mjs`):
|
|
170
162
|
```js
|
|
@@ -184,36 +176,14 @@ writeFileSync("{temp_dir}/prr-payload.json", JSON.stringify(payload, null, 2), "
|
|
|
184
176
|
console.log(`OK: ${payload.comments.length} comments`)
|
|
185
177
|
```
|
|
186
178
|
|
|
187
|
-
**
|
|
188
|
-
```python
|
|
189
|
-
import json
|
|
190
|
-
|
|
191
|
-
payload = {
|
|
192
|
-
"commit_id": "COMMIT_SHA",
|
|
193
|
-
"body": "SUMMARY BODY",
|
|
194
|
-
"event": "REQUEST_CHANGES",
|
|
195
|
-
"comments": [
|
|
196
|
-
{"path": "src/file.js", "line": 42, "side": "RIGHT", "body": "🔴 **[BLOCKER]** ..."},
|
|
197
|
-
]
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
with open("{temp_dir}/prr-payload.json", "w", encoding="utf-8") as f:
|
|
201
|
-
json.dump(payload, f, ensure_ascii=False, indent=2)
|
|
202
|
-
print(f"OK: {len(payload['comments'])} comments")
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**Step C — Execute:**
|
|
179
|
+
**Step B — Execute:**
|
|
206
180
|
```bash
|
|
207
181
|
node "{temp_dir}/build-payload.mjs"
|
|
208
|
-
# or: python3 "{temp_dir}/build-payload.py"
|
|
209
182
|
```
|
|
210
183
|
|
|
211
|
-
**Step
|
|
184
|
+
**Step C — Verify output (optional sanity check):**
|
|
212
185
|
```bash
|
|
213
|
-
# Node.js
|
|
214
186
|
node -e "const p=require('{temp_dir}/prr-payload.json'); console.log('OK:', p.comments.length, 'comments')"
|
|
215
|
-
# Python
|
|
216
|
-
python3 -c "import json; p=json.load(open('{temp_dir}/prr-payload.json')); print('OK:', len(p['comments']), 'comments')"
|
|
217
187
|
```
|
|
218
188
|
|
|
219
189
|
---
|
|
@@ -27,14 +27,9 @@ description: "Post comments via platform CLI/API, verify, clean up"
|
|
|
27
27
|
**Case A — Self-review** (`"Review Can not request changes on your own pull request"`):
|
|
28
28
|
- The authenticated user is the PR author. GitHub disallows `REQUEST_CHANGES` on own PRs.
|
|
29
29
|
- Fix: Update `event` in the payload from `"REQUEST_CHANGES"` to `"COMMENT"` and retry once.
|
|
30
|
-
- Use whichever runtime is available (`{detected_runtime}` from step A earlier):
|
|
31
30
|
|
|
32
31
|
```bash
|
|
33
|
-
# Node.js
|
|
34
32
|
node -e "const fs=require('fs'); const p=JSON.parse(fs.readFileSync('{temp_dir}/prr-payload.json','utf-8')); p.event='COMMENT'; fs.writeFileSync('{temp_dir}/prr-payload.json',JSON.stringify(p,null,2)); console.log('event → COMMENT')"
|
|
35
|
-
|
|
36
|
-
# Python3
|
|
37
|
-
python3 -c "import json; f=open('{temp_dir}/prr-payload.json','r+'); p=json.load(f); p['event']='COMMENT'; f.seek(0); json.dump(p,f,ensure_ascii=False,indent=2); f.truncate(); print('event → COMMENT')"
|
|
38
33
|
```
|
|
39
34
|
Then retry the POST above.
|
|
40
35
|
|
|
@@ -79,7 +74,7 @@ done
|
|
|
79
74
|
|
|
80
75
|
Use the runtime script approach to build the summary payload first:
|
|
81
76
|
|
|
82
|
-
Write `{temp_dir}/build-bb-summary.mjs`
|
|
77
|
+
Write `{temp_dir}/build-bb-summary.mjs` using the Write tool:
|
|
83
78
|
|
|
84
79
|
```js
|
|
85
80
|
// Node.js
|
|
@@ -167,9 +162,7 @@ rm -f "{temp_dir}/prr-payload.json" \
|
|
|
167
162
|
"{temp_dir}/prr-bb-"*.json \
|
|
168
163
|
"{temp_dir}/prr-bb-summary.json" \
|
|
169
164
|
"{temp_dir}/build-payload.mjs" \
|
|
170
|
-
"{temp_dir}/build-
|
|
171
|
-
"{temp_dir}/build-bb-summary.mjs" \
|
|
172
|
-
"{temp_dir}/build-bb-summary.py"
|
|
165
|
+
"{temp_dir}/build-bb-summary.mjs"
|
|
173
166
|
rmdir "{temp_dir}" 2>/dev/null || true
|
|
174
167
|
```
|
|
175
168
|
|
|
@@ -180,28 +180,7 @@ Wait for response. If empty → detect `origin/main` or `origin/master`.
|
|
|
180
180
|
Set `base_branch` = input or detected default.
|
|
181
181
|
Set `diff_range` = `{base_branch}...{target_branch}`.
|
|
182
182
|
|
|
183
|
-
### 1d.
|
|
184
|
-
|
|
185
|
-
Use the first available method based on platform:
|
|
186
|
-
|
|
187
|
-
**GitHub** (if `active_platform = github` and `pr_number` is set):
|
|
188
|
-
```bash
|
|
189
|
-
gh pr diff {pr_number} --repo {active_platform_repo}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
**GitLab** (if `active_platform = gitlab` and `pr_number` is set):
|
|
193
|
-
```bash
|
|
194
|
-
glab mr diff {pr_number} --repo {active_platform_repo}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
**Azure DevOps / Bitbucket / fallback:**
|
|
198
|
-
```bash
|
|
199
|
-
git -C {target_repo} diff {base_branch}...{target_branch} --stat
|
|
200
|
-
git -C {target_repo} diff {base_branch}...{target_branch}
|
|
201
|
-
```
|
|
202
|
-
Store diff in memory. Count files changed, lines added/removed.
|
|
203
|
-
|
|
204
|
-
### 1e. Create Session Folder
|
|
183
|
+
### 1d. Create Session Folder
|
|
205
184
|
|
|
206
185
|
Compute the session output folder:
|
|
207
186
|
|
|
@@ -233,9 +212,30 @@ mkdir -p "{session_output}"
|
|
|
233
212
|
|
|
234
213
|
**Store in working context:** `session_output`, `target_branch`, `base_branch`, `pr_number`, `pr_title`, `active_platform`, `active_platform_repo`.
|
|
235
214
|
|
|
215
|
+
### 1e. Load diff
|
|
216
|
+
|
|
217
|
+
Use the first available method based on platform:
|
|
218
|
+
|
|
219
|
+
**GitHub** (if `active_platform = github` and `pr_number` is set):
|
|
220
|
+
```bash
|
|
221
|
+
gh pr diff {pr_number} --repo {active_platform_repo} > "{session_output}/full.diff"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**GitLab** (if `active_platform = gitlab` and `pr_number` is set):
|
|
225
|
+
```bash
|
|
226
|
+
glab mr diff {pr_number} --repo {active_platform_repo} > "{session_output}/full.diff"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Azure DevOps / Bitbucket / fallback:**
|
|
230
|
+
```bash
|
|
231
|
+
git -C {target_repo} diff {base_branch}...{target_branch} > "{session_output}/full.diff"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Save the full diff to `{session_output}/full.diff`. Read that file to count files changed, lines added/removed.
|
|
235
|
+
|
|
236
236
|
### 1f. Generate Diffs Folder
|
|
237
237
|
|
|
238
|
-
Parse
|
|
238
|
+
Parse `{session_output}/full.diff` and write per-file markdown files under `{session_output}/diffs/`, mirroring the repo folder tree.
|
|
239
239
|
|
|
240
240
|
**For each changed file in the diff:**
|
|
241
241
|
|
|
@@ -275,6 +275,8 @@ After writing all files, show summary:
|
|
|
275
275
|
✓ Diffs saved: {file_count} files → {session_output}/diffs/
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
+
**⛔ After this point, do NOT run any further `git diff` commands to read file changes. All diff content is now available at `{session_output}/diffs/`. Read those files directly for all subsequent phases.**
|
|
279
|
+
|
|
278
280
|
---
|
|
279
281
|
|
|
280
282
|
## PHASE 2 — DESCRIBE PR
|