monoban 1.1.0 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +8 -1
  2. package/dist/index.mjs +895 -47
  3. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1021,7 +1021,7 @@ const uuid = (version) => {
1021
1021
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
1022
1022
  };
1023
1023
  /** Practical email validation */
1024
- const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1024
+ const email$1 = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1025
1025
  const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
1026
1026
  function emoji() {
1027
1027
  return new RegExp(_emoji$1, "u");
@@ -1559,7 +1559,7 @@ const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
1559
1559
  $ZodStringFormat.init(inst, def);
1560
1560
  });
1561
1561
  const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1562
- def.pattern ?? (def.pattern = email);
1562
+ def.pattern ?? (def.pattern = email$1);
1563
1563
  $ZodStringFormat.init(inst, def);
1564
1564
  });
1565
1565
  function canParseURL(input) {
@@ -4827,6 +4827,9 @@ const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
4827
4827
  $ZodEmail.init(inst, def);
4828
4828
  ZodStringFormat.init(inst, def);
4829
4829
  });
4830
+ function email(params) {
4831
+ return /* @__PURE__ */ _email(ZodEmail, params);
4832
+ }
4830
4833
  const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
4831
4834
  $ZodGUID.init(inst, def);
4832
4835
  ZodStringFormat.init(inst, def);
@@ -5395,6 +5398,163 @@ const LIMITS = {
5395
5398
  linkTitle: 200
5396
5399
  };
5397
5400
  //#endregion
