@harborppm/cli 0.110.0 → 0.112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.mjs CHANGED
@@ -2732,7 +2732,28 @@ function withoutPractice(data) {
2732
2732
  if (data.spendEntries) out.spendEntries = data.spendEntries.filter((e) => !isVoyageProject(e.projectId));
2733
2733
  return out;
2734
2734
  }
2735
- var VOYAGE_PROJECT_ID, STEPS, voyageTaskId, VOYAGE_NO_FORECAST, SEEDED;
2735
+ /**
2736
+ * First voyage's open tasks that what's happened in the harbor has now done.
2737
+ * Only the ones on the person whose device this is: a tick is saved as theirs,
2738
+ * so someone who joined never ticks the owner's practice (History would say
2739
+ * they did), and the owner's own apps are the ones that count.
2740
+ */
2741
+ function voyageTicks(data, signals) {
2742
+ if (!data.projects.some((p) => isVoyageProject(p.id))) return [];
2743
+ const open = data.tasks.filter((t) => SEEDED.has(t.id) && t.status !== "done" && t.assigneeId === data.currentUserId);
2744
+ if (open.length === 0) return [];
2745
+ const own = (t) => !SEEDED.has(t.id);
2746
+ const done = {
2747
+ task: data.tasks.some(own),
2748
+ move: data.tasks.some((t) => MOVED.includes(t.status) || own(t) && t.status === "done"),
2749
+ crew: data.people.length > 1,
2750
+ terminal: signals.apps?.some((a) => a === "Harbor CLI") ?? false,
2751
+ agent: signals.apps?.some((a) => a !== "Harbor CLI") ?? false,
2752
+ wrap: false
2753
+ };
2754
+ return open.filter((t) => done[t.id.slice(7)]).map((t) => t.id);
2755
+ }
2756
+ var VOYAGE_PROJECT_ID, STEPS, voyageTaskId, VOYAGE_NO_FORECAST, MOVED, SEEDED;
2736
2757
  var init_first_voyage = __esmMin((() => {
2737
2758
  VOYAGE_PROJECT_ID = "voyage";
2738
2759
  STEPS = [
@@ -2769,6 +2790,7 @@ var init_first_voyage = __esmMin((() => {
2769
2790
  ];
2770
2791
  voyageTaskId = (step) => `voyage-${step}`;
2771
2792
  VOYAGE_NO_FORECAST = "It's practice, not the crew's pace, so there's nothing to forecast.";
2793
+ MOVED = ["doing", "review"];
2772
2794
  SEEDED = new Set(STEPS.map((s) => voyageTaskId(s.step)));
2773
2795
  }));
2774
2796
 
@@ -6683,7 +6705,7 @@ function RowList$1({ rows, at, height, width }) {
6683
6705
  color: on ? theme.selected : r.color ?? (r.plain ? theme.muted : void 0),
6684
6706
  bold: on || r.plain && !r.text.startsWith(" "),
6685
6707
  wrap: "truncate-end",
6686
- children: [r.plain ? " " : on ? "›" : " ", r.text]
6708
+ children: [r.plain ? " " : on ? "› " : " ", r.text]
6687
6709
  })
6688
6710
  }, r.key);
6689
6711
  }) });
@@ -9245,15 +9267,19 @@ const KIND_WORD = {
9245
9267
  raid: "Risk or issue"
9246
9268
  };
9247
9269
  const ago = (iso) => iso ? timeAgo(new Date(iso), clockNow()) : "never";
