spur-board 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { L as ERRORS, m as renderMcpError, u as OPERATIONS } from "./src-Dk-_gP9r.mjs";
2
- import { a as CliError, r as requestOperation } from "./client-C0DEiR41.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-i3T5pqbh.mjs";
1
+ import { m as renderMcpError, u as OPERATIONS, z as ERRORS } from "./src-HVASmsVd.mjs";
2
+ import { a as CliError, r as requestOperation } from "./client-BODC7qTT.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-M7jQfUT9.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -105,6 +105,37 @@ const SESSION_END_REASONS = [
105
105
  ];
106
106
  /** How a project's dispatcher runs: `shadow` records moves only, `on` moves tasks and opens turns. */
107
107
  const DISPATCHER_MODES = ["shadow", "on"];
108
+ /** The exit conditions of the column gates, as `board task --why` names them. */
109
+ const GATE_CONDITIONS = [
110
+ "pr_open",
111
+ "not_draft",
112
+ "checks_green",
113
+ "no_conflict",
114
+ "external_comments_handled",
115
+ "comment_history_read",
116
+ "submit_on_head",
117
+ "review_on_head",
118
+ "approved",
119
+ "merged"
120
+ ];
121
+ /**
122
+ * The state of one gate condition: `waiting` fails only on a fact not known yet, `unchecked` was
123
+ * not evaluated because an earlier condition of the column failed first.
124
+ */
125
+ const GATE_CONDITION_STATES = [
126
+ "met",
127
+ "failed",
128
+ "waiting",
129
+ "unchecked"
130
+ ];
131
+ /** What holds the dispatcher from acting on a task. */
132
+ const TASK_HOLDS = [
133
+ "pr_snapshot_missing",
134
+ "github_blind",
135
+ "spur_blind",
136
+ "cycle_limit",
137
+ "work_not_started"
138
+ ];
108
139
  /** Who caused a journal event. */
109
140
  const ACTORS = [
110
141
  "operator",
@@ -174,7 +205,7 @@ function plainHttpAllowed(url) {
174
205
  return host === "localhost" || host === "[::1]" || LOOPBACK_IPV4.test(host);
175
206
  }
176
207
  const jiraTracker = z.strictObject({
177
- type: z.literal("jira"),
208
+ type: z.literal("jira").describe("jira: tasks come from the Jira issues jql returns, read with JIRA_EMAIL and JIRA_API_TOKEN from secrets.env."),
178
209
  baseUrl: z.url({ protocol: /^https?$/ }).refine((value) => {
179
210
  try {
180
211
  return plainHttpAllowed(new URL(value));
@@ -182,10 +213,10 @@ const jiraTracker = z.strictObject({
182
213
  return true;
183
214
  }
184
215
  }, { error: "Use https: for the Jira URL; http: is allowed only on a loopback host (localhost, 127.0.0.0/8, ::1) because it receives your Jira credentials" }).describe("Jira site URL. https:, or http: only on a loopback host."),
185
- jql: nonEmpty,
186
- doneStatuses: z.array(nonEmpty).min(1),
187
- readyStatuses: z.array(nonEmpty).min(1),
188
- projectKeys: z.array(z.string().regex(/^[A-Z][A-Z0-9_]*$/, "Expected a Jira project key like PROJ")).default([])
216
+ jql: nonEmpty.describe("Jira search whose issues become tasks in To Do. A task whose issue leaves the result is flagged out of filter while it has an open PR or a live session, and is archived otherwise, once Spur, the tracker and every repo have a complete poll since its last change and none of them is blind; a task added or removed by hand is left alone."),
217
+ doneStatuses: z.array(nonEmpty.describe("A Jira status name, spelled exactly as in Jira.")).min(1).describe("Jira statuses that mean done. A task whose issue is in one of them and that has no open PR is archived on the next archive.doneWeekday, once every repo has a complete poll since its last change. Each name must exist in every projectKeys project, or the Jira poll fails with a config error."),
218
+ readyStatuses: z.array(nonEmpty.describe("A Jira status name, spelled exactly as in Jira.")).min(1).describe("Jira statuses that mean ready for development. The board checks only that each name exists in every projectKeys project; the Jira poll fails with a config error otherwise."),
219
+ projectKeys: z.array(z.string().regex(/^[A-Z][A-Z0-9_]*$/, "Expected a Jira project key like PROJ").describe("A Jira project key in capitals, such as PROJ.")).default([]).describe("Keys of this board project's Jira projects, such as PROJ. A PR names its task by one of these keys, and doneStatuses and readyStatuses are checked in each of these projects. A task key such as PROJ-12 belongs to the one board project whose list holds its prefix; an empty list takes every Jira key, and a key that several projects take belongs to none. The Jira poll fails with a config error while the list is empty.")
189
220
  });
190
221
  /** Capture groups of a pattern that compiles without flags, or `undefined` when it does not. */
191
222
  function captureGroups(pattern) {
@@ -221,8 +252,8 @@ function linkPattern(fallback, description) {
221
252
  }).default(fallback).describe(description);
222
253
  }
223
254
  const githubIssuesTracker = z.strictObject({
224
- type: z.literal("github-issues"),
225
- repo: repoSlugSchema,
255
+ type: z.literal("github-issues").describe("github-issues: tasks come from the open issues of tracker.repo, narrowed by label or milestone when set, read with GITHUB_TOKEN."),
256
+ repo: repoSlugSchema.describe("Repository as owner/name whose open issues become tasks. PRs link to its issues only in this repository, so list it in repos too."),
226
257
  label: nonEmpty.describe("Only open issues with this label become tasks. Set at most one of label and milestone; with neither, every open issue of tracker.repo becomes a task.").optional(),
227
258
  milestone: nonEmpty.describe("Only open issues in the milestone with this title become tasks. Set at most one of label and milestone; with neither, every open issue of tracker.repo becomes a task.").optional()
228
259
  }).superRefine((tracker, ctx) => {
@@ -242,9 +273,9 @@ const spurProject = z.strictObject({
242
273
  });
243
274
  const DEFAULT_CYCLE_LIMIT = 10;
244
275
  const columnConfig = z.strictObject({
245
- 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 }),
246
- enabled: z.boolean().default(true),
247
- orchestrator: nonEmpty.default("none"),
276
+ 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 }).describe("The built-in column this entry configures."),
277
+ enabled: z.boolean().default(true).describe("false skips the column: tasks move past it and its exit condition is not checked. todo, dev and done cannot be disabled."),
278
+ orchestrator: nonEmpty.default("none").describe("Who takes the column's turns. none: the task's live worker session, else the operator. operator: the operator, who also gets the questions asked in the column. Otherwise the name of a spurProjects entry whose sessions orchestrate the column and get the questions others ask in it."),
248
279
  cycleLimit: z.int().min(1).default(DEFAULT_CYCLE_LIMIT).describe("How many times a task may return to Dev from this column before the board stops it for the operator. Returns by the column executor, changes requested and external comments count; a conflict, red CI and a draft do not.")
249
280
  });
