spur-board 0.15.0 → 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.
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,14 +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
- const staleIds = stale.map((session) => session.id).filter((id) => /^[a-zA-Z0-9_-]+$/.test(id)).slice(0, 10);
409
- 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."));
485
+ const staleSessions = [...new Set(stale.map((session) => session.id))];
486
+ const staleIds = safeIds(staleSessions);
487
+ const staleCount = staleSessions.length === 0 ? "sessions" : `${String(staleSessions.length)} session${staleSessions.length === 1 ? "" : "s"}`;
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."));
410
489
  const portFix = await checkHttpPort(config.http.port, {
411
490
  bind: ports.bind,
412
491
  run: (command, args) => Promise.resolve(ports.run(command, args))
@@ -479,7 +558,6 @@ function renderUserUnit(paths) {
479
558
  "[Service]",
480
559
  `ExecStart=${unitArgument(paths.nodePath)} ${unitArgument(paths.daemonEntry)}`,
481
560
  ...(paths.environment ?? []).map((entry) => `Environment=${unitArgument(entry)}`),
482
- `EnvironmentFile=${unitArgument(paths.secretsFile)}`,
483
561
  ...SYSTEMD_SERVICE_SETTINGS,
484
562
  "",
485
563
  "[Install]",
@@ -1155,6 +1233,19 @@ function registerSetupCommands(program, options, io, env) {
1155
1233
  ...await runSetup(() => uninstallService(serviceOptions))
1156
1234
  });
1157
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
+ });
1158
1249
  const manifest = commandFor(program, "slack manifest");
1159
1250
  manifest.description("Print a Slack app manifest.");
1160
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.0",
3
+ "version": "0.15.2",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -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.