@staff0rd/assist 0.20.0 → 0.21.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.
Files changed (2) hide show
  1. package/dist/index.js +61 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2089,6 +2089,19 @@ import { execSync as execSync11 } from "child_process";
2089
2089
  import chalk30 from "chalk";
2090
2090
  import enquirer4 from "enquirer";
2091
2091
  var PAGE_SIZE = 10;
2092
+ function isGhNotInstalled(error) {
2093
+ if (error instanceof Error) {
2094
+ const msg = error.message.toLowerCase();
2095
+ return msg.includes("enoent") || msg.includes("command not found");
2096
+ }
2097
+ return false;
2098
+ }
2099
+ function getRepoInfo() {
2100
+ const repoInfo = JSON.parse(
2101
+ execSync11("gh repo view --json owner,name", { encoding: "utf-8" })
2102
+ );
2103
+ return { org: repoInfo.owner.login, repo: repoInfo.name };
2104
+ }
2092
2105
  async function prs(options) {
2093
2106
  const state = options.open ? "open" : options.closed ? "closed" : "all";
2094
2107
  try {
@@ -2105,13 +2118,10 @@ async function prs(options) {
2105
2118
  }
2106
2119
  await displayPaginated(pullRequests);
2107
2120
  } catch (error) {
2108
- if (error instanceof Error) {
2109
- const msg = error.message.toLowerCase();
2110
- if (msg.includes("enoent") || msg.includes("command not found")) {
2111
- console.error("Error: GitHub CLI (gh) is not installed.");
2112
- console.error("Install it from https://cli.github.com/");
2113
- return;
2114
- }
2121
+ if (isGhNotInstalled(error)) {
2122
+ console.error("Error: GitHub CLI (gh) is not installed.");
2123
+ console.error("Install it from https://cli.github.com/");
2124
+ return;
2115
2125
  }
2116
2126
  throw error;
2117
2127
  }
@@ -2176,6 +2186,42 @@ Page ${page + 1} of ${totalPages} (${pullRequests.length} total)
2176
2186
  }
2177
2187
  }
2178
2188
  }
2189
+ async function comments(prNumber) {
2190
+ try {
2191
+ const { org, repo } = getRepoInfo();
2192
+ const allComments = [];
2193
+ const reviewResult = execSync11(
2194
+ `gh api repos/${org}/${repo}/pulls/${prNumber}/reviews --jq '.[] | select(.body != "") | {id: .id, user: .user.login, state: .state, body: .body}'`,
2195
+ { encoding: "utf-8" }
2196
+ );
2197
+ if (reviewResult.trim()) {
2198
+ for (const line of reviewResult.trim().split("\n")) {
2199
+ if (line.trim()) {
2200
+ allComments.push({ type: "review", ...JSON.parse(line) });
2201
+ }
2202
+ }
2203
+ }
2204
+ const lineResult = execSync11(
2205
+ `gh api repos/${org}/${repo}/pulls/${prNumber}/comments --jq '.[] | {id: .id, user: .user.login, path: .path, line: .line, body: .body, diff_hunk: .diff_hunk}'`,
2206
+ { encoding: "utf-8" }
2207
+ );
2208
+ if (lineResult.trim()) {
2209
+ for (const line of lineResult.trim().split("\n")) {
2210
+ if (line.trim()) {
2211
+ allComments.push({ type: "line", ...JSON.parse(line) });
2212
+ }
2213
+ }
2214
+ }
2215
+ return allComments;
2216
+ } catch (error) {
2217
+ if (isGhNotInstalled(error)) {
2218
+ console.error("Error: GitHub CLI (gh) is not installed.");
2219
+ console.error("Install it from https://cli.github.com/");
2220
+ return [];
2221
+ }
2222
+ throw error;
2223
+ }
2224
+ }
2179
2225
 
2180
2226
  // src/commands/refactor/check.ts
2181
2227
  import { spawn as spawn2 } from "child_process";
@@ -2670,7 +2716,14 @@ program.command("update").description("Update claude-code to the latest version"
2670
2716
  console.log("Updating claude-code...");
2671
2717
  execSync14("npm install -g @anthropic-ai/claude-code", { stdio: "inherit" });
2672
2718
  });
2673
- program.command("prs").description("List pull requests for the current repository").option("--open", "List only open pull requests").option("--closed", "List only closed pull requests").action(prs);
2719
+ var prsCommand = program.command("prs").description("Pull request utilities").option("--open", "List only open pull requests").option("--closed", "List only closed pull requests").action(prs);
2720
+ prsCommand.command("comments <pr-number>").description("List all comments on a pull request").action((prNumber) => {
2721
+ comments(Number.parseInt(prNumber, 10)).then((comments2) => {
2722
+ for (const comment of comments2) {
2723
+ console.log(JSON.stringify(comment));
2724
+ }
2725
+ });
2726
+ });
2674
2727
  var runCommand = program.command("run").description("Run a configured command from assist.yml").argument("<name>", "Name of the configured command").argument("[args...]", "Arguments to pass to the command").allowUnknownOption().action((name, args) => {
2675
2728
  run(name, args);
2676
2729
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {