spur-board 0.12.1 → 0.14.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/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { H as requiredSecretKeys, N as ERRORS, U as SLACK_BOT_SCOPES, V as configSchema, c as roleCanUseOperation, l as OPERATIONS, n as SYSTEMD_SERVICE_SETTINGS } from "./src-CYQZCwhN.mjs";
2
- import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-BOm8yksw.mjs";
3
- import { a as memoryVerdictCache, c as loadEnrollmentConfig, i as fileVerdictCache, l as readConfiguredPort, n as cliPackageVersion, o as configFile, s as loadClientConfig, t as checkCatalog, u as resolveDaemonAddress } from "./config-Dl7_gx5z.mjs";
1
+ import { H as requiredSecretKeys, N as ERRORS, U as SLACK_BOT_SCOPES, V as configSchema, c as roleCanUseOperation, l as OPERATIONS, n as SYSTEMD_SERVICE_SETTINGS } from "./src-Cbx6zcQN.mjs";
2
+ import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-DTod4bFs.mjs";
3
+ import { a as memoryVerdictCache, c as loadEnrollmentConfig, i as fileVerdictCache, l as readConfiguredPort, n as cliPackageVersion, o as configFile, s as loadClientConfig, t as checkCatalog, u as resolveDaemonAddress } from "./config-v4JtO52B.mjs";
4
4
  import { createHash, randomBytes, randomUUID } from "node:crypto";
5
5
  import { chmodSync, closeSync, constants, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
6
6
  import { homedir, hostname, userInfo } from "node:os";
@@ -1,4 +1,4 @@
1
- import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-CYQZCwhN.mjs";
1
+ import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-Cbx6zcQN.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
package/dist/client.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-BOm8yksw.mjs";
1
+ import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-DTod4bFs.mjs";
2
2
  export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
@@ -1,5 +1,5 @@
1
- import { L as DEFAULT_HTTP_PORT, V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-CYQZCwhN.mjs";
2
- import { i as CliError, t as fetchCatalogVersion } from "./client-BOm8yksw.mjs";
1
+ import { L as DEFAULT_HTTP_PORT, V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-Cbx6zcQN.mjs";
2
+ import { i as CliError, t as fetchCatalogVersion } from "./client-DTod4bFs.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as parseActorId, B as RESERVED_PROJECT, C as prFactsSchema, D as actorIdSchema, E as ticketFactsSchema, H as requiredSecretKeys, I as successEnvelopeSchema, M as taskKeySchema, N as ERRORS, O as encodeActorId, S as SESSION_STATUSES, T as sessionFactsSchema, U as SLACK_BOT_SCOPES, V as configSchema, _ as messageRefSchema, a as entityRefSchema, b as eventPayloadSchemas, c as roleCanUseOperation, g as interactionRefSchema, h as inboundEventSchema, i as batchSchema, j as parseRef$1, k as errorCodeOf, l as OPERATIONS, m as conversationRefSchema, o as sourceCursorSchema, p as SPACE_IDS, r as AdapterError, s as buildCatalogSnapshot, t as BOARD_TICK_MS, u as renderHttpProblem, v as userIdSchema, w as prRefSchema, x as SESSION_HEALTH_STATES, y as EVENT_KINDS, z as DEFAULT_SLACK_COMMAND } from "./src-CYQZCwhN.mjs";
1
+ import { A as parseActorId, B as RESERVED_PROJECT, C as prFactsSchema, D as actorIdSchema, E as ticketFactsSchema, H as requiredSecretKeys, I as successEnvelopeSchema, M as taskKeySchema, N as ERRORS, O as encodeActorId, S as SESSION_STATUSES, T as sessionFactsSchema, U as SLACK_BOT_SCOPES, V as configSchema, _ as messageRefSchema, a as entityRefSchema, b as eventPayloadSchemas, c as roleCanUseOperation, g as interactionRefSchema, h as inboundEventSchema, i as batchSchema, j as parseRef$1, k as errorCodeOf, l as OPERATIONS, m as conversationRefSchema, o as sourceCursorSchema, p as SPACE_IDS, r as AdapterError, s as buildCatalogSnapshot, t as BOARD_TICK_MS, u as renderHttpProblem, v as userIdSchema, w as prRefSchema, x as SESSION_HEALTH_STATES, y as EVENT_KINDS, z as DEFAULT_SLACK_COMMAND } from "./src-Cbx6zcQN.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { closeSync, existsSync, fstatSync, ftruncateSync, mkdirSync, openSync, readFileSync, readdirSync, writeSync } from "node:fs";
@@ -10736,18 +10736,44 @@ function sessionView(fact) {
10736
10736
  }))
10737
10737
  };
10738
10738
  }
10739
+ /** Counts of each value, rendered as `<n> <value>` in the given order. */
10740
+ function counts(values, order) {
10741
+ return order.map((value) => [value, values.filter((entry) => entry === value).length]).filter(([, n]) => n > 0).map(([value, n]) => `${String(n)} ${value}`).join(", ");
10742
+ }
10743
+ /** The one-line task state: ticket status, pull request states, session health counts. */
10744
+ function taskState(ticket, prs, sessions) {
10745
+ const parts = [ticket === null ? "ticket not observed" : `ticket ${ticket.status}`];
10746
+ if (prs.length > 0) {
10747
+ const labels = prs.map((pr) => pr.state === "open" && pr.draft ? "draft" : pr.state);
10748
+ parts.push(`PRs ${counts(labels, [
10749
+ "draft",
10750
+ "open",
10751
+ "merged",
10752
+ "closed"
10753
+ ])}`);
10754
+ }
10755
+ if (sessions.length > 0) {
10756
+ const health = sessions.map((session) => session.health);
10757
+ parts.push(`sessions ${counts(health, [...new Set(health)].sort())}`);
10758
+ }
10759
+ return parts.join("; ");
10760
+ }
10739
10761
  function interval(config, source) {
10740
10762
  if (source === "spur") return config.adapters.spur.intervalMs;
10741
10763
  if (source.startsWith("jira:")) return config.adapters.jira.intervalMs;
10742
10764
  return config.adapters.github.intervalMs;
10743
10765
  }
