@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.
@@ -1,95 +1,51 @@
1
1
  ---
2
2
  name: pi-pr-comment-sweep
3
- description: Fetch GitHub pull request comments with gh, assess actionable feedback, then apply, validate, commit, push, and resolve scoped fixes without approval pauses. Use when asked to sweep, address, or fix PR comments end to end.
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
- Address actionable feedback on current-branch PR or supplied PR number/URL.
9
- Run standalone; never invoke, defer to, or modify Shipyard.
10
-
11
- 1. Resolve `<skill>` as the absolute directory containing the effective
12
- `SKILL.md` loaded by Pi. It is a placeholder to substitute, never a literal
13
- path; use it for bundled scripts and references. Set optional `$PR` and
14
- require a clean tracked tree. On resume, dirt, or head mismatch, read
15
- [Sweep recovery](<skill>/references/recovery.md>) and stop unless its
16
- checkpoint or adoption rules pass. For a fresh sweep:
17
-
18
- ```bash
19
- SNAPSHOT=$(mktemp)
20
- if [ -n "${PR:-}" ]; then
21
- node "<skill>/scripts/pr-feedback.mjs" target --pr "$PR"
22
- node "<skill>/scripts/pr-feedback.mjs" fetch --pr "$PR" --out "$SNAPSHOT"
23
- else
24
- node "<skill>/scripts/pr-feedback.mjs" target
25
- node "<skill>/scripts/pr-feedback.mjs" fetch --out "$SNAPSHOT"
26
- fi
27
- PR=$(node "<skill>/scripts/pr-feedback.mjs" snapshot-url --snapshot "$SNAPSHOT")
28
- ```
29
-
30
- Target verification requires authenticated `gh`, an open PR, exact local/PR
31
- head, and one matching configured push target. Inspect the base and full
32
- diff. Maintain the recovery reference's one-line checkpoint after each phase.
33
-
34
- 2. Initial fetch prints a compact index of every feedback ID. Later fetches into
35
- a copied snapshot print compact indexes of additions, edits, and state changes.
36
- The snapshot remains complete. A thread record with child IDs is a container:
37
- inspect `thread_comment` IDs directly. Do not call `show` on the parent solely
38
- to discover its children. Show the parent only if it has no child or parent-level
39
- metadata is actually needed. For each non-obvious item, inspect only that item:
40
-
41
- ```bash
42
- node "<skill>/scripts/pr-feedback.mjs" show --snapshot "$SNAPSHOT" --id "$ID"
43
- ```
44
-
45
- Issue independent `show` lookups in one tool-call round. Always inspect every
46
- unresolved feedback item before triage. Never
47
- read or print the whole raw snapshot when `show` provides the bounded lookup.
48
- Follow [Thread triage](<skill>/references/thread-triage.md>) and ledger every item as
49
- `actionable`, `non-actionable`, or `blocked`, with terse evidence, smallest
50
- fix, and regression. Never reconstruct GraphQL pagination.
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 Recovery
1
+ # Sweep recovery
2
2
 
3
- Read only for resume or PR-head mismatch.
3
+ The workflow owns one versioned recovery file for each canonical worktree:
4
4
 
5
- ## Checkpoint
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
- Run the clean-tree and Git-operation checks immediately before the fast-forward.
48
- Stop on an absent object, divergence, dirty tracked or untracked state, an active
49
- Git operation, or an ambiguous push URL. Never stash, reset, or clean. Re-run
50
- target verification and initial fetch after fast-forward.
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: ignore.
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 `actionable`, `non-actionable`, or `blocked` with evidence,
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.