spur-board 0.15.1 → 0.15.2

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +93 -3
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -198,6 +198,7 @@ const defaultPorts = {
198
198
  },
199
199
  listDir: readdirSync,
200
200
  exists: existsSync,
201
+ realPath: (path) => realpathSync(path),
201
202
  run: systemRun,
202
203
  sessions: liveSessions,
203
204
  fetcher: fetch,
@@ -348,6 +349,53 @@ function remoteChecks(value) {
348
349
  checks
349
350
  };
350
351
  }
352
+ function safeIds(values) {
353
+ return values.filter((id) => /^[a-zA-Z0-9_-]+$/.test(id)).slice(0, 10);
354
+ }
355
+ function listing(ids) {
356
+ return ids.length ? `: ${ids.join(", ")}` : "";
357
+ }
358
+ const skillLink = ".agents/skills/spur-board";
359
+ const codexVisibilityFix = "Add .agents/skills/spur-board to the Spur project's symlinks in its config and start a new session.";
360
+ const spurProjectList = z.array(z.object({
361
+ id: z.string(),
362
+ path: z.string()
363
+ }));
364
+ const spurProjectConfig = z.object({
365
+ symlinks: z.array(z.string()).optional(),
366
+ defaultAgent: z.string().optional()
367
+ });
368
+ /** Spur's own project list is the only source of each project's main checkout path. */
369
+ async function spurProjectPaths(baseUrl, ports) {
370
+ try {
371
+ const response = await ports.fetcher(new URL("projects", `${baseUrl.replace(/\/$/, "")}/`), { signal: AbortSignal.timeout(5e3) });
372
+ if (!response.ok) return null;
373
+ const parsed = spurProjectList.safeParse(await response.json());
374
+ return parsed.success ? new Map(parsed.data.map((project) => [project.id, project.path])) : null;
375
+ } catch {
376
+ return null;
377
+ }
378
+ }
379
+ function spurProjectEntry(ports, path, id) {
380
+ for (const file of ["spur.yaml", "spur.yml"]) {
381
+ let value;
382
+ try {
383
+ value = YAML.parse(ports.readText(join(path, file)));
384
+ } catch {
385
+ continue;
386
+ }
387
+ if (!value || typeof value !== "object" || !("projects" in value)) continue;
388
+ const projects = value.projects;
389
+ if (!projects || typeof projects !== "object" || !Object.hasOwn(projects, id)) continue;
390
+ const parsed = spurProjectConfig.safeParse(projects[id]);
391
+ if (!parsed.success) continue;
392
+ return {
393
+ symlinks: (parsed.data.symlinks ?? []).map((entry) => entry.replace(/^\.\//, "").replace(/\/+$/, "")),
394
+ ...parsed.data.defaultAgent === void 0 ? {} : { defaultAgent: parsed.data.defaultAgent }
395
+ };
396
+ }
397
+ return null;
398
+ }
351
399
  /** Local preflight remains useful even when the daemon is stopped. */
352
400
  async function runDoctor(options = {}) {
353
401
  const env = options.env ?? process.env;
@@ -399,16 +447,45 @@ async function runDoctor(options = {}) {
399
447
  checks.push(live === void 0 ? warning("path.spur", "Start a Spur session, then rerun board doctor.") : result("path.spur", spurBoard?.exitCode === 0, "Install board into the live Spur session PATH."));
400
448
  const configured = new Set(config.projects.flatMap((project) => project.spurProjects.map((spur) => spur.name)));
401
449
  const codexSessions = sessions.filter((session) => session.codexHome && session.project && configured.has(session.project));
402
- checks.push(codexSessions.length === 0 ? warning("skills.codex_visibility", "Start a Codex session in a configured Spur project to verify skill visibility.") : result("skills.codex_visibility", codexSessions.some((session) => session.cwd !== void 0 && ports.exists(join(session.cwd, ".agents", "skills", "spur-board", "SKILL.md")) || session.codexHome !== void 0 && ports.exists(join(session.codexHome, "skills", "spur-board", "SKILL.md"))), "Add .agents/skills/spur-board to the Spur project's symlinks in its config and start a new session."));
450
+ const projectPaths = configured.size === 0 ? null : await spurProjectPaths(config.adapters.spur.baseUrl, ports);
451
+ const states = /* @__PURE__ */ new Map();
452
+ const missing = [];
453
+ if (projectPaths !== null) {
454
+ const codexHome = env["CODEX_HOME"];
455
+ const installed = /* @__PURE__ */ new Set();
456
+ for (const copy of [join(home, ".claude", "skills", "spur-board"), codexHome ? join(resolve(codexHome), "skills", "spur-board") : join(home, ".codex", "skills", "spur-board")]) try {
457
+ installed.add(ports.realPath(copy));
458
+ } catch {}
459
+ for (const name of configured) {
460
+ const path = projectPaths.get(name);
461
+ if (path === void 0) {
462
+ missing.push(name);
463
+ continue;
464
+ }
465
+ const entry = spurProjectEntry(ports, path, name);
466
+ let linkReal = null;
467
+ try {
468
+ linkReal = ports.realPath(join(path, skillLink));
469
+ } catch {}
470
+ const listed = entry?.symlinks.includes(skillLink) ?? false;
471
+ const used = codexSessions.some((session) => session.project === name) || entry?.defaultAgent === "codex" || listed || linkReal !== null;
472
+ const foreignLink = linkReal !== null && !installed.has(linkReal);
473
+ states.set(name, entry === null ? foreignLink ? "broken" : "unknown" : used && (linkReal === null || foreignLink || !listed) ? "broken" : "ok");
474
+ }
475
+ }
476
+ const unknown = [...states].filter(([, state]) => state === "unknown").map(([name]) => name);
477
+ checks.push(configured.size === 0 ? result("skills.codex_visibility", true, codexVisibilityFix) : projectPaths === null ? warning("skills.codex_visibility", "Start Spur or correct adapters.spur.baseUrl in config.yaml, then rerun board doctor to check the Codex skill install.") : [...states.values()].includes("broken") ? result("skills.codex_visibility", false, codexVisibilityFix) : missing.length > 0 || unknown.length > 0 ? warning("skills.codex_visibility", [...missing.length > 0 ? [`Correct spurProjects in config.yaml or register these projects in Spur${listing(safeIds(missing))}.`] : [], ...unknown.length > 0 ? [`Check that projects.<id>.symlinks in each project's spur.yaml lists .agents/skills/spur-board${listing(safeIds(unknown))}.`] : []].join(" ")) : result("skills.codex_visibility", true, codexVisibilityFix));
478
+ const oldSessions = codexSessions.filter((session) => session.project !== void 0 && states.get(session.project) === "ok" && !(session.cwd !== void 0 && ports.exists(join(session.cwd, ".agents", "skills", "spur-board", "SKILL.md")) || session.codexHome !== void 0 && ports.exists(join(session.codexHome, "skills", "spur-board", "SKILL.md"))));
479
+ checks.push(oldSessions.length > 0 ? warning("sessions.codex_skill", `Start new Spur sessions to replace Codex sessions created before the skill link${listing(safeIds([...new Set(oldSessions.map((session) => session.id))]))}; Spur links .agents/skills/spur-board only into new worktrees.`) : result("sessions.codex_skill", true, "Start new Spur sessions."));
403
480
  const version = ports.productVersion();
404
481
  const stamps = [".claude", ".codex"].flatMap((agent) => ["spur-board", "spur-board-setup"].map((skill) => stamp(ports, join(home, agent, "skills", skill, ".spur-board-install.json"))));
405
482
  const latestInstall = Math.max(...stamps.flatMap((entry) => entry === null ? [] : [entry.installedAt]));
406
483
  const stale = sessions.filter((session) => session.startAt !== void 0 && session.startAt < latestInstall);
407
484
  const unknownStarts = sessions.some((session) => session.startAt === void 0);
408
485
  const staleSessions = [...new Set(stale.map((session) => session.id))];
409
- const staleIds = staleSessions.filter((id) => /^[a-zA-Z0-9_-]+$/.test(id)).slice(0, 10);
486
+ const staleIds = safeIds(staleSessions);
410
487
  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."));
488
+ checks.push(stale.length > 0 || unknownStarts ? warning("sessions.stale", `Restart ${staleCount} started before the last skill install${listing(staleIds)}; verify sessions whose start time is unavailable.`) : result("sessions.stale", true, "Restart older sessions."));
412
489
  const portFix = await checkHttpPort(config.http.port, {
413
490
  bind: ports.bind,
414
491
  run: (command, args) => Promise.resolve(ports.run(command, args))
@@ -1156,6 +1233,19 @@ function registerSetupCommands(program, options, io, env) {
1156
1233
  ...await runSetup(() => uninstallService(serviceOptions))
1157
1234
  });
1158
1235
  });
1236
+ commandFor(program, "mcp").summary("Start the MCP server for an agent on standard input and output.").description([
1237
+ "Start the MCP server for an agent on standard input and output. Stdout carries only JSON-RPC.",
1238
+ "",
1239
+ "Each tool call finds the caller: `SPUR_SESSION` inside a Spur session, otherwise `BOARD_TOKEN`, otherwise the first `.spur-board/token` found walking upward from the directory the agent starts it in, stopping at home.",
1240
+ "",
1241
+ "It reaches the daemon at `BOARD_DAEMON_URL`, otherwise at `http.port` from `config.yaml`.",
1242
+ "",
1243
+ "A `version_mismatch` answer means the server and the daemon have different catalogs: restart the agent session so `board mcp` loads the daemon's catalog; if it remains, run `board service restart`.",
1244
+ "",
1245
+ "Register it with Claude Code: `claude mcp add spur-board -- board mcp`. With Codex: `codex mcp add spur-board -- board mcp`."
1246
+ ].join("\n")).action(() => {
1247
+ throw new CliError("usage", void 0, void 0, "Run `board mcp` with no other arguments or flags.");
1248
+ });
1159
1249
  const manifest = commandFor(program, "slack manifest");
1160
1250
  manifest.description("Print a Slack app manifest.");
1161
1251
  manifest.option("--app-name <name>", "Slack app name.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"