@henryqw/pi-pr 6.2.0 → 6.2.2

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,6 +1,6 @@
1
1
  # `@henryqw/pi-pr`
2
2
 
3
- See the current branch pull request in the Pi footer. Use `/pr` to run its next safe step. It shows CI, review, merge, and lifecycle status without repeated `gh` commands.
3
+ See the current branch pull request in the Pi footer. Run `/pr` to create, update, repair, review, or merge it when safe, without repeatedly checking GitHub by hand.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,198 +8,79 @@ See the current branch pull request in the Pi footer. Use `/pr` to run its next
8
8
  pi install npm:@henryqw/pi-pr
9
9
  ```
10
10
 
11
- Requires an authenticated GitHub CLI session (`gh auth login`) and a checkout on GitHub.com or GitHub Enterprise. Run `gh auth status` to verify authentication.
12
-
13
- ## Feedback snapshots
14
-
15
- Run the bundled read-only diagnostic CLI from the installed package directory:
16
-
17
- ```bash
18
- node skills/pi-pr-comment-sweep/scripts/pr-feedback.mjs fetch [--pr PR] (--out FILE | --json)
19
- node skills/pi-pr-comment-sweep/scripts/pr-feedback.mjs show --snapshot FILE --id ID
20
- node skills/pi-pr-comment-sweep/scripts/pr-feedback.mjs checks [--pr PR] --expected-head SHA
21
- node skills/pi-pr-comment-sweep/scripts/pr-feedback.mjs self-test
22
- ```
23
-
24
- `checks` verifies the current pull request and its checks against the full head SHA; `self-test`
25
- checks local CLI behavior. `pr-feedback.mjs fetch --out FILE` prints a compact feedback index. The index
26
- includes IDs, kinds, states, authors, locations, and parent IDs as needed. It
27
- does not print comment or review bodies.
28
-
29
- With `--out`, it atomically replaces `FILE` as a mode-0600 file. It does not
30
- change the parent directory's permissions.
31
-
32
- The saved snapshot still contains the complete feedback. `fetch --json` also
33
- keeps the complete JSON output. Read one item with
34
- `pr-feedback.mjs show --snapshot FILE --id ID`.
35
-
36
- `show` prints one JSON record with its exact stored body and fields. A thread
37
- record includes child IDs without child bodies. Treat that record as a container.
38
- Inspect the `thread_comment` IDs directly. Do not call `show` on the parent only
39
- to find children. Show the parent only when it has no child, or when you need
40
- parent-level metadata. Issue independent `show` lookups in one tool-call round.
41
- A nested comment includes only its parent thread's ID, state, and location.
42
- Missing, unknown, duplicate, or ambiguous IDs fail. `show` does not run Git, call
43
- GitHub, use the network, or write files.
11
+ Requires an authenticated GitHub CLI session (`gh auth login`) and a GitHub.com or GitHub Enterprise checkout. Verify authentication with `gh auth status`.
44
12
 
45
13
  ## Works with
46
14
 
47
- **Requires.** [`@henryqw/pi-herdr`](https://pi.henry.wang/extensions/pi-herdr) is the shared Herdr CLI client. It installs with this package.
48
-
49
- **Uses.** [`@henryqw/pi-process`](https://pi.henry.wang/packages/pi-process) runs bounded child processes. It installs with this package.
15
+ | Package | Relationship | Purpose |
16
+ | --- | --- | --- |
17
+ | [`@henryqw/pi-footer`](https://pi.henry.wang/extensions/pi-footer) | Improves | Shows current-branch pull-request status in the shared footer. |
18
+ | [`@henryqw/pi-herdr`](https://pi.henry.wang/extensions/pi-herdr) | Required | Provides the Herdr CLI client when workspace renaming is available. |
19
+ | [`@henryqw/pi-process`](https://pi.henry.wang/packages/pi-process) | Required | Runs bounded child processes. |
50
20
 
51
- **Improves.** [`@henryqw/pi-footer`](https://pi.henry.wang/extensions/pi-footer) shows current-branch pull-request status in the footer.
21
+ The required packages install with `pi-pr`; Herdr itself is optional.
52
22
 
53
23
  ## Use
54
24
 
55
- Run `/pr` in a GitHub checkout. It reads fresh pull request and local state, then continues through safe routes in one invocation until it needs external input, meets an ambiguous blocker, waits for CI or review, or merges. The PR hostname selects its GitHub API host, and the extension works outside Herdr.
56
-
57
- `/pr` takes no flags, prose, or base argument. The package selects the branch base from one `branch.<branch>.gh-merge-base` setting or the validated `origin` default branch. After each published change, the extension rediscovers fresh GitHub mergeability, feedback, and CI before another action; no remembered flags or second `/pr` are needed. A stopped workflow may be resumed with a new `/pr` after the blocker is addressed.
25
+ Run `/pr` in a GitHub checkout. It reads fresh local and GitHub state, takes the next safe route, and continues until it needs external input, encounters a blocker, waits for CI or review, or merges. It works outside Herdr. A stopped workflow can be retried with `/pr` after the blocker is addressed.
58
26
 
59
27
  | Surface | Type | Purpose |
60
28
  | --- | --- | --- |
61
- | `/pr` | command | Inspect and run the current pull request's next safe route. |
62
- | Footer | ui | Show a linked `PR #number` and one plain-language status. |
63
- | Widget | ui | Show one action hint or transient routing status. |
64
-
65
- The footer already shows the pull request and status. Actionable widgets omit duplicate identity and status. Each uses one semantic status icon, a space, and a plain `Run /pr to …` route. `✗` marks errors, `!` warnings, `✓` success, and `●` accent or neutral routes. In TUI, only the icon uses a theme color. RPC and non-TUI output use the same plain text without ANSI.
66
-
67
- The widget switches to `⠋ Checking pull request…` as soon as `/pr` starts discovery. The braille spinner animates in TUI mode. RPC receives one plain static line. The footer stays unchanged. The routing widget clears after route selection and before any prompt, notification, mutation, or workflow dispatch.
29
+ | `/pr` | command | Human entry point; inspect and act on the current branch's pull request. |
30
+ | `pi_pr_create` | tool | Agent-only guarded creation steps selected by `/pr`. |
31
+ | `pi_pr_fix_ci` | tool | Agent-only guarded GitHub Actions repair. |
32
+ | `pi_pr_publish_work` | tool | Agent-only scoped local work publication. |
33
+ | `pi_pr_sweep` | tool | Agent-only feedback triage and publication. |
34
+ | `pi_pr_update_branch` | tool | Agent-only conflict rebase and publication. |
35
+ | `pi-pr-comment-sweep` | skill | Agent guidance for review feedback. |
36
+ | `pi-pr-create` | skill | Agent guidance for creating a pull request. |
37
+ | `pi-pr-fix-ci` | skill | Agent guidance for failed GitHub Actions. |
38
+ | `pi-pr-publish-work` | skill | Agent guidance for publishing local changes. |
39
+ | `pi-pr-update-branch` | skill | Agent guidance for confirmed merge conflicts. |
40
+ | Footer | ui | Linked PR number and plain-language status. |
41
+ | Widget | ui | Action hint or transient routing status. |
42
+
43
+ `/pr` accepts no flags, prose, or base argument. Start with the command, not a helper skill or tool: direct calls cannot establish route authority. The helper run is bound to the current session and worktree.
68
44
 