5401
+ //#region ../../packages/contract/src/dates.ts
5402
+ /**
5403
+ * Days, as tasks are scheduled: "2026-10-02", no time and no time zone. "Today" is the user's own: clients
5404
+ * work it out from their clock (today()) and send it, so the API never guesses a time zone.
5405
+ */
5406
+ const DAY_MS$1 = 864e5;
5407
+ const DAY_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
5408
+ const WEEKDAYS = [
5409
+ "sunday",
5410
+ "monday",
5411
+ "tuesday",
5412
+ "wednesday",
5413
+ "thursday",
5414
+ "friday",
5415
+ "saturday"
5416
+ ];
5417
+ const MONTHS = [
5418
+ "january",
5419
+ "february",
5420
+ "march",
5421
+ "april",
5422
+ "may",
5423
+ "june",
5424
+ "july",
5425
+ "august",
5426
+ "september",
5427
+ "october",
5428
+ "november",
5429
+ "december"
5430
+ ];
5431
+ const SHORT_WEEKDAYS = [
5432
+ "Sun",
5433
+ "Mon",
5434
+ "Tue",
5435
+ "Wed",
5436
+ "Thu",
5437
+ "Fri",
5438
+ "Sat"
5439
+ ];
5440
+ const SHORT_MONTHS = [
5441
+ "Jan",
5442
+ "Feb",
5443
+ "Mar",
5444
+ "Apr",
5445
+ "May",
5446
+ "Jun",
5447
+ "Jul",
5448
+ "Aug",
5449
+ "Sep",
5450
+ "Oct",
5451
+ "Nov",
5452
+ "Dec"
5453
+ ];
5454
+ const pad = (n) => String(n).padStart(2, "0");
5455
+ const fromUtc = (ms) => {
5456
+ const d = new Date(ms);
5457
+ return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}`;
5458
+ };
5459
+ /** Midnight UTC of a day: arithmetic on it never meets a daylight-saving change. */
5460
+ const utc = (day) => {
5461
+ const [, y, m, d] = DAY_PATTERN.exec(day) ?? [];
5462
+ return Date.UTC(Number(y), Number(m) - 1, Number(d));
5463
+ };
5464
+ /** Whether `value` is a real day ("2026-02-30" isn't). */
5465
+ function isDay(value) {
5466
+ return DAY_PATTERN.test(value) && fromUtc(utc(value)) === value;
5467
+ }
5468
+ /** Today, by this device's clock and time zone. */
5469
+ function today(now = /* @__PURE__ */ new Date()) {
5470
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
5471
+ }
5472
+ function addDays(day, days) {
5473
+ return fromUtc(utc(day) + days * DAY_MS$1);
5474
+ }
5475
+ /** How many days from `from` to `to` (negative when `to` is earlier). */
5476
+ function daysBetween(from, to) {
5477
+ return Math.round((utc(to) - utc(from)) / DAY_MS$1);
5478
+ }
5479
+ /** 0 is Sunday. */
5480
+ const weekday = (day) => new Date(utc(day)).getUTCDay();
5481
+ /** A day in a few characters, next to `today`: "today", "tomorrow", "yesterday", "Fri" (this week), "Oct 12". */
5482
+ function formatDay(day, now) {
5483
+ const diff = daysBetween(now, day);
5484
+ if (diff === 0) return "today";
5485
+ if (diff === 1) return "tomorrow";
5486
+ if (diff === -1) return "yesterday";
5487
+ if (diff > 1 && diff < 7) return SHORT_WEEKDAYS[weekday(day)];
5488
+ const d = new Date(utc(day));
5489
+ const month = `${SHORT_MONTHS[d.getUTCMonth()]} ${d.getUTCDate()}`;
5490
+ return day.slice(0, 4) === now.slice(0, 4) ? month : `${month}, ${day.slice(0, 4)}`;
5491
+ }
5492
+ /** A day in full, for a heading: "Thu Oct 2" (with the year when it isn't this one). */
5493
+ function longDay(day, now) {
5494
+ const d = new Date(utc(day));
5495
+ const text = `${SHORT_WEEKDAYS[d.getUTCDay()]} ${SHORT_MONTHS[d.getUTCMonth()]} ${d.getUTCDate()}`;
5496
+ return day.slice(0, 4) === now.slice(0, 4) ? text : `${text}, ${day.slice(0, 4)}`;
5497
+ }
5498
+ /** The weekday a word names, by its first letters ("fri", "tues"); -1 if none. */
5499
+ const weekdayOf = (word) => word.length >= 2 ? WEEKDAYS.findIndex((name) => name.startsWith(word)) : -1;
5500
+ /** The month a word names, by its first three letters or more ("oct", "october"); -1 if none. */
5501
+ const monthOf = (word) => word.length >= 3 ? MONTHS.findIndex((name) => name.startsWith(word)) : -1;
5502
+ /**
5503
+ * The day someone means, typed loosely, or null: "today", "tomorrow" ("tom"), "yesterday", a weekday ("fri":
5504
+ * the next one, today included; "next fri": after today), "next week" (Monday), "weekend" (Saturday),
5505
+ * "+3" or "3d" (days ahead), "2w", "oct 12" or "12 oct" (the next one; a year after it works too), or
5506
+ * "2026-10-12".
5507
+ */
5508
+ function parseDay(input, now) {
5509
+ const text = input.trim().toLowerCase().replace(/\s+/g, " ").replace(/,/g, "");
5510
+ if (!text) return null;
5511
+ if ([
5512
+ "today",
5513
+ "tod",
5514
+ "now"
5515
+ ].includes(text)) return now;
5516
+ if ([
5517
+ "tomorrow",
5518
+ "tom",
5519
+ "tmr",
5520
+ "tmrw"
5521
+ ].includes(text)) return addDays(now, 1);
5522
+ if (text === "yesterday") return addDays(now, -1);
5523
+ if (isDay(text)) return text;
5524
+ const ahead = /^\+?(\d{1,3}) ?(d|days?|w|weeks?)?$/.exec(text);
5525
+ if (ahead && (text.startsWith("+") || ahead[2])) {
5526
+ const n = Number(ahead[1]);
5527
+ return addDays(now, ahead[2]?.startsWith("w") ? n * 7 : n);
5528
+ }
5529
+ const next = (target, from) => addDays(now, from + (target - weekday(addDays(now, from)) + 7) % 7);
5530
+ if (text === "next week") return next(1, 1);
5531
+ if (text === "weekend") return next(6, 0);
5532
+ const [first = "", second] = text.split(" ");
5533
+ if (first === "next" && second && weekdayOf(second) >= 0) return next(weekdayOf(second), 1);
5534
+ if (!second && weekdayOf(first) >= 0) return next(weekdayOf(first), 0);
5535
+ const words = text.split(" ");
5536
+ const month = words.map(monthOf).find((m) => m >= 0) ?? -1;
5537
+ const numbers = words.filter((w) => /^\d{1,4}$/.test(w)).map(Number);
5538
+ if (month >= 0 && words.length <= 3 && words.length === numbers.length + 1) {
5539
+ const [date, year] = numbers;
5540
+ if (!date || date > 31) return null;
5541
+ const make = (y) => `${y}-${pad(month + 1)}-${pad(date)}`;
5542
+ if (year !== void 0) return year >= 1e3 && isDay(make(year)) ? make(year) : null;
5543
+ const thisYear = Number(now.slice(0, 4));
5544
+ const day = make(thisYear);
5545
+ if (!isDay(day)) return null;
5546
+ return day < now ? isDay(make(thisYear + 1)) ? make(thisYear + 1) : null : day;
5547
+ }
5548
+ return null;
5549
+ }
5550
+ /**
5551
+ * A project's Done column, as `monoban done` and the Today view read it: the one named Done (any case),
5552
+ * else the last. `columns` in board order.
5553
+ */
5554
+ function doneColumn(columns) {
5555
+ return columns.find((c) => c.name.trim().toLowerCase() === "done") ?? columns.at(-1);
5556
+ }
5557
+ //#endregion
5398
5558
  //#region ../../packages/contract/src/links.ts
5399
5559
  /** What a task's link points at. */
5400
5560
  const LINK_KINDS = [
@@ -5874,6 +6034,11 @@ const Version = string().regex(/^[A-Za-z0-9_-]{16}$/).describe("For If-Match; ch
5874
6034
  * into this form with normalizeRepo() first; the API only lowercases it.
5875
6035
  */
5876
6036
  const RepoSchema = string().regex(/^github\.com\/[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9._-]{1,100}$/, "A repository like github.com/owner/repo").overwrite((v) => v.toLowerCase()).refine((v) => !/\/\.\.?$/.test(v), "Not a repository name").meta({ example: "github.com/thiagodmont/monoban" });
6037
+ /** A day, without a time or a time zone: "2026-10-12". */
6038
+ const DaySchema = string().regex(/^\d{4}-\d{2}-\d{2}$/, "A day like 2026-10-12").refine(isDay, "Not a real day").meta({
6039
+ format: "date",
6040
+ example: "2026-10-12"
6041
+ });
5877
6042
  /** A Postgres uuid: any 8-4-4-4-12 hex id (not only RFC 9562 versions, which is what z.uuid() checks). */
5878
6043
  const IdSchema = guid();
5879
6044
  const ProjectSchema = object({
@@ -5890,6 +6055,8 @@ const ProjectSchema = object({
5890
6055
  repo: string().nullable(),
5891
6056
  /** The web board opens a task after you add it, so you can write its description. */
5892
6057
  openNewTasks: boolean(),
6058
+ /** Days a task stays in the Done column before it's archived (off the board); null: never. */
6059
+ archiveAfterDays: number$1().int().min(1).max(365).nullable(),
5893
6060
  createdAt: Timestamp,
5894
6061
  updatedAt: Timestamp
5895
6062
  }).meta({ id: "Project" });
@@ -5918,7 +6085,9 @@ strictObject({
5918
6085
  /** Link a GitHub repository; null unlinks. One project per repository (409 if another has it). */
5919
6086
  repo: RepoSchema.nullable().optional(),
5920
6087
  /** Open a task on the web board after adding it. */
5921
- openNewTasks: boolean().optional()
6088
+ openNewTasks: boolean().optional(),
6089
+ /** Days in Done before a task is archived (1–365); null: never. */
6090
+ archiveAfterDays: number$1().int().min(1).max(365).nullable().optional()
5922
6091
  }).refine((patch) => Object.keys(patch).length > 0, "Send at least one field to change").meta({
5923
6092
  id: "ProjectPatch",
5924
6093
  minProperties: 1
@@ -6044,7 +6213,9 @@ strictObject({
6044
6213
  columnId: IdSchema.optional(),
6045
6214
  /** Where it goes in the column; the end when left out. */
6046
6215
  position: PositionSchema.optional(),
6047
- tagIds: tagIds.optional()
6216
+ tagIds: tagIds.optional(),
6217
+ /** The day you plan to work on it. */
6218
+ scheduledOn: DaySchema.nullable().optional()
6048
6219
  }).meta({ id: "TaskCreate" });
6049
6220
  strictObject({
6050
6221
  title: taskTitle.optional(),
@@ -6054,11 +6225,27 @@ strictObject({
6054
6225
  /** New place in the column. */
6055
6226
  position: PositionSchema.optional(),
6056
6227
  /** Its tags from now on (all of them: the list replaces the old one). */
6057
- tagIds: tagIds.optional()
6228
+ tagIds: tagIds.optional(),
6229
+ /** The day you plan to work on it; null takes the date off. */
6230
+ scheduledOn: DaySchema.nullable().optional()
6058
6231
  }).refine((patch) => Object.keys(patch).length > 0, "Send at least one field to change").meta({
6059
6232
  id: "TaskPatch",
6060
6233
  minProperties: 1
6061
6234
  });
6235
+ strictObject({
6236
+ /** The project's key (MON). */
6237
+ project: ProjectKeySchema,
6238
+ /** A column of that project; left out: the one named like the task's column now (any case), else the first. */
6239
+ columnId: IdSchema.optional(),
6240
+ /** Where it goes in the column (with `columnId`); its end when left out. */
6241
+ position: PositionSchema.optional()
6242
+ }).refine((body) => body.position === void 0 || body.columnId !== void 0, {
6243
+ message: "position needs a columnId",
6244
+ path: ["position"]
6245
+ }).meta({
6246
+ id: "TaskTransfer",
6247
+ dependentRequired: { position: ["columnId"] }
6248
+ });
6062
6249
  strictObject({
6063
6250
  id: IdSchema,
6064
6251
  /** Optional (the path has it); if sent, it must match. */
@@ -6069,6 +6256,7 @@ strictObject({
6069
6256
  position: PositionSchema,
6070
6257
  /** Tags deleted since are left out. */
6071
6258
  tagIds: tagIds.optional(),
6259
+ scheduledOn: DaySchema.nullable().optional(),
6072
6260
  /** Its links, as DELETE returned them (only these fields are read). */
6073
6261
  links: array(object({
6074
6262
  url: linkUrl,
@@ -6077,6 +6265,8 @@ strictObject({
6077
6265
  checkedAt: Timestamp.nullable().optional()
6078
6266
  })).max(LIMITS.linksPerTask).optional(),
6079
6267
  createdAt: datetime({ offset: true }).optional(),
6268
+ /** When it came into its column, so an undone delete doesn't start its archive clock again. */
6269
+ columnSince: Timestamp.optional(),
6080
6270
  ref: string().optional(),
6081
6271
  version: string().optional(),
6082
6272
  updatedAt: string().optional()
@@ -6094,11 +6284,103 @@ const TaskSchema = object({
6094
6284
  tagIds: array(IdSchema),
6095
6285
  /** What's attached to it (pull requests, issues, pages), oldest first. They aren't part of its version. */
6096
6286
  links: array(TaskLinkSchema),
6287
+ /** The day you plan to work on it (not a deadline), or null. */
6288
+ scheduledOn: DaySchema.nullable(),
6289
+ /** When it came into its column. In the Done column for longer than its project's archiveAfterDays, it's archived. */
6290
+ columnSince: Timestamp,
6097
6291
  version: Version,
6098
6292
  createdAt: Timestamp,
6099
6293
  updatedAt: Timestamp
6100
6294
  }).meta({ id: "Task" });
6101
6295
  /**
6296
+ * A column or tag in a task's history: as it was named then (it may have been renamed or deleted since).
6297
+ * The column has no OpenAPI name: it's nullable in places, and a named schema would be nullable everywhere.
6298
+ */
6299
+ const EventColumn = object({
6300
+ id: IdSchema,
6301
+ name: string(),
6302
+ color: ColorSchema
6303
+ });
6304
+ /** Where a task was, or went, when it changed project: the project, the task's reference there, its column. */
6305
+ const EventPlace = object({
6306
+ project: object({
6307
+ id: IdSchema,
6308
+ key: string(),
6309
+ name: string()
6310
+ }),
6311
+ ref: string(),
6312
+ column: EventColumn
6313
+ }).meta({ id: "EventPlace" });
6314
+ const EventTag = object({
6315
+ id: IdSchema,
6316
+ name: string(),
6317
+ color: ColorSchema
6318
+ }).meta({ id: "EventTag" });
6319
+ const EventLink = object({
6320
+ id: IdSchema,
6321
+ url: string(),
6322
+ kind: _enum(LINK_KINDS),
6323
+ title: string(),
6324
+ state: _enum(LINK_STATES).nullable()
6325
+ }).meta({ id: "EventLink" });
6326
+ const event = (kind, shape) => object({
6327
+ /** Newer events have larger ids. */
6328
+ id: string().regex(/^[1-9][0-9]*$/),
6329
+ kind: literal(kind),
6330
+ ...shape,
6331
+ /** What made the change: `web`, `cli` or `api` (another client); null for what happened before history began. */
6332
+ via: string().nullable(),
6333
+ createdAt: Timestamp,
6334
+ /** Later than `createdAt` when a burst of changes merged into this event (typing, toggling tags). */
6335
+ updatedAt: Timestamp
6336
+ });
6337
+ discriminatedUnion("kind", [
6338
+ event("created", {
6339
+ /** Null for tasks made before history began. */
6340
+ column: EventColumn.nullable(),
6341
+ title: string().nullable(),
6342
+ tags: array(EventTag),
6343
+ /** The day it was made for, if it was made with one. */
6344
+ scheduledOn: DaySchema.nullable()
6345
+ }),
6346
+ event("moved", {
6347
+ from: EventColumn,
6348
+ to: EventColumn
6349
+ }),
6350
+ event("renamed", {
6351
+ from: string(),
6352
+ to: string()
6353
+ }),
6354
+ event("edited", {
6355
+ from: number$1().int().nonnegative(),
6356
+ to: number$1().int().nonnegative()
6357
+ }),
6358
+ event("tagged", {
6359
+ added: array(EventTag),
6360
+ removed: array(EventTag)
6361
+ }),
6362
+ event("linked", { link: EventLink }),
6363
+ event("unlinked", { link: EventLink }),
6364
+ event("link_state", {
6365
+ link: EventLink,
6366
+ from: _enum(LINK_STATES).nullable(),
6367
+ to: _enum(LINK_STATES).nullable()
6368
+ }),
6369
+ event("deleted", {
6370
+ title: string(),
6371
+ column: EventColumn.nullable()
6372
+ }),
6373
+ event("restored", { column: EventColumn.nullable() }),
6374
+ event("scheduled", {
6375
+ from: DaySchema.nullable(),
6376
+ to: DaySchema.nullable()
6377
+ }),
6378
+ event("transferred", {
6379
+ from: EventPlace,
6380
+ to: EventPlace
6381
+ })
6382
+ ]).meta({ id: "TaskEvent" });
6383
+ /**
6102
6384
  * Every list takes `?limit=` and `?cursor=` and answers `{ <items>: [...], nextCursor }` (keyset
6103
6385
  * pagination; see docs/PLAN-API-CLI.md §4.1). `nextCursor` is null on the last page.
6104
6386
  */
@@ -6106,16 +6388,56 @@ const PAGE_LIMIT = {
6106
6388
  default: 100,
6107
6389
  max: 200
6108
6390
  };
6109
- strictObject({
6391
+ /** Strict, like every request schema: a typo such as `?colum=backlog` is a 400, not a silently wider list. */
6392
+ const PageQuerySchema = strictObject({
6110
6393
  limit: number().int().min(1).max(PAGE_LIMIT.max).default(PAGE_LIMIT.default).describe("Items per page"),
6111
6394
  cursor: string().min(1).max(1024).optional().describe("`nextCursor` from the previous page")
6112
6395
  });
6396
+ PageQuerySchema.extend({
6397
+ from: DaySchema.describe("The first day (the client's today, for Today)"),
6398
+ to: DaySchema.optional().describe("The last day (`from` when left out); at most 62 days after `from`"),
6399
+ overdue: _enum(["true", "false"]).optional().describe("Also the tasks scheduled before `from` that aren't done (not in their project's Done column)")
6400
+ });
6401
+ /** Where a task is, for a list across projects: its project and column, and whether it's done. */
6402
+ const TaskPlace = {
6403
+ project: object({
6404
+ key: ProjectKeySchema,
6405
+ name: string(),
6406
+ icon: string().nullable(),
6407
+ color: ColorSchema
6408
+ }),
6409
+ column: object({
6410
+ id: IdSchema,
6411
+ name: string(),
6412
+ color: ColorSchema
6413
+ }),
6414
+ /** In its project's Done column (the one named Done, else the last). */
6415
+ done: boolean()
6416
+ };
6417
+ TaskSchema.extend({
6418
+ ...TaskPlace,
6419
+ scheduledOn: DaySchema
6420
+ }).meta({ id: "ScheduledTask" });
6421
+ /** The longest search, and the most words in it. */
6422
+ const SEARCH_LIMITS = {
6423
+ length: 200,
6424
+ words: 8
6425
+ };
6426
+ PageQuerySchema.extend({ q: string().trim().min(1).max(SEARCH_LIMITS.length).regex(/^[^\u0000]*$/).describe(`Words, all of which a task must have (any case): in its title or description, as its tag's name, or as its reference (\`MON-12\`). At most ${SEARCH_LIMITS.words} words.`) });
6427
+ TaskSchema.extend({
6428
+ ...TaskPlace,
6429
+ /** Done long enough ago that its board leaves it out (its project's archive setting). */
6430
+ archived: boolean()
6431
+ }).meta({ id: "FoundTask" });
6113
6432
  object({
6114
6433
  project: ProjectSchema,
6115
6434
  columns: array(ColumnSchema),
6116
6435
  /** The tags its tasks can have: the project's own and the shared ones, by name. */
6117
6436
  tags: array(TagSchema),
6437
+ /** Its tasks, except the archived ones (`GET …/tasks?archived=true` lists those). */
6118
6438
  tasks: array(TaskSchema),
6439
+ /** How many archived tasks it leaves out. */
6440
+ archived: number$1().int().nonnegative(),
6119
6441
  /** More tasks than the board returns at once (2,000): load the rest from the paginated task list. */
6120
6442
  truncated: boolean()
6121
6443
  }).meta({ id: "Board" });