250
281
  /** The board rules: required columns present and enabled, built-ins in canonical order. */
@@ -278,12 +309,12 @@ const projectSchema = z.strictObject({
278
309
  id: z.string().refine((id) => id !== RESERVED_PROJECT, {
279
310
  message: `"${RESERVED_PROJECT}" is reserved for board-wide journal events; choose another project id`,
280
311
  abort: true
281
- }).regex(/^[a-z][a-z0-9-]*$/, "Expected lowercase letters, digits and dashes"),
312
+ }).regex(/^[a-z][a-z0-9-]*$/, "Expected lowercase letters, digits and dashes").describe("Board project id: lowercase letters, digits and dashes, unique, not _board. It names the project on its tasks, in the journal and in its source ids such as jira:<id> and github:<id>:<repo>."),
282
313
  tracker: z.discriminatedUnion("type", [jiraTracker, githubIssuesTracker]),
283
- repos: z.array(repoSlugSchema).min(1),
284
- reposWithoutCi: z.array(repoSlugSchema).default([]).describe("Repos from repos that run no CI checks, in any letter case. In a listed repo, a PR whose check list on head is empty passes the Dev gate check condition instead of waiting in Dev. A list of only skipped checks still waits, and red or pending checks still count. A listed repo whose branch protection requires checks that have not reported yet also passes, so list only repos that run no checks. Without this key, a PR with no checks waits in Dev."),
314
+ repos: z.array(repoSlugSchema.describe("A repository as owner/name.")).min(1).describe("GitHub repositories as owner/name whose PRs the board polls for this project, one source each. A done task is archived only after every listed repository has a complete poll since its last change."),
315
+ reposWithoutCi: z.array(repoSlugSchema.describe("A repository from repos as owner/name, in any letter case.")).default([]).describe("Repos from repos that run no CI checks, in any letter case. In a listed repo, a PR whose check list on head is empty passes the Dev gate check condition instead of waiting in Dev. A list of only skipped checks still waits, and red or pending checks still count. A listed repo whose branch protection requires checks that have not reported yet also passes, so list only repos that run no checks. Without this key, a PR with no checks waits in Dev."),
285
316
  link: z.strictObject({
286
- sources: z.array(z.enum(LINK_SOURCES)).min(1).superRefine((sources, ctx) => {
317
+ sources: z.array(z.enum(LINK_SOURCES).describe("One place a PR can name its task: closing, branch or title.")).min(1).superRefine((sources, ctx) => {
287
318
  sources.forEach((source, i) => {
288
319
  if (sources.indexOf(source) !== i) ctx.addIssue({
289
320
  code: "custom",
@@ -308,13 +339,13 @@ const projectSchema = z.strictObject({
308
339
  });
309
340
  curator ??= item.name;
310
341
  });
311
- }).default([]),
342
+ }).default([]).describe("Spur projects whose sessions work on this board project, each with a role; at most one curator. Board commands from a session whose Spur project is in no spurProjects list are refused."),
312
343
  columns: z.array(columnConfig).superRefine(checkBoard).default(() => COLUMN_IDS.map((id) => ({
313
344
  id,
314
345
  enabled: true,
315
346
  orchestrator: "none",
316
347
  cycleLimit: DEFAULT_CYCLE_LIMIT
317
- }))),
348
+ }))).describe("The project's board columns in canonical order. todo, dev and done must be present and enabled. A column left out or disabled is skipped. Without this key, all nine columns are enabled with orchestrator none."),
318
349
  dispatcher: z.strictObject({ mode: z.enum(DISPATCHER_MODES).default("shadow").describe("shadow: the board evaluates the column gates and records where each task would go in its shadow column, and opens no turn, doorbell or block; the column executor submits with the task key. on: the board moves the task between columns, hands the column executor a turn and raises the cycle-limit block.") }).prefault({}).describe("How the board moves tasks between columns. The board records the mode it last ran with. The daemon reads the mode at start, so a change takes effect after a restart; a switch from shadow to on copies the shadow column of each task into its column, and a switch back to shadow closes the open turns and starts the shadow column from the column again.")
