prreviewbuddy 0.59.50 → 0.63.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,108 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.63.0
4
+
5
+ **Telemetry now records first use.** With telemetry on, PR Review Buddy sends one more event,
6
+ `installation_started`, once per installation: the first time you run `prreviewbuddy` on its own,
7
+ `review`, `open` or `agents`. It marks first use, not when the package was installed, and it adds
8
+ no field. It carries the installation id, version, platform and a timestamp, and no agent. If it
9
+ cannot reach the server it is tried again on your next such command, and never again once it
10
+ arrives. The server keeps one per installation, so a repeat is acknowledged and not stored. Until now only reviews were counted, so somebody who tried PR Review Buddy and stopped
11
+ before a review was invisible. Installations from before this version send it once, on their first
12
+ command after upgrading.
13
+
14
+ `prreviewbuddy` on its own now shows the one-time telemetry notice too, because it can now send.
15
+ Its usage text is unchanged. An installation that already saw the telemetry notice, or turned telemetry
16
+ on, is told once about this one addition; one that turned it off is told nothing. `--help`, `--version` and `config` send nothing and show no notice.
17
+ `prreviewbuddy config set telemetry-upload off` and `PRB_TELEMETRY=off` stop this event exactly as
18
+ they stop the others. The privacy page lists it: https://prreviewbuddy.com/privacy
19
+
20
+ ## 0.62.0
21
+
22
+ **Buddy AI has its own keys.** On a review, ⌘K B opens a Buddy AI menu. B O opens Buddy AI with
23
+ the cursor in its question, which is what ⌘K S B used to do; Sections now lists the review's own
24
+ content only.
25
+
26
+ **Choose a prompt without leaving the keyboard.** ⌘K B P lists your prompts, the ones under Your
27
+ prompts in Buddy AI, in the same order. Type to narrow them by name or wording. The first ten shown
28
+ are numbered, and pressing a number picks that prompt; the numbers follow what you have typed, so
29
+ the best match is always 1. The arrows, or J and K once you are in the list, reach the rest, and
30
+ Enter picks. The prompt goes into your question exactly as clicking it does, with Buddy AI open
31
+ and ready for you to carry on. Escape goes back to the Buddy AI menu.
32
+
33
+ ## 0.61.1
34
+
35
+ **J and K show the ends of the list.** Walking the Reviews list stopped with the first or last
36
+ review flush against the edge of the window, leaving the count, Select and the section's name above
37
+ it, or Load more below it, scrolled out of sight. Reaching the first review now scrolls the list
38
+ right back to its top, reaching the last scrolls it to its bottom, arriving at the first review of a
39
+ section brings that section's heading with it, and every other review stops a little short of the
40
+ edge. The same goes for notifications.
41
+
42
+ **The highlight on a notification has its corners.** On the first or last notification shown, the
43
+ list's rounded corners cut the highlight off; it is now rounded to match.
44
+
45
+ ## 0.61.0
46
+
47
+ **Search and Filters inside the command palette.** On the Reviews list, ⌘K S now turns the palette
48
+ into a search: type, and the matching reviews appear under the field as you go; Enter or a click
49
+ opens one. ⌘K F shows the list's filters there, each with its current choice. Both are the toolbar's
50
+ own search and filters, so whatever you choose in one shows in the other, and the toolbar is still
51
+ there for the mouse. Escape takes you back to the palette's commands, and a second Escape closes it.
52
+
53
+ **J and K on Notifications.** Move through the notifications with J and K, open one with Enter or
54
+ in a new tab with Shift+Enter, and come back to it with Back, as on the Reviews list.
55
+
56
+ **The Reviews list's ring now sits on the card's own edge**, with no gap between them.
57
+
58
+ ## 0.60.0
59
+
60
+ **Keyboard commands across the workspace.** Press **⌘K** on a Mac, or **Ctrl+K** elsewhere, to open
61
+ the command palette. It lists what you can do on the page you are on, and after a key that leads
62
+ somewhere (on a review **S** for Sections, **M** for Mark and **A** for Actions, on the Reviews
63
+ list **L** for its sections), it shows the keys that can follow. It stays open until you choose
64
+ something, press Escape or click away. A key it does not know just closes it.
65
+
66
+ - **Anywhere:** ⌘K R goes to Reviews, ⌘K N to Notifications, and ⌘K ? opens the full table of
67
+ keyboard shortcuts.
68
+ - **On a review:** ⌘K S then K, I, G, Q, F or B goes to KISS, Issues, Diagrams, Questions, Files or
69
+ Buddy AI. With a section expanded, the one you go to arrives expanded. **\\** expands or collapses
70
+ the section you are on, and Escape still leaves focus mode. ⌘K M then R, W or D marks the review
71
+ reviewed, waiting or done. ⌘K A then C checks for updates, U updates the review (wherever the
72
+ Update review button is offered), Q adds it to the review queue or takes it out, and D opens the
73
+ delete confirmation, with Cancel ready, and deletes nothing by itself.
74
+ - **On the Reviews list:** J and K move through the reviews on screen, drawing a ring around the
75
+ one Enter opens; Shift+Enter opens it in a new tab. The ring stays put while the mouse moves, is
76
+ separate from the ticks of Select, and comes back to the review you opened when you go Back. ⌘K S
77
+ puts you in search, ⌘K F on the filters, and ⌘K L then P, A, W or D folds or opens Pinned,
78
+ Active, Waiting or Done, with the palette saying which are open.
79
+
80
+ A command that cannot apply right now, such as Mark waiting on an older review of a branch, is shown
81
+ dimmed and does nothing, as is anything that would change where the review stands while another
82
+ such change is still on its way to the server. Single keys never act while you are typing in a
83
+ field. The **…** menu on a review shows each action's shortcut beside it, and Help has the same
84
+ table under Keyboard.
85
+
86
+ ## 0.59.52
87
+
88
+ **The Reviews page remembers which sections you fold.** Pinned, Active, Waiting and Done each keep
89
+ the state you left them in through a refresh, the page's own live updates and a restart of the
90
+ workspace. A review arriving in a section you folded does not open it, though the count beside its
91
+ name still changes. Until you fold or open a section yourself it starts as before, with Done folded
92
+ and the rest open. The choice is stored on your machine, alongside the theme and the Buddy AI width.
93
+
94
+ ## 0.59.51
95
+
96
+ **A merge no longer marks a Done review as changed.** A review you had marked Done showed
97
+ **Changed since done** as soon as its pull request merged or closed, even with no new commits, which
98
+ read as a contradiction beside **Review up to date**. It now shows that only when new commits land
99
+ after you marked it Done, including commits pushed just before a merge. A pull request reopened after
100
+ Done shows **Reopened since done**.
101
+
102
+ **Keep done settles a changed review.** On a Done review showing either of those, the menu now says
103
+ **Keep done** where it used to offer **Mark done** again. It clears the note and leaves the review in
104
+ Done. Waiting reviews are unchanged: any new activity, a merge included, still brings them back.
105
+
3
106
  ## 0.59.50
4
107
 
5
108
  **A click on the Architecture background clears the selection.** Clicking empty space in the
@@ -4343,6 +4343,11 @@ var ACTIVITY_LABELS = {
4343
4343
  closed: "Closed",
4344
4344
  reopened: "Reopened"
4345
4345
  };
4346
+ /** An activity as the `data-activity-*` attributes carry it, so the pages can recompute the chip. */
4347
+ function activityAttributes(activity) {
4348
+ const moved = activity.movedAt === void 0 ? "" : ` data-activity-moved-at="${activity.movedAt}"`;
4349
+ return ` data-activity-at="${activity.at}" data-activity-kind="${activity.kind}"${moved}`;
4350
+ }
4346
4351
  function activityLabel(kind) {
4347
4352
  return ACTIVITY_LABELS[kind];
4348
4353
  }
@@ -4361,10 +4366,21 @@ function sectionOf(lifecycle, activity) {
4361
4366
  if (lifecycle.state === "waiting" && changedSince(lifecycle, activity)) return "active";
4362
4367
  return lifecycle.state;
4363
4368
  }
4364
- /** The chip that says why a card is where it is, or absent when its section already says it. */
4369
+ /**
4370
+ * The chip that says why a card is where it is, or absent when its section already says it.
4371
+ *
4372
+ * Waiting is answered by any movement, a merge included: that is often what it was waiting for.
4373
+ * Done is answered only by what could change the verdict. A push after Done means the code is no
4374
+ * longer the code that was reviewed, even when the request merged afterwards. A reopen can make it
4375
+ * relevant again. A merge or close on its own is the request finishing after the review did, which
4376
+ * confirms Done rather than unsettling it.
4377
+ */
4365
4378
  function lifecycleChip(lifecycle, activity) {
4366
- if (!lifecycle || !changedSince(lifecycle, activity)) return void 0;
4367
- return lifecycle.state === "waiting" ? "Changed while waiting" : "Changed since done";
4379
+ if (!lifecycle || !activity) return void 0;
4380
+ if (lifecycle.state === "waiting") return changedSince(lifecycle, activity) ? "Changed while waiting" : void 0;
4381
+ if (activity.kind === "reopened" && activity.at > lifecycle.at) return "Reopened since done";
4382
+ const movedAt = activity.movedAt ?? (activity.kind === "updated" ? activity.at : void 0);
4383
+ return movedAt !== void 0 && movedAt > lifecycle.at ? "Changed since done" : void 0;
4368
4384
  }