69
45
  ## Flow
70
46
 
71
- Each footer entry is one linked `PR #number` plus one plain-language status: `N unresolved`, `draft`, `open`, `approved`, `CI running`, `CI failed`, `changes requested`, `base update required`, `merge conflict`, `merge-ready`, `merged`, or `closed`. Colors support the text; they do not carry meaning alone.
72
-
73
47
  ![Flowchart showing /pr reading fresh GitHub and local state and choosing the next safe route](./docs/pr-routing.svg)
74
48
 
75
49
  ### Routes
76
50
 
77
- | Current condition | `/pr` route |
51
+ | Current condition | `/pr` action |
78
52
  | --- | --- |
79
- | No current-branch pull request, no published matching ref, safe Git push configuration, and a commit or ordinary pending work | Start pull-request creation. |
80
- | One open pull request inferred from a published matching ref | Revalidate the exact `remote/ref`, link the local branch without another prompt, then rediscover and continue. |
81
- | Ambiguous or unsafe discovery | Show the blocked reason and do not mutate Git or GitHub. |
82
- | Open PR with intended uncommitted or ahead local work | Only when local HEAD descends from the published PR head: inspect, scope, commit if needed, validate and push the exact OID with the saved lease. A behind or diverged HEAD blocks commits. Stop and report when ownership is ambiguous or unrelated work cannot be separated. |
83
- | Confirmed merge conflict | Rebase onto the pinned base commit when the tree is clean and local HEAD equals the PR head. Resolve conflicts only with clear intent; otherwise stop and report. A previously verified rebase resumes guarded publication instead of rewriting HEAD again. |
84
- | GitHub Actions job failed | Run the CI fix workflow when the same local prerequisite holds. |
85
- | External check or commit status failed | Show `CI failed` as a no-action blocker. |
86
- | Changes requested or unresolved review threads | Start or resume the package comment sweep when the same local prerequisite holds. |
87
- | New standalone feedback (including conversation comments) | Start or resume a guarded sweep when the tree is clean and local HEAD equals the PR head. |
88
- | No-action state | Report the state without taking action. |
89
- | Merge-ready pull request | Recheck fresh state and squash-merge without another prompt. |
90
-
91
- `pi-pr-create` selects its base in this order: one `branch.<branch>.gh-merge-base` value, then the default branch of validated `origin`. It captures the selected base OID and merge-base. Creation requires a commit ahead or ordinary pending work, including untracked files. A Git operation in progress does not count as pending work. If the current branch is the selected base, pi-pr stays silent because GitHub cannot create a pull request from a ref to itself.
92
-
93
- The base always comes from validated `origin`. The head may use that repository or a fork with the same GitHub source. Base and head must use the same GitHub host. Other fork relationships stop before mutation.
94
-
95
- It does not merge or rebase the base during creation. The package helper inspects and commits selected pending paths, including both sides of a staged rename. After a clean verification and relevant validation, it pushes the captured OID.
96
-
97
- A configured target never changes branch upstream settings. Without a target, the helper pushes the captured OID to the local branch ref on validated `origin` and fetches its tracking ref. It leaves upstream unset. It creates or updates and validates the exact PR before it sets and verifies upstream. A failed setup rolls back only unchanged helper-owned settings. If configuration changed concurrently, it stops without overwriting it. Retrying `publish` resumes setup without another push or PR mutation.
98
-
99
- Without a configured push target, discovery checks validated remotes for the same branch ref. One exact open PR becomes an inferred target. `/pr` links the single exact `remote/ref` without a separate confirmation, then rediscovers the same configured PR before continuing. The extension revalidates the branch, PR, remote OID, and Git configuration before mutation. It rolls back its upstream and remote-tracking changes if final verification fails.
100
-
101
- Multiple candidate remotes, multiple matching PRs, OID mismatches, and unsafe Git push configuration block routing. A published ref with no PR also blocks creation. If no candidate ref exists, creation uses only a validated `origin` destination.
102
-
103
- The creation workflow repeats destination, remote OID, PR, and configuration checks immediately before pushing. It pushes to the saved validated URL, not a mutable remote name. Every push uses the saved remote OID as an exact lease. Existing refs must also be ancestors of the captured local OID. A missing ref uses an empty lease as a create-only compare-and-swap.
104
-
105
- Each helper workflow receives a random run ID and its first action. The run stays bound to one session, canonical worktree, route, and fresh authority. Helper calls from another run, session, worktree, or route fail.
106
-
107
- For comment sweeps, `/pr` checks the package recovery file without changing it. It selects `start` when recovery is absent. It selects `resume` only when valid recovery matches the fresh route authority. Invalid recovery stays unchanged and blocks dispatch with its path and reason. One `/pr` inspects all feedback, records a complete disposition ledger and exact owned paths, then makes scoped fixes, validates, and publishes without a second approval. New sweeps require a clean worktree at the original head before recording the plan; publication validates the clean scoped commit. Recovery preserves the saved plan and checks owned paths and remote authority before continuing. After publication, the helper carries unchanged decisions through a fresh feedback snapshot; new or edited feedback remains blocked for a later fix cycle. It does not expand path ownership or push again in the same sweep.
108
-
109
- A flagless `/pr` reads complete standalone and inline feedback before merge or waiting when the tree is clean and HEAD equals the configured PR head. It compares feedback against the last finalized sweep. New or edited feedback selects the guarded sweep; comments already assessed in that sweep do not. Immediately before merging, it checks again and cancels if feedback arrived meanwhile. A malformed attention marker is preserved and blocks routing rather than silently losing triage history.
110
-
111
- Direct skill or `pi_pr_*` tool calls cannot create route authority. Run `/pr` to reserve a fresh route.
112
-
113
- Only one helper run can exist at a time. Most runs expire when the agent settles. A branch-update conflict stays available for one user-guided continuation, then expires after that continuation settles. Session replacement and shutdown forget the run without aborting or cleaning a pending rebase. A verified rebase can be resumed through a fresh `/pr` run; an unverified rebase intent requires manual recovery, never an automatic retry.
114
-
115
- After a `/pr` create workflow settles, the extension waits for a refresh that finds a configured current PR. It then prefixes the Herdr workspace label with `#<number> • `.
116
-
117
- Failed or empty discovery leaves one rename pending for a later refresh. A restored configured PR completes the rename even when GitHub reports it as merged or closed.
118
-
119
- It removes repeated leading `#<number> • ` prefixes and legacy trailing ` · PR #<number>` suffixes before adding one current prefix. The remaining workspace name must be non-empty. This requires `HERDR_ENV=1` and a non-empty, trimmed `HERDR_WORKSPACE_ID`.
120
-
121
- It renames only the workspace. Outside Herdr, it does nothing.
122
-
123
- If Herdr lookup, JSON validation, or rename fails, the PR and normal UI refresh remain available. Each Herdr command has a 10-second timeout. The extension warns with `Herdr workspace rename failed: <error>`.
124
-
125
- Current-branch discovery reads pull requests associated with the exact push repository ref. It does not run a global branch search. It finds a fork-head PR whose base is an upstream repository. A unique historical match uses the exact remote push-ref OID, not local HEAD.
126
-
127
- A no-action state includes drafts, merged or closed pull requests, unsupported failed CI, pending review, and blocked merge policy. Running CI blocks merge but not other mutating workflows. A matching verified branch-update recovery takes priority, then matching comment-sweep recovery. Otherwise a dirty tree or ahead local HEAD selects the scoped local publication helper first. A behind or diverged head remains a blocker unless matching recovery can resume.
128
-
129
- ### Route priority
130
-
131
- A missing pull request uses creation. For an existing configured open, non-draft pull request, verified branch-update recovery is checked first, then matching sweep recovery. They can resume guarded publication or owned edits before the local clean/equal gate. Otherwise, the first matching condition wins:
132
-
133
- 1. Merged, closed, or draft: no action.
134
- 2. Dirty worktree or ahead local HEAD: scope and publish intended local work. In-progress Git operations block its helper; unrelated pending paths require an ownership decision.
135
- 3. Confirmed merge conflict: rebase onto the pinned base OID only with a clean, equal local HEAD. A behind base alone never triggers a rebase.
136
- 4. Diagnosable GitHub Actions failure: run CI fix with the same local prerequisite.
137
- 5. Changes requested or unresolved review threads: run the comment sweep.
138
- 6. New or edited standalone feedback, including conversation comments and review bodies: triage and fix scoped issues without another approval.
139
- 7. Running CI, pending review, blocked policy, or unsafe local merge state: wait or report the blocker.
140
- 8. Merge-ready: allow a clean local HEAD equal to or behind the PR head. Revalidate, then squash-merge directly.
141
-
142
- The sweep finalizes its feedback marker only after checking the complete refreshed generation. GitHub offers no resolution control for standalone comments or review bodies; they are triaged and reported, not marked resolved.
143
-
144
- The comment sweep resolves its bundled helper and references from the installed package skill path. It does not require an external `jq` executable.
145
-
146
- After publishing, `refresh` freezes the complete latest feedback, retains unchanged decisions, and blocks new or edited actionable items for the next `/pr` cycle. It needs no second record or approval. `resolve` selects eligible unresolved review threads with no blocked children, posts a commit URL for addressed threads or a one-sentence ledger reason for non-actionable threads, and verifies the returned reply ID before resolving. The helper checks feedback capacity and leaves blocked threads open. If a reply response is lost without a saved ID, recovery stops without replaying or guessing from a matching comment body. `finalize` uses its saved projection and rechecks complete live feedback. Standalone comments and review bodies have no GitHub resolution state; report them without claiming they were resolved.
147
-
148
- The sweep runs existing non-destructive checks on the clean committed `HEAD` before publishing. Finalization reruns them as a later state guard.
53
+ | No PR and a commit ahead or ordinary pending work | Create a PR, provided the destination is unambiguous and safe. |
54
+ | One matching published PR without a configured upstream | Link its exact remote ref, then rediscover and continue. |
55
+ | Intended uncommitted or ahead local work on an open PR | Inspect and publish only owned paths after validation. Stop if ownership is ambiguous or work cannot be separated. |
56
+ | Confirmed merge conflict | Rebase onto the pinned base when local state permits; stop for unclear resolutions. |
57
+ | Failed GitHub Actions job | Inspect failure evidence, make a scoped fix, validate, and publish. Other failed checks block without an automatic fix. |
58
+ | Changes requested, unresolved threads, or new feedback | Triage and address actionable feedback; leave blocked threads open. |
59
+ | Draft, closed, merged, pending review, or running CI | Report the state or wait rather than mutate. |
60
+ | Merge-ready | Recheck fresh state and squash-merge. |
149
61
 
