spur-board 0.11.0 → 0.11.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
@@ -1,6 +1,6 @@
1
- import { H as requiredSecretKeys, N as ERRORS, U as SLACK_BOT_SCOPES, V as configSchema, l as OPERATIONS, n as SYSTEMD_SERVICE_SETTINGS } from "./src-Dl5c0sRb.mjs";
2
- import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-DbeVLW2G.mjs";
3
- import { a as memoryVerdictCache, c as loadEnrollmentConfig, i as fileVerdictCache, l as resolveDaemonAddress, n as cliPackageVersion, o as configFile, s as loadClientConfig, t as checkCatalog } from "./config-B1OeBAM-.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-CjlXSUX-.mjs";
2
+ import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-B3aIcQ5T.mjs";
3
+ import { a as memoryVerdictCache, c as loadEnrollmentConfig, i as fileVerdictCache, l as resolveDaemonAddress, n as cliPackageVersion, o as configFile, s as loadClientConfig, t as checkCatalog } from "./config-DWp8J6RP.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";
@@ -880,6 +880,22 @@ function shellValue(value) {
880
880
  const text = String(value);
881
881
  return /^[A-Za-z0-9_./#:@-]+$/.test(text) ? text : JSON.stringify(text);
882
882
  }
883
+ /** The identity an operation in the selected input mode needs, when only one kind of caller can run it. */
884
+ function identityHint(op, mode) {
885
+ const flag = op.cli.modes?.find((item) => item.mode === mode)?.flag;
886
+ const command = `\`board ${op.cli.command}${flag ? ` ${flag}` : ""}\``;
887
+ if (!roleCanUseOperation(op, "worker", mode) && !roleCanUseOperation(op, "orchestrator", mode)) return `${command} needs operator identity: run it in a Spur session of a project whose spurProjects role is operator, or run \`board token create --name <name> --into <folder>\` and ask the operator to approve the request in Slack.`;
888
+ if (!roleCanUseOperation(op, "operator", mode)) return `${command} needs an agent identity: run it in a Spur session of a project listed in config.yaml.`;
889
+ }
890
+ function loadOperationConfig(op, input, env) {
891
+ try {
892
+ return loadClientConfig(env);
893
+ } catch (error) {
894
+ const hint = identityHint(op, typeof input === "object" && input !== null && "mode" in input && typeof input.mode === "string" ? input.mode : void 0);
895
+ if (error instanceof CliError && error.code === "identity_missing" && hint) throw new CliError(error.code, error.context, error.requestId, hint);
896
+ throw error;
897
+ }
898
+ }
883
899
  function exampleCommand(op, input) {
884
900
  const words = ["board", op.cli.command];
885
901
  for (const arg of op.cli.args) {
@@ -1076,7 +1092,7 @@ function createProgram(options = {}) {
1076
1092
  if (keyOption === "") throw new CliError("usage");
1077
1093
  if (keyOption !== void 0 && escapeTerminalControls(keyOption) !== keyOption) throw new CliError("usage", void 0, void 0, "The idempotency key must contain only printable characters.");
1078
1094
  if (op.kind === "mutation" && env["SPUR_SESSION"] && !keyOption) throw new CliError("usage");
1079
- const config = options.clientConfig ?? loadClientConfig(env);
1095
+ const config = options.clientConfig ?? loadOperationConfig(op, input, env);
1080
1096
  const key = op.kind === "mutation" ? keyOption || randomUUID() : void 0;
1081
1097
  if (key) io.stderr(`key: ${escapeTerminalControls(key)}\n`);
1082
1098
  let instance;
@@ -1,4 +1,4 @@
1
- import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-Dl5c0sRb.mjs";
1
+ import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-CjlXSUX-.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -153,7 +153,7 @@ function send({ method, path, body, config, anonymous, decode, observe }) {
153
153
  }
154
154
  /** Shared daemon HTTP client. The CLI owns output; this module owns transport and wire parsing. */
155
155
  async function requestOperation(op, input, key, config, observe) {
156
- if (!config.session && !config.token) throw new CliError("config");
156
+ if (!config.session && !config.token) throw new CliError("identity_missing");
157
157
  return send({
158
158
  method: "POST",
159
159
  path: `/v1/ops/${encodeURIComponent(op.id)}`,
package/dist/client.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-DbeVLW2G.mjs";
1
+ import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-B3aIcQ5T.mjs";
2
2
  export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
@@ -1,5 +1,5 @@
1
- import { V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-Dl5c0sRb.mjs";
2
- import { i as CliError, t as fetchCatalogVersion } from "./client-DbeVLW2G.mjs";
1
+ import { V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-CjlXSUX-.mjs";
2
+ import { i as CliError, t as fetchCatalogVersion } from "./client-B3aIcQ5T.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";
@@ -90,7 +90,10 @@ function loadClientConfig(env = process.env, paths = {
90
90
  const address = resolveDaemonAddress(env, paths.home);
91
91
  const session = env["SPUR_SESSION"] || void 0;
92
92
  const token = session ? void 0 : env["BOARD_TOKEN"] === void 0 ? findTokenFile(paths.cwd, paths.home) : env["BOARD_TOKEN"];
93
- if (!session && !token) throw new CliError("config", { environmentVariable: "BOARD_TOKEN" });
93
+ if (!session && !token) {
94
+ if (env["BOARD_TOKEN"] === "") throw new CliError("config", { environmentVariable: "BOARD_TOKEN" });
95
+ throw new CliError("identity_missing");
96
+ }
94
97
  return {
95
98
  address,
96
99
  session,
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-Dl5c0sRb.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-CjlXSUX-.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";
@@ -11466,6 +11466,10 @@ function refKey(ref) {
11466
11466
  function projectForSource(config, source) {
11467
11467
  return config.projects.find((project) => source === trackerSource(project) || project.repos.some((repo) => source === `github:${project.id}:${repo.toLowerCase()}`));
11468
11468
  }
11469
+ /** A closed issue of a GitHub Issues tracker, which lists only open issues. */
11470
+ function closedIssue(project, status) {
11471
+ return project.tracker.type === "github-issues" && status === "closed";
11472
+ }
11469
11473
  async function updateTerminal(trx, config, taskId, at, completeSince, blind) {
11470
11474
  const task = await trx.selectFrom("task").selectAll().where("id", "=", taskId).executeTakeFirstOrThrow();
11471
11475
  const project = config.projects.find((entry) => entry.id === task.project);
@@ -11555,7 +11559,7 @@ async function ticket(trx, config, fact, at, source) {
11555
11559
  if (task === void 0) task = pending;
11556
11560
  if (task?.manual_exclude === 1) return;
11557
11561
  if (task === void 0) {
11558
- if (!fact.inFilter) return;
11562
+ if (!fact.inFilter || closedIssue(project, fact.status)) return;
11559
11563
  task = await trx.insertInto("task").values({
11560
11564
  project: project.id,
11561
11565
  tracker_kind: project.tracker.type,
@@ -11851,8 +11855,10 @@ function createObservationCore(deps) {
11851
11855
  "task.manual_include",
11852
11856
  "ticket_snapshot.detail"
11853
11857
  ]).where("project", "=", project.id).where("membership", "!=", "archived").execute()).flatMap((task) => {
11854
- const outside = task.detail === null ? false : !parseJson(ticketFactsSchema, task.detail).inFilter;
11855
- return task.manual_include === 1 || outside ? [{
11858
+ const detail = task.detail === null ? null : parseJson(ticketFactsSchema, task.detail);
11859
+ const outside = detail !== null && !detail.inFilter;
11860
+ const openIssue = project.tracker.type === "github-issues" && detail !== null && !closedIssue(project, detail.status);
11861
+ return task.manual_include === 1 || outside || openIssue ? [{
11856
11862
  kind: "ticket",
11857
11863
  trackerId: source,
11858
11864
  ...task.tracker_id === null ? {} : { id: task.tracker_id },
@@ -11952,12 +11958,14 @@ function createObservationCore(deps) {
11952
11958
  "ticket_snapshot.task_id",
11953
11959
  "ticket_snapshot.detail",
11954
11960
  "task.tracker_id",
11955
- "task.key"
11961
+ "task.key",
11962
+ "task.membership"
11956
11963
  ]).where("task.project", "=", project.id).where("task.manual_include", "=", 0).where("task.manual_exclude", "=", 0).execute();
11957
11964
  for (const row of rows) {
11965
+ if (project.tracker.type === "github-issues" && row.membership === "archived") continue;
11958
11966
  if (unresolved.has(row.key) || row.tracker_id !== null && (seen.has(row.tracker_id) || unresolved.has(row.tracker_id))) continue;
11959
11967
  const fact = parseJson(ticketFactsSchema, row.detail);
11960
- if (!fact.inFilter) continue;
11968
+ if (!fact.inFilter || closedIssue(project, fact.status)) continue;
11961
11969
  const outside = {
11962
11970
  ...fact,
11963
11971
  inFilter: false
@@ -13835,7 +13843,7 @@ function matchesFilter(issue, tracker) {
13835
13843
  if (tracker.label !== void 0) return issue.labels.some((label) => label.name === tracker.label);
13836
13844
  return issue.milestone?.title === tracker.milestone;
13837
13845
  }
13838
- /** Lists tracker issues and resolves manually included keys outside the filter. */
13846
+ /** Lists open filter issues and resolves requested tickets missing from that listing. */
13839
13847
  function createGithubIssuesAdapter(options) {
13840
13848
  const transport = options.fetch ?? fetch;
13841
13849
  const [owner, name] = options.tracker.repo.split("/");
@@ -13931,7 +13939,7 @@ function createGithubIssuesAdapter(options) {
13931
13939
  const observedAt = (/* @__PURE__ */ new Date()).toISOString();
13932
13940
  const milestone = await milestoneNumber(ctx.signal);
13933
13941
  const filter = new URL(`${root}/issues`);
13934
- filter.searchParams.set("state", "all");
13942
+ filter.searchParams.set("state", "open");
13935
13943
  filter.searchParams.set("per_page", "100");
13936
13944
  if (options.tracker.label !== void 0) filter.searchParams.set("labels", options.tracker.label);
13937
13945
  if (milestone !== void 0) filter.searchParams.set("milestone", String(milestone));
@@ -13969,7 +13977,7 @@ function createGithubIssuesAdapter(options) {
13969
13977
  fact = normalize(detail, options.id, options.tracker.repo, matchesFilter(detail, options.tracker));
13970
13978
  facts.set(issueNo, fact);
13971
13979
  } catch (error) {
13972
- if (error instanceof GithubIssuesHttpError && error.status === 404) {
13980
+ if (error instanceof GithubIssuesHttpError && (error.status === 404 || error.status === 410)) {
13973
13981
  entities.push({
13974
13982
  ref,
13975
13983
  status: "not_found"
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-Dl5c0sRb.mjs";
2
- import { i as CliError, n as requestOperation } from "./client-DbeVLW2G.mjs";
3
- import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-B1OeBAM-.mjs";
1
+ import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-CjlXSUX-.mjs";
2
+ import { i as CliError, n as requestOperation } from "./client-B3aIcQ5T.mjs";
3
+ import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-DWp8J6RP.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -551,6 +551,13 @@ const ERRORS = {
551
551
  hint: "Fix the configuration file named in the error, then run the command again.",
552
552
  recovery: noRetry("Fix the named configuration file and retry.")
553
553
  }),
554
+ identity_missing: spec("identity_missing", {
555
+ status: null,
556
+ exit: EXIT_CODES.config,
557
+ message: "No caller identity was found: this is not a Spur session and no .spur-board/token was found walking up from the current folder.",
558
+ hint: "Run the command in a Spur session of a project listed in config.yaml, or run `board token create --name <name> --into <folder>` and ask the operator to approve the request in Slack.",
559
+ recovery: noRetry("Get a caller identity as the fix says, then run the command again.")
560
+ }),
554
561
  outcome_unknown: spec("outcome_unknown", {
555
562
  status: null,
556
563
  exit: EXIT_CODES.outcomeUnknown,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"