@staff0rd/assist 0.728.0 → 0.729.1

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.728.0",
9
+ version: "0.729.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -857,7 +857,8 @@ var assistConfigShape = {
857
857
  showInNav: z3.boolean().default(false)
858
858
  }).optional(),
859
859
  next: z3.strictObject({
860
- peers: z3.array(z3.string()).optional()
860
+ peers: z3.array(z3.string()).optional(),
861
+ repos: z3.array(z3.string()).optional()
861
862
  }).optional(),
862
863
  deny: z3.array(
863
864
  z3.strictObject({
@@ -10343,13 +10344,13 @@ function phaseNotes(entry, position) {
10343
10344
  }
10344
10345
  function renderDiffPhase(entry, idx) {
10345
10346
  const notes = phaseNotes(entry, idx + 1);
10346
- const section3 = renderPhaseSection(
10347
+ const section2 = renderPhaseSection(
10347
10348
  { ...entry.phase, name: `${entry.phase.name} (${notes.join(", ")})` },
10348
10349
  idx
10349
10350
  );
10350
- if (!entry.previousTasks) return section3;
10351
+ if (!entry.previousTasks) return section2;
10351
10352
  return [
10352
- section3,
10353
+ section2,
10353
10354
  "**Previously:**",
10354
10355
  entry.previousTasks.map((task) => `- ${task}`).join("\n")
10355
10356
  ].join("\n\n");
@@ -12562,6 +12563,11 @@ var nextConfigHelp = [
12562
12563
  key: "next.peers",
12563
12564
  setter: "assist config set next.peers alice,bob -g --repo",
12564
12565
  note: "GitHub logins whose open, non-draft PRs the web /next view lists for review alongside PRs requesting your review; PRs you approved with no newer commits are hidden"
12566
+ },
12567
+ {
12568
+ key: "next.repos",
12569
+ setter: "assist config set next.repos owner/api,owner/web -g --repo",
12570
+ note: "owner/name GitHub repos the web /next view reads peer PRs and issues assigned to you from (default: the selected repo)"
12565
12571
  }
12566
12572
  ];
12567
12573
 
@@ -13700,10 +13706,12 @@ function ghJson(cwd, args) {
13700
13706
  }
13701
13707
 
13702
13708
  // src/commands/sessions/web/next/fetchAssignedIssues.ts
13703
- async function fetchAssignedIssues(cwd) {
13709
+ async function fetchAssignedIssues(cwd, repo) {
13704
13710
  const issues = await ghJson(cwd, [
13705
13711
  "issue",
13706
13712
  "list",
13713
+ "--repo",
13714
+ repo,
13707
13715
  "--assignee",
13708
13716
  "@me",
13709
13717
  "--state",
@@ -13714,6 +13722,7 @@ async function fetchAssignedIssues(cwd) {
13714
13722
  "number,title,url,createdAt,author,labels"
13715
13723
  ]);
13716
13724
  return issues.map((issue) => ({
13725
+ repo,
13717
13726
  number: issue.number,
13718
13727
  title: issue.title,
13719
13728
  url: issue.url,
@@ -13722,7 +13731,7 @@ async function fetchAssignedIssues(cwd) {
13722
13731
  labels: (issue.labels ?? []).flatMap(
13723
13732
  (label2) => label2.name ? [label2.name] : []
13724
13733
  )
13725
- })).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
13734
+ }));
13726
13735
  }
13727
13736
 
13728
13737
  // src/commands/sessions/web/next/peerPrsQuery.ts
@@ -13822,16 +13831,17 @@ function selectPeerPrs(nodes, viewer, peers) {
13822
13831
  }
13823
13832
 
13824
13833
  // src/commands/sessions/web/next/fetchPeerPrs.ts
13825
- async function fetchPeerPrs(cwd, peers) {
13834
+ async function fetchPeerPrs(cwd, repo, peers) {
13835
+ const [owner, name] = repo.split("/");
13826
13836
  const response = await ghJson(cwd, [
13827
13837
  "api",
13828
13838
  "graphql",
13829
13839
  "-f",
13830
13840
  `query=${peerPrsQuery}`,
13831
13841
  "-F",
13832
- "owner={owner}",
13842
+ `owner=${owner}`,
13833
13843
  "-F",
13834
- "name={repo}"
13844
+ `name=${name}`
13835
13845
  ]);
13836
13846
  const viewer = response.data?.viewer?.login;
13837
13847
  const repository = response.data?.repository;
@@ -13839,31 +13849,74 @@ async function fetchPeerPrs(cwd, peers) {
13839
13849
  const nodes = (repository.pullRequests?.nodes ?? []).filter(
13840
13850
  (node) => !!node
13841
13851
  );
13842
- return selectPeerPrs(nodes, viewer, peers);
13852
+ return selectPeerPrs(nodes, viewer, peers).map((pr) => ({ ...pr, repo }));
13843
13853
  }
13844
13854
 
13845
- // src/commands/sessions/web/next/nextItems.ts
13855
+ // src/commands/sessions/web/next/nextScope.ts
13856
+ var GITHUB = "github.com/";
13857
+ function githubRepo(cwd) {
13858
+ const { origin } = resolveCurrentOrigin(cwd);
13859
+ return origin.startsWith(GITHUB) ? origin.slice(GITHUB.length) : null;
13860
+ }
13861
+ function nextScope(cwd) {
13862
+ const next3 = loadConfigFrom(cwd).next;
13863
+ return {
13864
+ selfRepo: githubRepo(cwd),
13865
+ peers: next3?.peers ?? [],
13866
+ repos: next3?.repos ?? null
13867
+ };
13868
+ }
13869
+
13870
+ // src/commands/sessions/web/next/scopeRepos.ts
13871
+ function scopeRepos(configured, selfRepo) {
13872
+ if (configured) return configured;
13873
+ return selfRepo ? [selfRepo] : [];
13874
+ }
13875
+
13876
+ // src/commands/sessions/web/next/sectionAcross.ts
13846
13877
  function errorMessage(error) {
13847
13878
  const stderr = error.stderr;
13848
13879
  if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
13849
13880
  return error instanceof Error ? error.message : String(error);
13850
13881
  }
13851
- async function section(load3) {
13852
- try {
13853
- return { items: await load3(), error: null };
13854
- } catch (error) {
13855
- return { items: [], error: errorMessage(error) };
13856
- }
13882
+ async function sectionAcross(repos2, load3, compare) {
13883
+ if (repos2.length === 0)
13884
+ return {
13885
+ items: [],
13886
+ error: "No GitHub repo to read: set next.repos or select a repo with a GitHub origin."
13887
+ };
13888
+ const results = await Promise.allSettled(repos2.map((repo) => load3(repo)));
13889
+ const items2 = [];
13890
+ const errors = [];
13891
+ results.forEach((result, index3) => {
13892
+ if (result.status === "fulfilled") items2.push(...result.value);
13893
+ else errors.push(`${repos2[index3]}: ${errorMessage(result.reason)}`);
13894
+ });
13895
+ return {
13896
+ items: items2.sort(compare),
13897
+ error: errors.length > 0 ? errors.join("\n") : null
13898
+ };
13857
13899
  }
13900
+
13901
+ // src/commands/sessions/web/next/nextItems.ts
13858
13902
  async function nextItems(req, res) {
13859
13903
  const cwd = getCwdParam(req, res);
13860
13904
  if (!cwd) return;
13861
- const peers = loadConfigFrom(cwd).next?.peers ?? [];
13905
+ const scope = nextScope(cwd);
13906
+ const repos2 = scopeRepos(scope.repos, scope.selfRepo);
13862
13907
  const [peerPrs, assignedIssues] = await Promise.all([
13863
- section(() => fetchPeerPrs(cwd, peers)),
13864
- section(() => fetchAssignedIssues(cwd))
13908
+ sectionAcross(
13909
+ repos2,
13910
+ (repo) => fetchPeerPrs(cwd, repo, scope.peers),
13911
+ (a, b) => a.requestedAt.localeCompare(b.requestedAt)
13912
+ ),
13913
+ sectionAcross(
13914
+ repos2,
13915
+ (repo) => fetchAssignedIssues(cwd, repo),
13916
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
13917
+ )
13865
13918
  ]);
13866
- const body = { peers, peerPrs, assignedIssues };
13919
+ const body = { scope, peerPrs, assignedIssues };
13867
13920
  respondJson(res, 200, body);
13868
13921
  }
13869
13922
 
@@ -27741,9 +27794,9 @@ function parsePrBody(body) {
27741
27794
  return sections;
27742
27795
  }
27743
27796
  function serializePrBody(sections) {
27744
- return sections.map((section3) => `## ${section3.heading}
27797
+ return sections.map((section2) => `## ${section2.heading}
27745
27798
 
27746
- ${section3.content}`).join("\n\n");
27799
+ ${section2.content}`).join("\n\n");
27747
27800
  }
27748
27801
 
27749
27802
  // src/commands/prs/editPrBody.ts
@@ -27792,11 +27845,11 @@ function findWallOfText(body) {
27792
27845
  }
27793
27846
  function splitParagraphs(body) {
27794
27847
  const paragraphs = [];
27795
- let section3 = "(intro)";
27848
+ let section2 = "(intro)";
27796
27849
  let lines2 = [];
27797
27850
  const flush = () => {
27798
27851
  if (lines2.length > 0) {
27799
- paragraphs.push({ section: section3, lines: lines2 });
27852
+ paragraphs.push({ section: section2, lines: lines2 });
27800
27853
  lines2 = [];
27801
27854
  }
27802
27855
  };
@@ -27804,7 +27857,7 @@ function splitParagraphs(body) {
27804
27857
  const heading2 = line.match(/^#{1,6}\s+(.*)$/);
27805
27858
  if (heading2) {
27806
27859
  flush();
27807
- section3 = heading2[1].trim();
27860
+ section2 = heading2[1].trim();
27808
27861
  } else if (line.trim() === "") {
27809
27862
  flush();
27810
27863
  } else {
@@ -31206,13 +31259,13 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
31206
31259
  // src/commands/refactor/extract/displayPlan.ts
31207
31260
  import path50 from "path";
31208
31261
  import chalk207 from "chalk";
31209
- function section2(title) {
31262
+ function section(title) {
31210
31263
  return `
31211
31264
  ${chalk207.cyan(title)}`;
31212
31265
  }
31213
31266
  function displayImporters(plan2, cwd) {
31214
31267
  if (plan2.importersToUpdate.length === 0) return;
31215
- console.log(section2("Update importers:"));
31268
+ console.log(section("Update importers:"));
31216
31269
  for (const imp of plan2.importersToUpdate) {
31217
31270
  const rel = path50.relative(cwd, imp.file.getFilePath());
31218
31271
  console.log(` ${chalk207.dim(rel)}: \u2192 import from "${imp.relPath}"`);
@@ -31226,18 +31279,18 @@ function displayPlan(functionName, relDest, plan2, cwd) {
31226
31279
  console.log(` ${name}`);
31227
31280
  }
31228
31281
  if (plan2.imports.length > 0) {
31229
- console.log(section2("Imports to copy:"));
31282
+ console.log(section("Imports to copy:"));
31230
31283
  for (const imp of plan2.imports) {
31231
31284
  console.log(` ${formatImportLine(imp)}`);
31232
31285
  }
31233
31286
  }
31234
31287
  if (plan2.exportedDeps.length > 0) {
31235
- console.log(section2("New imports from source:"));
31288
+ console.log(section("New imports from source:"));
31236
31289
  console.log(
31237
31290
  ` import { ${plan2.exportedDeps.join(", ")} } from "${plan2.sourceRelPath}";`
31238
31291
  );
31239
31292
  }
31240
- console.log(section2("Source file changes:"));
31293
+ console.log(section("Source file changes:"));
31241
31294
  console.log(` Remove: ${plan2.extractedNames.join(", ")}`);
31242
31295
  if (plan2.sourceNeedsReimport) {
31243
31296
  console.log(
@@ -31246,7 +31299,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
31246
31299
  }
31247
31300
  displayImporters(plan2, cwd);
31248
31301
  if (plan2.barrel) {
31249
- console.log(section2("Barrel export:"));
31302
+ console.log(section("Barrel export:"));
31250
31303
  console.log(
31251
31304
  ` Add: export { ${functionName} } from "${plan2.barrelRelPath}";`
31252
31305
  );
@@ -33004,10 +33057,10 @@ function checkDescriptionLinksIssue(body) {
33004
33057
 
33005
33058
  // src/commands/review/highLevel/checkDescriptionSections.ts
33006
33059
  function sectionContent(body, heading2) {
33007
- const section3 = parsePrBody(body).find(
33060
+ const section2 = parsePrBody(body).find(
33008
33061
  (candidate) => candidate.heading.trim().toLowerCase() === heading2
33009
33062
  );
33010
- return section3 ? section3.content.trim() : null;
33063
+ return section2 ? section2.content.trim() : null;
33011
33064
  }
33012
33065
  function describe5(heading2, content) {
33013
33066
  if (content === null) return `no \`## ${heading2}\` section`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.728.0",
3
+ "version": "0.729.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {