spur-board 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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-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";
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-eVAzSAsk.mjs";
2
+ import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-FoFGbc11.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-6Nm4MFGe.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";
@@ -302,6 +302,7 @@ const remoteBaseIds = [
302
302
  "secrets",
303
303
  "jira.credentials",
304
304
  "github.credentials",
305
+ "link.rules",
305
306
  "spur.api",
306
307
  "spur.send",
307
308
  "operator.path"
@@ -404,8 +405,10 @@ async function runDoctor(options = {}) {
404
405
  const latestInstall = Math.max(...stamps.flatMap((entry) => entry === null ? [] : [entry.installedAt]));
405
406
  const stale = sessions.filter((session) => session.startAt !== void 0 && session.startAt < latestInstall);
406
407
  const unknownStarts = sessions.some((session) => session.startAt === void 0);
407
- const staleIds = stale.map((session) => session.id).filter((id) => /^[a-zA-Z0-9_-]+$/.test(id)).slice(0, 10);
408
- checks.push(stale.length > 0 || unknownStarts ? warning("sessions.stale", `Restart sessions started before the last skill install${staleIds.length ? `: ${staleIds.join(", ")}` : ""}; verify sessions whose start time is unavailable.`) : result("sessions.stale", true, "Restart older sessions."));
408
+ const staleSessions = [...new Set(stale.map((session) => session.id))];
409
+ const staleIds = staleSessions.filter((id) => /^[a-zA-Z0-9_-]+$/.test(id)).slice(0, 10);
410
+ const staleCount = staleSessions.length === 0 ? "sessions" : `${String(staleSessions.length)} session${staleSessions.length === 1 ? "" : "s"}`;
411
+ checks.push(stale.length > 0 || unknownStarts ? warning("sessions.stale", `Restart ${staleCount} started before the last skill install${staleIds.length ? `: ${staleIds.join(", ")}` : ""}; verify sessions whose start time is unavailable.`) : result("sessions.stale", true, "Restart older sessions."));
409
412
  const portFix = await checkHttpPort(config.http.port, {
410
413
  bind: ports.bind,
411
414
  run: (command, args) => Promise.resolve(ports.run(command, args))
@@ -478,7 +481,6 @@ function renderUserUnit(paths) {
478
481
  "[Service]",
479
482
  `ExecStart=${unitArgument(paths.nodePath)} ${unitArgument(paths.daemonEntry)}`,
480
483
  ...(paths.environment ?? []).map((entry) => `Environment=${unitArgument(entry)}`),
481
- `EnvironmentFile=${unitArgument(paths.secretsFile)}`,
482
484
  ...SYSTEMD_SERVICE_SETTINGS,
483
485
  "",
484
486
  "[Install]",
@@ -1,4 +1,4 @@
1
- import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-Cbx6zcQN.mjs";
1
+ import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-eVAzSAsk.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-DTod4bFs.mjs";
1
+ import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-FoFGbc11.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-Cbx6zcQN.mjs";
2
- import { i as CliError, t as fetchCatalogVersion } from "./client-DTod4bFs.mjs";
1
+ import { L as DEFAULT_HTTP_PORT, V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-eVAzSAsk.mjs";
2
+ import { i as CliError, t as fetchCatalogVersion } from "./client-FoFGbc11.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-Cbx6zcQN.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-eVAzSAsk.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";
@@ -7665,6 +7665,10 @@ async function scanTransaction(store, fn) {
7665
7665
  function trackerSource(project) {
7666
7666
  return project.tracker.type === "jira" ? `jira:${project.id}` : `github-issues:${project.id}:${project.tracker.repo.toLowerCase()}`;
7667
7667
  }
7668
+ /** The project whose tracker or repo source wrote an observation. */
7669
+ function projectForSource(config, source) {
7670
+ return config.projects.find((project) => source === trackerSource(project) || project.repos.some((repo) => source === `github:${project.id}:${repo.toLowerCase()}`));
7671
+ }
7668
7672
  function projectForKey(config, key) {
7669
7673
  const lowerKey = key.toLowerCase();
7670
7674
  const matched = config.projects.filter((project) => {
@@ -10758,6 +10762,10 @@ function taskState(ticket, prs, sessions) {
10758
10762
  }
10759
10763
  return parts.join("; ");
10760
10764
  }
10765
+ /** The tracker repo of a GitHub Issues project, lowercased; null for Jira or no project. */
10766
+ function issuesRepo(project) {
10767
+ return project?.tracker.type === "github-issues" ? project.tracker.repo.toLowerCase() : null;
10768
+ }
10761
10769
  function interval(config, source) {
10762
10770
  if (source === "spur") return config.adapters.spur.intervalMs;
10763
10771
  if (source.startsWith("jira:")) return config.adapters.jira.intervalMs;
@@ -10778,7 +10786,8 @@ async function getStatus(deps, options = {}) {
10778
10786
  for (const task of rows) {
10779
10787
  if (!projectIds.has(task.project)) continue;
10780
10788
  const ticket = await store.db.selectFrom("ticket_snapshot").selectAll().where("task_id", "=", task.id).executeTakeFirst();
10781
- const links = await store.db.selectFrom("link").selectAll().where("task_id", "=", task.id).where("banned", "=", 0).execute();
10789
+ const taskLinks = await store.db.selectFrom("link").selectAll().where("task_id", "=", task.id).execute();
10790
+ const links = taskLinks.filter((link) => link.banned === 0);
10782
10791
  const prs = [];
10783
10792
  const sessions = [];
10784
10793
  for (const link of links) if (link.entity === "pr" && link.repo !== null && link.number !== null) {
@@ -10789,6 +10798,17 @@ async function getStatus(deps, options = {}) {
10789
10798
  if (snapshot !== void 0) sessions.push(parseJson(sessionFactsSchema, snapshot.detail));
10790
10799
  }
10791
10800
  const ticketFacts = ticket === void 0 ? null : parseJson(ticketFactsSchema, ticket.detail);
10801
+ const trackerRepo = issuesRepo(config.projects.find((entry) => entry.id === task.project));
10802
+ const linkHints = [];
10803
+ for (const session of sessions) {
10804
+ const pr = session.pr;
10805
+ if (trackerRepo === null || pr === null || pr.repo.toLowerCase() !== trackerRepo) continue;
10806
+ if (taskLinks.some((link) => link.entity === "pr" && link.repo?.toLowerCase() === trackerRepo && link.number === pr.number)) continue;
10807
+ const snapshot = await store.db.selectFrom("pr_snapshot").select("detail").where(sql`lower(repo) = ${trackerRepo}`).where("number", "=", pr.number).executeTakeFirst();
10808
+ if (snapshot === void 0) continue;
10809
+ if (parseJson(prFactsSchema, snapshot.detail).ticketKeys.some((key) => key.toLowerCase() === task.key.toLowerCase())) continue;
10810
+ linkHints.push(`Session ${session.id} has PR ${pr.repo}#${String(pr.number)}, but the link rules give it no link to this task; check projects[].link in config.yaml.`);
10811
+ }
10792
10812
  tasks.push({
10793
10813
  key: task.key,
10794
10814
  project: task.project,
@@ -10798,6 +10818,7 @@ async function getStatus(deps, options = {}) {
10798
10818
  prCount: links.filter((link) => link.entity === "pr").length,
10799
10819
  sessionCount: links.filter((link) => link.entity === "session").length,
10800
10820
  openBlocks: openBlocks.get(task.id) ?? 0,
10821
+ ...linkHints.length > 0 ? { linkHints } : {},
10801
10822
  ...detail ? {
10802
10823
  ticket: ticketFacts,
10803
10824
  prs,
@@ -10809,9 +10830,24 @@ async function getStatus(deps, options = {}) {
10809
10830
  const allPrs = await store.db.selectFrom("pr_snapshot").selectAll().execute();
10810
10831
  const allSessions = await store.db.selectFrom("session_snapshot").selectAll().execute();
10811
10832
  const allLinks = await store.db.selectFrom("link").selectAll().where("banned", "=", 0).execute();
10833
+ const bannedPrLinks = await store.db.selectFrom("link").select(["repo", "number"]).where("entity", "=", "pr").where("banned", "=", 1).execute();
10834
+ /** Why the link rules left an open tracker-repo PR unlinked, or undefined. */
10835
+ const unlinkedReason = (source, facts) => {
10836
+ if (facts.state !== "open") return void 0;
10837
+ const project = projectForSource(config, source);
10838
+ if (project === void 0 || issuesRepo(project) !== facts.repo.toLowerCase()) return void 0;
10839
+ if (bannedPrLinks.some((link) => link.repo?.toLowerCase() === facts.repo.toLowerCase() && link.number === facts.number)) return void 0;
10840
+ if (facts.ticketKeys.length === 0) return "no key in branch or title by the link rules";
10841
+ return facts.ticketKeys.some((key) => rows.some((task) => task.project === project.id && task.key === key)) ? void 0 : `no task on the board for ${facts.ticketKeys.join(", ")}`;
10842
+ };
10812
10843
  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
10844
  const facts = parseJson(prFactsSchema, pr.detail);
10814
- if (detail) return facts;
10845
+ const reason = unlinkedReason(pr.source, facts);
10846
+ const why = reason === void 0 ? {} : { reason };
10847
+ if (detail) return {
10848
+ ...facts,
10849
+ ...why
10850
+ };
10815
10851
  const { repo, number, url, title, state, draft } = facts;
10816
10852
  return {
10817
10853
  repo,
@@ -10819,7 +10855,8 @@ async function getStatus(deps, options = {}) {
10819
10855
  url,
10820
10856
  title,
10821
10857
  state,
10822
- draft
10858
+ draft,
10859
+ ...why
10823
10860
  };
10824
10861
  });
10825
10862
  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) => {
@@ -11524,9 +11561,6 @@ function refKey(ref) {
11524
11561
  case "session": return `session:${ref.id}`;
11525
11562
  }
11526
11563
  }
11527
- function projectForSource(config, source) {
11528
- return config.projects.find((project) => source === trackerSource(project) || project.repos.some((repo) => source === `github:${project.id}:${repo.toLowerCase()}`));
11529
- }
11530
11564
  /** A closed issue of a GitHub Issues tracker, which lists only open issues. */
11531
11565
  function closedIssue(project, status) {
11532
11566
  return project.tracker.type === "github-issues" && status === "closed";
@@ -13294,12 +13328,15 @@ function retryAt(headers, now) {
13294
13328
  }
13295
13329
  //#endregion
13296
13330
  //#region ../adapters/src/github/client.ts
13297
- const MALFORMED$2 = "Malformed GitHub response";
13331
+ const MALFORMED$3 = "Malformed GitHub response";
13298
13332
  const graphErrorWire = z.object({
13299
13333
  message: z.string(),
13300
13334
  path: z.array(z.union([z.string(), z.number()])).optional(),
13301
13335
  type: z.string().optional()
13302
13336
  });
13337
+ function deniedReference(error) {
13338
+ return (error.type === "FORBIDDEN" || error.type === "NOT_FOUND") && error.path?.includes("closingIssuesReferences") === true;
13339
+ }
13303
13340
  const envelopeWire = z.object({
13304
13341
  errors: z.array(graphErrorWire).optional(),
13305
13342
  data: z.unknown()
@@ -13383,9 +13420,9 @@ var GithubClient = class {
13383
13420
  try {
13384
13421
  body = await response.json();
13385
13422
  } catch (cause) {
13386
- throw new AdapterError("transient", MALFORMED$2, { cause });
13423
+ throw new AdapterError("transient", MALFORMED$3, { cause });
13387
13424
  }
13388
- const wire = parseWire(envelopeWire, body, MALFORMED$2);
13425
+ const wire = parseWire(envelopeWire, body, MALFORMED$3);
13389
13426
  const errors = wire.errors ?? [];
13390
13427
  if (errors.some((error) => error.type === "RATE_LIMITED" || /rate limit/i.test(error.message))) throw classifyHttpFailure({
13391
13428
  status: 429,
@@ -13393,7 +13430,7 @@ var GithubClient = class {
13393
13430
  }, Date.now());
13394
13431
  if (errors.some((error) => teamNameScopeDenied(error, query))) throw new AdapterError("auth", "GitHub token needs read:org for team review requests");
13395
13432
  if (errors.some((error) => error.type === "INSUFFICIENT_SCOPES")) throw new AdapterError("auth", "GitHub token lacks a required GraphQL read scope");
13396
- const data = parseWire(dataWire, wire.data, MALFORMED$2, ["data"]);
13433
+ const data = parseWire(dataWire, wire.data, MALFORMED$3, ["data"]);
13397
13434
  return {
13398
13435
  data,
13399
13436
  errors,
@@ -13480,6 +13517,10 @@ const reviewWire = z.object({
13480
13517
  submittedAt: z.string().nullish()
13481
13518
  }).refine((review) => review.commit !== null || !review.author?.login || review.submittedAt == null || !KEPT_REVIEWS.includes(review.state.toLowerCase()), { path: ["commit"] });
13482
13519
  const nodes = (node) => z.object({ nodes: z.array(node) });
13520
+ const closingWire = z.object({ nodes: z.array(z.object({
13521
+ number: z.int().positive(),
13522
+ repository: z.object({ nameWithOwner: z.string() }).nullish()
13523
+ }).nullable()) }).nullish();
13483
13524
  const prWire = z.object({
13484
13525
  number: z.number(),
13485
13526
  url: z.string(),
@@ -13502,11 +13543,25 @@ const prWire = z.object({
13502
13543
  }),
13503
13544
  asCodeOwner: z.boolean()
13504
13545
  })),
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()
13546
+ closingIssuesReferences: closingWire
13509
13547
  });
13548
+ /** The key rule of a github-issues project's tracker repo, built from `projects[].link`. */
13549
+ function issuesRule(repo, link) {
13550
+ return {
13551
+ type: "issues",
13552
+ repo,
13553
+ sources: link.sources,
13554
+ branch: new RegExp(link.branchPattern),
13555
+ title: new RegExp(link.titlePattern)
13556
+ };
13557
+ }
13558
+ /** Drops denied (null) nodes and nodes without a repository. */
13559
+ function closingRefs(wire) {
13560
+ return (wire?.nodes ?? []).flatMap((node) => node?.repository ? [{
13561
+ repo: node.repository.nameWithOwner,
13562
+ number: node.number
13563
+ }] : []);
13564
+ }
13510
13565
  function checkState(node) {
13511
13566
  if (node.__typename === "StatusContext") {
13512
13567
  const state = node.state.toLowerCase();
@@ -13590,7 +13645,7 @@ function issueKeys(title, branch, refs, rule) {
13590
13645
  for (const source of rule.sources) {
13591
13646
  const numbers = /* @__PURE__ */ new Set();
13592
13647
  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);
13648
+ for (const ref of refs) if (ref.repo.toLowerCase() === repo && ISSUE_NUMBER.test(String(ref.number))) numbers.add(ref.number);
13594
13649
  } else {
13595
13650
  const number = source === "branch" ? matchedNumber(branch, rule.branch) : matchedNumber(title, rule.title);
13596
13651
  if (number !== void 0) numbers.add(number);
@@ -13635,7 +13690,7 @@ function normalizePr(repo, value, rule) {
13635
13690
  reviewer: node.requestedReviewer.login ?? node.requestedReviewer.name,
13636
13691
  asCodeOwner: node.asCodeOwner
13637
13692
  })),
13638
- ticketKeys: rule.type === "prefixes" ? ticketKeys(title, headBranch, rule.prefixes) : issueKeys(title, headBranch, wire.closingIssuesReferences, rule),
13693
+ ticketKeys: rule.type === "prefixes" ? ticketKeys(title, headBranch, rule.prefixes) : issueKeys(title, headBranch, closingRefs(wire.closingIssuesReferences), rule),
13639
13694
  updatedAt: wire.updatedAt
13640
13695
  };
13641
13696
  const parsed = prFactsSchema.safeParse(facts);
@@ -13644,7 +13699,7 @@ function normalizePr(repo, value, rule) {
13644
13699
  }
13645
13700
  //#endregion
13646
13701
  //#region ../adapters/src/github/index.ts
13647
- const MALFORMED$1 = "Malformed GitHub response";
13702
+ const MALFORMED$2 = "Malformed GitHub response";
13648
13703
  const discoveryRootWire = z.object({ pullRequests: connectionWire(discoveryNodeWire) });
13649
13704
  const baselineRootWire = z.object({ mergedBaseline: z.object({ nodes: z.array(baselineNodeWire) }) });
13650
13705
  const pagingWire = connectionWire(z.unknown());
@@ -13664,13 +13719,7 @@ function githubSources(config, options) {
13664
13719
  const sources = [];
13665
13720
  for (const project of config.projects) {
13666
13721
  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;
13722
+ const issues = tracker.type === "github-issues" ? issuesRule(tracker.repo, project.link) : void 0;
13674
13723
  const prefixes = {
13675
13724
  type: "prefixes",
13676
13725
  prefixes: tracker.type === "jira" ? tracker.projectKeys : []
@@ -13721,9 +13770,6 @@ function status(error) {
13721
13770
  function connectionOf(pr, field) {
13722
13771
  return (field === "contexts" ? pr.statusCheckRollup?.contexts : pr[field]) ?? void 0;
13723
13772
  }
13724
- function deniedReference(error) {
13725
- return (error.type === "FORBIDDEN" || error.type === "NOT_FOUND") && error.path?.includes("closingIssuesReferences") === true;
13726
- }
13727
13773
  function withoutDeniedReferences(errors) {
13728
13774
  return errors.filter((error) => !deniedReference(error));
13729
13775
  }
@@ -13766,7 +13812,7 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
13766
13812
  requireCheckAccess(response.errors);
13767
13813
  const denied = response.errors.some(deniedReference);
13768
13814
  if (withoutDeniedReferences(response.errors).length > 0) return void 0;
13769
- const page = connectionOf(parseWire(pageRootWire, response.data.repository, MALFORMED$1, ["data", "repository"]).pullRequest, field);
13815
+ const page = connectionOf(parseWire(pageRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequest, field);
13770
13816
  if (page === void 0 && denied && field === "closingIssuesReferences") break;
13771
13817
  if (page === void 0) throw new AdapterError("transient", "Malformed GitHub pagination");
13772
13818
  target = {
@@ -13799,7 +13845,7 @@ async function pollRepository({ id, repo, login, keys, client, ctx }) {
13799
13845
  const entities = [];
13800
13846
  const items = [];
13801
13847
  let discoveryOk = scoped(response.errors, "repository").length === 0;
13802
- const first = discoveryOk ? parseWire(discoveryRootWire, response.data.repository, MALFORMED$1, ["data", "repository"]).pullRequests : void 0;
13848
+ const first = discoveryOk ? parseWire(discoveryRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequests : void 0;
13803
13849
  const nodes = first === void 0 ? [] : [...first.nodes];
13804
13850
  let cursor = first === void 0 || pastCursor(nodes, ctx.cursor) ? void 0 : nextPage(first);
13805
13851
  const seenPages = /* @__PURE__ */ new Set();
@@ -13817,13 +13863,13 @@ async function pollRepository({ id, repo, login, keys, client, ctx }) {
13817
13863
  discoveryOk = false;
13818
13864
  break;
13819
13865
  }
13820
- const connection = parseWire(discoveryRootWire, page.data.repository, MALFORMED$1, ["data", "repository"]).pullRequests;
13866
+ const connection = parseWire(discoveryRootWire, page.data.repository, MALFORMED$2, ["data", "repository"]).pullRequests;
13821
13867
  nodes.push(...connection.nodes);
13822
13868
  cursor = pastCursor(connection.nodes, ctx.cursor) ? void 0 : nextPage(connection);
13823
13869
  }
13824
13870
  if (!discoveryOk) complete = false;
13825
13871
  const found = discover(nodes, ctx.cursor, login);
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;
13872
+ const bootstrapCursor = bootstrap && discoveryOk ? latestUpdatedAt(parseWire(baselineRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).mergedBaseline.nodes, found.cursor) ?? sourceCursorSchema.parse("1970-01-01T00:00:00.000Z") : void 0;
13827
13873
  const process = async (number, alias, data, scopedErrors, ref) => {
13828
13874
  const errors = withoutDeniedReferences(scopedErrors);
13829
13875
  requireCheckAccess(errors);
@@ -13837,7 +13883,7 @@ async function pollRepository({ id, repo, login, keys, client, ctx }) {
13837
13883
  });
13838
13884
  return false;
13839
13885
  }
13840
- const wire = parseWire(aliasWire, data[alias], MALFORMED$1, ["data", alias])?.pullRequest;
13886
+ const wire = parseWire(aliasWire, data[alias], MALFORMED$2, ["data", alias])?.pullRequest;
13841
13887
  if (wire === null || wire === void 0) {
13842
13888
  if (ref) entities.push({
13843
13889
  ref,
@@ -13909,7 +13955,7 @@ var GithubIssuesHttpError = class extends AdapterError {
13909
13955
  this.status = status;
13910
13956
  }
13911
13957
  };
13912
- const MALFORMED = "Malformed GitHub issue response";
13958
+ const MALFORMED$1 = "Malformed GitHub issue response";
13913
13959
  const text$2 = z.string().min(1);
13914
13960
  const issueWire$1 = z.object({
13915
13961
  node_id: text$2,
@@ -13933,7 +13979,7 @@ function issueNumber(ref, repo) {
13933
13979
  const match = /^(.+)#([1-9]\d*)$/.exec(ref.key);
13934
13980
  if (match?.[1]?.toLowerCase() !== repo.toLowerCase()) throw new AdapterError("config", "Requested issue is outside its configured repository");
13935
13981
  const value = Number(match[2]);
13936
- if (!Number.isSafeInteger(value) || value <= 0) throw new AdapterError("transient", MALFORMED);
13982
+ if (!Number.isSafeInteger(value) || value <= 0) throw new AdapterError("transient", MALFORMED$1);
13937
13983
  return value;
13938
13984
  }
13939
13985
  function normalize(issue, trackerId, repo, inFilter) {
@@ -14011,7 +14057,7 @@ function createGithubIssuesAdapter(options) {
14011
14057
  if (pageUrl.pathname === base.pathname + "/milestones") return;
14012
14058
  const match = /^\/repositories\/([1-9]\d*)\/(?:issues|milestones)$/.exec(pageUrl.pathname);
14013
14059
  if (match === null) throw new AdapterError("transient", PAGINATION);
14014
- repositoryId ??= parseWire(repositoryWire, (await request(root, signal)).value, MALFORMED).id;
14060
+ repositoryId ??= parseWire(repositoryWire, (await request(root, signal)).value, MALFORMED$1).id;
14015
14061
  if (Number(match[1]) !== repositoryId) {
14016
14062
  repositoryId = void 0;
14017
14063
  throw new AdapterError("transient", PAGINATION);
@@ -14060,7 +14106,7 @@ function createGithubIssuesAdapter(options) {
14060
14106
  if (error instanceof GithubIssuesHttpError && error.status === 404) throw new AdapterError("config", "GitHub Issues repository is unavailable");
14061
14107
  throw error;
14062
14108
  }
14063
- const match = parseWire(z.array(milestoneWire), milestones, MALFORMED).find((entry) => entry.title === options.tracker.milestone);
14109
+ const match = parseWire(z.array(milestoneWire), milestones, MALFORMED$1).find((entry) => entry.title === options.tracker.milestone);
14064
14110
  if (match === void 0) throw new AdapterError("config", "Configured GitHub milestone is missing");
14065
14111
  return match.number;
14066
14112
  }
@@ -14088,7 +14134,7 @@ function createGithubIssuesAdapter(options) {
14088
14134
  }
14089
14135
  const facts = /* @__PURE__ */ new Map();
14090
14136
  for (const value of listed) {
14091
- const issue = parseWire(issueWire$1, value, MALFORMED);
14137
+ const issue = parseWire(issueWire$1, value, MALFORMED$1);
14092
14138
  if (issue.pull_request !== void 0) continue;
14093
14139
  facts.set(issue.number, normalize(issue, options.id, options.tracker.repo, true));
14094
14140
  }
@@ -14098,7 +14144,7 @@ function createGithubIssuesAdapter(options) {
14098
14144
  const issueNo = issueNumber(ref, options.tracker.repo);
14099
14145
  let fact = facts.get(issueNo);
14100
14146
  if (fact === void 0) try {
14101
- const detail = parseWire(issueWire$1, (await request(`${root}/issues/${String(issueNo)}`, ctx.signal)).value, MALFORMED);
14147
+ const detail = parseWire(issueWire$1, (await request(`${root}/issues/${String(issueNo)}`, ctx.signal)).value, MALFORMED$1);
14102
14148
  if (detail.pull_request !== void 0) {
14103
14149
  entities.push({
14104
14150
  ref,
@@ -15006,6 +15052,49 @@ function createSpurAdapter(options) {
15006
15052
  };
15007
15053
  }
15008
15054
  //#endregion
15055
+ //#region ../adapters/src/github/linkSample.ts
15056
+ const MALFORMED = "Malformed GitHub response";
15057
+ /** PRs read per sample; the operator's PRs among them are matched. */
15058
+ const SCANNED = 50;
15059
+ /** Operator PRs matched per sample. */
15060
+ const SAMPLED = 10;
15061
+ const sampleRootWire = z.object({ pullRequests: z.object({ nodes: z.array(z.object({
15062
+ number: z.int().positive(),
15063
+ title: z.string(),
15064
+ headRefName: z.string(),
15065
+ author: z.object({ login: z.string().optional() }).nullish(),
15066
+ closingIssuesReferences: closingWire
15067
+ })) }) });
15068
+ function sampleQuery(closing) {
15069
+ return `query LinkSample($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: ${String(SCANNED)}, states: [OPEN, MERGED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { number title headRefName author { login }${closing ? " closingIssuesReferences(first: 100) { nodes { number repository { nameWithOwner } } }" : ""} } } } }`;
15070
+ }
15071
+ /**
15072
+ * Matches up to 10 of the operator's most recently updated open or merged PRs in `repo` (among
15073
+ * the last 50) against `link`. A denied closing reference is dropped, as the poller does; any
15074
+ * other GraphQL error rejects with a transient `AdapterError`.
15075
+ */
15076
+ async function sampleLinkRules({ repo, login, link }, { token, fetch: fetcher, signal }) {
15077
+ const [owner, name] = repo.split("/");
15078
+ if (!owner || !name) throw new AdapterError("config", "Invalid repository");
15079
+ const closing = link.sources.includes("closing");
15080
+ const response = await new GithubClient(token, fetcher).query(sampleQuery(closing), {
15081
+ owner,
15082
+ repo: name
15083
+ }, signal);
15084
+ if (response.errors.some((error) => !deniedReference(error))) throw new AdapterError("transient", "GitHub link sample failed");
15085
+ const root = parseWire(sampleRootWire, response.data["repository"], MALFORMED, ["data", "repository"]);
15086
+ const rule = issuesRule(repo, link);
15087
+ const operator = login.toLowerCase();
15088
+ const sampled = root.pullRequests.nodes.filter((pr) => pr.author?.login?.toLowerCase() === operator).slice(0, SAMPLED);
15089
+ return {
15090
+ sampled: sampled.length,
15091
+ unmatched: sampled.filter((pr) => issueKeys(pr.title, pr.headRefName, closingRefs(pr.closingIssuesReferences), rule).length === 0).map((pr) => ({
15092
+ number: pr.number,
15093
+ branch: pr.headRefName
15094
+ }))
15095
+ };
15096
+ }
15097
+ //#endregion
15009
15098
  //#region ../adapters/src/index.ts
15010
15099
  function blindSource(id, intervalMs, message) {
15011
15100
  return {
@@ -16261,45 +16350,22 @@ function scopedGithubError(value) {
16261
16350
  if (error?.["type"] === "INSUFFICIENT_SCOPES" && fields.includes("reviewRequests") && fields.includes("requestedReviewer") && fields.includes("name")) return GITHUB_TEAMS_FIX;
16262
16351
  return null;
16263
16352
  }
16264
- async function githubGraphql(ctx, fetcher, token, repo) {
16265
- const [owner, name] = repo.split("/");
16266
- if (!owner || !name) return null;
16353
+ async function deadlineCall(ctx, name, failure, call) {
16267
16354
  const controller = new AbortController();
16268
16355
  const deadline = setTimeout(() => {
16269
16356
  controller.abort();
16270
16357
  }, TIMEOUT_MS);
16271
16358
  const aborted = new Promise((_resolve, reject) => {
16272
16359
  controller.signal.addEventListener("abort", () => {
16273
- reject(/* @__PURE__ */ new Error("GitHub doctor probe timed out"));
16360
+ reject(/* @__PURE__ */ new Error(`${failure}: timed out`));
16274
16361
  }, { once: true });
16275
16362
  });
16276
16363
  try {
16277
- return await ctx.logCall("doctor.github", async () => {
16364
+ return await ctx.logCall(name, async () => {
16278
16365
  try {
16279
- return await Promise.race([(async () => {
16280
- const response = await fetcher("https://api.github.com/graphql", {
16281
- method: "POST",
16282
- headers: {
16283
- Authorization: `Bearer ${token}`,
16284
- Accept: "application/vnd.github+json",
16285
- "Content-Type": "application/json"
16286
- },
16287
- body: JSON.stringify({
16288
- query: GITHUB_PROBE,
16289
- variables: {
16290
- owner,
16291
- repo: name
16292
- }
16293
- }),
16294
- signal: controller.signal
16295
- });
16296
- return {
16297
- response,
16298
- body: response.ok ? await response.json() : null
16299
- };
16300
- })(), aborted]);
16366
+ return await Promise.race([call(controller.signal), aborted]);
16301
16367
  } catch {
16302
- throw new Error("GitHub doctor probe failed");
16368
+ throw new Error(failure);
16303
16369
  }
16304
16370
  });
16305
16371
  } catch {
@@ -16308,6 +16374,127 @@ async function githubGraphql(ctx, fetcher, token, repo) {
16308
16374
  clearTimeout(deadline);
16309
16375
  }
16310
16376
  }
16377
+ async function githubGraphql(ctx, fetcher, token, repo) {
16378
+ const [owner, name] = repo.split("/");
16379
+ if (!owner || !name) return null;
16380
+ return deadlineCall(ctx, "doctor.github", "GitHub doctor probe failed", async (signal) => {
16381
+ const response = await fetcher("https://api.github.com/graphql", {
16382
+ method: "POST",
16383
+ headers: {
16384
+ Authorization: `Bearer ${token}`,
16385
+ Accept: "application/vnd.github+json",
16386
+ "Content-Type": "application/json"
16387
+ },
16388
+ body: JSON.stringify({
16389
+ query: GITHUB_PROBE,
16390
+ variables: {
16391
+ owner,
16392
+ repo: name
16393
+ }
16394
+ }),
16395
+ signal
16396
+ });
16397
+ return {
16398
+ response,
16399
+ body: response.ok ? await response.json() : null
16400
+ };
16401
+ });
16402
+ }
16403
+ const FIX_MAX = 300;
16404
+ const BRANCH_MAX = 40;
16405
+ const NAMED_PRS = 3;
16406
+ const LINK_RULES_TAIL = "Change projects[].link to the repo's branch and PR title rules.";
16407
+ const LINK_RULES_TOKEN_FIX = "Add GITHUB_TOKEN to secrets.env, then rerun board doctor to compare projects[].link with recent PRs.";
16408
+ function sampleProject(ctx, fetcher, token, project, repo) {
16409
+ return deadlineCall(ctx, "doctor.link_rules", "GitHub link sample failed", (signal) => sampleLinkRules({
16410
+ repo,
16411
+ login: project.operatorGithubLogin,
16412
+ link: project.link
16413
+ }, {
16414
+ token,
16415
+ fetch: fetcher,
16416
+ signal
16417
+ }));
16418
+ }
16419
+ function sampleLinks(ctx, fetcher, token) {
16420
+ const projects = ctx.config.projects.flatMap((project) => project.tracker.type === "github-issues" ? [{
16421
+ project,
16422
+ repo: project.tracker.repo
16423
+ }] : []);
16424
+ if (projects.length === 0 || token === void 0) return null;
16425
+ return Promise.all(projects.map(async ({ project, repo }) => {
16426
+ const polled = project.repos.some((entry) => entry.toLowerCase() === repo.toLowerCase());
16427
+ return polled ? {
16428
+ project,
16429
+ repo,
16430
+ polled,
16431
+ sample: await sampleProject(ctx, fetcher, token, project, repo)
16432
+ } : {
16433
+ project,
16434
+ repo,
16435
+ polled
16436
+ };
16437
+ }));
16438
+ }
16439
+ function branchText(branch) {
16440
+ const clean = branch.replace(/[\u0000-\u001f\u007f-\u009f`]/g, "");
16441
+ return clean.length > BRANCH_MAX ? `${clean.slice(0, BRANCH_MAX)}...` : clean;
16442
+ }
16443
+ function linkSegment(outcome) {
16444
+ const { project, repo } = outcome;
16445
+ const fixed = (text) => ({
16446
+ problem: true,
16447
+ unmatched: false,
16448
+ text: () => `${project.id}: ${text}`
16449
+ });
16450
+ if (!outcome.polled) return fixed(`${repo} is not in projects[].repos, so its PRs are not polled`);
16451
+ const { sample } = outcome;
16452
+ if (sample === null) return fixed(`could not read PRs in ${repo}`);
16453
+ if (sample.sampled === 0) return fixed(`skipped: no PRs by ${project.operatorGithubLogin} in ${repo}`);
16454
+ const count = `${project.id}: link rules match ${String(sample.sampled - sample.unmatched.length)} of the last ${String(sample.sampled)} PRs in ${repo}`;
16455
+ if (sample.unmatched.length === 0) return {
16456
+ problem: false,
16457
+ unmatched: false,
16458
+ text: () => count
16459
+ };
16460
+ const more = sample.unmatched.length - NAMED_PRS;
16461
+ return {
16462
+ problem: true,
16463
+ unmatched: true,
16464
+ text: (branches) => `${count}; not matched: ${sample.unmatched.slice(0, NAMED_PRS).map((pr) => `#${String(pr.number)}${branches ? ` \`${branchText(pr.branch)}\`` : ""}`).join(", ")}${more > 0 ? ` and ${String(more)} more` : ""}`
16465
+ };
16466
+ }
16467
+ function fitFix(segments, tail, fallback) {
16468
+ for (const branches of [true, false]) {
16469
+ const full = `${segments.map((segment) => segment.text(branches)).join(". ")}.${tail}`;
16470
+ if (full.length <= FIX_MAX) return full;
16471
+ }
16472
+ const texts = segments.map((segment) => segment.text(false));
16473
+ for (let kept = texts.length - 1; kept > 0; kept -= 1) {
16474
+ const text = `${texts.slice(0, kept).join(". ")}; and ${String(texts.length - kept)} more projects.${tail}`;
16475
+ if (text.length <= FIX_MAX) return text;
16476
+ }
16477
+ return fallback;
16478
+ }
16479
+ function linkRulesCheck(outcomes, configured) {
16480
+ const id = "link.rules";
16481
+ if (!configured) return {
16482
+ id,
16483
+ status: "pass",
16484
+ blocking: false,
16485
+ fix: null
16486
+ };
16487
+ if (outcomes === null) return warning(id, LINK_RULES_TOKEN_FIX);
16488
+ const segments = outcomes.map(linkSegment);
16489
+ const problems = segments.filter((segment) => segment.problem);
16490
+ if (problems.length === 0) return {
16491
+ id,
16492
+ status: "pass",
16493
+ blocking: false,
16494
+ fix: fitFix(segments, "", `link rules match every sampled PR in ${String(segments.length)} projects.`)
16495
+ };
16496
+ return warning(id, fitFix(problems, problems.some((segment) => segment.unmatched) ? ` ${LINK_RULES_TAIL}` : "", `link rules miss recent PRs in ${String(problems.length)} projects; change projects[].link to the repo's branch and PR title rules.`));
16497
+ }
16311
16498
  function check(id, ok, fix) {
16312
16499
  return {
16313
16500
  id,
@@ -16360,6 +16547,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
16360
16547
  const checks = [];
16361
16548
  const jiraTrackers = config.projects.flatMap((project) => project.tracker.type === "jira" ? [project.tracker] : []);
16362
16549
  const slackConfigured = Boolean(config.slack.channels.feed || config.slack.channels.orchestrators);
16550
+ const linkSamples = sampleLinks(ctx, fetcher, secrets["GITHUB_TOKEN"]);
16363
16551
  const missing = requiredSecretKeys(config).filter((name) => !secrets[name]);
16364
16552
  checks.push(check("secrets", missing.length === 0, `Add ${missing.join(", ")} to the private secrets.env file.`));
16365
16553
  const jiraEmail = secrets["JIRA_EMAIL"];
@@ -16400,6 +16588,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
16400
16588
  return null;
16401
16589
  }))).find((failure) => failure !== null) ?? null;
16402
16590
  checks.push(check("github.credentials", githubFailure === null, githubFailure ?? GITHUB_FIX));
16591
+ checks.push(linkRulesCheck(await linkSamples, config.projects.some((project) => project.tracker.type === "github-issues")));
16403
16592
  const probe = spurSendRequest(config.adapters.spur.baseUrl, SPUR_PROBE_SESSION, "spur-board doctor probe");
16404
16593
  const [spur, spurSend] = await Promise.all([request(ctx, fetcher, "spur", new URL("sessions", `${config.adapters.spur.baseUrl.replace(/\/$/, "")}/`)), request(ctx, fetcher, "spur.send", probe.url, probe.init)]);
16405
16594
  checks.push(check("spur.api", spur?.ok === true, "Start or correct the configured Spur API."));
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
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";
1
+ import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-eVAzSAsk.mjs";
2
+ import { i as CliError, n as requestOperation } from "./client-FoFGbc11.mjs";
3
+ import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-6Nm4MFGe.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -196,7 +196,7 @@ const githubIssuesTracker = z.strictObject({
196
196
  });
197
197
  const spurProject = z.strictObject({
198
198
  name: nonEmpty,
199
- role: z.enum(["worker", "operator"])
199
+ role: z.enum(["worker", "operator"]).describe("worker: sessions of this Spur project may link to this project's tasks through their PR or branch. operator: sessions act as the operator.")
200
200
  });
201
201
  const columnConfig = z.strictObject({
202
202
  id: z.enum(COLUMN_IDS, { error: (issue) => typeof issue.input === "string" ? `Unknown column ${JSON.stringify(issue.input)}: custom columns arrive with custom matchers and are not supported yet. Built-in columns: ${COLUMN_IDS.join(", ")}` : void 0 }),
@@ -249,8 +249,8 @@ const projectSchema = z.strictObject({
249
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
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
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."),
253
- operatorGithubLogin: z.string().regex(/^[A-Za-z0-9-]{1,39}$/, "Expected a GitHub login"),
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. Set the sources and patterns to the branch and PR title naming rules of tracker.repo. The board does not enforce those rules; the repo enforces them through its CI title check and its agents' skills. board doctor compares these rules with recent PRs by operatorGithubLogin."),
253
+ operatorGithubLogin: z.string().regex(/^[A-Za-z0-9-]{1,39}$/, "Expected a GitHub login").describe("The GitHub account agents open PRs under. PR discovery in repos keeps only PRs whose author is this login. It is not necessarily the maintainer's own account: when agents push as one account and a maintainer approves as another, set the agents' account, or no PR is discovered."),
254
254
  spurProjects: z.array(spurProject).superRefine((items, ctx) => {
255
255
  rejectDuplicates(items, "name", "spur project name", ctx);
256
256
  }).default([]),
@@ -1532,7 +1532,8 @@ const statusTaskSchema = taskViewSchema.extend({
1532
1532
  ticket: ticketFactsSchema.nullable().optional().describe(`Latest ticket facts, or null before observation. ${detailOnly}`),
1533
1533
  prs: z.array(prFactsSchema).optional().describe(`Latest facts for linked pull requests. ${detailOnly}`),
1534
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}`)
1535
+ links: z.array(linkViewSchema).optional().describe(`Effective pull request, session, and ticket links. ${detailOnly}`),
1536
+ linkHints: z.array(z.string().min(1)).min(1).optional().describe("Why a pull request a linked session reports has no link to this task: the PR is in the GitHub Issues tracker repo and the project link rules found no key for the task in it. Present only when there is a hint.")
1536
1537
  }).describe("A board task with a one-line state and counts; detail adds its facts and links.");
1537
1538
  const statusUnlinkedPrSchema = prFactsSchema.partial({
1538
1539
  author: true,
@@ -1547,7 +1548,7 @@ const statusUnlinkedPrSchema = prFactsSchema.partial({
1547
1548
  reviewRequests: true,
1548
1549
  ticketKeys: true,
1549
1550
  updatedAt: true
1550
- }).describe("A pull request without a task link; fields beyond its identity need detail.");
1551
+ }).extend({ reason: z.string().min(1).optional().describe("Why the link rules gave this pull request no task link. Present only on an open pull request in the tracker repo of a GitHub Issues project, when the rules found no key or no board task for its keys.") }).describe("A pull request without a task link; fields beyond its identity need detail.");
1551
1552
  const statusUnlinkedSessionSchema = statusSessionFactsSchema.partial({
1552
1553
  pr: true,
1553
1554
  links: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -21,9 +21,10 @@ Ask one question at a time, only when current state cannot answer it. Check befo
21
21
 
22
22
  ## 3. Complete missing configuration
23
23
 
24
- - Discover repositories, Spur projects, and GitHub logins where possible. For each unset value, ask one question and write only that answer: Jira filter and statuses if used, repositories, project names and roles, operator GitHub login per project, and the operator's Slack user ID. Preserve settled and unrelated fields; validate against the shipped config schema.
24
+ - Discover repositories, Spur projects, and GitHub logins where possible. For each unset value, ask one question and write only that answer: Jira filter and statuses if used, repositories, project names and roles, the GitHub login agents open PRs under per project (PR discovery filters by it; not always the operator's), and the operator's Slack user ID. Preserve settled and unrelated fields; validate against the shipped config schema.
25
25
  - If Slack roles are unset, follow [Slack setup](references/slack.md). List channels visible to the bot and ask which serve orchestrators and feed; store their IDs. The bot sees only private channels it joined.
26
26
  - Check required secret names and permissions. Follow [secret files](references/secrets.md) for private entry and any existing `slack.env` migration. Write `config.yaml` and a regular mode `0600` `secrets.env` only when needed.
27
+ - For a `github-issues` project, follow [worker links](references/worker-links.md).
27
28
  - After config edits, run `board doctor --offline` and apply its config fixes. An offline pass does not prove service or integration readiness.
28
29
 
29
30
  ## 4. Start service and grant access
@@ -4,6 +4,6 @@ Use this when the orchestrators or feed channel is not configured, or the app-le
4
4
 
5
5
  1. Check the bot's current channel membership. List the private channels it can see and ask the operator, one choice at a time, which should serve orchestrators and feed. An empty list does not prove no channels exist: the bot sees only private channels to which it was invited. Store channel IDs in config, never guessed names.
6
6
  2. If no channel fits, ask for an operator-chosen prefix and suggest available names using it. The operator creates or invites the app to channels; ask before any app or channel change.
7
- 3. Check whether an app and slash command already exist. If either is missing, use `board slack manifest --app-name <name> --command <slash-command>` to prepare a manifest with operator-chosen names. The operator creates the Slack app; do not claim the manifest creates it. Set `slack.appName` and `slack.command` in config to the selected names.
7
+ 3. Check whether an app and slash command already exist. Before generating a manifest, have the operator confirm that the chosen slash command, app name and channel names are free in the workspace: no other app or Board uses them, or commands and delivery can reach the wrong Board. The bot token cannot list other apps' slash commands, so do not claim an automatic check; ask the operator to type the command in a Slack message box and look at the autocomplete list, and to look at the workspace's installed apps. If a name is taken, suggest names with an operator-chosen prefix, such as `/acme-board`, `acme-board`, `#acme-orchestrators` and `#acme-board-feed`. If the app or command is missing, use `board slack manifest --app-name <name> --command <slash-command>` to prepare a manifest with operator-chosen names. The operator creates the Slack app; do not claim the manifest creates it. Set `slack.appName` and `slack.command` in config to the selected names.
8
8
  4. The manifest cannot create the app-level token with `connections:write`. In the Slack app settings, open **Basic Information → App-Level Tokens** and create a token with that scope. Then use the private entry procedure in [secret files](secrets.md). Never ask for a token value in chat.
9
9
  5. Check channel membership and command configuration with online doctor. If a check fails, apply its reported fix after inspecting state.
@@ -0,0 +1,10 @@
1
+ # Worker links
2
+
3
+ Use this for each `github-issues` project with a `role: worker` entry in `spurProjects`. A worker session links to its task through a `board-worker` Spur link, or later through its PR or branch.
4
+
5
+ 1. For each `role: worker` entry in that project's `spurProjects`, ask how its workers start (a script, an orchestrator prompt, a spawn step). Read that flow; do not change it yet.
6
+ 2. Check that the flow sets the session's `board-worker` link to `https://github.com/<owner>/<repo>/issues/<N>`, with owner and repo spelled letter for letter as in `tracker.repo`, and no trailing slash, query or fragment. A URL cased differently links nothing and reports no error.
7
+ 3. If it does not, suggest adding `spur slots --session "$SPUR_SESSION" --link board-worker=<issue URL>` as the worker's first step. `spur spawn` cannot set links; a script that spawns the session passes the new session's ID instead of `$SPUR_SESSION`. Ask before editing the flow.
8
+ 4. Confirm `operatorGithubLogin` is the account the agents' PRs are authored by. It may differ from the maintainer's own account; PR discovery keeps only PRs by this author.
9
+ 5. Read the tracker repo's branch and PR title rules (its CI title check and agent skills) and set `projects[].link` to match. The Board does not enforce naming. `board doctor` reports `link.rules`: how many of the operator's recent PRs the rules match.
10
+ 6. After a worker starts, check `board status --detail` within one Spur poll: the task lists the session as worker. If it does not, the operator can run `board link <task> --session <id> --reason <text> --key <key>`.
@@ -6,8 +6,7 @@ description: Use the Board to read task state and handle worker questions, inbox
6
6
  # Spur Board
7
7
 
8
8
  The Board records task state, questions, comments, and work that needs attention. Read task
9
- state before acting. The role sections link commands and their flags; task state may still
10
- restrict an action.
9
+ state before acting.
11
10
 
12
11
  Use `board schema --role worker --json` or `board schema --role orchestrator --json` for
13
12
  current operation IDs, inputs, grants, and errors.
@@ -24,6 +23,9 @@ operation result or current state before retrying.
24
23
 
25
24
  ## Worker flow
26
25
 
26
+ - If `board task <task>` lists no worker link for your session, run
27
+ `spur slots --session "$SPUR_SESSION" --link board-worker=<issue URL>`, or ask the operator
28
+ for `board link`. Spell the URL as the task key: `o/r#12` is `https://github.com/o/r/issues/12`.
27
29
  - Ask a blocking question with keyed `board ask <task> <text>`; keep its B<number> ID and
28
30
  wait for the doorbell.
29
31
  Use keyed `board comment <task> <text>` for nonblocking updates.
@@ -37,17 +39,15 @@ operation result or current state before retrying.
37
39
  - Exit 3 means not applied. Ask in your own session immediately. When the Board returns,
38
40
  retry `board ask` with identical text and key; retry failed `--done` identically too.
39
41
  - Exit 4 means this session lacks Board configuration. Ask in your own session immediately
40
- and say the Board is not configured so the operator can fix it. Keep the original key for
41
- retry after setup; never make a new key for that retry.
42
+ and say the Board is not configured so the operator can fix it. Keep the original key to
43
+ retry after setup.
42
44
  - Exit 5 (unknown): retry up to three times within about a minute, then ask in your
43
45
  own session. Repeat reads (`board inbox`, `board task`) without `--key`. For mutations,
44
- check the outcome first; if unclear, repeat the same command, input, and key. Keep that
45
- mutation key for recovery; give each new action a fresh key.
46
+ check the outcome first; if unclear, repeat the same command, input, and key.
46
47
  - For an answer received in your own session, add one keyed task-level comment recording
47
48
  provenance only, without the answer. Use keyed `board unblock <block> --withdraw <answer>`
48
49
  on the recovered B<number> question: it records the block answer and sends the conversation
49
- reply. Check uncertain outcomes and retry only with identical answer and key. Add no other
50
- answer comment or reply.
50
+ reply. Add no other answer comment or reply.
51
51
  - Only the session that asked may `--withdraw`. A replacement session with the answer posts
52
52
  its provenance in a keyed `board comment`, leaves the block open for the operator, and does
53
53
  not retry `--withdraw`.