319
350
  }).superRefine((project, ctx) => {
320
351
  const repos = new Set(project.repos.map((repo) => repo.toLowerCase()));
@@ -390,24 +421,24 @@ const configSchema = z.strictObject({
390
421
  projects: z.array(projectSchema).min(1).superRefine((items, ctx) => {
391
422
  rejectDuplicates(items, "id", "project id", ctx);
392
423
  rejectSharedSpurProjects(items, ctx);
393
- }),
394
- operator: z.strictObject({ slack: nonEmpty }),
424
+ }).describe("Board projects, at least one. Each reads tasks from one tracker and PRs from its repos. A Spur project can be listed under only one board project."),
425
+ operator: z.strictObject({ slack: nonEmpty.describe("Slack user ID of the operator, such as U0123456789. Slack commands, button presses and messages from anyone else are denied. A feed line the operator resolves names this user.") }),
395
426
  slack: z.strictObject({
396
- appName: z.string().trim().min(1).default(DEFAULT_SLACK_APP_NAME),
397
- command: z.string().regex(/^\/[a-z0-9_-]+$/, "Expected a slash command such as /board").default(DEFAULT_SLACK_COMMAND),
398
- appId: z.string().regex(/^A[A-Z0-9]+$/, "Expected a Slack app ID").optional(),
427
+ appName: z.string().trim().min(1).default(DEFAULT_SLACK_APP_NAME).describe("Slack app and bot display name that board slack manifest writes when --app-name is not given."),
428
+ command: z.string().regex(/^\/[a-z0-9_-]+$/, "Expected a slash command such as /board").default(DEFAULT_SLACK_COMMAND).describe("Slash command with its leading slash. The board acts only on this command, and board slack manifest writes it when --command is not given. When slack.channels is set and SLACK_APP_CONFIG_TOKEN and slack.appId are present, board doctor compares it with the installed app."),
429
+ appId: z.string().regex(/^A[A-Z0-9]+$/, "Expected a Slack app ID").optional().describe("Slack app ID, such as A0123456789. When slack.channels is set and SLACK_APP_CONFIG_TOKEN is present, board doctor reads this app's manifest to check the installed slash command against slack.command."),
399
430
  channels: z.strictObject({
400
- orchestrators: nonEmpty.optional(),
401
- feed: nonEmpty.optional()
431
+ orchestrators: nonEmpty.optional().describe("Slack channel ID, such as C0123456789, where the board opens a thread for each block addressed to the operator by someone else. Once either channel is set, the daemon does not start without the other channel and SLACK_BOT_TOKEN, and without SLACK_APP_TOKEN it reads nothing from Slack."),
432
+ feed: nonEmpty.optional().describe("Slack channel ID where the board posts a line for each curator answer, each newly installed version and each operator item, with the buttons the operator presses. Operator items about failed Slack posts, transport health, undelivered answers and ended workers, and those shown as operator blocks, get no feed line. A line whose item clears before it is first sent, such as an expired token request, is dropped. Set it together with orchestrators.")
402
433
  }).prefault({})
403
434
  }).prefault({}),
404
435
  thresholds: z.strictObject({
405
- staleMultiplier: z.number().min(1).default(3),
436
+ staleMultiplier: z.number().min(1).default(3).describe("A source with no complete poll for this many of its poll intervals turns blind stale. board status marks that source, and an operator item whose fact is older than that, as stale."),
406
437
  blockOpenMs: durationMs(864e5, "How long a block may stay open before an item is raised")
407
438
  }).prefault({}),
408
- archive: z.strictObject({ doneWeekday: z.enum(WEEKDAYS).default("saturday") }).prefault({}),
409
- digest: z.strictObject({ tz: z.string().refine(isTimeZone, "Unknown IANA time zone") }),
410
- commands: z.strictObject({ retentionDays: z.int().min(1).default(7) }).prefault({}),
439
+ archive: z.strictObject({ doneWeekday: z.enum(WEEKDAYS).default("saturday").describe("Weekday whose local midnight, in digest.tz, is the weekly archive slot: tasks done before it are archived then, once their repos have a complete poll since their last change. A slot missed while the daemon was down is applied on the next tick.") }).prefault({}),
440
+ digest: z.strictObject({ tz: z.string().refine(isTimeZone, "Unknown IANA time zone").describe("IANA time zone, such as Europe/Berlin, for the archive.doneWeekday slot and the times shown in resolved feed lines.") }),
441
+ commands: z.strictObject({ retentionDays: z.int().min(1).default(7).describe("Days the board keeps each caller's mutation --key with its input and result. In that time the same caller and key with the same input returns the stored result, and with a different input the call is refused. A daily job deletes older keys.") }).prefault({}),
411
442
  doorbells: z.strictObject({
412
443
  firstRetryMs: durationMs(12e4, "Wait after the first unanswered doorbell"),
413
444
  secondRetryMs: durationMs(3e5, "Wait after the second unanswered doorbell"),
@@ -648,6 +679,13 @@ const ERRORS = {
648
679
  hint: "In Dev, ask with `board ask` instead.",
649
680
  recovery: noRetry("In Dev, ask with a block instead of returning the task.")
650
681
  }),
682
+ move_not_allowed: spec("move_not_allowed", {
683
+ status: 409,
684
+ exit: EXIT_CODES.refused,
685
+ message: "The task cannot be corrected to that column.",
686
+ hint: "Read why with `board task <KEY> --why`; pick an enabled column, and unlink a merged pull request with `board unlink` first.",
687
+ recovery: noRetry("Read why the task is where it is; pick an enabled column, and unlink a merged pull request first.")
688
+ }),
651
689
  task_archived: spec("task_archived", {
652
690
  status: 409,
653
691
  exit: EXIT_CODES.refused,
@@ -1106,6 +1144,24 @@ const unknownSessionHealthSchema = z.string().min(1).brand();
1106
1144
  const unknownSessionStatusSchema = z.string().min(1).brand();
1107
1145
  const knownHealth = z.enum(SESSION_HEALTH_STATES);
1108
1146
  const knownStatus = z.enum(SESSION_STATUSES);
1147
+ const queuedRingSchema = z.strictObject({
1148
+ notification: z.int().positive().describe("Board notification the queued ring belongs to."),
1149
+ ring: z.int().positive().describe("Ring number within that notification series.")
1150
+ }).describe("One board ring waiting in the session queue.");
1151
+ /** The marker that ends a board ring text: `(N<notification>-<ring>)`. */
1152
+ function ringMarker(notification, ring) {
1153
+ return `(N${String(notification)}-${String(ring)})`;
1154
+ }
1155
+ /** The notification and ring a text ends with, or null when it ends with no valid marker. */
1156
+ function parseRingMarker(text) {
1157
+ const match = /\(N([1-9]\d*)-([1-9]\d*)\)$/.exec(text);
1158
+ if (!match) return null;
1159
+ const parsed = queuedRingSchema.safeParse({
1160
+ notification: Number(match[1]),
1161
+ ring: Number(match[2])
1162
+ });
1163
+ return parsed.success ? parsed.data : null;
1164
+ }
1109
1165
  const sessionFactsSchema = z.strictObject({
1110
1166
  id: actorPartSchema.describe("Spur session name."),
1111
1167
  spurProject: actorPartSchema.describe("Spur project the session belongs to."),
@@ -1117,7 +1173,8 @@ const sessionFactsSchema = z.strictObject({
1117
1173
  healthSince: at$2.describe("When the current health value began to hold, as the adapter observed it; health durations count from here."),
1118
1174
  lastActivityAt: at$2.nullable().describe("When the session last showed activity, or null."),
1119
1175
  endedAt: at$2.nullable().describe("When the session ended, or null while it is live. The adapter supplies it: Spur keeps no end time."),
1120
- endReason: z.enum(SESSION_END_REASONS).nullable().describe("Why the session ended, or null while it is live. Set together with endedAt.")
1176
+ endReason: z.enum(SESSION_END_REASONS).nullable().describe("Why the session ended, or null while it is live. Set together with endedAt."),
1177
+ queuedRings: z.array(queuedRingSchema).min(1).optional().describe("Board rings still waiting in the session queue, undelivered. Only board rings are listed, never other queued text; absent when none.")
1121
1178
  }).superRefine((session, ctx) => {
1122
1179
  if (session.endedAt === null !== (session.endReason === null)) ctx.addIssue({
1123
1180
  code: "custom",
@@ -1151,6 +1208,7 @@ const EVENT_KINDS = [
1151
1208
  "task_submitted",
1152
1209
  "task_moved",
1153
1210
  "task_shadow_moved",
1211
+ "task_corrected",
1154
1212
  "dispatcher_mode_changed",
1155
1213
  "block_opened",
1156
1214
  "block_escalated",
@@ -1304,6 +1362,12 @@ const eventPayloadSchemas = {
1304
1362
  reason: z.enum(MOVE_REASONS),
1305
1363
  gate: z.array(z.enum(GATE_REASONS)).optional()
1306
1364
  }),
1365
+ task_corrected: z.looseObject({
1366
+ from: z.enum(COLUMN_IDS),
1367
+ to: z.enum(COLUMN_IDS),
1368
+ reason: S,
1369
+ shadow: z.boolean()
1370
+ }),
1307
1371
  dispatcher_mode_changed: z.looseObject({
1308
1372
  from: z.enum(DISPATCHER_MODES),
1309
1373
  to: z.enum(DISPATCHER_MODES)
@@ -1764,6 +1828,46 @@ const turnViewSchema = z.strictObject({
1764
1828
  at: z.iso.datetime().describe("When the turn was taken, ISO 8601 UTC.")
1765
1829
  }).nullable().describe("Who took the turn and when; null until it is taken.")
1766
1830
  }).describe("A turn: the executor of a column is asked to act on a task.");
1831
+ /** One column move from the journal: a dispatcher move, a return to Dev or a correction. */
1832
+ const moveViewSchema = z.strictObject({
1833
+ at: z.iso.datetime().describe("When the task moved, ISO 8601 UTC."),
1834
+ kind: z.enum([
1835
+ "task_moved",
1836
+ "task_shadow_moved",
1837
+ "task_corrected"
1838
+ ]).describe("task_moved moves the column, task_shadow_moved only the shadow column, task_corrected is an operator correction."),
1839
+ actor: actorIdSchema,
1840
+ from: z.enum(COLUMN_IDS).describe("Column the task left."),
1841
+ to: z.enum(COLUMN_IDS).describe("Column the task entered."),
1842
+ reason: z.enum([
1843
+ ...MOVE_REASONS,
1844
+ "returned",
1845
+ "corrected"
1846
+ ]).describe("Why it moved: a dispatcher reason, returned (a column executor returned it to Dev) or corrected (the operator corrected the column)."),
1847
+ gate: z.array(z.enum(GATE_REASONS)).describe("The failing gate reasons of a gate_broken move; empty otherwise."),
1848
+ text: z.string().nullable().describe("The block a return opened, or the reason the operator gave for a correction; null otherwise.")
1849
+ }).describe("A column move of a task.");
1850
+ const gateConditionSchema = z.strictObject({
1851
+ condition: z.enum(GATE_CONDITIONS).describe("Exit condition of the column."),
1852
+ state: z.enum(GATE_CONDITION_STATES).describe("met; failed; waiting (fails on a fact not known yet); unchecked (an earlier condition failed first)."),
1853
+ reason: z.enum(GATE_REASONS).nullable().describe("The gate reason a failed or waiting condition reports; null otherwise.")
1854
+ }).describe("One exit condition of a column and its state.");
1855
+ /** Why a task is where it is, from the dispatcher's point of view. */
1856
+ const taskWhySchema = z.strictObject({
1857
+ column: z.enum(COLUMN_IDS).describe("Column the dispatcher works from: the shadow column in shadow mode."),
1858
+ dispatcher: z.enum(DISPATCHER_MODES).nullable().describe("The project's dispatcher mode; null when the project is not configured."),
1859
+ holds: z.array(z.enum(TASK_HOLDS)).describe("What holds the dispatcher from acting on the task; empty when nothing does."),
1860
+ gates: z.array(z.strictObject({
1861
+ column: z.enum(COLUMN_IDS).describe("Board column."),
1862
+ enabled: z.boolean().describe("Whether the column is enabled in the project."),
1863
+ ok: z.boolean().describe("Whether the column's own exit conditions pass."),
1864
+ blockedIn: z.enum(COLUMN_IDS).nullable().describe("Leftmost enabled column at or left of this one whose exit conditions fail; null when the cumulative gate passes."),
1865
+ conditions: z.array(gateConditionSchema).describe("The column's exit conditions, empty for a column without any.")
1866
+ }).describe("The gate of one column.")).describe("The gate of every column, To Do to Done; empty when the pull request facts are missing."),
1867
+ checksWaivedBy: z.literal("reposWithoutCi").nullable().describe("The config key that passed Dev's check condition for a repo without checks; null otherwise."),
1868
+ turn: turnViewSchema.nullable().describe("The open turn of the task; null when none is open."),
1869
+ moves: z.array(moveViewSchema).describe("The last 5 column moves, oldest first.")
1870
+ }).describe("Why the task is in its column and what the dispatcher waits for.");
1767
1871
  const itemViewSchema = z.strictObject({
1768
1872
  id: itemIdSchema,
1769
1873
  task: taskKeySchema.nullable().describe("Task the item is about; null for a board-wide item."),
@@ -1981,6 +2085,93 @@ const item = {
1981
2085
  at,
1982
2086
  summary: "Deploy of PROJ-123 failed."
1983
2087
  };
2088
+ const met = (condition) => ({
2089
+ condition,
2090
+ state: "met",
2091
+ reason: null
2092
+ });
2093
+ const failed = (condition, reason) => ({
2094
+ condition,
2095
+ state: "failed",
2096
+ reason
2097
+ });
2098
+ /**
2099
+ * The gates of a task in Review on a project with To Do, Dev, Review and Done enabled: Dev passes,
2100
+ * Review waits for its review on head.
2101
+ */
2102
+ const reviewGates = [
2103
+ {
2104
+ column: "todo",
2105
+ enabled: true,
2106
+ ok: true,
2107
+ blockedIn: null,
2108
+ conditions: []
2109
+ },
2110
+ {
2111
+ column: "ready-for-dev",
2112
+ enabled: false,
2113
+ ok: true,
2114
+ blockedIn: null,
2115
+ conditions: []
2116
+ },
2117
+ {
2118
+ column: "dev",
2119
+ enabled: true,
2120
+ ok: true,
2121
+ blockedIn: null,
2122
+ conditions: [
2123
+ met("pr_open"),
2124
+ met("not_draft"),
2125
+ met("checks_green"),
2126
+ met("no_conflict"),
2127
+ met("external_comments_handled"),
2128
+ met("comment_history_read"),
2129
+ met("submit_on_head")
2130
+ ]
2131
+ },
2132
+ {
2133
+ column: "review",
2134
+ enabled: true,
2135
+ ok: false,
2136
+ blockedIn: "review",
2137
+ conditions: [failed("review_on_head", "no_review_on_head")]
2138
+ },
2139
+ {
2140
+ column: "product-review",
2141
+ enabled: false,
2142
+ ok: false,
2143
+ blockedIn: "review",
2144
+ conditions: [failed("review_on_head", "no_review_on_head")]
2145
+ },
2146
+ {
2147
+ column: "external-review",
2148
+ enabled: false,
2149
+ ok: false,
2150
+ blockedIn: "review",
2151
+ conditions: [failed("approved", "not_approved")]
2152
+ },
2153
+ {
2154
+ column: "qa",
2155
+ enabled: false,
2156
+ ok: false,
2157
+ blockedIn: "review",
2158
+ conditions: [failed("submit_on_head", "no_submit_on_head")]
2159
+ },
2160
+ {
2161
+ column: "ready-to-merge",
2162
+ enabled: false,
2163
+ ok: false,
2164
+ blockedIn: "review",
2165
+ conditions: [failed("merged", "not_merged")]
2166
+ },
2167
+ {
2168
+ column: "done",
2169
+ enabled: true,
2170
+ ok: true,
2171
+ blockedIn: "review",
2172
+ conditions: []
2173
+ }
2174
+ ];
1984
2175
  const taskOutput = z.strictObject({ task: taskViewSchema });
1985
2176
  const blockOutput = z.strictObject({ block: blockViewSchema });
1986
2177
  const itemOutput = z.strictObject({ item: itemViewSchema });
@@ -2099,12 +2290,16 @@ const OPERATIONS = [
2099
2290
  whenToUse: "Inspect one task now.",
2100
2291
  whenNotToUse: "Use task_history for past events."
2101
2292
  },
2102
- input: z.strictObject({ task: taskKeySchema }),
2293
+ input: z.strictObject({
2294
+ task: taskKeySchema,
2295
+ why: z.boolean().optional().describe("Explain why the task is in its column: gates, holds, the open turn and the last moves; absent means no explanation.")
2296
+ }),
2103
2297
  output: z.strictObject({
2104
2298
  task: taskViewSchema,
2105
2299
  links: z.array(linkViewSchema).describe("Effective pull request, session, and ticket links."),
2106
2300
  blocks: z.array(blockViewSchema).describe("Blocks on the task, open and unblocked."),
2107
- comments: z.array(commentSchema).describe("Comments on the task, oldest first.")
2301
+ comments: z.array(commentSchema).describe("Comments on the task, oldest first."),
2302
+ why: taskWhySchema.optional().describe("Present only with why.")
2108
2303
  }),
2109
2304
  grants: operatorOrProjectAgent,
2110
2305
  errors: ["wrong_id_kind", "not_found"],
@@ -2114,7 +2309,7 @@ const OPERATIONS = [
2114
2309
  },
2115
2310
  slack: {
2116
2311
  kind: "slash-command",
2117
- usage: "/board task <KEY>"
2312
+ usage: "/board task <KEY> [why]"
2118
2313
  },
2119
2314
  examples: [{
2120
2315
  summary: "Show one task",
@@ -2125,6 +2320,46 @@ const OPERATIONS = [
2125
2320
  blocks: [question],
2126
2321
  comments: [comment]
2127
2322
  }
2323
+ }, {
2324
+ summary: "Explain why a task waits in Review",
2325
+ input: {
2326
+ task: "PROJ-123",
2327
+ why: true
2328
+ },
2329
+ output: {
2330
+ task: {
2331
+ ...task,
2332
+ column: "review"
2333
+ },
2334
+ links: [],
2335
+ blocks: [],
2336
+ comments: [],
2337
+ why: {
2338
+ column: "review",
2339
+ dispatcher: "on",
2340
+ holds: [],
2341
+ gates: reviewGates,
2342
+ checksWaivedBy: null,
2343
+ turn: {
2344
+ ...reviewTurn,
2345
+ handed: [],
2346
+ taken: {
2347
+ by: "agent:rev/rev-1",
2348
+ at
2349
+ }
2350
+ },
2351
+ moves: [{
2352
+ at,
2353
+ kind: "task_moved",
2354
+ actor: "system",
2355
+ from: "dev",
2356
+ to: "review",
2357
+ reason: "gate_passed",
2358
+ gate: [],
2359
+ text: null
2360
+ }]
2361
+ }
2362
+ }
2128
2363
  }]
2129
2364
  }),
2130
2365
  defineOperation({
@@ -3042,6 +3277,85 @@ const OPERATIONS = [
3042
3277
  }
3043
3278
  }
3044
3279
  }]
3280
+ }),
3281
+ defineOperation({
3282
+ id: "task.move",
3283
+ kind: "mutation",
3284
+ description: "Correct the column of a task by hand; the gates then settle the task from that column at once.",
3285
+ mcp: {
3286
+ whenToUse: "Put a task the board moved wrongly into the right column, Done excluded; the reply names the column it settled in.",
3287
+ whenNotToUse: "Use task_get with why to read why the task is where it is."
3288
+ },
3289
+ input: z.discriminatedUnion("mode", [z.strictObject({
3290
+ mode: z.literal("correct").describe("Correct a wrong column by hand."),
3291
+ task: taskKeySchema,
3292
+ column: z.enum(COLUMN_IDS).exclude(["done"]).describe("Enabled column to put the task in; Done is reached only from the facts."),
3293
+ reason: text("Why the column is corrected, kept in the journal.")
3294
+ })]),
3295
+ output: z.strictObject({
3296
+ task: taskViewSchema,
3297
+ from: z.enum(COLUMN_IDS).describe("Column the dispatcher worked from before the correction."),
3298
+ to: z.enum(COLUMN_IDS).describe("Column the correction put the task in."),
3299
+ column: z.enum(COLUMN_IDS).describe("Column the gates settled the task in; the shadow column while the dispatcher is in shadow mode."),
3300
+ settled: z.array(moveViewSchema).describe("The dispatcher moves from the corrected column, oldest first.")
3301
+ }),
3302
+ grants: operatorOnly,
3303
+ errors: [
3304
+ "wrong_id_kind",
3305
+ "not_found",
3306
+ "task_archived",
3307
+ "move_not_allowed"
3308
+ ],
3309
+ cli: {
3310
+ command: "move",
3311
+ args: ["task", "column"],
3312
+ modes: [{
3313
+ mode: "correct",
3314
+ flag: "--correct",
3315
+ value: null
3316
+ }]
3317
+ },
3318
+ slack: null,
3319
+ examples: [{
3320
+ summary: "Correct a task the board put in Done by mistake",
3321
+ input: {
3322
+ mode: "correct",
3323
+ task: "PROJ-123",
3324
+ column: "dev",
3325
+ reason: "The linked pull request belongs to another ticket."
3326
+ },
3327
+ output: {
3328
+ task,
3329
+ from: "done",
3330
+ to: "dev",
3331
+ column: "dev",
3332
+ settled: []
3333
+ }
3334
+ }, {
3335
+ summary: "Correct a task into Review while its Dev gate is broken",
3336
+ input: {
3337
+ mode: "correct",
3338
+ task: "PROJ-123",
3339
+ column: "review",
3340
+ reason: "The review was done outside the board."
3341
+ },
3342
+ output: {
3343
+ task,
3344
+ from: "dev",
3345
+ to: "review",
3346
+ column: "dev",
3347
+ settled: [{
3348
+ at,
3349
+ kind: "task_moved",
3350
+ actor: "system",
3351
+ from: "review",
3352
+ to: "dev",
3353
+ reason: "gate_broken",
3354
+ gate: ["external_comments"],
3355
+ text: null
3356
+ }]
3357
+ }
3358
+ }]
3045
3359
  })
3046
3360
  ];
3047
3361
  //#endregion
@@ -3290,4 +3604,4 @@ function assertNever(value) {
3290
3604
  throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
3291
3605
  }
3292
3606
  //#endregion
3293
- export { SLACK_BOT_SCOPES as $, ticketFactsSchema as A, errorEnvelopeSchema as B, REVIEW_STATES as C, prFactsSchema as D, isExternalAuthor as E, parseRef as F, DEFAULT_SLACK_APP_NAME as G, successEnvelopeSchema as H, taskKeySchema as I, configSchema as J, DEFAULT_SLACK_COMMAND as K, ERRORS as L, encodeActorId as M, errorCodeOf as N, prRefSchema as O, parseActorId as P, DISPATCHER_MODES as Q, err as R, eventPayloadSchemas as S, SESSION_STATUSES as T, DEFAULT_HTTP_PORT as U, ok as V, DEFAULT_LINK as W, requiredSecretKeys as X, plainHttpAllowed as Y, COLUMN_IDS as Z, inboundEventSchema as _, batchSchema as a, userIdSchema as b, buildCatalogSnapshot as c, turnHandedSchema as d, renderHttpProblem as f, conversationRefSchema as g, SPACE_IDS as h, AdapterError as i, actorIdSchema as j, sessionFactsSchema as k, roleCanUseOperation as l, renderMcpError as m, BOARD_TICK_MS as n, entityRefSchema as o, renderJsonError as p, RESERVED_PROJECT as q, SYSTEMD_SERVICE_SETTINGS as r, sourceCursorSchema as s, assertNever as t, OPERATIONS as u, interactionRefSchema as v, SESSION_HEALTH_STATES as w, EVENT_KINDS as x, messageRefSchema as y, errorContextSchema as z };
3607
+ export { COLUMN_IDS as $, ringMarker as A, err as B, REVIEW_STATES as C, parseRingMarker as D, isExternalAuthor as E, errorCodeOf as F, DEFAULT_HTTP_PORT as G, errorEnvelopeSchema as H, parseActorId as I, DEFAULT_SLACK_COMMAND as J, DEFAULT_LINK as K, parseRef as L, ticketFactsSchema as M, actorIdSchema as N, prFactsSchema as O, encodeActorId as P, requiredSecretKeys as Q, taskKeySchema as R, eventPayloadSchemas as S, SESSION_STATUSES as T, ok as U, errorContextSchema as V, successEnvelopeSchema as W, configSchema as X, RESERVED_PROJECT as Y, plainHttpAllowed as Z, inboundEventSchema as _, batchSchema as a, userIdSchema as b, buildCatalogSnapshot as c, turnHandedSchema as d, DISPATCHER_MODES as et, renderHttpProblem as f, conversationRefSchema as g, SPACE_IDS as h, AdapterError as i, sessionFactsSchema as j, prRefSchema as k, roleCanUseOperation as l, renderMcpError as m, BOARD_TICK_MS as n, entityRefSchema as o, renderJsonError as p, DEFAULT_SLACK_APP_NAME as q, SYSTEMD_SERVICE_SETTINGS as r, sourceCursorSchema as s, assertNever as t, SLACK_BOT_SCOPES as tt, OPERATIONS as u, interactionRefSchema as v, SESSION_HEALTH_STATES as w, EVENT_KINDS as x, messageRefSchema as y, ERRORS as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -16,7 +16,7 @@ Other errors: `not_found`.
16
16
 
17
17
  Purpose: Show a task with its links, blocks and comments.
18
18
  Arguments: `<task>`.
19
- Flags: `--json`.
19
+ Flags: `--why`, `--json`.
20
20
  Use when: Inspect one task now.
21
21
  Avoid when: Use `board task history <task>` for past events.
22
22
  Example: `board task PROJ-123` — Show one task.