10744
10766
  /** Reads the board's latest facts, items and source availability. */
10745
- async function getStatus(deps, projectId, visibleProjects, includeBoardItems = visibleProjects === void 0) {
10767
+ async function getStatus(deps, options = {}) {
10746
10768
  const { store, config, clock, completeSince, gateways = [] } = deps;
10769
+ const { project: projectId, visibleProjects, detail = false } = options;
10770
+ const includeBoardItems = options.includeBoardItems ?? visibleProjects === void 0;
10747
10771
  const projects = projectId === void 0 ? config.projects.filter((project) => visibleProjects === void 0 || visibleProjects.has(project.id)) : config.projects.filter((project) => project.id === projectId && (visibleProjects === void 0 || visibleProjects.has(project.id)));
10748
10772
  if (projects.length === 0) throw new CommandError("not_found", "Check the project ID.");
10749
10773
  const projectIds = new Set(projects.map((project) => project.id));
10750
10774
  const rows = await store.db.selectFrom("task").selectAll().where("membership", "!=", "archived").execute();
10775
+ const blockRows = await store.db.selectFrom("block").select(["task_id", (eb) => eb.fn.countAll().as("open")]).where("state", "=", "open").groupBy("task_id").execute();
10776
+ const openBlocks = new Map(blockRows.map((row) => [row.task_id, row.open]));
10751
10777
  const tasks = [];
10752
10778
  for (const task of rows) {
10753
10779
  if (!projectIds.has(task.project)) continue;
@@ -10760,24 +10786,54 @@ async function getStatus(deps, projectId, visibleProjects, includeBoardItems = v
10760
10786
  if (snapshot !== void 0) prs.push(parseJson(prFactsSchema, snapshot.detail));
10761
10787
  } else if (link.entity === "session" && link.session_id !== null) {
10762
10788
  const snapshot = await store.db.selectFrom("session_snapshot").select("detail").where("id", "=", link.session_id).executeTakeFirst();
10763
- if (snapshot !== void 0) sessions.push(sessionView(parseJson(sessionFactsSchema, snapshot.detail)));
10789
+ if (snapshot !== void 0) sessions.push(parseJson(sessionFactsSchema, snapshot.detail));
10764
10790
  }
10791
+ const ticketFacts = ticket === void 0 ? null : parseJson(ticketFactsSchema, ticket.detail);
10765
10792
  tasks.push({
10766
10793
  key: task.key,
10767
10794
  project: task.project,
10768
10795
  column: task.column,
10769
10796
  membership: task.membership,
10770
- ticket: ticket === void 0 ? null : parseJson(ticketFactsSchema, ticket.detail),
10771
- prs,
10772
- sessions,
10773
- links: links.map(linkView)
10797
+ state: taskState(ticketFacts, prs, sessions),
10798
+ prCount: links.filter((link) => link.entity === "pr").length,
10799
+ sessionCount: links.filter((link) => link.entity === "session").length,
10800
+ openBlocks: openBlocks.get(task.id) ?? 0,
10801
+ ...detail ? {
10802
+ ticket: ticketFacts,
10803
+ prs,
10804
+ sessions: sessions.map(sessionView),
10805
+ links: links.map(linkView)
10806
+ } : {}
10774
10807
  });
10775
10808
  }
10776
10809
  const allPrs = await store.db.selectFrom("pr_snapshot").selectAll().execute();
10777
10810
  const allSessions = await store.db.selectFrom("session_snapshot").selectAll().execute();
10778
10811
  const allLinks = await store.db.selectFrom("link").selectAll().where("banned", "=", 0).execute();
10779
- const unlinkedPrs = allPrs.filter((pr) => projects.some((project) => project.repos.some((repo) => repo.toLowerCase() === pr.repo.toLowerCase())) && !allLinks.some((link) => link.entity === "pr" && link.repo?.toLowerCase() === pr.repo.toLowerCase() && link.number === pr.number)).map((pr) => parseJson(prFactsSchema, pr.detail));
10780
- const unlinkedSessions = allSessions.filter((session) => projects.some((project) => project.spurProjects.some((spur) => spur.name === session.spur_project)) && !allLinks.some((link) => link.entity === "session" && link.session_id === session.id)).map((session) => sessionView(parseJson(sessionFactsSchema, session.detail)));
10812
+ const unlinkedPrs = allPrs.filter((pr) => projects.some((project) => project.repos.some((repo) => repo.toLowerCase() === pr.repo.toLowerCase())) && !allLinks.some((link) => link.entity === "pr" && link.repo?.toLowerCase() === pr.repo.toLowerCase() && link.number === pr.number)).map((pr) => {
10813
+ const facts = parseJson(prFactsSchema, pr.detail);
10814
+ if (detail) return facts;
10815
+ const { repo, number, url, title, state, draft } = facts;
10816
+ return {
10817
+ repo,
10818
+ number,
10819
+ url,
10820
+ title,
10821
+ state,
10822
+ draft
10823
+ };
10824
+ });
10825
+ const unlinkedSessions = allSessions.filter((session) => projects.some((project) => project.spurProjects.some((spur) => spur.name === session.spur_project)) && !allLinks.some((link) => link.entity === "session" && link.session_id === session.id)).map((session) => {
10826
+ const facts = parseJson(sessionFactsSchema, session.detail);
10827
+ if (detail) return sessionView(facts);
10828
+ const { id, spurProject, branch, lifecycle, health } = facts;
10829
+ return {
10830
+ id,
10831
+ spurProject,
10832
+ branch,
10833
+ lifecycle,
10834
+ health
10835
+ };
10836
+ });
10781
10837
  const sourceRows = await store.db.selectFrom("source_state").selectAll().execute();
10782
10838
  const required = /* @__PURE__ */ new Set(["spur", ...projects.flatMap((project) => [trackerSource(project), ...project.repos.map((repo) => `github:${project.id}:${repo.toLowerCase()}`)])]);
10783
10839
  const sourceById = new Map(sourceRows.map((row) => [row.source, row]));
@@ -10834,15 +10890,15 @@ async function getStatus(deps, projectId, visibleProjects, includeBoardItems = v
10834
10890
  };
10835
10891
  });
