@harborppm/cli 0.119.0 → 0.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,8 @@ It runs on the same engine as the website: health, task keys, limits and undo wo
50
50
 
51
51
  It has colours for dark terminals and for light ones, and picks by asking the terminal for its background (or reading `COLORFGBG`); a terminal that doesn't say gets the dark ones. `harbor theme light` or `harbor theme dark` settles it, `harbor theme auto` goes back to asking, and `HARBOR_THEME` overrides it for one run.
52
52
 
53
+ The commands' answers are coloured on a terminal: a task's key stands out, the details in brackets step back, and late work, off track and at risk are the only warm words. They use your terminal's own colours, so they follow its theme. Piped, redirected or with `--json` the text is plain, and `--no-color` or `NO_COLOR=1` keeps it plain on a terminal too.
54
+
53
55
  `harbor help` starts with the dozen commands most people need; `harbor help all` lists every one. It shows the mark too, in a terminal with colour; piped, or with `NO_COLOR` set, it's plain text. `harbor --version` says which version you have.
54
56
 
55
57
  ## On the website
@@ -115,6 +117,8 @@ Task titles, names and notes can come from an intake form, a GitHub pull request
115
117
 
116
118
  `harbor signup` is for a first visit: the same sign-in, with the page opened on making an account. `harbor login` registers the CLI with Harbor and opens the same page Claude and other apps use: it names "Harbor CLI" and asks what to allow. Choose **Allow reading only** (or run `harbor login --read-only`) if it shouldn't change anything. The sign-in is saved in `~/.config/harbor/credentials.json`, readable only by you, and refreshes itself for 30 days.
117
119
 
