spur-board 0.140.0 → 0.142.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 { _ as renderJsonError, c as tokenRequestStatusSchema, dt as errorContextSchema, ft as errorEnvelopeSchema, lt as ERRORS, mt as successEnvelopeSchema, o as tokenRequestResultSchema } from "./chunk-cNszIZ1p.mjs";
1
+ import { _ as renderJsonError, c as tokenRequestStatusSchema, dt as errorContextSchema, ft as errorEnvelopeSchema, lt as ERRORS, mt as successEnvelopeSchema, o as tokenRequestResultSchema } from "./chunk-94uNRHe7.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -1408,6 +1408,13 @@ const ERRORS = {
1408
1408
  hint: "Change the task status in the named project tracker instead.",
1409
1409
  recovery: noRetry("Change the task status in the named project tracker instead.")
1410
1410
  }),
1411
+ order_anchor_invalid: spec("order_anchor_invalid", {
1412
+ status: 409,
1413
+ exit: EXIT_CODES.refused,
1414
+ message: "The order anchor must be another live task in the same column.",
1415
+ hint: "Pick another task from the same column in `board status`, or use `--top` or `--bottom`.",
1416
+ recovery: noRetry("Pick another task from the same column, or place the task at the top or bottom.")
1417
+ }),
1411
1418
  task_archived: spec("task_archived", {
1412
1419
  status: 409,
1413
1420
  exit: EXIT_CODES.refused,
@@ -2306,6 +2313,7 @@ const EVENT_KINDS = [
2306
2313
  "task_corrected",
2307
2314
  "task_manually_moved",
2308
2315
  "task_mirror_moved",
2316
+ "task_reordered",
2309
2317
  "external_round",
2310
2318
  "dispatcher_mode_changed",
2311
2319
  "turn_opened",
@@ -2495,6 +2503,12 @@ const eventPayloadSchemas = {
2495
2503
  /** Only the shadow column moved; `from` and `to` are shadow positions. */
2496
2504
  shadow: z.literal(true).optional()
2497
2505
  }),
2506
+ /** An operator moved the task inside its column order; `from` and `to` are 1-based places. */
2507
+ task_reordered: z.looseObject({
2508
+ column: z.enum(COLUMN_IDS),
2509
+ from: N,
2510
+ to: N
2511
+ }),
2498
2512
  /** An external change request on a new PR head while the task is in Dev: one course-check round. */
2499
2513
  external_round: z.looseObject({
2500
2514
  repo: S,
@@ -3011,7 +3025,7 @@ const statusReturnedSchema = z.strictObject({
3011
3025
  block: blockIdSchema.describe("The code block the return opened."),
3012
3026
  findings: z.int().min(0).nullable().describe("Number of review findings the return sent; null when not given.")
3013
3027
  });
3014
- const latestSubmissionSchema = z.strictObject({
3028
+ const submissionViewSchema = z.strictObject({
3015
3029
  column: z.enum(COLUMN_IDS).describe("Column submitted from."),
3016
3030
  sha: commitShaSchema.describe("Full submitted commit SHA."),
3017
3031
  at: z.iso.datetime().describe("Submission time, ISO 8601 UTC."),
@@ -3021,7 +3035,9 @@ const latestSubmissionSchema = z.strictObject({
3021
3035
  reason: z.string().max(2e3).nullable().describe("Literal explanation supplied by the submitter."),
3022
3036
  pending: z.boolean().describe("Whether head confirmation is pending."),
3023
3037
  voided: z.boolean().describe("Whether this submission has been voided for gate purposes.")
3024
- }).describe("Latest accepted submission by row order, including pending and voided submissions.").nullable().optional().describe("Latest submission; null when none, absent on older servers.");
3038
+ }).describe("Latest accepted submission by row order, including pending and voided submissions.");
3039
+ const columnPositionSchema = z.int().min(1).optional().describe("1-based place in the column order; new arrivals go last; absent on older servers.");
3040
+ const latestSubmissionSchema = submissionViewSchema.nullable().optional().describe("Latest submission; null when none, absent on older servers.");
3025
3041
  const summaryCount = (what) => z.int().min(0).describe(what);
3026
3042
  const topLevelEntries = (what) => z.array(z.string().describe("A top-level entry: name/ for a directory, a bare name for a file.")).optional().describe(what);
3027
3043
  /** One latest approval of an open pull request and what changed after it. */
@@ -3184,6 +3200,7 @@ const statusTaskSchema = taskViewSchema.extend({
3184
3200
  submission: latestSubmissionSchema,
3185
3201
  qaSubmission: latestSubmissionSchema.describe("The QA column's latest submission, pending and voided included; null when none or when the project has no enabled QA column; absent on older servers."),
3186
3202
  columnEnteredAt: z.iso.datetime().nullable().describe("Time the task entered its current real column, ISO 8601 UTC; latest real move or correction, falling back to the original add time, or null if neither is known."),
3203
+ position: columnPositionSchema,
3187
3204
  shadowColumn: z.enum(COLUMN_IDS).optional().describe("Column the dispatcher works from in shadow mode: where the board would have the task. Present only while the project dispatcher is in shadow mode."),
3188
3205
  shadowDiffers: z.boolean().optional().describe("Whether shadowColumn differs from column. Present only while the project dispatcher is in shadow mode."),
3189
3206
  state: z.string().min(1).describe("One line: ticket status, pull request states and session counts by health, an ended session counted as `ended (<reason>)`, joined by \"; \"."),
@@ -3296,6 +3313,33 @@ const taskMoveOutputSchema = z.strictObject({
3296
3313
  column: z.enum(COLUMN_IDS).describe("Resulting position; correction uses the shadow position in shadow mode."),
3297
3314
  settled: z.array(moveViewSchema).describe("Dispatcher moves after a correction, oldest first; empty for manual placement.")
3298
3315
  });
3316
+ const orderAnchor = taskKeyInputSchema.describe("Another live task of the same column; the task goes directly before it in mode before, after it in mode after.");
3317
+ const taskOrderInputSchema = z.discriminatedUnion("mode", [
3318
+ z.strictObject({
3319
+ mode: z.literal("before").describe("Place the task directly before the anchor task."),
3320
+ task: taskKeyInputSchema,
3321
+ anchor: orderAnchor
3322
+ }),
3323
+ z.strictObject({
3324
+ mode: z.literal("after").describe("Place the task directly after the anchor task."),
3325
+ task: taskKeyInputSchema,
3326
+ anchor: orderAnchor
3327
+ }),
3328
+ z.strictObject({
3329
+ mode: z.literal("top").describe("Place the task first in its column order."),
3330
+ task: taskKeyInputSchema
3331
+ }),
3332
+ z.strictObject({
3333
+ mode: z.literal("bottom").describe("Place the task last in its column order."),
3334
+ task: taskKeyInputSchema
3335
+ })
3336
+ ]);
3337
+ const taskOrderOutputSchema = z.strictObject({
3338
+ task: taskViewSchema,
3339
+ position: z.int().min(1).describe("1-based place of the task in its column order after the call."),
3340
+ previous: taskKeySchema.nullable().describe("Task directly before it in the column order; null when it is first."),
3341
+ next: taskKeySchema.nullable().describe("Task directly after it in the column order; null when it is last.")
3342
+ });
3299
3343
  const inboxAckInputSchema = z.strictObject({ entries: z.array(z.union([
3300
3344
  z.strictObject({
3301
3345
  id: commentIdSchema,
@@ -4013,6 +4057,7 @@ const OPERATIONS = [
4013
4057
  sources: [],
4014
4058
  tasks: [{
4015
4059
  ...task,
4060
+ position: 1,
4016
4061
  columnEnteredAt: at,
4017
4062
  state: "ticket not observed",
4018
4063
  prCount: 0,
@@ -4076,6 +4121,7 @@ const OPERATIONS = [
4076
4121
  sources: [],
4077
4122
  tasks: [{
4078
4123
  ...task,
4124
+ position: 1,
4079
4125
  columnEnteredAt: at,
4080
4126
  state: "ticket not observed",
4081
4127
  prCount: 0,
@@ -5477,6 +5523,84 @@ const OPERATIONS = [
5477
5523
  }
5478
5524
  ]
5479
5525
  }),
5526
+ defineOperation({
5527
+ id: "task.order",
5528
+ kind: "mutation",
5529
+ description: "Place a task before or after another task, or at the top or bottom of its column order; exactly one placement (`--before`, `--after`, `--top` or `--bottom`) and a non-blank key are required, else `usage`.",
5530
+ mcp: {
5531
+ whenToUse: "The operator wants a task earlier or later among the tasks of its column; pass an explicit key. Each column has one order for the whole board.",
5532
+ whenNotToUse: "Use task_move to change the column."
5533
+ },
5534
+ input: taskOrderInputSchema,
5535
+ output: taskOrderOutputSchema,
5536
+ explicitKeyModes: [
5537
+ "before",
5538
+ "after",
5539
+ "top",
5540
+ "bottom"
5541
+ ],
5542
+ web: true,
5543
+ grants: operatorOnly,
5544
+ errors: [
5545
+ "wrong_id_kind",
5546
+ "not_found",
5547
+ "task_archived",
5548
+ "order_anchor_invalid"
5549
+ ],
5550
+ cli: {
5551
+ command: "order",
5552
+ args: ["task"],
5553
+ modes: [
5554
+ {
5555
+ mode: "before",
5556
+ flag: "--before",
5557
+ value: "anchor"
5558
+ },
5559
+ {
5560
+ mode: "after",
5561
+ flag: "--after",
5562
+ value: "anchor"
5563
+ },
5564
+ {
5565
+ mode: "top",
5566
+ flag: "--top",
5567
+ value: null
5568
+ },
5569
+ {
5570
+ mode: "bottom",
5571
+ flag: "--bottom",
5572
+ value: null
5573
+ }
5574
+ ]
5575
+ },
5576
+ slack: null,
5577
+ examples: [{
5578
+ summary: "Place a task directly before another task of its column",
5579
+ input: {
5580
+ mode: "before",
5581
+ task: "PROJ-123",
5582
+ anchor: "PROJ-120"
5583
+ },
5584
+ output: {
5585
+ task,
5586
+ position: 2,
5587
+ previous: "PROJ-118",
5588
+ next: "PROJ-120"
5589
+ }
5590
+ }, {
5591
+ summary: "Place a task first in its column",
5592
+ input: {
5593
+ mode: "top",
5594
+ task: "PROJ-123"
5595
+ },
5596
+ output: {
5597
+ task,
5598
+ position: 1,
5599
+ previous: null,
5600
+ next: "PROJ-118"
5601
+ }
5602
+ }]
5603
+ }),
5480
5604
  defineOperation({
5481
5605
  id: "config.get",
5482
5606
  web: true,
@@ -1,5 +1,5 @@
1
- import { Dt as plainHttpAllowed, Tt as configSchema, d as buildCatalogSnapshot, p as OPERATIONS } from "./chunk-cNszIZ1p.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-BbsLyYl1.mjs";
1
+ import { Dt as plainHttpAllowed, Tt as configSchema, d as buildCatalogSnapshot, p as OPERATIONS } from "./chunk-94uNRHe7.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-7rRkhWZT.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 { At as resolveWebOrigin, D as sortSkillFiles, It as SLACK_BOT_SCOPES, T as skillReloadFileSchema, Tt as configSchema, a as requestHashOf, f as roleCanUseOperation, it as actorIdSchema, kt as requiredSecretKeys, lt as ERRORS, mt as successEnvelopeSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as DEFAULT_STAND_PORT_RANGE } from "./chunk-cNszIZ1p.mjs";
1
+ import { At as resolveWebOrigin, D as sortSkillFiles, It as SLACK_BOT_SCOPES, T as skillReloadFileSchema, Tt as configSchema, a as requestHashOf, f as roleCanUseOperation, it as actorIdSchema, kt as requiredSecretKeys, lt as ERRORS, mt as successEnvelopeSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as DEFAULT_STAND_PORT_RANGE } from "./chunk-94uNRHe7.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-BbsLyYl1.mjs";
4
- import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-H35ORvxg.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-7rRkhWZT.mjs";
4
+ import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-DApVVC2b.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";
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-BbsLyYl1.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-7rRkhWZT.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as ringMarker, A as eventPayloadSchemas, At as resolveWebOrigin, B as sourceCursorSchema, Bt as isTodoGroupColumn, C as messageRefSchema, Ct as columnTurnTimings, D as sortSkillFiles, Dt as plainHttpAllowed, E as skillReloadFilesSchema, Et as defaultAddressee, F as defaultBranchFactSchema, Ft as ITEM_KINDS, G as SESSION_HEALTH_STATES, H as PR_STATES, I as entityRefSchema, It as SLACK_BOT_SCOPES, J as parseRingMarker, K as SESSION_STATUSES, L as mirrorSourceId, Lt as TASK_HOLDS, M as MIRROR_FAILURES, Mt as COLUMN_GROUPS, N as MIRROR_FAILURE_CODES, Nt as COLUMN_IDS, O as EVENT_KINDS, Ot as readyMirrorOf, P as batchSchema, Pt as DISPATCHER_MODES, Q as prReviewRuleSchema, R as prSourceId, Rt as TODO_GROUP_COLUMN_IDS, S as interactionRefSchema, St as boardWideSpurProject, Tt as configSchema, U as REVIEW_DECISIONS, V as trackerSourceId, W as REVIEW_STATES, X as prFactsSchema, Y as prApprovalPairSchema, Z as prRefSchema, a as requestHashOf, at as encodeActorId, b as conversationRefSchema, bt as RESERVED_PROJECT, c as tokenRequestStatusSchema, ct as parseRef$1, d as buildCatalogSnapshot, et as sessionFactsSchema, f as roleCanUseOperation, g as renderHttpProblem, gt as DEFAULT_LINK, h as turnHandedSchema, i as TOKEN_REQUEST_LIMITS, it as actorIdSchema, j as AdapterError, jt as COLUMNS, k as GATE_REASONS, kt as requiredSecretKeys, l as BOARD_TICK_MS, lt as ERRORS, m as defaultBranchViewSchema, mt as successEnvelopeSchema, n as doctorReportSchema, nt as JIRA_PROJECT_KEY, o as tokenRequestResultSchema, ot as errorCodeOf, p as OPERATIONS, pt as ok, q as isExternalAuthor, rt as REF_NUMBER, s as tokenRequestSchema, st as parseActorId, t as assertNever, tt as ticketFactsSchema, ut as err, vt as DEFAULT_SLACK_COMMAND, w as userIdSchema, wt as configBindings, x as inboundEventSchema, xt as approvalRuleOf, y as SPACE_IDS, z as sessionTransitionSchema, zt as VIAS } from "./chunk-cNszIZ1p.mjs";
1
+ import { $ as ringMarker, A as eventPayloadSchemas, At as resolveWebOrigin, B as sourceCursorSchema, Bt as isTodoGroupColumn, C as messageRefSchema, Ct as columnTurnTimings, D as sortSkillFiles, Dt as plainHttpAllowed, E as skillReloadFilesSchema, Et as defaultAddressee, F as defaultBranchFactSchema, Ft as ITEM_KINDS, G as SESSION_HEALTH_STATES, H as PR_STATES, I as entityRefSchema, It as SLACK_BOT_SCOPES, J as parseRingMarker, K as SESSION_STATUSES, L as mirrorSourceId, Lt as TASK_HOLDS, M as MIRROR_FAILURES, Mt as COLUMN_GROUPS, N as MIRROR_FAILURE_CODES, Nt as COLUMN_IDS, O as EVENT_KINDS, Ot as readyMirrorOf, P as batchSchema, Pt as DISPATCHER_MODES, Q as prReviewRuleSchema, R as prSourceId, Rt as TODO_GROUP_COLUMN_IDS, S as interactionRefSchema, St as boardWideSpurProject, Tt as configSchema, U as REVIEW_DECISIONS, V as trackerSourceId, W as REVIEW_STATES, X as prFactsSchema, Y as prApprovalPairSchema, Z as prRefSchema, a as requestHashOf, at as encodeActorId, b as conversationRefSchema, bt as RESERVED_PROJECT, c as tokenRequestStatusSchema, ct as parseRef$1, d as buildCatalogSnapshot, et as sessionFactsSchema, f as roleCanUseOperation, g as renderHttpProblem, gt as DEFAULT_LINK, h as turnHandedSchema, i as TOKEN_REQUEST_LIMITS, it as actorIdSchema, j as AdapterError, jt as COLUMNS, k as GATE_REASONS, kt as requiredSecretKeys, l as BOARD_TICK_MS, lt as ERRORS, m as defaultBranchViewSchema, mt as successEnvelopeSchema, n as doctorReportSchema, nt as JIRA_PROJECT_KEY, o as tokenRequestResultSchema, ot as errorCodeOf, p as OPERATIONS, pt as ok, q as isExternalAuthor, rt as REF_NUMBER, s as tokenRequestSchema, st as parseActorId, t as assertNever, tt as ticketFactsSchema, ut as err, vt as DEFAULT_SLACK_COMMAND, w as userIdSchema, wt as configBindings, x as inboundEventSchema, xt as approvalRuleOf, y as SPACE_IDS, z as sessionTransitionSchema, zt as VIAS } from "./chunk-94uNRHe7.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";
@@ -11972,7 +11972,7 @@ function rule(fn) {
11972
11972
  throw error;
11973
11973
  }
11974
11974
  }
11975
- async function taskByKey$1(trx, key) {
11975
+ async function taskByKey$2(trx, key) {
11976
11976
  return trx.selectFrom("task").selectAll().where("key", "=", key).executeTakeFirst();
11977
11977
  }
11978
11978
  async function taskById$1(trx, id) {
@@ -12026,7 +12026,7 @@ async function authorizationTarget(trx, task, block) {
12026
12026
  return subjectTarget(trx, task === void 0 ? void 0 : taskSubject(task), block);
12027
12027
  }
12028
12028
  async function taskTarget(trx, key) {
12029
- return [await authorizationTarget(trx, await taskByKey$1(trx, key))];
12029
+ return [await authorizationTarget(trx, await taskByKey$2(trx, key))];
12030
12030
  }
12031
12031
  async function blockTarget(trx, id) {
12032
12032
  const block = await blockById(trx, id);
@@ -12531,7 +12531,7 @@ function createBlockMutations(config) {
12531
12531
  id: "block.ask",
12532
12532
  resolveTargets: (trx, input) => taskTarget(trx, input.task),
12533
12533
  async run(trx, input, ctx) {
12534
- const task = found(await taskByKey$1(trx, input.task));
12534
+ const task = found(await taskByKey$2(trx, input.task));
12535
12535
  active(task);
12536
12536
  return askOn(trx, taskSubject(task), input.text, ctx);
12537
12537
  }
@@ -12540,7 +12540,7 @@ function createBlockMutations(config) {
12540
12540
  id: "block.create",
12541
12541
  resolveTargets: (trx, input) => taskTarget(trx, input.task),
12542
12542
  async run(trx, input, ctx) {
12543
- const task = found(await taskByKey$1(trx, input.task));
12543
+ const task = found(await taskByKey$2(trx, input.task));
12544
12544
  active(task);
12545
12545
  const subject = taskSubject(task);
12546
12546
  const block = await openBlock(trx, subject, input.type, input.reason, ctx, config);
@@ -12678,7 +12678,7 @@ function createBlockMutations(config) {
12678
12678
  id: "comment.add",
12679
12679
  resolveTargets: (trx, input) => taskTarget(trx, input.task),
12680
12680
  async run(trx, input, ctx) {
12681
- const task = found(await taskByKey$1(trx, input.task));
12681
+ const task = found(await taskByKey$2(trx, input.task));
12682
12682
  active(task);
12683
12683
  const block = input.block === void 0 ? void 0 : found(await blockById(trx, input.block));
12684
12684
  if (block !== void 0 && block.task_id !== task.id) throw new CommandError("not_found", "Block does not belong to this task.");
@@ -13025,6 +13025,14 @@ function canonicalKey(config, key) {
13025
13025
  key
13026
13026
  };
13027
13027
  }
13028
+ /**
13029
+ * The stored key a task key names, read as `task.get` reads it: only the short `repo#N` form needs
13030
+ * a configured project, so a task whose project left the config is still found by its full key.
13031
+ */
13032
+ function storedKey(config, key) {
13033
+ const parsed = parseRef$1(key, "task");
13034
+ return parsed.ok && parsed.value.kind === "task" && parsed.value.form === "github-short" ? canonicalKey(config, key).key : key;
13035
+ }
13028
13036
  async function target$1(trx, key) {
13029
13037
  const task = await trx.selectFrom("task").selectAll().where("key", "=", key).executeTakeFirst();
13030
13038
  return task === void 0 ? [{ kind: "missing" }] : [{
@@ -17910,6 +17918,7 @@ async function getStatus(deps, options = {}) {
17910
17918
  qaSubmission: qaSubmissions.get(task.id) ?? null,
17911
17919
  project: task.project,
17912
17920
  column: task.column,
17921
+ position: task.position,
17913
17922
  columnEnteredAt: columnEntries.get(task.id) ?? task.created_at,
17914
17923
  membership: task.membership,
17915
17924
  ...project?.dispatcher.mode === "shadow" ? {
@@ -18177,6 +18186,7 @@ const EVENT_SUMMARIES = {
18177
18186
  task_corrected: "Column corrected by the operator",
18178
18187
  task_manually_moved: "Task manually moved by the operator",
18179
18188
  task_mirror_moved: "Task moved by the GitHub Project mirror",
18189
+ task_reordered: "Task reordered",
18180
18190
  external_round: "External change-request round",
18181
18191
  dispatcher_mode_changed: "Dispatcher mode changed",
18182
18192
  turn_opened: "Turn opened",
@@ -18419,7 +18429,7 @@ function historyEvents(rows) {
18419
18429
  const previous = /* @__PURE__ */ new Map();
18420
18430
  return rows.flatMap((row) => {
18421
18431
  const kind = EVENT_KINDS.find((candidate) => candidate === row.kind);
18422
- if (kind === void 0) return [];
18432
+ if (kind === void 0 || kind === "task_reordered") return [];
18423
18433
  const entity = factsEntity(kind, row.payload);
18424
18434
  let summary;
18425
18435
  if (entity !== null && kind !== "link_added") {
@@ -18573,7 +18583,7 @@ function withoutBlockOpenings(comments, blocks) {
18573
18583
  return !(block !== void 0 && comment.author === block.author && comment.text === block.reason && comment.created_at === block.at);
18574
18584
  });
18575
18585
  }
18576
- async function taskByKey(trx, key) {
18586
+ async function taskByKey$1(trx, key) {
18577
18587
  const task = await trx.selectFrom("task").selectAll().where("key", "=", key).executeTakeFirst();
18578
18588
  if (task === void 0) throw new CommandError("not_found", "Check the task key.");
18579
18589
  return task;
@@ -18666,7 +18676,7 @@ function createTaskQueries(deps) {
18666
18676
  resolveTargets: (trx, input) => taskTarget(trx, taskKey(input.task)),
18667
18677
  async prepare(db, input) {
18668
18678
  if (input.refresh !== true) return;
18669
- const task = await taskByKey(db, taskKey(input.task));
18679
+ const task = await taskByKey$1(db, taskKey(input.task));
18670
18680
  const links = await db.selectFrom("link").select(["repo", "number"]).where("task_id", "=", task.id).where("entity", "=", "pr").where("banned", "=", 0).execute();
18671
18681
  await refreshPrs(config, task.project, links.flatMap((link) => link.repo === null || link.number === null ? [] : [{
18672
18682
  kind: "pr",
@@ -18675,7 +18685,7 @@ function createTaskQueries(deps) {
18675
18685
  }]), deps.prPoller?.());
18676
18686
  },
18677
18687
  async run(trx, input) {
18678
- const task = await taskByKey(trx, taskKey(input.task));
18688
+ const task = await taskByKey$1(trx, taskKey(input.task));
18679
18689
  const [blocks, comments, links] = await Promise.all([
18680
18690
  taskBlockViews(trx, task),
18681
18691
  trx.selectFrom("comment").selectAll().where("task_id", "=", task.id).orderBy("id").execute(),
@@ -18714,7 +18724,7 @@ function createTaskQueries(deps) {
18714
18724
  id: "task.history",
18715
18725
  resolveTargets: (trx, input) => taskTarget(trx, taskKey(input.task)),
18716
18726
  async run(trx, input) {
18717
- const task = await taskByKey(trx, taskKey(input.task));
18727
+ const task = await taskByKey$1(trx, taskKey(input.task));
18718
18728
  const rows = await trx.selectFrom("event").selectAll().where("task_id", "=", task.id).orderBy("id").execute();
18719
18729
  return {
18720
18730
  task: taskView(task),
@@ -19200,6 +19210,80 @@ function createLinkMutations(config, deps = {}) {
19200
19210
  }
19201
19211
  };
19202
19212
  }
19213
+ // ../core/src/app/order.ts
19214
+ const PICK_ANOTHER = "name another task of its column, or use --top or --bottom.";
19215
+ async function taskByKey(trx, key) {
19216
+ return trx.selectFrom("task").selectAll().where("key", "=", key).executeTakeFirst();
19217
+ }
19218
+ /**
19219
+ * The anchor task of a before or after placement, looked up in the task's own project only, so a
19220
+ * refusal never tells a per-project operator about another project's task. Anything but another
19221
+ * live task of the column is refused.
19222
+ */
19223
+ async function anchorTask(trx, config, key, task) {
19224
+ let stored;
19225
+ try {
19226
+ stored = storedKey(config, key);
19227
+ } catch (error) {
19228
+ if (error instanceof CommandError && error.code === "not_found") throw new CommandError("order_anchor_invalid", `No task has the key ${key}; ${PICK_ANOTHER}`);
19229
+ throw error;
19230
+ }
19231
+ const anchor = await trx.selectFrom("task").selectAll().where("key", "=", stored).where("project", "=", task.project).executeTakeFirst();
19232
+ if (anchor === void 0) throw new CommandError("order_anchor_invalid", `No task has the key ${key}; ${PICK_ANOTHER}`);
19233
+ if (anchor.id === task.id) throw new CommandError("order_anchor_invalid", `The anchor is the task itself; ${PICK_ANOTHER}`);
19234
+ if (anchor.membership === "archived") throw new CommandError("order_anchor_invalid", `Task ${anchor.key} is archived; ${PICK_ANOTHER}`);
19235
+ if (anchor.column !== task.column) throw new CommandError("order_anchor_invalid", `Task ${anchor.key} is in ${anchor.column}, not ${task.column}; ${PICK_ANOTHER}`);
19236
+ return anchor;
19237
+ }
19238
+ /** The operator's manual order of a column: one board-wide order per (project, column). */
19239
+ function createOrderMutations(config) {
19240
+ return { order: {
19241
+ id: "task.order",
19242
+ resolveTargets: (trx, input) => taskTarget(trx, storedKey(config, input.task)),
19243
+ async run(trx, input, ctx) {
19244
+ const task = await taskByKey(trx, storedKey(config, input.task));
19245
+ if (task === void 0) throw new CommandError("not_found", "Check the task key.");
19246
+ if (task.membership === "archived") throw new CommandError("task_archived", "Add the task again before ordering it.");
19247
+ const rows = await trx.selectFrom("task").select([
19248
+ "id",
19249
+ "key",
19250
+ "position"
19251
+ ]).where("project", "=", task.project).where("column", "=", task.column).where("membership", "!=", "archived").orderBy("position").orderBy("id").execute();
19252
+ const self = rows.find((row) => row.id === task.id);
19253
+ if (self === void 0) throw new Error("Live task missing from its column");
19254
+ const others = rows.filter((row) => row.id !== task.id);
19255
+ let index = input.mode === "top" ? 0 : others.length;
19256
+ if (input.mode === "before" || input.mode === "after") {
19257
+ const anchor = await anchorTask(trx, config, input.anchor, task);
19258
+ index = others.findIndex((row) => row.id === anchor.id) + (input.mode === "after" ? 1 : 0);
19259
+ }
19260
+ const placed = [
19261
+ ...others.slice(0, index),
19262
+ self,
19263
+ ...others.slice(index)
19264
+ ];
19265
+ const from = rows.indexOf(self) + 1;
19266
+ const to = index + 1;
19267
+ if (from !== to) {
19268
+ for (const [i, row] of placed.entries()) {
19269
+ if (row.position === i + 1) continue;
19270
+ await trx.updateTable("task").set({ position: i + 1 }).where("id", "=", row.id).execute();
19271
+ }
19272
+ await emit(trx, "task_reordered", task.project, task.id, ctx.at, {
19273
+ column: task.column,
19274
+ from,
19275
+ to
19276
+ }, ctx.actor);
19277
+ }
19278
+ return {
19279
+ task: taskView(task),
19280
+ position: to,
19281
+ previous: placed[index - 1]?.key ?? null,
19282
+ next: placed[index + 1]?.key ?? null
19283
+ };
19284
+ }
19285
+ } };
19286
+ }
19203
19287
  // ../core/src/app/operator-inbox.ts
19204
19288
  /** How far back `handled` reaches, and how many entries it keeps. */
19205
19289
  const HANDLED_WINDOW_MS = 864e5;
@@ -19567,14 +19651,6 @@ async function turnVisitTarget(db, id) {
19567
19651
  }];
19568
19652
  }
19569
19653
  /**
19570
- * The stored key a task key names, read as `task.get` reads it: only the short `repo#N` form needs
19571
- * a configured project, so a task whose project left the config is still found by its full key.
19572
- */
19573
- function storedKey(config, key) {
19574
- const parsed = parseRef$1(key, "task");
19575
- return parsed.ok && parsed.value.kind === "task" && parsed.value.form === "github-short" ? canonicalKey(config, key).key : key;
19576
- }
19577
- /**
19578
19654
  * The task a submit names by its key. A key is taken only while the task's project dispatcher is
19579
19655
  * in shadow mode; otherwise `wrong_id_kind`.
19580
19656
  */
@@ -20107,7 +20183,8 @@ function createOperationRegistry(deps) {
20107
20183
  "item.close": items.close,
20108
20184
  "task.submit": turns.submit,
20109
20185
  "task.return": turns.return,
20110
- "task.move": turns.move
20186
+ "task.move": turns.move,
20187
+ "task.order": createOrderMutations(config).order
20111
20188
  };
20112
20189
  }
20113
20190
  // ../core/src/app/doctor.ts
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { lt as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-cNszIZ1p.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-BbsLyYl1.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-H35ORvxg.mjs";
1
+ import { lt as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-94uNRHe7.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-7rRkhWZT.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-DApVVC2b.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -0,0 +1,68 @@
1
+ -- A live task's 1-based place in its (project, column) order: dense 1..n among non-archived tasks.
2
+ -- The backfill orders each column by the latest real column entry, the predicate of
3
+ -- readStatusColumnEntries frozen here, then journal order, then task id; created_at stands in for
4
+ -- a task with no entry. Two triggers keep the order dense from then on. Any insert, column change,
5
+ -- column_epoch change or un-archive puts the task last; leaving a column or archiving closes the
6
+ -- gap. The WHEN guard skips a SET that keeps column, epoch and archived-ness, because SQLite fires
7
+ -- UPDATE OF for every listed column in SET, changed or not. task.order rewrites position alone,
8
+ -- which no trigger watches. A table rebuild of task must recreate both triggers.
9
+ ALTER TABLE task ADD COLUMN position INTEGER NOT NULL DEFAULT 0;
10
+
11
+ WITH entry AS (
12
+ SELECT e.task_id, MAX(e.id) AS id
13
+ FROM event e
14
+ JOIN task t ON t.id = e.task_id
15
+ WHERE t.membership != 'archived'
16
+ AND (json_extract(e.payload, '$.to') = t."column" OR (
17
+ e.kind = 'task_added' AND e.at = t.created_at
18
+ AND json_extract(e.payload, '$.column') = t."column"
19
+ AND e.id = (
20
+ SELECT MIN(original.id) FROM event original
21
+ WHERE original.task_id = t.id AND original.kind = 'task_added'
22
+ )
23
+ ))
24
+ AND (e.kind IN ('task_added', 'task_moved', 'task_manually_moved')
25
+ OR (e.kind = 'task_mirror_moved' AND json_extract(e.payload, '$.shadow') IS NULL)
26
+ OR (e.kind = 'task_corrected' AND json_extract(e.payload, '$.shadow') = 0))
27
+ GROUP BY e.task_id
28
+ ),
29
+ ranked AS (
30
+ SELECT t.id, ROW_NUMBER() OVER (
31
+ PARTITION BY t.project, t."column"
32
+ ORDER BY julianday(coalesce(latest.at, t.created_at)), latest.id, t.id
33
+ ) AS place
34
+ FROM task t
35
+ LEFT JOIN entry ON entry.task_id = t.id
36
+ LEFT JOIN event latest ON latest.id = entry.id
37
+ WHERE t.membership != 'archived'
38
+ )
39
+ UPDATE task SET position = (SELECT place FROM ranked WHERE ranked.id = task.id)
40
+ WHERE membership != 'archived';
41
+
42
+ CREATE TRIGGER task_position_insert AFTER INSERT ON task
43
+ WHEN NEW.membership != 'archived'
44
+ BEGIN
45
+ UPDATE task SET position = (
46
+ SELECT coalesce(MAX(other.position), 0) + 1 FROM task other
47
+ WHERE other.project = NEW.project AND other."column" = NEW."column"
48
+ AND other.membership != 'archived' AND other.id != NEW.id
49
+ )
50
+ WHERE id = NEW.id;
51
+ END;
52
+
53
+ CREATE TRIGGER task_position_update AFTER UPDATE OF "column", column_epoch, membership ON task
54
+ WHEN OLD."column" IS NOT NEW."column"
55
+ OR OLD.column_epoch IS NOT NEW.column_epoch
56
+ OR (OLD.membership = 'archived') IS NOT (NEW.membership = 'archived')
57
+ BEGIN
58
+ UPDATE task SET position = position - 1
59
+ WHERE OLD.membership != 'archived'
60
+ AND project = OLD.project AND "column" = OLD."column"
61
+ AND membership != 'archived' AND id != OLD.id AND position > OLD.position;
62
+ UPDATE task SET position = (
63
+ SELECT coalesce(MAX(other.position), 0) + 1 FROM task other
64
+ WHERE other.project = NEW.project AND other."column" = NEW."column"
65
+ AND other.membership != 'archived' AND other.id != NEW.id
66
+ )
67
+ WHERE id = NEW.id AND NEW.membership != 'archived';
68
+ END;