150
- ### Refresh
62
+ Creation chooses the base from `branch.<branch>.gh-merge-base` or the validated `origin` default branch. It requires a commit ahead or ordinary pending work, including untracked files. It stays silent on the base branch itself. The head may be in a fork on the same GitHub host; other fork relationships block creation. A published ref without a PR, multiple candidate remotes or PRs, and unsafe push configuration also block it.
151
63
 
152
- PR discovery starts in the background at session start, so the Pi footer appears before the PR status is ready. When switching sessions, the previous PR status and action hint clear immediately; the new ones appear when discovery finishes. A directory outside a Git worktree stays silent. The UI shows `PR · status unavailable` for other discovery failures and reports only a generic error.
64
+ Local work takes priority over other open-PR routes. Behind or diverged local HEAD blocks publication; a behind base alone never authorizes a rebase. Running CI prevents merging, not a safe earlier route. New or edited standalone comments and review bodies are assessed before merge or waiting; GitHub does not provide a resolution control for these, so they are triaged rather than marked resolved. A sweep makes scoped fixes without a second approval, but new feedback after publication waits for a later `/pr` cycle.
153
65
 
154
- They refresh after local commits, PR creation, pushes, and each dispatched workflow settles. A successful terminal helper action redispatches through fresh discovery before settlement; an incomplete or failed helper does not chain. During creation, intermediate refreshes wait until the workflow settles. They also refresh after any successful delegated task settles. There is no periodic presentation refresh, so external changes may leave the footer and widget stale indefinitely. `/pr` cancels any pending presentation lookup and reads fresh state before routing or acting; it remains authoritative.
66
+ The footer shows one linked `PR #number` and a text status such as `N unresolved`, `CI failed`, `merge conflict`, or `merge-ready`. The widget shows a route hint without repeating the footer. Status text remains meaningful without color. When `/pr` begins, the widget shows `⠋ Checking pull request…` until route selection; errors use `✗`, warnings `!`, success `✓`, and neutral routes `●`.
155
67
 