120
+ A new harbor starts with First voyage, a short project of practice tasks. They tick themselves off from the terminal as they do on the website: `harbor add "Call the printer"` puts your first task there (it's the only project you have) and ticks "Add a task of your own" and "Try Harbor in your terminal", and the answer says so.
121
+
118
122
  `harbor logout` forgets it on this machine. To end its access everywhere, disconnect **Harbor CLI** under **Connected apps** in Harbor's menu.
119
123
 
120
124
  ## Commands
@@ -177,7 +181,11 @@ harbor add "TITLE" --project P [--assignee me|NAME] [--also "NAME, NAME"] [--due
177
181
  away, what it waits on, how long their similar tasks
178
182
  took); it needs an owner, and an empty queue gives
179
183
  their next working day. A date that won't hold says so
180
- harbor start TASK | submit TASK | done TASK [--confirm] [--over-limit]
184
+ harbor start TASK | submit TASK | done TASK [--confirm] [--over-limit] [--comment TEXT]
185
+ --comment leaves a note on the task as it moves;
186
+ several keys at once (harbor done RR-4 RR-7) move
187
+ each in turn; one that can't move says why and the
188
+ rest carry on
181
189
  harbor edit TASK [--title T] [--assignee me|none|NAME] [--also "NAME, NAME"|none]
182
190
  [--due DATE|pilot|none] [--starts DATE|none]
183
191
  [--priority P] [--status S] [--notes TEXT]
package/bin/harbor.mjs CHANGED
@@ -2,10 +2,17 @@
2
2
  import { VERSION, run } from "../lib/cli.mjs";
3
3
  import { exitWhenWritten } from "../lib/exit.mjs";
4
4
  import { HarborError } from "../lib/mcp.mjs";
5
+ import { paint, wantsColour, withoutColourFlags } from "../lib/paint.mjs";
5
6
  import { jsonText, plain } from "../lib/plain.mjs";
6
7
  import { updateNotice } from "../lib/update.mjs";
7
8
 
8
- const argv = process.argv.slice(2);
9
+ const typed = process.argv.slice(2);
10
+ // Colour on a terminal only, and never in what a script reads (paint.mjs).
11
+ const colour = wantsColour({ argv: typed });
12
+ const argv = withoutColourFlags(typed);
13
+ const help =
14
+ argv[0] === "help" || argv.includes("--help") || argv.includes("-h") || argv.length === 0;
15
+ const io = colour ? { out: (s) => process.stdout.write(`${paint(s, { help })}\n`) } : {};
9
16
  // Asked alongside the command, so it costs nothing extra (see update.mjs).
10
17
  // Not for the shell prompt, which draws on every Enter and must never wait.
11
18
  const notice =
@@ -17,7 +24,7 @@ const tell = async () => {
17
24
  if (line) process.stderr.write(`\n${line}\n`);
18
25
  };
19
26
 
20
- run(argv).then(
27
+ run(argv, io).then(
21
28
  async (code) => {
22
29
  await tell();
23
30
  await exitWhenWritten(code);
package/dist/app.mjs CHANGED
@@ -18,18 +18,18 @@ var __esmMin = (fn, res, err) => () => {
18
18
  throw err = [e], e;
19
19
  }
20
20
  };
21
- var __exportAll = (all, no_symbols) => {
22
- let target = {};
21
+ var __exportAll = (all, flags) => {
22
+ let target = Object.setPrototypeOf({}, null);
23
23
  for (var name in all) {
24
24
  __defProp(target, name, {
25
25
  get: all[name],
26
26
  enumerable: true
27
27
  });
28
28
  }
29
- if (!no_symbols) {
29
+ if (!(flags & 1)) {
30
30
  __defProp(target, Symbol.toStringTag, { value: "Module" });
31
31
  }
32
- return target;
32
+ return flags & 2 ? target : Object.preventExtensions(target);
33
33
  };
34
34
 
35
35
  // src/lib/clock.ts
@@ -653,11 +653,11 @@ var init_esm = __esmMin((() => {
653
653
  }));
654
654
 
655
655
  // src/tui/context.tsx
656
- init_utils();
657
656
  /**
658
657
  * What every screen of the terminal app reaches for: the store, the sync
659
658
  * loop, who is signed in and the harbors they belong to.
660
659
  */
660
+ init_utils();
661
661
  init_esm();
662
662
  const Deps = createContext(null);
663
663
  const DepsProvider = Deps.Provider;
@@ -2514,8 +2514,7 @@ function wipFullMessage(overflow) {
2514
2514
  function columnWip(data, projectId, status, extra = 1) {
2515
2515
  const col = boardConfigOf(data, projectId).columns.find((c) => c.status === status);
2516
2516
  if (!col) return null;
2517
- const current = tasksOf(data.tasks, projectId).filter((t) => t.status === status && !isSubtask(t, data.tasks)).length;
2518
- return wipOverflow(col, current, extra);
2517
+ return wipOverflow(col, tasksOf(data.tasks, projectId).filter((t) => t.status === status && !isSubtask(t, data.tasks)).length, extra);
2519
2518
  }
2520
2519
  var BOARD_PRESETS, ALL_FIELDS, DEFAULT_DOING_WIP, DEFAULT_REVIEW_WIP, WIP_CAP_CHOICES;
2521
2520
  var init_board = __esmMin((() => {
@@ -3227,7 +3226,7 @@ function trialDaysLeft(trialEndsAt, now = /* @__PURE__ */ new Date()) {
3227
3226
 
3228
3227
  // src/lib/forecast.ts
3229
3228
  init_date_fns();
3230
- const day$10 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
3229
+ const day$11 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
3231
3230
  /**
3232
3231
  * A straight-line estimate at completion from the burn so far: spend divided
3233
3232
  * by the share of the schedule elapsed. Null before anything is spent or
@@ -3236,8 +3235,8 @@ const day$10 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
3236
3235
  */
3237
3236
  function forecastAtCompletion(item, now) {
3238
3237
  if (item.spent <= 0) return null;
3239
- const total = differenceInCalendarDays(day$10(item.endDate), day$10(item.startDate)) + 1;
3240
- const gone = differenceInCalendarDays(now, day$10(item.startDate)) + 1;
3238
+ const total = differenceInCalendarDays(day$11(item.endDate), day$11(item.startDate)) + 1;
3239
+ const gone = differenceInCalendarDays(now, day$11(item.startDate)) + 1;
3241
3240
  if (total <= 0 || gone <= 0) return null;
3242
3241
  const elapsed = Math.min(1, gone / total);
3243
3242
  const eac = Math.round(item.spent / elapsed);
@@ -3911,7 +3910,7 @@ function weeklyFinished(tasks, startDate, now, weeks = 6) {
3911
3910
  return counts;
3912
3911
  }
3913
3912
  function hash(text) {
3914
- let h = 2166136261;
3913
+ let h = 0x811c9dc5;
3915
3914
  for (let i = 0; i < text.length; i++) {
3916
3915
  h ^= text.charCodeAt(i);
3917
3916
  h = Math.imul(h, 16777619);
@@ -3922,7 +3921,7 @@ function hash(text) {
3922
3921
  function random(seed) {
3923
3922
  let a = seed;
3924
3923
  return () => {
3925
- a = a + 1831565813 | 0;
3924
+ a = a + 0x6d2b79f5 | 0;
3926
3925
  let t = Math.imul(a ^ a >>> 15, 1 | a);
3927
3926
  t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
3928
3927
  return ((t ^ t >>> 14) >>> 0) / 4294967296;
@@ -3934,7 +3933,7 @@ function simulate(remaining, weekly, seed, pace = 1, shares = null) {
3934
3933
  const out = [];
3935
3934
  for (let run = 0; run < TRIALS; run++) {
3936
3935
  let left = remaining;
3937
- let days = Infinity;
3936
+ let days = 1e400;
3938
3937
  for (let week = 0; week < MAX_WEEKS; week++) {
3939
3938
  const drawn = weekly[Math.floor(next() * weekly.length)];
3940
3939
  let closed = pace === 1 ? drawn : Math.floor(drawn * pace) + (next() < drawn * pace % 1 ? 1 : 0);
@@ -4484,7 +4483,7 @@ init_tide();
4484
4483
  init_raid();
4485
4484
  init_flow();
4486
4485
  init_date_fns();
4487
- const day$9 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4486
+ const day$10 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4488
4487
  function monthKey(iso) {
4489
4488
  return iso.slice(0, 7);
4490
4489
  }
@@ -4500,7 +4499,7 @@ function monthsBetween(from, to) {
4500
4499
  return out;
4501
4500
  }
4502
4501
  function daysIn(key) {
4503
- return getDaysInMonth(day$9(`${key}-01`));
4502
+ return getDaysInMonth(day$10(`${key}-01`));
4504
4503
  }
4505
4504
  /** How many of the schedule's days fall in `key`. */
4506
4505
  function overlapDays(key, start, end) {
@@ -4508,7 +4507,7 @@ function overlapDays(key, start, end) {
4508
4507
  const lastDay = `${key}-${String(daysIn(key)).padStart(2, "0")}`;
4509
4508
  const from = start > first ? start : first;
4510
4509
  const to = end < lastDay ? end : lastDay;
4511
- return to < from ? 0 : differenceInCalendarDays(day$9(to), day$9(from)) + 1;
4510
+ return to < from ? 0 : differenceInCalendarDays(day$10(to), day$10(from)) + 1;
4512
4511
  }
4513
4512
  /**
4514
4513
  * The budget spread straight across the schedule: each month gets the share
@@ -4518,7 +4517,7 @@ function overlapDays(key, start, end) {
4518
4517
  function evenPhasing(project) {
4519
4518
  const end = project.endDate < project.startDate ? project.startDate : project.endDate;
4520
4519
  const months = monthsBetween(project.startDate, end);
4521
- const total = differenceInCalendarDays(day$9(end), day$9(project.startDate)) + 1;
4520
+ const total = differenceInCalendarDays(day$10(end), day$10(project.startDate)) + 1;
4522
4521
  const out = {};
4523
4522
  let placed = 0;
4524
4523
  months.forEach((k, i) => {
@@ -4625,7 +4624,7 @@ function hasBaseline(p) {
4625
4624
  /** Days the end has moved past the baseline end; negative when it came in. Null without a baseline. */
4626
4625
  function slipDays(p) {
4627
4626
  if (!p.baselineEnd) return null;
4628
- return differenceInCalendarDays(day$8(p.endDate), day$8(p.baselineEnd));
4627
+ return differenceInCalendarDays(day$9(p.endDate), day$9(p.baselineEnd));
4629
4628
  }
4630
4629
  /**
4631
4630
  * The projects with the current dates committed as their baseline; ones that
@@ -4647,10 +4646,10 @@ function slipLabel(p) {
4647
4646
  const n = Math.abs(slip);
4648
4647
  return slip > 0 ? `slipped ${n} day${n === 1 ? "" : "s"}` : `${n} day${n === 1 ? "" : "s"} early`;
4649
4648
  }
4650
- var day$8;
4649
+ var day$9;
4651
4650
  var init_baseline = __esmMin((() => {
4652
4651
  init_date_fns();
4653
- day$8 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4652
+ day$9 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4654
4653
  }));
4655
4654
 
4656
4655
  // src/lib/roadmap.ts
@@ -4678,7 +4677,7 @@ const ZOOMS = [
4678
4677
  step: 3
4679
4678
  }
4680
4679
  ];
4681
- const day$7 = (iso) => /* @__PURE__ */ new Date(`${iso.slice(0, 10)}T12:00:00`);
4680
+ const day$8 = (iso) => /* @__PURE__ */ new Date(`${iso.slice(0, 10)}T12:00:00`);
4682
4681
  /** Names in the order people expect: "Phase 2" before "Phase 10". */
4683
4682
  const byName = (a, b) => a.localeCompare(b, void 0, { numeric: true });
4684
4683
  const isoDay$4 = (d) => format(d, "yyyy-MM-dd");
@@ -4688,7 +4687,7 @@ const isoDay$4 = (d) => format(d, "yyyy-MM-dd");
4688
4687
  */
4689
4688
  function roadmapWindow(zoom, today, shift = 0) {
4690
4689
  const z = ZOOMS.find((x) => x.id === zoom) ?? ZOOMS[1];
4691
- const first = addMonths$1(startOfMonth(day$7(today)), -1 + shift * z.step);
4690
+ const first = addMonths$1(startOfMonth(day$8(today)), -1 + shift * z.step);
4692
4691
  const after = addMonths$1(first, z.months);
4693
4692
  const days = differenceInCalendarDays(after, first);
4694
4693
  const months = Array.from({ length: z.months }, (_, i) => {
@@ -4712,15 +4711,15 @@ function roadmapWindow(zoom, today, shift = 0) {
4712
4711
  function at(iso, w) {
4713
4712
  if (!iso) return null;
4714
4713
  if (iso < w.start || iso >= w.end) return null;
4715
- return differenceInCalendarDays(day$7(iso), day$7(w.start)) / w.days;
4714
+ return differenceInCalendarDays(day$8(iso), day$8(w.start)) / w.days;
4716
4715
  }
4717
4716
  /** A bar for a start–end span, clipped to the window; null when it's wholly outside. */
4718
4717
  function span$1(start, end, w) {
4719
4718
  if (!start || !end || end < w.start || start >= w.end) return null;
4720
4719
  const from = start < w.start ? w.start : start;
4721
- const until = end >= w.end ? w.end : isoDay$4(new Date(day$7(end).getTime() + 864e5));
4722
- const left = differenceInCalendarDays(day$7(from), day$7(w.start)) / w.days;
4723
- const right = differenceInCalendarDays(day$7(until), day$7(w.start)) / w.days;
4720
+ const until = end >= w.end ? w.end : isoDay$4(new Date(day$8(end).getTime() + 864e5));
4721
+ const left = differenceInCalendarDays(day$8(from), day$8(w.start)) / w.days;
4722
+ const right = differenceInCalendarDays(day$8(until), day$8(w.start)) / w.days;
4724
4723
  return {
4725
4724
  left,
4726
4725
  width: Math.max(right - left, 1 / w.days),
@@ -4835,7 +4834,7 @@ function scoreMatch(query, name, ...secondary) {
4835
4834
  return tokens.every((t) => blob.includes(t)) ? SCORE.anywhere : 0;
4836
4835
  }
4837
4836
  /** Keep what matches, best first. Ties keep the caller's order. */
4838
- function rank(items, score, limit = Infinity) {
4837
+ function rank(items, score, limit = 1e400) {
4839
4838
  const out = [];
4840
4839
  items.forEach((item, index) => {
4841
4840
  const s = score(item);
@@ -8367,7 +8366,7 @@ function bottleState(note, ctx) {
8367
8366
  /** "opens on Nov 14", "opens when Factory buy-off is reached", "opens if Ridge Runner launch turns Off track" */
8368
8367
  function opensText(opens, ctx) {
8369
8368
  if (!opens) return "open now";
8370
- if (opens.on === "date") return `opens on ${day$6(opens.date)}`;
8369
+ if (opens.on === "date") return `opens on ${day$7(opens.date)}`;
8371
8370
  if (opens.on === "milestone") {
8372
8371
  const m = ctx.milestones.find((x) => x.id === opens.milestoneId);
8373
8372
  return m ? `opens when ${m.name} is reached` : "opens when its milestone is reached";
@@ -8401,7 +8400,7 @@ function freshlyOpened(data, projects, now) {
8401
8400
  }
8402
8401
  return out.sort((a, b) => (b.state.openedOn ?? "").localeCompare(a.state.openedOn ?? ""));
8403
8402
  }
8404
- var BOTTLE_FRESH_DAYS, isBottle, sealed, day$6;
8403
+ var BOTTLE_FRESH_DAYS, isBottle, sealed, day$7;
8405
8404
  var init_bottle = __esmMin((() => {
8406
8405
  init_date_fns();
8407
8406
  init_date_text();
@@ -8413,7 +8412,7 @@ var init_bottle = __esmMin((() => {
8413
8412
  open: false,
8414
8413
  openedOn: null
8415
8414
  };
8416
- day$6 = (iso) => format(parseIso(iso.slice(0, 10)), "MMM d");
8415
+ day$7 = (iso) => format(parseIso(iso.slice(0, 10)), "MMM d");
8417
8416
  }));
8418
8417
 
8419
8418
  // src/lib/decisions.ts
@@ -8728,7 +8727,7 @@ function lateOwnersOf(data, tasks, now) {
8728
8727
  }
8729
8728
  function composeBriefBody(opts) {
8730
8729
  const date = format(opts.date, "MMMM d, yyyy");
8731
- const shown = opts.all ? Infinity : 8;
8730
+ const shown = opts.all ? 1e400 : 8;
8732
8731
  const watch = opts.watch ?? [];
8733
8732
  const milestones = opts.milestones ?? [];
8734
8733
  const lateMilestones = milestones.filter((m) => m.daysLate > 0);
@@ -10803,8 +10802,8 @@ init_blockers();
10803
10802
  init_date_text();
10804
10803
  init_premortem();
10805
10804
  init_thanks();
10806
- const day$5 = (iso) => parseIso(localDay(iso));
10807
- const between = (a, b) => differenceInCalendarDays(day$5(b), day$5(a));
10805
+ const day$6 = (iso) => parseIso(localDay(iso));
10806
+ const between = (a, b) => differenceInCalendarDays(day$6(b), day$6(a));
10808
10807
  function voyageLog(data, projectId) {
10809
10808
  const project = data.projects.find((p) => p.id === projectId);
10810
10809
  if (!project) return null;
@@ -10871,7 +10870,7 @@ function voyageLog(data, projectId) {
10871
10870
  };
10872
10871
  }
10873
10872
  const plural$7 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
10874
- const md$1 = (iso) => format(day$5(iso), "MMM d");
10873
+ const md$1 = (iso) => format(day$6(iso), "MMM d");
10875
10874
  /** The three numbers at the top: how late, how much work, how many risks came true. */
10876
10875
  function voyageStats(log) {
10877
10876
  const happened = log.risks.filter((r) => r.happened).length;
@@ -13258,7 +13257,7 @@ function dollars(value) {
13258
13257
  const n = Number(value ?? 0);
13259
13258
  return whole$1.format(Number.isFinite(n) ? n : 0);
13260
13259
  }
13261
- function day$4(value) {
13260
+ function day$5(value) {
13262
13261
  return value ? shortDate(value) : "no date";
13263
13262
  }
13264
13263
  /** Whole days from one ISO day to another. */
@@ -13346,15 +13345,15 @@ function describeEvent(e, names) {
13346
13345
  };
13347
13346
  case "dueDate": return {
13348
13347
  action: "moved the due date of",
13349
- detail: `from ${day$4(from)} to ${day$4(to)}${slip(from, to)}`
13348
+ detail: `from ${day$5(from)} to ${day$5(to)}${slip(from, to)}`
13350
13349
  };
13351
13350
  case "startDate": return {
13352
13351
  action: "moved the start of",
13353
- detail: `from ${day$4(from)} to ${day$4(to)}${slip(from, to)}`
13352
+ detail: `from ${day$5(from)} to ${day$5(to)}${slip(from, to)}`
13354
13353
  };
13355
13354
  case "endDate": return {
13356
13355
  action: "moved the end of",
13357
- detail: `from ${day$4(from)} to ${day$4(to)}${slip(from, to)}`
13356
+ detail: `from ${day$5(from)} to ${day$5(to)}${slip(from, to)}`
13358
13357
  };
13359
13358
  case "budget": return {
13360
13359
  action: "changed the budget of",
@@ -13796,7 +13795,7 @@ function landfallProblem(input) {
13796
13795
  function landfallAnswerProblem(input) {
13797
13796
  if (!LANDFALL_RESULTS.includes(input.result)) return "Say yes, partly or no.";
13798
13797
  if (input.value != null && (typeof input.value !== "number" || !Number.isFinite(input.value))) return "The number has to be a number.";
13799
- if (typeof input.value === "number" && Math.abs(input.value) > 0xe8d4a51000) return "That number is too big.";
13798
+ if (typeof input.value === "number" && Math.abs(input.value) > 1e12) return "That number is too big.";
13800
13799
  if (clean$1(input.note).length > 500) return `Keep the note under ${500} characters.`;
13801
13800
  return null;
13802
13801
  }
@@ -13910,7 +13909,7 @@ function landfallJson(project, tasks, today, people) {
13910
13909
  */
13911
13910
  /** FNV-1a over the text, as eight hex digits. */
13912
13911
  function hash8(text) {
13913
- let h = 2166136261;
13912
+ let h = 0x811c9dc5;
13914
13913
  for (let i = 0; i < text.length; i++) {
13915
13914
  h ^= text.charCodeAt(i);
13916
13915
  h = Math.imul(h, 16777619);
@@ -13935,7 +13934,7 @@ init_date_fns();
13935
13934
  init_date_text();
13936
13935
  init_indexes();
13937
13936
  init_tide();
13938
- const day$3 = (iso) => parseIso(iso.slice(0, 10));
13937
+ const day$4 = (iso) => parseIso(iso.slice(0, 10));
13939
13938
  /** When a convoy looks like arriving, and how that was read. */
13940
13939
  function expectedOf(data, convoy, now) {
13941
13940
  const project = convoy.projectId ? byId(data.projects).get(convoy.projectId) ?? null : null;
@@ -13973,7 +13972,7 @@ function convoyRows(data, now) {
13973
13972
  for (const asker of data.programs) for (const convoy of asker.convoys ?? []) {
13974
13973
  const giver = programs.get(convoy.toProgramId) ?? null;
13975
13974
  const { expected, basis, project } = expectedOf(data, convoy, now);
13976
- const late = expected ? differenceInCalendarDays(day$3(expected), day$3(convoy.by)) : null;
13975
+ const late = expected ? differenceInCalendarDays(day$4(expected), day$4(convoy.by)) : null;
13977
13976
  out.push({
13978
13977
  convoy,
13979
13978
  asker,
@@ -14029,7 +14028,7 @@ const MONTHS = [
14029
14028
  ];
14030
14029
  /** "Dec 12". */
14031
14030
  function shortDay(iso) {
14032
- const d = day$3(iso);
14031
+ const d = day$4(iso);
14033
14032
  return Number.isNaN(d.getTime()) ? iso : `${MONTHS[d.getMonth()]} ${d.getDate()}`;
14034
14033
  }
14035
14034
  /** Who should hear about a convoy: its program's owner and whoever asked or answered. */
@@ -14083,7 +14082,7 @@ function firstName$3(name) {
14083
14082
  }
14084
14083
  /** FNV-1a over the text, as eight hex digits: a short, stable name for a set of ids. */
14085
14084
  function shortHash(text) {
14086
- let h = 2166136261;
14085
+ let h = 0x811c9dc5;
14087
14086
  for (let i = 0; i < text.length; i++) {
14088
14087
  h ^= text.charCodeAt(i);
14089
14088
  h = Math.imul(h, 16777619);
@@ -15081,7 +15080,7 @@ function suggestTakers(data, fromId, items, now, today) {
15081
15080
  for (const item of items) {
15082
15081
  if (item.kind !== "task") continue;
15083
15082
  let pick = people[0].id;
15084
- let score = -Infinity;
15083
+ let score = -1e400;
15085
15084
  for (const p of people) {
15086
15085
  const s = room.get(p.id) + (inProject.get(item.projectId)?.has(p.id) ? 1.5 : 0) + (handed.get(item.projectId)?.has(p.id) ? 1 : 0);
15087
15086
  if (s > score) {
@@ -15387,7 +15386,7 @@ function withSuggestions(data, lines, now) {
15387
15386
  return lines.map((line) => {
15388
15387
  const pool = takers({ people }, line.soloId, today);
15389
15388
  let best = null;
15390
- let score = -Infinity;
15389
+ let score = -1e400;
15391
15390
  for (const p of pool) {
15392
15391
  const s = (room.get(p.id) ?? 0) + (line.projectId && inProject.get(line.projectId)?.has(p.id) ? 3 : 0) + (line.programId && inProgram.get(line.programId)?.has(p.id) ? 1 : 0);
15393
15392
  if (s > score) {
@@ -19204,7 +19203,7 @@ function raiseRows(data, projectId, at, byId) {
19204
19203
  }
19205
19204
  var WHY_MAX, kept;
19206
19205
  var init_scuttle_rows = __esmMin((() => {
19207
- init_assignment();
19206
+ /* @__PURE__ */ init_assignment();
19208
19207
  init_indexes();
19209
19208
  init_raid();
19210
19209
  init_rollup_lock();
@@ -19980,8 +19979,8 @@ function optionalKeys(shape) {
19980
19979
  }
19981
19980
  const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
19982
19981
  safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
19983
- int32: [-2147483648, 2147483647],
19984
- uint32: [0, 4294967295],
19982
+ int32: [-0x80000000, 0x7fffffff],
19983
+ uint32: [0, 0xffffffff],
19985
19984
  float32: [-34028234663852886e22, 34028234663852886e22],
19986
19985
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
19987
19986
  }))();
@@ -22102,9 +22101,7 @@ function mergeValues(a, b) {
22102
22101
  };
22103
22102
  const newArray = [];
22104
22103
  for (let index = 0; index < a.length; index++) {
22105
- const itemA = a[index];
22106
- const itemB = b[index];
22107
- const sharedValue = mergeValues(itemA, itemB);
22104
+ const sharedValue = mergeValues(a[index], b[index]);
22108
22105
  if (!sharedValue.valid) return {
22109
22106
  valid: false,
22110
22107
  mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
@@ -25470,7 +25467,7 @@ const SIMILAR_MIN = 3;
25470
25467
  /** A finished task that took longer than this sat somewhere; it counts as this long. */
25471
25468
  const SIMILAR_CAP = 15;
25472
25469
  const firstName$1 = (name) => name.trim().split(/\s+/)[0] || name;
25473
- const day$2 = (iso) => iso ? iso.slice(0, 10) : null;
25470
+ const day$3 = (iso) => iso ? iso.slice(0, 10) : null;
25474
25471
  function quantile(sorted, q) {
25475
25472
  const at = (sorted.length - 1) * q;
25476
25473
  const lo = Math.floor(at);
@@ -25486,7 +25483,7 @@ function pilotDate(task, data, localToday, at) {
25486
25483
  const owner = byId(data.people).get(task.assigneeId);
25487
25484
  if (!owner || owner.kind === "agent") return null;
25488
25485
  const today = at ? todayFor(owner, at, localToday) : localToday;
25489
- const chosen = day$2(task.dueDate);
25486
+ const chosen = day$3(task.dueDate);
25490
25487
  let underWay = 0;
25491
25488
  const dated = [];
25492
25489
  const finished = [];
@@ -25496,14 +25493,14 @@ function pilotDate(task, data, localToday, at) {
25496
25493
  if (t.projectId === task.projectId && t.completedAt) finished.push(t);
25497
25494
  continue;
25498
25495
  }
25499
- const due = day$2(t.dueDate);
25496
+ const due = day$3(t.dueDate);
25500
25497
  if (t.status === "doing" || t.status === "review") underWay += 1;
25501
25498
  else if (due) dated.push(due);
25502
25499
  }
25503
25500
  const perDay = Math.max(.2, (owner.weeklyCapacity ?? 5) / 5);
25504
25501
  let similar = null;
25505
25502
  if (finished.length >= SIMILAR_MIN) {
25506
- const took = finished.sort((a, b) => b.completedAt < a.completedAt ? -1 : 1).slice(0, SIMILAR).map((t) => Math.min(SIMILAR_CAP, Math.max(1, workingDaysBetween(day$2(t.createdAt), day$2(t.completedAt))))).sort((a, b) => a - b);
25503
+ const took = finished.sort((a, b) => b.completedAt < a.completedAt ? -1 : 1).slice(0, SIMILAR).map((t) => Math.min(SIMILAR_CAP, Math.max(1, workingDaysBetween(day$3(t.createdAt), day$3(t.completedAt))))).sort((a, b) => a - b);
25507
25504
  similar = {
25508
25505
  low: Math.round(quantile(took, .25)),
25509
25506
  high: Math.round(quantile(took, .75)),
@@ -25511,7 +25508,7 @@ function pilotDate(task, data, localToday, at) {
25511
25508
  };
25512
25509
  }
25513
25510
  const ownDays = Math.min(5, Math.max(1, similar?.low ?? 1));
25514
- const backOn = isAway(owner, today) ? day$2(owner.away.until) : null;
25511
+ const backOn = isAway(owner, today) ? day$3(owner.away.until) : null;
25515
25512
  const start = backOn && backOn > today ? dayBefore(backOn) : today;
25516
25513
  const tasks = byId(data.tasks);
25517
25514
  const projects = byId(data.projects);
@@ -25522,7 +25519,7 @@ function pilotDate(task, data, localToday, at) {
25522
25519
  for (const id of blockers) {
25523
25520
  const b = tasks.get(id);
25524
25521
  if (!b || b.status === "done") continue;
25525
- const due = day$2(b.dueDate);
25522
+ const due = day$3(b.dueDate);
25526
25523
  if (!due) {
25527
25524
  undated ??= b;
25528
25525
  continue;
@@ -25591,7 +25588,7 @@ const plural$3 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
25591
25588
  /** The line under the date: "Dana's queue says Nov 12 at the earliest", or, with no date yet, "Dana could likely have this by Nov 12". */
25592
25589
  function pilotHeadline(p, chosen, you = false) {
25593
25590
  const who = you ? "You" : firstName$1(p.owner.name);
25594
- if (!day$2(chosen)) return `${who} could likely have this by ${shortDate(p.earliest)}`;
25591
+ if (!day$3(chosen)) return `${who} could likely have this by ${shortDate(p.earliest)}`;
25595
25592
  return `${you ? "Your" : `${who}'s`} queue says ${shortDate(p.earliest)} at the earliest`;
25596
25593
  }
25597
25594
  /** Why: the queue, time away, what it waits on, and how long similar tasks took. */
@@ -25663,7 +25660,7 @@ function lastLooked(mark, data, personId) {
25663
25660
  init_date_text();
25664
25661
  init_indexes();
25665
25662
  init_task_keys();
25666
- const day$1 = (iso) => parseIso(iso.slice(0, 10));
25663
+ const day$2 = (iso) => parseIso(iso.slice(0, 10));
25667
25664
  const daysBetween = dayGap;
25668
25665
  /** Their projects: ones they lead, in a program they lead, or with a task of theirs. */
25669
25666
  function projectsOf(data, personId) {
@@ -25678,7 +25675,7 @@ function dueText(task, today) {
25678
25675
  if (d === 0) return "due today";
25679
25676
  if (d < 0) return `${-d} day${d === -1 ? "" : "s"} late`;
25680
25677
  if (d === 1) return "due tomorrow";
25681
- return `due ${format(day$1(task.dueDate), "EEE, MMM d")}`;
25678
+ return `due ${format(day$2(task.dueDate), "EEE, MMM d")}`;
25682
25679
  }
25683
25680
  /** What a person needs to hear about since `when.since`, as of `today` (YYYY-MM-DD). */
25684
25681
  function welcomeBack(data, personId, when, today, shown = []) {
@@ -25806,7 +25803,7 @@ function moreText(more) {
25806
25803
  /** "Welcome back, Priya · away Oct 3 to Oct 17", or "· 5 days since you last looked". */
25807
25804
  function welcomeTitle(w, name, today) {
25808
25805
  const hi = name ? `Welcome back, ${name}` : "Welcome back";
25809
- if (w.when.why === "away") return `${hi} · away ${format(day$1(w.when.since), "MMM d")} to ${format(day$1(today), "MMM d")}`;
25806
+ if (w.when.why === "away") return `${hi} · away ${format(day$2(w.when.since), "MMM d")} to ${format(day$2(today), "MMM d")}`;
25810
25807
  return `${hi} · ${w.when.days} days since you last looked`;
25811
25808
  }
25812
25809
  /** "Checkout v3: 4 done, 2 added, now At risk (was On track)". */
@@ -26289,8 +26286,8 @@ var wbs_move_exports = /* @__PURE__ */ __exportAll({
26289
26286
  function byRank(list, fallback) {
26290
26287
  const at = new Map(list.map((x, i) => [x.id, i]));
26291
26288
  return [...list].sort((a, b) => {
26292
- const ra = a.wbsRank ?? Infinity;
26293
- const rb = b.wbsRank ?? Infinity;
26289
+ const ra = a.wbsRank ?? 1e400;
26290
+ const rb = b.wbsRank ?? 1e400;
26294
26291
  if (ra !== rb) return ra - rb;
26295
26292
  if (fallback) {
26296
26293
  const f = fallback(a, b);
@@ -26458,7 +26455,7 @@ init_indexes();
26458
26455
  init_rollup_lock();
26459
26456
  init_task_keys();
26460
26457
  init_wbs_move();
26461
- const day = (iso) => iso ? iso.slice(0, 10) : null;
26458
+ const day$1 = (iso) => iso ? iso.slice(0, 10) : null;
26462
26459
  const earlier = (a, b) => !a ? b : !b ? a : a < b ? a : b;
26463
26460
  const later = (a, b) => !a ? b : !b ? a : a > b ? a : b;
26464
26461
  function lockOf(t) {
@@ -26467,10 +26464,10 @@ function lockOf(t) {
26467
26464
  return locked.includes("parentTaskId") ? "all" : "project";
26468
26465
  }
26469
26466
  function taskNode(t, kind, code, level, project, subs, today) {
26470
- const lateOf = (x) => x.status !== "done" && x.dueDate && day(x.dueDate) < today ? 1 : 0;
26467
+ const lateOf = (x) => x.status !== "done" && x.dueDate && day$1(x.dueDate) < today ? 1 : 0;
26471
26468
  const children = orderTasks(subs).map((s, i) => taskNode(s, "subtask", `${code}.${i + 1}`, level + 1, project, [], today));
26472
- let start = day(t.startDate);
26473
- let end = day(t.dueDate);
26469
+ let start = day$1(t.startDate);
26470
+ let end = day$1(t.dueDate);
26474
26471
  if (children.length) {
26475
26472
  start = earlier(start, end);
26476
26473
  for (const c of children) {
@@ -26514,7 +26511,7 @@ function projectNode(p, code, level, doc, today) {
26514
26511
  });
26515
26512
  let latest = null;
26516
26513
  for (const c of children) latest = later(latest, c.end);
26517
- const end = day(p.endDate);
26514
+ const end = day$1(p.endDate);
26518
26515
  const done = all.filter((t) => t.status === "done").length;
26519
26516
  return {
26520
26517
  kind: "project",
@@ -26524,7 +26521,7 @@ function projectNode(p, code, level, doc, today) {
26524
26521
  title: p.name,
26525
26522
  key: p.key,
26526
26523
  ownerId: p.ownerId || null,
26527
- start: day(p.startDate),
26524
+ start: day$1(p.startDate),
26528
26525
  end,
26529
26526
  runsPast: Boolean(end && latest && latest > end),
26530
26527
  done,
@@ -26556,7 +26553,7 @@ function programNode(g, code, level, doc, today) {
26556
26553
  const children = orderPlans(doc.projects.filter((p) => p.programId === g.id)).map((p, i) => projectNode(p, code ? `${code}.${i + 1}` : `${i + 1}`, level + 1, doc, today));
26557
26554
  let latest = null;
26558
26555
  for (const c of children) latest = later(latest, later(c.end, latestUnder(c)));
26559
- const end = day(g.endDate);
26556
+ const end = day$1(g.endDate);
26560
26557
  return summed({
26561
26558
  kind: "program",
26562
26559
  id: g.id,
@@ -26564,7 +26561,7 @@ function programNode(g, code, level, doc, today) {
26564
26561
  level,
26565
26562
  title: g.name,
26566
26563
  ownerId: g.ownerId || null,
26567
- start: day(g.startDate),
26564
+ start: day$1(g.startDate),
26568
26565
  end,
26569
26566
  runsPast: Boolean(end && latest && latest > end),
26570
26567
  health: g.health,
@@ -29572,6 +29569,58 @@ var init_errors = __esmMin((() => {
29572
29569
  };
29573
29570
  }));
29574
29571
 
29572
+ // src/lib/first-due.ts
29573
+ /** The task as it should be saved after its due day went from `was` to `task`'s. */
29574
+ function firstDueAfter(was, task) {
29575
+ if (task.firstDue !== was.firstDue) return task.firstDue == null ? dropFirstDue(task) : task;
29576
+ const from = day(was.dueDate);
29577
+ const to = day(task.dueDate);
29578
+ if (from === to) return task;
29579
+ if (!to || !from) return dropFirstDue(task);
29580
+ const first = task.firstDue ?? from;
29581
+ if (first === to) return dropFirstDue(task);
29582
+ return task.firstDue === first ? task : {
29583
+ ...task,
29584
+ firstDue: first
29585
+ };
29586
+ }
29587
+ function dropFirstDue(task) {
29588
+ if (!("firstDue" in task)) return task;
29589
+ const { firstDue: _gone, ...rest } = task;
29590
+ return rest;
29591
+ }
29592
+ /** A new task in a series, or a copy, starts with its own first date. */
29593
+ function withoutFirstDue(task) {
29594
+ if (!("firstDue" in task)) return task;
29595
+ const { firstDue: _gone, ...rest } = task;
29596
+ return rest;
29597
+ }
29598
+ /**
29599
+ * Keeps each task's first due day through a write: only tasks whose object
29600
+ * changed are looked at, so a write that doesn't touch tasks costs nothing.
29601
+ */
29602
+ function keepFirstDue(before, after) {
29603
+ if (after.tasks === before.tasks) return after;
29604
+ const was = byId(before.tasks);
29605
+ let changed = false;
29606
+ const tasks = after.tasks.map((t) => {
29607
+ const old = was.get(t.id);
29608
+ if (!old || old === t) return t;
29609
+ const next = firstDueAfter(old, t);
29610
+ if (next !== t) changed = true;
29611
+ return next;
29612
+ });
29613
+ return changed ? {
29614
+ ...after,
29615
+ tasks
29616
+ } : after;
29617
+ }
29618
+ var day;
29619
+ var init_first_due = __esmMin((() => {
29620
+ init_indexes();
29621
+ day = (iso) => iso ? iso.slice(0, 10) : null;
29622
+ }));
29623
+
29575
29624
  // src/lib/deep-equal.ts
29576
29625
  /**
29577
29626
  * Structural equality, key-order independent, treating `undefined` and a
@@ -29728,7 +29777,7 @@ function applyRowChanges(rows, changes, options = {}) {
29728
29777
  }
29729
29778
  var LATEST_WINS;
29730
29779
  var init_row_changes = __esmMin((() => {
29731
- init_deep_equal();
29780
+ /* @__PURE__ */ init_deep_equal();
29732
29781
  LATEST_WINS = /* @__PURE__ */ new Set(["touchedAt"]);
29733
29782
  }));
29734
29783
 
@@ -30085,6 +30134,12 @@ var init_session = __esmMin((() => {
30085
30134
  *
30086
30135
  * The placeholder program ("The work") isn't on the list: it gives way to
30087
30136
  * the first program anyone makes, so naming it is never a chore to set.
30137
+ *
30138
+ * The list opens partway done, because it is: making the account, and
30139
+ * opening the harbor (or joining one), are the first steps, and they were
30140
+ * taken before Today ever showed. People finish a list they've already
30141
+ * started more often than an empty one, so those count, ticked. Nothing
30142
+ * else is ticked that wasn't done.
30088
30143
  */
30089
30144
  /**
30090
30145
  * The program launch named for you, while nobody has renamed it and it holds
@@ -30689,7 +30744,7 @@ var init_hierarchy = __esmMin((() => {
30689
30744
  init_health_history();
30690
30745
  init_derived_health();
30691
30746
  init_shared();
30692
- init_assignment();
30747
+ /* @__PURE__ */ init_assignment();
30693
30748
  init_scuttle_rows();
30694
30749
  init_hill();
30695
30750
  init_charter_lines();
@@ -30914,7 +30969,7 @@ function nextOccurrence(task, id, today, createdAt, siblings = []) {
30914
30969
  if (siblings.some((t) => t.status !== "done" && t.repeat === task.repeat && t.title === task.title && (t.dueDate ?? "") >= dueDate)) return null;
30915
30970
  const lead = task.startDate && task.dueDate ? differenceInCalendarDays(/* @__PURE__ */ new Date(`${task.dueDate.slice(0, 10)}T12:00:00`), /* @__PURE__ */ new Date(`${task.startDate.slice(0, 10)}T12:00:00`)) : null;
30916
30971
  return {
30917
- ...task,
30972
+ ...withoutFirstDue(task),
30918
30973
  id,
30919
30974
  status: "todo",
30920
30975
  dueDate,
@@ -30935,6 +30990,7 @@ var REPEAT_LABEL, iso, step;
30935
30990
  var init_recurrence = __esmMin((() => {
30936
30991
  init_date_fns();
30937
30992
  init_date_text();
30993
+ init_first_due();
30938
30994
  REPEAT_LABEL = {
30939
30995
  weekly: "Every week",
30940
30996
  biweekly: "Every two weeks",
@@ -31050,7 +31106,7 @@ function tasksSlice({ set, get, write }) {
31050
31106
  }
31051
31107
  const id = uid("t");
31052
31108
  const row = {
31053
- ...t,
31109
+ ...withoutFirstDue(t),
31054
31110
  id,
31055
31111
  createdAt: stamp(),
31056
31112
  createdById: t.createdById ?? (get().currentUserId || null),
@@ -31634,8 +31690,9 @@ var init_tasks = __esmMin((() => {
31634
31690
  init_work();
31635
31691
  init_shared();
31636
31692
  init_recurrence();
31693
+ init_first_due();
31637
31694
  init_indexes();
31638
- init_assignment();
31695
+ /* @__PURE__ */ init_assignment();
31639
31696
  init_bulk();
31640
31697
  init_task_people();
31641
31698
  init_subtasks();
@@ -32414,13 +32471,13 @@ function applyMoves(s, moves, lineFor) {
32414
32471
  var init_people_spend = __esmMin((() => {
32415
32472
  init_format();
32416
32473
  init_handover();
32417
- init_assignment();
32474
+ /* @__PURE__ */ init_assignment();
32418
32475
  init_rollup_lock();
32419
32476
  init_spend();
32420
32477
  init_utils();
32421
32478
  init_countries();
32422
32479
  init_shared();
32423
- init_allocation();
32480
+ /* @__PURE__ */ init_allocation();
32424
32481
  }));
32425
32482
 
32426
32483
  // src/tui/engine/store.ts
@@ -32447,10 +32504,10 @@ function createAppStore(onNotice = () => {}) {
32447
32504
  };
32448
32505
  const write = (partial) => {
32449
32506
  const before = get();
32450
- guardedSet((s) => stampHealth(followMilestones(s, numberNewTasks(s, {
32507
+ guardedSet((s) => stampHealth(followMilestones(s, keepFirstDue(s, numberNewTasks(s, {
32451
32508
  ...s,
32452
32509
  ...partial
32453
- }))));
32510
+ })))));
32454
32511
  undo = nextStep(undo, before, get(), Date.now());
32455
32512
  };
32456
32513
  const api = {
@@ -32516,6 +32573,7 @@ var init_store = __esmMin((() => {
32516
32573
  init_vanilla();
32517
32574
  init_derived_health();
32518
32575
  init_task_keys();
32576
+ init_first_due();
32519
32577
  init_task_milestones();
32520
32578
  init_payload();
32521
32579
  init_undo();
@@ -32606,7 +32664,7 @@ function liftWholeRows(sent, stored, sameVersion) {
32606
32664
  }
32607
32665
  var COLLECTIONS, ROW_COLLECTIONS, KEYED, isKeyed, isRowKey;
32608
32666
  var init_changes = __esmMin((() => {
32609
- init_deep_equal();
32667
+ /* @__PURE__ */ init_deep_equal();
32610
32668
  init_row_changes();
32611
32669
  COLLECTIONS = [
32612
32670
  "currentUserId",
@@ -32832,7 +32890,7 @@ function catchUpPatch(current, fresh) {
32832
32890
  var hasId;
32833
32891
  var init_catch_up = __esmMin((() => {
32834
32892
  init_changes();
32835
- init_deep_equal();
32893
+ /* @__PURE__ */ init_deep_equal();
32836
32894
  hasId = (v) => typeof v === "object" && v !== null && typeof v.id === "string";
32837
32895
  }));
32838
32896
 
@@ -32873,7 +32931,7 @@ var NOT_WHOLE;
32873
32931
  var init_live_changes = __esmMin((() => {
32874
32932
  init_changes();
32875
32933
  init_catch_up();
32876
- init_deep_equal();
32934
+ /* @__PURE__ */ init_deep_equal();
32877
32935
  init_row_changes();
32878
32936
  NOT_WHOLE = [...ROW_COLLECTIONS, "currentUserId"];
32879
32937
  }));
package/lib/args.mjs CHANGED
@@ -32,8 +32,42 @@ export function parseArgs(argv, { flags = [], options = [], repeat = [] } = {})
32
32
  }
33
33
  values[key] = repeat.includes(key) ? [...(values[key] ?? []), value] : value;
34
34
  } else {
35
- throw new Error(`Unknown option --${key}.`);
35
+ const near = nearest(key, [...flags, ...options, ...repeat]);
36
+ throw new Error(`Unknown option --${key}.${near ? ` Did you mean --${near}?` : ""}`);
36
37
  }
37
38
  }
38
39
  return { positionals, values };
39
40
  }
41
+
42
+ /** How many single-letter edits (and swaps of neighbours) turn one word into another. */
43
+ function editDistance(a, b) {
44
+ const rows = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
45
+ for (let j = 1; j <= b.length; j++) rows[0][j] = j;
46
+ for (let i = 1; i <= a.length; i++) {
47
+ for (let j = 1; j <= b.length; j++) {
48
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
49
+ rows[i][j] = Math.min(rows[i - 1][j] + 1, rows[i][j - 1] + 1, rows[i - 1][j - 1] + cost);
50
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1])
51
+ rows[i][j] = Math.min(rows[i][j], rows[i - 2][j - 2] + 1);
52
+ }
53
+ }
54
+ return rows[a.length][b.length];
55
+ }
56
+
57
+ /**
58
+ * The option a mistyped one was most likely meant to be: within two edits
59
+ * (one for a short word), or the one it begins, when only one fits.
60
+ */
61
+ export function nearest(typed, known) {
62
+ const word = typed.toLowerCase();
63
+ if (!word) return null;
64
+ const starts = known.filter((k) => k.startsWith(word));
65
+ if (starts.length === 1) return starts[0];
66
+ const reach = word.length <= 4 ? 1 : 2;
67
+ const scored = known
68
+ .map((k) => ({ k, d: editDistance(word, k) }))
69
+ .filter((x) => x.d <= reach)
70
+ .sort((x, y) => x.d - y.d);
71
+ if (!scored.length || (scored[1] && scored[1].d === scored[0].d)) return null;
72
+ return scored[0].k;
73
+ }
package/lib/cli.mjs CHANGED
@@ -210,8 +210,11 @@ export const HELP = `harbor: Harbor from the terminal
210
210
  the date the owner's queue
211
211
  suggests (harbor help add)
212
212
  harbor start TASK | submit TASK | done TASK [--confirm] [--over-limit]
213
- move a task to In play, In review
214
- or Done
213
+ [--comment TEXT] move a task to In play, In review
214
+ or Done; several keys at once
215
+ (harbor done RR-4 RR-7) move each
216
+ in turn; --comment leaves a note
217
+ on each as it moves
215
218
  harbor edit TASK [--title T] [--assignee me|none|NAME]
216
219
  [--also "NAME, NAME"|none] [--due DATE|pilot|none]
217
220
  [--starts DATE|none]
@@ -418,11 +421,14 @@ export const HELP = `harbor: Harbor from the terminal
418
421
  takes --status all. Lists say your board's own name for a column it
419
422
  renamed; --json keeps Harbor's word in status and the board's in column.
420
423
  DATE: YYYY-MM-DD, today, tomorrow, or +N for N days from today.
424
+ On a terminal the answers are coloured: keys, what's late, health. Piped
425
+ or with --json they're plain; --no-color or NO_COLOR=1 keeps them plain.
421
426
  Changes show in Harbor's History as yours, "via Harbor CLI". These commands
422
427
  never delete; the full-screen app can, as the website can, and asks first,
423
428
  and so can harbor fog --sweep's x (drop it), one task at a time.
424
429
  Practice: a new harbor starts with First voyage, a project of practice
425
- tasks that tick themselves off as you try things; the brief, harbor week,
430
+ tasks that tick themselves off as you try things, from here too; harbor add
431
+ puts a task there while it's your only project. The brief, harbor week,
426
432
  bridge and forecast leave it out. To look around a made-up harbor instead,
427
433
  open harborppm.com/demo or run ssh try.harborppm.com.
428
434
  `;
@@ -586,15 +592,25 @@ const REPEAT_WORD = { weekly: "every week", biweekly: "every two weeks", monthly
586
592
 
587
593
  const WEEKDAYS = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
588
594
 
589
- /** The one open project a task can go in (First voyage aside), or why --project is needed. */
590
- async function onlyProject(client, harbor, say = "--project NAME") {
595
+ /** The one open project a task can go in (First voyage only when it is all there is), or why --project is needed. */
596
+ async function onlyProject(
597
+ client,
598
+ harbor,
599
+ say = "--project NAME",
600
+ { practice: orPractice = false } = {},
601
+ ) {
591
602
  const r = await client.call("list_projects", {
592
603
  harbor,
593
604
  health: ["on-track", "at-risk", "off-track", "paused"],
594
605
  limit: 5,
595
606
  });
596
- const open = (r.projects ?? []).filter((p) => p.id !== "voyage");
607
+ const all = r.projects ?? [];
608
+ const open = all.filter((p) => p.id !== "voyage");
597
609
  if (open.length === 1) return open[0].name;
610
+ // A new harbor has First voyage alone, and its first task says to add one:
611
+ // the task goes there, as it does from the website's New.
612
+ const practice = all.find((p) => p.id === "voyage");
613
+ if (open.length === 0 && practice && orPractice) return practice.name;
598
614
  if (open.length === 0)
599
615
  throw new HarborError(
600
616
  'This harbor has no open project yet; harbor project "NAME" --program P makes one.',
@@ -2055,6 +2071,15 @@ async function harborNamed(client, key) {
2055
2071
  }
2056
2072
 
2057
2073
  const TASK_KEY = /^[A-Za-z][A-Za-z0-9]{0,9}-\d+$/;
2074
+ /** How many keys harbor start, submit and done take in one go. */
2075
+ const MANY_KEYS = 20;
2076
+
2077
+ /** First voyage's practice tasks this change ticked off, said once under the answer. */
2078
+ function practiceLine(r) {
2079
+ const ticked = Array.isArray(r?.practice) ? r.practice : [];
2080
+ if (!ticked.length) return "";
2081
+ return `First voyage: ticked off ${ticked.map((t) => `“${t}”`).join(" and ")}.`;
2082
+ }
2058
2083
 
2059
2084
  /** True when every word of `words` is somewhere in `name`, any case. */
2060
2085
  const nameHas = (name, words) =>
@@ -2576,7 +2601,11 @@ export async function run(argv, io = {}) {
2576
2601
  );
2577
2602
  // The prompt's counts are behind now; its next draw fetches new ones.
2578
2603
  if (name === "create_task" || name === "update_task") await stalePromptCache(env);
2579
- out(asJson ? jsonText(result) : plain(show(result)));
2604
+ out(
2605
+ asJson
2606
+ ? jsonText(result)
2607
+ : plain([show(result), practiceLine(result)].filter(Boolean).join("\n")),
2608
+ );
2580
2609
  return 0;
2581
2610
  };
2582
2611
  let asJson = false;
@@ -3158,7 +3187,9 @@ export async function run(argv, io = {}) {
3158
3187
  : await readTitles(client, harbor, titles, values);
3159
3188
  // No --project and no #Project: the harbor's one open project, if that's all there is.
3160
3189
  if (!values.project && !reads.every((r) => r.project))
3161
- values.project = await onlyProject(client, harbor, "--project NAME or #NAME in the title");
3190
+ values.project = await onlyProject(client, harbor, "--project NAME or #NAME in the title", {
3191
+ practice: true,
3192
+ });
3162
3193
  const projectOf = (r) => values.project ?? r.project?.value;
3163
3194
  // One task as --json lists it, the same for a dry run and the real thing.
3164
3195
  const taskEntry = (t, title) => ({
@@ -3337,6 +3368,7 @@ export async function run(argv, io = {}) {
3337
3368
  ...(r.pilot ? { pilot: r.pilot } : {}),
3338
3369
  ...(r.milestoneReached ? { milestoneReached: r.milestoneReached } : {}),
3339
3370
  ...(r.milestoneReopened ? { milestoneReopened: r.milestoneReopened } : {}),
3371
+ ...(r.practice?.length ? { practice: r.practice } : {}),
3340
3372
  },
3341
3373
  );
3342
3374
  const where = [...new Set(tasks.map((t) => t.project).filter(Boolean))];
@@ -3378,6 +3410,7 @@ export async function run(argv, io = {}) {
3378
3410
  ...(r.milestoneReopened
3379
3411
  ? [`${r.milestoneReopened} is open again: it has an open task now.`]
3380
3412
  : []),
3413
+ ...(practiceLine(r) ? [practiceLine(r)] : []),
3381
3414
  ].join("\n"),
3382
3415
  )
3383
3416
  .join("\n"),
@@ -3392,7 +3425,7 @@ export async function run(argv, io = {}) {
3392
3425
  const { positionals, values, harbor } = parse(
3393
3426
  command === "review"
3394
3427
  ? spec(["confirm", "over-limit", "mine", "done"], ["owner", "portfolio"])
3395
- : spec(["confirm", "over-limit"]),
3428
+ : spec(["confirm", "over-limit"], ["comment"]),
3396
3429
  );
3397
3430
  if (command === "review") {
3398
3431
  // The review only reads: a task key here once moved the task, so it says where that went.
@@ -3431,32 +3464,80 @@ export async function run(argv, io = {}) {
3431
3464
  );
3432
3465
  }
3433
3466
  const status = { start: "doing", submit: "review", done: "done" }[command];
3434
- return call(
3435
- "update_task",
3436
- {
3437
- harbor,
3438
- task: one(positionals, "task key, like RR-42"),
3439
- status,
3440
- confirmed: values.confirm || undefined,
3441
- overLimit: values["over-limit"] || undefined,
3442
- },
3443
- (r) =>
3444
- [
3445
- `${r.updated.title}: ${r.reopened ? "reopened, " : ""}${{ doing: "started", review: "in review", done: "done" }[status]}.`,
3446
- r.queuedNext ? `Next one: ${taskLine(r.queuedNext, opts)}` : "",
3447
- r.milestoneReached
3448
- ? `That was the last of its tasks: ${r.milestoneReached} is reached.`
3449
- : "",
3450
- r.milestoneReopened
3451
- ? `${r.milestoneReopened} is open again: one of its tasks is open.`
3452
- : "",
3453
- r.projectFinished
3454
- ? `That was the last open task in ${r.projectFinished}. Mark the project Done in the app (harbor) or on the website.`
3455
- : "",
3456
- ]
3457
- .filter(Boolean)
3458
- .join("\n"),
3459
- );
3467
+ const moved = (r) =>
3468
+ [
3469
+ `${r.updated.title}: ${r.reopened ? "reopened, " : ""}${{ doing: "started", review: "in review", done: "done" }[status]}.`,
3470
+ r.commented ? "Your comment is on it." : "",
3471
+ r.queuedNext ? `Next one: ${taskLine(r.queuedNext, opts)}` : "",
3472
+ r.milestoneReached
3473
+ ? `That was the last of its tasks: ${r.milestoneReached} is reached.`
3474
+ : "",
3475
+ r.milestoneReopened
3476
+ ? `${r.milestoneReopened} is open again: one of its tasks is open.`
3477
+ : "",
3478
+ r.projectFinished
3479
+ ? `That was the last open task in ${r.projectFinished}. Mark the project Done in the app (harbor) or on the website.`
3480
+ : "",
3481
+ ]
3482
+ .filter(Boolean)
3483
+ .join("\n");
3484
+ const move = (task) => ({
3485
+ harbor,
3486
+ task,
3487
+ status,
3488
+ confirmed: values.confirm || undefined,
3489
+ overLimit: values["over-limit"] || undefined,
3490
+ });
3491
+ // --comment says why, on the task's own thread, once the move has landed:
3492
+ // a move that's refused leaves no comment behind.
3493
+ const note = values.comment === undefined ? undefined : values.comment.trim();
3494
+ if (note === "") throw new HarborError("--comment needs some words.");
3495
+ const moveOne = async (task) => {
3496
+ const r = await client.call("update_task", move(task));
3497
+ if (!note) return r;
3498
+ const c = await client.call("add_comment", { harbor, task, body: note });
3499
+ return { ...r, commented: c.commented, mentioned: c.mentioned };
3500
+ };
3501
+ // Several keys: each in turn, as if typed one after another. Only keys,
3502
+ // so a title typed without quotes is never read as several tasks.
3503
+ const keys = [...new Map(positionals.map((k) => [k.toUpperCase(), k])).values()];
3504
+ if (positionals.length > 1 && positionals.every((k) => TASK_KEY.test(k))) {
3505
+ if (keys.length > MANY_KEYS)
3506
+ throw new HarborError(`That's ${keys.length} tasks; ${MANY_KEYS} at a time at most.`);
3507
+ const results = [];
3508
+ for (const key of keys) {
3509
+ try {
3510
+ const r = await moveOne(key);
3511
+ results.push({ task: key.toUpperCase(), ...r });
3512
+ } catch (err) {
3513
+ if (!(err instanceof HarborError)) throw err;
3514
+ results.push({ task: key.toUpperCase(), error: hint(err.message) });
3515
+ }
3516
+ }
3517
+ await stalePromptCache(env);
3518
+ const failed = results.filter((r) => r.error).length;
3519
+ if (asJson) out(jsonText({ results, moved: results.length - failed, failed }));
3520
+ else {
3521
+ const lines = results.map((r) =>
3522
+ r.error
3523
+ ? `${r.task}: ${r.error}`
3524
+ : [moved(r), practiceLine(r)].filter(Boolean).join("\n"),
3525
+ );
3526
+ if (failed && results.length > failed)
3527
+ lines.push(`${results.length - failed} of ${results.length} moved.`);
3528
+ out(plain(lines.join("\n")));
3529
+ }
3530
+ return failed ? 1 : 0;
3531
+ }
3532
+ const task = one(positionals, "task key, like RR-42");
3533
+ if (!note) return call("update_task", move(task), moved);
3534
+ const r = await moveOne(task).catch((err) => {
3535
+ if (err instanceof HarborError) throw new HarborError(hint(err.message));
3536
+ throw err;
3537
+ });
3538
+ await stalePromptCache(env);
3539
+ out(asJson ? jsonText(r) : plain([moved(r), practiceLine(r)].filter(Boolean).join("\n")));
3540
+ return 0;
3460
3541
  }
3461
3542
  case "edit": {
3462
3543
  const { positionals, values, harbor } = parse(
package/lib/format.mjs CHANGED
@@ -1630,7 +1630,9 @@ export function milestonesText(r, { done = false } = {}) {
1630
1630
  ? [`None ${r.program ? `in ${r.program} ` : ""}reached yet.`]
1631
1631
  : [];
1632
1632
  const hidden = r.reachedHidden
1633
- ? `${r.reachedHidden} reached ${r.reachedHidden === 1 ? "one" : "ones"} not shown (--done shows them).`
1633
+ ? r.reachedHidden === 1
1634
+ ? "1 reached milestone not shown (--done shows it)."
1635
+ : `${r.reachedHidden} reached milestones not shown (--done shows them).`
1634
1636
  : "";
1635
1637
  if (!list.length) {
1636
1638
  const none = r.program ? `${r.program} has no open milestones.` : "No open milestones.";
@@ -1820,7 +1822,12 @@ export function wbsText(r) {
1820
1822
  : `${l.percent}% (${l.done}/${l.tasks})`,
1821
1823
  l.owner || null,
1822
1824
  dates,
1823
- l.late ? `${l.late} late` : null,
1825
+ // A task on its own is late or it isn't; anything with work under it says how many.
1826
+ l.late
1827
+ ? (l.kind === "task" || l.kind === "subtask") && !l.subtasks
1828
+ ? "late"
1829
+ : `${l.late} late`
1830
+ : null,
1824
1831
  l.runsPastEnd ? "runs past its end" : null,
1825
1832
  ].filter(Boolean);
1826
1833
  out.push(` ${lead} ${l.name}${l.key ? ` ${l.key}` : ""} (${bits.join(" · ")})`);
package/lib/paint.mjs ADDED
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Colour for the commands' answers, on a terminal only. Harbor's lines keep
3
+ * one shape (`KEY Title (status · late, due … · owner · project)`), so the
4
+ * colour is laid over the finished text rather than threaded through every
5
+ * formatter: a task's key stands out, the details in brackets step back, and
6
+ * the few words that ask for attention (late, off track, at risk) are the
7
+ * only ones in a warm colour. Piped, redirected, with --json, with NO_COLOR
8
+ * set or with --no-color, the text is exactly what it was.
9
+ *
10
+ * The colours are the terminal's own sixteen, so they follow whatever theme
11
+ * the person chose, light or dark; nothing here picks a shade for them.
12
+ */
13
+
14
+ const ESC = "\x1b[";
15
+ const RESET = `${ESC}0m`;
16
+ const wrap = (code) => (s) => (s ? `${ESC}${code}m${s}${RESET}` : s);
17
+ const dim = wrap("2");
18
+ const bold = wrap("1");
19
+ const cyan = wrap("36");
20
+ const red = wrap("31");
21
+ const yellow = wrap("33");
22
+ const green = wrap("32");
23
+
24
+ /** Commands whose answer is data for another program, or draws itself. */
25
+ const PLAIN_COMMANDS = new Set(["export", "prompt", "calendar", "version"]);
26
+
27
+ /**
28
+ * Whether this run's answers are coloured. `--no-color` and NO_COLOR (any
29
+ * value but empty) always win; FORCE_COLOR turns it on where there's no
30
+ * terminal to ask, as other tools take it.
31
+ * @param {{ argv: string[], env?: Record<string, string | undefined>, stream?: { isTTY?: boolean } }} opts
32
+ */
33
+ export function wantsColour({ argv, env = process.env, stream = process.stdout }) {
34
+ if (argv.includes("--no-color") || argv.includes("--no-colour")) return false;
35
+ if (argv.includes("--json") || argv.includes("--csv")) return false;
36
+ const command = argv.find((a) => !a.startsWith("-"));
37
+ if (command && PLAIN_COMMANDS.has(command)) return false;
38
+ if (argv.includes("--version") || argv.includes("-v")) return false;
39
+ if (env.NO_COLOR) return false;
40
+ if (env.FORCE_COLOR && env.FORCE_COLOR !== "0") return true;
41
+ return Boolean(stream.isTTY) && env.TERM !== "dumb";
42
+ }
43
+
44
+ /** argv without the colour switches, which every command takes. */
45
+ export function withoutColourFlags(argv) {
46
+ return argv.filter((a) => a !== "--no-color" && a !== "--no-colour");
47
+ }
48
+
49
+ /** One detail between the dots: the few that ask for attention keep a colour. */
50
+ function paintBit(bit) {
51
+ const t = bit.trim();
52
+ if (/^(late\b|\d+ late$|was due\b|off track$|overdue\b|runs past its end$)/.test(t))
53
+ return red(bit);
54
+ if (/^(at risk$|changes asked for\b)/.test(t)) return yellow(bit);
55
+ if (/^on track$/.test(t)) return green(bit);
56
+ return dim(bit);
57
+ }
58
+
59
+ /** "a · b · c" with each part painted and the dots dimmed. */
60
+ function paintBits(text) {
61
+ return text
62
+ .split(" · ")
63
+ .map((bit) =>
64
+ // "5 open, 1 late": the late half is the news.
65
+ /, \d+ late$/.test(bit)
66
+ ? `${dim(bit.slice(0, bit.lastIndexOf(", ") + 2))}${red(bit.slice(bit.lastIndexOf(", ") + 2))}`
67
+ : paintBit(bit),
68
+ )
69
+ .join(dim(" · "));
70
+ }
71
+
72
+ /** A task key as Harbor writes one: RR-42, FV-1. */
73
+ const KEY = "[A-Z][A-Z0-9]{0,9}-\\d+";
74
+ const LEADING_KEY = new RegExp(`^(\\s*(?:(?:Added|Would add|Next one): )?)(${KEY})( )`);
75
+ /** The details at a line's end: two spaces, then one pair of brackets. */
76
+ const DETAILS = /^(.*\S)( {2})\(([^()]*(?:\([^()]*\)[^()]*)*)\)$/;
77
+ /** harbor help's lines: the command, a gap, what it does. */
78
+ const HELP_LINE = /^( {2}harbor(?: \S+)*?)( {2,})(\S.*)$/;
79
+ /** A line that only carries on the description above it. */
80
+ const HELP_MORE = /^ {20,}\S/;
81
+ /** A second line of details under a row: indented, parts between dots. */
82
+ const UNDER = /^( {4,})(\S.* · .*)$/;
83
+
84
+ /**
85
+ * One line with colour laid over it. A line that already carries an escape
86
+ * (the banner draws its own) is left alone.
87
+ * @param {string} line
88
+ * @param {{ help?: boolean }} [opts]
89
+ */
90
+ export function paintLine(line, opts = {}) {
91
+ if (!line || line.includes("\x1b")) return line;
92
+ if (opts.help) {
93
+ const help = HELP_LINE.exec(line);
94
+ if (help) return `${help[1]}${help[2]}${dim(help[3])}`;
95
+ if (HELP_MORE.test(line)) return dim(line);
96
+ return line;
97
+ }
98
+ let head = line;
99
+ let tail = "";
100
+ const details = DETAILS.exec(line);
101
+ if (details) {
102
+ head = details[1];
103
+ tail = `${details[2]}${dim("(")}${paintBits(details[3])}${dim(")")}`;
104
+ }
105
+ const key = LEADING_KEY.exec(head);
106
+ if (key) head = `${key[1]}${cyan(key[2])}${key[3]}${head.slice(key[0].length)}`;
107
+ else if (!tail) {
108
+ const under = UNDER.exec(line);
109
+ if (under) return `${under[1]}${paintBits(under[2])}`;
110
+ }
111
+ return `${head}${tail}`;
112
+ }
113
+
114
+ /**
115
+ * A whole answer, line by line. The first line of a list with a count
116
+ * ("Aya: 5 open, 1 late") is its heading, so it's bold.
117
+ * @param {string} text
118
+ * @param {{ help?: boolean }} [opts]
119
+ */
120
+ export function paint(text, opts = {}) {
121
+ const lines = String(text).split("\n");
122
+ return lines
123
+ .map((line, i) => {
124
+ if (
125
+ !opts.help &&
126
+ i === 0 &&
127
+ lines.length > 2 &&
128
+ lines[1] === "" &&
129
+ !line.includes("\x1b") &&
130
+ !/^\s/.test(line) &&
131
+ !DETAILS.test(line)
132
+ )
133
+ return bold(line);
134
+ return paintLine(line, opts);
135
+ })
136
+ .join("\n");
137
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harborppm/cli",
3
- "version": "0.119.0",
3
+ "version": "0.120.0",
4
4
  "description": "Harbor from the terminal: a full-screen app with everything, plus commands for scripts and agents.",
5
5
  "keywords": [
6
6
  "harbor",