@@ -6769,6 +7091,126 @@ async function* pages(fetchPage) {
6769
7091
  } while (cursor);
6770
7092
  }
6771
7093
  //#endregion
7094
+ //#region ../../packages/contract/src/history.ts
7095
+ const KIND_NAMES = {
7096
+ pr: "PR ",
7097
+ issue: "issue ",
7098
+ commit: "commit ",
7099
+ url: ""
7100
+ };
7101
+ /** How a link is named in a task's history: "PR #54", "issue #3", "commit a1b2c3d", "figma.com". */
7102
+ function eventLinkName(link) {
7103
+ const number = parseLink(link.url)?.number ?? null;
7104
+ return `${KIND_NAMES[link.kind]}${linkLabel({
7105
+ ...link,
7106
+ number
7107
+ })}`;
7108
+ }
7109
+ /** What a pull request's or issue's new state says it did. */
7110
+ function stateVerb(from, to) {
7111
+ if (to === "open") return from === "merged" || from === "closed" ? "reopened" : "opened";
7112
+ if (to === "draft") return "drafted";
7113
+ return to ?? "updated";
7114
+ }
7115
+ const signed = (n) => n > 0 ? `+${n}` : `−${-n}`;
7116
+ /**
7117
+ * A history event in words, for a line: a verb ("moved") and what it did ("To do → In progress"). The web
7118
+ * draws some of it richer (column dots, tag chips); the words are the same.
7119
+ */
7120
+ function describeEvent(event, now = today()) {
7121
+ const day = (d) => formatDay(d, now);
7122
+ switch (event.kind) {
7123
+ case "created": {
7124
+ const tags = event.tags.map((t) => `#${t.name}`);
7125
+ const when = event.scheduledOn && `for ${day(event.scheduledOn)}`;
7126
+ return {
7127
+ verb: "created",
7128
+ detail: [
7129
+ event.column && `in ${event.column.name}`,
7130
+ ...tags,
7131
+ when
7132
+ ].filter(Boolean).join(" ")
7133
+ };
7134
+ }
7135
+ case "scheduled":
7136
+ if (!event.to) return {
7137
+ verb: "unscheduled",
7138
+ detail: event.from ? `(was ${day(event.from)})` : ""
7139
+ };
7140
+ return {
7141
+ verb: "scheduled",
7142
+ detail: event.from ? `${day(event.from)} → ${day(event.to)}` : `for ${day(event.to)}`
7143
+ };
7144
+ case "moved": return {
7145
+ verb: "moved",
7146
+ detail: `${event.from.name} → ${event.to.name}`
7147
+ };
7148
+ case "transferred": return {
7149
+ verb: "moved",
7150
+ detail: `${event.from.ref} → ${event.to.ref} (${event.to.project.name}, ${event.to.column.name})`
7151
+ };
7152
+ case "renamed": return {
7153
+ verb: "renamed",
7154
+ detail: `${event.from} → ${event.to}`
7155
+ };
7156
+ case "edited": {
7157
+ if (event.from === 0) return {
7158
+ verb: "edited",
7159
+ detail: `description (new, ${event.to} chars)`
7160
+ };
7161
+ if (event.to === 0) return {
7162
+ verb: "edited",
7163
+ detail: "description (cleared)"
7164
+ };
7165
+ const delta = event.to - event.from;
7166
+ return {
7167
+ verb: "edited",
7168
+ detail: delta ? `description (${signed(delta)} chars)` : "description"
7169
+ };
7170
+ }
7171
+ case "tagged": return {
7172
+ verb: "tagged",
7173
+ detail: [...event.added.map((t) => `+${t.name}`), ...event.removed.map((t) => `−${t.name}`)].join(" ")
7174
+ };
7175
+ case "linked":
7176
+ case "unlinked": {
7177
+ const { link } = event;
7178
+ return {
7179
+ verb: event.kind,
7180
+ detail: [eventLinkName(link), link.title].filter(Boolean).join(" ")
7181
+ };
7182
+ }
7183
+ case "link_state": {
7184
+ const was = event.from ? ` (was ${event.from})` : "";
7185
+ return {
7186
+ verb: stateVerb(event.from, event.to),
7187
+ detail: `${eventLinkName(event.link)}${was}`
7188
+ };
7189
+ }
7190
+ case "deleted": return {
7191
+ verb: "deleted",
7192
+ detail: event.column ? `from ${event.column.name}` : ""
7193
+ };
7194
+ case "restored": return {
7195
+ verb: "restored",
7196
+ detail: event.column ? `to ${event.column.name}` : ""
7197
+ };
7198
+ }
7199
+ }
7200
+ const MINUTE = 6e4;
7201
+ /** How long ago, in a few characters, for a history line: "now", "5m", "3h", "2d", "5mo", "2y". */
7202
+ function eventAge(iso, now = Date.now()) {
7203
+ const minutes = Math.floor((now - new Date(iso).getTime()) / MINUTE);
7204
+ if (minutes < 1) return "now";
7205
+ if (minutes < 60) return `${minutes}m`;
7206
+ const hours = Math.floor(minutes / 60);
7207
+ if (hours < 24) return `${hours}h`;
7208
+ const days = Math.floor(hours / 24);
7209
+ if (days < 60) return `${days}d`;
7210
+ if (days < 730) return `${Math.floor(days / 30)}mo`;
7211
+ return `${Math.floor(days / 365)}y`;
7212
+ }
7213
+ //#endregion
6772
7214
  //#region ../../packages/contract/src/repo.ts
6773
7215
  /**
6774
7216
  * A project's linked repository, in the one form the database stores: github.com/<owner>/<repo>,
@@ -6846,10 +7288,20 @@ function matchColumn(columns, query) {
6846
7288
  choices: [...columns]
6847
7289
  };
6848
7290
  }
7291
+ const DAY_MS = 864e5;
7292
+ /**
7293
+ * Whether a task is archived: in its project's Done column (`doneColumnId`: doneColumn()) for longer
7294
+ * than the project's `archiveAfterDays` (null: never). The API applies the same rule when it reads.
7295
+ */
7296
+ function isArchived(task, doneColumnId, archiveAfterDays, now = Date.now()) {
7297
+ if (archiveAfterDays === null || !doneColumnId || task.columnId !== doneColumnId) return false;
7298
+ return Date.parse(task.columnSince) < now - archiveAfterDays * DAY_MS;
7299
+ }
7300
+ strictObject({ email: email().max(254).meta({ example: "ada@example.com" }) }).meta({ id: "WaitlistJoin" });
6849
7301
  //#endregion
6850
7302
  //#region src/version.ts
6851
7303
  /** This CLI's version, from package.json (set at build time by tsdown, and by vitest in tests). */
6852
- const VERSION = "1.1.0";
7304
+ const VERSION = "1.2.0";
6853
7305
  /** Sent as X-Monoban-Client, and shown in Devices & tokens. */
6854
7306
  const CLIENT = `cli/${VERSION}`;
6855
7307
  //#endregion
@@ -10178,6 +10630,18 @@ function git(cwd, ...args) {
10178
10630
  }, (err, stdout) => resolve(err ? null : stdout.trim()));
10179
10631
  });
10180
10632
  }
10633
+ /** Runs git in `cwd` and says what went wrong when it fails (git's own message). */
10634
+ function gitOrWhy(cwd, ...args) {
10635
+ return new Promise((resolve) => {
10636
+ execFile("git", args, {
10637
+ cwd,
10638
+ timeout: 15e3
10639
+ }, (err, _stdout, stderr) => resolve(err ? {
10640
+ ok: false,
10641
+ why: stderr.trim() || err.message
10642
+ } : { ok: true }));
10643
+ });
10644
+ }
10181
10645
  function clone(cwd = process.cwd()) {
10182
10646
  return {
10183
10647
  project: async () => await git(cwd, "config", "--local", "--get", "monoban.project") || null,
@@ -10196,7 +10660,13 @@ function clone(cwd = process.cwd()) {
10196
10660
  const name = await git(cwd, "rev-parse", "--abbrev-ref", "HEAD");
10197
10661
  return name && name !== "HEAD" ? name : null;
10198
10662
  },
10199
- root: async () => await git(cwd, "rev-parse", "--show-toplevel") || cwd
10663
+ root: async () => await git(cwd, "rev-parse", "--show-toplevel") || cwd,
10664
+ inClone: async () => await git(cwd, "rev-parse", "--is-inside-work-tree") === "true",
10665
+ branches: async () => (await git(cwd, "branch", "--list", "--format=%(refname:short)") ?? "").split("\n").filter(Boolean),
10666
+ switchTo: async (name, create) => {
10667
+ const result = await gitOrWhy(cwd, "switch", ...create ? ["-c", name] : [name]);
10668
+ return result.ok ? null : result.why;
10669
+ }
10200
10670
  };
10201
10671
  }
