prreviewbuddy 0.31.0 → 0.36.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/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $t as writeAgentPreference, A as removeWorktree, B as workspaceUrl, C as recordTelemetryUploadConsent, Dt as saveWorkspace, Et as reviewedRepositories, G as DEFAULT_WORKSPACE_PORT, H as BUILD_VERSION, I as ensureServer, J as parseWorkspacePort, Jt as git, K as MAX_WORKSPACE_PORT, Kt as resolveTarget, M as relativeTime, N as readIndexToken, O as MANAGED_ROOT, Ot as summarise, P as bootstrapUrl, Q as forgeResolver, Qt as readAgentPreference, R as reviewsUrl, S as record$1, St as positionInLineage, U as PACKAGE_NAME, X as statedWorkspacePort, Xt as resolveModel, Yt as resolveAgent, Z as writePortPreference, a as wasBlocked, at as isTerminal, b as startJob, bt as loadWorkspace, c as updateReview, ct as PHASES, dt as purposeOf, en as CONFIG_PATH, f as UpdateAlreadyRunningError, ft as clearClaim, g as recordKissRun, ht as groupByLineage, i as liveJobsFor, in as agentById, j as modelHelpLines, k as readMarker, m as runningJobs, mt as followedRefName, n as deleteReview$1, nn as AGENT_IDS, nt as allJobs, on as detectAgents, ot as loadJob, p as liveUpdateFor, pt as isClaimed, q as MIN_WORKSPACE_PORT, qt as displayRef, rn as DEFAULT_AGENT_ID, tn as STORE_ROOT, tt as checkReview, ut as progressSteps, v as reanalyseReview, vt as lineageKeyFor, w as telemetryUploadConsent, wt as recentWorkspaces, xt as matchingWorkspaceIds, y as runJob, z as stopServer } from "./delete_review-C2wax0ED.js";
2
+ import { $ as BUILD_VERSION, At as lineageKeyFor, B as modelHelpLines, Bt as summarise, C as recordTelemetryUploadConsent, Ct as clearClaim, Dt as groupByLineage, Et as followedRefName, G as ensureServer, H as readIndexToken, It as recentWorkspaces, L as MANAGED_ROOT, Mt as loadWorkspace, Nt as matchingWorkspaceIds, Pt as positionInLineage, R as readMarker, Rt as reviewedRepositories, S as record$1, St as purposeOf, Tt as isClaimed, U as bootstrapUrl, V as relativeTime, X as stopServer, Z as workspaceUrl, _t as loadJob, a as wasBlocked, an as displayRef, at as parseWorkspacePort, b as startJob, c as updateReview, cn as resolveModel, ct as writePortPreference, dn as writeAgentPreference, et as PACKAGE_NAME, f as UpdateAlreadyRunningError, fn as CONFIG_PATH, ft as checkReview, g as recordKissRun, gn as agentById, gt as isTerminal, hn as DEFAULT_AGENT_ID, i as liveJobsFor, in as resolveTarget, it as MIN_WORKSPACE_PORT, lt as forgeResolver, m as runningJobs, mn as AGENT_IDS, n as deleteReview$1, nt as DEFAULT_WORKSPACE_PORT, on as git, p as liveUpdateFor, pn as STORE_ROOT, pt as allJobs, q as reviewsUrl, rt as MAX_WORKSPACE_PORT, sn as resolveAgent, st as statedWorkspacePort, un as readAgentPreference, v as reanalyseReview, vn as detectAgents, w as telemetryUploadConsent, wt as driverGone, xt as progressSteps, y as runJob, yt as PHASES, z as removeWorktree, zt as saveWorkspace } from "./delete_review-Kup1LXD_.js";
3
3
  import { basename, dirname, join, resolve } from "node:path";
4
4
  import { spawn } from "node:child_process";
