spur-board 0.170.3 → 0.171.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.
@@ -1,4 +1,4 @@
1
- import { d as tokenRequestStatusSchema, gt as errorEnvelopeSchema, ht as errorContextSchema, l as tokenRequestResultSchema, pt as ERRORS, vt as successEnvelopeSchema, x as renderJsonError } from "./chunk-CljtkzXu.mjs";
1
+ import { d as tokenRequestStatusSchema, gt as errorEnvelopeSchema, ht as errorContextSchema, l as tokenRequestResultSchema, pt as ERRORS, vt as successEnvelopeSchema, x as renderJsonError } from "./chunk-CqjDrIzS.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -254,6 +254,27 @@ const TASK_HOLDS = [
254
254
  "cycle_limit",
255
255
  "work_not_started"
256
256
  ];
257
+ /**
258
+ * What a task waits for, as `board task --why` names it in `why.waitsFor`: an open turn, a merge,
259
+ * a human approval, the ticket, CI checks, GitHub, Spur, the board itself, an answer to a block,
260
+ * work to start or end, a failing gate, nothing (`done`, `archived`), or the project config.
261
+ */
262
+ const WAITS_FOR_KINDS = [
263
+ "turn",
264
+ "merge",
265
+ "approval",
266
+ "ticket",
267
+ "checks",
268
+ "github",
269
+ "spur",
270
+ "board",
271
+ "answer",
272
+ "work",
273
+ "gate",
274
+ "done",
275
+ "archived",
276
+ "config"
277
+ ];
257
278
  /** Every operator item kind; core's `ITEM_POLICY` gives each one a policy. */
258
279
  const ITEM_KINDS = [
259
280
  "token_request",
@@ -3016,6 +3037,7 @@ function defineOperation(spec) {
3016
3037
  const mutation = spec.kind === "mutation";
3017
3038
  for (const mode of [...spec.explicitKeyModes ?? [], ...spec.cli.defaultMode === void 0 ? [] : [spec.cli.defaultMode]]) if (!spec.cli.modes?.some((entry) => entry.mode === mode)) throw new Error(`Unknown mode ${mode} in ${spec.id}.`);
3018
3039
  if (!mutation && spec.explicitKeyModes?.length) throw new Error("Only mutations require explicit keys.");
3040
+ if (spec.cli.view !== void 0) checkView(spec.id, spec.input, spec.cli.modes ?? [], spec.cli.view);
3019
3041
  const order = Object.keys(ERRORS);
3020
3042
  const errors = [.../* @__PURE__ */ new Set([
3021
3043
  ...COMMON_ERRORS,
@@ -3032,7 +3054,8 @@ function defineOperation(spec) {
3032
3054
  args: spec.cli.args,
3033
3055
  modes: spec.cli.modes ?? null,
3034
3056
  ...spec.cli.defaultMode === void 0 ? {} : { defaultMode: spec.cli.defaultMode },
3035
- key: mutation ? "--key" : null
3057
+ key: mutation ? "--key" : null,
3058
+ ...spec.cli.view === void 0 ? {} : { view: spec.cli.view }
3036
3059
  },
3037
3060
  mcp: {
3038
3061
  name: spec.id.replace(".", "_"),
@@ -3042,6 +3065,24 @@ function defineOperation(spec) {
3042
3065
  }
3043
3066
  };
3044
3067
  }
3068
+ /** The CLI flag of an input field: `--` and the field name in kebab case. */
3069
+ const fieldFlag = (field) => `--${field.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
3070
+ /**
3071
+ * A CLI view reads a boolean input field and binds a flag no input field, mode, `--key` or
3072
+ * `--json` already takes.
3073
+ */
3074
+ function checkView(id, input, modes, view) {
3075
+ const fields = (input instanceof z.ZodDiscriminatedUnion ? input.options : [input]).flatMap((shape) => Object.entries(shape.shape));
3076
+ const when = fields.filter(([name]) => name === view.when).map(([, schema]) => schema);
3077
+ const boolean = (schema) => (schema instanceof z.ZodOptional ? schema.unwrap() : schema) instanceof z.ZodBoolean;
3078
+ if (when.length === 0 || !when.every(boolean)) throw new Error(`CLI view of ${id} needs a boolean input field ${view.when}.`);
3079
+ if ((/* @__PURE__ */ new Set([
3080
+ ...fields.map(([name]) => fieldFlag(name)),
3081
+ ...modes.map((mode) => mode.flag),
3082
+ "--key",
3083
+ "--json"
3084
+ ])).has(view.hide.flag)) throw new Error(`CLI view flag ${view.hide.flag} of ${id} is already taken.`);
3085
+ }
3045
3086
  // ../contracts/src/ops/turn-schemas.ts
3046
3087
  /** One pull request comment or review a turn handed to its executor. */
3047
3088
  const turnHandedSchema = z.strictObject({
@@ -3233,6 +3274,11 @@ const gateConditionSchema = z.strictObject({
3233
3274
  }).describe("One exit condition of a column and its state.");
3234
3275
  /** Why a task is where it is, from the dispatcher's point of view. */
3235
3276
  const taskWhySchema = z.strictObject({
3277
+ waitsFor: z.strictObject({
3278
+ kind: z.enum(WAITS_FOR_KINDS).describe("What the task waits for, e.g. turn or merge."),
3279
+ text: z.string().describe("The wait in one line; ends with (<actor>) when one acts next."),
3280
+ actor: z.enum([...ADDRESSEE_ROLES, "human"]).nullable().describe("Who acts next: a role, human on GitHub, or null for the board, GitHub or Spur.")
3281
+ }).optional().describe("What the task waits for and who acts next; absent only from an older daemon."),
3236
3282
  column: z.enum(COLUMN_IDS).describe("Column the dispatcher works from: the shadow column in shadow mode."),
3237
3283
  dispatcher: z.enum(DISPATCHER_MODES).nullable().describe("The project's dispatcher mode; null when the project is not configured."),
3238
3284
  holds: z.array(z.enum(TASK_HOLDS)).describe("What holds the dispatcher from acting on the task; empty when nothing does."),
@@ -3253,8 +3299,9 @@ const taskWhySchema = z.strictObject({
3253
3299
  enabled: z.boolean().describe("Whether the column is enabled in the project."),
3254
3300
  ok: z.boolean().describe("Whether the column's own exit conditions pass. Dev's threads_resolved counts once any enabled column requires resolved threads, while the gates left of that column ignore it."),
3255
3301
  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."),
3256
- conditions: z.array(gateConditionSchema).describe("The column's exit conditions, empty for a column without any.")
3257
- }).describe("The gate of one column.")).describe("The gate of every column, To Do to Done; empty when the pull request facts are missing."),
3302
+ conditions: z.array(gateConditionSchema).describe("The column's exit conditions, empty for a column without any."),
3303
+ waitsFor: z.string().optional().describe("What an enabled Done gate, or the To Do group gate the task sits in, waits for; absent otherwise.")
3304
+ }).describe("The gate of one column.")).describe("The gate of every column, To Do to Done; empty when the pull request facts are missing. A terminal leaves out disabled columns unless --all; JSON lists every column."),
3258
3305
  checksWaivedBy: z.literal("reposWithoutCi").nullable().describe("The config key that passed Dev's check condition for a repo without checks; null otherwise."),
3259
3306
  turn: turnViewSchema.nullable().describe("The open turn of the task; null when none is open."),
3260
3307
  moves: z.array(moveViewSchema).describe("The last 5 column moves, oldest first."),
@@ -3834,7 +3881,7 @@ const taskGetInputSchema = z.strictObject({
3834
3881
  task: taskKeyInputSchema,
3835
3882
  refresh: z.boolean().optional().describe("Read every linked pull request from GitHub before showing the task; unavailable reads fail visibly."),
3836
3883
  detail: z.boolean().optional().describe("Also list the last 5 closed turns, newest first; absent means none."),
3837
- 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.")
3884
+ why: z.boolean().optional().describe("Explain why the task is in its column: what it waits for, gates, holds, the open turn and the last moves; absent means no explanation.")
3838
3885
  });
3839
3886
  const taskGetOutputSchema = z.strictObject({
3840
3887
  submission: latestSubmissionSchema,
@@ -4140,7 +4187,8 @@ const reviewGates = [
4140
4187
  enabled: true,
4141
4188
  ok: true,
4142
4189
  blockedIn: "review",
4143
- conditions: []
4190
+ conditions: [],
4191
+ waitsFor: "merge of example/web#9, then the ticket to close"
4144
4192
  }
4145
4193
  ];
4146
4194
  const taskOutput = z.strictObject({ task: taskViewSchema });
@@ -4328,7 +4376,7 @@ const OPERATIONS = [
4328
4376
  kind: "query",
4329
4377
  description: "Show a task; refresh reads GitHub PRs.",
4330
4378
  mcp: {
4331
- whenToUse: "Inspect a task; detail adds closed turns.",
4379
+ whenToUse: "Inspect a task; why starts with what it waits for, detail adds closed turns.",
4332
4380
  whenNotToUse: "Use task_history for past events."
4333
4381
  },
4334
4382
  input: taskGetInputSchema,
@@ -4341,7 +4389,24 @@ const OPERATIONS = [
4341
4389
  ],
4342
4390
  cli: {
4343
4391
  command: "task",
4344
- args: ["task"]
4392
+ args: ["task"],
4393
+ view: {
4394
+ when: "why",
4395
+ lead: {
4396
+ label: "waits for",
4397
+ path: [
4398
+ "why",
4399
+ "waitsFor",
4400
+ "text"
4401
+ ]
4402
+ },
4403
+ hide: {
4404
+ path: ["why", "gates"],
4405
+ field: "enabled",
4406
+ flag: "--all",
4407
+ description: "With --why on a terminal, also list the gates of disabled columns; JSON always lists every column."
4408
+ }
4409
+ }
4345
4410
  },
4346
4411
  slack: {
4347
4412
  kind: "slash-command",
@@ -4396,6 +4461,11 @@ const OPERATIONS = [
4396
4461
  blocks: [],
4397
4462
  comments: [],
4398
4463
  why: {
4464
+ waitsFor: {
4465
+ kind: "turn",
4466
+ text: "Review turn T4 (orchestrator:review)",
4467
+ actor: "orchestrator:review"
4468
+ },
4399
4469
  column: "review",
4400
4470
  dispatcher: "on",
4401
4471
  holds: [],
@@ -1,5 +1,5 @@
1
- import { It as slackConfigured, Mt as plainHttpAllowed, g as OPERATIONS, kt as configSchema, m as buildCatalogSnapshot } from "./chunk-CljtkzXu.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-d2uszLEI.mjs";
1
+ import { It as slackConfigured, Mt as plainHttpAllowed, g as OPERATIONS, kt as configSchema, m as buildCatalogSnapshot } from "./chunk-CqjDrIzS.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-BRiD3EcI.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/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { Ct as DEFAULT_STAND_PORT_RANGE, Ft as resolveWebOrigin, It as slackConfigured, Pt as requiredSecretKeys, Ut as SLACK_BOT_SCOPES, c as requestHashOf, ct as actorIdSchema, g as OPERATIONS, h as roleCanUseOperation, j as sortSkillFiles, k as skillReloadFileSchema, kt as configSchema, n as SLACK_OFF_FIX, o as remoteDoctorReportSchema, p as SYSTEMD_SERVICE_SETTINGS, pt as ERRORS, r as SLACK_PARTLY_FIX, vt as successEnvelopeSchema } from "./chunk-CljtkzXu.mjs";
1
+ import { Ct as DEFAULT_STAND_PORT_RANGE, Ft as resolveWebOrigin, It as slackConfigured, Pt as requiredSecretKeys, Ut as SLACK_BOT_SCOPES, c as requestHashOf, ct as actorIdSchema, g as OPERATIONS, h as roleCanUseOperation, j as sortSkillFiles, k as skillReloadFileSchema, kt as configSchema, n as SLACK_OFF_FIX, o as remoteDoctorReportSchema, p as SYSTEMD_SERVICE_SETTINGS, pt as ERRORS, r as SLACK_PARTLY_FIX, vt as successEnvelopeSchema } from "./chunk-CqjDrIzS.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
- import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-d2uszLEI.mjs";
4
- import { a as memoryVerdictCache, c as dataDirectory, d as readConfiguredPort, f as resolveDaemonAddress, i as fileVerdictCache, l as loadClientConfig, n as cliPackageVersion, o as boardSlackState, p as tokenInFolder, s as configFile, t as checkCatalog, u as loadEnrollmentConfig } from "./chunk-DbBNabCm.mjs";
3
+ import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-BRiD3EcI.mjs";
4
+ import { a as memoryVerdictCache, c as dataDirectory, d as readConfiguredPort, f as resolveDaemonAddress, i as fileVerdictCache, l as loadClientConfig, n as cliPackageVersion, o as boardSlackState, p as tokenInFolder, s as configFile, t as checkCatalog, u as loadEnrollmentConfig } from "./chunk-CqtrnYE5.mjs";
5
5
  import { createHash, randomBytes, randomUUID } from "node:crypto";
6
6
  import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
7
7
  import { homedir, hostname, tmpdir, userInfo } from "node:os";
@@ -2430,6 +2430,35 @@ function formatHuman(value, indent = 0) {
2430
2430
  }
2431
2431
  return `${prefix}${escapeTerminalControls(String(value))}`;
2432
2432
  }
2433
+ /** The value at `path` of a JSON result, or undefined when the path does not reach one. */
2434
+ function valueAt(value, path) {
2435
+ let current = value;
2436
+ for (const key of path) {
2437
+ if (current === null || typeof current !== "object" || Array.isArray(current)) return void 0;
2438
+ current = current[key];
2439
+ }
2440
+ return current;
2441
+ }
2442
+ /**
2443
+ * The result without the entries of the array at `path` whose `field` is false, keys in place.
2444
+ * A path that does not reach an array leaves the result as it is.
2445
+ */
2446
+ function withoutEntries(value, path, field) {
2447
+ const [key, ...rest] = path;
2448
+ if (key === void 0) return Array.isArray(value) ? value.filter((entry) => !(entry && typeof entry === "object" && entry[field] === false)) : value;
2449
+ if (value === null || typeof value !== "object" || Array.isArray(value) || !(key in value)) return value;
2450
+ const object = value;
2451
+ return {
2452
+ ...object,
2453
+ [key]: withoutEntries(object[key], rest, field)
2454
+ };
2455
+ }
2456
+ /** Terminal output shaped by a catalog `cli.view`: the lead line, then the result. */
2457
+ function formatView(result, view, all) {
2458
+ const lead = valueAt(result, view.lead.path);
2459
+ const body = formatHuman(all ? result : withoutEntries(result, view.hide.path, view.hide.field));
2460
+ return typeof lead === "string" ? `${escapeTerminalControls(view.lead.label)}: ${escapeTerminalControls(lead)}\n${body}` : body;
2461
+ }
2433
2462
  function commandFor(root, path) {
2434
2463
  let parent = root;
2435
2464
  for (const segment of path.split(" ")) {
@@ -2470,6 +2499,7 @@ function registerOptions(command, op) {
2470
2499
  const description = schema.description ?? bareSchema(schema).description ?? mode.value;
2471
2500
  command.option(`${mode.flag} ${value}`, description);
2472
2501
  }
2502
+ if (op.cli.view !== void 0) command.option(op.cli.view.hide.flag, op.cli.view.hide.description);
2473
2503
  if (op.kind === "mutation") command.option("--key <key>", "Idempotency key for this action.");
2474
2504
  command.option("--json", "Print JSON output or a JSON error.");
2475
2505
  }
@@ -2635,6 +2665,10 @@ function createProgram(options = {}) {
2635
2665
  const invoked = parts.at(-1);
2636
2666
  const json = Boolean(invoked.opts()["json"] || program.opts()["json"]);
2637
2667
  const input = buildInput(op, parts.slice(0, -1), invoked.opts());
2668
+ const view = op.cli.view;
2669
+ const viewOn = view !== void 0 && input[view.when] === true;
2670
+ const all = view !== void 0 && invoked.opts()[optionField(view.hide.flag)] === true;
2671
+ if (view !== void 0 && all && !viewOn) throw new CliError("usage", void 0, void 0, `${view.hide.flag} needs ${optionName(view.when)}.`);
2638
2672
  const keyOption = invoked.opts()["key"];
2639
2673
  if (op.explicitKeyModes?.includes(input["mode"] ?? "") && (typeof keyOption !== "string" || keyOption.trim() === "")) throw new CliError("usage", void 0, void 0, "Pass an explicit non-blank --key for this mode.");
2640
2674
  if (keyOption !== void 0 && (typeof keyOption !== "string" || keyOption === "")) throw new CliError("usage", void 0, void 0, "Pass a nonempty --key, or omit it to have one generated.");
@@ -2661,7 +2695,7 @@ function createProgram(options = {}) {
2661
2695
  try {
2662
2696
  if ("error" in outcome) throw outcome.error;
2663
2697
  const result = outcome.value;
2664
- io.stdout(`${json || !io.isTTY ? JSON.stringify(result) : formatHuman(result)}\n`);
2698
+ io.stdout(`${json || !io.isTTY ? JSON.stringify(result) : view !== void 0 && viewOn ? formatView(result, view, all) : formatHuman(result)}\n`);
2665
2699
  } catch (error) {
2666
2700
  if (error instanceof CliError) {
2667
2701
  io.stderr(`${renderCliError(error, json, key)}\n`);
@@ -2800,4 +2834,4 @@ async function runCli(argv, options = {}) {
2800
2834
  return errorExitCode(cliError);
2801
2835
  }
2802
2836
  }
2803
- export { createProgram, exampleCommand, runCli };
2837
+ export { createProgram, exampleCommand, formatView, runCli };
package/dist/client.mjs CHANGED
@@ -1 +1 @@
1
- export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-d2uszLEI.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-BRiD3EcI.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as prApprovalPairSchema, A as skillReloadFilesSchema, At as defaultAddressee, B as entityRefSchema, Bt as COLUMN_IDS, C as SPACE_IDS, D as messageRefSchema, Dt as columnTurnTimings, E as interactionRefSchema, Et as boardWideSpurProject, F as AdapterError, Ft as resolveWebOrigin, G as trackerSourceId, Gt as TODO_GROUP_COLUMN_IDS, H as prSourceId, Ht as ITEM_KINDS, I as MIRROR_FAILURES, It as slackConfigured, J as REVIEW_STATES, K as PR_STATES, Kt as VIAS, L as MIRROR_FAILURE_CODES, Lt as BLOCK_TYPES, M as EVENT_KINDS, Mt as plainHttpAllowed, N as GATE_REASONS, Nt as readyMirrorOf, O as userIdSchema, Ot as configBindings, P as eventPayloadSchemas, Pt as requiredSecretKeys, Q as parseRingMarker, R as batchSchema, Rt as COLUMNS, St as DEFAULT_SLACK_COMMAND, T as inboundEventSchema, Tt as approvalRuleOf, U as sessionTransitionSchema, Ut as SLACK_BOT_SCOPES, V as mirrorSourceId, Vt as DISPATCHER_MODES, W as sourceCursorSchema, Wt as TASK_HOLDS, X as SESSION_STATUSES, Y as SESSION_HEALTH_STATES, Z as isExternalAuthor, _ as defaultBranchViewSchema, _t as ok, a as doctorReportSchema, at as ticketFactsSchema, b as renderHttpProblem, bt as DEFAULT_LINK, c as requestHashOf, ct as actorIdSchema, d as tokenRequestStatusSchema, dt as parseActorId, et as prFactsSchema, f as BOARD_TICK_MS, ft as parseRef$1, g as OPERATIONS, h as roleCanUseOperation, i as SPUR_MIN_VERSION, it as sessionFactsSchema, j as sortSkillFiles, jt as externalQuietAfterMs, kt as configSchema, l as tokenRequestResultSchema, lt as encodeActorId, m as buildCatalogSnapshot, mt as err, n as SLACK_OFF_FIX, nt as prReviewRuleSchema, ot as JIRA_PROJECT_KEY, pt as ERRORS, q as REVIEW_DECISIONS, qt as isTodoGroupColumn, r as SLACK_PARTLY_FIX, rt as ringMarker, s as TOKEN_REQUEST_LIMITS, st as REF_NUMBER, t as assertNever, tt as prRefSchema, u as tokenRequestSchema, ut as errorCodeOf, v as inboxNoSessionSchema, vt as successEnvelopeSchema, w as conversationRefSchema, wt as RESERVED_PROJECT, y as turnHandedSchema, z as defaultBranchFactSchema, zt as COLUMN_GROUPS } from "./chunk-CljtkzXu.mjs";
1
+ import { $ as prApprovalPairSchema, A as skillReloadFilesSchema, At as defaultAddressee, B as entityRefSchema, Bt as COLUMN_IDS, C as SPACE_IDS, D as messageRefSchema, Dt as columnTurnTimings, E as interactionRefSchema, Et as boardWideSpurProject, F as AdapterError, Ft as resolveWebOrigin, G as trackerSourceId, Gt as TODO_GROUP_COLUMN_IDS, H as prSourceId, Ht as ITEM_KINDS, I as MIRROR_FAILURES, It as slackConfigured, J as REVIEW_STATES, K as PR_STATES, Kt as VIAS, L as MIRROR_FAILURE_CODES, Lt as BLOCK_TYPES, M as EVENT_KINDS, Mt as plainHttpAllowed, N as GATE_REASONS, Nt as readyMirrorOf, O as userIdSchema, Ot as configBindings, P as eventPayloadSchemas, Pt as requiredSecretKeys, Q as parseRingMarker, R as batchSchema, Rt as COLUMNS, St as DEFAULT_SLACK_COMMAND, T as inboundEventSchema, Tt as approvalRuleOf, U as sessionTransitionSchema, Ut as SLACK_BOT_SCOPES, V as mirrorSourceId, Vt as DISPATCHER_MODES, W as sourceCursorSchema, Wt as TASK_HOLDS, X as SESSION_STATUSES, Y as SESSION_HEALTH_STATES, Z as isExternalAuthor, _ as defaultBranchViewSchema, _t as ok, a as doctorReportSchema, at as ticketFactsSchema, b as renderHttpProblem, bt as DEFAULT_LINK, c as requestHashOf, ct as actorIdSchema, d as tokenRequestStatusSchema, dt as parseActorId, et as prFactsSchema, f as BOARD_TICK_MS, ft as parseRef$1, g as OPERATIONS, h as roleCanUseOperation, i as SPUR_MIN_VERSION, it as sessionFactsSchema, j as sortSkillFiles, jt as externalQuietAfterMs, kt as configSchema, l as tokenRequestResultSchema, lt as encodeActorId, m as buildCatalogSnapshot, mt as err, n as SLACK_OFF_FIX, nt as prReviewRuleSchema, ot as JIRA_PROJECT_KEY, pt as ERRORS, q as REVIEW_DECISIONS, qt as isTodoGroupColumn, r as SLACK_PARTLY_FIX, rt as ringMarker, s as TOKEN_REQUEST_LIMITS, st as REF_NUMBER, t as assertNever, tt as prRefSchema, u as tokenRequestSchema, ut as errorCodeOf, v as inboxNoSessionSchema, vt as successEnvelopeSchema, w as conversationRefSchema, wt as RESERVED_PROJECT, y as turnHandedSchema, z as defaultBranchFactSchema, zt as COLUMN_GROUPS } from "./chunk-CqjDrIzS.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -20628,7 +20628,12 @@ async function readInput(trx, task, project, mode, blind, config, clock) {
20628
20628
  mergedOpen,
20629
20629
  mergedPr,
20630
20630
  ticketUnconfirmed,
20631
- pending
20631
+ pending,
20632
+ prRef: pr === null ? null : {
20633
+ repo: pr.repo,
20634
+ number: pr.number,
20635
+ state: pr.state
20636
+ }
20632
20637
  };
20633
20638
  }
20634
20639
  async function applyShadow(trx, task, project, result, at) {
@@ -20853,6 +20858,162 @@ async function dispatchMergedTickets(trx, source, ctx) {
20853
20858
  if (project === void 0) return;
20854
20859
  await dispatchTasks(trx, (await trx.selectFrom("task").innerJoin("link", "link.task_id", "task.id").innerJoin("pr_snapshot", (join) => join.on(sql`lower(pr_snapshot.repo) = lower(link.repo)`).onRef("pr_snapshot.number", "=", "link.number")).select("task.id").distinct().where("task.project", "=", project.id).where("task.membership", "!=", "archived").where((eb) => eb.or([eb("task.column", "!=", "done"), eb("task.shadow_column", "!=", "done")])).where("link.entity", "=", "pr").where("link.banned", "=", 0).where("pr_snapshot.state", "=", "merged").where(pastReopenFloor).execute()).map((task) => task.id), ctx);
20855
20860
  }
20861
+ // ../core/src/domain/waits-for.ts
20862
+ const columnName = (column) => COLUMNS.find((entry) => entry.id === column)?.name ?? column;
20863
+ const refOf = (pr) => pr === null ? "the pull request" : `${pr.repo}#${String(pr.number)}`;
20864
+ const by = (actor) => actor === "human" ? "a human" : actor;
20865
+ const wait = (kind, text, actor = null) => ({
20866
+ kind,
20867
+ text: actor === null ? text : `${text} (${by(actor)})`,
20868
+ actor
20869
+ });
20870
+ /** The open turn, its actor the operator who took it over, and its holder's wait on one line. */
20871
+ function turnWait(turn) {
20872
+ const actor = turn.byOperator ? "operator" : turn.addressee;
20873
+ const line = wait("turn", `${columnName(turn.column)} turn ${turn.id}`, actor);
20874
+ if (turn.wait === void 0) return line;
20875
+ const until = `${turn.wait.wakesAt.slice(0, 16)}Z`;
20876
+ const reason = turn.wait.reason.replace(/\s+/g, " ").trim();
20877
+ return {
20878
+ ...line,
20879
+ text: `${line.text}, waiting until ${until} for ${reason}`
20880
+ };
20881
+ }
20882
+ const NEXT_PASS_TO_DONE = "the next dispatcher pass to move it to done";
20883
+ const TICKET_WITHOUT_WORK = "ticket to close, with no open PR and no live worker";
20884
+ /**
20885
+ * Whether completion, which bypasses every gate and turn, judges the task now: a done ticket, or a
20886
+ * merged PR the gates judge (an unconfirmed ticket holds the task before it).
20887
+ */
20888
+ const completes = (pr, work) => work.ticketDone || pr?.state === "merged";
20889
+ /**
20890
+ * What completion waits for, by the first unmet condition of `COMPLETION_RULE`: a merged PR or a
20891
+ * finished ticket with fresh polls moves the task. An open PR completes it once merged, or once
20892
+ * closed when no worker is live; a live worker otherwise blocks only the closed-ticket route.
20893
+ */
20894
+ function completionWait(pr, work) {
20895
+ if (COMPLETION_RULE.reason(pr, work) !== null) return [
20896
+ "board",
20897
+ NEXT_PASS_TO_DONE,
20898
+ null
20899
+ ];
20900
+ if (pr?.state === "open") return work.liveWorker ? [
20901
+ "merge",
20902
+ `merge of ${refOf(pr)}`,
20903
+ "human"
20904
+ ] : [
20905
+ "merge",
20906
+ `merge of ${refOf(pr)} or close it unmerged`,
20907
+ "human"
20908
+ ];
20909
+ if (work.hasOpenLinkedPr) return [
20910
+ "merge",
20911
+ "an open linked PR to merge or close",
20912
+ "human"
20913
+ ];
20914
+ if (work.liveWorker) return [
20915
+ "work",
20916
+ "the worker session to end, with no open PR",
20917
+ null
20918
+ ];
20919
+ return [
20920
+ "board",
20921
+ "fresh polls of Spur and every GitHub repository since the last change",
20922
+ null
20923
+ ];
20924
+ }
20925
+ /** What work start waits for: after a reopen only an open PR counts. */
20926
+ const workToStart = (work) => work.reopened ? [
20927
+ "work",
20928
+ "work to start: an open PR (the ticket was reopened)",
20929
+ null
20930
+ ] : [
20931
+ "work",
20932
+ "work to start: an open PR or a live worker",
20933
+ null
20934
+ ];
20935
+ /** The waits-for line of each fact GitHub or the board has not settled, by its gate reason. */
20936
+ const WAITING = {
20937
+ checks_pending: ({ head }) => wait("checks", `CI on ${head.slice(0, 8)}`),
20938
+ checks_red: ({ head }) => wait("checks", `green checks on ${head.slice(0, 8)}`),
20939
+ mergeable_unknown: ({ head }) => wait("github", `GitHub to compute mergeability on ${head.slice(0, 8)}`),
20940
+ comment_history_incomplete: ({ head }) => wait("board", `the board to read the full PR comment history on ${head.slice(0, 8)}`),
20941
+ merge_state_unknown: () => wait("github", "GitHub to compute the merge state"),
20942
+ review_rule_unreadable: () => wait("github", "the GitHub review rule for the base branch to be readable"),
20943
+ awaiting_required_reviewers: ({ reviewers }) => wait("approval", `review by ${(reviewers ?? []).join(", ")}`, "human"),
20944
+ review_rule_blocked: () => wait("approval", "the GitHub review rule to pass", "human"),
20945
+ changes_requested: (_entry, pr) => wait("approval", `a new review of the requested changes on ${refOf(pr)}`, "human")
20946
+ };
20947
+ /**
20948
+ * What stops the dispatcher before it judges the task, in its own order: `dispatch()` returns at
20949
+ * once while GitHub is blind or a submit is pending, and the pass skips a task whose ticket is not
20950
+ * confirmed after a merge (`app/dispatch.ts`).
20951
+ */
20952
+ function stopped(facts) {
20953
+ if (facts.work.githubBlind) return [
20954
+ "github",
20955
+ "GitHub to be readable",
20956
+ null
20957
+ ];
20958
+ if (facts.holds.includes("submit_pending")) return [
20959
+ "board",
20960
+ `confirmation of submit ${(facts.pendingSha ?? "").slice(0, 7)}`,
20961
+ null
20962
+ ];
20963
+ if (facts.holds.includes("ticket_unconfirmed")) return [
20964
+ "ticket",
20965
+ "ticket to close",
20966
+ null
20967
+ ];
20968
+ }
20969
+ /** What the task waits for: the first rung of the ladder that matches. */
20970
+ function waitsFor(facts) {
20971
+ if (facts.project === null) return wait("config", "the project in config.yaml", "operator");
20972
+ if (facts.archived) return wait("archived", "nothing while the task is archived; unarchive it to resume", "operator");
20973
+ if (facts.gate === null) return wait("board", "the first poll of the linked PR");
20974
+ const { holds, gate, column, project, pr } = facts;
20975
+ const stop = stopped(facts);
20976
+ if (stop !== void 0) return wait(...stop);
20977
+ if (column !== "done" && COMPLETION_RULE.reason(pr, facts.work) !== null) return wait("board", NEXT_PASS_TO_DONE);
20978
+ if (holds.includes("cycle_limit")) {
20979
+ const [first] = facts.heldBlocks;
20980
+ return first === void 0 ? wait("answer", "clearing of the cycle-limit or course-check item", "operator") : wait("answer", `answer to ${facts.heldBlocks.map((block) => block.id).join(", ")}`, first.addressee);
20981
+ }
20982
+ if (facts.turn !== null) return turnWait(facts.turn);
20983
+ if (holds.includes("spur_blind")) return wait("spur", "Spur to be readable");
20984
+ const [waiting] = facts.waiting;
20985
+ const fact = waiting === void 0 ? void 0 : WAITING[waiting.reason]?.(waiting, pr);
20986
+ if (fact !== void 0) return fact;
20987
+ if (column !== "done" && completes(pr, facts.work)) return wait(...completionWait(pr, facts.work));
20988
+ if (holds.includes("work_not_started")) return wait(...workToStart(facts.work));
20989
+ if (column === "done") return wait("done", "nothing, the task is done");
20990
+ if (gate.ok) {
20991
+ const next = nextColumn(project, column);
20992
+ if (next === void 0 || next === "done") return pr?.state === "open" ? wait("merge", `merge of ${refOf(pr)}`, "human") : wait("ticket", TICKET_WITHOUT_WORK);
20993
+ return wait("board", `the next dispatcher pass to move it to ${next}`);
20994
+ }
20995
+ if (gate.column === column) {
20996
+ if (column === "ready-to-merge" && gate.reasons.every((reason) => reason === "not_merged")) return wait("merge", `merge of ${refOf(pr)}`, "human");
20997
+ if (column === "external-review" && gate.reasons.includes("not_approved")) return wait("approval", `approval of ${refOf(pr)} by an external reviewer`, "human");
20998
+ return wait("gate", `${columnName(column)} exit: ${gate.reasons.join(", ")}`);
20999
+ }
21000
+ return wait("board", `the next dispatcher pass to move it back to ${gate.column}`);
21001
+ }
21002
+ /**
21003
+ * What one gate waits for when its conditions do not say it: the enabled Done gate of a task not
21004
+ * in Done, and the To Do group gate of the column a task sits in before work starts. The Done gate
21005
+ * names what stops the dispatcher first, so it never promises a pass that cannot act.
21006
+ */
21007
+ function gateWaitsFor(gate, facts) {
21008
+ if (facts.archived) return void 0;
21009
+ if (gate.column === "done" && gate.enabled && facts.column !== "done") {
21010
+ const stop = stopped(facts);
21011
+ if (stop !== void 0) return stop[1];
21012
+ if (completes(facts.pr, facts.work)) return completionWait(facts.pr, facts.work)[1];
21013
+ return facts.pr?.state === "open" ? `merge of ${refOf(facts.pr)}, then the ticket to close` : TICKET_WITHOUT_WORK;
21014
+ }
21015
+ if (isTodoGroupColumn(gate.column) && gate.column === facts.column && facts.holds.includes("work_not_started")) return (completes(facts.pr, facts.work) ? completionWait(facts.pr, facts.work) : workToStart(facts.work))[1];
21016
+ }
20856
21017
  // ../core/src/app/approval-watch.ts
20857
21018
  const [countedPair, notCountedPair] = prApprovalPairSchema.options;
20858
21019
  const storedSchema = z.union([countedPair.omit({
@@ -20952,6 +21113,17 @@ async function approvalViews(db, fact, watch) {
20952
21113
  };
20953
21114
  });
20954
21115
  }
21116
+ // ../core/src/app/hold-blocks.ts
21117
+ /**
21118
+ * The blocks of the active cycle-limit and course-check items that hold the task's turn, in item
21119
+ * order, with their addressees. The inner join leaves no item without a block.
21120
+ */
21121
+ async function holdBlocks(trx, taskId) {
21122
+ return (await trx.selectFrom("operator_item").innerJoin("block", "block.id", "operator_item.block_id").select(["operator_item.block_id", "block.addressee_role"]).where((eb) => eb.or([eb("operator_item.item_key", "like", `${cycleKeyPrefix(taskId)}%`), eb("operator_item.item_key", "like", `${courseKeyPrefix(taskId)}%`)])).where("operator_item.cleared_at", "is", null).orderBy("operator_item.id").execute()).map((item) => ({
21123
+ id: `B${String(item.block_id)}`,
21124
+ addressee: item.addressee_role
21125
+ }));
21126
+ }
20955
21127
  // ../core/src/app/conversations.ts
20956
21128
  /**
20957
21129
  * The only writer of conversation rows. A block thread takes its task, state and start from the
@@ -23218,6 +23390,7 @@ function createTaskQueries(deps) {
23218
23390
  ...withoutCommit === void 0 ? {} : { submittedWithoutCommit: withoutCommit }
23219
23391
  };
23220
23392
  if (project === void 0) return {
23393
+ waitsFor: waitsFor({ project: null }),
23221
23394
  ...shared,
23222
23395
  dispatcher: null,
23223
23396
  holds: [],
@@ -23225,6 +23398,7 @@ function createTaskQueries(deps) {
23225
23398
  checksWaivedBy: null
23226
23399
  };
23227
23400
  const mode = project.dispatcher.mode;
23401
+ const archived = task.membership === "archived";
23228
23402
  const read = await readInput(trx, {
23229
23403
  ...task,
23230
23404
  column
@@ -23233,6 +23407,11 @@ function createTaskQueries(deps) {
23233
23407
  complete: completeSince
23234
23408
  });
23235
23409
  if (read === null) return {
23410
+ waitsFor: waitsFor({
23411
+ project,
23412
+ archived,
23413
+ gate: null
23414
+ }),
23236
23415
  ...shared,
23237
23416
  dispatcher: mode,
23238
23417
  holds: ["pr_snapshot_missing"],
@@ -23265,27 +23444,46 @@ function createTaskQueries(deps) {
23265
23444
  text: RULE_WAITS[reason]
23266
23445
  }] : []);
23267
23446
  const holds = [...dispatchHolds(read.input), ...read.ticketUnconfirmed ? ["ticket_unconfirmed"] : []].sort((left, right) => TASK_HOLDS.indexOf(left) - TASK_HOLDS.indexOf(right));
23268
- const heldBy = holds.includes("cycle_limit") ? await holdBlocks(trx, task.id) : [];
23447
+ const held = holds.includes("cycle_limit") ? await holdBlocks(trx, task.id) : [];
23269
23448
  const pending = read.pending?.state === "pending" ? read.pending : void 0;
23449
+ const ladder = {
23450
+ ...shared,
23451
+ project: read.input.project,
23452
+ archived,
23453
+ gate,
23454
+ holds,
23455
+ heldBlocks: held,
23456
+ pendingSha: pending?.sha,
23457
+ waiting,
23458
+ pr: read.prRef,
23459
+ work: read.input,
23460
+ turn: shared.turn && {
23461
+ ...shared.turn,
23462
+ byOperator: shared.turn.taken !== null && isOperator(shared.turn.taken.by, config, task.project)
23463
+ }
23464
+ };
23270
23465
  return {
23466
+ waitsFor: waitsFor(ladder),
23271
23467
  ...shared,
23272
23468
  dispatcher: mode,
23273
23469
  holds,
23274
- ...heldBy.length === 0 ? {} : { heldBy },
23470
+ ...held.length === 0 ? {} : { heldBy: held.map((block) => block.id) },
23275
23471
  ...pending === void 0 ? {} : { pendingSubmit: {
23276
23472
  sha: pending.sha,
23277
23473
  until: pending.until,
23278
23474
  text: `submit pending confirmation of ${pending.sha.slice(0, 7)}`
23279
23475
  } },
23280
- gates,
23476
+ gates: gates.map((entry) => {
23477
+ const text = gateWaitsFor(entry, ladder);
23478
+ return text === void 0 ? entry : {
23479
+ ...entry,
23480
+ waitsFor: text
23481
+ };
23482
+ }),
23281
23483
  checksWaivedBy,
23282
23484
  ...waiting.length === 0 ? {} : { waiting }
23283
23485
  };
23284
23486
  }
23285
- /** The blocks of the active cycle-limit and course-check items that hold the task's turn. */
23286
- async function holdBlocks(trx, taskId) {
23287
- return (await trx.selectFrom("operator_item").select("block_id").where((eb) => eb.or([eb("item_key", "like", `${cycleKeyPrefix(taskId)}%`), eb("item_key", "like", `${courseKeyPrefix(taskId)}%`)])).where("cleared_at", "is", null).where("block_id", "is not", null).orderBy("id").execute()).flatMap((item) => item.block_id === null ? [] : [`B${String(item.block_id)}`]);
23288
- }
23289
23487
  const get = {
23290
23488
  id: "task.get",
23291
23489
  resolveTargets: (trx, input) => taskTarget(trx, taskKey(input.task)),
@@ -24784,6 +24982,20 @@ function ticketBrowseBase(tracker) {
24784
24982
  url.pathname = `${url.pathname.replace(/\/+$/, "")}/browse/`;
24785
24983
  return url.href;
24786
24984
  }
24985
+ /**
24986
+ * An operation's CLI binding as `schema.get` returns it, with mutable copies of its lists. The
24987
+ * terminal `view` stays out: the CLI reads it from its own catalog, and an older CLI's strict
24988
+ * `schema.get` parse does not know it.
24989
+ */
24990
+ function catalogCli(cli) {
24991
+ return {
24992
+ command: cli.command,
24993
+ args: [...cli.args],
24994
+ modes: cli.modes?.map((mode) => ({ ...mode })) ?? null,
24995
+ ...cli.defaultMode === void 0 ? {} : { defaultMode: cli.defaultMode },
24996
+ key: cli.key
24997
+ };
24998
+ }
24787
24999
  /** Concrete handlers shared by the daemon's HTTP and inbound transports. */
24788
25000
  function createOperationRegistry(deps) {
24789
25001
  const { config, clock, completeSince, gateways } = deps;
@@ -24827,11 +25039,7 @@ function createOperationRegistry(deps) {
24827
25039
  })),
24828
25040
  errors: [...operation.errors],
24829
25041
  ...operation.explicitKeyModes === void 0 ? {} : { explicitKeyModes: [...operation.explicitKeyModes] },
24830
- cli: {
24831
- ...operation.cli,
24832
- args: [...operation.cli.args],
24833
- modes: operation.cli.modes?.map((mode) => ({ ...mode })) ?? null
24834
- },
25042
+ cli: catalogCli(operation.cli),
24835
25043
  mcp: { ...operation.mcp },
24836
25044
  inputSchema: operation.input,
24837
25045
  outputSchema: operation.output
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { S as renderMcpError, g as OPERATIONS, pt as ERRORS } from "./chunk-CljtkzXu.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-d2uszLEI.mjs";
3
- import { a as memoryVerdictCache, l as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-DbBNabCm.mjs";
1
+ import { S as renderMcpError, g as OPERATIONS, pt as ERRORS } from "./chunk-CqjDrIzS.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-BRiD3EcI.mjs";
3
+ import { a as memoryVerdictCache, l as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-CqtrnYE5.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";