10202
10672
  //#endregion
@@ -10744,10 +11214,16 @@ function taskRefOf(ref) {
10744
11214
  if (!parsed) throw new CliError(`"${ref}" isn't a task like MON-12.`, EXIT.usage);
10745
11215
  return parsed;
10746
11216
  }
10747
- /** A task by its reference, with its ETag version (a 404 exits 5). */
10748
- async function taskByRef(api, ref) {
11217
+ /**
11218
+ * A task by its reference, with its ETag version (a 404 exits 5). A task that moved to another project is
11219
+ * found by its old reference too (a branch named after it still works); `ctx` says what it's called now.
11220
+ */
11221
+ async function taskByRef(api, ref, ctx) {
10749
11222
  const { key, number } = taskRefOf(ref);
10750
- return unwrap(api.GET("/v1/tasks/{ref}", { params: { path: { ref: `${key}-${number}` } } }));
11223
+ const asked = `${key}-${number}`;
11224
+ const task = await unwrap(api.GET("/v1/tasks/{ref}", { params: { path: { ref: asked } } }));
11225
+ if (task.ref !== asked) ctx?.err(`${asked} is ${task.ref} now: it moved to another project.`);
11226
+ return task;
10751
11227
  }
10752
11228
  /** The column `query` names (see matchColumn), or an error that lists the columns to choose from. */
10753
11229
  function findColumn(columns, query) {
@@ -10773,6 +11249,155 @@ const taskJson = (task, columns, tags) => ({
10773
11249
  /** Where the web shows a project's board, or one task on it. */
10774
11250
  const boardUrl = (ctx, key, number) => `${ctx.webUrl}/p/${key}${number === void 0 ? "" : `?task=${number}`}`;
10775
11251
  //#endregion
11252
+ //#region src/commands/history.ts
11253
+ /** The newest `count` events of a task (a page at a time), and whether it has older ones. */
11254
+ async function historyOf(api, ref, count) {
11255
+ const { key, number } = taskRefOf(ref);
11256
+ const events = [];
11257
+ let cursor;
11258
+ do {
11259
+ const limit = Math.min(count - events.length, PAGE_LIMIT.max);
11260
+ const page = await unwrap(api.GET("/v1/projects/{key}/tasks/{number}/history", { params: {
11261
+ path: {
11262
+ key,
11263
+ number
11264
+ },
11265
+ query: {
11266
+ limit,
11267
+ cursor
11268
+ }
11269
+ } }));
11270
+ events.push(...page.events);
11271
+ cursor = page.nextCursor ?? void 0;
11272
+ } while (cursor && events.length < count);
11273
+ return {
11274
+ events,
11275
+ more: cursor !== void 0
11276
+ };
11277
+ }
11278
+ /** One line per event, aligned: "2h moved To do → In progress cli". */
11279
+ function historyLines(events, { dim }, now = Date.now()) {
11280
+ const rows = events.map((e) => ({
11281
+ age: eventAge(e.updatedAt, now),
11282
+ ...describeEvent(e),
11283
+ via: e.via ?? ""
11284
+ }));
11285
+ const ageWidth = Math.max(0, ...rows.map((r) => r.age.length));
11286
+ const verbWidth = Math.max(0, ...rows.map((r) => r.verb.length));
11287
+ return rows.map((r) => {
11288
+ const via = r.via ? ` ${dim(r.via)}` : "";
11289
+ return `${dim(r.age.padStart(ageWidth))} ${r.verb.padEnd(verbWidth)} ${oneLine(r.detail)}${via}`.trimEnd();
11290
+ });
11291
+ }
11292
+ /** `monoban log MON-12`: what happened to a task, newest first (`-n` events, 20 unless you say). */
11293
+ async function log(ctx, ref, options) {
11294
+ const count = options.number === void 0 ? 20 : Number(options.number);
11295
+ if (!Number.isInteger(count) || count < 1) throw new CliError("-n is how many events to show: 1 or more.", EXIT.usage);
11296
+ const api = apis(ctx).signedIn;
11297
+ const { events, more } = await historyOf(api, ref, count);
11298
+ if (options.json) return ctx.out(JSON.stringify(events, null, 2));
11299
+ for (const line of historyLines(events, ctx.style)) ctx.out(line);
11300
+ if (more) ctx.err(`Older events too: -n ${count * 5} shows more.`);
11301
+ }
11302
+ //#endregion
11303
+ //#region src/commands/schedule.ts
11304
+ /** A day typed on the command line ("tomorrow", "fri", "2026-10-12"), or a usage error that shows how. */
11305
+ function dayArgument(input, now = today()) {
11306
+ const day = parseDay(input, now);
11307
+ if (!day) throw new CliError(`"${input}" isn't a day. Try today, tomorrow, fri, next week, +3, oct 12 or 2026-10-12.`, EXIT.usage);
11308
+ return day;
11309
+ }
11310
+ /**
11311
+ * `monoban today [DAY]`: the tasks planned for today (or DAY, or 7 days with --week) in every project, done
11312
+ * ones ticked. From today, the overdue ones come first: planned before and not done.
11313
+ */
11314
+ async function todayView(ctx, dayInput, options) {
11315
+ const now = today();
11316
+ const from = dayInput ? dayArgument(dayInput, now) : now;
11317
+ const to = options.week ? addDays(from, 6) : from;
11318
+ const api = apis(ctx).signedIn;
11319
+ const tasks = [];
11320
+ const query = {
11321
+ from,
11322
+ to,
11323
+ ...from === now && { overdue: "true" }
11324
+ };
11325
+ for await (const task of pages((cursor) => unwrap(api.GET("/v1/schedule", { params: { query: {
11326
+ ...query,
11327
+ cursor
11328
+ } } })).then((page) => ({
11329
+ items: page.tasks,
11330
+ nextCursor: page.nextCursor
11331
+ })))) tasks.push(task);
11332
+ if (options.json) return ctx.out(JSON.stringify(tasks, null, 2));
11333
+ const { bold, dim, color } = ctx.style;
11334
+ const late = tasks.filter((t) => t.scheduledOn < from);
11335
+ const planned = tasks.filter((t) => t.scheduledOn >= from);
11336
+ const name = options.week ? `Next 7 days from ${longDay(from, now)}` : headingOf(from, now);
11337
+ const done = planned.filter((t) => t.done).length;
11338
+ ctx.out(`${bold(name)} ${dim(planned.length ? `${done} of ${planned.length} done` : "nothing planned")}`);
11339
+ if (tasks.length === 0) {
11340
+ ctx.err(`Plan a task for it: monoban schedule MON-12 ${dayInput ?? "today"}`);
11341
+ return;
11342
+ }
11343
+ const refWidth = Math.max(...tasks.map((t) => t.ref.length));
11344
+ const columnWidth = Math.max(...tasks.map((t) => [...t.column.name].length));
11345
+ const line = (t, extra = "") => {
11346
+ const mark = t.done ? color("green", "✓") : " ";
11347
+ const column = `${t.column.name}${" ".repeat(columnWidth - [...t.column.name].length)}`;
11348
+ const title = t.done ? dim(oneLine(t.title)) : oneLine(t.title);
11349
+ return `${mark} ${t.ref.padEnd(refWidth)} ${dim(column)} ${title}${extra}`;
11350
+ };
11351
+ if (late.length) {
11352
+ ctx.out("");
11353
+ ctx.out(color("amber", `Overdue · ${late.length}`));
11354
+ for (const t of late) ctx.out(line(t, ` ${color("amber", `${daysBetween(t.scheduledOn, now)}d late`)}`));
11355
+ }
11356
+ for (let day = from; day <= to; day = addDays(day, 1)) {
11357
+ const of = planned.filter((t) => t.scheduledOn === day);
11358
+ if (options.week ? of.length === 0 : planned.length === 0) continue;
11359
+ if (options.week || late.length) {
11360
+ ctx.out("");
11361
+ ctx.out(bold(options.week ? headingOf(day, now) : name));
11362
+ }
11363
+ for (const t of of) ctx.out(line(t));
11364
+ }
11365
+ }
11366
+ /** "Today · Thu Oct 2", "Tomorrow · Fri Oct 3", or just "Mon Oct 12". */
11367
+ function headingOf(day, now) {
11368
+ const near = formatDay(day, now);
11369
+ const long = longDay(day, now);
11370
+ return [
11371
+ "today",
11372
+ "tomorrow",
11373
+ "yesterday"
11374
+ ].includes(near) ? `${near[0]?.toUpperCase()}${near.slice(1)} · ${long}` : long;
11375
+ }
11376
+ /** `monoban schedule MON-12 fri`: plans a task for a day; --clear takes its date off. */
11377
+ async function schedule(ctx, ref, dayInput, options) {
11378
+ if (dayInput === void 0 === !options.clear) throw new CliError("Say a day (monoban schedule MON-12 tomorrow), or --clear to take the date off.", EXIT.usage);
11379
+ const now = today();
11380
+ const day = dayInput === void 0 ? null : dayArgument(dayInput, now);
11381
+ const api = apis(ctx).signedIn;
11382
+ const task = await taskByRef(api, ref, ctx);
11383
+ const { key, number } = taskRefOf(task.ref);
11384
+ const saved = task.scheduledOn === day ? task : await unwrap(api.PATCH("/v1/projects/{key}/tasks/{number}", {
11385
+ params: {
11386
+ path: {
11387
+ key,
11388
+ number
11389
+ },
11390
+ header: ifMatch(task.version)
11391
+ },
11392
+ body: { scheduledOn: day }
11393
+ })).catch((err) => changedElsewhere(err, task.ref));
11394
+ if (options.json) {
11395
+ const [columns, tags] = await Promise.all([columnsOf(api, key), saved.tagIds.length ? tagsOf(api, key) : []]);
11396
+ return ctx.out(JSON.stringify(taskJson(saved, columns, tags), null, 2));
11397
+ }
11398
+ ctx.out(day ? `${saved.ref} is planned for ${longDay(day, now)} (${formatDay(day, now)}).` : `${saved.ref} has no date now.`);
11399
+ }
11400
+ //#endregion
10776
11401
  //#region src/commands/board.ts
10777
11402
  const printJson$1 = (ctx, value) => ctx.out(JSON.stringify(value, null, 2));
10778
11403
  /** `monoban projects`: your projects, with their keys and repositories; * marks this folder's. */
@@ -10800,12 +11425,15 @@ async function projects(ctx, options) {
10800
11425
  }
10801
11426
  }
10802
11427
  const tasks = (p) => `${p.taskCount} ${p.taskCount === 1 ? "task" : "tasks"}`;
10803
- /** `monoban list [COLUMN…]`: the board, by column (every column, or the ones named); `--tag` keeps a tag's tasks. */
11428
+ /**
11429
+ * `monoban list [COLUMN…]`: the board, by column (every column, or the ones named); `--tag` keeps a tag's
11430
+ * tasks. `--archived`: the archived ones instead (done a while ago, off the board).
11431
+ */
10804
11432
  async function list(ctx, columnQueries, options) {
10805
11433
  const api = apis(ctx).signedIn;
10806
11434
  const key = await resolveProject(ctx, api, options.project);
10807
11435
  const board = await unwrap(api.GET("/v1/projects/{key}/board", { params: { path: { key } } }));
10808
- let tasks = board.truncated ? await allTasks(api, key) : board.tasks;
11436
+ let tasks = options.archived ? await allTasks(api, key, true) : board.truncated ? await allTasks(api, key) : board.tasks;
10809
11437
  if (options.tag !== void 0) {
10810
11438
  const tag = findTag(board.tags, options.tag);
10811
11439
  if (!tag) {
@@ -10814,19 +11442,23 @@ async function list(ctx, columnQueries, options) {
10814
11442
  }
10815
11443
  tasks = tasks.filter((t) => t.tagIds.includes(tag.id));
10816
11444
  }
10817
- const groups = (columnQueries.length ? [...new Set(columnQueries.map((q) => findColumn(board.columns, q)))] : board.columns).map((column) => ({
11445
+ const groups = (columnQueries.length ? [...new Set(columnQueries.map((q) => findColumn(board.columns, q)))] : options.archived ? board.columns.filter((c) => tasks.some((t) => t.columnId === c.id)) : board.columns).map((column) => ({
10818
11446
  column,
10819
11447
  tasks: tasks.filter((t) => t.columnId === column.id)
10820
11448
  }));
10821
11449
  if (options.json) return printJson$1(ctx, groups.flatMap((g) => g.tasks.map((t) => taskJson(t, board.columns, board.tags))));
10822
11450
  const { bold, dim } = ctx.style;
10823
11451
  const repo = board.project.repo ? ` · ${board.project.repo}` : "";
10824
- ctx.out(`${bold(board.project.name)} ${dim(`(${board.project.key})${repo}`)}`);
11452
+ ctx.out(`${bold(board.project.name)} ${dim(`(${board.project.key})${repo}`)}${options.archived ? " archived" : ""}`);
11453
+ if (options.archived && tasks.length === 0) ctx.err(board.project.archiveAfterDays === null ? "Nothing archived: this project keeps its done tasks on the board." : `Nothing archived yet: tasks go after ${board.project.archiveAfterDays} days in ${doneColumn(board.columns)?.name ?? "Done"}.`);
10825
11454
  const rows = groups.flatMap((g) => g.tasks);
10826
11455
  const refWidth = Math.max(0, ...rows.map((t) => t.ref.length));
11456
+ const now = today();
11457
+ const done = doneColumn(board.columns)?.id;
10827
11458
  const meta = (t) => {
10828
11459
  const list = checklist(t.description);
10829
- return `${list ? `[${list.done}/${list.all}] ` : ""}${age(t.updatedAt).padStart(5)}`;
11460
+ const late = t.scheduledOn && t.columnId !== done && t.scheduledOn < now;
11461
+ return `${t.scheduledOn ? `@${formatDay(t.scheduledOn, now)}${late ? "!" : ""} ` : ""}${list ? `[${list.done}/${list.all}] ` : ""}${age(t.updatedAt).padStart(5)}`;
10830
11462
  };
10831
11463
  const metaWidth = Math.max(0, ...rows.map((t) => meta(t).length));
10832
11464
  const cell = (t, width) => titleCell(oneLine(t.title), tagsOfTask(t, board.tags), width, ctx.style);
@@ -10840,6 +11472,7 @@ async function list(ctx, columnQueries, options) {
10840
11472
  const pad = " ".repeat(Math.max(0, titleWidth - visibleLength(title)));
10841
11473
  ctx.out(` ${dim(t.ref.padEnd(refWidth))} ${title}${pad} ${dim(meta(t).padStart(metaWidth))}`.trimEnd());
10842
11474
  }
11475
+ if (!options.archived && board.archived > 0 && column.id === done && options.tag === void 0) ctx.out(dim(` + ${board.archived} archived (monoban list --archived)`));
10843
11476
  }
10844
11477
  }
10845
11478
  /**
@@ -10860,11 +11493,16 @@ function titleCell(title, tags, width, style) {
10860
11493
  }
10861
11494
  return truncate(title, width);
10862
11495
  }
10863
- async function allTasks(api, key) {
11496
+ /** A project's tasks, page by page: the ones on the board, or the archived ones. */
11497
+ async function allTasks(api, key, archived = false) {
10864
11498
  const all = [];
11499
+ const query = (cursor) => ({
11500
+ cursor,
11501
+ ...archived && { archived: "true" }
11502
+ });
10865
11503
  for await (const t of pages((cursor) => unwrap(api.GET("/v1/projects/{key}/tasks", { params: {
10866
11504
  path: { key },
10867
- query: { cursor }
11505
+ query: query(cursor)
10868
11506
  } })).then((page) => ({
10869
11507
  items: page.tasks,
10870
11508
  nextCursor: page.nextCursor
@@ -10875,18 +11513,27 @@ const ago = (iso) => {
10875
11513
  const a = age(iso);
10876
11514
  return a === "today" ? a : `${a} ago`;
10877
11515
  };
10878
- /** `monoban show MON-12`: a task in full. */
11516
+ /** How many history events `show` ends with. */
11517
+ const SHOW_HISTORY = 3;
11518
+ /** `monoban show MON-12`: a task in full, and what happened to it last. */
10879
11519
  async function show(ctx, ref, options) {
10880
11520
  const api = apis(ctx).signedIn;
10881
- const task = await taskByRef(api, ref);
11521
+ const task = await taskByRef(api, ref, ctx);
10882
11522
  const key = taskRefOf(task.ref).key;
10883
- const [columns, tags] = await Promise.all([columnsOf(api, key), tagsFor(api, key, task)]);
11523
+ const [columns, tags, history] = await Promise.all([
11524
+ columnsOf(api, key),
11525
+ tagsFor(api, key, task),
11526
+ options.json ? null : historyOf(api, task.ref, SHOW_HISTORY).catch(() => null)
11527
+ ]);
10884
11528
  if (options.json) return printJson$1(ctx, taskJson(task, columns, tags));
10885
11529
  const { bold, dim } = ctx.style;
10886
- const column = columns.find((c) => c.id === task.columnId)?.name ?? "?";
11530
+ const doneId = doneColumn(columns)?.id;
11531
+ const archived = task.columnId === doneId && isArchived(task, doneId, (await unwrap(api.GET("/v1/projects/{key}", { params: { path: { key } } }))).project.archiveAfterDays);
11532
+ const column = `${columns.find((c) => c.id === task.columnId)?.name ?? "?"}${archived ? " · archived" : ""}`;
10887
11533
  const list = checklist(task.description);
10888
11534
  ctx.out(`${bold(task.ref)} ${bold(task.title)}`);
10889
- ctx.out(dim(`${column} · created ${ago(task.createdAt)} · updated ${ago(task.updatedAt)}`));
11535
+ const when = task.scheduledOn ? ` · ${planned(task, columns)}` : "";
11536
+ ctx.out(dim(`${column}${when} · created ${ago(task.createdAt)} · updated ${ago(task.updatedAt)}`));
10890
11537
  const own = tagsOfTask(task, tags);
10891
11538
  if (own.length) ctx.out(tagWords(own, ctx.style));
10892
11539
  if (list) ctx.out(dim(`Checklist ${list.done}/${list.all}`));
@@ -10901,6 +11548,19 @@ async function show(ctx, ref, options) {
10901
11548
  ctx.out("");
10902
11549
  ctx.out(task.description.trimEnd());
10903
11550
  }
11551
+ if (history?.events.length) {
11552
+ ctx.out("");
11553
+ ctx.out(dim(history.more ? `History (all of it: monoban log ${task.ref})` : "History"));
11554
+ for (const line of historyLines(history.events, ctx.style)) ctx.out(` ${line}`);
11555
+ }
11556
+ }
11557
+ /** When a task is planned for: "for tomorrow", or "for Oct 1, 2d late" past it and not done. */
11558
+ function planned(task, columns) {
11559
+ if (!task.scheduledOn) return "";
11560
+ const now = today();
11561
+ const late = daysBetween(task.scheduledOn, now);
11562
+ const done = doneColumn(columns)?.id === task.columnId;
11563
+ return `for ${formatDay(task.scheduledOn, now)}${late > 0 && !done ? `, ${late}d late` : ""}`;
10904
11564
  }
10905
11565
  /** The project's tags, when `task` has any to name (else none: one request fewer). */
10906
11566
  const tagsFor = async (api, key, task) => task.tagIds.length ? tagsOf(api, key) : [];
@@ -10909,6 +11569,7 @@ async function add(ctx, title, options) {
10909
11569
  if (options.description !== void 0 && options.edit) throw new CliError("Use -d or -e, not both.", EXIT.usage);
10910
11570
  const names = options.tag ?? [];
10911
11571
  assertTagCount(new Set(names).size);
11572
+ const scheduledOn = options.date === void 0 ? void 0 : dayArgument(options.date);
10912
11573
  const api = apis(ctx).signedIn;
10913
11574
  const key = await resolveProject(ctx, api, options.project);
10914
11575
  const [columns, tags] = await Promise.all([columnsOf(api, key), names.length ? tagsOf(api, key) : []]);
@@ -10925,17 +11586,19 @@ async function add(ctx, title, options) {
10925
11586
  title,
10926
11587
  ...description ? { description } : {},
10927
11588
  ...column ? { columnId: column.id } : {},
10928
- ...tagIds.length ? { tagIds } : {}
11589
+ ...tagIds.length ? { tagIds } : {},
11590
+ ...scheduledOn ? { scheduledOn } : {}
10929
11591
  }
10930
11592
  }));
10931
11593
  if (options.json) return printJson$1(ctx, taskJson(task, columns, tags));
10932
11594
  const tagged = tagIds.length ? ` ${tagWords(tagsOfTask(task, tags), ctx.style)}` : "";
10933
- ctx.out(`Added ${task.ref} to ${column?.name ?? "the board"}: ${task.title}${tagged}`);
11595
+ const when = scheduledOn ? `, for ${formatDay(scheduledOn, today())}` : "";
11596
+ ctx.out(`Added ${task.ref} to ${column?.name ?? "the board"}${when}: ${task.title}${tagged}`);
10934
11597
  }
10935
11598
  /** `monoban tag MON-12 bug ui`: puts tags on a task (a name that isn't a tag yet becomes one). */
10936
11599
  async function tag(ctx, ref, names, options) {
10937
11600
  const api = apis(ctx).signedIn;
10938
- const task = await taskByRef(api, ref);
11601
+ const task = await taskByRef(api, ref, ctx);
10939
11602
  const key = taskRefOf(task.ref).key;
10940
11603
  const tags = await tagsOf(api, key);
10941
11604
  const adding = (await resolveTags(ctx, api, key, names, tags)).filter((t) => !task.tagIds.includes(t.id));
@@ -10953,7 +11616,7 @@ async function tag(ctx, ref, names, options) {
10953
11616
  /** `monoban untag MON-12 bug`: takes tags off a task (the tags themselves stay). */
10954
11617
  async function untag(ctx, ref, names, options) {
10955
11618
  const api = apis(ctx).signedIn;
10956
- const task = await taskByRef(api, ref);
11619
+ const task = await taskByRef(api, ref, ctx);
10957
11620
  const key = taskRefOf(task.ref).key;
10958
11621
  const tags = await tagsOf(api, key);
10959
11622
  const own = tagsOfTask(task, tags);
@@ -11001,17 +11664,49 @@ async function tags(ctx, options) {
11001
11664
  ctx.out(`${name} ${dim(where)} ${dim(count)}`);
11002
11665
  }
11003
11666
  }
11004
- /** `monoban move MON-12 done`: to the end of another column. */
11667
+ /**
11668
+ * `monoban move MON-12 in-progress`: to the end of another column. With `--to WEB`, to another project
11669
+ * (to the column you say, else the one named like its column, else the first), where it gets a new number.
11670
+ */
11005
11671
  async function move(ctx, ref, columnQuery, options) {
11006
11672
  const api = apis(ctx).signedIn;
11007
- const task = await taskByRef(api, ref);
11008
- const columns = await columnsOf(api, taskRefOf(task.ref).key);
11673
+ const task = await taskByRef(api, ref, ctx);
11674
+ const { key } = taskRefOf(task.ref);
11675
+ const to = options.to?.trim().toUpperCase();
11676
+ if (to && to !== key) return transfer(ctx, api, task, to, columnQuery, options);
11677
+ if (columnQuery === void 0) {
11678
+ if (to) throw new CliError(`${task.ref} is in ${to} already. Say a column to move it to.`, EXIT.usage);
11679
+ throw new CliError("Say where: monoban move MON-12 in-progress (or --to WEB, another project).", EXIT.usage);
11680
+ }
11681
+ const columns = await columnsOf(api, key);
11009
11682
  await moveTo(ctx, api, task, columns, findColumn(columns, columnQuery), options);
11010
11683
  }
11684
+ /** Moves a task to project `to` (its column `columnQuery`, if given). */
11685
+ async function transfer(ctx, api, task, to, columnQuery, options) {
11686
+ const columns = await columnsOf(api, to);
11687
+ const target = columnQuery === void 0 ? void 0 : findColumn(columns, columnQuery);
11688
+ const { key, number } = taskRefOf(task.ref);
11689
+ const moved = await unwrap(api.POST("/v1/projects/{key}/tasks/{number}/transfer", {
11690
+ params: {
11691
+ path: {
11692
+ key,
11693
+ number
11694
+ },
11695
+ header: ifMatch(task.version)
11696
+ },
11697
+ body: {
11698
+ project: to,
11699
+ ...target && { columnId: target.id }
11700
+ }
11701
+ })).catch((err) => changedElsewhere(err, task.ref));
11702
+ if (options.json) return printJson$1(ctx, taskJson(moved, columns, await tagsFor(api, to, moved)));
11703
+ const column = columns.find((c) => c.id === moved.columnId)?.name ?? "its first column";
11704
+ ctx.out(`Moved ${task.ref} to ${to}: it's ${moved.ref} now, in ${column}.`);
11705
+ }
11011
11706
  /** `monoban done MON-12`: to the column called Done, or else the last one. */
11012
11707
  async function done(ctx, ref, options) {
11013
11708
  const api = apis(ctx).signedIn;
11014
- const task = await taskByRef(api, ref);
11709
+ const task = await taskByRef(api, ref, ctx);
11015
11710
  const columns = await columnsOf(api, taskRefOf(task.ref).key);
11016
11711
  const target = columns.find((c) => c.name.trim().toLowerCase() === "done") ?? columns.at(-1);
11017
11712
  if (!target) throw new CliError(`${task.ref}'s project has no columns.`);
@@ -11045,7 +11740,7 @@ async function moveTo(ctx, api, task, columns, target, options) {
11045
11740
  */
11046
11741
  async function edit(ctx, ref, options) {
11047
11742
  const api = apis(ctx).signedIn;
11048
- const task = await taskByRef(api, ref);
11743
+ const task = await taskByRef(api, ref, ctx);
11049
11744
  const direct = options.title !== void 0 || options.description !== void 0;
11050
11745
  let text = "";
11051
11746
  let title;
@@ -11096,7 +11791,7 @@ async function edit(ctx, ref, options) {
11096
11791
  /** `monoban rm MON-12`: asks first, unless -y. */
11097
11792
  async function rm$1(ctx, ref, options) {
11098
11793
  const api = apis(ctx).signedIn;
11099
- const task = await taskByRef(api, ref);
11794
+ const task = await taskByRef(api, ref, ctx);
11100
11795
  if (!options.yes) {
11101
11796
  if (!ctx.tty.in) throw new CliError(`To delete ${task.ref} without a terminal to ask on, pass -y.`, EXIT.usage);
11102
11797
  if (!await ctx.confirm(`Delete ${task.ref} "${oneLine(task.title)}"?`)) {
@@ -11237,7 +11932,7 @@ async function attach(ctx, args, options) {
11237
11932
  if (!(err instanceof NoGh)) ctx.err(`Couldn't read it with gh (${err.message}); attaching it as it is.`);
11238
11933
  }
11239
11934
  const api = apis(ctx).signedIn;
11240
- const task = await taskByRef(api, ref);
11935
+ const task = await taskByRef(api, ref, ctx);
11241
11936
  const had = task.links.some((l) => l.url === parsed.url);
11242
11937
  const { key, number } = taskRefOf(task.ref);
11243
11938
  const title = options.title ?? item?.title;
@@ -11258,7 +11953,7 @@ async function attach(ctx, args, options) {
11258
11953
  /** `monoban detach MON-12 #54`: takes a link off (by its number, its URL, or where it points). */
11259
11954
  async function detach(ctx, ref, which, options) {
11260
11955
  const api = apis(ctx).signedIn;
11261
- const task = await taskByRef(api, ref);
11956
+ const task = await taskByRef(api, ref, ctx);
11262
11957
  const wanted = which.trim();
11263
11958
  const number = /^#?([1-9][0-9]*)$/.exec(wanted)?.[1];
11264
11959
  const url = parseLink(wanted)?.url;
@@ -11340,6 +12035,47 @@ async function notesEdit(ctx, options) {
11340
12035
  ctx.out(`Updated the notes of ${key}.`);
11341
12036
  }
11342
12037
  //#endregion
12038
+ //#region src/commands/search.ts
12039
+ /**
12040
+ * `monoban search login page`: the tasks with all of these words (in the title or description, as a tag, or
12041
+ * as the reference), in every project, the last changed first, archived ones too. `-n` of them, 30 unless
12042
+ * you say.
12043
+ */
12044
+ async function search(ctx, words, options) {
12045
+ const q = words.join(" ").trim();
12046
+ if (!q) throw new CliError("Say what to look for: monoban search login page", EXIT.usage);
12047
+ const count = options.number === void 0 ? 30 : Number(options.number);
12048
+ if (!Number.isInteger(count) || count < 1) throw new CliError("-n is how many tasks to show: 1 or more.", EXIT.usage);
12049
+ const api = apis(ctx).signedIn;
12050
+ const tasks = [];
12051
+ let cursor;
12052
+ do {
12053
+ const limit = Math.min(count - tasks.length, PAGE_LIMIT.max);
12054
+ const page = await unwrap(api.GET("/v1/search", { params: { query: {
12055
+ q,
12056
+ limit,
12057
+ cursor
12058
+ } } }));
12059
+ tasks.push(...page.tasks);
12060
+ cursor = page.nextCursor ?? void 0;
12061
+ } while (cursor && tasks.length < count);
12062
+ if (options.json) return ctx.out(JSON.stringify(tasks, null, 2));
12063
+ if (tasks.length === 0) {
12064
+ ctx.err(`No task has "${q}".`);
12065
+ return;
12066
+ }
12067
+ const { dim, color } = ctx.style;
12068
+ const refWidth = Math.max(...tasks.map((t) => t.ref.length));
12069
+ const columnWidth = Math.max(...tasks.map((t) => [...t.column.name].length));
12070
+ for (const t of tasks) {
12071
+ const mark = t.done ? color("green", "✓") : " ";
12072
+ const column = `${t.column.name}${" ".repeat(columnWidth - [...t.column.name].length)}`;
12073
+ const title = t.done ? dim(oneLine(t.title)) : oneLine(t.title);
12074
+ ctx.out(`${mark} ${t.ref.padEnd(refWidth)} ${dim(column)} ${title}${t.archived ? ` ${dim("archived")}` : ""}`);
12075
+ }
12076
+ if (cursor) ctx.err(`More tasks have it: -n ${count * 5} shows more.`);
12077
+ }
12078
+ //#endregion
11343
12079
  //#region src/skill.ts
11344
12080
  /** The coding agents `monoban setup` teaches monoban to. */
11345
12081
  const AGENTS = ["claude", "codex"];
@@ -11360,6 +12096,9 @@ const READ_ONLY = [
11360
12096
  "monoban list",
11361
12097
  "monoban ls",
11362
12098
  "monoban show",
12099
+ "monoban log",
12100
+ "monoban today",
12101
+ "monoban search",
11363
12102
  "monoban tags",
11364
12103
  "monoban notes show"
11365
12104
  ];
@@ -11393,6 +12132,8 @@ plans into tasks on the board and to keep those tasks current while you work.
11393
12132
  running it (it changes the project).
11394
12133
  3. Read with \`--json\`: \`monoban list --json\` (every task, with its \`column\` and \`tags\`),
11395
12134
  \`monoban show MON-12 --json\`, \`monoban tags --json\`, and \`monoban notes show\` for the notes.
12135
+ \`monoban log MON-12\` shows what happened to a task, when, and through what (web or cli).
12136
+ \`monoban search WORDS\` finds a task in any project ("the login bug": \`monoban search login bug\`).
11396
12137
 
11397
12138
  If a command can't reach the API (a sandbox without network), ask the user to allow it; don't work around it.
11398
12139
 
@@ -11451,8 +12192,9 @@ shows one phase.
11451
12192
  Ask once before you start updating the board in a session ("Shall I keep MON-31…MON-35 up to date as I
11452
12193
  go?"). Once the user agrees:
11453
12194
 
11454
- - Starting a task: \`monoban move MON-31 "in progress"\` (columns match in any case, or by a unique prefix;
11455
- use the names \`monoban list\` shows).
12195
+ - Starting a task: \`monoban start MON-31\` in the repository: it checks out the task's branch (\`mon-31-…\`,
12196
+ made from the commit you're on, so be on the right base first) and moves it to In progress. Elsewhere,
12197
+ \`monoban move MON-31 "in progress"\` (columns match in any case, or by a unique prefix).
11456
12198
  - Ticking the checklist: read the description (\`monoban show MON-31 --json\`), change \`- [ ]\` to \`- [x]\`,
11457
12199
  and write the whole description back with \`monoban edit MON-31 -d -\` (stdin, a heredoc as above).
11458
12200
  - Opened a pull request for it: \`monoban attach MON-31 --pr\` right after \`gh pr create\` (on a branch named
@@ -11461,6 +12203,8 @@ go?"). Once the user agrees:
11461
12203
  or whatever they said). If unsure, ask. After a merge, attach the pull request again
11462
12204
  (\`monoban attach MON-31 <its URL>\`) so the board shows it merged.
11463
12205
  - New work you discover: propose a task; don't add it silently.
12206
+ - Planning for a day: only when the user gives one ("do it Friday"): \`monoban schedule MON-31 fri\`. Their
12207
+ \`monoban today\` shows it then, and late until it's done. "What's on today?" is \`monoban today\`.
11464
12208
 
11465
12209
  "changed elsewhere" means someone edited the task since you read it: read it again, then retry once.
11466
12210
 
@@ -11477,13 +12221,19 @@ go?"). Once the user agrees:
11477
12221
  | Command | Does |
11478
12222
  | --- | --- |
11479
12223
  | \`monoban projects\` | the projects and their keys |
11480
- | \`monoban list [COLUMN…] [--tag TAG]\` | tasks by column |
12224
+ | \`monoban list [COLUMN…] [--tag TAG] [--archived]\` | tasks by column (--archived: the ones done long ago) |
11481
12225
  | \`monoban show MON-12\` | one task in full |
12226
+ | \`monoban log MON-12 [-n COUNT]\` | what happened to it, newest first |
12227
+ | \`monoban today [DAY] [--week]\` | what's planned for today (overdue first) in every project |
12228
+ | \`monoban search WORDS… [-n COUNT]\` | tasks with all the words, in every project, last changed first |
12229
+ | \`monoban schedule MON-12 DAY\` (or \`--clear\`) | plan it for a day: today, tomorrow, fri, +3, oct 12 |
11482
12230
  | \`monoban tags\` | the tags the project's tasks can have |
11483
12231
  | \`monoban notes show\` | the project's notes |
11484
- | \`monoban add "TITLE" [-c COLUMN] [-t TAG]… [-d TEXT \\| -d -]\` | add a task |
12232
+ | \`monoban add "TITLE" [-c COLUMN] [-t TAG]… [--date DAY] [-d TEXT \\| -d -]\` | add a task |
11485
12233
  | \`monoban edit MON-12 [--title TEXT] [-d TEXT \\| -d -]\` | replace its title or description |
11486
12234
  | \`monoban move MON-12 COLUMN\` | move it to the end of a column |
12235
+ | \`monoban move MON-12 --to KEY [COLUMN]\` | move it to another project (it gets a new ref there: say it; the old one still finds it) |
12236
+ | \`monoban start MON-12 [--no-branch]\` | check out its branch (mon-12-title) and move it to In progress |
11487
12237
  | \`monoban done MON-12\` | move it to Done |
11488
12238
  | \`monoban tag MON-12 TAG…\` / \`monoban untag MON-12 TAG…\` | put tags on it / take them off |
11489
12239
  | \`monoban attach MON-12 --pr\` or \`monoban attach MON-12 URL\` | attach this branch's pull request, or any link |
@@ -11550,6 +12300,91 @@ async function setup(ctx, agent, options) {
11550
12300
  ctx.err(options.project ? `Commit it so everyone working in this repository gets it. New ${name} sessions use it.` : `New ${name} sessions use it, in any repository. Ask one to plan something, or say "put it on monoban".`);
11551
12301
  }
11552
12302
  //#endregion
12303
+ //#region src/commands/start.ts
12304
+ /** How long a branch name's words may be, after `mon-12-`. */
12305
+ const SLUG_LENGTH = 40;
12306
+ /** The branch for a task: `mon-12-import-boards-from-trello` (its ref, then its title's first words). */
12307
+ function branchName(ref, title) {
12308
+ const words = title.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
12309
+ const cut = words.length > SLUG_LENGTH ? words.slice(0, 41).replace(/-[^-]*$/, "") : words;
12310
+ return [ref.toLowerCase(), cut].filter(Boolean).join("-");
12311
+ }
12312
+ /**
12313
+ * The column where work happens: the one named In progress (or Doing, WIP…), else the one after the
12314
+ * first, unless that's Done. undefined when the board has none (Backlog and Done only).
12315
+ */
12316
+ function workColumn(columns) {
12317
+ const names = [
12318
+ "in progress",
12319
+ "in-progress",
12320
+ "doing",
12321
+ "wip",
12322
+ "started",
12323
+ "working",
12324
+ "active"
12325
+ ];
12326
+ const named = columns.find((c) => names.includes(c.name.trim().toLowerCase()));
12327
+ if (named) return named;
12328
+ const second = columns[1];
12329
+ return second && second !== doneColumn(columns) ? second : void 0;
12330
+ }
12331
+ /**
12332
+ * `monoban start MON-12`: work on a task. Checks out its branch (`mon-12-title`: made from the commit
12333
+ * you're on, or the one already there) and moves it to In progress, unless it's there or further on.
12334
+ * --no-branch and --no-move do half of it.
12335
+ */
12336
+ async function start(ctx, ref, options) {
12337
+ const api = apis(ctx).signedIn;
12338
+ let task = await taskByRef(api, ref, ctx);
12339
+ const { key, number } = taskRefOf(task.ref);
12340
+ const columns = await columnsOf(api, key);
12341
+ const lines = [];
12342
+ let branch = null;
12343
+ if (options.branch !== false) {
12344
+ if (!await ctx.clone.inClone()) throw new CliError("Not in a git clone, so there's no branch to make. Run it in the repository, or with --no-branch.", EXIT.usage);
12345
+ const current = await ctx.clone.branch();
12346
+ const own = (name) => taskOfBranch(name) === task.ref;
12347
+ if (own(current)) {
12348
+ branch = current;
12349
+ lines.push(`Already on ${branch}.`);
12350
+ } else {
12351
+ const existing = (await ctx.clone.branches()).find(own);
12352
+ branch = existing ?? branchName(task.ref, task.title);
12353
+ const why = await ctx.clone.switchTo(branch, !existing);
12354
+ if (why) throw new CliError(`git couldn't switch to ${branch}: ${why}`);
12355
+ lines.push(existing ? `Switched to ${branch}.` : `Switched to a new branch ${branch}.`);
12356
+ }
12357
+ }
12358
+ if (options.move !== false) {
12359
+ const target = workColumn(columns);
12360
+ const at = (t) => columns.findIndex((c) => c.id === t.columnId);
12361
+ const here = columns[at(task)];
12362
+ if (!target) lines.push(`${task.ref} stays in ${here?.name ?? "its column"}: the board has no In progress column.`);
12363
+ else if (at(task) >= columns.indexOf(target)) lines.push(`${task.ref} is in ${here?.name ?? "its column"} already.`);
12364
+ else {
12365
+ task = await unwrap(api.PATCH("/v1/projects/{key}/tasks/{number}", {
12366
+ params: {
12367
+ path: {
12368
+ key,
12369
+ number
12370
+ },
12371
+ header: ifMatch(task.version)
12372
+ },
12373
+ body: { columnId: target.id }
12374
+ })).catch((err) => changedElsewhere(err, task.ref));
12375
+ lines.push(`Moved ${task.ref}${here ? ` from ${here.name}` : ""} to ${target.name}.`);
12376
+ }
12377
+ }
12378
+ if (options.json) {
12379
+ const json = {
12380
+ ...taskJson(task, columns, await tagsFor(api, key, task)),
12381
+ branch
12382
+ };
12383
+ return ctx.out(JSON.stringify(json, null, 2));
12384
+ }
12385
+ for (const line of lines) ctx.out(line);
12386
+ }
12387
+ //#endregion
11553
12388
  //#region src/complete.ts
11554
12389
  /**
11555
12390
  * Shell completion (`monoban completion bash|zsh|fish`). The scripts are thin: on Tab they run
@@ -11565,6 +12400,7 @@ const SHELLS = [
11565
12400
  const VALUES = {
11566
12401
  project: "projects",
11567
12402
  key: "projects",
12403
+ to: "projects",
11568
12404
  column: "columns",
11569
12405
  columns: "columns",
11570
12406
  task: "tasks",
@@ -11579,11 +12415,13 @@ async function complete(root, words, lookup) {
11579
12415
  let command = root;
11580
12416
  let positionals = 0;
11581
12417
  let pending;
12418
+ let to;
11582
12419
  let project;
11583
12420
  let taskProject;
11584
12421
  let dashes = false;
11585
12422
  for (const word of words.slice(0, -1)) if (pending) {
11586
12423
  if (pending.attributeName() === "project") project = word;
12424
+ if (pending.attributeName() === "to") to = word;
11587
12425
  pending = void 0;
11588
12426
  } else if (!dashes && word === "--") dashes = true;
11589
12427
  else if (!dashes && word.startsWith("-") && word !== "-") {
@@ -11592,6 +12430,7 @@ async function complete(root, words, lookup) {
11592
12430
  if (option && takesValue(option)) {
11593
12431
  if (value === void 0) pending = option;
11594
12432
  else if (option.attributeName() === "project") project = value;
12433
+ else if (option.attributeName() === "to") to = value;
11595
12434
  }
11596
12435
  } else if (command.commands.length) {
11597
12436
  const next = command.commands.find((c) => c.name() === word || c.aliases().includes(word));
@@ -11602,7 +12441,11 @@ async function complete(root, words, lookup) {
11602
12441
  taskProject ??= parseTaskRef(word)?.key;
11603
12442
  }
11604
12443
  project ??= taskProject;
11605
- if (pending) return values(pending.attributeName(), pending.argChoices, lookup, project, current);
12444
+ const where = {
12445
+ project,
12446
+ columns: to ?? project
12447
+ };
12448
+ if (pending) return values(pending.attributeName(), pending.argChoices, lookup, where, current);
11606
12449
  if (!dashes && current.startsWith("-")) return help.visibleOptions(command).flatMap((o) => o.long ? [{
11607
12450
  value: o.long,
11608
12451
  description: o.description
@@ -11614,16 +12457,16 @@ async function complete(root, words, lookup) {
11614
12457
  const args = command.registeredArguments;
11615
12458
  const last = args.at(-1);
11616
12459
  const arg = args[positionals] ?? (last?.variadic ? last : void 0);
11617
- return arg ? values(arg.name(), arg.argChoices, lookup, project, current) : [];
12460
+ return arg ? values(arg.name(), arg.argChoices, lookup, where, current) : [];
11618
12461
  }
11619
- function values(name, choices, lookup, project, current) {
12462
+ function values(name, choices, lookup, { project, columns }, current) {
11620
12463
  if (choices) return choices.map((value) => ({
11621
12464
  value,
11622
12465
  description: ""
11623
12466
  }));
11624
12467
  switch (VALUES[name]) {
11625
12468
  case "projects": return lookup.projects();
11626
- case "columns": return lookup.columns(project);
12469
+ case "columns": return lookup.columns(columns);
11627
12470
  case "tasks": return lookup.tasks(/^([^-\s]+)-/.exec(current)?.[1] ?? project);
11628
12471
  case "tags": return lookup.tags(project);
11629
12472
  default: return [];
@@ -11799,7 +12642,7 @@ async function latestVersion(ctx) {
11799
12642
  async function upgrade(ctx, options, kind = thisInstall()) {
11800
12643
  const latest = await latestVersion(ctx);
11801
12644
  const { how, command } = UPGRADE[kind];
11802
- const outdated = latest !== null && newer(latest, "1.1.0");
12645
+ const outdated = latest !== null && newer(latest, "1.2.0");
11803
12646
  if (options.json) {
11804
12647
  ctx.out(JSON.stringify({
11805
12648
  version: VERSION,
@@ -11828,11 +12671,16 @@ function program(ctx) {
11828
12671
  cli.command("projects").description("List your projects and their keys").addOption(json()).action(async (options) => projects(await ctx(), options));
11829
12672
  cli.command("link").argument("[key]", "the project (else the one already linked, or your only one)").description("Link a project to this clone's GitHub repository, so commands here use it").addOption(json()).action(async (key, options) => link(await ctx(), key, options));
11830
12673
  cli.command("unlink").description("Undo `monoban link` for this clone's repository").addOption(json()).action(async (options) => unlink(await ctx(), options));
11831
- cli.command("list").alias("ls").argument("[columns...]", "only these columns (any case; a prefix works: `back`, `inp`)").description("Show the board's tasks by column").option("-t, --tag <tag>", "only tasks with this tag").addOption(project()).addOption(json()).action(async (columns, options) => list(await ctx(), columns, options));
12674
+ cli.command("list").alias("ls").argument("[columns...]", "only these columns (any case; a prefix works: `back`, `inp`)").description("Show the board's tasks by column").option("-t, --tag <tag>", "only tasks with this tag").option("--archived", "the archived tasks instead (done a while ago, off the board)").addOption(project()).addOption(json()).action(async (columns, options) => list(await ctx(), columns, options));
11832
12675
  cli.command("show").argument("<task>", "like MON-12").description("Show a task: title, column, tags, checklist and description").addOption(json()).action(async (ref, options) => show(await ctx(), ref, options));
11833
- cli.command("add").argument("<title>").description("Add a task (to the end of the first column, or of -c)").option("-c, --column <column>", "the column to add it to").option("-d, --description <text>", "its description (- reads it from stdin)").option("-e, --edit", "write the description in $EDITOR").option("-t, --tag <tag>", "a tag (repeat for more; a new name makes a tag)", collect).addOption(project()).addOption(json()).action(async (title, options) => add(await ctx(), title, options));
11834
- cli.command("move").argument("<task>", "like MON-12").argument("<column>", "where to (any case; a prefix works)").description("Move a task to the end of another column").addOption(json()).action(async (ref, column, options) => move(await ctx(), ref, column, options));
12676
+ cli.command("log").argument("<task>", "like MON-12").description("Show what happened to a task, newest first: created, moved, edited, tags, links").option("-n, --number <count>", "how many events (default 20)").addOption(json()).action(async (ref, options) => log(await ctx(), ref, options));
12677
+ cli.command("add").argument("<title>").description("Add a task (to the end of the first column, or of -c)").option("-c, --column <column>", "the column to add it to").option("-d, --description <text>", "its description (- reads it from stdin)").option("-e, --edit", "write the description in $EDITOR").option("-t, --tag <tag>", "a tag (repeat for more; a new name makes a tag)", collect).option("--date <day>", "the day to do it: today, tomorrow, fri, +3, oct 12…").addOption(project()).addOption(json()).action(async (title, options) => add(await ctx(), title, options));
12678
+ cli.command("today").argument("[day]", "another day: tomorrow, fri, oct 12, 2026-10-12…").description("Show what's planned for today in every project (overdue first), or for another day").option("-w, --week", "the 7 days from it").addOption(json()).action(async (day, options) => todayView(await ctx(), day, options));
12679
+ cli.command("search").argument("<words...>", "all of them: in the title or description, a tag, or a reference like MON-12").description("Find tasks in every project, the last changed first").option("-n, --number <count>", "how many tasks (default 30)").addOption(json()).action(async (words, options) => search(await ctx(), words, options));
12680
+ cli.command("schedule").argument("<task>", "like MON-12").argument("[day]", "today, tomorrow, fri, next week, +3, oct 12, 2026-10-12…").description("Plan a task for a day (it shows in `monoban today` then), or take its date off with --clear").option("--clear", "take the date off").addOption(json()).action(async (ref, day, options) => schedule(await ctx(), ref, day, options));
12681
+ cli.command("move").argument("<task>", "like MON-12").argument("[column]", "where to (any case; a prefix works)").description("Move a task to the end of another column, or (--to) to another project").option("--to <project>", "another project's key: the task gets a number there (MON-12 becomes WEB-7)").addOption(json()).action(async (ref, column, options) => move(await ctx(), ref, column, options));
11835
12682
  cli.command("done").argument("<task>", "like MON-12").description("Move a task to Done (or the last column)").addOption(json()).action(async (ref, options) => done(await ctx(), ref, options));
12683
+ cli.command("start").argument("<task>", "like MON-12").description("Start a task: check out its branch (mon-12-title, made from the commit you're on) and move it to In progress").option("--no-branch", "only move it").option("--no-move", "only check out its branch").addOption(json()).action(async (ref, options) => start(await ctx(), ref, options));
11836
12684
  cli.command("edit").argument("<task>", "like MON-12").description("Edit a task's title (the first line) and description in $EDITOR, or set them with --title and -d").option("--title <text>", "a new title (no editor)").option("-d, --description <text>", "a new description, replacing it (- reads it from stdin; no editor)").addOption(json()).action(async (ref, options) => edit(await ctx(), ref, options));
11837
12685
  cli.command("rm").argument("<task>", "like MON-12").description("Delete a task (asks first)").option("-y, --yes", "don't ask").addOption(json()).action(async (ref, options) => rm$1(await ctx(), ref, options));
11838
12686
  cli.command("tag").argument("<task>", "like MON-12").argument("<tags...>", "tag names (a new name makes a tag in the task's project)").description("Put tags on a task").addOption(json()).action(async (ref, names, options) => tag(await ctx(), ref, names, options));