prr-kit 2.0.10 → 2.0.11
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
|
|