10836
10892
  return {
10837
- tasks,
10838
10893
  items,
10839
- unlinkedPrs,
10840
- unlinkedSessions,
10841
- sources,
10842
10894
  warmingUp: sources.some((source) => source.warmingUp),
10843
10895
  spurUnavailable: spur?.blind_reason === null || spur === void 0 ? null : `Spur unavailable: ${spur.blind_message ?? spur.blind_reason}`,
10844
10896
  hostLoad: host?.value !== void 0 && host.value !== "null" ? "Host under load" : null,
10845
- transport
10897
+ transport,
10898
+ sources,
10899
+ tasks,
10900
+ unlinkedPrs,
10901
+ unlinkedSessions
10846
10902
  };
10847
10903
  }
10848
10904
  //#endregion
@@ -11086,10 +11142,15 @@ function createOperationRegistry(deps) {
11086
11142
  clock,
11087
11143
  completeSince,
11088
11144
  gateways
11089
- }, input.project, visibleProjects(config, actor), authorize([{ grant: "operator" }], actor, {
11090
- config,
11091
- target: { kind: "missing" }
11092
- }).status === "allowed");
11145
+ }, {
11146
+ project: input.project,
11147
+ visibleProjects: visibleProjects(config, actor),
11148
+ includeBoardItems: authorize([{ grant: "operator" }], actor, {
11149
+ config,
11150
+ target: { kind: "missing" }
11151
+ }).status === "allowed",
11152
+ detail: input.detail
11153
+ });
11093
11154
  }
11094
11155
  },
11095
11156
  "task.get": taskQueries.get,
@@ -13262,7 +13323,8 @@ function teamNameScopeDenied(error, query) {
13262
13323
  if (error.path !== void 0) return error.path.includes("reviewRequests") && error.path.includes("requestedReviewer") && error.path.at(-1) === "name";
13263
13324
  return /\bname\b/i.test(error.message) && /\bread:(?:org|discussion)\b/i.test(error.message);
13264
13325
  }
13265
- const prFields = (number) => `id number url title updatedAt state isDraft mergeable mergeStateStatus
13326
+ const CLOSING_FIELDS = "nodes { number repository { nameWithOwner } } pageInfo { hasNextPage endCursor }";
13327
+ const prFields = (number, closing = false) => `id number url title updatedAt state isDraft mergeable mergeStateStatus
13266
13328
  author { login } headRefName headRefOid