156
- The create widget stays hidden on a clean branch with no commit ahead. It appears for a commit ahead or ordinary pending work. It stays hidden during a Git operation and when the current branch is the selected base. `/pr` replaces any hint with routing feedback while it selects a route. The feedback clears before route interaction. A dispatched workflow keeps the widget hidden until the agent settles. Direct and no-action routes refresh it after completion. A failed command restores the prior hint and schedules a refresh, except when fresh lookup hits the GitHub API quota: it shows the sanitized message `GitHub API rate limit exhausted; retry after GitHub resets it` and does not immediately retry.
68
+ ### Refresh and Herdr
157
69
 
158
- Presentation uses route priority, so draft appears before running CI. `/pr` reads fresh state before routing or merging. The command is authoritative for actions.
70
+ Discovery starts in the background when a session starts. Status refreshes after local commits, PR creation, pushes, and completed workflows, but not on a timer; external changes may leave the display stale. `/pr` always reads fresh state before acting. Outside a Git worktree the UI stays silent; discovery failures show `PR · status unavailable` with a generic error. A GitHub API quota error instead reports `GitHub API rate limit exhausted; retry after GitHub resets it` without immediately retrying.
159
71
 
160
- ### Session identity
72
+ After creating a PR, the extension prefixes the Herdr workspace name with `#<number> • ` when `HERDR_ENV=1` and `HERDR_WORKSPACE_ID` is non-empty. It renames only the workspace, not the branch. Outside Herdr nothing is renamed. A failed rename leaves the PR and UI usable and warns `Herdr workspace rename failed: <error>`.
161
73
 
