@staff0rd/assist 0.543.1 → 0.545.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.543.1",
9
+ version: "0.545.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -16834,8 +16834,8 @@ function codeCommentConfirm(pin) {
16834
16834
  }
16835
16835
  const marker = isHashCommentFile(state.file) ? "#" : "//";
16836
16836
  const indentSource = lines2[index3] ?? "";
16837
- const indent2 = indentSource.match(/^\s*/)?.[0] ?? "";
16838
- lines2.splice(index3, 0, `${indent2}${marker} ${state.text}`);
16837
+ const indent3 = indentSource.match(/^\s*/)?.[0] ?? "";
16838
+ lines2.splice(index3, 0, `${indent3}${marker} ${state.text}`);
16839
16839
  writeFileSync24(state.file, lines2.join("\n"));
16840
16840
  unlinkSync8(getPinStatePath(pin));
16841
16841
  console.log(
@@ -19864,52 +19864,52 @@ function renderInline(node) {
19864
19864
  if (node.marks?.some((m) => m.type === "code")) return `\`${text17}\``;
19865
19865
  return text17;
19866
19866
  }
19867
- function renderChildren(node, indent2) {
19868
- return renderNodes(node.content ?? [], indent2);
19867
+ function renderChildren(node, indent3) {
19868
+ return renderNodes(node.content ?? [], indent3);
19869
19869
  }
19870
- function renderOrderedList(node, indent2) {
19870
+ function renderOrderedList(node, indent3) {
19871
19871
  let counter = 0;
19872
19872
  return (node.content ?? []).map((item) => {
19873
19873
  counter++;
19874
- return renderListItem(item, indent2, `${counter}.`);
19874
+ return renderListItem(item, indent3, `${counter}.`);
19875
19875
  }).join("\n");
19876
19876
  }
19877
- function renderBulletList(node, indent2) {
19878
- return (node.content ?? []).map((item) => renderListItem(item, indent2, "-")).join("\n");
19877
+ function renderBulletList(node, indent3) {
19878
+ return (node.content ?? []).map((item) => renderListItem(item, indent3, "-")).join("\n");
19879
19879
  }
19880
- function renderHeading(node, indent2) {
19880
+ function renderHeading(node, indent3) {
19881
19881
  const level = node.attrs?.level ?? 1;
19882
- return `${"#".repeat(level)} ${renderChildren(node, indent2)}`;
19882
+ return `${"#".repeat(level)} ${renderChildren(node, indent3)}`;
19883
19883
  }
19884
19884
  var renderers = {
19885
19885
  text: (node) => renderInline(node),
19886
19886
  paragraph: renderChildren,
19887
19887
  orderedList: renderOrderedList,
19888
19888
  bulletList: renderBulletList,
19889
- listItem: (node, indent2) => renderListItem(node, indent2, "-"),
19889
+ listItem: (node, indent3) => renderListItem(node, indent3, "-"),
19890
19890
  heading: renderHeading,
19891
19891
  doc: renderChildren
19892
19892
  };
19893
- function renderNode(node, indent2) {
19893
+ function renderNode(node, indent3) {
19894
19894
  const renderer = renderers[node.type];
19895
- if (renderer) return renderer(node, indent2);
19896
- return node.content ? renderChildren(node, indent2) : "";
19895
+ if (renderer) return renderer(node, indent3);
19896
+ return node.content ? renderChildren(node, indent3) : "";
19897
19897
  }
19898
- function renderNodes(nodes, indent2) {
19899
- return nodes.map((node) => renderNode(node, indent2)).join("");
19898
+ function renderNodes(nodes, indent3) {
19899
+ return nodes.map((node) => renderNode(node, indent3)).join("");
19900
19900
  }
19901
19901
  function isListNode(node) {
19902
19902
  return node.type === "orderedList" || node.type === "bulletList";
19903
19903
  }
19904
- function renderListChild(child, indent2, pad, marker, isFirst) {
19905
- if (isListNode(child)) return renderNodes([child], indent2 + 1);
19906
- if (child.type !== "paragraph") return renderNode(child, indent2);
19907
- const text17 = renderChildren(child, indent2);
19904
+ function renderListChild(child, indent3, pad, marker, isFirst) {
19905
+ if (isListNode(child)) return renderNodes([child], indent3 + 1);
19906
+ if (child.type !== "paragraph") return renderNode(child, indent3);
19907
+ const text17 = renderChildren(child, indent3);
19908
19908
  return isFirst ? `${pad}${marker} ${text17}` : `${pad} ${text17}`;
19909
19909
  }
19910
- function renderListItem(node, indent2, marker) {
19911
- const pad = " ".repeat(indent2);
19912
- return (node.content ?? []).map((child, i) => renderListChild(child, indent2, pad, marker, i === 0)).join("\n");
19910
+ function renderListItem(node, indent3, marker) {
19911
+ const pad = " ".repeat(indent3);
19912
+ return (node.content ?? []).map((child, i) => renderListChild(child, indent3, pad, marker, i === 0)).join("\n");
19913
19913
  }
19914
19914
  function adfToText(doc) {
19915
19915
  return renderNodes([doc], 0);
@@ -22281,45 +22281,148 @@ function updateCommentsCache(org, repo, prNumber, comments3) {
22281
22281
  }
22282
22282
  }
22283
22283
 
22284
- // src/commands/prs/listComments/printComments.ts
22284
+ // src/commands/prs/listComments/commentStyle.ts
22285
22285
  import chalk170 from "chalk";
22286
- function formatForHuman(comment3) {
22287
- if (comment3.type === "review") {
22288
- const stateColor = comment3.state === "APPROVED" ? chalk170.green : comment3.state === "CHANGES_REQUESTED" ? chalk170.red : chalk170.yellow;
22289
- return [
22290
- `${chalk170.cyan("Review")} by ${chalk170.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
22291
- comment3.body,
22292
- ""
22293
- ].join("\n");
22286
+ var plain = (text17) => text17;
22287
+ function colouredState(state) {
22288
+ const label2 = `[${state}]`;
22289
+ if (state === "APPROVED") return chalk170.green(label2);
22290
+ if (state === "CHANGES_REQUESTED") return chalk170.red(label2);
22291
+ return chalk170.yellow(label2);
22292
+ }
22293
+ function commentStyle() {
22294
+ if (isClaudeCode()) {
22295
+ return {
22296
+ cyan: plain,
22297
+ bold: plain,
22298
+ dim: plain,
22299
+ state: (state) => `[${state}]`,
22300
+ diffHunk: false
22301
+ };
22302
+ }
22303
+ return {
22304
+ cyan: chalk170.cyan,
22305
+ bold: chalk170.bold,
22306
+ dim: chalk170.dim,
22307
+ state: colouredState,
22308
+ diffHunk: true
22309
+ };
22310
+ }
22311
+
22312
+ // src/commands/prs/listComments/groupThreads.ts
22313
+ function threadLocation(comment3) {
22314
+ return comment3.line ? `${comment3.path}:${comment3.line}` : comment3.path;
22315
+ }
22316
+ function groupThreads(comments3) {
22317
+ const threads = /* @__PURE__ */ new Map();
22318
+ for (const comment3 of comments3) {
22319
+ const id = comment3.threadId || `comment-${comment3.id}`;
22320
+ const existing = threads.get(id);
22321
+ if (existing) {
22322
+ existing.comments.push(comment3);
22323
+ continue;
22324
+ }
22325
+ threads.set(id, { id, resolved: comment3.resolved, comments: [comment3] });
22294
22326
  }
22295
- const location = comment3.line ? `:${comment3.line}` : "";
22327
+ return [...threads.values()];
22328
+ }
22329
+
22330
+ // src/commands/prs/listComments/renderResolvedIndex.ts
22331
+ var summaryLimit = 100;
22332
+ function firstLine(body) {
22333
+ const line = body.trim().split("\n")[0] ?? "";
22334
+ return line.length > summaryLimit ? `${line.slice(0, summaryLimit - 1)}\u2026` : line;
22335
+ }
22336
+ function renderResolvedIndex(threads, style) {
22337
+ const lines2 = [style.cyan(`Resolved threads (${threads.length})`)];
22338
+ for (const thread of threads) {
22339
+ const first = thread.comments[0];
22340
+ if (!first) continue;
22341
+ const count8 = thread.comments.length > 1 ? ` (${thread.comments.length} comments)` : "";
22342
+ lines2.push(
22343
+ ` ${style.bold(threadLocation(first))} ${first.user}: ${firstLine(first.body)}${count8}`
22344
+ );
22345
+ }
22346
+ lines2.push("");
22347
+ return lines2.join("\n");
22348
+ }
22349
+
22350
+ // src/commands/prs/listComments/renderThreadBlock.ts
22351
+ function indent(text17) {
22352
+ return text17.split("\n").map((line) => line ? ` ${line}` : line).join("\n");
22353
+ }
22354
+ function renderThreadBlock(thread, style) {
22355
+ const first = thread.comments[0];
22356
+ if (!first) return "";
22357
+ const lines2 = [
22358
+ `${style.cyan("Thread")} on ${style.bold(threadLocation(first))}`
22359
+ ];
22360
+ if (style.diffHunk) {
22361
+ lines2.push(
22362
+ indent(style.dim(first.diff_hunk.split("\n").slice(-3).join("\n")))
22363
+ );
22364
+ }
22365
+ for (const comment3 of thread.comments) {
22366
+ lines2.push(
22367
+ indent(
22368
+ [
22369
+ `${style.bold(comment3.user)} ${style.dim(comment3.html_url)}`,
22370
+ comment3.body,
22371
+ ""
22372
+ ].join("\n")
22373
+ )
22374
+ );
22375
+ }
22376
+ return lines2.join("\n");
22377
+ }
22378
+
22379
+ // src/commands/prs/listComments/renderReview.ts
22380
+ function renderReview(comment3, style) {
22296
22381
  return [
22297
- `${chalk170.cyan("Line comment")} by ${chalk170.bold(comment3.user)} on ${chalk170.dim(`${comment3.path}${location}`)}`,
22298
- chalk170.dim(comment3.diff_hunk.split("\n").slice(-3).join("\n")),
22382
+ `${style.cyan("Review")} by ${style.bold(comment3.user)} ${style.state(comment3.state)}`,
22299
22383
  comment3.body,
22300
22384
  ""
22301
22385
  ].join("\n");
22302
22386
  }
22303
- function summarise(comments3) {
22304
- const lineCount = comments3.filter((c) => c.type === "line").length;
22305
- const reviewCount = comments3.filter((c) => c.type === "review").length;
22306
- const parts = [];
22307
- if (lineCount > 0) parts.push(`${lineCount} line`);
22308
- if (reviewCount > 0) parts.push(`${reviewCount} review`);
22309
- return `Found ${parts.join(" and ")} comment${comments3.length === 1 ? "" : "s"}.`;
22387
+
22388
+ // src/commands/prs/listComments/summarise.ts
22389
+ function summarise(reviewCount, unresolved, resolved) {
22390
+ const threadCounts = `${unresolved.length} unresolved and ${resolved.length} resolved threads.`;
22391
+ if (reviewCount === 0) return `Found ${threadCounts}`;
22392
+ const reviews = `${reviewCount} review comment${reviewCount === 1 ? "" : "s"}`;
22393
+ return `Found ${reviews}, ${threadCounts}`;
22310
22394
  }
22395
+
22396
+ // src/commands/prs/listComments/printComments.ts
22311
22397
  function printComments2(result) {
22312
22398
  const { comments: comments3, cachePath } = result;
22313
22399
  if (comments3.length === 0) {
22314
22400
  console.log("No comments found.");
22315
22401
  return;
22316
22402
  }
22317
- if (!isClaudeCode()) {
22318
- for (const comment3 of comments3) {
22319
- console.log(formatForHuman(comment3));
22403
+ const style = commentStyle();
22404
+ const reviews = comments3.filter(
22405
+ (c) => c.type === "review"
22406
+ );
22407
+ const threads = groupThreads(
22408
+ comments3.filter((c) => c.type === "line")
22409
+ );
22410
+ const unresolved = threads.filter((t) => !t.resolved);
22411
+ const resolved = threads.filter((t) => t.resolved);
22412
+ for (const review2 of reviews) {
22413
+ console.log(renderReview(review2, style));
22414
+ }
22415
+ if (unresolved.length > 0) {
22416
+ console.log(`${style.cyan(`Unresolved threads (${unresolved.length})`)}
22417
+ `);
22418
+ for (const thread of unresolved) {
22419
+ console.log(renderThreadBlock(thread, style));
22320
22420
  }
22321
22421
  }
22322
- console.log(summarise(comments3));
22422
+ if (resolved.length > 0) {
22423
+ console.log(renderResolvedIndex(resolved, style));
22424
+ }
22425
+ console.log(summarise(reviews.length, unresolved, resolved));
22323
22426
  if (cachePath) {
22324
22427
  console.log(`Saved to ${cachePath}`);
22325
22428
  }
@@ -26185,7 +26288,7 @@ function skippedCodexResult(outputPath) {
26185
26288
  // src/commands/review/formatReviewerFailure.ts
26186
26289
  var FAST_FAIL_MS = 1e3;
26187
26290
  var STDOUT_TAIL_LINES = 20;
26188
- function indent(text17) {
26291
+ function indent2(text17) {
26189
26292
  return text17.split(/\r?\n/).map((line) => ` ${line}`);
26190
26293
  }
26191
26294
  function tailLines(text17, maxLines) {
@@ -26204,12 +26307,12 @@ function fastFailHint(command) {
26204
26307
  }
26205
26308
  function outputDetail(input) {
26206
26309
  const stderr = input.stderr.trim();
26207
- if (stderr) return ["stderr:", ...indent(stderr)];
26310
+ if (stderr) return ["stderr:", ...indent2(stderr)];
26208
26311
  const stdout = (input.stdout ?? "").trim();
26209
26312
  if (stdout) {
26210
26313
  return [
26211
26314
  `stdout (no stderr was captured \u2014 showing last ${STDOUT_TAIL_LINES} lines):`,
26212
- ...indent(tailLines(stdout, STDOUT_TAIL_LINES))
26315
+ ...indent2(tailLines(stdout, STDOUT_TAIL_LINES))
26213
26316
  ];
26214
26317
  }
26215
26318
  return [
@@ -26318,9 +26421,9 @@ import { writeFileSync as writeFileSync37 } from "fs";
26318
26421
  // src/commands/review/finaliseReviewerSpinner.ts
26319
26422
  var SUMMARY_MAX_LEN = 80;
26320
26423
  function summariseStderr(stderr) {
26321
- const firstLine = stderr.split(/\r?\n/).find((l) => l.trim().length > 0);
26322
- if (!firstLine) return "";
26323
- const trimmed = firstLine.trim();
26424
+ const firstLine2 = stderr.split(/\r?\n/).find((l) => l.trim().length > 0);
26425
+ if (!firstLine2) return "";
26426
+ const trimmed = firstLine2.trim();
26324
26427
  return trimmed.length > SUMMARY_MAX_LEN ? `${trimmed.slice(0, SUMMARY_MAX_LEN - 1)}\u2026` : trimmed;
26325
26428
  }
26326
26429
  function finaliseReviewerSpinner(spinner, name, exitCode, elapsedMs, stderr = "") {
@@ -34318,8 +34421,6 @@ function joinableStream(sessions, targetId) {
34318
34421
  if (target.commandType === "run")
34319
34422
  return { reason: "a server run has no agent stream" };
34320
34423
  if (target.closing === true) return { reason: "the session is closing" };
34321
- if (target.status !== "running" && target.status !== "waiting")
34322
- return { reason: `the session is ${target.status}` };
34323
34424
  if (!target.cwd) return { reason: "the session has no working directory" };
34324
34425
  return { session: target };
34325
34426
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.543.1",
3
+ "version": "0.545.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {