spur-board 0.13.0 → 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-B0lbg34-.mjs";
2
- import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-CAcEf5xs.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-Cd5oLu2h.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-B0lbg34-.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-CAcEf5xs.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-B0lbg34-.mjs";
2
- import { i as CliError, t as fetchCatalogVersion } from "./client-CAcEf5xs.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-B0lbg34-.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";
@@ -13323,7 +13323,8 @@ function teamNameScopeDenied(error, query) {
13323
13323
  if (error.path !== void 0) return error.path.includes("reviewRequests") && error.path.includes("requestedReviewer") && error.path.at(-1) === "name";
13324
13324
  return /\bname\b/i.test(error.message) && /\bread:(?:org|discussion)\b/i.test(error.message);
13325
13325
  }
13326
- 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
13327
13328
  author { login } headRefName headRefOid
13328
13329
  statusCheckRollup { contexts(first: 100) { nodes {
13329
13330
  ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: ${String(number)}) }
@@ -13331,20 +13332,20 @@ const prFields = (number) => `id number url title updatedAt state isDraft mergea
13331
13332
  } pageInfo { hasNextPage endCursor } } }
13332
13333
  reviews(first: 100) { nodes { author { login } state commit { oid } submittedAt } pageInfo { hasNextPage endCursor } }
13333
13334
  reviewThreads(first: 100) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
13334
- 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} }` : ""}`;
13335
13336
  const DISCOVERY_FIELDS = `nodes { number updatedAt author { login } state } pageInfo { hasNextPage endCursor }`;
13336
- function aliases(numbers) {
13337
- 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");
13338
13339
  }
13339
- function initialQuery(numbers, bootstrap = false) {
13340
- 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)} }`;
13341
13342
  }
13342
- function detailQuery(numbers) {
13343
- 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)} }`;
13344
13345
  }
13345
13346
  function pageQuery(connection, bootstrap = false) {
13346
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} } } }`;
13347
- 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 } }`} } } }`;
13348
13349
  }
13349
13350
  var GithubClient = class {
13350
13351
  token;
@@ -13500,7 +13501,11 @@ const prWire = z.object({
13500
13501
  name: z.string().nullish()
13501
13502
  }),
13502
13503
  asCodeOwner: z.boolean()
13503
- }))
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()
13504
13509
  });
13505
13510
  function checkState(node) {
13506
13511
  if (node.__typename === "StatusContext") {
@@ -13573,7 +13578,28 @@ function ticketKeys(title, branch, prefixes) {
13573
13578
  }
13574
13579
  return [...keys];
13575
13580
  }
13576
- 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) {
13577
13603
  const wire = parseWire(prWire, value, "Malformed GitHub PR response");
13578
13604
  const checks = latestChecks(wire.statusCheckRollup?.contexts.nodes ?? []);
13579
13605
  const state = wire.state === "MERGED" ? "merged" : wire.state === "CLOSED" ? "closed" : "open";
@@ -13609,7 +13635,7 @@ function normalizePr(repo, value, prefixes) {
13609
13635
  reviewer: node.requestedReviewer.login ?? node.requestedReviewer.name,
13610
13636
  asCodeOwner: node.asCodeOwner
13611
13637
  })),
13612
- ticketKeys: ticketKeys(title, headBranch, prefixes),
13638
+ ticketKeys: rule.type === "prefixes" ? ticketKeys(title, headBranch, rule.prefixes) : issueKeys(title, headBranch, wire.closingIssuesReferences, rule),
13613
13639
  updatedAt: wire.updatedAt
13614
13640
  };
13615
13641
  const parsed = prFactsSchema.safeParse(facts);
@@ -13626,7 +13652,8 @@ const prPagingWire = z.looseObject({
13626
13652
  reviews: pagingWire,
13627
13653
  reviewThreads: pagingWire,
13628
13654
  reviewRequests: pagingWire,
13629
- statusCheckRollup: z.object({ contexts: pagingWire }).nullish()
13655
+ statusCheckRollup: z.object({ contexts: pagingWire }).nullish(),
13656
+ closingIssuesReferences: pagingWire.nullish()
13630
13657
  });
13631
13658
  const aliasWire = z.object({ pullRequest: prPagingWire.nullish() }).nullish();
13632
13659
  const pageRootWire = z.object({ pullRequest: prPagingWire.partial() });