162
- The extension records one configured PR identity in the Pi session. It stores only the PR URL, number, host, head identity, and configured target identity. It does not store lifecycle, CI, review, readiness, or base state. Event-driven refreshes do not add duplicate entries, and no repository cache file is created.
74
+ ## State and storage
163
75
 
164
- Normal discovery always runs first. If the configured remote ref was deleted, the footer and `/pr` may reload the exact observed PR URL. The current host, repository, branch, remote, ref, and local HEAD must still match the observation. Repository names use case-insensitive GitHub matching.
76
+ The Pi session stores the configured PR URL, number, host, head identity, and target identity, but not mutable CI or review state. Discovery revalidates this identity against GitHub; no repository cache is created.
165
77
 
166
- The GitHub response must match the observed URL, host, repository, head ref, head OID, and PR number. GitHub supplies fresh mutable state. Invalid session data is ignored. A failed GitHub lookup stops routing and cannot start PR creation.
78
+ In-progress feedback sweeps keep private recovery under `<agent-dir>/config/pi-pr/sweep/<worktree-id>/state.json`; branch updates use `<agent-dir>/config/pi-pr/update-branch/`. These files protect in-progress decisions and remote mutation attempts. A fresh `/pr` resumes only matching, verified recovery. If a record is malformed or mismatched, it remains unchanged and routing stops; do not delete it or replay an uncertain mutation to force continuation.
167
79
 