5
5
  import { existsSync, mkdirSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -705,11 +705,17 @@ function madeAgainst(requested) {
705
705
  const wanted = displayRef(requested);
706
706
  return (review) => review.baseRef !== "" && displayRef(review.baseRef) === wanted;
707
707
  }
708
- /** Whether the job behind a stored review is still working. A review with no job never was. */
708
+ /**
709
+ * Whether the job behind a stored review is still working. A review with no job never was.
710
+ *
711
+ * A job whose driver has gone is not working, whatever phase its record was left at. Calling it in
712
+ * progress told the reviewer who had just closed a terminal that there was "nothing to do but wait",
713
+ * for a process that no longer existed, until the sweep called it failed half an hour later.
714
+ */
709
715
  function isRunning(jobId) {
710
716
  if (!jobId) return false;
711
717
  const job = loadJob(jobId);
712
- return !!job && !isTerminal(job);
718
+ return !!job && !isTerminal(job) && !driverGone(job.id);
713
719
  }
714
720
  /**
715
721
  * What the review is of, as the clause both surfaces hang off "Made two hours ago".
@@ -1264,7 +1270,7 @@ function unknownAgent(id, known) {
1264
1270
  * mistake; `Open workspace now` and `Review ready` read as a beginning and an end.
1265
1271
  */
1266
1272
  function startedReview(url, _target) {
1267
- return [`Open workspace now ${url}`, "The review continues if this terminal closes."].join("\n");
1273
+ return [`Open workspace now ${url}`, "Keep this terminal open while it runs. If it closes, run the same command again to carry on."].join("\n");
1268
1274
  }
1269
1275
  /**
1270
1276
  * The one-review-per-branch rule, said to a person rather than to a session.
@@ -1517,8 +1523,9 @@ function commitReviewCannotUpdate(sha) {
1517
1523
  * Said before the update starts, so the command answers at once and the link is there to open while
1518
1524
  * it works. The same label the creation path uses, because it is the same offer.
1519
1525
  *
1520
- * Not "continues if this terminal closes", which the creation path can say and this cannot: the
1521
- * update runs in this process, so closing the terminal stops it.
1526
+ * Without the creation path's line about carrying on if the terminal closes. An update runs in this
1527
+ * process and ends with it, and running the command again starts the update over rather than
1528
+ * picking one up, because `liveUpdateFor` reads a dead driver as nothing running.
1522
1529
  */
1523
1530
  function startedUpdate(url, acted) {
1524
1531
  return `${subjectLine(acted)}\nOpen workspace now ${url}`;
@@ -2178,8 +2185,10 @@ function describe(deps, id) {
2178
2185
  * One thing differs, and it is a property of the surface rather than of the review. An MCP tool
2179
2186
  * returns to a session that must not sit and wait, so it fires `runJob` and returns the link at
2180
2187
  * once. A person who typed a command is already waiting, so this awaits the job and reports what
2181
- * it is doing. Either way the job is durable and either way the link works from the moment it is
2182
- * printed, so a terminal closed halfway through loses nothing.
2188
+ * it is doing. Either way the job is durable and the link works from the moment it is printed. The
2189
+ * job does not outlive this process, though: the agent shares the terminal's process group, so a
2190
+ * terminal closed halfway through ends both. What it loses is time, not work. The claim it leaves
2191
+ * behind is `driverGone`, and running the command again carries on from the phase it reached.
2183
2192
  *
2184
2193
  * **Two axes, and this file is where they meet.** A command names a target and an operation, and
2185
2194
  * the operations are `update` and `reanalyse`, which were `prreviewbuddy update` until 0.15.0.
@@ -2480,15 +2489,19 @@ function makeCommandFor(command) {
2480
2489
  if (command.commitRef) return `prreviewbuddy review --commit ${command.commitRef}`;
2481
2490
  return "prreviewbuddy review";
2482
2491
  }
2492
+ /** Why an unfinished review is being picked up, when nothing recorded a failure because nothing could. */
2493
+ var DRIVER_GONE = "the command that was running it ended before it finished, most often because its terminal closed.";
2483
2494
  function failureOf(workspaceId) {
2484
2495
  const workspace = loadWorkspace(workspaceId);
2485
2496
  if (!workspace?.jobId) return null;
2486
2497
  const job = loadJob(workspace.jobId);
2487
- if (!job || !isTerminal(job) || job.phase !== "failed") return null;
2498
+ if (!job) return null;
2499
+ const abandoned = !isTerminal(job) && driverGone(job.id);
2500
+ if (!abandoned && (!isTerminal(job) || job.phase !== "failed")) return null;
2488
2501
  if (isClaimed(job.id)) return null;
2489
2502
  return {
2490
- message: job.failure?.message ?? "The reason was not recorded.",
2491
- stopped: job.failure?.stopped === true,
2503
+ message: abandoned ? DRIVER_GONE : job.failure?.message ?? "The reason was not recorded.",
2504
+ stopped: !abandoned && job.failure?.stopped === true,
2492
2505
  agentId: job.env.agentId ?? DEFAULT_AGENT_ID,
2493
2506
  ...job.requestedModel ? { requestedModel: job.requestedModel } : {}
2494
2507
  };
@@ -3202,8 +3215,7 @@ async function cleanUp(options) {
3202
3215
  *
3203
3216
  * It stops the workspace server, which the help screen says on purpose there is no command to do.
3204
3217
  * That is not a hole in the rule but the end of it: "no command to stop the server" exists so that
3205
- * a review outlives the terminal that asked for it, and there are no reviews left to outlive
3206
- * anything here.
3218
+ * the workspace outlives the terminal that opened it, and there are no reviews left to serve here.
3207
3219
  *
3208
3220
  * What it does not do is remove its own npm package. A running binary deleting the install it is
3209
3221
  * executing from depends on which package manager put it there and fails in ways that leave a