13267
13329
  statusCheckRollup { contexts(first: 100) { nodes {
13268
13330
  ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: ${String(number)}) }
@@ -13270,20 +13332,20 @@ const prFields = (number) => `id number url title updatedAt state isDraft mergea
13270
13332
  } pageInfo { hasNextPage endCursor } } }
13271
13333
  reviews(first: 100) { nodes { author { login } state commit { oid } submittedAt } pageInfo { hasNextPage endCursor } }
13272
13334
  reviewThreads(first: 100) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
13273
- reviewRequests(first: 100) { nodes { requestedReviewer { ... on User { login } ... on Team { name } } asCodeOwner } pageInfo { hasNextPage endCursor } }`;
13335
+ reviewRequests(first: 100) { nodes { requestedReviewer { ... on User { login } ... on Team { name } } asCodeOwner } pageInfo { hasNextPage endCursor } }${closing ? `\n closingIssuesReferences(first: 100) { ${CLOSING_FIELDS} }` : ""}`;
13274
13336
  const DISCOVERY_FIELDS = `nodes { number updatedAt author { login } state } pageInfo { hasNextPage endCursor }`;
13275
- function aliases(numbers) {
13276
- return numbers.map((number, i) => `pr${String(i)}: repository(owner: $owner, name: $repo) { pullRequest(number: ${String(number)}) { ${prFields(number)} } }`).join("\n");
13337
+ function aliases(numbers, closing = false) {
13338
+ return numbers.map((number, i) => `pr${String(i)}: repository(owner: $owner, name: $repo) { pullRequest(number: ${String(number)}) { ${prFields(number, closing)} } }`).join("\n");
13277
13339
  }
13278
- function initialQuery(numbers, bootstrap = false) {
13279
- return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${bootstrap ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} }${bootstrap ? " mergedBaseline: pullRequests(first: 1, states: [MERGED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { updatedAt } }" : ""} } ${aliases(numbers)} }`;
13340
+ function initialQuery(numbers, bootstrap = false, closing = false) {
13341
+ return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${bootstrap ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} }${bootstrap ? " mergedBaseline: pullRequests(first: 1, states: [MERGED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { updatedAt } }" : ""} } ${aliases(numbers, closing)} }`;
13280
13342
  }
13281
- function detailQuery(numbers) {
13282
- return `query PrDetails($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers)} }`;
13343
+ function detailQuery(numbers, closing = false) {
13344
+ return `query PrDetails($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers, closing)} }`;
13283
13345
  }
13284
13346
  function pageQuery(connection, bootstrap = false) {
13285
13347
  if (connection === "pullRequests") return `query DiscoveryPage($owner: String!, $repo: String!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, after: $after, states: [${bootstrap ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} } } }`;
13286
- return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { ${connection === "contexts" ? `statusCheckRollup { contexts(first: 100, after: $after) { nodes { ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: $number) } ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: $number) } } pageInfo { hasNextPage endCursor } } }` : `${connection}(first: 100, after: $after) { nodes { ${connection === "reviews" ? "author { login } state commit { oid } submittedAt" : connection === "reviewThreads" ? "isResolved" : "requestedReviewer { ... on User { login } ... on Team { name } } asCodeOwner"} } pageInfo { hasNextPage endCursor } }`} } } }`;
13348
+ return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { ${connection === "closingIssuesReferences" ? `closingIssuesReferences(first: 100, after: $after) { ${CLOSING_FIELDS} }` : connection === "contexts" ? `statusCheckRollup { contexts(first: 100, after: $after) { nodes { ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: $number) } ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: $number) } } pageInfo { hasNextPage endCursor } } }` : `${connection}(first: 100, after: $after) { nodes { ${connection === "reviews" ? "author { login } state commit { oid } submittedAt" : connection === "reviewThreads" ? "isResolved" : "requestedReviewer { ... on User { login } ... on Team { name } } asCodeOwner"} } pageInfo { hasNextPage endCursor } }`} } } }`;
13287
13349
  }
13288
13350
  var GithubClient = class {
13289
13351
  token;
@@ -13439,7 +13501,11 @@ const prWire = z.object({
13439
13501
  name: z.string().nullish()
13440
13502
  }),
13441
13503
  asCodeOwner: z.boolean()
13442
- }))
13504
+ })),
13505
+ closingIssuesReferences: z.object({ nodes: z.array(z.object({
13506
+ number: z.int().positive(),
13507
+ repository: z.object({ nameWithOwner: z.string() }).nullish()
13508
+ }).nullable()) }).nullish()
13443
13509
  });
13444
13510
  function checkState(node) {
13445
13511
  if (node.__typename === "StatusContext") {
@@ -13512,7 +13578,28 @@ function ticketKeys(title, branch, prefixes) {
13512
13578
  }
13513
13579
  return [...keys];
13514
13580
  }
13515
- function normalizePr(repo, value, prefixes) {
13581
+ const ISSUE_NUMBER = /^[1-9][0-9]{0,14}$/;
13582
+ const MAX_MATCHED_LENGTH = 255;
13583
+ function matchedNumber(text, pattern) {
13584
+ if (text.length > MAX_MATCHED_LENGTH) return void 0;
13585
+ const number = pattern.exec(text)?.[1];
13586
+ return number !== void 0 && ISSUE_NUMBER.test(number) ? Number(number) : void 0;
13587
+ }
13588
+ function issueKeys(title, branch, refs, rule) {
13589
+ const repo = rule.repo.toLowerCase();
13590
+ for (const source of rule.sources) {
13591
+ const numbers = /* @__PURE__ */ new Set();
13592
+ if (source === "closing") {
13593
+ for (const node of refs?.nodes ?? []) if (node?.repository?.nameWithOwner.toLowerCase() === repo && ISSUE_NUMBER.test(String(node.number))) numbers.add(node.number);
13594
+ } else {
13595
+ const number = source === "branch" ? matchedNumber(branch, rule.branch) : matchedNumber(title, rule.title);
13596
+ if (number !== void 0) numbers.add(number);
13597
+ }
13598
+ if (numbers.size > 0) return [...numbers].sort((a, b) => a - b).map((number) => `${rule.repo}#${String(number)}`);
13599
+ }
13600
+ return [];
13601
+ }
13602
+ function normalizePr(repo, value, rule) {
13516
13603
  const wire = parseWire(prWire, value, "Malformed GitHub PR response");
13517
13604
  const checks = latestChecks(wire.statusCheckRollup?.contexts.nodes ?? []);
13518
13605
  const state = wire.state === "MERGED" ? "merged" : wire.state === "CLOSED" ? "closed" : "open";
@@ -13548,7 +13635,7 @@ function normalizePr(repo, value, prefixes) {
13548
13635
  reviewer: node.requestedReviewer.login ?? node.requestedReviewer.name,
13549
13636
  asCodeOwner: node.asCodeOwner
13550
13637
  })),
13551
- ticketKeys: ticketKeys(title, headBranch, prefixes),
13638
+ ticketKeys: rule.type === "prefixes" ? ticketKeys(title, headBranch, rule.prefixes) : issueKeys(title, headBranch, wire.closingIssuesReferences, rule),
13552
13639
  updatedAt: wire.updatedAt