@@ -13636,6 +13663,18 @@ function sourceId(project, repo) {
13636
13663
  function githubSources(config, options) {
13637
13664
  const sources = [];
13638
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
+ };
13639
13678
  const seen = /* @__PURE__ */ new Set();
13640
13679
  for (const repo of project.repos) {
13641
13680
  const normalized = repo.toLowerCase();
@@ -13643,7 +13682,7 @@ function githubSources(config, options) {
13643
13682
  seen.add(normalized);
13644
13683
  const id = sourceId(project.id, repo);
13645
13684
  const client = new GithubClient(options.token, options.fetch);
13646
- const prefixes = project.tracker.type === "jira" ? project.tracker.projectKeys : [];
13685
+ const keys = issues?.repo.toLowerCase() === normalized ? issues : prefixes;
13647
13686
  sources.push({
13648
13687
  repo,
13649
13688
  reserveRemaining: config.github.reserveRemaining,
@@ -13654,7 +13693,7 @@ function githubSources(config, options) {
13654
13693
  id,
13655
13694
  repo,
13656
13695
  login: project.operatorGithubLogin,
13657
- prefixes,
13696
+ keys,
13658
13697
  client,
13659
13698
  ctx
13660
13699
  })
@@ -13680,7 +13719,13 @@ function status(error) {
13680
13719
  return error.type === "NOT_FOUND" ? "not_found" : "no_access";
13681
13720
  }
13682
13721
  function connectionOf(pr, field) {
13683
- 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));
13684
13729
  }
13685
13730
  function withConnection(pr, field, connection) {
13686
13731
  return field === "contexts" ? {
@@ -13700,7 +13745,8 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
13700
13745
  "reviews",
13701
13746
  "reviewThreads",
13702
13747
  "reviewRequests",
13703
- "contexts"
13748
+ "contexts",
13749
+ "closingIssuesReferences"
13704
13750
  ]) {
13705
13751
  let target = connectionOf(pr, field);
13706
13752
  if (target === void 0) continue;
@@ -13718,8 +13764,10 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
13718
13764
  budget(response.budget);
13719
13765
  rejectUnscoped(response.errors, ["repository"]);
13720
13766
  requireCheckAccess(response.errors);
13721
- 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;
13722
13769
  const page = connectionOf(parseWire(pageRootWire, response.data.repository, MALFORMED$1, ["data", "repository"]).pullRequest, field);
13770
+ if (page === void 0 && denied && field === "closingIssuesReferences") break;
13723
13771
  if (page === void 0) throw new AdapterError("transient", "Malformed GitHub pagination");
13724
13772
  target = {
13725
13773
  nodes: [...target.nodes, ...page.nodes],
@@ -13731,7 +13779,7 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
13731
13779
  }
13732
13780
  return pr;
13733
13781
  }
13734
- async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13782
+ async function pollRepository({ id, repo, login, keys, client, ctx }) {
13735
13783
  const observedAt = sourceCursorSchema.parse((/* @__PURE__ */ new Date()).toISOString());
13736
13784
  const bootstrap = ctx.cursor === void 0;
13737
13785
  const [owner, name] = repo.split("/");
@@ -13739,7 +13787,8 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13739
13787
  const requested = ctx.observe.prs.filter((ref) => ref.repo.toLowerCase() === repo.toLowerCase());
13740
13788
  const byNumber = new Map(requested.map((ref) => [ref.number, ref]));
13741
13789
  const numbers = [...byNumber.keys()];
13742
- 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), {
13743
13792
  owner,
13744
13793
  repo: name
13745
13794
  }, ctx.signal);
@@ -13775,7 +13824,8 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13775
13824
  if (!discoveryOk) complete = false;
13776
13825
  const found = discover(nodes, ctx.cursor, login);
13777
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;
13778
- const process = async (number, alias, data, errors, ref) => {
13827
+ const process = async (number, alias, data, scopedErrors, ref) => {
13828
+ const errors = withoutDeniedReferences(scopedErrors);
13779
13829
  requireCheckAccess(errors);
13780
13830
  const error = errors[0];
13781
13831
  if (error !== void 0) {
@@ -13807,7 +13857,7 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13807
13857
  });
13808
13858
  return false;
13809
13859
  }
13810
- const facts = normalizePr(ref?.repo ?? repo, full, prefixes);
13860
+ const facts = normalizePr(ref?.repo ?? repo, full, keys);
13811
13861
  items.push({
13812
13862
  kind: "pr",
13813
13863
  facts
@@ -13827,7 +13877,7 @@ async function pollRepository({ id, repo, login, prefixes, client, ctx }) {
13827
13877
  const discovered = found.numbers.filter((number) => !byNumber.has(number));
13828
13878
  for (let offset = 0; offset < discovered.length; offset += 50) {
13829
13879
  const chunk = discovered.slice(offset, offset + 50);
13830
- const detail = await client.query(detailQuery(chunk), {
13880
+ const detail = await client.query(detailQuery(chunk, closing), {
13831
13881
  owner,
13832
13882
  repo: name
13833
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-B0lbg34-.mjs";
2
- import { i as CliError, n as requestOperation } from "./client-CAcEf5xs.mjs";
3
- import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-Cd5oLu2h.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
  ]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"