@henryqw/pi-pr 3.1.10 → 4.0.3
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 +29 -12
- package/docs/pr-routing.svg +1 -1
- package/extensions/pr-ci.ts +908 -0
- package/extensions/pr-command.ts +124 -22
- package/extensions/pr-comment-sweep.ts +1102 -0
- package/extensions/pr-create.ts +674 -0
- package/extensions/pr-execution.ts +558 -0
- package/extensions/pr-feedback.ts +519 -0
- package/extensions/pr-github.ts +690 -163
- package/extensions/pr-merge.ts +4 -44
- package/extensions/pr-routing.ts +8 -3
- package/extensions/pr-ui.ts +2 -3
- package/extensions/pr-update-branch.ts +327 -0
- package/extensions/pr.ts +409 -26
- package/package.json +4 -2
- package/skills/pi-pr-comment-sweep/SKILL.md +45 -89
- package/skills/pi-pr-comment-sweep/references/recovery.md +24 -46
- package/skills/pi-pr-comment-sweep/references/thread-triage.md +2 -2
- package/skills/pi-pr-comment-sweep/scripts/pr-feedback.mjs +223 -1799
- package/skills/pi-pr-create/SKILL.md +6 -77
- package/skills/pi-pr-fix-ci/SKILL.md +39 -39
- package/skills/pi-pr-update-branch/SKILL.md +5 -108
|
@@ -1,95 +1,51 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pi-pr-comment-sweep
|
|
3
|
-
description: Fetch GitHub pull request
|
|
3
|
+
description: Fetch GitHub pull request feedback, assess every item, apply scoped fixes, publish one guarded head, and resolve addressed review threads.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# PR Comment Sweep
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
3. Verify feedback against code, callers, tests, and PR intent. For SDK/framework
|
|
53
|
-
claims, inspect installed types and runtime caller; missing public capability
|
|
54
|
-
is `blocked`, never a private-API or cast workaround. Invocation authorizes
|
|
55
|
-
scoped edits, commits, push, and addressed-thread resolution. Stop only for
|
|
56
|
-
unclear behavior, conflicting feedback, material product choice, or scope
|
|
57
|
-
expansion.
|
|
58
|
-
4. Inspect resulting diff and run smallest relevant non-destructive validation.
|
|
59
|
-
Stage only inspected paths; stop on failed or unavailable required validation
|
|
60
|
-
unless user accepts risk. Never change secrets or unrelated work. Never
|
|
61
|
-
hand-edit generated files: change source, run canonical generator for required
|
|
62
|
-
tracked artifacts, then inspect both. Never wait or poll checks.
|
|
63
|
-
5. Commit accepted fixes with scoped Conventional Commit message(s). With no
|
|
64
|
-
fixes, do not commit or push. After clean-tree validation, run
|
|
65
|
-
`node "<skill>/scripts/pr-feedback.mjs" push --snapshot "$SNAPSHOT"`. The
|
|
66
|
-
helper revalidates the configured destination, PR identity, and local HEAD.
|
|
67
|
-
It pushes the captured OID once with no fallback. Then capture the swept head:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
EXPECTED_HEAD=$(git rev-parse --verify 'HEAD^{commit}')
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
6. Copy baseline before final fetch:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
FINAL_SNAPSHOT=$(mktemp)
|
|
77
|
-
cp "$SNAPSHOT" "$FINAL_SNAPSHOT"
|
|
78
|
-
node "<skill>/scripts/pr-feedback.mjs" fetch --pr "$PR" --out "$FINAL_SNAPSHOT"
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Assess the compact delta. Use `show --snapshot "$FINAL_SNAPSHOT" --id "$ID"`
|
|
82
|
-
for each non-obvious delta item and every unresolved human feedback item.
|
|
83
|
-
Then resolve all addressed IDs in one command, repeating the flag:
|
|
84
|
-
`node "<skill>/scripts/pr-feedback.mjs" resolve --pr "$PR" --expected-head
|
|
85
|
-
"$EXPECTED_HEAD" --thread "$ID1" --thread "$ID2"`. Before each resolution,
|
|
86
|
-
the helper re-resolves the checkout's configured push target and exact open PR.
|
|
87
|
-
Never resolve non-actionable or blocked threads. Re-fetch once into `FINAL_SNAPSHOT`, assess
|
|
88
|
-
late delta, batch any newly addressed IDs, then run
|
|
89
|
-
`node "<skill>/scripts/pr-feedback.mjs" checks --pr "$PR" --expected-head
|
|
90
|
-
"$EXPECTED_HEAD"` once. Read-only
|
|
91
|
-
transient retries are allowed; mutation retries and polling are not. Do not
|
|
92
|
-
reply unless explicitly requested.
|
|
93
|
-
|
|
94
|
-
7. Report `PR | actioned | resolved IDs | skipped IDs | pending IDs | checks |
|
|
95
|
-
commits | push | blockers`.
|
|
8
|
+
Use the package-owned comment-sweep workflow. It exposes these closed actions:
|
|
9
|
+
`start`, `resume`, `show`, `record`, `publish`, `refresh`, `resolve`, and
|
|
10
|
+
`finalize`.
|
|
11
|
+
|
|
12
|
+
1. Call `start` for a fresh current-branch pull request. Call `resume` only for
|
|
13
|
+
saved work. Never replace or delete blocked recovery state by hand. See
|
|
14
|
+
[Sweep recovery](references/recovery.md).
|
|
15
|
+
2. Use `show` for one feedback ID at a time. Inspect every conversation
|
|
16
|
+
comment, review, thread, and thread comment. Follow
|
|
17
|
+
[Thread triage](references/thread-triage.md).
|
|
18
|
+
3. Classify every item exactly once as `addressed`, `non-actionable`, or
|
|
19
|
+
`blocked`. Give each entry a short note. Use `record` with the complete
|
|
20
|
+
ledger and the exact repository-relative paths this sweep may change.
|
|
21
|
+
`ownedPaths` is required for this initial record.
|
|
22
|
+
4. Make judgment calls in the model. Verify claims against the code and its
|
|
23
|
+
callers. Edit only owned paths. Add the smallest useful regression. Commit
|
|
24
|
+
accepted fixes with a scoped Conventional Commit message.
|
|
25
|
+
5. Choose one or more existing non-destructive checks that cover the changes.
|
|
26
|
+
Run each on the clean committed `HEAD`. Do not call `publish` unless every
|
|
27
|
+
chosen check passes. Keep the exact commands for finalization.
|
|
28
|
+
6. Call `publish`. It captures the validated clean `HEAD`. It skips the push
|
|
29
|
+
when `HEAD` is unchanged. Otherwise it performs one exact-OID push with the
|
|
30
|
+
original lease. Never retry an unknown push.
|
|
31
|
+
7. Call `refresh` with the current guard and no ledger. It freezes the complete
|
|
32
|
+
fresh feedback, clears the old ledger, and returns a new guard plus bounded
|
|
33
|
+
IDs and kinds. Status never includes feedback bodies.
|
|
34
|
+
8. Use `show` with the new guard for every returned ID. This catches new items
|
|
35
|
+
and edits that kept the same ID. Then call `record` with that guard and one
|
|
36
|
+
complete replacement ledger. Omit `ownedPaths`; the initial ownership stays
|
|
37
|
+
fixed. A stale guard or mismatched coverage fails.
|
|
38
|
+
9. Call `resolve` only with addressed, unresolved parent thread IDs. Do not
|
|
39
|
+
resolve a thread classified as non-actionable or blocked. Do not post replies
|
|
40
|
+
unless the user asks.
|
|
41
|
+
10. Call `finalize` with the exact projection returned by the post-refresh
|
|
42
|
+
`record` and the same chosen checks. Finalization reruns them, then reloads
|
|
43
|
+
feedback as a later state guard. It succeeds only when PR linkage, content,
|
|
44
|
+
and thread states still match.
|
|
45
|
+
|
|
46
|
+
The bundled `scripts/pr-feedback.mjs` is a read-only diagnostic CLI. It supports
|
|
47
|
+
only `fetch`, `show`, `checks`, and `self-test`. It cannot push or resolve
|
|
48
|
+
threads.
|
|
49
|
+
|
|
50
|
+
Report `PR | addressed | resolved IDs | non-actionable | blocked | checks |
|
|
51
|
+
commit | push`.
|
|
@@ -1,50 +1,28 @@
|
|
|
1
|
-
# Sweep
|
|
1
|
+
# Sweep recovery
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The workflow owns one versioned recovery file for each canonical worktree:
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Only ignored `.context/progress.md` may change under `.context/`. Keep one JSON
|
|
8
|
-
line under `## PR comment sweep`; never stage it:
|
|
9
|
-
|
|
10
|
-
```json
|
|
11
|
-
{"workflow":"pi-pr-comment-sweep","pr":"URL","snapshot":"/tmp/file","final_snapshot":null,"head":"SHA","phase":"triage","owned":[],"ledger":{},"checks":[],"commit":null,"pushed":false,"resolved":[]}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Use phases `triage`, `editing`, `validated`, `committed`, `pushed`, or `resolved`.
|
|
15
|
-
Update after each phase. Keep ledger evidence and validation results terse. Edit
|
|
16
|
-
only fields changed by that phase; do not replace the whole JSON line. Keep
|
|
17
|
-
repository-relative owned paths, commit SHA, push state, and resolved IDs.
|
|
18
|
-
|
|
19
|
-
Resume only when workflow and PR match, snapshot exists and names that PR, local
|
|
20
|
-
`HEAD` equals `head`, and tracked dirty paths equal `owned`. Skip completed
|
|
21
|
-
phases and continue with next one. Stop on missing, malformed, or conflicting
|
|
22
|
-
state; never absorb unknown changes. Commands requiring a clean tree remain
|
|
23
|
-
blocked until tracked work is committed or otherwise restored by user.
|
|
24
|
-
|
|
25
|
-
## Adopt PR head
|
|
26
|
-
|
|
27
|
-
Only exact user words **“Adopt PR head”** authorize this path. Inspect
|
|
28
|
-
`gh pr view "$PR" --json url,headRepository,headRefName,headRefOid`. Validate the
|
|
29
|
-
PR URL, full head OID, and ref. Choose exactly one push URL whose normalized
|
|
30
|
-
GitHub host/owner/repository matches `headRepository`. Run:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
git fetch --no-write-fetch-head --no-tags "$PUSH_URL" "$PR_HEAD_SHA"
|
|
34
|
-
git cat-file -e "$PR_HEAD_SHA^{commit}"
|
|
35
|
-
git log --oneline HEAD.."$PR_HEAD_SHA"
|
|
36
|
-
git diff --stat HEAD.."$PR_HEAD_SHA"
|
|
37
|
-
git merge-base --is-ancestor HEAD "$PR_HEAD_SHA"
|
|
38
|
-
STATUS=$(git status --porcelain=v1 --untracked-files=all) || exit 1
|
|
39
|
-
test -z "$STATUS" || exit 1
|
|
40
|
-
for STATE in MERGE_HEAD rebase-merge rebase-apply CHERRY_PICK_HEAD REVERT_HEAD sequencer; do
|
|
41
|
-
STATE_PATH=$(git rev-parse --git-path "$STATE") || exit 1
|
|
42
|
-
test -n "$STATE_PATH" && test ! -e "$STATE_PATH" || exit 1
|
|
43
|
-
done
|
|
44
|
-
git merge --ff-only "$PR_HEAD_SHA"
|
|
5
|
+
```text
|
|
6
|
+
<agent-dir>/config/pi-pr/sweep/<worktree-id>/state.json
|
|
45
7
|
```
|
|
46
8
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
9
|
+
The file is private, bounded to 1 MiB, and replaced atomically. It contains the
|
|
10
|
+
frozen PR authority, original head and lease, complete feedback, exact ledger,
|
|
11
|
+
owned paths, and mutation attempts.
|
|
12
|
+
|
|
13
|
+
Use `resume` when this file exists. Resume checks the canonical worktree, local
|
|
14
|
+
changes, PR linkage, and remote head. It reconciles an attempted push or thread
|
|
15
|
+
resolution before issuing a new epoch and run ID. Calls from the old run then
|
|
16
|
+
fail.
|
|
17
|
+
|
|
18
|
+
A completed post-publish `refresh` stores the new complete snapshot before any
|
|
19
|
+
replacement ledger. Recovery keeps that snapshot in `refresh-pending`, with its
|
|
20
|
+
new generation and fingerprint. Its status exposes only item IDs and kinds.
|
|
21
|
+
Use `show` with the resumed guard to inspect each frozen item. Then use `record`
|
|
22
|
+
without `ownedPaths` to supply exact complete coverage for that snapshot.
|
|
23
|
+
Resolution and finalization remain blocked until this record succeeds.
|
|
24
|
+
|
|
25
|
+
Malformed or oversized recovery is preserved and blocks the workflow. Never
|
|
26
|
+
repair, move, replace, or delete it automatically. An unknown mutation is never
|
|
27
|
+
replayed. If reconciliation cannot prove its exact result, stop and report the
|
|
28
|
+
state path and blocker.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Thread Triage
|
|
2
2
|
|
|
3
|
-
- Resolved:
|
|
3
|
+
- Resolved: record the thread and its comments as `non-actionable`.
|
|
4
4
|
- Outdated: inspect current diff and source lines; re-anchor before deciding relevance.
|
|
5
|
-
- Open/current: record `
|
|
5
|
+
- Open/current: record `addressed`, `non-actionable`, or `blocked` with evidence,
|
|
6
6
|
smallest fix, and regression check.
|
|
7
7
|
- Resolve only an addressed actionable thread after verified fix and head check.
|
|
8
8
|
Never resolve non-actionable or blocked threads; report their IDs as pending.
|