13553
13640
  };
13554
13641
  const parsed = prFactsSchema.safeParse(facts);
@@ -13565,7 +13652,8 @@ const prPagingWire = z.looseObject({
13565
13652
  reviews: pagingWire,
13566
13653
  reviewThreads: pagingWire,
13567
13654
  reviewRequests: pagingWire,
13568
- statusCheckRollup: z.object({ contexts: pagingWire }).nullish()
13655
+ statusCheckRollup: z.object({ contexts: pagingWire }).nullish(),
13656
+ closingIssuesReferences: pagingWire.nullish()
13569
13657
  });
13570
13658
  const aliasWire = z.object({ pullRequest: prPagingWire.nullish() }).nullish();
13571
13659
  const pageRootWire = z.object({ pullRequest: prPagingWire.partial() });
@@ -13575,6 +13663,18 @@ function sourceId(project, repo) {
13575
13663
  function githubSources(config, options) {
13576
13664
  const sources = [];
13577
13665
  for (const project of config.projects) {
13666
+ const tracker = project.tracker;
13667
+ const issues = tracker.type === "github-issues" ? {
13668
+ type: "issues",
13669
+ repo: tracker.repo,
13670
+ sources: project.link.sources,
13671
+ branch: new RegExp(project.link.branchPattern),
13672
+ title: new RegExp(project.link.titlePattern)
13673
+ } : void 0;
13674
+ const prefixes = {
13675
+ type: "prefixes",
13676
+ prefixes: tracker.type === "jira" ? tracker.projectKeys : []
13677
+ };
13578
13678
  const seen = /* @__PURE__ */ new Set();
13579
13679
  for (const repo of project.repos) {
13580
13680
  const normalized = repo.toLowerCase();
@@ -13582,7 +13682,7 @@ function githubSources(config, options) {
13582
13682
  seen.add(normalized);
13583
13683
  const id = sourceId(project.id, repo);
13584
13684
  const client = new GithubClient(options.token, options.fetch);
13585
- const prefixes = project.tracker.type === "jira" ? project.tracker.projectKeys : [];
13685
+ const keys = issues?.repo.toLowerCase() === normalized ? issues : prefixes;
13586
13686
  sources.push({
13587
13687
  repo,
13588
13688
  reserveRemaining: config.github.reserveRemaining,
@@ -13593,7 +13693,7 @@ function githubSources(config, options) {
13593
13693
  id,
13594
13694
  repo,
13595
13695
  login: project.operatorGithubLogin,
13596
- prefixes,
13696
+ keys,
13597
13697
  client,
13598
13698
  ctx
13599
13699
  })
@@ -13619,7 +13719,13 @@ function status(error) {
13619
13719
  return error.type === "NOT_FOUND" ? "not_found" : "no_access";
13620
13720
  }
13621
13721
  function connectionOf(pr, field) {
13622
- return field === "contexts" ? pr.statusCheckRollup?.contexts : pr[field];
13722
+ return (field === "contexts" ? pr.statusCheckRollup?.contexts : pr[field]) ?? void 0;
13723
+ }
13724
+ function deniedReference(error) {
13725
+ return (error.type === "FORBIDDEN" || error.type === "NOT_FOUND") && error.path?.includes("closingIssuesReferences") === true;
13726
+ }
13727
+ function withoutDeniedReferences(errors) {
13728
+ return errors.filter((error) => !deniedReference(error));
13623
13729
  }
13624
13730
  function withConnection(pr, field, connection) {
13625
13731
  return field === "contexts" ? {
@@ -13639,7 +13745,8 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
13639
13745
  "reviews",
13640
13746
  "reviewThreads",
13641
13747
  "reviewRequests",
13642
- "contexts"
13748
+ "contexts",
13749
+ "closingIssuesReferences"
13643
13750
  ]) {
13644
13751
  let target = connectionOf(pr, field);
13645
13752
  if (target === void 0) continue;
@@ -13657,8 +13764,10 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
13657
13764
  budget(response.budget);
13658
13765
  rejectUnscoped(response.errors, ["repository"]);
13659
13766
  requireCheckAccess(response.errors);
13660
- if (response.errors.length > 0) return void 0;
13767
+ const denied = response.errors.some(deniedReference);
13768
+ if (withoutDeniedReferences(response.errors).length > 0) return void 0;
13661
13769
  const page = connectionOf(parseWire(pageRootWire, response.data.repository, MALFORMED$1, ["data", "repository"]).pullRequest, field);
13770
+ if (page === void 0 && denied && field === "closingIssuesReferences") break;
13662
13771
  if (page === void 0) throw new AdapterError("transient", "Malformed GitHub pagination");
13663
13772
  target = {
13664
13773
  nodes: [...target.nodes, ...page.nodes],
@@ -13670,7 +13779,7 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
13670
13779
  }
13671
13780
  return pr;
13672
13781
  }
13673
- async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13782
+ async function pollRepository({ id, repo, login, keys, client, ctx }) {
13674
13783
  const observedAt = sourceCursorSchema.parse((/* @__PURE__ */ new Date()).toISOString());
13675
13784
  const bootstrap = ctx.cursor === void 0;
13676
13785
  const [owner, name] = repo.split("/");
@@ -13678,7 +13787,8 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13678
13787
  const requested = ctx.observe.prs.filter((ref) => ref.repo.toLowerCase() === repo.toLowerCase());
13679
13788
  const byNumber = new Map(requested.map((ref) => [ref.number, ref]));
13680
13789
  const numbers = [...byNumber.keys()];
13681
- const response = await client.query(initialQuery(numbers, bootstrap), {
13790
+ const closing = keys.type === "issues" && keys.sources.includes("closing");
13791
+ const response = await client.query(initialQuery(numbers, bootstrap, closing), {
13682
13792
  owner,
13683
13793
  repo: name
13684
13794
  }, ctx.signal);
@@ -13714,7 +13824,8 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13714
13824
  if (!discoveryOk) complete = false;
13715
13825
  const found = discover(nodes, ctx.cursor, login);
13716
13826
  const bootstrapCursor = bootstrap && discoveryOk ? latestUpdatedAt(parseWire(baselineRootWire, response.data.repository, MALFORMED$1, ["data", "repository"]).mergedBaseline.nodes, found.cursor) ?? sourceCursorSchema.parse("1970-01-01T00:00:00.000Z") : void 0;
13717
- const process = async (number, alias, data, errors, ref) => {
13827
+ const process = async (number, alias, data, scopedErrors, ref) => {
13828
+ const errors = withoutDeniedReferences(scopedErrors);
13718
13829
  requireCheckAccess(errors);
13719
13830
  const error = errors[0];
13720
13831
  if (error !== void 0) {
@@ -13746,7 +13857,7 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13746
13857
  });
13747
13858
  return false;
13748
13859
  }
13749
- const facts = normalizePr(ref?.repo ?? repo, full, prefixes);
13860
+ const facts = normalizePr(ref?.repo ?? repo, full, keys);
13750
13861
  items.push({
13751
13862
  kind: "pr",
13752
13863
  facts
@@ -13766,7 +13877,7 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13766
13877
  const discovered = found.numbers.filter((number) => !byNumber.has(number));
13767
13878
  for (let offset = 0; offset < discovered.length; offset += 50) {
13768
13879
  const chunk = discovered.slice(offset, offset + 50);
13769
- const detail = await client.query(detailQuery(chunk), {
13880
+ const detail = await client.query(detailQuery(chunk, closing), {
13770
13881
  owner,
13771
13882
  repo: name
13772
13883
  }, ctx.signal);
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-CYQZCwhN.mjs";
2
- import { i as CliError, n as requestOperation } from "./client-BOm8yksw.mjs";
3
- import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-Dl7_gx5z.mjs";
1
+ import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-Cbx6zcQN.mjs";
2
+ import { i as CliError, n as requestOperation } from "./client-DTod4bFs.mjs";
3
+ import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-v4JtO52B.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -80,7 +80,7 @@ const SESSION_LINK_ROLES = [
80
80
  "other",
81
81
  "orchestrator"
82
82
  ];
83
- const LINK_SOURCES = [
83
+ const LINK_SOURCES$1 = [
84
84
  "spawn_link",
85
85
  "branch",
86
86
  "manual"
@@ -158,6 +158,30 @@ const jiraTracker = z.strictObject({
158
158
  readyStatuses: z.array(nonEmpty).min(1),
159
159
  projectKeys: z.array(z.string().regex(/^[A-Z][A-Z0-9_]*$/, "Expected a Jira project key like PROJ")).default([])
160
160
  });
161
+ /** Capture groups of a pattern that compiles without flags, or `undefined` when it does not. */
162
+ function captureGroups(pattern) {
163
+ try {
164
+ new RegExp(pattern);
165
+ return (new RegExp(`(?:${pattern})|`).exec("")?.length ?? 1) - 1;
166
+ } catch {
167
+ return;
168
+ }
169
+ }
170
+ /** Where a PR in the tracker repository can name its issue, in the default priority order. */
171
+ const LINK_SOURCES = [
172
+ "closing",
173
+ "branch",
174
+ "title"
175
+ ];
176
+ /** A `link` pattern: compiles, starts with `^` and has exactly one capture group. */
177
+ function linkPattern(fallback, description) {
178
+ return nonEmpty.superRefine((pattern, ctx) => {
179
+ if (!pattern.startsWith("^") || captureGroups(pattern) !== 1) ctx.addIssue({
180
+ code: "custom",
181
+ message: "Expected a regular expression that starts with ^ and has exactly one capture group"
182
+ });
183
+ }).default(fallback).describe(description);
184
+ }
161
185
  const githubIssuesTracker = z.strictObject({
162
186
  type: z.literal("github-issues"),
163
187
  repo: repoSlugSchema,
@@ -213,6 +237,19 @@ const projectSchema = z.strictObject({
213
237
  }).regex(/^[a-z][a-z0-9-]*$/, "Expected lowercase letters, digits and dashes"),
214
238
  tracker: z.discriminatedUnion("type", [jiraTracker, githubIssuesTracker]),
215
239
  repos: z.array(repoSlugSchema).min(1),
240
+ link: z.strictObject({
241
+ sources: z.array(z.enum(LINK_SOURCES)).min(1).superRefine((sources, ctx) => {
242
+ sources.forEach((source, i) => {
243
+ if (sources.indexOf(source) !== i) ctx.addIssue({
244
+ code: "custom",
245
+ path: [i],
246
+ message: `Duplicate link source: ${JSON.stringify(source)}`
247
+ });
248
+ });
249
+ }).default([...LINK_SOURCES]).describe("Where a PR in tracker.repo names its issue, in priority order; the first source that yields an issue number wins. closing: issues in tracker.repo the PR closes (Closes #12 in the body, or linked in the sidebar), for PRs to the default branch only. branch: branchPattern on the head branch. title: titlePattern on the PR title."),
250
+ branchPattern: linkPattern("^[A-Za-z]+-([1-9][0-9]*)", "Regular expression that starts with ^ and whose one capture group reads the issue number from a PR head branch, such as <agent>-<number>-<slug>. Branches longer than 255 characters are not matched."),
251
+ titlePattern: linkPattern("^[a-z]+(?:\\([^)]*\\))?!?: #([1-9][0-9]*)", "Regular expression that starts with ^ and whose one capture group reads the issue number from a PR title, such as fix(core): #12 summary. Titles longer than 255 characters are not matched.")
252
+ }).prefault({}).describe("How a github-issues project links a PR in tracker.repo to its issue. A Jira project ignores it and links by tracker.projectKeys."),
216
253
  operatorGithubLogin: z.string().regex(/^[A-Za-z0-9-]{1,39}$/, "Expected a GitHub login"),
217
254
  spurProjects: z.array(spurProject).superRefine((items, ctx) => {
218
255
  rejectDuplicates(items, "name", "spur project name", ctx);
@@ -990,7 +1027,7 @@ const eventPayloadSchemas = {
990
1027
  entity: z.literal("session"),
991
1028
  session: S,
992
1029
  role: z.enum(SESSION_LINK_ROLES),
993
- source: z.enum(LINK_SOURCES),
1030
+ source: z.enum(LINK_SOURCES$1),
994
1031
  facts: sessionFactsSchema.optional(),
995
1032
  reason: S.optional()
996
1033
  }),
@@ -999,14 +1036,14 @@ const eventPayloadSchemas = {
999
1036
  repo: S,
1000
1037
  pr: N,
1001
1038
  state: z.enum(PR_LINK_STATES),
1002
- source: z.enum(LINK_SOURCES),
1039
+ source: z.enum(LINK_SOURCES$1),
1003
1040
  facts: prFactsSchema.optional(),
1004
1041
  reason: S.optional()
1005
1042
  }),
1006
1043
  z.looseObject({
1007
1044
  entity: z.literal("ticket"),
1008
1045
  ticket: S,
1009
- source: z.enum(LINK_SOURCES),
1046
+ source: z.enum(LINK_SOURCES$1),
1010
1047
  reason: S.optional()
1011
1048
  })
1012
1049
  ]),
@@ -1485,12 +1522,40 @@ const linkViewSchema = z.strictObject({
1485
1522
  "orchestrator"
1486
1523
  ]).nullable().describe("Session role; null for a pull request or ticket.")
1487
1524
  }).describe("An effective link to a task.");
1525
+ const detailOnly = "Present only with detail.";
1526
+ const count = (what) => z.int().min(0).describe(what);
1488
1527
  const statusTaskSchema = taskViewSchema.extend({
1489
- ticket: ticketFactsSchema.nullable().describe("Latest ticket facts, or null before observation."),
1490
- prs: z.array(prFactsSchema).describe("Latest facts for linked pull requests."),
1491
- sessions: z.array(statusSessionFactsSchema).describe("Latest facts for linked sessions."),
1492
- links: z.array(linkViewSchema).describe("Effective pull request, session, and ticket links.")
1493
- }).describe("A board task with its latest observed facts and links.");
1528
+ state: z.string().min(1).describe("One line: ticket status, pull request states and session health counts, joined by \"; \"."),
1529
+ prCount: count("Number of effective pull request links."),
1530
+ sessionCount: count("Number of effective session links."),
1531
+ openBlocks: count("Number of open blocks on the task."),
1532
+ ticket: ticketFactsSchema.nullable().optional().describe(`Latest ticket facts, or null before observation. ${detailOnly}`),
1533
+ prs: z.array(prFactsSchema).optional().describe(`Latest facts for linked pull requests. ${detailOnly}`),
1534
+ sessions: z.array(statusSessionFactsSchema).optional().describe(`Latest facts for linked sessions. ${detailOnly}`),
1535
+ links: z.array(linkViewSchema).optional().describe(`Effective pull request, session, and ticket links. ${detailOnly}`)
1536
+ }).describe("A board task with a one-line state and counts; detail adds its facts and links.");
1537
+ const statusUnlinkedPrSchema = prFactsSchema.partial({
1538
+ author: true,
1539
+ headSha: true,
1540
+ headBranch: true,
1541
+ mergeable: true,
1542
+ mergeState: true,
1543
+ requiredChecks: true,
1544
+ checks: true,
1545
+ reviews: true,
1546
+ reviewThreads: true,
1547
+ reviewRequests: true,
1548
+ ticketKeys: true,
1549
+ updatedAt: true
1550
+ }).describe("A pull request without a task link; fields beyond its identity need detail.");
1551
+ const statusUnlinkedSessionSchema = statusSessionFactsSchema.partial({
1552
+ pr: true,
1553
+ links: true,
1554
+ healthSince: true,
1555
+ lastActivityAt: true,
1556
+ endedAt: true,
1557
+ endReason: true
1558
+ }).describe("A session without a task link; fields beyond its identity need detail.");
1494
1559
  const statusItemSchema = itemViewSchema.extend({
1495
1560
  key: z.string().min(1).describe("Stable key of this actionable item."),
1496
1561
  unconfirmed: z.boolean().describe("Whether a supporting fact is stale or its source is blind."),
@@ -1651,18 +1716,17 @@ const OPERATIONS = [
1651
1716
  defineOperation({
1652
1717
  id: "status.get",
1653
1718
  kind: "query",
1654
- description: "List tasks, observations, source freshness and actionable items.",
1719
+ description: "List actionable items, source freshness and compact tasks; detail adds full facts and links.",
1655
1720
  mcp: {
1656
- whenToUse: "Get a board overview.",
1721
+ whenToUse: "Get a board overview; pass detail for full ticket, pull request and session facts.",
1657
1722
  whenNotToUse: "Use task_get for one task."
1658
1723
  },
1659
- input: z.strictObject({ project }),
1724
+ input: z.strictObject({
1725
+ project,
1726
+ detail: z.boolean().optional().describe("Include full ticket, pull request and session facts and links; absent means compact rows.")
1727
+ }),
1660
1728
  output: z.strictObject({
1661
- tasks: z.array(statusTaskSchema).describe("Tasks on the board with facts and links."),
1662
1729
  items: z.array(statusItemSchema).describe("Actionable items in priority order."),
1663
- unlinkedPrs: z.array(prFactsSchema).describe("Observed pull requests without a task link."),
1664
- unlinkedSessions: z.array(statusSessionFactsSchema).describe("Observed sessions without a task link."),
1665
- sources: z.array(sourceViewSchema).describe("Freshness and availability of each source."),
1666
1730
  warmingUp: z.boolean().describe("Whether required sources still need a complete poll."),
1667
1731
  spurUnavailable: z.string().nullable().describe("One combined Spur availability line, or null when available."),
1668
1732
  hostLoad: z.string().nullable().describe("Host-load episode line, or null when absent."),
@@ -1672,7 +1736,11 @@ const OPERATIONS = [
1672
1736
  since: z.iso.datetime().nullable().describe("When the earliest outage started, ISO 8601 UTC, or null when up."),
1673
1737
  reason: z.string().nullable().describe("Reason of the earliest outage, or null when up."),
1674
1738
  spaces: z.array(z.enum(SPACE_IDS)).describe("Spaces whose delivery is suspended.")
1675
- }).describe("Transport health of one gateway.")).describe("Transport health of each chat gateway.")
1739
+ }).describe("Transport health of one gateway.")).describe("Transport health of each chat gateway."),
1740
+ sources: z.array(sourceViewSchema).describe("Freshness and availability of each source."),
1741
+ tasks: z.array(statusTaskSchema).describe("Tasks on the board with state and counts; facts and links with detail."),
1742
+ unlinkedPrs: z.array(statusUnlinkedPrSchema).describe("Observed pull requests without a task link."),
1743
+ unlinkedSessions: z.array(statusUnlinkedSessionSchema).describe("Observed sessions without a task link.")
1676
1744
  }),
1677
1745
  grants: operatorOrProjectAgent,
1678
1746
  errors: ["not_found"],
@@ -1688,21 +1756,45 @@ const OPERATIONS = [
1688
1756
  summary: "Show the board",
1689
1757
  input: {},
1690
1758
  output: {
1759
+ items: [],
1760
+ warmingUp: true,
1761
+ spurUnavailable: null,
1762
+ hostLoad: null,
1763
+ transport: [],
1764
+ sources: [],
1691
1765
  tasks: [{
1692
1766
  ...task,
1767
+ state: "ticket not observed",
1768
+ prCount: 0,
1769
+ sessionCount: 0,
1770
+ openBlocks: 0
1771
+ }],
1772
+ unlinkedPrs: [],
1773
+ unlinkedSessions: []
1774
+ }
1775
+ }, {
1776
+ summary: "Show the board with full facts and links",
1777
+ input: { detail: true },
1778
+ output: {
1779
+ items: [],
1780
+ warmingUp: false,
1781
+ spurUnavailable: null,
1782
+ hostLoad: null,
1783
+ transport: [],
1784
+ sources: [],
1785
+ tasks: [{
1786
+ ...task,
1787
+ state: "ticket not observed",
1788
+ prCount: 0,
1789
+ sessionCount: 0,
1790
+ openBlocks: 0,
1693
1791
  ticket: null,
1694
1792
  prs: [],
1695
1793
  sessions: [],
1696
1794
  links: []
1697
1795
  }],
1698
- items: [],
1699
1796
  unlinkedPrs: [],
1700
- unlinkedSessions: [],
1701
- sources: [],
1702
- warmingUp: true,
1703
- spurUnavailable: null,
1704
- hostLoad: null,
1705
- transport: []
1797
+ unlinkedSessions: []
1706
1798
  }
1707
1799
  }]
1708
1800
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.12.1",
3
+ "version": "0.14.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -22,10 +22,10 @@ Every command can return the common errors below. Each entry lists its other cod
22
22
 
23
23
  ### `board status`
24
24
 
25
- Purpose: List tasks, observations, source freshness and actionable items.
25
+ Purpose: List actionable items, source freshness and compact tasks; detail adds full facts and links.
26
26
  Arguments: none.
27
- Flags: `--project <value>`, `--json`.
28
- Use when: Get a board overview.
27
+ Flags: `--project <value>`, `--detail`, `--json`.
28
+ Use when: Get a board overview; pass detail for full ticket, pull request and session facts.
29
29
  Avoid when: Use `board task <task>` for one task.
30
30
  Example: `board status` — Show the board.
31
31
  Other errors: `not_found`.