@henryqw/pi-pr 6.2.0 → 6.2.1

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.
@@ -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.1",
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",