9248
- /** Recently deleted as lines: what it was, where it sat, what came with it, who and when. */
9270
+ /**
9271
+ * Recently deleted as lines: what it was, who deleted it and when, where it
9272
+ * sat, and what came with it. When says the most, so it comes before where:
9273
+ * a narrow terminal cuts from the end.
9274
+ */
9249
9275
  function deletedRows(entries) {
9250
9276
  return entries.map((e) => ({
9251
9277
  key: e.id,
9252
9278
  text: [
9253
9279
  `${KIND_WORD[e.kind]} · ${e.name}`,
9280
+ `deleted ${ago(e.deletedAt)}${e.deletedBy ? ` by ${e.deletedBy}` : ""}`,
9254
9281
  e.parentName ? `in ${e.parentName}` : null,
9255
- e.summary ? `with ${e.summary}` : null,
9256
- `deleted ${ago(e.deletedAt)}${e.deletedBy ? ` by ${e.deletedBy}` : ""}`
9282
+ e.summary ? `with ${e.summary}` : null
9257
9283
  ].filter(Boolean).join(" · "),
9258
9284
  item: e
9259
9285
  }));
@@ -11022,6 +11048,7 @@ function readTaskWords(input, ctx) {
11022
11048
  break;
11023
11049
  }
11024
11050
  let owner = null;
11051
+ const nobody = [];
11025
11052
  if (!skip.has("owner")) {
11026
11053
  const byKey = (key) => {
11027
11054
  const full = ctx.people.filter((p) => loose(p.name) === key);
@@ -11032,16 +11059,23 @@ function readTaskWords(input, ctx) {
11032
11059
  return key.length >= 3 && begins.length === 1 ? begins[0] : null;
11033
11060
  };
11034
11061
  for (const m of text.matchAll(/(?:^|\s)@([\p{L}\p{N}._-]+)/gu)) {
11035
- const hit = byKey(loose(m[1]));
11036
- if (!hit) continue;
11037
11062
  const start = m.index + (m[0].length - m[0].trimStart().length);
11038
- if (!free(start, m.index + m[0].length)) continue;
11063
+ const end = m.index + m[0].length;
11064
+ const hit = byKey(loose(m[1]));
11065
+ if (!hit) {
11066
+ if (free(start, end)) nobody.push({
11067
+ value: text.slice(start, end),
11068
+ start,
11069
+ end
11070
+ });
11071
+ continue;
11072
+ }
11073
+ if (owner || !free(start, end)) continue;
11039
11074
  owner = {
11040
11075
  value: hit.id,
11041
11076
  start,
11042
- end: m.index + m[0].length
11077
+ end
11043
11078
  };
11044
- break;
11045
11079
  }
11046
11080
  if (!owner) for (const m of text.matchAll(/(?:^|[\s,])(?:assign(?:ed)? (?:it )?to|owner(?: is)?:?) (\p{L}+(?: \p{L}+)?)/giu)) {
11047
11081
  const words = m[1].split(" ");
@@ -11079,7 +11113,7 @@ function readTaskWords(input, ctx) {
11079
11113
  break;
11080
11114
  }
11081
11115
  if (!due) {
11082
- const rest = without(text, taken);
11116
+ const rest = without(text, [...taken, ...nobody]);
11083
11117
  const tail = new RegExp(`(?:^|[\\s,])(${WHEN})[.!]?$`, "i").exec(rest);
11084
11118
  const short = tail && /^(?:sun|mon|tue|wed|thu|fri|sat)$/i.test(tail[1]);
11085
11119
  const said = tail && /\b(?:to|for|from|after|with|since)$/i.test(rest.slice(0, tail.index).trimEnd());
@@ -11118,7 +11152,8 @@ function readTaskWords(input, ctx) {
11118
11152
  project: project ? {
11119
11153
  value: project.value,
11120
11154
  text: span(project)
11121
- } : null
11155
+ } : null,
11156
+ nobody: nobody.filter((n) => free(n.start, n.end)).map((n) => n.value)
11122
11157
  };
11123
11158
  }
11124
11159
 
@@ -11186,9 +11221,14 @@ function readNewTask(text, data, today) {
11186
11221
  words.priority && `${PRIORITY_LABEL[words.priority.value].toLowerCase()} priority`,
11187
11222
  words.project && (data.projects.find((p) => p.id === words.project.value)?.name ?? "project")
11188
11223
  ].filter((b) => Boolean(b));
11224
+ const nobody = words.nobody.map((n) => `no one called ${n.slice(1)} yet`);
11189
11225
  return {
11190
11226
  words,
11191
- line: bits.length && words.title ? [`Adds “${words.title}”`, ...bits].join(" · ") : null
11227
+ line: (bits.length || nobody.length) && words.title ? [
11228
+ `Adds “${words.title}”`,
11229
+ ...bits,
11230
+ ...nobody
11231
+ ].join(" · ") : null
11192
11232
  };
11193
11233
  }
11194
11234
  const CREATE_TITLE = {
@@ -12211,7 +12251,103 @@ function blankCharters(data, programs, today) {
12211
12251
  return out.sort((a, b) => b.days - a.days || a.project.name.localeCompare(b.project.name));
12212
12252
  }
12213
12253
 
12254
+ // src/lib/empty.ts
12255
+ function addMonths(iso, months) {
12256
+ const [y, m, d] = iso.split("-").map(Number);
12257
+ const dt = new Date(y, (m ?? 1) - 1, d ?? 1);
12258
+ dt.setMonth(dt.getMonth() + months);
12259
+ return todayISO(dt);
12260
+ }
12261
+ /**
12262
+ * True when an account's name is just its email's local part: what sign-up
12263
+ * filled in before it asked, and still does when the name is left blank.
12264
+ */
12265
+ function nameFromEmail(name, email) {
12266
+ const local = (email ?? "").split("@")[0]?.trim().toLowerCase() ?? "";
12267
+ const given = (name ?? "").trim().toLowerCase();
12268
+ return given === "" || local !== "" && given === local;
12269
+ }
12270
+ /**
12271
+ * A name worth offering in the harbor-name field: "Sam's harbor", or "" when
12272
+ * no real name is known yet, so the field stays empty and shows its
12273
+ * placeholder. An email address isn't a name: "test+x's harbor" reads worse
12274
+ * than none.
12275
+ */
12276
+ function harborNameFor(displayName, email) {
12277
+ if (nameFromEmail(displayName, email)) return "";
12278
+ const first = (displayName ?? "").split(/\s/)[0]?.trim();
12279
+ return first ? `${first}'s harbor` : "";
12280
+ }
12281
+ /** What a new harbor is called until its owner names it: "Sam's harbor", else "My harbor". */
12282
+ function suggestedHarborName(displayName, email) {
12283
+ return harborNameFor(displayName, email) || "My harbor";
12284
+ }
12285
+ function createEmptyHarbor(opts) {
12286
+ const today = todayISO();
12287
+ const person = opts.person;
12288
+ const harbor = opts.harborName.trim() || "Harbor";
12289
+ const program = opts.programName?.trim() || "The work";
12290
+ const drum = opts.drumTitle?.trim() ?? "";
12291
+ return {
12292
+ currentUserId: person.id,
12293
+ readPingIds: [],
12294
+ ropes: [],
12295
+ checkIns: [],
12296
+ boardConfigs: {},
12297
+ people: [person],
12298
+ portfolios: [{
12299
+ id: "home",
12300
+ name: harbor,
12301
+ description: "The work of this harbor.",
12302
+ swatch: "pine",
12303
+ ownerId: person.id,
12304
+ health: "on-track",
12305
+ budget: 0
12306
+ }],
12307
+ programs: [{
12308
+ id: "p1",
12309
+ portfolioId: "home",
12310
+ name: program,
12311
+ description: opts.programDescription?.trim() ?? "",
12312
+ swatch: "pine",
12313
+ ownerId: person.id,
12314
+ health: "on-track",
12315
+ startDate: today,
12316
+ endDate: addMonths(today, 6),
12317
+ budget: 0
12318
+ }],
12319
+ projects: [],
12320
+ milestones: [],
12321
+ raidItems: [],
12322
+ constraints: drum ? [{
12323
+ id: "k1",
12324
+ programId: "p1",
12325
+ title: drum,
12326
+ kind: opts.drumKind ?? "external",
12327
+ status: "active",
12328
+ ownerId: person.id,
12329
+ note: opts.drumNote?.trim() ?? ""
12330
+ }] : [],
12331
+ tasks: [],
12332
+ comments: [],
12333
+ attachments: [],
12334
+ activity: [{
12335
+ id: "a1",
12336
+ personId: person.id,
12337
+ text: drum ? `named the constraint — ${drum}` : `opened ${harbor}`,
12338
+ at: (/* @__PURE__ */ new Date()).toISOString(),
12339
+ href: "/today"
12340
+ }]
12341
+ };
12342
+ }
12343
+ var STARTER_PROGRAM;
12344
+ var init_empty = __esmMin((() => {
12345
+ init_format();
12346
+ STARTER_PROGRAM = "The work";
12347
+ }));
12348
+
12214
12349
  // src/tui/moves.ts
12350
+ init_empty();
12215
12351
  init_board();
12216
12352
  function moveTask(store, go, task, status) {
12217
12353
  const s = store.getState();
@@ -13169,6 +13305,146 @@ function HistoryView({ active, width, height, go }) {
13169
13305
  });
13170
13306
  }
13171
13307
 
13308
+ // src/lib/daily-digest.ts
13309
+ /**
13310
+ * The projects a scope covers; a person's are the ones they lead, sit under,
13311
+ * or have a task in. First voyage is practice, so its tasks, talk and
13312
+ * health never count as what changed.
13313
+ */
13314
+ function projectsIn(data, scope) {
13315
+ const own = ownProjects(data.projects);
13316
+ if (scope.kind === "harbor") return own;
13317
+ if (scope.kind === "program") return own.filter((p) => p.programId === scope.id);
13318
+ const led = new Set(data.programs.filter((p) => p.ownerId === scope.id).map((p) => p.id));
13319
+ return own.filter((p) => p.ownerId === scope.id || led.has(p.programId) || tasksOf(data.tasks, p.id).some((t) => t.assigneeId === scope.id));
13320
+ }
13321
+ /** Where health went since `since`: from what it was just before to what it is now, if it moved. */
13322
+ function moved(history, now, since) {
13323
+ const list = history ?? [];
13324
+ if (!list.some((h) => h.at >= since)) return null;
13325
+ const before = [...list].reverse().find((h) => h.at < since)?.health;
13326
+ return before && before !== now ? {
13327
+ from: before,
13328
+ to: now
13329
+ } : null;
13330
+ }
13331
+ /** What changed in `scope` from `since` (an ISO moment) on. */
13332
+ function dailyDigest(data, scope, since) {
13333
+ const projects = projectsIn(data, scope);
13334
+ const projectIds = new Set(projects.map((p) => p.id));
13335
+ const programIds = scope.kind === "program" ? /* @__PURE__ */ new Set([scope.id]) : new Set(scope.kind === "harbor" ? data.programs.map((p) => p.id) : [...projects.map((p) => p.programId), ...data.programs.filter((p) => p.ownerId === scope.id).map((p) => p.id)]);
13336
+ const tasks = projects.flatMap((p) => tasksOf(data.tasks, p.id));
13337
+ const arrivedDone = (t) => Boolean(t.completedAt) && Math.abs(Date.parse(t.completedAt) - Date.parse(t.createdAt)) < ARRIVED_DONE_MS;
13338
+ const finished = tasks.filter((t) => t.status === "done" && t.completedAt && t.completedAt >= since && !arrivedDone(t)).sort((a, b) => b.completedAt.localeCompare(a.completedAt));
13339
+ const finishedIds = new Set(finished.map((t) => t.id));
13340
+ const added = tasks.filter((t) => t.createdAt >= since && !finishedIds.has(t.id)).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
13341
+ const health = [];
13342
+ for (const p of data.programs) {
13343
+ if (!programIds.has(p.id)) continue;
13344
+ const m = moved(p.healthHistory, p.health, since);
13345
+ if (m) health.push({
13346
+ name: p.name,
13347
+ path: `/programs/${p.id}`,
13348
+ ...m
13349
+ });
13350
+ }
13351
+ for (const p of projects) {
13352
+ const m = moved(p.healthHistory, p.health, since);
13353
+ if (m) health.push({
13354
+ name: p.name,
13355
+ path: `/projects/${p.id}`,
13356
+ ...m
13357
+ });
13358
+ }
13359
+ const inScope = (r) => r.projectId ? projectIds.has(r.projectId) : r.programId ? programIds.has(r.programId) : scope.kind === "harbor";
13360
+ const raised = data.raidItems.filter((r) => r.kind !== "decision" && r.createdAt >= since && inScope(r)).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
13361
+ const decided = data.raidItems.filter((r) => r.kind === "decision" && r.status !== "proposed" && Boolean(r.decidedAt) && r.decidedAt >= since && inScope(r)).sort((a, b) => b.decidedAt.localeCompare(a.decidedAt));
13362
+ const people = byId(data.people);
13363
+ const first = (id) => people.get(id)?.name.split(" ")[0] ?? "Someone";
13364
+ const projectById = byId(data.projects);
13365
+ const programById = byId(data.programs);
13366
+ const talkBy = /* @__PURE__ */ new Map();
13367
+ const count = (key, where, path, authorId, taskId) => {
13368
+ const t = talkBy.get(key) ?? {
13369
+ where,
13370
+ path,
13371
+ ...taskId ? { taskId } : {},
13372
+ count: 0,
13373
+ who: []
13374
+ };
13375
+ t.count++;
13376
+ const name = first(authorId);
13377
+ if (!t.who.includes(name)) t.who.push(name);
13378
+ talkBy.set(key, t);
13379
+ };
13380
+ for (const r of data.reflections ?? []) {
13381
+ if (!isMessage(r) || r.createdAt < since) continue;
13382
+ const place = placeOf(r);
13383
+ const holder = place.kind === "program" ? programById.get(place.id) : projectById.get(place.id);
13384
+ const inside = place.kind === "program" ? programIds.has(place.id) : projectIds.has(place.id);
13385
+ if (!holder || !inside) continue;
13386
+ count(`${place.kind}:${place.id}`, holder.name, placePath(place), r.authorId);
13387
+ }
13388
+ const taskById = byId(data.tasks);
13389
+ for (const c of data.comments) {
13390
+ if (c.createdAt < since) continue;
13391
+ const task = taskById.get(c.taskId);
13392
+ if (!task || !projectIds.has(task.projectId)) continue;
13393
+ const key = taskKey(task, projectById.get(task.projectId));
13394
+ count(`task:${task.id}`, key ? `${key} ${task.title}` : task.title, `/projects/${task.projectId}`, c.authorId, task.id);
13395
+ }
13396
+ const talk = [...talkBy.values()].sort((a, b) => b.count - a.count || a.where.localeCompare(b.where));
13397
+ return {
13398
+ since,
13399
+ finished,
13400
+ added,
13401
+ health,
13402
+ raised,
13403
+ decided,
13404
+ talk,
13405
+ quiet: !finished.length && !added.length && !health.length && !raised.length && !decided.length && !talk.length
13406
+ };
13407
+ }
13408
+ /** "A, B and 2 more". */
13409
+ function some(names, shown = 3) {
13410
+ const quoted = names.slice(0, shown).map((n) => `“${n}”`);
13411
+ const rest = names.length - quoted.length;
13412
+ if (rest > 0) return `${quoted.join(", ")} and ${rest} more`;
13413
+ if (quoted.length < 2) return quoted.join("");
13414
+ return `${quoted.slice(0, -1).join(", ")} and ${quoted.at(-1)}`;
13415
+ }
13416
+ /** The digest as short plain lines, the way the Inbox card, a chat post and the terminal say it. */
13417
+ function digestLines(d) {
13418
+ const lines = [];
13419
+ if (d.finished.length) lines.push(`${plural$6(d.finished.length, "task")} finished: ${some(d.finished.map((t) => t.title))}.`);
13420
+ if (d.added.length) lines.push(`${plural$6(d.added.length, "task")} added: ${some(d.added.map((t) => t.title))}.`);
13421
+ for (const h of d.health.slice(0, 5)) lines.push(`${h.name} went from ${HEALTH_LABEL$1[h.from] ?? h.from} to ${HEALTH_LABEL$1[h.to] ?? h.to}.`);
13422
+ if (d.health.length > 5) lines.push(`${d.health.length - 5} more changed health.`);
13423
+ if (d.raised.length) {
13424
+ const risks = d.raised.filter((r) => r.kind === "risk").length;
13425
+ const issues = d.raised.length - risks;
13426
+ const what = [risks ? plural$6(risks, "risk") : "", issues ? plural$6(issues, "issue") : ""].filter(Boolean).join(" and ");
13427
+ lines.push(`${what} raised: ${some(d.raised.map((r) => r.title))}.`);
13428
+ }
13429
+ if (d.decided.length) lines.push(`${plural$6(d.decided.length, "decision")} made: ${some(d.decided.map((r) => r.title))}.`);
13430
+ if (d.talk.length) {
13431
+ const top = d.talk.slice(0, 3).map((t) => `${t.where} (${t.count}, ${t.who.join(", ")})`).join("; ");
13432
+ const rest = d.talk.length - 3;
13433
+ lines.push(`Talk: ${top}${rest > 0 ? `; and ${plural$6(rest, "more conversation")}` : ""}.`);
13434
+ }
13435
+ return lines;
13436
+ }
13437
+ var ARRIVED_DONE_MS, plural$6;
13438
+ var init_daily_digest = __esmMin((() => {
13439
+ init_swatches();
13440
+ init_first_voyage();
13441
+ init_indexes();
13442
+ init_project_messages();
13443
+ init_task_keys();
13444
+ ARRIVED_DONE_MS = 6e4;
13445
+ plural$6 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
13446
+ }));
13447
+
13172
13448
  // src/lib/landfall-lines.ts
13173
13449
  function isLandfallDays(n) {
13174
13450
  return LANDFALL_DAYS.includes(n);
@@ -13245,6 +13521,7 @@ var init_landfall_lines = __esmMin((() => {
13245
13521
  }));
13246
13522
 
13247
13523
  // src/lib/landfall.ts
13524
+ init_daily_digest();
13248
13525
  init_date_fns();
13249
13526
  init_date_text();
13250
13527
  function plusDays(iso, days) {
@@ -13845,9 +14122,17 @@ function inboxOf(data, personId, now = clockNow()) {
13845
14122
 
13846
14123
  // src/tui/views/inbox.tsx
13847
14124
  init_date_text();
13848
- /** What's asking for you, the same pings as the website's Inbox: Enter opens one, space marks it read. */
14125
+ const DAY_MS = 864e5;
14126
+ /** The day What changed was hidden on: it comes back with the next day's, as on the website. */
14127
+ let digestHiddenOn = null;
14128
+ /**
14129
+ * What's asking for you, the same pings as the website's Inbox: Enter opens
14130
+ * one, space marks it read. What changed sits on top, as on the website: the
14131
+ * last day on your own projects (src/lib/daily-digest.ts), nothing on a quiet
14132
+ * day, and h hides it until tomorrow.
14133
+ */
13849
14134
  function InboxView({ active, width, height, go }) {
13850
- const { store } = useDeps();
14135
+ const { store, today } = useDeps();
13851
14136
  const tasks = useHarbor((s) => s.tasks);
13852
14137
  const comments = useHarbor((s) => s.comments);
13853
14138
  const milestones = useHarbor((s) => s.milestones);
@@ -13868,6 +14153,28 @@ function InboxView({ active, width, height, go }) {
13868
14153
  me,
13869
14154
  store
13870
14155
  ]);
14156
+ const projects = useHarbor((s) => s.projects);
14157
+ const programs = useHarbor((s) => s.programs);
14158
+ const day = today();
14159
+ const [hidden, setHidden] = useState(() => digestHiddenOn === day);
14160
+ const news = useMemo(() => {
14161
+ const d = dailyDigest(store.getState(), {
14162
+ kind: "person",
14163
+ id: me
14164
+ }, (/* @__PURE__ */ new Date(Date.now() - DAY_MS)).toISOString());
14165
+ return d.quiet ? [] : digestLines(d);
14166
+ }, [
14167
+ tasks,
14168
+ comments,
14169
+ raidItems,
14170
+ people,
14171
+ reflections,
14172
+ projects,
14173
+ programs,
14174
+ me,
14175
+ store
14176
+ ]);
14177
+ const shown = hidden ? [] : news;
13871
14178
  const read = readBy(readIds, me);
13872
14179
  const unread = pings.filter((p) => !read(p.id)).length;
13873
14180
  const [at, setAt] = useState(0);
@@ -13884,8 +14191,13 @@ function InboxView({ active, width, height, go }) {
13884
14191
  else if (key.return && ping) open(ping);
13885
14192
  else if (input === " " && ping) store.getState().readPing(readMark(me, ping.id));
13886
14193
  else if (input === "a") store.getState().catchUp(pings.map((p) => readMark(me, p.id)));
14194
+ else if (input === "h" && shown.length) {
14195
+ digestHiddenOn = day;
14196
+ setHidden(true);
14197
+ }
13887
14198
  }, { isActive: active });
13888
- const view = windowOf(pings, at, Math.max(1, height - 2));
14199
+ const newsRows = shown.length ? shown.length + 2 : 0;
14200
+ const view = windowOf(pings, at, Math.max(1, height - 2 - newsRows));
13889
14201
  return /* @__PURE__ */ jsxs(Box, {
13890
14202
  flexDirection: "column",
13891
14203
  width,
@@ -13896,6 +14208,20 @@ function InboxView({ active, width, height, go }) {
13896
14208
  right: `${unread} unread · a reads all`,
13897
14209
  children: "Inbox"
13898
14210
  }),
14211
+ shown.length ? /* @__PURE__ */ jsxs(Box, {
14212
+ flexDirection: "column",
14213
+ marginBottom: 1,
14214
+ children: [/* @__PURE__ */ jsxs(Text, {
14215
+ bold: true,
14216
+ children: ["What changed ", /* @__PURE__ */ jsx(Text, {
14217
+ color: theme.muted,
14218
+ children: "in the last day, on your work · h hides it"
14219
+ })]
14220
+ }), shown.map((line) => /* @__PURE__ */ jsxs(Text, {
14221
+ wrap: "truncate-end",
14222
+ children: [" ", line]
14223
+ }, line))]
14224
+ }) : null,
13899
14225
  pings.length === 0 ? /* @__PURE__ */ jsx(Text, {
13900
14226
  color: theme.muted,
13901
14227
  children: "Nothing waiting on you. Good."
@@ -14262,7 +14588,7 @@ function byTask(rows, who) {
14262
14588
  }
14263
14589
  return out;
14264
14590
  }
14265
- const plural$6 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
14591
+ const plural$5 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
14266
14592
  /** Work only one person has touched, soonest-needed first. `scope` narrows it to some programs. */
14267
14593
  function lifeboats(data, now, opts = {}) {
14268
14594
  const today = isoDay(now);
@@ -14301,7 +14627,7 @@ function lifeboats(data, now, opts = {}) {
14301
14627
  kind: "project",
14302
14628
  id: project.id,
14303
14629
  label: project.name,
14304
- detail: `${plural$6(open.length, "open task")}, nobody else on them`,
14630
+ detail: `${plural$5(open.length, "open task")}, nobody else on them`,
14305
14631
  soloId: solo[0],
14306
14632
  projectId: project.id,
14307
14633
  programId: project.programId,
@@ -14323,7 +14649,7 @@ function lifeboats(data, now, opts = {}) {
14323
14649
  out.push({
14324
14650
  kind: "tasks",
14325
14651
  id: `tasks:${project.id}:${soloId}`,
14326
- label: `${plural$6(list.length, "task")} on ${project.name}`,
14652
+ label: `${plural$5(list.length, "task")} on ${project.name}`,
14327
14653
  detail: `only ${first} has touched them`,
14328
14654
  soloId,
14329
14655
  projectId: project.id,
@@ -14343,7 +14669,7 @@ function lifeboats(data, now, opts = {}) {
14343
14669
  kind: "task",
14344
14670
  id: t.id,
14345
14671
  label: key ? `${key} ${t.title}` : t.title,
14346
- detail: [d < today ? `late since ${md(d)}` : `due ${md(d)}`, holds ? `${plural$6(holds, "task")} ${holds === 1 ? "waits" : "wait"} on it` : "urgent"].join(", "),
14672
+ detail: [d < today ? `late since ${md(d)}` : `due ${md(d)}`, holds ? `${plural$5(holds, "task")} ${holds === 1 ? "waits" : "wait"} on it` : "urgent"].join(", "),
14347
14673
  soloId,
14348
14674
  projectId: project.id,
14349
14675
  programId: project.programId,
@@ -14370,7 +14696,7 @@ function lifeboats(data, now, opts = {}) {
14370
14696
  const programId = first.programId ?? project?.programId ?? null;
14371
14697
  const where = project?.name ?? (programId ? programs.get(programId)?.name : null) ?? null;
14372
14698
  const issues = items.filter((r) => r.kind === "issue").length;
14373
- const noun = issues === 0 ? plural$6(items.length, "risk") : issues === items.length ? plural$6(items.length, "issue") : `${plural$6(items.length - issues, "risk")} and ${plural$6(issues, "issue")}`;
14699
+ const noun = issues === 0 ? plural$5(items.length, "risk") : issues === items.length ? plural$5(items.length, "issue") : `${plural$5(items.length - issues, "risk")} and ${plural$5(issues, "issue")}`;
14374
14700
  out.push({
14375
14701
  kind: "risks",
14376
14702
  id: key,
@@ -17692,140 +18018,6 @@ function applyDock(actions, projectId, changes) {
17692
18018
  return made;
17693
18019
  }
17694
18020
 
17695
- // src/lib/daily-digest.ts
17696
- /** The projects a scope covers; a person's are the ones they lead, sit under, or have a task in. */
17697
- function projectsIn(data, scope) {
17698
- if (scope.kind === "harbor") return data.projects;
17699
- if (scope.kind === "program") return data.projects.filter((p) => p.programId === scope.id);
17700
- const led = new Set(data.programs.filter((p) => p.ownerId === scope.id).map((p) => p.id));
17701
- return data.projects.filter((p) => p.ownerId === scope.id || led.has(p.programId) || tasksOf(data.tasks, p.id).some((t) => t.assigneeId === scope.id));
17702
- }
17703
- /** Where health went since `since`: from what it was just before to what it is now, if it moved. */
17704
- function moved(history, now, since) {
17705
- const list = history ?? [];
17706
- if (!list.some((h) => h.at >= since)) return null;
17707
- const before = [...list].reverse().find((h) => h.at < since)?.health;
17708
- return before && before !== now ? {
17709
- from: before,
17710
- to: now
17711
- } : null;
17712
- }
17713
- /** What changed in `scope` from `since` (an ISO moment) on. */
17714
- function dailyDigest(data, scope, since) {
17715
- const projects = projectsIn(data, scope);
17716
- const projectIds = new Set(projects.map((p) => p.id));
17717
- const programIds = scope.kind === "program" ? /* @__PURE__ */ new Set([scope.id]) : new Set(scope.kind === "harbor" ? data.programs.map((p) => p.id) : [...projects.map((p) => p.programId), ...data.programs.filter((p) => p.ownerId === scope.id).map((p) => p.id)]);
17718
- const tasks = projects.flatMap((p) => tasksOf(data.tasks, p.id));
17719
- const arrivedDone = (t) => Boolean(t.completedAt) && Math.abs(Date.parse(t.completedAt) - Date.parse(t.createdAt)) < ARRIVED_DONE_MS;
17720
- const finished = tasks.filter((t) => t.status === "done" && t.completedAt && t.completedAt >= since && !arrivedDone(t)).sort((a, b) => b.completedAt.localeCompare(a.completedAt));
17721
- const finishedIds = new Set(finished.map((t) => t.id));
17722
- const added = tasks.filter((t) => t.createdAt >= since && !finishedIds.has(t.id)).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
17723
- const health = [];
17724
- for (const p of data.programs) {
17725
- if (!programIds.has(p.id)) continue;
17726
- const m = moved(p.healthHistory, p.health, since);
17727
- if (m) health.push({
17728
- name: p.name,
17729
- path: `/programs/${p.id}`,
17730
- ...m
17731
- });
17732
- }
17733
- for (const p of projects) {
17734
- const m = moved(p.healthHistory, p.health, since);
17735
- if (m) health.push({
17736
- name: p.name,
17737
- path: `/projects/${p.id}`,
17738
- ...m
17739
- });
17740
- }
17741
- const inScope = (r) => r.projectId ? projectIds.has(r.projectId) : r.programId ? programIds.has(r.programId) : scope.kind === "harbor";
17742
- const raised = data.raidItems.filter((r) => r.kind !== "decision" && r.createdAt >= since && inScope(r)).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
17743
- const decided = data.raidItems.filter((r) => r.kind === "decision" && r.status !== "proposed" && Boolean(r.decidedAt) && r.decidedAt >= since && inScope(r)).sort((a, b) => b.decidedAt.localeCompare(a.decidedAt));
17744
- const people = byId(data.people);
17745
- const first = (id) => people.get(id)?.name.split(" ")[0] ?? "Someone";
17746
- const projectById = byId(data.projects);
17747
- const programById = byId(data.programs);
17748
- const talkBy = /* @__PURE__ */ new Map();
17749
- const count = (key, where, path, authorId, taskId) => {
17750
- const t = talkBy.get(key) ?? {
17751
- where,
17752
- path,
17753
- ...taskId ? { taskId } : {},
17754
- count: 0,
17755
- who: []
17756
- };
17757
- t.count++;
17758
- const name = first(authorId);
17759
- if (!t.who.includes(name)) t.who.push(name);
17760
- talkBy.set(key, t);
17761
- };
17762
- for (const r of data.reflections ?? []) {
17763
- if (!isMessage(r) || r.createdAt < since) continue;
17764
- const place = placeOf(r);
17765
- const holder = place.kind === "program" ? programById.get(place.id) : projectById.get(place.id);
17766
- const inside = place.kind === "program" ? programIds.has(place.id) : projectIds.has(place.id);
17767
- if (!holder || !inside) continue;
17768
- count(`${place.kind}:${place.id}`, holder.name, placePath(place), r.authorId);
17769
- }
17770
- const taskById = byId(data.tasks);
17771
- for (const c of data.comments) {
17772
- if (c.createdAt < since) continue;
17773
- const task = taskById.get(c.taskId);
17774
- if (!task || !projectIds.has(task.projectId)) continue;
17775
- const key = taskKey(task, projectById.get(task.projectId));
17776
- count(`task:${task.id}`, key ? `${key} ${task.title}` : task.title, `/projects/${task.projectId}`, c.authorId, task.id);
17777
- }
17778
- const talk = [...talkBy.values()].sort((a, b) => b.count - a.count || a.where.localeCompare(b.where));
17779
- return {
17780
- since,
17781
- finished,
17782
- added,
17783
- health,
17784
- raised,
17785
- decided,
17786
- talk,
17787
- quiet: !finished.length && !added.length && !health.length && !raised.length && !decided.length && !talk.length
17788
- };
17789
- }
17790
- /** "A, B and 2 more". */
17791
- function some(names, shown = 3) {
17792
- const quoted = names.slice(0, shown).map((n) => `“${n}”`);
17793
- const rest = names.length - quoted.length;
17794
- if (rest > 0) return `${quoted.join(", ")} and ${rest} more`;
17795
- if (quoted.length < 2) return quoted.join("");
17796
- return `${quoted.slice(0, -1).join(", ")} and ${quoted.at(-1)}`;
17797
- }
17798
- /** The digest as short plain lines, the way the Inbox card, a chat post and the terminal say it. */
17799
- function digestLines(d) {
17800
- const lines = [];
17801
- if (d.finished.length) lines.push(`${plural$5(d.finished.length, "task")} finished: ${some(d.finished.map((t) => t.title))}.`);
17802
- if (d.added.length) lines.push(`${plural$5(d.added.length, "task")} added: ${some(d.added.map((t) => t.title))}.`);
17803
- for (const h of d.health.slice(0, 5)) lines.push(`${h.name} went from ${HEALTH_LABEL$1[h.from] ?? h.from} to ${HEALTH_LABEL$1[h.to] ?? h.to}.`);
17804
- if (d.health.length > 5) lines.push(`${d.health.length - 5} more changed health.`);
17805
- if (d.raised.length) {
17806
- const risks = d.raised.filter((r) => r.kind === "risk").length;
17807
- const issues = d.raised.length - risks;
17808
- const what = [risks ? plural$5(risks, "risk") : "", issues ? plural$5(issues, "issue") : ""].filter(Boolean).join(" and ");
17809
- lines.push(`${what} raised: ${some(d.raised.map((r) => r.title))}.`);
17810
- }
17811
- if (d.decided.length) lines.push(`${plural$5(d.decided.length, "decision")} made: ${some(d.decided.map((r) => r.title))}.`);
17812
- if (d.talk.length) {
17813
- const top = d.talk.slice(0, 3).map((t) => `${t.where} (${t.count}, ${t.who.join(", ")})`).join("; ");
17814
- const rest = d.talk.length - 3;
17815
- lines.push(`Talk: ${top}${rest > 0 ? `; and ${plural$5(rest, "more conversation")}` : ""}.`);
17816
- }
17817
- return lines;
17818
- }
17819
- var ARRIVED_DONE_MS, plural$5;
17820
- var init_daily_digest = __esmMin((() => {
17821
- init_swatches();
17822
- init_indexes();
17823
- init_project_messages();
17824
- init_task_keys();
17825
- ARRIVED_DONE_MS = 6e4;
17826
- plural$5 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
17827
- }));
17828
-
17829
18021
  // src/lib/milestone-edits.ts
17830
18022
  /**
17831
18023
  * A milestone with `patch` applied, remembering the day it was reached:
@@ -17942,7 +18134,6 @@ var init_task_milestones = __esmMin((() => {
17942
18134
  }));
17943
18135
 
17944
18136
  // src/lib/compass.ts
17945
- init_daily_digest();
17946
18137
  init_task_milestones();
17947
18138
  init_indexes();
17948
18139
  const zero = () => ({
@@ -18081,7 +18272,239 @@ function shareOf(e, reading, by = "effort") {
18081
18272
  return (by === "spend" ? e.spent : amountOf(e, reading.measure)) / whole;
18082
18273
  }
18083
18274
 
18275
+ // src/lib/old-salts.ts
18276
+ init_date_fns();
18277
+ init_date_text();
18278
+ init_first_voyage();
18279
+ init_indexes();
18280
+ init_premortem();
18281
+ /** A slip shorter than this isn't a lesson, just a busy week. */
18282
+ const SLIP_DAYS = 7;
18283
+ /** Lessons one project offers, and the most a card shows at once. */
18284
+ const PER_PROJECT = 4;
18285
+ const SHOWN = 3;
18286
+ /** Finished projects a card draws on. */
18287
+ const SOURCES = 2;
18288
+ const days$3 = (from, to) => differenceInCalendarDays(parseIso(localDay(to)), parseIso(from.slice(0, 10)));
18289
+ const clip = (s, n) => {
18290
+ const flat = s.replace(/\s+/g, " ").trim();
18291
+ return flat.length <= n ? flat : `${flat.slice(0, n - 1).replace(/\s+\S*$/, "")}…`;
18292
+ };
18293
+ const lower = (s) => /^[A-Z][a-z]/.test(s) ? s[0].toLowerCase() + s.slice(1) : s;
18294
+ function slipText(task, late) {
18295
+ const weeks = Math.round(late / 7);
18296
+ const when = late >= 14 ? `${weeks} weeks` : `${late} days`;
18297
+ return `“${clip(task.title, 80)}” finished ${when} late`;
18298
+ }
18299
+ /** The lessons one finished project offers, the crew's own words first. */
18300
+ function lessonsOf(project, data, raid = data.raidItems.filter((r) => r.projectId === project.id), lines = (data.reflections ?? []).filter((r) => r.projectId === project.id && r.kind === "voyage")) {
18301
+ const from = {
18302
+ id: project.id,
18303
+ name: project.name
18304
+ };
18305
+ const out = [];
18306
+ for (const l of [...lines].sort((a, b) => a.createdAt.localeCompare(b.createdAt))) {
18307
+ if (!l.body.trim()) continue;
18308
+ out.push({
18309
+ id: `line:${l.id}`,
18310
+ kind: "line",
18311
+ from,
18312
+ text: clip(l.body, 200),
18313
+ helped: null,
18314
+ title: riskTitle(l.body)
18315
+ });
18316
+ }
18317
+ for (const r of raid) if (r.kind === "risk" && r.happened === true) out.push({
18318
+ id: `risk:${r.id}`,
18319
+ kind: "came-true",
18320
+ from,
18321
+ text: `${lower(clip(r.title, 120))} (a risk that came true)`,
18322
+ helped: r.contingency?.trim() || r.mitigation?.trim() || null,
18323
+ title: clip(r.title, 120)
18324
+ });
18325
+ else if (r.kind === "issue") out.push({
18326
+ id: `issue:${r.id}`,
18327
+ kind: "issue",
18328
+ from,
18329
+ text: lower(clip(r.title, 120)),
18330
+ helped: r.resolution?.trim() || null,
18331
+ title: clip(r.title, 120)
18332
+ });
18333
+ const slips = tasksOf(data.tasks, project.id).filter((t) => t.status === "done" && t.dueDate && t.completedAt && !t.parentTaskId).map((t) => ({
18334
+ t,
18335
+ late: days$3(t.dueDate, t.completedAt)
18336
+ })).filter((s) => s.late >= 7).sort((a, b) => b.late - a.late).slice(0, 2);
18337
+ for (const { t, late } of slips) out.push({
18338
+ id: `slip:${t.id}`,
18339
+ kind: "slip",
18340
+ from,
18341
+ text: slipText(t, late),
18342
+ helped: null,
18343
+ title: `Leave room for ${lower(clip(t.title, 100))}`
18344
+ });
18345
+ return out.slice(0, 4);
18346
+ }
18347
+ /**
18348
+ * The finished projects this one sounds like, best first: shared meaningful
18349
+ * words of name and description, with the same program counting as one
18350
+ * more (so a program's finished projects count even with no words shared).
18351
+ * Most recently finished first on a tie.
18352
+ */
18353
+ function kindredProjects(data, project) {
18354
+ const want = contentWords(`${project.name} ${project.description}`);
18355
+ const scored = [];
18356
+ for (const p of data.projects) {
18357
+ if (p.id === project.id || p.health !== "done" || isVoyageProject(p.id)) continue;
18358
+ const theirs = contentWords(`${p.name} ${p.description}`);
18359
+ let score = 0;
18360
+ for (const w of want) if (theirs.has(w)) score += 1;
18361
+ if (p.programId === project.programId) score += 1;
18362
+ if (score === 0) continue;
18363
+ const done = [...p.healthHistory ?? []].reverse().find((h) => h.health === "done")?.at;
18364
+ scored.push({
18365
+ p,
18366
+ score,
18367
+ at: done ?? p.endDate
18368
+ });
18369
+ }
18370
+ return scored.sort((a, b) => b.score - a.score || b.at.localeCompare(a.at)).map((s) => s.p);
18371
+ }
18372
+ /**
18373
+ * What the old salts say to this project: lessons from the finished projects
18374
+ * it looks like, leaving out any put away (or already taken) here. Nothing
18375
+ * for a finished project.
18376
+ */
18377
+ function oldSalts(data, project) {
18378
+ if (project.health === "done" || isVoyageProject(project.id)) return [];
18379
+ const heard = new Set(project.saltsHeard ?? []);
18380
+ const out = [];
18381
+ let sources = 0;
18382
+ for (const p of kindredProjects(data, project).slice(0, 10)) {
18383
+ const fresh = lessonsOf(p, data).filter((l) => !heard.has(l.id));
18384
+ if (fresh.length === 0) continue;
18385
+ out.push(...fresh);
18386
+ if (++sources >= SOURCES) break;
18387
+ }
18388
+ return out.slice(0, 3);
18389
+ }
18390
+
18084
18391
  // src/lib/dock-order.ts
18392
+ /** The same key for a pair whichever way round it comes. */
18393
+ const pairKey = (a, b) => a < b ? `${a}|${b}` : `${b}|${a}`;
18394
+ /** Every vote that counts: answers about projects still in the ranking, each person's latest per pair. */
18395
+ function countedVotes(votes, projectIds) {
18396
+ const live = new Set(projectIds);
18397
+ const latest = /* @__PURE__ */ new Map();
18398
+ for (const v of votes) {
18399
+ if (v.a === v.b || !live.has(v.a) || !live.has(v.b)) continue;
18400
+ if (v.winner !== null && v.winner !== v.a && v.winner !== v.b) continue;
18401
+ const key = `${v.voter}\u0000${pairKey(v.a, v.b)}`;
18402
+ const was = latest.get(key);
18403
+ if (!was || was.at <= v.at) latest.set(key, v);
18404
+ }
18405
+ return [...latest.values()];
18406
+ }
18407
+ /** Bradley-Terry strengths, normalised to average 1. */
18408
+ function strengths(projectIds, votes) {
18409
+ const ids = [...projectIds];
18410
+ const wins = new Map(ids.map((id) => [id, .5]));
18411
+ const games = /* @__PURE__ */ new Map();
18412
+ for (const v of votes) {
18413
+ games.set(pairKey(v.a, v.b), (games.get(pairKey(v.a, v.b)) ?? 0) + 1);
18414
+ if (v.winner === null) {
18415
+ wins.set(v.a, wins.get(v.a) + .5);
18416
+ wins.set(v.b, wins.get(v.b) + .5);
18417
+ } else wins.set(v.winner, wins.get(v.winner) + 1);
18418
+ }
18419
+ let p = new Map(ids.map((id) => [id, 1]));
18420
+ for (let round = 0; round < 200; round++) {
18421
+ const next = /* @__PURE__ */ new Map();
18422
+ let change = 0;
18423
+ for (const i of ids) {
18424
+ let denom = 1 / (p.get(i) + 1);
18425
+ for (const j of ids) {
18426
+ if (i === j) continue;
18427
+ const n = games.get(pairKey(i, j));
18428
+ if (n) denom += n / (p.get(i) + p.get(j));
18429
+ }
18430
+ next.set(i, wins.get(i) / denom);
18431
+ }
18432
+ const mean = ids.reduce((s, id) => s + next.get(id), 0) / Math.max(1, ids.length);
18433
+ for (const id of ids) {
18434
+ const v = next.get(id) / mean;
18435
+ change = Math.max(change, Math.abs(v - p.get(id)));
18436
+ next.set(id, v);
18437
+ }
18438
+ p = next;
18439
+ if (change < 1e-9) break;
18440
+ }
18441
+ return p;
18442
+ }
18443
+ const AGREEMENT_LABEL = {
18444
+ clear: "Clear",
18445
+ leaning: "Leaning",
18446
+ "coin-toss": "Coin toss"
18447
+ };
18448
+ function agreementOf(sure) {
18449
+ return sure >= .8 ? "clear" : sure >= .65 ? "leaning" : "coin-toss";
18450
+ }
18451
+ /**
18452
+ * The order, strongest first (ties broken by name order of the ids given, so
18453
+ * it's stable), and for each place how sure people are it sits above the
18454
+ * next: the share of direct answers between the two when there are at least
18455
+ * two, otherwise what the strengths say.
18456
+ */
18457
+ function dockOrder(projectIds, votes) {
18458
+ const counted = countedVotes(votes, projectIds);
18459
+ const p = strengths(projectIds, counted);
18460
+ const index = new Map(projectIds.map((id, i) => [id, i]));
18461
+ const sorted = [...projectIds].sort((a, b) => p.get(b) - p.get(a) || index.get(a) - index.get(b));
18462
+ const answers = /* @__PURE__ */ new Map();
18463
+ const direct = /* @__PURE__ */ new Map();
18464
+ for (const v of counted) {
18465
+ answers.set(v.a, (answers.get(v.a) ?? 0) + 1);
18466
+ answers.set(v.b, (answers.get(v.b) ?? 0) + 1);
18467
+ const key = pairKey(v.a, v.b);
18468
+ const d = direct.get(key) ?? {
18469
+ games: 0,
18470
+ firstWins: 0
18471
+ };
18472
+ d.games++;
18473
+ const first = v.a < v.b ? v.a : v.b;
18474
+ d.firstWins += v.winner === null ? .5 : v.winner === first ? 1 : 0;
18475
+ direct.set(key, d);
18476
+ }
18477
+ return {
18478
+ places: sorted.map((id, i) => {
18479
+ const below = sorted[i + 1];
18480
+ let overNext = null;
18481
+ if (below) {
18482
+ const d = direct.get(pairKey(id, below));
18483
+ if (d && d.games >= 2) overNext = (id < below ? d.firstWins : d.games - d.firstWins) / d.games;
18484
+ else overNext = p.get(id) / (p.get(id) + p.get(below));
18485
+ }
18486
+ return {
18487
+ projectId: id,
18488
+ place: i + 1,
18489
+ strength: p.get(id),
18490
+ overNext,
18491
+ agreement: overNext === null ? null : agreementOf(overNext),
18492
+ answers: answers.get(id) ?? 0
18493
+ };
18494
+ }),
18495
+ voters: new Set(counted.map((v) => v.voter)).size,
18496
+ answers: counted.length
18497
+ };
18498
+ }
18499
+ /** "1st", "2nd", "3rd", "4th", "11th", "21st". */
18500
+ function ordinal(n) {
18501
+ return `${n}${n % 100 >= 11 && n % 100 <= 13 ? "th" : [
18502
+ "th",
18503
+ "st",
18504
+ "nd",
18505
+ "rd"
18506
+ ][n % 10] ?? "th"}`;
18507
+ }
18085
18508
  /** An order once it's put on the portfolio: only projects still there, and still open, each once. */
18086
18509
  function liveOrder(order, projects) {
18087
18510
  const open = new Set(projects.filter((p) => p.health !== "done").map((p) => p.id));
@@ -24677,6 +25100,7 @@ function approvalsWaitingOn(tasks, personId) {
24677
25100
 
24678
25101
  // src/lib/mcp/tools.ts
24679
25102
  init_project_messages();
25103
+ init_daily_digest();
24680
25104
  init_subtasks();
24681
25105
  init_blockers();
24682
25106
  init_time_log();
@@ -26571,6 +26995,81 @@ const HARBOR_TOOLS = [
26571
26995
  };
26572
26996
  }
26573
26997
  }),
26998
+ tool({
26999
+ name: "old_salts",
27000
+ title: "Old salts",
27001
+ description: "What finished projects like this one ran into (Old salts, at the top of a project's Risks & issues): risks that came true, issues, lines from their voyage logs and tasks that finished long late, each with the project it came from and what helped when that's known. Up to three, ones put away left out; none for a finished project. heed_old_salt turns one into a risk or a task here, or puts it away." + DATA_NOTE,
27002
+ input: object({
27003
+ harbor: harborArg,
27004
+ project: string().min(1).max(200).describe("Project id, key or name.")
27005
+ }),
27006
+ run: (ctx, input) => {
27007
+ const project = findOne(ctx.data.projects, input.project, "project");
27008
+ const lessons = oldSalts(ctx.data, project);
27009
+ return {
27010
+ project: project.name,
27011
+ ...project.health === "done" ? { note: `${project.name} is finished; old salts are for the projects still sailing.` } : {},
27012
+ lessons: lessons.map((l, i) => ({
27013
+ n: i + 1,
27014
+ id: l.id,
27015
+ kind: l.kind,
27016
+ from: l.from.name,
27017
+ text: `Last time, on ${l.from.name}: ${l.text}.`,
27018
+ ...l.helped ? { helped: l.helped } : {},
27019
+ title: l.title
27020
+ }))
27021
+ };
27022
+ }
27023
+ }),
27024
+ tool({
27025
+ name: "dock_order",
27026
+ title: "Which ship docks first",
27027
+ description: "A portfolio's projects in the order they matter, from Which ship docks first: the order put on the portfolio (who set it, when, from how many people's answers; finished or removed projects left out), and how the newest ranking link stands so far (each place with how sure people are it sits above the next: clear, leaning or coin toss). set_dock_order puts an order on it." + DATA_NOTE,
27028
+ input: object({
27029
+ harbor: harborArg,
27030
+ portfolio: string().min(1).max(200).describe("Portfolio id or name.")
27031
+ }),
27032
+ run: (ctx, input) => {
27033
+ const { data } = ctx;
27034
+ const portfolio = findOne(data.portfolios, input.portfolio, "portfolio");
27035
+ const programs = new Set(data.programs.filter((p) => p.portfolioId === portfolio.id).map((p) => p.id));
27036
+ const inIt = data.projects.filter((p) => programs.has(p.programId));
27037
+ const names = byId(data.projects);
27038
+ const name = (id) => names.get(id)?.name ?? null;
27039
+ const kept = portfolio.dockOrder;
27040
+ const order = kept ? liveOrder(kept.projectIds, inIt) : [];
27041
+ const open = inIt.filter((p) => p.health !== "done");
27042
+ const link = ctx.dockLink ?? null;
27043
+ const live = link ? link.projectIds.filter((id) => open.some((p) => p.id === id)) : [];
27044
+ const standing = link && live.length >= 2 ? dockOrder(live, link.votes) : null;
27045
+ return {
27046
+ portfolio: portfolio.name,
27047
+ openProjects: open.length,
27048
+ kept: kept ? {
27049
+ order: order.map((id, i) => ({
27050
+ place: ordinal(i + 1),
27051
+ project: name(id)
27052
+ })),
27053
+ at: kept.at,
27054
+ by: data.people.find((p) => p.id === kept.byId)?.name ?? null,
27055
+ voters: kept.voters,
27056
+ notRanked: open.filter((p) => !order.includes(p.id)).map((p) => p.name)
27057
+ } : null,
27058
+ ...link ? { link: {
27059
+ ...ctx.origin ? { url: `${ctx.origin}/dock/${link.token}` } : {},
27060
+ open: !link.closedAt,
27061
+ made: link.createdAt,
27062
+ voters: standing?.voters ?? 0,
27063
+ answers: standing?.answers ?? 0,
27064
+ standing: (standing?.places ?? []).map((p) => ({
27065
+ place: ordinal(p.place),
27066
+ project: name(p.projectId),
27067
+ ...p.agreement ? { overNext: AGREEMENT_LABEL[p.agreement].toLowerCase() } : {}
27068
+ }))
27069
+ } } : {}
27070
+ };
27071
+ }
27072
+ }),
26574
27073
  tool({
26575
27074
  name: "list_dashboards",
26576
27075
  title: "Dashboards",
@@ -27191,89 +27690,6 @@ var init_errors = __esmMin((() => {
27191
27690
  };
27192
27691
  }));
27193
27692
 
27194
- // src/lib/empty.ts
27195
- function addMonths(iso, months) {
27196
- const [y, m, d] = iso.split("-").map(Number);
27197
- const dt = new Date(y, (m ?? 1) - 1, d ?? 1);
27198
- dt.setMonth(dt.getMonth() + months);
27199
- return todayISO(dt);
27200
- }
27201
- /**
27202
- * A name worth offering in the harbor-name field: "Sam's harbor", or "" when
27203
- * nobody is known yet, so the field stays empty and shows its placeholder.
27204
- */
27205
- function harborNameFor(displayName, email) {
27206
- const first = (displayName || email || "").split(/[\s@]/)[0]?.trim();
27207
- return first ? `${first}'s harbor` : "";
27208
- }
27209
- /** What a new harbor is called until its owner names it: "Sam's harbor", else "My harbor". */
27210
- function suggestedHarborName(displayName, email) {
27211
- return harborNameFor(displayName, email) || "My harbor";
27212
- }
27213
- function createEmptyHarbor(opts) {
27214
- const today = todayISO();
27215
- const person = opts.person;
27216
- const harbor = opts.harborName.trim() || "Harbor";
27217
- const program = opts.programName?.trim() || "The work";
27218
- const drum = opts.drumTitle?.trim() ?? "";
27219
- return {
27220
- currentUserId: person.id,
27221
- readPingIds: [],
27222
- ropes: [],
27223
- checkIns: [],
27224
- boardConfigs: {},
27225
- people: [person],
27226
- portfolios: [{
27227
- id: "home",
27228
- name: harbor,
27229
- description: "The work of this harbor.",
27230
- swatch: "pine",
27231
- ownerId: person.id,
27232
- health: "on-track",
27233
- budget: 0
27234
- }],
27235
- programs: [{
27236
- id: "p1",
27237
- portfolioId: "home",
27238
- name: program,
27239
- description: opts.programDescription?.trim() ?? "",
27240
- swatch: "pine",
27241
- ownerId: person.id,
27242
- health: "on-track",
27243
- startDate: today,
27244
- endDate: addMonths(today, 6),
27245
- budget: 0
27246
- }],
27247
- projects: [],
27248
- milestones: [],
27249
- raidItems: [],
27250
- constraints: drum ? [{
27251
- id: "k1",
27252
- programId: "p1",
27253
- title: drum,
27254
- kind: opts.drumKind ?? "external",
27255
- status: "active",
27256
- ownerId: person.id,
27257
- note: opts.drumNote?.trim() ?? ""
27258
- }] : [],
27259
- tasks: [],
27260
- comments: [],
27261
- attachments: [],
27262
- activity: [{
27263
- id: "a1",
27264
- personId: person.id,
27265
- text: drum ? `named the constraint — ${drum}` : `opened ${harbor}`,
27266
- at: (/* @__PURE__ */ new Date()).toISOString(),
27267
- href: "/today"
27268
- }]
27269
- };
27270
- }
27271
- var STARTER_PROGRAM;
27272
- var init_empty = __esmMin((() => {
27273
- init_format();
27274
- STARTER_PROGRAM = "The work";
27275
- }));
27276
-
27277
27693
  // src/lib/deep-equal.ts
27278
27694
  /**
27279
27695
  * Structural equality, key-order independent, treating `undefined` and a
@@ -27772,12 +28188,27 @@ var init_session = __esmMin((() => {
27772
28188
  }));
27773
28189
 
27774
28190
  // src/lib/first-week.ts
27775
- /** The program launch named for you, when nobody has renamed it yet. */
28191
+ /**
28192
+ * The few things a new harbor needs in its first week, in the order they
28193
+ * matter: a first project, a real name on the account, a confirmed email,
28194
+ * and someone else aboard. Today lists the ones not done. Someone who
28195
+ * joined is asked only for their name and their email.
28196
+ *
28197
+ * The placeholder program ("The work") isn't on the list: it gives way to
28198
+ * the first program anyone makes, so naming it is never a chore to set.
28199
+ */
28200
+ /**
28201
+ * The program launch named for you, while nobody has renamed it and it holds
28202
+ * nothing but First voyage: once someone's own project, milestone or risk is
28203
+ * in it, it's their program, and a new one is made beside it.
28204
+ */
27776
28205
  function starterProgram(data) {
27777
- return data.programs.find((p) => p.name.trim() === "The work") ?? null;
28206
+ const program = data.programs.find((p) => p.name.trim() === STARTER_PROGRAM);
28207
+ if (!program) return null;
28208
+ return ownProjects(data.projects).some((p) => p.programId === program.id) || data.milestones.some((m) => m.programId === program.id) || data.raidItems.some((r) => r.programId === program.id) ? null : program;
27778
28209
  }
27779
28210
  var init_first_week = __esmMin((() => {
27780
- init_empty();
28211
+ init_first_voyage();
27781
28212
  }));
27782
28213
 
27783
28214
  // src/lib/slices/hierarchy.ts
@@ -36699,6 +37130,7 @@ function WeekView({ active, width, height, go }) {
36699
37130
  * over the screen, which stays mounted so Esc comes back to the same place.
36700
37131
  */
36701
37132
  init_esm();
37133
+ init_empty();
36702
37134
  const NAV = [
36703
37135
  {
36704
37136
  screen: "today",
@@ -36764,6 +37196,15 @@ const LETTER_KEYS = [
36764
37196
  "G",
36765
37197
  "O"
36766
37198
  ];
37199
+ /** The screens where n makes something: a task, or what the screen lists. */
37200
+ const N_MAKES = /* @__PURE__ */ new Set([
37201
+ "today",
37202
+ "projects",
37203
+ "programs",
37204
+ "risks",
37205
+ "goals",
37206
+ "reports"
37207
+ ]);
36767
37208
  /** The key that opens a sidebar screen: 1 to 9, 0 for the tenth, then a letter. */
36768
37209
  const navKey = (i) => i < 10 ? String((i + 1) % 10) : LETTER_KEYS[i - 10] ?? " ";
36769
37210
  /** The sidebar's width: its longest line ("9 Calendar", ": Anything") with room either side. */
@@ -37272,7 +37713,7 @@ function App({ ui, startIn }) {
37272
37713
  ["0–9", "screens"],
37273
37714
  [":", "anything"],
37274
37715
  ["/", "find"],
37275
- ["n", "new"],
37716
+ ...N_MAKES.has(screen) ? [["n", "new"]] : [],
37276
37717
  ["u", "undo"],
37277
37718
  ["H", "harbors"],
37278
37719
  ["?", "keys"],
@@ -37368,7 +37809,11 @@ function App({ ui, startIn }) {
37368
37809
  children: quitting ? "● saving before you go…" : saveText
37369
37810
  }), /* @__PURE__ */ jsxs(Text, {
37370
37811
  color: theme.muted,
37371
- children: [" · ", account.name || account.email]
37812
+ children: [
37813
+ " ",
37814
+ "· ",
37815
+ nameFromEmail(account.name, account.email) ? account.email : account.name
37816
+ ]
37372
37817
  })] })]
37373
37818
  }),
37374
37819
  /* @__PURE__ */ jsxs(Box, {
@@ -38141,6 +38586,7 @@ init_errors();
38141
38586
  init_plain();
38142
38587
  init_search();
38143
38588
  init_view_only();
38589
+ init_first_voyage();
38144
38590
  init_repo_sync();
38145
38591
  init_commands();
38146
38592
  const today = () => format(/* @__PURE__ */ new Date(), "yyyy-MM-dd");
@@ -38178,6 +38624,11 @@ async function startApp(deps, options = {}) {
38178
38624
  instance.unmount();
38179
38625
  throw err;
38180
38626
  }
38627
+ const opened = store.getState();
38628
+ if (opened.myRole !== "viewer" && !opened.keepPaused) {
38629
+ const ticks = voyageTicks(opened, { apps: ["Harbor CLI"] });
38630
+ if (ticks.length) opened.tickVoyage(ticks);
38631
+ }
38181
38632
  if (deps.firstRun) {
38182
38633
  const project = deps.firstRun.project;
38183
38634
  if (project) addFirstProject(store, project, account.id, today());