4369
4385
  function changedSince(lifecycle, activity) {
4370
4386
  return activity !== void 0 && activity.kind !== "created" && activity.at > lifecycle.at;
@@ -4381,6 +4397,15 @@ function offersLifecycle(target, lifecycle, activity) {
4381
4397
  if (lifecycleChip(lifecycle, activity) !== void 0) return true;
4382
4398
  return target !== (lifecycle?.state ?? "active");
4383
4399
  }
4400
+ /**
4401
+ * A lifecycle item's words. The settle item on a changed Done review is "Keep done": "Mark done" on
4402
+ * something already Done reads as a no-op. Waiting keeps "Mark waiting", because a changed Waiting
4403
+ * review is drawn in Active, where parking it again is what the words already say.
4404
+ */
4405
+ function lifecycleItemLabel(target, lifecycle, activity) {
4406
+ if (target === "done" && lifecycle?.state === "done" && lifecycleChip(lifecycle, activity) !== void 0) return "Keep done";
4407
+ return lifecycleAction(target);
4408
+ }
4384
4409
  //#endregion
4385
4410
  //#region ../../packages/review-harness/src/workspace/store.ts
4386
4411
  var WORKSPACES_DIR = join(STORE_ROOT, "workspaces");
@@ -13561,6 +13586,13 @@ var TIMEOUT_MS = 1500;
13561
13586
  */
13562
13587
  function project(record) {
13563
13588
  const event = record.event;
13589
+ if (event.event === "installation_started") return {
13590
+ event: event.event,
13591
+ installationId: record.anonymousId,
13592
+ cliVersion: record.cliVersion,
13593
+ platform: record.platform,
13594
+ occurredAt: record.at
13595
+ };
13564
13596
  if (event.event !== "review_started" && event.event !== "review_finished") return null;
13565
13597
  const base = {
13566
13598
  event: event.event,
@@ -13589,13 +13621,38 @@ function send(record) {
13589
13621
  if (!telemetryUploadEnabled()) return;
13590
13622
  const payload = project(record);
13591
13623
  if (!payload) return;
13592
- fetch(endpoint(), {
13624
+ post(payload);
13625
+ } catch {}
13626
+ }
13627
+ /**
13628
+ * Send one record and say whether the server took it. Never rejects.
13629
+ *
13630
+ * For the one caller that has to know: `installation_started` is sent until it lands, so it needs
13631
+ * a yes it can trust, which is a 2xx and nothing else. Asks the same question `send` does before
13632
+ * anything goes over the wire.
13633
+ */
13634
+ async function deliver(record) {
13635
+ try {
13636
+ if (!telemetryUploadEnabled()) return false;
13637
+ const payload = project(record);
13638
+ return payload ? await post(payload) : false;
13639
+ } catch {
13640
+ return false;
13641
+ }
13642
+ }
13643
+ async function post(payload) {
13644
+ try {
13645
+ const response = await fetch(endpoint(), {
13593
13646
  method: "POST",
13594
13647
  headers: { "content-type": "application/json" },
13595
13648
  body: JSON.stringify(payload),
13596
13649
  signal: AbortSignal.timeout(TIMEOUT_MS)
13597
- }).catch(() => {});
13598
- } catch {}
13650
+ });
13651
+ await response.body?.cancel().catch(() => {});
13652
+ return response.ok;
13653
+ } catch {
13654
+ return false;
13655
+ }
13599
13656
  }
13600
13657
  /**
13601
13658
  * Where to. Overridable so the endpoint can be pointed at a local server while it is being built,
@@ -13620,29 +13677,44 @@ var LOG_PATH = join(STORE_ROOT, "events.jsonl");
13620
13677
  * The gate is on **transmission only**. Writing a file the developer owns and can read, delete or
13621
13678
  * disable is a different act from sending to a server, and the consent that suits one does not
13622
13679
  * carry to the other, so `events.jsonl` keeps recording the full event union either way and the
13623
- * question asked on first run is about the wire. Nineteen events are written here; two of them,
13680
+ * question asked on first run is about the wire. Twenty events are written here; three of them,
13624
13681
  * carrying eight fields between them, are the most that is ever sent.
13625
13682
  */
13626
13683
  function record(event) {
13627
13684
  try {
13628
- const config = loadConfig();
13629
- if (!config.telemetry) return;
13630
- const line = {
13631
- anonymousId: config.anonymousId,
13632
- cliVersion: BUILD_VERSION,
13633
- platform: platformName(),
13634
- at: (/* @__PURE__ */ new Date()).toISOString(),
13635
- event
13636
- };
13637
- mkdirSync(STORE_ROOT, { recursive: true });
13638
- appendFileSync(LOG_PATH, `${JSON.stringify(line)}\n`, { mode: 384 });
13685
+ const line = stamp(event);
13686
+ if (!line) return;
13687
+ append(line);
13639
13688
  send(line);
13640
13689
  } catch {}
13641
13690
  }
13691
+ /**
13692
+ * The line an event would be logged as, or `null` when the log is switched off.
13693
+ *
13694
+ * Split from `record` for `installation_started`, which is built and sent first and logged only
13695
+ * once the server has it: logging each attempt would leave one line per failed try for an event
13696
+ * that happens once.
13697
+ */
13698
+ function stamp(event) {
13699
+ const config = loadConfig();
13700
+ if (!config.telemetry) return null;
13701
+ return {
13702
+ anonymousId: config.anonymousId,
13703
+ cliVersion: BUILD_VERSION,
13704
+ platform: platformName(),
13705
+ at: (/* @__PURE__ */ new Date()).toISOString(),
13706
+ event
13707
+ };
13708
+ }
13709
+ /** Write one line to the log. Throws on a failed write; callers decide what that costs. */
13710
+ function append(line) {
13711
+ mkdirSync(STORE_ROOT, { recursive: true });
13712
+ appendFileSync(LOG_PATH, `${JSON.stringify(line)}\n`, { mode: 384 });
13713
+ }
13642
13714
  /** This review's own events, oldest first. The only reader, used to derive the rollup. */
13643
13715
  function readEvents(reviewId) {
13644
13716
  try {
13645
- return readFileSync(LOG_PATH, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line)).filter((entry) => entry.event?.reviewId === reviewId).map((entry) => entry.event);
13717
+ return readFileSync(LOG_PATH, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line)).map((entry) => entry.event).filter((event) => event !== void 0 && "reviewId" in event && event.reviewId === reviewId);
13646
13718
  } catch {
13647
13719
  return [];
13648
13720
  }
@@ -16127,4 +16199,4 @@ function lineageIds(id) {
16127
16199
  return [.../* @__PURE__ */ new Set([id, ...lineage.map((review) => review.id)])];
16128
16200
  }
16129
16201
  //#endregion
16130
- export { REPOSITORY_SCOPE as $, presentedKissRunOf as $n, reviewsUrl as $t, reanalyseReview as A, saveJob as An, describeAuthorship as Ar, renderInlineText as At, RUNTIME_WORDS as B, followedRefName as Bn, readAgentPreference as Br, removeWorktree as Bt, track as C, followedBranch as Cn, isIssueOutstanding as Cr, authorPreview as Ct, endRun as D, fail as Dn, reviewerDispositions as Dr, CODE_BLOCK_CLASS as Dt, completeRun as E, endedAt as En, questionsOutstanding as Er, renderMarkdown as Et, recordTelemetryUploadConsent as F, purposeOf as Fn, isCommitReview as Fr, MANAGED_ROOT as Ft, partFiles as G, kissDecisionsOf as Gn, DEFAULT_AGENT_ID as Gr, compactQueue as Gt, ARCHITECTURE_DIR as H, indexKeptIds as Hn, CONFIG_PATH as Hr, modelHelpLines as Ht, telemetryUploadConsent as I, clearClaim as In, git as Ir, createWorktree as It, storeArchitecture as J, lineagePosition as Jn, detectAgents as Jr, readIndexToken as Jt, readArchitecture as K, latestKissRun as Kn, agentById as Kr, queueForReview as Kt, waitingHistory as L, driverGone as Ln, resolveAgent as Lr, holdWorktree as Lt, startJob as M, isLiveJob as Mn, kissOutcome as Mr, extractJsonText as Mt, readEvents as N, phasesFor as Nn, resolveTarget as Nr, objectWithAnyOf as Nt, reportRun as O, isTerminal as On, processDiscussion as Or, CODE_COPY_CLASS as Ot, record as P, progressSteps as Pn, displayRef as Pr, ReviewBeingDeletedError as Pt, QUOTE_LIMITS as Q, positionInLineage as Qn, readServerRecord as Qt, mapRuntimes as R, isClaimed as Rn, resolveModel as Rr, isWorktreeHeld as Rt, isDriving as S, checkReview as Sn, doneVerb as Sr, UNESTABLISHED_MOTIVATION as St, beginRun as T, allJobs as Tn, issuesOutstanding as Tr, GITHUB_MARKDOWN as Tt, checkArchitecture as U, indexReviewGroups as Un, STORE_ROOT as Ur, relativeTime as Ut, describeRuntimes as V, groupByLineage as Vn, writeAgentPreference as Vr, requestJobStop as Vt, loadArchitecture as W, kissDecisionRefusal as Wn, AGENT_IDS as Wr, activateQueued as Wt, trackedFiles as X, matchingWorkspaceIds as Xn, AgentUnavailableError as Xr, clearServerRecordOwnedBy as Xt, storedScopes as Y, loadWorkspace as Yn, AgentCancelledError as Yr, bootstrapUrl as Yt, ownersOf as Z, mutateWorkspace as Zn, ensureServer as Zt, liveUpdateFor as _, forgeResolver as _n, queueAdd as _r, removeNotification as _t, wasBlocked as a, writeServerRecord as an, touchWorkspace as ar, subjectOf as at, recordKissRun as b, fillFileUrlTemplate as bn, queueStamp as br, withUsageRecorded as bt, RefreshUnavailableError as c, feedbackUrl as cn, LIFECYCLES as cr, createPrUpdate as ct, mergeUpdateInto as d, MIN_WORKSPACE_PORT as dn, lifecycleAction as dr, listNotifications as dt, serverEntryExists as en, previousKissResult as er, ancestorsOf as et, updateReview as f, parseWorkspacePort as fn, lifecycleChip as fr, markAllRead as ft, UpdateAlreadyRunningError as g, claimRequestUrl as gn, sectionOf as gr, readNotification as gt, askCheckout as h, writePortPreference as hn, parseLifecycle as hr, pruneNotifications as ht, liveJobsFor as i, workspaceUrl as in, summarise as ir, branchOf as it, runJob as j, PHASES as jn, WITHHELD_REASON as jr, asString as jt, stopRun as k, loadJob as kn, recommendationsOf as kr, escapeHtml as kt, cancelUpdate as l, DEFAULT_WORKSPACE_PORT as ln, activityLabel as lr, eventName as lt, isUnchanged as m, statedWorkspacePort as mn, offersLifecycle as mr, markReadForReview as mt, deleteReview as n, stopChild as nn, reviewedCommit as nr, writeJsonAtomically as nt, discardJob as o, BUILD_VERSION as on, workspaceRevision as or, createArchitectureNotification as ot, refreshPrContext as p, resolveWorkspacePort as pn, lifecyclePill as pr, markRead as pt, repositoryKey as q, lineageKeyFor as qn, agentFor as qr, settleQueue as qt, lineageIds as r, stopServer as rn, reviewedRepositories as rr, announceJob as rt, FETCH_TIMEOUT_MS as s, PACKAGE_NAME as sn, workspaceStamps as sr, createPrState as st, deleteLineage as t, spawnServer as tn, recentWorkspaces as tr, isArchitectureId as tt, cancellableHere as u, MAX_WORKSPACE_PORT as un, isLifecycle as ur, headline as ut, runningJobs as v, forgeFor as vn, queueAddMany as vr, toneOf as vt, RUN_KINDS as w, reviewedShaOf as wn, isQuestionOutstanding as wr, hasAuthorContent as wt, startKissJob as x, checkCodeFreshness as xn, readQueue as xr, EXPLAIN_SIMPLY_PROMPT as xt, agentEnvOf as y, remoteHost as yn, queueRemove as yr, unreadCount as yt, recordRuntimeBestEffort as z, decideKissRecommendation as zn, clearAgentPreference as zr, readMarker as zt };
16202
+ export { storedScopes as $, loadWorkspace as $n, detectAgents as $r, bootstrapUrl as $t, reanalyseReview as A, endedAt as An, issuesOutstanding as Ar, renderMarkdown as At, telemetryUploadEnabled as B, clearClaim as Bn, isCommitReview as Br, createWorktree as Bt, track as C, remoteHost as Cn, queueAddMany as Cr, unreadCount as Ct, endRun as D, followedBranch as Dn, doneVerb as Dr, authorPreview as Dt, completeRun as E, checkReview as En, readQueue as Er, UNESTABLISHED_MOTIVATION as Et, record as F, PHASES as Fn, describeAuthorship as Fr, asString as Ft, describeRuntimes as G, groupByLineage as Gn, readAgentPreference as Gr, requestJobStop as Gt, mapRuntimes as H, isClaimed as Hn, resolveAgent as Hr, isWorktreeHeld as Ht, stamp as I, isLiveJob as In, WITHHELD_REASON as Ir, extractJsonText as It, loadArchitecture as J, kissDecisionRefusal as Jn, STORE_ROOT as Jr, activateQueued as Jt, ARCHITECTURE_DIR as K, indexKeptIds as Kn, writeAgentPreference as Kr, modelHelpLines as Kt, deliver as L, phasesFor as Ln, kissOutcome as Lr, objectWithAnyOf as Lt, startJob as M, isTerminal as Mn, reviewerDispositions as Mr, CODE_COPY_CLASS as Mt, append as N, loadJob as Nn, processDiscussion as Nr, escapeHtml as Nt, reportRun as O, reviewedShaOf as On, isIssueOutstanding as Or, hasAuthorContent as Ot, readEvents as P, saveJob as Pn, recommendationsOf as Pr, renderInlineText as Pt, storeArchitecture as Q, lineagePosition as Qn, agentFor as Qr, readIndexToken as Qt, recordTelemetryUploadConsent as R, progressSteps as Rn, resolveTarget as Rr, ReviewBeingDeletedError as Rt, isDriving as S, forgeFor as Sn, queueAdd as Sr, toneOf as St, beginRun as T, checkCodeFreshness as Tn, queueStamp as Tr, EXPLAIN_SIMPLY_PROMPT as Tt, recordRuntimeBestEffort as U, decideKissRecommendation as Un, resolveModel as Ur, readMarker as Ut, waitingHistory as V, driverGone as Vn, git as Vr, holdWorktree as Vt, RUNTIME_WORDS as W, followedRefName as Wn, clearAgentPreference as Wr, removeWorktree as Wt, readArchitecture as X, latestKissRun as Xn, DEFAULT_AGENT_ID as Xr, queueForReview as Xt, partFiles as Y, kissDecisionsOf as Yn, AGENT_IDS as Yr, compactQueue as Yt, repositoryKey as Z, lineageKeyFor as Zn, agentById as Zr, settleQueue as Zt, liveUpdateFor as _, resolveWorkspacePort as _n, lifecycleItemLabel as _r, markRead as _t, wasBlocked as a, spawnServer as an, recentWorkspaces as ar, isArchitectureId as at, recordKissRun as b, claimRequestUrl as bn, parseLifecycle as br, readNotification as bt, RefreshUnavailableError as c, workspaceUrl as cn, summarise as cr, branchOf as ct, mergeUpdateInto as d, PACKAGE_NAME as dn, workspaceStamps as dr, createPrState as dt, AgentCancelledError as ei, clearServerRecordOwnedBy as en, matchingWorkspaceIds as er, trackedFiles as et, updateReview as f, feedbackUrl as fn, LIFECYCLES as fr, createPrUpdate as ft, UpdateAlreadyRunningError as g, parseWorkspacePort as gn, lifecycleChip as gr, markAllRead as gt, askCheckout as h, MIN_WORKSPACE_PORT as hn, isLifecycle as hr, listNotifications as ht, liveJobsFor as i, serverEntryExists as in, previousKissResult as ir, ancestorsOf as it, runJob as j, fail as jn, questionsOutstanding as jr, CODE_BLOCK_CLASS as jt, stopRun as k, allJobs as kn, isQuestionOutstanding as kr, GITHUB_MARKDOWN as kt, cancelUpdate as l, writeServerRecord as ln, touchWorkspace as lr, subjectOf as lt, isUnchanged as m, MAX_WORKSPACE_PORT as mn, activityLabel as mr, headline as mt, deleteReview as n, readServerRecord as nn, positionInLineage as nr, QUOTE_LIMITS as nt, discardJob as o, stopChild as on, reviewedCommit as or, writeJsonAtomically as ot, refreshPrContext as p, DEFAULT_WORKSPACE_PORT as pn, activityAttributes as pr, eventName as pt, checkArchitecture as q, indexReviewGroups as qn, CONFIG_PATH as qr, relativeTime as qt, lineageIds as r, reviewsUrl as rn, presentedKissRunOf as rr, REPOSITORY_SCOPE as rt, FETCH_TIMEOUT_MS as s, stopServer as sn, reviewedRepositories as sr, announceJob as st, deleteLineage as t, AgentUnavailableError as ti, ensureServer as tn, mutateWorkspace as tr, ownersOf as tt, cancellableHere as u, BUILD_VERSION as un, workspaceRevision as ur, createArchitectureNotification as ut, runningJobs as v, statedWorkspacePort as vn, lifecyclePill as vr, markReadForReview as vt, RUN_KINDS as w, fillFileUrlTemplate as wn, queueRemove as wr, withUsageRecorded as wt, startKissJob as x, forgeResolver as xn, sectionOf as xr, removeNotification as xt, agentEnvOf as y, writePortPreference as yn, offersLifecycle as yr, pruneNotifications as yt, telemetryUploadConsent as z, purposeOf as zn, displayRef as zr, MANAGED_ROOT as zt };
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $t as reviewsUrl, A as reanalyseReview, Bn as followedRefName, Br as readAgentPreference, Bt as removeWorktree, F as recordTelemetryUploadConsent, Fn as purposeOf, Ft as MANAGED_ROOT, Gr as DEFAULT_AGENT_ID, Hr as CONFIG_PATH, Ht as modelHelpLines, I as telemetryUploadConsent, In as clearClaim, Ir as git, Jr as detectAgents, Jt as readIndexToken, Kr as agentById, Kt as queueForReview, Ln as driverGone, Lr as resolveAgent, M as startJob, Mr as kissOutcome, Nr as resolveTarget, On as isTerminal, P as record$1, Pn as progressSteps, Pr as displayRef, Qn as positionInLineage, Rn as isClaimed, Rr as resolveModel, Sn as checkReview, Tn as allJobs, Ur as STORE_ROOT, Ut as relativeTime, Vn as groupByLineage, Vr as writeAgentPreference, Wr as AGENT_IDS, Xn as matchingWorkspaceIds, Yn as loadWorkspace, Yt as bootstrapUrl, Zn as mutateWorkspace, Zt as ensureServer, _ as liveUpdateFor, _n as forgeResolver, a as wasBlocked, b as recordKissRun, d as mergeUpdateInto, dn as MIN_WORKSPACE_PORT, f as updateReview, fn as parseWorkspacePort, g as UpdateAlreadyRunningError, hn as writePortPreference, i as liveJobsFor, in as workspaceUrl, ir as summarise, j as runJob, jn as PHASES, jr as WITHHELD_REASON, kn as loadJob, ln as DEFAULT_WORKSPACE_PORT, mn as statedWorkspacePort, n as deleteReview$1, on as BUILD_VERSION, qn as lineageKeyFor, rn as stopServer, rr as reviewedRepositories, sn as PACKAGE_NAME, tr as recentWorkspaces, un as MAX_WORKSPACE_PORT, v as runningJobs, zt as readMarker } from "./delete_review-TsYWWNVr.js";
2
+ import { $n as loadWorkspace, $r as detectAgents, $t as bootstrapUrl, A as reanalyseReview, B as telemetryUploadEnabled, Bn as clearClaim, En as checkReview, F as record$1, Fn as PHASES, Gn as groupByLineage, Gr as readAgentPreference, Hn as isClaimed, Hr as resolveAgent, I as stamp, Ir as WITHHELD_REASON, Jr as STORE_ROOT, Kr as writeAgentPreference, Kt as modelHelpLines, L as deliver, Lr as kissOutcome, M as startJob, Mn as isTerminal, N as append, Nn as loadJob, Qt as readIndexToken, R as recordTelemetryUploadConsent, Rn as progressSteps, Rr as resolveTarget, Ur as resolveModel, Ut as readMarker, Vn as driverGone, Vr as git, Wn as followedRefName, Wt as removeWorktree, Xr as DEFAULT_AGENT_ID, Xt as queueForReview, Yr as AGENT_IDS, Zn as lineageKeyFor, Zr as agentById, _ as liveUpdateFor, a as wasBlocked, ar as recentWorkspaces, b as recordKissRun, cn as workspaceUrl, cr as summarise, d as mergeUpdateInto, dn as PACKAGE_NAME, er as matchingWorkspaceIds, f as updateReview, g as UpdateAlreadyRunningError, gn as parseWorkspacePort, hn as MIN_WORKSPACE_PORT, i as liveJobsFor, j as runJob, kn as allJobs, mn as MAX_WORKSPACE_PORT, n as deleteReview$1, nr as positionInLineage, pn as DEFAULT_WORKSPACE_PORT, qr as CONFIG_PATH, qt as relativeTime, rn as reviewsUrl, sn as stopServer, sr as reviewedRepositories, tn as ensureServer, tr as mutateWorkspace, un as BUILD_VERSION, v as runningJobs, vn as statedWorkspacePort, xn as forgeResolver, yn as writePortPreference, z as telemetryUploadConsent, zn as purposeOf, zr as displayRef, zt as MANAGED_ROOT } from "./delete_review-CeJo9t7h.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";
@@ -107,15 +107,24 @@ var AUDIENCES = {
107
107
  reviewer: "writes it for somebody reviewing somebody else's work, with whether each one is worth raising"
108
108
  };
109
109
  function parse(argv) {
110
- if (argv.length === 0) return { name: "help" };
110
+ if (argv.length === 0) return {
111
+ name: "help",
112
+ via: "bare"
113
+ };
111
114
  const [head, ...rest] = argv;
112
- if (head === "--help" || head === "-h" || head === "help") return { name: "help" };
115
+ if (head === "--help" || head === "-h" || head === "help") return {
116
+ name: "help",
117
+ via: "asked"
118
+ };
113
119
  if (head === "--version" || head === "-v") return { name: "version" };
114
120
  if (head === void 0 || !(head in VALUED)) return {
115
121
  name: "error",
116
122
  message: unknownCommand(head)
117
123
  };
118
- if (rest.includes("--help") || rest.includes("-h")) return { name: "help" };
124
+ if (rest.includes("--help") || rest.includes("-h")) return {
125
+ name: "help",
126
+ via: "asked"
127
+ };
119
128
  const values = {};
120
129
  const flags = /* @__PURE__ */ new Set();
121
130
  const positional = [];
@@ -1217,12 +1226,26 @@ function unknownSetting(key, known) {
1217
1226
  * little else is attached to it. "Anonymous" is a word with a technical meaning strong enough to be
1218
1227
  * challenged on, and the claim below does not need it to be true.
1219
1228
  */
1229
+ /**
1230
+ * The one addition since the notice an installation already saw, or the yes it already gave. Not the
1231
+ * notice again: repeating what somebody was told reads as something else having changed.
1232
+ */
1233
+ function telemetryFirstUseNotice() {
1234
+ return [
1235
+ "",
1236
+ "Usage telemetry now also records first use: one event, once per installation, with the",
1237
+ "same version, platform and timestamp fields as before. Nothing else changed.",
1238
+ "Turn it off: `prreviewbuddy config set telemetry-upload off`",
1239
+ "Details: https://prreviewbuddy.com/privacy",
1240
+ ""
1241
+ ].join("\n");
1242
+ }
1220
1243
  function telemetryNotice() {
1221
1244
  return [
1222
1245
  "",
1223
- "Non-identifying usage telemetry is on by default: review start and finish, version,",
1224
- "platform, agent, success and duration. Never your code, diffs, repository names or",
1225
- "review content.",
1246
+ "Non-identifying usage telemetry is on by default: first use, review start and finish,",
1247
+ "version, platform, agent, success and duration. Never your code, diffs, repository",
1248
+ "names or review content.",
1226
1249
  "Turn it off: `prreviewbuddy config set telemetry-upload off`",
1227
1250
  "Details: https://prreviewbuddy.com/privacy",
1228
1251
  ""
@@ -3413,6 +3436,7 @@ async function uninstall(command, deps = REAL) {
3413
3436
  */
3414
3437
  var GREETING = "onboarding-shown";
3415
3438
  var TELEMETRY_NOTICE = "telemetry-notice-shown";
3439
+ var FIRST_USE_NOTICE = "telemetry-first-use-notice-shown";
3416
3440
  /** Whether this machine has been greeted. */
3417
3441
  function greeted() {
3418
3442
  return shown(GREETING);
@@ -3433,6 +3457,13 @@ function telemetryNoticed() {
3433
3457
  function recordTelemetryNotice() {
3434
3458
  record(TELEMETRY_NOTICE);
3435
3459
  }
3460
+ /** Whether this machine has been told that 0.63.0 added `installation_started` to what is sent. */
3461
+ function firstUseNoticed() {
3462
+ return shown(FIRST_USE_NOTICE);
3463
+ }
3464
+ function recordFirstUseNotice() {
3465
+ record(FIRST_USE_NOTICE);
3466
+ }
3436
3467
  /**
3437
3468
  * Unreadable reads as already shown.
3438
3469
  *
@@ -3473,16 +3504,108 @@ function record(name) {
3473
3504
  * Both are left alone, which is why the claim everywhere else is "every installation whose
3474
3505
  * behaviour changes is told once" rather than "every machine is told".
3475
3506
  *
3507
+ * **0.63.0 is such a change for everybody who sends.** `installation_started` joined what leaves
3508
+ * the machine, so an installation told the old list, or that said yes to it, is told once about the
3509
+ * addition, under its own marker. A no is still told nothing.
3510
+ *
3476
3511
  * **No terminal check.** The old question could not be asked without one. A disclosure has nobody
3477
3512
  * to wait for, and a headless install that transmits is exactly the install that must not be the
3478
3513
  * one nobody ever told. It costs a CI log three lines on a persisted home, once.
3479
3514
  */
3480
3515
  function noticeTelemetry(write) {
3481
3516
  if (process.env.PRB_TELEMETRY === "off") return;
3482
- if (telemetryUploadConsent() !== null) return;
3483
- if (telemetryNoticed()) return;
3484
- write(telemetryNotice());
3485
- recordTelemetryNotice();
3517
+ const consent = telemetryUploadConsent();
3518
+ if (consent === false) return;
3519
+ if (consent === null && !telemetryNoticed()) {
3520
+ write(telemetryNotice());
3521
+ recordTelemetryNotice();
3522
+ recordFirstUseNotice();
3523
+ return;
3524
+ }
3525
+ if (firstUseNoticed()) return;
3526
+ write(telemetryFirstUseNotice());
3527
+ recordFirstUseNotice();
3528
+ }
3529
+ //#endregion
3530
+ //#region src/product_commands.ts
3531
+ /**
3532
+ * Whether this command is somebody using the product, rather than asking about the binary or
3533
+ * changing a setting.
3534
+ *
3535
+ * One answer for two things, on purpose. These commands print the one-time telemetry notice, and
3536
+ * they are the commands that may send `installation_started`. If the lists ever differed, a
3537
+ * command could transmit before the installation had been told telemetry is on.
3538
+ *
3539
+ * `prreviewbuddy` on its own counts: it is somebody entering the product to see what it does.
3540
+ * `--help` and `--version` do not, nor `config` (where the setting is changed, and turning it off
3541
+ * must not need a disclosure first) or `uninstall`.
3542
+ */
3543
+ function isProductCommand(command) {
3544
+ switch (command.name) {
3545
+ case "review":
3546
+ case "open":
3547
+ case "agents": return true;
3548
+ case "help": return command.via === "bare";
3549
+ default: return false;
3550
+ }
3551
+ }
3552
+ //#endregion
3553
+ //#region ../../packages/review-harness/src/telemetry/installation_started.ts
3554
+ /**
3555
+ * Tell the server, once, that this installation was used.
3556
+ *
3557
+ * The review events only fire from inside a review job, so an installation that was tried and
3558
+ * left before its first review was invisible: nothing told "nobody installs this" apart from
3559
+ * "people install it and stop before reviewing". This is the event that sits in front of them.
3560
+ *
3561
+ * It means first meaningful use that telemetry saw, and the name has to survive that reading:
3562
+ * an installation from before the event existed sends it on its first command after upgrading,
3563
+ * and nothing on this machine knows when the package was actually installed.
3564
+ *
3565
+ * **Sent until it lands.** Every other event is best effort, because losing one review out of a
3566
+ * thousand changes nothing. Losing this one loses the installation from the funnel, so the marker
3567
+ * is written only after a 2xx, and every meaningful command until then tries again. Any failure
3568
+ * retries, a 422 included: a CLI that reached somebody before the API learned the event recovers
3569
+ * on its own once it has. `occurredAt` is the attempt's own time, never a remembered first try,
3570
+ * because the server refuses a timestamp more than two days from when it arrives and a stored
3571
+ * one would be refused forever.
3572
+ *
3573
+ * **Once is kept by the server, not here.** This side cannot know that a request it saw fail was
3574
+ * not stored: an acknowledgement lost after the row committed looks exactly like a failure, and two
3575
+ * commands started together on one home both pass the marker check before either has written it.
3576
+ * Both resend. The API holds one `installation_started` per installation under a unique index and
3577
+ * answers a repeat with a 200 it does not store, which also stops the retrying. The marker only
3578
+ * saves requests.
3579
+ */
3580
+ var MARKER = join(STORE_ROOT, "installation-started-sent");
3581
+ /**
3582
+ * Send `installation_started` if this installation has not had it accepted yet. Never rejects.
3583
+ *
3584
+ * Asks whether it may send before it reads anything, so under `PRB_TELEMETRY=off` it creates no
3585
+ * identity, no marker and no log line: the kill switch is not a decision, and a machine that
3586
+ * unsets it tomorrow has still never been counted.
3587
+ */
3588
+ async function announceInstallation() {
3589
+ try {
3590
+ if (!telemetryUploadEnabled()) return;
3591
+ if (announced()) return;
3592
+ const line = stamp({ event: "installation_started" });
3593
+ if (!line || !await deliver(line)) return;
3594
+ writeMarker();
3595
+ append(line);
3596
+ } catch {}
3597
+ }
3598
+ /** An unreadable home counts as already sent: failing closed on repetition. */
3599
+ function announced() {
3600
+ try {
3601
+ return existsSync(MARKER);
3602
+ } catch {
3603
+ return true;
3604
+ }
3605
+ }
3606
+ function writeMarker() {
3607
+ mkdirSync(STORE_ROOT, { recursive: true });
3608
+ writeFileSync(MARKER, `${(/* @__PURE__ */ new Date()).toISOString()}\n`, { mode: 384 });
3486
3609
  }
3487
3610
  //#endregion
3488
3611
  //#region src/main.ts
@@ -3520,28 +3643,33 @@ function greet(command) {
3520
3643
  /**
3521
3644
  * The one-time telemetry disclosure, printed after the hello and before the work.
3522
3645
  *
3523
- * The greeting's commands minus `config`, which is where the setting is changed: somebody typing
3646
+ * On the commands `isProductCommand` names, which are also the ones that may send
3647
+ * `installation_started`, so nothing is transmitted from a command that could not have disclosed
3648
+ * it. Not `config`, which is where the setting is changed: somebody typing
3524
3649
  * `config set telemetry-upload off` should be able to turn it off without being told first that it
3525
- * is on. That was true when this was a question and it is still true now it is a notice.
3650
+ * is on.
3526
3651
  *
3527
3652
  * On stderr, like every other line here that is not a result, so `prreviewbuddy review | pbcopy`
3528
3653
  * still copies a URL. Unlike the question it replaced it takes no input and checks for no terminal:
3529
3654
  * there is nobody to wait for, and a headless install that transmits is the one that most needs
3530
3655
  * telling.
3531
3656
  */
3532
- var NOTIFIED = [
3533
- "review",
3534
- "open",
3535
- "agents"
3536
- ];
3537
3657
  function notify(command) {
3538
- if (!NOTIFIED.includes(command.name)) return;
3658
+ if (!isProductCommand(command)) return;
3539
3659
  noticeTelemetry((chunk) => void process.stderr.write(chunk));
3540
3660
  }
3541
3661
  async function main(argv) {
3542
3662
  const command = parse(argv);
3543
3663
  greet(command);
3544
3664
  notify(command);
3665
+ const announced = isProductCommand(command) ? announceInstallation() : Promise.resolve();
3666
+ try {
3667
+ return await run(command);
3668
+ } finally {
3669
+ await announced;
3670
+ }
3671
+ }
3672
+ async function run(command) {
3545
3673
  switch (command.name) {
3546
3674
  case "help":
3547
3675
  out(HELP);