168
80
  ## Limits and recovery
169
81
 
170
- A comment sweep keeps a private, atomically replaced recovery file under
171
- `<agent-dir>/config/pi-pr/sweep/<worktree-id>/state.json`. It contains the frozen PR identity,
172
- original head and lease, full feedback, ledger, owned paths, and mutation attempts. After a push,
173
- `refresh` stores the new complete snapshot before a replacement ledger; `show` and `record` must
174
- cover it before thread mutations or finalization. Resume rechecks local state and the remote head
175
- and reconciles attempted mutations before issuing a new run. Malformed or mismatched recovery is
176
- preserved and blocks dispatch; never remove it or replay an uncertain mutation to continue.
177
-
178
- A branch update keeps a private recovery file under `<agent-dir>/config/pi-pr/update-branch/`.
179
- It records the original lease before rewriting HEAD, then the verified HEAD after checking the clean
180
- branch against the pinned base. A fresh `/pr` run checks that record and the branch before returning
181
- the verified result for validation and exact-lease publication; it never repeats Git rebase.
182
- If a rebase ended without verification, the record is preserved and routing stops for manual
183
- recovery. After an uncertain push, publication checks the exact remote postcondition without
184
- replaying the push. Malformed or mismatched records stay unchanged and block routing.
185
-
186
- - `/pr` accepts no arguments and does not open a browser.
187
- - It does not run `/done` or `/sweep`.
188
- - Presentation refreshes do not auto-triage comments or start a workflow. The package comment sweep starts or resumes only when an explicit `/pr` selects it. New or blocked standalone comments can select the sweep again after fresh inspection.
189
- - It does not enable auto-merge or add a merge queue.
190
- - It rebases only after a confirmed conflict. It never rebases merely because the base is behind, overwrites concurrent remote updates, deletes branches, or cleans up worktrees. Creation uses exact leases and an empty lease is only an atomic absence check.
191
- - Creation, discovery, and comment-sweep pushes require one unambiguous push URL for the configured destination.
192
- - Presentation fetches use that exact push URL and exact advertised OID. They do not use shared fetch state.
193
- - GitHub may block merging while the base is behind. That alone does not authorize a rebase.
194
- - Direct merges always use squash. GitHub rejects the mutation if repository policy does not allow it.
195
- - Before merge, `/pr` fetches the exact head OID from the validated push URL without shared fetch state.
196
- - A merge, rebase, cherry-pick, revert, or sequencer state blocks direct merge, even when `git status` is empty.
197
- - A conflict rebase resolves the base repository ref directly. It stops if that ref moves before rebase or force-with-lease push. Branches with merge commits since the fork point cannot be rebased automatically; preserve their merge resolutions manually.
198
- - Before a comment-sweep push, it revalidates the configured destination, full PR identity, and local HEAD. It pushes the captured OID.
199
- - CI repair resolves workflow runs from check-suite IDs. It does not treat HTML details links as identity.
200
- - It streams a bounded failed-step log tail and runs one narrow local reproducer before editing.
201
- - Before push, CI repair revalidates the saved destination, open PR, failure evidence, and repair HEAD.
202
- - An already-published local HEAD needs no second push.
203
- - Direct merge requires a fresh readiness check and an exact head OID; `/pr` is the authorization, not a separate confirmation dialog.
204
- - After a successful merge, the create widget stays hidden until a new local commit.
205
- - Only authenticated GitHub.com and GitHub Enterprise repositories are supported.
82
+ - `/pr` does not open a browser, run `/done` or `/sweep`, enable auto-merge, or use a merge queue. It only starts workflows when explicitly invoked.
83
+ - Pushes use a saved exact remote OID lease and revalidate the destination. Concurrent updates block publication instead of being overwritten. Creation does not change the base branch, and a configured push target does not change upstream settings.
84
+ - Direct merge requires a clean, safe local Git state and fresh matching head; it always squashes. GitHub repository policy may still reject it. No branch or worktree is deleted.
85
+ - A Git operation in progress blocks direct merge. An unverified conflict rebase needs manual recovery; a verified rebase can resume through `/pr`. Branches with merge commits since the fork point require manual rebase resolution.
86
+ - Only authenticated GitHub.com and GitHub Enterprise repositories are supported. Resolve ambiguous remotes, unrelated local changes, or GitHub blockers before retrying `/pr`.
@@ -40,7 +40,7 @@ export type PrCommandInvocation = ((nextStep: NextStep) => void) & {
40
40
  export type PrCommandHandler = (
41
41
  args: string,
42
42
  ctx: ExtensionContext,
43
- onRouteResolved?: PrCommandInvocation | ((nextStep: NextStep) => void),
43
+ onRouteResolved?: PrCommandInvocation,
44
44
  ) => Promise<NextStep>;
45
45
 
46
46
  export type WorkflowPromptIdentity = Readonly<{
@@ -234,15 +234,12 @@ export function createPrCommandHandler(
234
234
  const release = dependencies.releaseWorkflow ?? (() => {});
235
235
  const handle = async (
236
236
  args: string, ctx: ExtensionContext,
237
- onRouteResolved?: PrCommandInvocation | ((nextStep: NextStep) => void),
237
+ onRouteResolved?: PrCommandInvocation,
238
238
  linkedAuthority?: CurrentPullRequest,
239
239
  ): Promise<NextStep> => {
240
- const commandInvocation = onRouteResolved && "assertCurrent" in onRouteResolved
241
- ? onRouteResolved as PrCommandInvocation
242
- : undefined;
243
240
  if (args.trim()) throw new Error("/pr does not accept arguments");
244
241
  const discovery = await load(pi, ctx);
245
- commandInvocation?.assertCurrent();
242
+ onRouteResolved?.assertCurrent();
246
243
  if (linkedAuthority && (discovery.kind !== "current" || discovery.pullRequest.target.provenance !== "configured" ||
247
244
  !isSameConfirmedMerge(linkedAuthority, discovery.pullRequest))) {
248
245
  throw new Error("Link branch continuation cancelled: configured pull request context changed");
@@ -252,20 +249,20 @@ export function createPrCommandHandler(
252
249
  !discovery.pullRequest.conditions.draft && discovery.pullRequest.target.provenance === "configured" &&
253
250
  await inspectBranchRecovery(discovery.pullRequest, ctx)) {
254
251
  nextStep = "update-branch";
255
- commandInvocation?.assertCurrent();
252
+ onRouteResolved?.assertCurrent();
256
253
  }
257
254
  if (nextStep !== "update-branch" && discovery.kind === "current" && discovery.pullRequest.lifecycle === "open" &&
258
255
  !discovery.pullRequest.conditions.draft && discovery.pullRequest.target.provenance === "configured" &&
259
256
  await inspectSweepRecovery(discovery.pullRequest, ctx)) {
260
257
  nextStep = "sweep";
261
- commandInvocation?.assertCurrent();
258
+ onRouteResolved?.assertCurrent();
262
259
  }
263
260
  if (discovery.kind === "current" && (nextStep === "merge" || nextStep === "none") &&
264
261
  discovery.pullRequest.lifecycle === "open" && !discovery.pullRequest.conditions.draft &&
265
262
  discovery.pullRequest.target.provenance === "configured" &&
266
263
  discovery.pullRequest.local.worktree === "clean" && discovery.pullRequest.local.head === "equal") {
267
264
  if (await needsFeedback(discovery.pullRequest, { cwd: ctx.cwd, signal: ctx.signal, load })) nextStep = "sweep";
268
- commandInvocation?.assertCurrent();
265
+ onRouteResolved?.assertCurrent();
269
266
  }
270
267
  onRouteResolved?.(nextStep);
271
268
  if (discovery.kind === "inactive") return nextStep;
@@ -293,7 +290,7 @@ export function createPrCommandHandler(
293
290
 
294
291
  if (!(nextStep in WORKFLOWS)) throw new Error(`/pr cannot dispatch route ${nextStep}`);
295
292
  const route = nextStep as WorkflowNextStep;
296
- if (commandInvocation?.completedRoutes?.has(route)) {
293
+ if (onRouteResolved?.completedRoutes?.has(route)) {
297
294
  ctx.ui.notify(`PR ${route} already ran; inspect fresh state before retrying`, "warning");
298
295
  return "none";
299
296
  }
@@ -303,7 +300,7 @@ export function createPrCommandHandler(
303
300
  ctx,
304
301
  route,
305
302
  reservation,
306
- commandInvocation,
303
+ onRouteResolved,
307
304
  reserve,
308
305
  markPromptQueued,
309
306
  release,
@@ -96,7 +96,7 @@ export function isPullRequestCreationEligible(branch: BranchCreationState): bool
96
96
  (branch.ahead > 0 || branch.worktree === "dirty");
97
97
  }
98
98
 
99
- function deriveAutomaticNextStep(discovery: PullRequestDiscovery<PullRequest & { target: PullRequestTarget }>): NextStep {
99
+ export function deriveNextStep(discovery: PullRequestDiscovery<PullRequest & { target: PullRequestTarget }>): NextStep {
100
100
  if (discovery.kind === "inactive") return "none";
101
101
  if (discovery.kind === "blocked") return "blocked";
102
102
  if (discovery.kind === "none") return isPullRequestCreationEligible(discovery.branch) ? "create" : "none";
@@ -105,7 +105,3 @@ function deriveAutomaticNextStep(discovery: PullRequestDiscovery<PullRequest & {
105
105
  }
106
106
  return derivePullRequestNextStep(discovery.pullRequest);
107
107
  }
108
-
109
- export function deriveNextStep(discovery: PullRequestDiscovery<PullRequest & { target: PullRequestTarget }>): NextStep {
110
- return deriveAutomaticNextStep(discovery);
111
- }
@@ -91,14 +91,12 @@ function footerStatus(input: PrDisplayInput): Pick<PrFooter, "text" | "color"> {
91
91
  return { text: "open", color: "accent" };
92
92
  }
93
93
 
94
- function widgetText(input: PrDisplayInput, nextStep: NextStep): string | undefined {
94
+ function widgetText(nextStep: NextStep): string | undefined {
95
95
  switch (nextStep) {
96
96
  case "publish-work":
97
97
  return "Run /pr to publish local work";
98
98
  case "update-branch":
99
- return input.conditions.conflict
100
- ? "Run /pr to resolve merge conflict"
101
- : "Run /pr to update branch";
99
+ return "Run /pr to resolve merge conflict";
102
100
  case "sweep":
103
101
  return "Run /pr to address review feedback";
104
102
  case "fix-ci":
@@ -145,7 +143,7 @@ export function projectPrDisplay(
145
143
  url: input.url.href,
146
144
  ...footerStatus(input),
147
145
  },
148
- widget: widgetText(input, nextStep),
146
+ widget: widgetText(nextStep),
149
147
  };
150
148
  }
151
149
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-pr",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
4
  "description": "Run /pr to safely discover or link the current pull request, then create, update, address feedback, fix CI, or merge when ready.",
5
5
  "keywords": [
6
6
  "pi-package",