@staff0rd/assist 0.732.1 → 0.733.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.732.1",
9
+ version: "0.733.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -860,7 +860,9 @@ var assistConfigShape = {
860
860
  }).optional(),
861
861
  next: z3.strictObject({
862
862
  peers: z3.array(z3.string()).optional(),
863
- repos: z3.array(z3.string()).optional()
863
+ repos: z3.array(z3.string()).optional(),
864
+ project: z3.string().regex(/^[^/\s]+\/\d+$/, "Use <owner>/<project number>, e.g. my-org/3").optional(),
865
+ pickStatuses: z3.array(z3.string()).optional()
864
866
  }).optional(),
865
867
  deny: z3.array(
866
868
  z3.strictObject({
@@ -12576,6 +12578,16 @@ var nextConfigHelp = [
12576
12578
  key: "next.repos",
12577
12579
  setter: "assist config set next.repos my-org,other/web -g --repo",
12578
12580
  note: "GitHub repos the web /next view reads peer PRs and issues assigned to you from: owner/name for one repo, or a bare owner (org or user) for all its unarchived repos (default: the selected repo)"
12581
+ },
12582
+ {
12583
+ key: "next.project",
12584
+ setter: "assist config set next.project my-org/3 -g --repo",
12585
+ note: "GitHub Project (owner/number, from its URL) the web /next view suggests unassigned issues to pick up from; needs the gh project scope"
12586
+ },
12587
+ {
12588
+ key: "next.pickStatuses",
12589
+ setter: "assist config set next.pickStatuses Ready,Todo -g --repo",
12590
+ note: "Project Status values whose unassigned items the web /next view offers to pick up (default: Ready, Todo)"
12579
12591
  }
12580
12592
  ];
12581
12593
 
@@ -13931,8 +13943,150 @@ async function fetchPeerPrs(cwd, repo, peers) {
13931
13943
  return selectPeerPrs(nodes, viewer, peers).map((pr) => ({ ...pr, repo }));
13932
13944
  }
13933
13945
 
13946
+ // src/commands/sessions/web/next/ghErrorText.ts
13947
+ function ghErrorText(error) {
13948
+ const stderr = error.stderr;
13949
+ if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
13950
+ return error instanceof Error ? error.message : String(error);
13951
+ }
13952
+
13953
+ // src/commands/sessions/web/next/pickupsError.ts
13954
+ function pickupsError(project, error) {
13955
+ const text18 = ghErrorText(error);
13956
+ if (/read:project|required scopes/i.test(text18))
13957
+ return `The gh token has no project scope, so project ${project} cannot be read. Run: gh auth refresh -h github.com -s project`;
13958
+ return `${project}: ${text18}`;
13959
+ }
13960
+
13961
+ // src/commands/sessions/web/next/pickupsQuery.ts
13962
+ var pickupsQuery = `query($owner: String!, $number: Int!, $after: String) {
13963
+ repositoryOwner(login: $owner) {
13964
+ ... on ProjectV2Owner {
13965
+ projectV2(number: $number) {
13966
+ priorityField: field(name: "Priority") {
13967
+ ... on ProjectV2SingleSelectField { options { name } }
13968
+ }
13969
+ items(first: 100, after: $after) {
13970
+ pageInfo { hasNextPage endCursor }
13971
+ nodes {
13972
+ id
13973
+ status: fieldValueByName(name: "Status") {
13974
+ ... on ProjectV2ItemFieldSingleSelectValue { name }
13975
+ }
13976
+ priority: fieldValueByName(name: "Priority") {
13977
+ ... on ProjectV2ItemFieldSingleSelectValue { name }
13978
+ }
13979
+ content {
13980
+ ... on Issue {
13981
+ number
13982
+ title
13983
+ url
13984
+ createdAt
13985
+ state
13986
+ author { login }
13987
+ repository { nameWithOwner }
13988
+ assignees(first: 1) { totalCount }
13989
+ labels(first: 20) { nodes { name } }
13990
+ }
13991
+ }
13992
+ }
13993
+ }
13994
+ }
13995
+ }
13996
+ }
13997
+ }`;
13998
+
13999
+ // src/commands/sessions/web/next/readProjectPage.ts
14000
+ function readProjectPage(cwd, owner, number, after) {
14001
+ return ghJson(cwd, [
14002
+ "api",
14003
+ "graphql",
14004
+ "-f",
14005
+ `query=${pickupsQuery}`,
14006
+ "-F",
14007
+ `owner=${owner}`,
14008
+ "-F",
14009
+ `number=${number}`,
14010
+ ...after ? ["-f", `after=${after}`] : []
14011
+ ]);
14012
+ }
14013
+
14014
+ // src/commands/sessions/web/next/readProjectItems.ts
14015
+ var MAX_PAGES = 10;
14016
+ async function readProjectItems(cwd, project) {
14017
+ const [owner, number] = project.split("/");
14018
+ const nodes = [];
14019
+ let priorityOrder = [];
14020
+ let after = null;
14021
+ for (let page = 0; page < MAX_PAGES; page++) {
14022
+ const response = await readProjectPage(cwd, owner, number, after);
14023
+ const projectV2 = response.data?.repositoryOwner?.projectV2;
14024
+ if (!projectV2?.items) {
14025
+ const reason4 = response.errors?.[0]?.message;
14026
+ throw new Error(reason4 ?? `No project ${number} owned by ${owner}`);
14027
+ }
14028
+ priorityOrder = (projectV2.priorityField?.options ?? []).map(
14029
+ (option) => option.name
14030
+ );
14031
+ for (const node of projectV2.items.nodes ?? []) if (node) nodes.push(node);
14032
+ const { hasNextPage: hasNextPage2, endCursor } = projectV2.items.pageInfo ?? {};
14033
+ if (!hasNextPage2 || !endCursor) break;
14034
+ after = endCursor;
14035
+ }
14036
+ return { nodes, priorityOrder };
14037
+ }
14038
+
14039
+ // src/commands/sessions/web/next/selectPickups.ts
14040
+ function toPickup(node) {
14041
+ const issue = node.content;
14042
+ const repo = issue?.repository?.nameWithOwner;
14043
+ const status3 = node.status?.name;
14044
+ if (!issue?.number || !issue.url || !repo || !status3) return null;
14045
+ return {
14046
+ repo,
14047
+ number: issue.number,
14048
+ title: issue.title ?? "",
14049
+ url: issue.url,
14050
+ createdAt: issue.createdAt ?? "",
14051
+ author: issue.author?.login ?? "unknown",
14052
+ labels: (issue.labels?.nodes ?? []).flatMap(
14053
+ (label2) => label2?.name ? [label2.name] : []
14054
+ ),
14055
+ itemId: node.id,
14056
+ status: status3,
14057
+ priority: node.priority?.name ?? null
14058
+ };
14059
+ }
14060
+ function selectPickups(nodes, pickStatuses, priorityOrder) {
14061
+ const statuses = new Set(pickStatuses.map((status3) => status3.toLowerCase()));
14062
+ const rank = (pickup) => {
14063
+ const index3 = pickup.priority ? priorityOrder.indexOf(pickup.priority) : -1;
14064
+ return index3 === -1 ? priorityOrder.length : index3;
14065
+ };
14066
+ return nodes.filter(
14067
+ (node) => node.content?.state === "OPEN" && node.content.assignees?.totalCount === 0
14068
+ ).flatMap((node) => toPickup(node) ?? []).filter((pickup) => statuses.has(pickup.status.toLowerCase())).sort(
14069
+ (a, b) => rank(a) - rank(b) || a.createdAt.localeCompare(b.createdAt)
14070
+ );
14071
+ }
14072
+
14073
+ // src/commands/sessions/web/next/fetchPickups.ts
14074
+ async function fetchPickups(cwd, project, pickStatuses) {
14075
+ if (!project) return { items: [], error: null };
14076
+ try {
14077
+ const { nodes, priorityOrder } = await readProjectItems(cwd, project);
14078
+ return {
14079
+ items: selectPickups(nodes, pickStatuses, priorityOrder),
14080
+ error: null
14081
+ };
14082
+ } catch (error) {
14083
+ return { items: [], error: pickupsError(project, error) };
14084
+ }
14085
+ }
14086
+
13934
14087
  // src/commands/sessions/web/next/nextScope.ts
13935
14088
  var GITHUB = "github.com/";
14089
+ var DEFAULT_PICK_STATUSES = ["Ready", "Todo"];
13936
14090
  function githubRepo(cwd) {
13937
14091
  const { origin } = resolveCurrentOrigin(cwd);
13938
14092
  return origin.startsWith(GITHUB) ? origin.slice(GITHUB.length) : null;
@@ -13942,7 +14096,9 @@ function nextScope(cwd) {
13942
14096
  return {
13943
14097
  selfRepo: githubRepo(cwd),
13944
14098
  peers: next3?.peers ?? [],
13945
- repos: next3?.repos ?? null
14099
+ repos: next3?.repos ?? null,
14100
+ project: next3?.project ?? null,
14101
+ pickStatuses: next3?.pickStatuses ?? DEFAULT_PICK_STATUSES
13946
14102
  };
13947
14103
  }
13948
14104
 
@@ -13953,11 +14109,6 @@ function scopeRepos(configured, selfRepo) {
13953
14109
  }
13954
14110
 
13955
14111
  // src/commands/sessions/web/next/sectionAcross.ts
13956
- function errorMessage(error) {
13957
- const stderr = error.stderr;
13958
- if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
13959
- return error instanceof Error ? error.message : String(error);
13960
- }
13961
14112
  async function sectionAcross(repos2, load3, compare) {
13962
14113
  if (repos2.length === 0)
13963
14114
  return {
@@ -13970,7 +14121,7 @@ async function sectionAcross(repos2, load3, compare) {
13970
14121
  results.forEach((result, index3) => {
13971
14122
  if (result.status === "fulfilled")
13972
14123
  for (const item of result.value) items2.set(item.url, item);
13973
- else errors.push(`${repos2[index3]}: ${errorMessage(result.reason)}`);
14124
+ else errors.push(`${repos2[index3]}: ${ghErrorText(result.reason)}`);
13974
14125
  });
13975
14126
  return {
13976
14127
  items: [...items2.values()].sort(compare),
@@ -13984,7 +14135,7 @@ async function nextItems(req, res) {
13984
14135
  if (!cwd) return;
13985
14136
  const scope = nextScope(cwd);
13986
14137
  const repos2 = scopeRepos(scope.repos, scope.selfRepo);
13987
- const [peerPrs, assignedIssues] = await Promise.all([
14138
+ const [peerPrs, assignedIssues, pickups] = await Promise.all([
13988
14139
  sectionAcross(
13989
14140
  repos2,
13990
14141
  (repo) => fetchPeerPrs(cwd, repo, scope.peers),
@@ -13994,12 +14145,222 @@ async function nextItems(req, res) {
13994
14145
  repos2,
13995
14146
  (repo) => fetchAssignedIssues(cwd, repo),
13996
14147
  (a, b) => a.createdAt.localeCompare(b.createdAt)
13997
- )
14148
+ ),
14149
+ fetchPickups(cwd, scope.project, scope.pickStatuses)
13998
14150
  ]);
13999
- const body = { scope, peerPrs, assignedIssues };
14151
+ const body = { scope, peerPrs, assignedIssues, pickups };
14000
14152
  respondJson(res, 200, body);
14001
14153
  }
14002
14154
 
14155
+ // src/commands/sessions/web/readJsonBody.ts
14156
+ async function readJsonBody(req) {
14157
+ const chunks = [];
14158
+ for await (const chunk of req) chunks.push(chunk);
14159
+ return JSON.parse(Buffer.concat(chunks).toString("utf8"));
14160
+ }
14161
+
14162
+ // src/commands/github/issue/readGhTokenScopes.ts
14163
+ import { spawnSync as spawnSync3 } from "child_process";
14164
+ var SCOPES_LINE = /Token scopes:\s*(.*)/;
14165
+ function readGhTokenScopes() {
14166
+ const result = spawnSync3("gh", ["auth", "status"], {
14167
+ encoding: "utf8",
14168
+ windowsHide: true
14169
+ });
14170
+ const match = SCOPES_LINE.exec(
14171
+ `${result.stdout ?? ""}
14172
+ ${result.stderr ?? ""}`
14173
+ );
14174
+ if (!match) return void 0;
14175
+ return (match[1] ?? "").split(",").map((scope) => scope.trim().replace(/^'|'$/g, "")).filter((scope) => scope.length > 0);
14176
+ }
14177
+
14178
+ // src/commands/github/issue/assertProjectScope.ts
14179
+ function assertProjectScope() {
14180
+ const scopes = readGhTokenScopes();
14181
+ if (!scopes || scopes.includes("project")) return;
14182
+ throw new Error(
14183
+ `The gh token has no project scope, so a project cannot be read or written. It has ${scopes.join(", ") || "no scopes"}. Run: gh auth refresh -h github.com -s project`
14184
+ );
14185
+ }
14186
+
14187
+ // src/commands/github/issue/assignIssueToSelf.ts
14188
+ import { execFileSync as execFileSync3 } from "child_process";
14189
+ function assignIssueToSelf(number, repo) {
14190
+ const args = [
14191
+ "issue",
14192
+ "edit",
14193
+ String(number),
14194
+ "--repo",
14195
+ repo,
14196
+ "--add-assignee",
14197
+ "@me"
14198
+ ];
14199
+ try {
14200
+ execFileSync3("gh", args, {
14201
+ stdio: ["ignore", "ignore", "pipe"],
14202
+ encoding: "utf8"
14203
+ });
14204
+ } catch (error) {
14205
+ const stderr = error.stderr;
14206
+ throw new Error(
14207
+ typeof stderr === "string" && stderr.trim() ? stderr.trim() : `Could not assign ${repo}#${number} to you`
14208
+ );
14209
+ }
14210
+ }
14211
+
14212
+ // src/shared/runGhGraphqlJson.ts
14213
+ import { spawnSync as spawnSync4 } from "child_process";
14214
+
14215
+ // src/shared/throwOnGraphqlErrors.ts
14216
+ function throwOnGraphqlErrors(stdout) {
14217
+ let parsed;
14218
+ try {
14219
+ parsed = JSON.parse(stdout);
14220
+ } catch {
14221
+ return;
14222
+ }
14223
+ if (!parsed || typeof parsed !== "object") return;
14224
+ const errors = parsed.errors;
14225
+ if (!Array.isArray(errors) || errors.length === 0) return;
14226
+ const messages = errors.map(
14227
+ (entry) => entry && typeof entry === "object" && "message" in entry ? String(entry.message) : String(entry)
14228
+ ).join("; ");
14229
+ throw new Error(messages || "GraphQL request returned errors");
14230
+ }
14231
+
14232
+ // src/shared/runGhGraphqlJson.ts
14233
+ function runGhGraphqlJson(query, vars = {}) {
14234
+ const result = spawnSync4("gh", ["api", "graphql", "--input", "-"], {
14235
+ encoding: "utf8",
14236
+ windowsHide: true,
14237
+ input: JSON.stringify({ query, variables: vars }),
14238
+ maxBuffer: 64 * 1024 * 1024
14239
+ });
14240
+ if (result.status !== 0) throw new Error(result.stderr || result.stdout);
14241
+ throwOnGraphqlErrors(result.stdout);
14242
+ return result.stdout;
14243
+ }
14244
+
14245
+ // src/commands/github/issue/projectV2Query.ts
14246
+ function projectV2Query(root2) {
14247
+ return `query($owner: String!, $number: Int!) {
14248
+ ${root2}(login: $owner) {
14249
+ projectV2(number: $number) {
14250
+ id
14251
+ title
14252
+ field(name: "Status") {
14253
+ ... on ProjectV2SingleSelectField { id options { id name } }
14254
+ }
14255
+ }
14256
+ }
14257
+ }`;
14258
+ }
14259
+
14260
+ // src/commands/github/issue/readProject.ts
14261
+ function readProject(owner, number, root2) {
14262
+ let raw;
14263
+ try {
14264
+ raw = runGhGraphqlJson(projectV2Query(root2), { owner, number });
14265
+ } catch (error) {
14266
+ const message3 = error instanceof Error ? error.message : String(error);
14267
+ if (root2 === "organization" && message3.includes("Could not resolve to an")) {
14268
+ return void 0;
14269
+ }
14270
+ throw error;
14271
+ }
14272
+ const project = JSON.parse(raw).data?.[root2]?.projectV2;
14273
+ if (!project?.id) return void 0;
14274
+ const field = project.field;
14275
+ return {
14276
+ id: project.id,
14277
+ number,
14278
+ title: project.title ?? String(number),
14279
+ statusField: field?.id ? { id: field.id, options: field.options ?? [] } : void 0
14280
+ };
14281
+ }
14282
+
14283
+ // src/commands/github/issue/fetchProjectV2.ts
14284
+ function fetchProjectV2(owner, number) {
14285
+ const project = readProject(owner, number, "organization") ?? readProject(owner, number, "user");
14286
+ if (!project) {
14287
+ throw new Error(`No project ${number} owned by ${owner} could be read`);
14288
+ }
14289
+ return project;
14290
+ }
14291
+
14292
+ // src/commands/github/issue/setProjectItemStatus.ts
14293
+ var MUTATION = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
14294
+ updateProjectV2ItemFieldValue(input: {
14295
+ projectId: $projectId
14296
+ itemId: $itemId
14297
+ fieldId: $fieldId
14298
+ value: { singleSelectOptionId: $optionId }
14299
+ }) {
14300
+ projectV2Item { id }
14301
+ }
14302
+ }`;
14303
+ function setProjectItemStatus(input) {
14304
+ runGhGraphqlJson(MUTATION, input);
14305
+ }
14306
+
14307
+ // src/commands/sessions/web/next/pickUpItem.ts
14308
+ var IN_PROGRESS = "in progress";
14309
+ function pickUpItem(project, target) {
14310
+ assertProjectScope();
14311
+ const [owner, number] = project.split("/");
14312
+ const board = fetchProjectV2(owner, Number(number));
14313
+ const option = board.statusField?.options.find(
14314
+ (candidate) => candidate.name.toLowerCase() === IN_PROGRESS
14315
+ );
14316
+ if (!board.statusField || !option)
14317
+ throw new Error(
14318
+ `Project ${project} (${board.title}) has no In Progress status to move ${target.repo}#${target.number} to`
14319
+ );
14320
+ assignIssueToSelf(target.number, target.repo);
14321
+ setProjectItemStatus({
14322
+ projectId: board.id,
14323
+ itemId: target.itemId,
14324
+ fieldId: board.statusField.id,
14325
+ optionId: option.id
14326
+ });
14327
+ }
14328
+
14329
+ // src/commands/sessions/web/next/nextPickup.ts
14330
+ function parseTarget(body) {
14331
+ const { repo, number, itemId: itemId2 } = body ?? {};
14332
+ if (typeof repo !== "string" || !repo.includes("/")) return null;
14333
+ if (typeof number !== "number" || !Number.isInteger(number)) return null;
14334
+ if (typeof itemId2 !== "string" || !itemId2) return null;
14335
+ return { repo, number, itemId: itemId2 };
14336
+ }
14337
+ async function nextPickup(req, res) {
14338
+ const cwd = getCwdParam(req, res);
14339
+ if (!cwd) return;
14340
+ let target;
14341
+ try {
14342
+ target = parseTarget(await readJsonBody(req));
14343
+ } catch {
14344
+ respondJson(res, 400, { error: "Invalid JSON body" });
14345
+ return;
14346
+ }
14347
+ if (!target) {
14348
+ respondJson(res, 400, { error: "Missing repo, number or itemId" });
14349
+ return;
14350
+ }
14351
+ const { project } = nextScope(cwd);
14352
+ if (!project) {
14353
+ respondJson(res, 400, { error: "next.project is not set for this repo" });
14354
+ return;
14355
+ }
14356
+ try {
14357
+ pickUpItem(project, target);
14358
+ respondJson(res, 200, { ok: true });
14359
+ } catch (error) {
14360
+ respondJson(res, 500, { error: ghErrorText(error) });
14361
+ }
14362
+ }
14363
+
14003
14364
  // src/commands/sessions/web/listScopedRules.ts
14004
14365
  import path27 from "path";
14005
14366
 
@@ -15010,7 +15371,7 @@ async function streamRunState(cwd, stream) {
15010
15371
  }
15011
15372
 
15012
15373
  // src/commands/sessions/web/releases/streamState.ts
15013
- function errorMessage2(error) {
15374
+ function errorMessage(error) {
15014
15375
  if (!(error instanceof Error)) return "Failed to read release state";
15015
15376
  return error.message.trim().split("\n")[0] || "Failed to read release state";
15016
15377
  }
@@ -15048,7 +15409,7 @@ async function streamState(cwd, stream, repoEnvironments2 = streamEnvironments(s
15048
15409
  head: null,
15049
15410
  nodes: [],
15050
15411
  run: null,
15051
- error: errorMessage2(error)
15412
+ error: errorMessage(error)
15052
15413
  };
15053
15414
  }
15054
15415
  }
@@ -15121,7 +15482,7 @@ async function restartDaemon() {
15121
15482
  }
15122
15483
 
15123
15484
  // src/commands/sessions/web/restartMenu/reExecWebServer.ts
15124
- import { spawnSync as spawnSync3 } from "child_process";
15485
+ import { spawnSync as spawnSync5 } from "child_process";
15125
15486
  function resolveExecve() {
15126
15487
  return typeof process.execve === "function" ? process.execve.bind(process) : null;
15127
15488
  }
@@ -15132,7 +15493,7 @@ function reExecWebServer(deps2 = {}) {
15132
15493
  const {
15133
15494
  beforeExec,
15134
15495
  execveFn = resolveExecve(),
15135
- spawnSyncFn = spawnSync3,
15496
+ spawnSyncFn = spawnSync5,
15136
15497
  exit = (code) => process.exit(code),
15137
15498
  releasePort = releaseWebServerPort
15138
15499
  } = deps2;
@@ -15222,13 +15583,13 @@ import { spawn as spawn4 } from "child_process";
15222
15583
  import { existsSync as existsSync38 } from "fs";
15223
15584
 
15224
15585
  // src/commands/run/resolveCommand.ts
15225
- import { execFileSync as execFileSync3 } from "child_process";
15586
+ import { execFileSync as execFileSync4 } from "child_process";
15226
15587
  import { existsSync as existsSync37 } from "fs";
15227
15588
  import { dirname as dirname23, join as join38, resolve as resolve12 } from "path";
15228
15589
  function resolveCommand(command) {
15229
15590
  if (process.platform !== "win32" || command !== "bash") return command;
15230
15591
  try {
15231
- const gitPath = execFileSync3("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
15592
+ const gitPath = execFileSync4("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
15232
15593
  const gitRoot = resolve12(dirname23(gitPath), "..");
15233
15594
  const gitBash = join38(gitRoot, "bin", "bash.exe");
15234
15595
  if (existsSync37(gitBash)) return gitBash;
@@ -15302,15 +15663,6 @@ async function selfUpdate(_req, res, deps2 = {}) {
15302
15663
 
15303
15664
  // src/commands/sessions/web/revertDiffPaths.ts
15304
15665
  import { relative as relative4 } from "path";
15305
-
15306
- // src/commands/sessions/web/readJsonBody.ts
15307
- async function readJsonBody(req) {
15308
- const chunks = [];
15309
- for await (const chunk of req) chunks.push(chunk);
15310
- return JSON.parse(Buffer.concat(chunks).toString("utf8"));
15311
- }
15312
-
15313
- // src/commands/sessions/web/revertDiffPaths.ts
15314
15666
  function requestedPaths(body) {
15315
15667
  const paths = body.paths;
15316
15668
  if (!Array.isArray(paths)) return null;
@@ -16292,6 +16644,7 @@ var routes2 = {
16292
16644
  "GET /api/server-runs": handleServerRuns,
16293
16645
  "GET /api/pr-list": prList,
16294
16646
  "GET /api/next": nextItems,
16647
+ "POST /api/next/pickup": nextPickup,
16295
16648
  "GET /api/news/items": listNewsItems,
16296
16649
  "GET /api/news/nav": newsNavConfig,
16297
16650
  "GET /api/releases/state": releasesState,
@@ -20530,7 +20883,7 @@ function registerDeploy(program2) {
20530
20883
  }
20531
20884
 
20532
20885
  // src/commands/devlog/list.ts
20533
- import { execFileSync as execFileSync4 } from "child_process";
20886
+ import { execFileSync as execFileSync5 } from "child_process";
20534
20887
  import { basename as basename14 } from "path";
20535
20888
 
20536
20889
  // src/commands/devlog/loadBlogSkipDays.ts
@@ -20710,7 +21063,7 @@ function list2(options2) {
20710
21063
  if (options2.reverse) args.push("--reverse");
20711
21064
  else args.push("-n", "500");
20712
21065
  args.push("--pretty=format:%ad|%h|%s", "--date=short");
20713
- const output = execFileSync4("git", args, { encoding: "utf8" });
21066
+ const output = execFileSync5("git", args, { encoding: "utf8" });
20714
21067
  const commitsByDate = parseGitLogCommits(output, ignore3);
20715
21068
  let dateCount = 0;
20716
21069
  let isFirst = true;
@@ -20733,7 +21086,7 @@ function list2(options2) {
20733
21086
  }
20734
21087
 
20735
21088
  // src/commands/devlog/getLastVersionInfo.ts
20736
- import { execFileSync as execFileSync5, execSync as execSync32 } from "child_process";
21089
+ import { execFileSync as execFileSync6, execSync as execSync32 } from "child_process";
20737
21090
  import semver from "semver";
20738
21091
  function getVersionAtCommit(hash) {
20739
21092
  try {
@@ -20752,7 +21105,7 @@ function stripToMinor(version2) {
20752
21105
  }
20753
21106
  function getLastVersionInfoFromGit() {
20754
21107
  try {
20755
- const output = execFileSync5(
21108
+ const output = execFileSync6(
20756
21109
  "git",
20757
21110
  ["log", "-1", "--pretty=format:%ad|%h", "--date=short"],
20758
21111
  {
@@ -20797,7 +21150,7 @@ function bumpVersion(version2, type) {
20797
21150
  }
20798
21151
 
20799
21152
  // src/commands/devlog/next/displayNextEntry.ts
20800
- import { execFileSync as execFileSync6 } from "child_process";
21153
+ import { execFileSync as execFileSync7 } from "child_process";
20801
21154
  import chalk147 from "chalk";
20802
21155
 
20803
21156
  // src/commands/devlog/next/displayNextEntry/displayVersion.ts
@@ -20831,7 +21184,7 @@ function findTargetDate(commitsByDate, skipDays) {
20831
21184
  return Array.from(commitsByDate.keys()).filter((d) => !skipDays.has(d)).sort()[0];
20832
21185
  }
20833
21186
  function fetchCommitsByDate(ignore3, lastDate) {
20834
- const output = execFileSync6(
21187
+ const output = execFileSync7(
20835
21188
  "git",
20836
21189
  ["log", "--pretty=format:%ad|%h|%s", "--date=short", "-n", "500"],
20837
21190
  { encoding: "utf8" }
@@ -22434,29 +22787,10 @@ function aggregateCommitters(authorLists) {
22434
22787
  }
22435
22788
 
22436
22789
  // src/shared/runGhGraphql.ts
22437
- import { spawnSync as spawnSync4 } from "child_process";
22790
+ import { spawnSync as spawnSync6 } from "child_process";
22438
22791
  import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
22439
22792
  import { tmpdir as tmpdir6 } from "os";
22440
22793
  import { join as join59 } from "path";
22441
-
22442
- // src/shared/throwOnGraphqlErrors.ts
22443
- function throwOnGraphqlErrors(stdout) {
22444
- let parsed;
22445
- try {
22446
- parsed = JSON.parse(stdout);
22447
- } catch {
22448
- return;
22449
- }
22450
- if (!parsed || typeof parsed !== "object") return;
22451
- const errors = parsed.errors;
22452
- if (!Array.isArray(errors) || errors.length === 0) return;
22453
- const messages = errors.map(
22454
- (entry) => entry && typeof entry === "object" && "message" in entry ? String(entry.message) : String(entry)
22455
- ).join("; ");
22456
- throw new Error(messages || "GraphQL request returned errors");
22457
- }
22458
-
22459
- // src/shared/runGhGraphql.ts
22460
22794
  function buildArgs2(queryFile, vars) {
22461
22795
  const args = ["api", "graphql", "-F", `query=@${queryFile}`];
22462
22796
  for (const [key, value] of Object.entries(vars)) {
@@ -22469,7 +22803,7 @@ function runGhGraphql(mutation, vars) {
22469
22803
  const queryFile = join59(tmpdir6(), `gh-query-${Date.now()}.graphql`);
22470
22804
  writeFileSync30(queryFile, mutation);
22471
22805
  try {
22472
- const result = spawnSync4("gh", buildArgs2(queryFile, vars), {
22806
+ const result = spawnSync6("gh", buildArgs2(queryFile, vars), {
22473
22807
  encoding: "utf8",
22474
22808
  windowsHide: true
22475
22809
  });
@@ -22637,38 +22971,24 @@ import chalk164 from "chalk";
22637
22971
  // src/commands/github/issue/fixStructure/applyFixStructurePlan.ts
22638
22972
  import chalk163 from "chalk";
22639
22973
 
22640
- // src/shared/runGhGraphqlJson.ts
22641
- import { spawnSync as spawnSync5 } from "child_process";
22642
- function runGhGraphqlJson(query, vars = {}) {
22643
- const result = spawnSync5("gh", ["api", "graphql", "--input", "-"], {
22644
- encoding: "utf8",
22645
- windowsHide: true,
22646
- input: JSON.stringify({ query, variables: vars }),
22647
- maxBuffer: 64 * 1024 * 1024
22648
- });
22649
- if (result.status !== 0) throw new Error(result.stderr || result.stdout);
22650
- throwOnGraphqlErrors(result.stdout);
22651
- return result.stdout;
22652
- }
22653
-
22654
22974
  // src/commands/github/issue/fixStructure/removeIssueLabels.ts
22655
- var MUTATION = `mutation($labelableId: ID!, $labelIds: [ID!]!) {
22975
+ var MUTATION2 = `mutation($labelableId: ID!, $labelIds: [ID!]!) {
22656
22976
  removeLabelsFromLabelable(input: { labelableId: $labelableId, labelIds: $labelIds }) {
22657
22977
  labelable { __typename }
22658
22978
  }
22659
22979
  }`;
22660
22980
  function removeIssueLabels(issueId, labelIds) {
22661
- runGhGraphqlJson(MUTATION, { labelableId: issueId, labelIds });
22981
+ runGhGraphqlJson(MUTATION2, { labelableId: issueId, labelIds });
22662
22982
  }
22663
22983
 
22664
22984
  // src/commands/github/issue/fixStructure/updateIssueType.ts
22665
- var MUTATION2 = `mutation($issueId: ID!, $issueTypeId: ID!) {
22985
+ var MUTATION3 = `mutation($issueId: ID!, $issueTypeId: ID!) {
22666
22986
  updateIssueIssueType(input: { issueId: $issueId, issueTypeId: $issueTypeId }) {
22667
22987
  issue { id }
22668
22988
  }
22669
22989
  }`;
22670
22990
  function updateIssueType(issueId, issueTypeId) {
22671
- runGhGraphqlJson(MUTATION2, { issueId, issueTypeId });
22991
+ runGhGraphqlJson(MUTATION3, { issueId, issueTypeId });
22672
22992
  }
22673
22993
 
22674
22994
  // src/commands/github/issue/fixStructure/writeLineNow.ts
@@ -23204,7 +23524,7 @@ async function readBodyArgument(value) {
23204
23524
  }
23205
23525
 
23206
23526
  // src/commands/github/issue/commentIssue.ts
23207
- import { execFileSync as execFileSync7 } from "child_process";
23527
+ import { execFileSync as execFileSync8 } from "child_process";
23208
23528
 
23209
23529
  // src/shared/validateProposedContent.ts
23210
23530
  function validateProposedContent(labels, title, body) {
@@ -23265,7 +23585,7 @@ async function commentIssue(numberArg, options2) {
23265
23585
  const args = ["issue", "comment", String(number), "--body", body];
23266
23586
  if (options2.repo) args.push("--repo", options2.repo);
23267
23587
  try {
23268
- execFileSync7("gh", args, { stdio: "inherit" });
23588
+ execFileSync8("gh", args, { stdio: "inherit" });
23269
23589
  } catch {
23270
23590
  process.exit(1);
23271
23591
  }
@@ -23307,26 +23627,26 @@ ${screenshots.join("\n\n")}`;
23307
23627
  }
23308
23628
 
23309
23629
  // src/commands/github/issue/addIssueToProject.ts
23310
- var MUTATION3 = `mutation($projectId: ID!, $contentId: ID!) {
23630
+ var MUTATION4 = `mutation($projectId: ID!, $contentId: ID!) {
23311
23631
  addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) {
23312
23632
  item { id }
23313
23633
  }
23314
23634
  }`;
23315
23635
  function addIssueToProject(projectId, contentId) {
23316
- const raw = runGhGraphqlJson(MUTATION3, { projectId, contentId });
23636
+ const raw = runGhGraphqlJson(MUTATION4, { projectId, contentId });
23317
23637
  const id = JSON.parse(raw).data?.addProjectV2ItemById?.item?.id;
23318
23638
  if (!id) throw new Error("The project returned no item for the issue");
23319
23639
  return id;
23320
23640
  }
23321
23641
 
23322
23642
  // src/commands/github/issue/addSubIssue.ts
23323
- var MUTATION4 = `mutation($issueId: ID!, $subIssueId: ID!) {
23643
+ var MUTATION5 = `mutation($issueId: ID!, $subIssueId: ID!) {
23324
23644
  addSubIssue(input: { issueId: $issueId, subIssueId: $subIssueId, replaceParent: true }) {
23325
23645
  subIssue { id }
23326
23646
  }
23327
23647
  }`;
23328
23648
  function addSubIssue(parentId, childId) {
23329
- runGhGraphqlJson(MUTATION4, { issueId: parentId, subIssueId: childId });
23649
+ runGhGraphqlJson(MUTATION5, { issueId: parentId, subIssueId: childId });
23330
23650
  }
23331
23651
 
23332
23652
  // src/commands/github/issue/fetchIssueNodeId.ts
@@ -23363,21 +23683,6 @@ function parseCreatedIssueUrl(output) {
23363
23683
  };
23364
23684
  }
23365
23685
 
23366
- // src/commands/github/issue/setProjectItemStatus.ts
23367
- var MUTATION5 = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
23368
- updateProjectV2ItemFieldValue(input: {
23369
- projectId: $projectId
23370
- itemId: $itemId
23371
- fieldId: $fieldId
23372
- value: { singleSelectOptionId: $optionId }
23373
- }) {
23374
- projectV2Item { id }
23375
- }
23376
- }`;
23377
- function setProjectItemStatus(input) {
23378
- runGhGraphqlJson(MUTATION5, input);
23379
- }
23380
-
23381
23686
  // src/commands/github/issue/applyCreatedIssueMetadata.ts
23382
23687
  function applyCreatedIssueMetadata(createOutput, metadata2) {
23383
23688
  let step3 = "identifying the created issue";
@@ -23594,78 +23899,6 @@ function resolveCreateIssueParent(target, parent) {
23594
23899
  return { ...reference, id: fetchIssueNodeId(reference) };
23595
23900
  }
23596
23901
 
23597
- // src/commands/github/issue/readGhTokenScopes.ts
23598
- import { spawnSync as spawnSync6 } from "child_process";
23599
- var SCOPES_LINE = /Token scopes:\s*(.*)/;
23600
- function readGhTokenScopes() {
23601
- const result = spawnSync6("gh", ["auth", "status"], {
23602
- encoding: "utf8",
23603
- windowsHide: true
23604
- });
23605
- const match = SCOPES_LINE.exec(
23606
- `${result.stdout ?? ""}
23607
- ${result.stderr ?? ""}`
23608
- );
23609
- if (!match) return void 0;
23610
- return (match[1] ?? "").split(",").map((scope) => scope.trim().replace(/^'|'$/g, "")).filter((scope) => scope.length > 0);
23611
- }
23612
-
23613
- // src/commands/github/issue/assertProjectScope.ts
23614
- function assertProjectScope() {
23615
- const scopes = readGhTokenScopes();
23616
- if (!scopes || scopes.includes("project")) return;
23617
- throw new Error(
23618
- `The gh token has no project scope, so a project cannot be read or written. It has ${scopes.join(", ") || "no scopes"}. Run: gh auth refresh -h github.com -s project`
23619
- );
23620
- }
23621
-
23622
- // src/commands/github/issue/projectV2Query.ts
23623
- function projectV2Query(root2) {
23624
- return `query($owner: String!, $number: Int!) {
23625
- ${root2}(login: $owner) {
23626
- projectV2(number: $number) {
23627
- id
23628
- title
23629
- field(name: "Status") {
23630
- ... on ProjectV2SingleSelectField { id options { id name } }
23631
- }
23632
- }
23633
- }
23634
- }`;
23635
- }
23636
-
23637
- // src/commands/github/issue/readProject.ts
23638
- function readProject(owner, number, root2) {
23639
- let raw;
23640
- try {
23641
- raw = runGhGraphqlJson(projectV2Query(root2), { owner, number });
23642
- } catch (error) {
23643
- const message3 = error instanceof Error ? error.message : String(error);
23644
- if (root2 === "organization" && message3.includes("Could not resolve to an")) {
23645
- return void 0;
23646
- }
23647
- throw error;
23648
- }
23649
- const project = JSON.parse(raw).data?.[root2]?.projectV2;
23650
- if (!project?.id) return void 0;
23651
- const field = project.field;
23652
- return {
23653
- id: project.id,
23654
- number,
23655
- title: project.title ?? String(number),
23656
- statusField: field?.id ? { id: field.id, options: field.options ?? [] } : void 0
23657
- };
23658
- }
23659
-
23660
- // src/commands/github/issue/fetchProjectV2.ts
23661
- function fetchProjectV2(owner, number) {
23662
- const project = readProject(owner, number, "organization") ?? readProject(owner, number, "user");
23663
- if (!project) {
23664
- throw new Error(`No project ${number} owned by ${owner} could be read`);
23665
- }
23666
- return project;
23667
- }
23668
-
23669
23902
  // src/commands/github/issue/resolveCreateIssueProject.ts
23670
23903
  function parseProjectNumber(value) {
23671
23904
  const number = Number(value);
@@ -23736,13 +23969,13 @@ async function reviewProposedIssue(title, body, metadata2 = []) {
23736
23969
  }
23737
23970
 
23738
23971
  // src/commands/github/issue/runGhIssueCreate.ts
23739
- import { execFileSync as execFileSync8 } from "child_process";
23972
+ import { execFileSync as execFileSync9 } from "child_process";
23740
23973
  function runGhIssueCreate(title, body, repo, labels) {
23741
23974
  const args = ["issue", "create", "--title", title, "--body", body];
23742
23975
  if (repo) args.push("--repo", repo);
23743
23976
  for (const label2 of labels ?? []) args.push("--label", label2);
23744
23977
  try {
23745
- return execFileSync8("gh", args, {
23978
+ return execFileSync9("gh", args, {
23746
23979
  encoding: "utf8",
23747
23980
  stdio: ["ignore", "pipe", "inherit"]
23748
23981
  });
@@ -23822,7 +24055,7 @@ function inWebSession() {
23822
24055
  }
23823
24056
 
23824
24057
  // src/commands/github/issue/fetchIssue.ts
23825
- import { execFileSync as execFileSync9 } from "child_process";
24058
+ import { execFileSync as execFileSync10 } from "child_process";
23826
24059
  function fetchIssue2(number, repo) {
23827
24060
  const args = [
23828
24061
  "issue",
@@ -23834,7 +24067,7 @@ function fetchIssue2(number, repo) {
23834
24067
  if (repo) args.push("--repo", repo);
23835
24068
  let raw;
23836
24069
  try {
23837
- raw = execFileSync9("gh", args, { encoding: "utf8" });
24070
+ raw = execFileSync10("gh", args, { encoding: "utf8" });
23838
24071
  } catch {
23839
24072
  console.error(`Could not fetch issue #${number} with gh issue view`);
23840
24073
  process.exit(1);
@@ -23925,12 +24158,12 @@ function prepareIssueEdit(number, repo, fresh) {
23925
24158
  }
23926
24159
 
23927
24160
  // src/commands/github/issue/pushIssueBody.ts
23928
- import { execFileSync as execFileSync10 } from "child_process";
24161
+ import { execFileSync as execFileSync11 } from "child_process";
23929
24162
  function pushIssueBody(number, repo, bodyPath) {
23930
24163
  const args = ["issue", "edit", String(number), "--body-file", bodyPath];
23931
24164
  if (repo) args.push("--repo", repo);
23932
24165
  try {
23933
- execFileSync10("gh", args, { stdio: "inherit" });
24166
+ execFileSync11("gh", args, { stdio: "inherit" });
23934
24167
  } catch {
23935
24168
  process.exit(1);
23936
24169
  }
@@ -23990,12 +24223,12 @@ function setIssueParent(number, repo, parentArg) {
23990
24223
  }
23991
24224
 
23992
24225
  // src/commands/github/issue/viewIssue.ts
23993
- import { execFileSync as execFileSync11 } from "child_process";
24226
+ import { execFileSync as execFileSync12 } from "child_process";
23994
24227
  function viewIssue(number, repo) {
23995
24228
  const args = ["issue", "view", String(number)];
23996
24229
  if (repo) args.push("--repo", repo);
23997
24230
  try {
23998
- execFileSync11("gh", args, { stdio: "inherit" });
24231
+ execFileSync12("gh", args, { stdio: "inherit" });
23999
24232
  } catch {
24000
24233
  process.exit(1);
24001
24234
  }
@@ -24051,7 +24284,7 @@ function registerEditIssue(issueCommand) {
24051
24284
  }
24052
24285
 
24053
24286
  // src/commands/github/issue/editIssueComment.ts
24054
- import { execFileSync as execFileSync12 } from "child_process";
24287
+ import { execFileSync as execFileSync13 } from "child_process";
24055
24288
  var USAGE4 = "Usage: assist github issue edit-comment <comment-id> --body <body> [-R <owner>/<repo>]";
24056
24289
  async function editIssueComment(commentIdArg, options2) {
24057
24290
  const commentId = Number.parseInt(commentIdArg, 10);
@@ -24078,7 +24311,7 @@ async function editIssueComment(commentIdArg, options2) {
24078
24311
  ];
24079
24312
  let raw;
24080
24313
  try {
24081
- raw = execFileSync12("gh", args, {
24314
+ raw = execFileSync13("gh", args, {
24082
24315
  input: JSON.stringify({ body }),
24083
24316
  encoding: "utf8"
24084
24317
  });
@@ -24116,25 +24349,6 @@ function registerEditIssueComment(issueCommand) {
24116
24349
  );
24117
24350
  }
24118
24351
 
24119
- // src/commands/github/issue/assignIssueToSelf.ts
24120
- import { execFileSync as execFileSync13 } from "child_process";
24121
- function assignIssueToSelf(number, repo) {
24122
- const args = [
24123
- "issue",
24124
- "edit",
24125
- String(number),
24126
- "--repo",
24127
- repo,
24128
- "--add-assignee",
24129
- "@me"
24130
- ];
24131
- try {
24132
- execFileSync13("gh", args, { stdio: ["ignore", "ignore", "inherit"] });
24133
- } catch {
24134
- process.exit(1);
24135
- }
24136
- }
24137
-
24138
24352
  // src/commands/github/issue/toIssueProjectItem.ts
24139
24353
  function toIssueProjectItem(node) {
24140
24354
  const project = node?.project;
@@ -24185,7 +24399,7 @@ function fetchIssueProjectItems(target) {
24185
24399
  }
24186
24400
 
24187
24401
  // src/commands/github/issue/moveIssueToInProgress.ts
24188
- var IN_PROGRESS = "in progress";
24402
+ var IN_PROGRESS2 = "in progress";
24189
24403
  function boardName(item) {
24190
24404
  return `project ${item.projectNumber} (${item.projectTitle})`;
24191
24405
  }
@@ -24196,7 +24410,7 @@ function moveItem(item) {
24196
24410
  return;
24197
24411
  }
24198
24412
  const option = statusField.options.find(
24199
- (candidate) => candidate.name.toLowerCase() === IN_PROGRESS
24413
+ (candidate) => candidate.name.toLowerCase() === IN_PROGRESS2
24200
24414
  );
24201
24415
  if (!option) {
24202
24416
  const names = statusField.options.map((candidate) => candidate.name);
@@ -24240,7 +24454,12 @@ function startIssue(numberArg, options2) {
24240
24454
  }
24241
24455
  const { owner, repo } = resolveIssueRepoTarget(options2.repo);
24242
24456
  const slug2 = `${owner}/${repo}`;
24243
- assignIssueToSelf(number, slug2);
24457
+ try {
24458
+ assignIssueToSelf(number, slug2);
24459
+ } catch (error) {
24460
+ console.error(error instanceof Error ? error.message : String(error));
24461
+ process.exit(1);
24462
+ }
24244
24463
  console.log(`Assigned ${slug2}#${number} to you`);
24245
24464
  moveIssueToInProgress({ owner, repo, number });
24246
24465
  }
@@ -29942,12 +30161,12 @@ import fs27 from "fs";
29942
30161
 
29943
30162
  // src/commands/lint/shared.ts
29944
30163
  import chalk202 from "chalk";
29945
- function reportViolations2(violations, checkName2, errorMessage3, successMessage) {
30164
+ function reportViolations2(violations, checkName2, errorMessage2, successMessage) {
29946
30165
  if (violations.length > 0) {
29947
30166
  console.error(chalk202.red(`
29948
30167
  ${checkName2} failed:
29949
30168
  `));
29950
- console.error(chalk202.red(` ${errorMessage3}
30169
+ console.error(chalk202.red(` ${errorMessage2}
29951
30170
  `));
29952
30171
  for (const violation of violations) {
29953
30172
  console.error(chalk202.red(` ${violation.filePath}:${violation.line}`));