@staff0rd/assist 0.417.0 → 0.418.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/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.417.0",
9
+ version: "0.418.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -18241,7 +18241,7 @@ async function placePr(prNumber, title, body, options2) {
18241
18241
  // src/commands/prs/previewAndPlace.ts
18242
18242
  import { randomUUID as randomUUID4 } from "crypto";
18243
18243
 
18244
- // src/commands/prs/requestPrDecision.ts
18244
+ // src/commands/prs/parseIncoming.ts
18245
18245
  function parseIncoming(line, requestId) {
18246
18246
  try {
18247
18247
  const msg = JSON.parse(line);
@@ -18251,12 +18251,18 @@ function parseIncoming(line, requestId) {
18251
18251
  if (msg.decision !== "approve" && msg.decision !== "reject") return null;
18252
18252
  return {
18253
18253
  kind: "decision",
18254
- decision: { decision: msg.decision, reason: msg.reason }
18254
+ decision: {
18255
+ decision: msg.decision,
18256
+ reason: msg.reason,
18257
+ comments: Array.isArray(msg.comments) ? msg.comments : void 0
18258
+ }
18255
18259
  };
18256
18260
  } catch {
18257
18261
  return null;
18258
18262
  }
18259
18263
  }
18264
+
18265
+ // src/commands/prs/requestPrDecision.ts
18260
18266
  function requestPrDecision(request) {
18261
18267
  return new Promise((resolve19, reject) => {
18262
18268
  connectToDaemon().then((socket) => {
@@ -18307,6 +18313,21 @@ async function previewAndPlace(args) {
18307
18313
  console.error(
18308
18314
  `PR preview rejected${decision.reason ? `: ${decision.reason}` : "."}`
18309
18315
  );
18316
+ const comments3 = decision.comments ?? [];
18317
+ if (comments3.length > 0) {
18318
+ console.error(
18319
+ `
18320
+ The reviewer left ${comments3.length} comment${comments3.length === 1 ? "" : "s"} on the preview. Address each one, then re-run this command:
18321
+ `
18322
+ );
18323
+ for (const [i, c] of comments3.entries()) {
18324
+ const quoted = c.quote.split("\n").map((line) => ` > ${line}`).join("\n");
18325
+ console.error(`${i + 1}. On:
18326
+ ${quoted}
18327
+ Comment: ${c.note}
18328
+ `);
18329
+ }
18330
+ }
18310
18331
  process.exit(1);
18311
18332
  }
18312
18333
  await placePr(args.prNumber, args.title, args.body, args.options);
@@ -25460,6 +25481,61 @@ function logSpawnedSession(session) {
25460
25481
  );
25461
25482
  }
25462
25483
 
25484
+ // src/commands/sessions/daemon/decidePrPreview.ts
25485
+ function decidePrPreview(sessions, waiters, notify2, d) {
25486
+ const id = d.sessionId;
25487
+ const requestId = d.requestId;
25488
+ const session = sessions.get(id);
25489
+ if (!session || session.pendingPrPreview?.requestId !== requestId) {
25490
+ daemonLog(
25491
+ `pr-decision for stale/unknown preview id=${id} requestId=${requestId} (ignoring)`
25492
+ );
25493
+ return;
25494
+ }
25495
+ const commentCount = Array.isArray(d.comments) ? d.comments.length : 0;
25496
+ daemonLog(
25497
+ `pr-decision received: id=${id} requestId=${requestId} decision=${d.decision} comments=${commentCount}`
25498
+ );
25499
+ const waiter = waiters.get(id);
25500
+ if (waiter)
25501
+ sendTo(waiter, {
25502
+ type: "pr-decision",
25503
+ requestId,
25504
+ decision: d.decision,
25505
+ reason: d.reason,
25506
+ comments: d.comments
25507
+ });
25508
+ waiters.delete(id);
25509
+ session.pendingPrPreview = void 0;
25510
+ notify2();
25511
+ }
25512
+
25513
+ // src/commands/sessions/daemon/setPrPreview.ts
25514
+ function setPrPreview(sessions, waiters, notify2, client, d) {
25515
+ const id = d.sessionId;
25516
+ const session = sessions.get(id);
25517
+ if (!session) {
25518
+ daemonLog(`pr-preview for unknown session id=${id} (ignoring)`);
25519
+ sendTo(client, {
25520
+ type: "error",
25521
+ message: `No live session ${id} for pr-preview`
25522
+ });
25523
+ return;
25524
+ }
25525
+ const prNumber = typeof d.prNumber === "number" ? d.prNumber : null;
25526
+ session.pendingPrPreview = {
25527
+ requestId: d.requestId,
25528
+ title: d.title,
25529
+ body: d.body,
25530
+ prNumber
25531
+ };
25532
+ waiters.set(id, client);
25533
+ daemonLog(
25534
+ `pr-preview set: id=${id} requestId=${d.requestId} target=${prNumber === null ? "create" : `edit #${prNumber}`}`
25535
+ );
25536
+ notify2();
25537
+ }
25538
+
25463
25539
  // src/commands/sessions/daemon/PrPreviewCoordinator.ts
25464
25540
  var PrPreviewCoordinator = class {
25465
25541
  constructor(sessions, notify2) {
@@ -25468,53 +25544,10 @@ var PrPreviewCoordinator = class {
25468
25544
  }
25469
25545
  waiters = /* @__PURE__ */ new Map();
25470
25546
  set(client, d) {
25471
- const id = d.sessionId;
25472
- const session = this.sessions.get(id);
25473
- if (!session) {
25474
- daemonLog(`pr-preview for unknown session id=${id} (ignoring)`);
25475
- sendTo(client, {
25476
- type: "error",
25477
- message: `No live session ${id} for pr-preview`
25478
- });
25479
- return;
25480
- }
25481
- const prNumber = typeof d.prNumber === "number" ? d.prNumber : null;
25482
- session.pendingPrPreview = {
25483
- requestId: d.requestId,
25484
- title: d.title,
25485
- body: d.body,
25486
- prNumber
25487
- };
25488
- this.waiters.set(id, client);
25489
- daemonLog(
25490
- `pr-preview set: id=${id} requestId=${d.requestId} target=${prNumber === null ? "create" : `edit #${prNumber}`}`
25491
- );
25492
- this.notify();
25547
+ setPrPreview(this.sessions, this.waiters, this.notify, client, d);
25493
25548
  }
25494
25549
  decide(d) {
25495
- const id = d.sessionId;
25496
- const requestId = d.requestId;
25497
- const session = this.sessions.get(id);
25498
- if (!session || session.pendingPrPreview?.requestId !== requestId) {
25499
- daemonLog(
25500
- `pr-decision for stale/unknown preview id=${id} requestId=${requestId} (ignoring)`
25501
- );
25502
- return;
25503
- }
25504
- daemonLog(
25505
- `pr-decision received: id=${id} requestId=${requestId} decision=${d.decision}`
25506
- );
25507
- const waiter = this.waiters.get(id);
25508
- if (waiter)
25509
- sendTo(waiter, {
25510
- type: "pr-decision",
25511
- requestId,
25512
- decision: d.decision,
25513
- reason: d.reason
25514
- });
25515
- this.waiters.delete(id);
25516
- session.pendingPrPreview = void 0;
25517
- this.notify();
25550
+ decidePrPreview(this.sessions, this.waiters, this.notify, d);
25518
25551
  }
25519
25552
  clearWaiter(client) {
25520
25553
  for (const [id, waiter] of this.waiters) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.417.0",
3
+ "version": "0.418.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {