@harborppm/cli 0.118.0 → 0.119.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
@@ -258,6 +258,7 @@ harbor convoy ask PROGRAM --to OTHER --by DATE "WHAT"
258
258
  harbor convoy accept|decline|deliver|undeliver|move|withdraw CONVOY [--project P] [--note WHY] [--by DATE]
259
259
  harbor salts PROJECT [--risk N|--task N|--put-away N] what finished projects like it ran into
260
260
  harbor rank PORTFOLIO [--order "A, B, C"|--clear] which ship docks first
261
+ harbor wbs NAME [--depth N] [--open] the work breakdown, numbered 1, 1.1, 1.1.2
261
262
  harbor agent [--agent NAME]
262
263
  harbor agent report TASK "WHAT YOU DID" [--start] [--agent NAME]
263
264
  ```
@@ -272,6 +273,8 @@ harbor agent report TASK "WHAT YOU DID" [--start] [--agent NAME]
272
273
 
273
274
  `harbor salts "Ridge Runner"` shows up to three old salts: what finished projects like it ran into (risks that came true, issues, voyage log lines, tasks that finished long late), with what helped. `--risk 1` puts the first on the register, `--task 1` adds it as a task, `--put-away 1` stops showing it. `harbor rank "Summit Line"` shows the order a portfolio's projects dock in, who set it and how the newest ranking link stands; `--order "Daypack, Ridge Runner"` sets one (open projects of that portfolio, first to dock first) and `--clear` takes it off. The ranking link the crew answers in pairs is made on the portfolio page.
274
275
 
276
+ `harbor wbs "Summit Line"` prints a portfolio, program or project as its work breakdown: every program, project, task and subtask under it on its own line, numbered from it (1, 1.1, 1.1.2) as the website's Breakdown view numbers them, with the owner, dates, how much is done and how many are late. `--depth 2` stays two levels down, `--open` leaves finished work out without renumbering the rest, and `--kind program` settles a name a project and a program share.
277
+
275
278
  `harbor lifeboats` lists the work only one person has touched (a project, their corner of one, a task others wait on, their serious risks), numbered, each with someone who has room this week and already works nearby. `harbor lifeboats 2` puts that person on line 2 as a second pair of hands (`--person NAME` for someone else); `harbor follow RR-4 --person Sam` does it for one task. Following doesn't take the work over. `harbor raid "DECISION" --still-stands "WHY"` says a decision that came back for a look still stands.
276
279
 
277
280
  Agents on the crew: put an AI app on People with Add an agent and assign it tasks like anyone else. An agent working through the CLI (Claude Code, say) runs `harbor agent` for its tasks, in progress first, with their notes, checklists and latest comments. When it's done, `harbor agent report RR-4 "Drafted 12 questions; two need Dana"` adds its note as the agent's comment and moves the task to In review and asks whoever gave it the task to check it. They approve it, or send it back with a note, which `harbor agent` shows first. An agent never marks its own work Done.
package/dist/app.mjs CHANGED
@@ -3118,6 +3118,7 @@ function weekPlan(data, personId, monday) {
3118
3118
  date,
3119
3119
  items,
3120
3120
  hours,
3121
+ doneHours: items.reduce((sum, i) => sum + (i.task.status === "done" ? i.hours : 0), 0),
3121
3122
  over: hours > dayHours
3122
3123
  };
3123
3124
  });
@@ -3226,7 +3227,7 @@ function trialDaysLeft(trialEndsAt, now = /* @__PURE__ */ new Date()) {
3226
3227
 
3227
3228
  // src/lib/forecast.ts
3228
3229
  init_date_fns();
3229
- const day$9 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
3230
+ const day$10 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
3230
3231
  /**
3231
3232
  * A straight-line estimate at completion from the burn so far: spend divided
3232
3233
  * by the share of the schedule elapsed. Null before anything is spent or
@@ -3235,8 +3236,8 @@ const day$9 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
3235
3236
  */
3236
3237
  function forecastAtCompletion(item, now) {
3237
3238
  if (item.spent <= 0) return null;
3238
- const total = differenceInCalendarDays(day$9(item.endDate), day$9(item.startDate)) + 1;
3239
- const gone = differenceInCalendarDays(now, day$9(item.startDate)) + 1;
3239
+ const total = differenceInCalendarDays(day$10(item.endDate), day$10(item.startDate)) + 1;
3240
+ const gone = differenceInCalendarDays(now, day$10(item.startDate)) + 1;
3240
3241
  if (total <= 0 || gone <= 0) return null;
3241
3242
  const elapsed = Math.min(1, gone / total);
3242
3243
  const eac = Math.round(item.spent / elapsed);
@@ -4483,7 +4484,7 @@ init_tide();
4483
4484
  init_raid();
4484
4485
  init_flow();
4485
4486
  init_date_fns();
4486
- const day$8 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4487
+ const day$9 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4487
4488
  function monthKey(iso) {
4488
4489
  return iso.slice(0, 7);
4489
4490
  }
@@ -4499,7 +4500,7 @@ function monthsBetween(from, to) {
4499
4500
  return out;
4500
4501
  }
4501
4502
  function daysIn(key) {
4502
- return getDaysInMonth(day$8(`${key}-01`));
4503
+ return getDaysInMonth(day$9(`${key}-01`));
4503
4504
  }
4504
4505
  /** How many of the schedule's days fall in `key`. */
4505
4506
  function overlapDays(key, start, end) {
@@ -4507,7 +4508,7 @@ function overlapDays(key, start, end) {
4507
4508
  const lastDay = `${key}-${String(daysIn(key)).padStart(2, "0")}`;
4508
4509
  const from = start > first ? start : first;
4509
4510
  const to = end < lastDay ? end : lastDay;
4510
- return to < from ? 0 : differenceInCalendarDays(day$8(to), day$8(from)) + 1;
4511
+ return to < from ? 0 : differenceInCalendarDays(day$9(to), day$9(from)) + 1;
4511
4512
  }
4512
4513
  /**
4513
4514
  * The budget spread straight across the schedule: each month gets the share
@@ -4517,7 +4518,7 @@ function overlapDays(key, start, end) {
4517
4518
  function evenPhasing(project) {
4518
4519
  const end = project.endDate < project.startDate ? project.startDate : project.endDate;
4519
4520
  const months = monthsBetween(project.startDate, end);
4520
- const total = differenceInCalendarDays(day$8(end), day$8(project.startDate)) + 1;
4521
+ const total = differenceInCalendarDays(day$9(end), day$9(project.startDate)) + 1;
4521
4522
  const out = {};
4522
4523
  let placed = 0;
4523
4524
  months.forEach((k, i) => {
@@ -4624,7 +4625,7 @@ function hasBaseline(p) {
4624
4625
  /** Days the end has moved past the baseline end; negative when it came in. Null without a baseline. */
4625
4626
  function slipDays(p) {
4626
4627
  if (!p.baselineEnd) return null;
4627
- return differenceInCalendarDays(day$7(p.endDate), day$7(p.baselineEnd));
4628
+ return differenceInCalendarDays(day$8(p.endDate), day$8(p.baselineEnd));
4628
4629
  }
4629
4630
  /**
4630
4631
  * The projects with the current dates committed as their baseline; ones that
@@ -4646,10 +4647,10 @@ function slipLabel(p) {
4646
4647
  const n = Math.abs(slip);
4647
4648
  return slip > 0 ? `slipped ${n} day${n === 1 ? "" : "s"}` : `${n} day${n === 1 ? "" : "s"} early`;
4648
4649
  }
4649
- var day$7;
4650
+ var day$8;
4650
4651
  var init_baseline = __esmMin((() => {
4651
4652
  init_date_fns();
4652
- day$7 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4653
+ day$8 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
4653
4654
  }));
4654
4655
 
4655
4656
  // src/lib/roadmap.ts
@@ -4677,7 +4678,7 @@ const ZOOMS = [
4677
4678
  step: 3
4678
4679
  }
4679
4680
  ];
4680
- const day$6 = (iso) => /* @__PURE__ */ new Date(`${iso.slice(0, 10)}T12:00:00`);
4681
+ const day$7 = (iso) => /* @__PURE__ */ new Date(`${iso.slice(0, 10)}T12:00:00`);
4681
4682
  /** Names in the order people expect: "Phase 2" before "Phase 10". */
4682
4683
  const byName = (a, b) => a.localeCompare(b, void 0, { numeric: true });
4683
4684
  const isoDay$4 = (d) => format(d, "yyyy-MM-dd");
@@ -4687,7 +4688,7 @@ const isoDay$4 = (d) => format(d, "yyyy-MM-dd");
4687
4688
  */
4688
4689
  function roadmapWindow(zoom, today, shift = 0) {
4689
4690
  const z = ZOOMS.find((x) => x.id === zoom) ?? ZOOMS[1];
4690
- const first = addMonths$1(startOfMonth(day$6(today)), -1 + shift * z.step);
4691
+ const first = addMonths$1(startOfMonth(day$7(today)), -1 + shift * z.step);
4691
4692
  const after = addMonths$1(first, z.months);
4692
4693
  const days = differenceInCalendarDays(after, first);
4693
4694
  const months = Array.from({ length: z.months }, (_, i) => {
@@ -4711,15 +4712,15 @@ function roadmapWindow(zoom, today, shift = 0) {
4711
4712
  function at(iso, w) {
4712
4713
  if (!iso) return null;
4713
4714
  if (iso < w.start || iso >= w.end) return null;
4714
- return differenceInCalendarDays(day$6(iso), day$6(w.start)) / w.days;
4715
+ return differenceInCalendarDays(day$7(iso), day$7(w.start)) / w.days;
4715
4716
  }
4716
4717
  /** A bar for a start–end span, clipped to the window; null when it's wholly outside. */
4717
4718
  function span$1(start, end, w) {
4718
4719
  if (!start || !end || end < w.start || start >= w.end) return null;
4719
4720
  const from = start < w.start ? w.start : start;
4720
- const until = end >= w.end ? w.end : isoDay$4(new Date(day$6(end).getTime() + 864e5));
4721
- const left = differenceInCalendarDays(day$6(from), day$6(w.start)) / w.days;
4722
- const right = differenceInCalendarDays(day$6(until), day$6(w.start)) / w.days;
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;
4723
4724
  return {
4724
4725
  left,
4725
4726
  width: Math.max(right - left, 1 / w.days),
@@ -8366,7 +8367,7 @@ function bottleState(note, ctx) {
8366
8367
  /** "opens on Nov 14", "opens when Factory buy-off is reached", "opens if Ridge Runner launch turns Off track" */
8367
8368
  function opensText(opens, ctx) {
8368
8369
  if (!opens) return "open now";
8369
- if (opens.on === "date") return `opens on ${day$5(opens.date)}`;
8370
+ if (opens.on === "date") return `opens on ${day$6(opens.date)}`;
8370
8371
  if (opens.on === "milestone") {
8371
8372
  const m = ctx.milestones.find((x) => x.id === opens.milestoneId);
8372
8373
  return m ? `opens when ${m.name} is reached` : "opens when its milestone is reached";
@@ -8400,7 +8401,7 @@ function freshlyOpened(data, projects, now) {
8400
8401
  }
8401
8402
  return out.sort((a, b) => (b.state.openedOn ?? "").localeCompare(a.state.openedOn ?? ""));
8402
8403
  }
8403
- var BOTTLE_FRESH_DAYS, isBottle, sealed, day$5;
8404
+ var BOTTLE_FRESH_DAYS, isBottle, sealed, day$6;
8404
8405
  var init_bottle = __esmMin((() => {
8405
8406
  init_date_fns();
8406
8407
  init_date_text();
@@ -8412,7 +8413,7 @@ var init_bottle = __esmMin((() => {
8412
8413
  open: false,
8413
8414
  openedOn: null
8414
8415
  };
8415
- day$5 = (iso) => format(parseIso(iso.slice(0, 10)), "MMM d");
8416
+ day$6 = (iso) => format(parseIso(iso.slice(0, 10)), "MMM d");
8416
8417
  }));
8417
8418
 
8418
8419
  // src/lib/decisions.ts
@@ -10802,8 +10803,8 @@ init_blockers();
10802
10803
  init_date_text();
10803
10804
  init_premortem();
10804
10805
  init_thanks();
10805
- const day$4 = (iso) => parseIso(localDay(iso));
10806
- const between = (a, b) => differenceInCalendarDays(day$4(b), day$4(a));
10806
+ const day$5 = (iso) => parseIso(localDay(iso));
10807
+ const between = (a, b) => differenceInCalendarDays(day$5(b), day$5(a));
10807
10808
  function voyageLog(data, projectId) {
10808
10809
  const project = data.projects.find((p) => p.id === projectId);
10809
10810
  if (!project) return null;
@@ -10870,7 +10871,7 @@ function voyageLog(data, projectId) {
10870
10871
  };
10871
10872
  }
10872
10873
  const plural$7 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
10873
- const md$1 = (iso) => format(day$4(iso), "MMM d");
10874
+ const md$1 = (iso) => format(day$5(iso), "MMM d");
10874
10875
  /** The three numbers at the top: how late, how much work, how many risks came true. */
10875
10876
  function voyageStats(log) {
10876
10877
  const happened = log.risks.filter((r) => r.happened).length;
@@ -13257,7 +13258,7 @@ function dollars(value) {
13257
13258
  const n = Number(value ?? 0);
13258
13259
  return whole$1.format(Number.isFinite(n) ? n : 0);
13259
13260
  }
13260
- function day$3(value) {
13261
+ function day$4(value) {
13261
13262
  return value ? shortDate(value) : "no date";
13262
13263
  }
13263
13264
  /** Whole days from one ISO day to another. */
@@ -13345,15 +13346,15 @@ function describeEvent(e, names) {
13345
13346
  };
13346
13347
  case "dueDate": return {
13347
13348
  action: "moved the due date of",
13348
- detail: `from ${day$3(from)} to ${day$3(to)}${slip(from, to)}`
13349
+ detail: `from ${day$4(from)} to ${day$4(to)}${slip(from, to)}`
13349
13350
  };
13350
13351
  case "startDate": return {
13351
13352
  action: "moved the start of",
13352
- detail: `from ${day$3(from)} to ${day$3(to)}${slip(from, to)}`
13353
+ detail: `from ${day$4(from)} to ${day$4(to)}${slip(from, to)}`
13353
13354
  };
13354
13355
  case "endDate": return {
13355
13356
  action: "moved the end of",
13356
- detail: `from ${day$3(from)} to ${day$3(to)}${slip(from, to)}`
13357
+ detail: `from ${day$4(from)} to ${day$4(to)}${slip(from, to)}`
13357
13358
  };
13358
13359
  case "budget": return {
13359
13360
  action: "changed the budget of",
@@ -13934,7 +13935,7 @@ init_date_fns();
13934
13935
  init_date_text();
13935
13936
  init_indexes();
13936
13937
  init_tide();
13937
- const day$2 = (iso) => parseIso(iso.slice(0, 10));
13938
+ const day$3 = (iso) => parseIso(iso.slice(0, 10));
13938
13939
  /** When a convoy looks like arriving, and how that was read. */
13939
13940
  function expectedOf(data, convoy, now) {
13940
13941
  const project = convoy.projectId ? byId(data.projects).get(convoy.projectId) ?? null : null;
@@ -13972,7 +13973,7 @@ function convoyRows(data, now) {
13972
13973
  for (const asker of data.programs) for (const convoy of asker.convoys ?? []) {
13973
13974
  const giver = programs.get(convoy.toProgramId) ?? null;
13974
13975
  const { expected, basis, project } = expectedOf(data, convoy, now);
13975
- const late = expected ? differenceInCalendarDays(day$2(expected), day$2(convoy.by)) : null;
13976
+ const late = expected ? differenceInCalendarDays(day$3(expected), day$3(convoy.by)) : null;
13976
13977
  out.push({
13977
13978
  convoy,
13978
13979
  asker,
@@ -14028,7 +14029,7 @@ const MONTHS = [
14028
14029
  ];
14029
14030
  /** "Dec 12". */
14030
14031
  function shortDay(iso) {
14031
- const d = day$2(iso);
14032
+ const d = day$3(iso);
14032
14033
  return Number.isNaN(d.getTime()) ? iso : `${MONTHS[d.getMonth()]} ${d.getDate()}`;
14033
14034
  }
14034
14035
  /** Who should hear about a convoy: its program's owner and whoever asked or answered. */
@@ -15198,7 +15199,7 @@ init_handover();
15198
15199
  const SOON_DAYS = 21;
15199
15200
  /** This many open tasks in one project that only one person has touched read as their corner of it. */
15200
15201
  const CLUSTER = 4;
15201
- const isoDay$1 = (d) => d.toISOString().slice(0, 10);
15202
+ const isoDay$1 = (d) => format(d, "yyyy-MM-dd");
15202
15203
  const md = (iso) => format(parseIso(iso), "MMM d");
15203
15204
  /** Everyone a task has passed through. */
15204
15205
  function taskHands(task, commentsBy, attachedBy) {
@@ -24988,7 +24989,7 @@ init_format();
24988
24989
  init_indexes();
24989
24990
  const noon$1 = (iso) => /* @__PURE__ */ new Date(`${iso.slice(0, 10)}T12:00:00`);
24990
24991
  const days$2 = (from, to) => differenceInCalendarDays(noon$1(to), noon$1(from));
24991
- const later = (a, b) => !a ? b : !b ? a : a >= b ? a : b;
24992
+ const later$1 = (a, b) => !a ? b : !b ? a : a >= b ? a : b;
24992
24993
  const open = (t) => t.status !== "done";
24993
24994
  /** True when `a` finishes later than `b`, or as late behind a longer line. */
24994
24995
  const beats = (a, b) => !b || a.finish > b.finish || a.finish === b.finish && a.depth > b.depth;
@@ -25011,10 +25012,10 @@ function finishes(all, today) {
25011
25012
  const w = walk(b);
25012
25013
  if (w.finish && beats(w, behind)) behind = w;
25013
25014
  }
25014
- const own = t.dueDate ? later(t.dueDate.slice(0, 10), today) : null;
25015
+ const own = t.dueDate ? later$1(t.dueDate.slice(0, 10), today) : null;
25015
25016
  onPath.delete(t.id);
25016
25017
  const out = {
25017
- finish: later(own, behind?.finish ?? null),
25018
+ finish: later$1(own, behind?.finish ?? null),
25018
25019
  depth: (behind?.depth ?? 0) + 1
25019
25020
  };
25020
25021
  memo.set(t.id, out);
@@ -25135,7 +25136,7 @@ function milestonePole(milestone, data, now) {
25135
25136
  return [{
25136
25137
  project,
25137
25138
  pole,
25138
- finish: pole.kind === "chain" ? later(pole.finish, end) ?? end : end
25139
+ finish: pole.kind === "chain" ? later$1(pole.finish, end) ?? end : end
25139
25140
  }];
25140
25141
  });
25141
25142
  if (runs.length === 0) return {
@@ -25469,7 +25470,7 @@ const SIMILAR_MIN = 3;
25469
25470
  /** A finished task that took longer than this sat somewhere; it counts as this long. */
25470
25471
  const SIMILAR_CAP = 15;
25471
25472
  const firstName$1 = (name) => name.trim().split(/\s+/)[0] || name;
25472
- const day$1 = (iso) => iso ? iso.slice(0, 10) : null;
25473
+ const day$2 = (iso) => iso ? iso.slice(0, 10) : null;
25473
25474
  function quantile(sorted, q) {
25474
25475
  const at = (sorted.length - 1) * q;
25475
25476
  const lo = Math.floor(at);
@@ -25485,7 +25486,7 @@ function pilotDate(task, data, localToday, at) {
25485
25486
  const owner = byId(data.people).get(task.assigneeId);
25486
25487
  if (!owner || owner.kind === "agent") return null;
25487
25488
  const today = at ? todayFor(owner, at, localToday) : localToday;
25488
- const chosen = day$1(task.dueDate);
25489
+ const chosen = day$2(task.dueDate);
25489
25490
  let underWay = 0;
25490
25491
  const dated = [];
25491
25492
  const finished = [];
@@ -25495,14 +25496,14 @@ function pilotDate(task, data, localToday, at) {
25495
25496
  if (t.projectId === task.projectId && t.completedAt) finished.push(t);
25496
25497
  continue;
25497
25498
  }
25498
- const due = day$1(t.dueDate);
25499
+ const due = day$2(t.dueDate);
25499
25500
  if (t.status === "doing" || t.status === "review") underWay += 1;
25500
25501
  else if (due) dated.push(due);
25501
25502
  }
25502
25503
  const perDay = Math.max(.2, (owner.weeklyCapacity ?? 5) / 5);
25503
25504
  let similar = null;
25504
25505
  if (finished.length >= SIMILAR_MIN) {
25505
- 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$1(t.createdAt), day$1(t.completedAt))))).sort((a, b) => a - b);
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);
25506
25507
  similar = {
25507
25508
  low: Math.round(quantile(took, .25)),
25508
25509
  high: Math.round(quantile(took, .75)),
@@ -25510,7 +25511,7 @@ function pilotDate(task, data, localToday, at) {
25510
25511
  };
25511
25512
  }
25512
25513
  const ownDays = Math.min(5, Math.max(1, similar?.low ?? 1));
25513
- const backOn = isAway(owner, today) ? day$1(owner.away.until) : null;
25514
+ const backOn = isAway(owner, today) ? day$2(owner.away.until) : null;
25514
25515
  const start = backOn && backOn > today ? dayBefore(backOn) : today;
25515
25516
  const tasks = byId(data.tasks);
25516
25517
  const projects = byId(data.projects);
@@ -25521,7 +25522,7 @@ function pilotDate(task, data, localToday, at) {
25521
25522
  for (const id of blockers) {
25522
25523
  const b = tasks.get(id);
25523
25524
  if (!b || b.status === "done") continue;
25524
- const due = day$1(b.dueDate);
25525
+ const due = day$2(b.dueDate);
25525
25526
  if (!due) {
25526
25527
  undated ??= b;
25527
25528
  continue;
@@ -25590,7 +25591,7 @@ const plural$3 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
25590
25591
  /** 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". */
25591
25592
  function pilotHeadline(p, chosen, you = false) {
25592
25593
  const who = you ? "You" : firstName$1(p.owner.name);
25593
- if (!day$1(chosen)) return `${who} could likely have this by ${shortDate(p.earliest)}`;
25594
+ if (!day$2(chosen)) return `${who} could likely have this by ${shortDate(p.earliest)}`;
25594
25595
  return `${you ? "Your" : `${who}'s`} queue says ${shortDate(p.earliest)} at the earliest`;
25595
25596
  }
25596
25597
  /** Why: the queue, time away, what it waits on, and how long similar tasks took. */
@@ -25662,7 +25663,7 @@ function lastLooked(mark, data, personId) {
25662
25663
  init_date_text();
25663
25664
  init_indexes();
25664
25665
  init_task_keys();
25665
- const day = (iso) => parseIso(iso.slice(0, 10));
25666
+ const day$1 = (iso) => parseIso(iso.slice(0, 10));
25666
25667
  const daysBetween = dayGap;
25667
25668
  /** Their projects: ones they lead, in a program they lead, or with a task of theirs. */
25668
25669
  function projectsOf(data, personId) {
@@ -25677,7 +25678,7 @@ function dueText(task, today) {
25677
25678
  if (d === 0) return "due today";
25678
25679
  if (d < 0) return `${-d} day${d === -1 ? "" : "s"} late`;
25679
25680
  if (d === 1) return "due tomorrow";
25680
- return `due ${format(day(task.dueDate), "EEE, MMM d")}`;
25681
+ return `due ${format(day$1(task.dueDate), "EEE, MMM d")}`;
25681
25682
  }
25682
25683
  /** What a person needs to hear about since `when.since`, as of `today` (YYYY-MM-DD). */
25683
25684
  function welcomeBack(data, personId, when, today, shown = []) {
@@ -25805,7 +25806,7 @@ function moreText(more) {
25805
25806
  /** "Welcome back, Priya · away Oct 3 to Oct 17", or "· 5 days since you last looked". */
25806
25807
  function welcomeTitle(w, name, today) {
25807
25808
  const hi = name ? `Welcome back, ${name}` : "Welcome back";
25808
- if (w.when.why === "away") return `${hi} · away ${format(day(w.when.since), "MMM d")} to ${format(day(today), "MMM d")}`;
25809
+ if (w.when.why === "away") return `${hi} · away ${format(day$1(w.when.since), "MMM d")} to ${format(day$1(today), "MMM d")}`;
25809
25810
  return `${hi} · ${w.when.days} days since you last looked`;
25810
25811
  }
25811
25812
  /** "Checkout v3: 4 done, 2 added, now At risk (was On track)". */
@@ -26277,6 +26278,346 @@ function gapText(gap) {
26277
26278
  return `${called}; the numbers have said ${WORD[gap.rules]} for the last ${weeksText(gap.days)}.`;
26278
26279
  }
26279
26280
 
26281
+ // src/lib/wbs-move.ts
26282
+ var wbs_move_exports = /* @__PURE__ */ __exportAll({
26283
+ applyMove: () => applyMove,
26284
+ moveProblem: () => moveProblem,
26285
+ orderPlans: () => orderPlans,
26286
+ orderTasks: () => orderTasks
26287
+ });
26288
+ /** Ranked first, in rank order; the rest after, as `fallback` orders them (stable). */
26289
+ function byRank(list, fallback) {
26290
+ const at = new Map(list.map((x, i) => [x.id, i]));
26291
+ return [...list].sort((a, b) => {
26292
+ const ra = a.wbsRank ?? Infinity;
26293
+ const rb = b.wbsRank ?? Infinity;
26294
+ if (ra !== rb) return ra - rb;
26295
+ if (fallback) {
26296
+ const f = fallback(a, b);
26297
+ if (f) return f;
26298
+ }
26299
+ return at.get(a.id) - at.get(b.id);
26300
+ });
26301
+ }
26302
+ /** The task a link really points at as its parent (subtasks.ts's rule, without the import). */
26303
+ function realParent(t, index) {
26304
+ const p = t.parentTaskId ? index.get(t.parentTaskId) : void 0;
26305
+ if (!p || p.id === t.id || p.projectId !== t.projectId || p.parentTaskId) return null;
26306
+ return p;
26307
+ }
26308
+ /** The subtasks under `parent`, in list order. */
26309
+ function subsOf(parent, tasks, index) {
26310
+ if (realParent(parent, index)) return [];
26311
+ return (childrenByParent(tasks).get(parent.id) ?? []).filter((t) => t.projectId === parent.projectId && t.id !== parent.id);
26312
+ }
26313
+ /** The tasks that stand on their own in a project. */
26314
+ function topOf(projectId, tasks, index) {
26315
+ return tasksOf(tasks, projectId).filter((t) => !realParent(t, index));
26316
+ }
26317
+ /** Why this move can't be made, in a sentence; null when it can. */
26318
+ function moveProblem(doc, move) {
26319
+ if (move.kind === "program") {
26320
+ if (!doc.programs.some((p) => p.id === move.id)) return "That program isn't here any more.";
26321
+ return null;
26322
+ }
26323
+ if (move.kind === "project") {
26324
+ if (!doc.projects.some((p) => p.id === move.id)) return "That project isn't here any more.";
26325
+ if (!doc.programs.some((p) => p.id === move.into)) return "That program isn't here any more.";
26326
+ return null;
26327
+ }
26328
+ const index = byId(doc.tasks);
26329
+ const task = index.get(move.id);
26330
+ if (!task) return "That task isn't here any more.";
26331
+ const parent = move.into.kind === "task" ? index.get(move.into.id) : void 0;
26332
+ if (move.into.kind === "task" && !parent) return "That task isn't here any more.";
26333
+ const projectId = parent ? parent.projectId : move.into.id;
26334
+ if (!doc.projects.some((p) => p.id === projectId)) return "That project isn't here any more.";
26335
+ const locked = lockedFields(task);
26336
+ if (projectId !== task.projectId && locked.includes("projectId")) return "This task is kept in step from another tool, so it stays in its project.";
26337
+ const parentNow = realParent(task, index)?.id ?? null;
26338
+ if ((parent?.id ?? null) !== parentNow && locked.includes("parentTaskId")) return "This task is kept in step from Jira, which says what it sits under.";
26339
+ if (!parent) return null;
26340
+ if (parent.id === task.id) return "A task can't go inside itself.";
26341
+ if (realParent(parent, index)) return "That task is already a subtask; subtasks go one level deep.";
26342
+ if (subsOf(task, doc.tasks, index).length > 0) return "This task has subtasks of its own, so it can't go inside another.";
26343
+ if (subsOf(parent, doc.tasks, index).filter((t) => t.id !== task.id).length >= 50) return `A task can hold up to ${50} subtasks.`;
26344
+ return null;
26345
+ }
26346
+ /** `list` with `item` put before `before` (or last), each given its place as its rank. */
26347
+ function ranked(list, item, before) {
26348
+ const rest = list.filter((x) => x.id !== item.id);
26349
+ const at = before ? rest.findIndex((x) => x.id === before) : -1;
26350
+ rest.splice(at < 0 ? rest.length : at, 0, item);
26351
+ return new Map(rest.map((x, i) => [x.id, i + 1]));
26352
+ }
26353
+ /**
26354
+ * The rows the move changes, or null when it changes nothing (or can't be
26355
+ * made: ask `moveProblem` for why). A task moved to another project takes its
26356
+ * subtasks with it, as moving it from its drawer does; one kept in step from
26357
+ * another tool can't leave, so it stands alone where it was.
26358
+ */
26359
+ function applyMove(doc, move, now) {
26360
+ if (moveProblem(doc, move)) return null;
26361
+ if (move.kind === "program") {
26362
+ const program = doc.programs.find((p) => p.id === move.id);
26363
+ const ranks = ranked(orderPlans(doc.programs.filter((p) => p.portfolioId === move.into)), program, move.before);
26364
+ let changed = false;
26365
+ const programs = doc.programs.map((p) => {
26366
+ const rank = ranks.get(p.id);
26367
+ if (rank === void 0) return p;
26368
+ const portfolioId = p.id === program.id ? move.into : p.portfolioId;
26369
+ if (p.wbsRank === rank && p.portfolioId === portfolioId) return p;
26370
+ changed = true;
26371
+ return {
26372
+ ...p,
26373
+ wbsRank: rank,
26374
+ portfolioId
26375
+ };
26376
+ });
26377
+ return changed ? { programs } : null;
26378
+ }
26379
+ if (move.kind === "project") {
26380
+ const project = doc.projects.find((p) => p.id === move.id);
26381
+ const ranks = ranked(orderPlans(doc.projects.filter((p) => p.programId === move.into)), project, move.before);
26382
+ let changed = false;
26383
+ const projects = doc.projects.map((p) => {
26384
+ const rank = ranks.get(p.id);
26385
+ if (rank === void 0) return p;
26386
+ const programId = p.id === project.id ? move.into : p.programId;
26387
+ if (p.wbsRank === rank && p.programId === programId) return p;
26388
+ changed = true;
26389
+ return {
26390
+ ...p,
26391
+ wbsRank: rank,
26392
+ programId
26393
+ };
26394
+ });
26395
+ return changed ? { projects } : null;
26396
+ }
26397
+ const index = byId(doc.tasks);
26398
+ const task = index.get(move.id);
26399
+ const parent = move.into.kind === "task" ? index.get(move.into.id) : null;
26400
+ const projectId = parent ? parent.projectId : move.into.id;
26401
+ const parentTaskId = parent?.id ?? null;
26402
+ const ranks = ranked(parent ? orderTasks(subsOf(parent, doc.tasks, index)) : orderTasks(topOf(projectId, doc.tasks, index)), task, move.before);
26403
+ const under = projectId !== task.projectId ? subsOf(task, doc.tasks, index) : [];
26404
+ const carried = new Set(under.filter((t) => !lockedFields(t).includes("projectId")).map((t) => t.id));
26405
+ const leftBehind = new Set(under.filter((t) => !carried.has(t.id)).map((t) => t.id));
26406
+ let changed = false;
26407
+ const tasks = doc.tasks.map((t) => {
26408
+ if (t.id === task.id) {
26409
+ const rank = ranks.get(t.id);
26410
+ const parentNow = realParent(t, index)?.id ?? null;
26411
+ if (t.projectId === projectId && parentNow === parentTaskId && t.wbsRank === rank) return t;
26412
+ changed = true;
26413
+ return {
26414
+ ...t,
26415
+ projectId,
26416
+ parentTaskId,
26417
+ wbsRank: rank,
26418
+ touchedAt: now
26419
+ };
26420
+ }
26421
+ if (carried.has(t.id)) {
26422
+ changed = true;
26423
+ return {
26424
+ ...t,
26425
+ projectId,
26426
+ touchedAt: now
26427
+ };
26428
+ }
26429
+ if (leftBehind.has(t.id)) {
26430
+ changed = true;
26431
+ return {
26432
+ ...t,
26433
+ parentTaskId: null
26434
+ };
26435
+ }
26436
+ const rank = ranks.get(t.id);
26437
+ if (rank === void 0 || t.wbsRank === rank) return t;
26438
+ changed = true;
26439
+ return {
26440
+ ...t,
26441
+ wbsRank: rank
26442
+ };
26443
+ });
26444
+ return changed ? { tasks } : null;
26445
+ }
26446
+ var byStart, orderTasks, orderPlans;
26447
+ var init_wbs_move = __esmMin((() => {
26448
+ init_indexes();
26449
+ init_rollup_lock();
26450
+ init_subtasks();
26451
+ byStart = (a, b) => (a.startDate || "").localeCompare(b.startDate || "") || a.name.localeCompare(b.name);
26452
+ orderTasks = (list) => byRank(list);
26453
+ orderPlans = (list) => byRank(list, byStart);
26454
+ }));
26455
+
26456
+ // src/lib/wbs.ts
26457
+ init_indexes();
26458
+ init_rollup_lock();
26459
+ init_task_keys();
26460
+ init_wbs_move();
26461
+ const day = (iso) => iso ? iso.slice(0, 10) : null;
26462
+ const earlier = (a, b) => !a ? b : !b ? a : a < b ? a : b;
26463
+ const later = (a, b) => !a ? b : !b ? a : a > b ? a : b;
26464
+ function lockOf(t) {
26465
+ const locked = lockedFields(t);
26466
+ if (!locked.includes("projectId")) return void 0;
26467
+ return locked.includes("parentTaskId") ? "all" : "project";
26468
+ }
26469
+ function taskNode(t, kind, code, level, project, subs, today) {
26470
+ const lateOf = (x) => x.status !== "done" && x.dueDate && day(x.dueDate) < today ? 1 : 0;
26471
+ 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);
26474
+ if (children.length) {
26475
+ start = earlier(start, end);
26476
+ for (const c of children) {
26477
+ start = earlier(earlier(start, c.start), c.end);
26478
+ end = later(later(end, c.end), c.start);
26479
+ }
26480
+ }
26481
+ const doneSubs = children.filter((c) => c.finished).length;
26482
+ return {
26483
+ kind,
26484
+ id: t.id,
26485
+ code,
26486
+ level,
26487
+ title: t.title,
26488
+ key: taskKey(t, project) ?? void 0,
26489
+ ownerId: t.assigneeId,
26490
+ start,
26491
+ end,
26492
+ runsPast: false,
26493
+ done: children.length ? doneSubs : t.status === "done" ? 1 : 0,
26494
+ total: children.length || 1,
26495
+ late: lateOf(t) + children.reduce((n, c) => n + c.late, 0),
26496
+ status: t.status,
26497
+ finished: t.status === "done",
26498
+ projectId: t.projectId,
26499
+ locked: lockOf(t),
26500
+ children
26501
+ };
26502
+ }
26503
+ function projectNode(p, code, level, doc, today) {
26504
+ const index = byId(doc.tasks);
26505
+ const kids = childrenByParent(doc.tasks);
26506
+ const all = tasksByProject(doc.tasks).get(p.id) ?? [];
26507
+ const parentOf = (t) => {
26508
+ const q = t.parentTaskId ? index.get(t.parentTaskId) : void 0;
26509
+ return q && q.id !== t.id && q.projectId === t.projectId && !q.parentTaskId ? q : null;
26510
+ };
26511
+ const children = orderTasks(all.filter((t) => !parentOf(t))).map((t, i) => {
26512
+ const subs = (kids.get(t.id) ?? []).filter((s) => s.projectId === p.id && s.id !== t.id);
26513
+ return taskNode(t, "task", code ? `${code}.${i + 1}` : `${i + 1}`, level + 1, p, subs, today);
26514
+ });
26515
+ let latest = null;
26516
+ for (const c of children) latest = later(latest, c.end);
26517
+ const end = day(p.endDate);
26518
+ const done = all.filter((t) => t.status === "done").length;
26519
+ return {
26520
+ kind: "project",
26521
+ id: p.id,
26522
+ code,
26523
+ level,
26524
+ title: p.name,
26525
+ key: p.key,
26526
+ ownerId: p.ownerId || null,
26527
+ start: day(p.startDate),
26528
+ end,
26529
+ runsPast: Boolean(end && latest && latest > end),
26530
+ done,
26531
+ total: all.length,
26532
+ late: children.reduce((n, c) => n + c.late, 0),
26533
+ health: p.health,
26534
+ finished: p.health === "done",
26535
+ children
26536
+ };
26537
+ }
26538
+ /** A node that adds up its children's tasks. */
26539
+ function summed(base) {
26540
+ let done = 0;
26541
+ let total = 0;
26542
+ let late = 0;
26543
+ for (const c of base.children) {
26544
+ done += c.done;
26545
+ total += c.total;
26546
+ late += c.late;
26547
+ }
26548
+ return {
26549
+ ...base,
26550
+ done,
26551
+ total,
26552
+ late
26553
+ };
26554
+ }
26555
+ function programNode(g, code, level, doc, today) {
26556
+ 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
+ let latest = null;
26558
+ for (const c of children) latest = later(latest, later(c.end, latestUnder(c)));
26559
+ const end = day(g.endDate);
26560
+ return summed({
26561
+ kind: "program",
26562
+ id: g.id,
26563
+ code,
26564
+ level,
26565
+ title: g.name,
26566
+ ownerId: g.ownerId || null,
26567
+ start: day(g.startDate),
26568
+ end,
26569
+ runsPast: Boolean(end && latest && latest > end),
26570
+ health: g.health,
26571
+ finished: g.health === "done",
26572
+ children
26573
+ });
26574
+ }
26575
+ /** The latest end among a node's children, all the way down. */
26576
+ function latestUnder(n) {
26577
+ let out = null;
26578
+ for (const c of n.children) out = later(out, later(c.end, latestUnder(c)));
26579
+ return out;
26580
+ }
26581
+ /**
26582
+ * The breakdown of one portfolio, program or project, or null when it isn't
26583
+ * there. `today` is "YYYY-MM-DD", for what's late.
26584
+ */
26585
+ function buildBreakdown(doc, root, today) {
26586
+ if (root.kind === "project") {
26587
+ const p = doc.projects.find((x) => x.id === root.id);
26588
+ return p ? projectNode(p, "", 0, doc, today) : null;
26589
+ }
26590
+ if (root.kind === "program") {
26591
+ const g = doc.programs.find((x) => x.id === root.id);
26592
+ return g ? programNode(g, "", 0, doc, today) : null;
26593
+ }
26594
+ const f = doc.portfolios.find((x) => x.id === root.id);
26595
+ if (!f) return null;
26596
+ const children = orderPlans(doc.programs.filter((g) => g.portfolioId === f.id)).map((g, i) => programNode(g, `${i + 1}`, 1, doc, today));
26597
+ let start = null;
26598
+ let end = null;
26599
+ for (const c of children) {
26600
+ start = earlier(start, c.start);
26601
+ end = later(end, c.end);
26602
+ }
26603
+ return summed({
26604
+ kind: "portfolio",
26605
+ id: f.id,
26606
+ code: "",
26607
+ level: 0,
26608
+ title: f.name,
26609
+ ownerId: f.ownerId || null,
26610
+ start,
26611
+ end,
26612
+ runsPast: false,
26613
+ health: f.health,
26614
+ finished: f.health === "done",
26615
+ children
26616
+ });
26617
+ }
26618
+ /** Whole percent done; 0 with nothing to count. */
26619
+ const percentDone = (n) => n.total > 0 ? Math.round(n.done / n.total * 100) : 0;
26620
+
26280
26621
  // src/lib/mcp/tools.ts
26281
26622
  init_project_messages();
26282
26623
  init_daily_digest();
@@ -26998,6 +27339,60 @@ function chatAnswer(data, target, lines) {
26998
27339
  }))
26999
27340
  };
27000
27341
  }
27342
+ /** The portfolio, program or project a breakdown is asked of; a name that's two kinds asks which. */
27343
+ function breakdownTarget(data, of, kind) {
27344
+ const lists = {
27345
+ project: data.projects,
27346
+ program: data.programs,
27347
+ portfolio: data.portfolios
27348
+ };
27349
+ if (kind) return {
27350
+ kind,
27351
+ id: findOne(lists[kind], of, kind).id
27352
+ };
27353
+ const want = of.trim().toLowerCase();
27354
+ const exact = [
27355
+ "project",
27356
+ "program",
27357
+ "portfolio"
27358
+ ].flatMap((k) => lists[k].filter((i) => i.id === of.trim() || i.name.trim().toLowerCase() === want || i.key?.toLowerCase() === want).map((i) => ({
27359
+ kind: k,
27360
+ id: i.id
27361
+ })));
27362
+ const kinds = new Set(exact.map((e) => e.kind));
27363
+ if (kinds.size > 1) throw new ToolError(`"${of.trim()}" is a ${[...kinds].join(" and a ")}; say which with kind.`);
27364
+ if (exact.length) return {
27365
+ kind: exact[0].kind,
27366
+ id: findOne(lists[exact[0].kind], of, exact[0].kind).id
27367
+ };
27368
+ for (const k of [
27369
+ "project",
27370
+ "program",
27371
+ "portfolio"
27372
+ ]) try {
27373
+ return {
27374
+ kind: k,
27375
+ id: findOne(lists[k], of, k).id
27376
+ };
27377
+ } catch (e) {
27378
+ if (!(e instanceof ToolError) || !/^No /.test(e.message)) throw e;
27379
+ }
27380
+ throw new ToolError(`No portfolio, program or project called "${of.trim()}".`);
27381
+ }
27382
+ /** The lines under `root`, top to bottom, `depth` levels down; with `open`, nothing finished or under it. */
27383
+ function breakdownLines(root, depth, open) {
27384
+ const out = [];
27385
+ const walk = (n) => {
27386
+ for (const c of n.children) {
27387
+ if (open && c.finished) continue;
27388
+ if (depth && c.level - root.level > depth) continue;
27389
+ out.push(c);
27390
+ walk(c);
27391
+ }
27392
+ };
27393
+ walk(root);
27394
+ return out;
27395
+ }
27001
27396
  const HARBOR_TOOLS = [
27002
27397
  tool({
27003
27398
  name: "harbor_overview",
@@ -28934,6 +29329,58 @@ const HARBOR_TOOLS = [
28934
29329
  };
28935
29330
  }
28936
29331
  }),
29332
+ tool({
29333
+ name: "work_breakdown",
29334
+ title: "Work breakdown",
29335
+ description: "A portfolio, program or project as its work breakdown (the website's Breakdown view): one numbered line per program, project, task and subtask under it (1, 1.1, 1.1.2), each with its owner, dates, tasks done of all and how many are late, rolled up from under it. Numbers count from the thing asked for and include finished work, so they match the website's. `of` names it; `kind` settles a name that's both a project and a program. `depth` keeps to that many levels; `open` leaves finished work out." + DATA_NOTE,
29336
+ input: object({
29337
+ harbor: harborArg,
29338
+ of: string().min(1).max(200).describe("Portfolio, program or project: id, key or name."),
29339
+ kind: _enum([
29340
+ "portfolio",
29341
+ "program",
29342
+ "project"
29343
+ ]).optional(),
29344
+ depth: number().int().min(1).max(4).optional().describe("Levels to show, 1 being its children."),
29345
+ open: boolean().default(false).describe("Leave finished work out (numbers stay)."),
29346
+ limit: limitArg(1e3, 300),
29347
+ offset: offsetArg
29348
+ }),
29349
+ run: (ctx, input) => {
29350
+ const { data } = ctx;
29351
+ const root = breakdownTarget(data, input.of, input.kind);
29352
+ const tree = buildBreakdown(data, root, todayISO(ctx.now));
29353
+ const people = byId(data.people);
29354
+ const all = breakdownLines(tree, input.depth, input.open);
29355
+ return {
29356
+ of: {
29357
+ kind: tree.kind,
29358
+ name: tree.title
29359
+ },
29360
+ done: tree.done,
29361
+ tasks: tree.total,
29362
+ late: tree.late,
29363
+ lines: all.slice(input.offset, input.offset + input.limit).map((n) => ({
29364
+ wbs: n.code,
29365
+ level: n.level - tree.level,
29366
+ kind: n.kind,
29367
+ name: n.title,
29368
+ ...n.key && (n.kind === "task" || n.kind === "subtask") ? { key: n.key } : {},
29369
+ owner: nameOf$2(people, n.ownerId),
29370
+ start: n.start,
29371
+ end: n.end,
29372
+ ...n.status ? { status: n.status } : n.finished ? { status: "done" } : {},
29373
+ ...n.kind === "task" && n.children.length ? { subtasks: n.children.length } : {},
29374
+ done: n.done,
29375
+ tasks: n.total,
29376
+ percent: percentDone(n),
29377
+ ...n.late ? { late: n.late } : {},
29378
+ ...n.runsPast ? { runsPastEnd: true } : {}
29379
+ })),
29380
+ more: all.length > input.offset + input.limit
29381
+ };
29382
+ }
29383
+ }),
28937
29384
  tool({
28938
29385
  name: "what_if",
28939
29386
  title: "Try a what-if plan for a portfolio",
@@ -30074,6 +30521,19 @@ function hierarchySlice({ get, write }) {
30074
30521
  const program = get().programs.find((p) => p.id === programId);
30075
30522
  get().log(`moved ${ids.length} project${ids.length === 1 ? "" : "s"} to ${program?.name ?? "a program"}`, `/programs/${programId}`);
30076
30523
  },
30524
+ placeInBreakdown: async (move) => {
30525
+ const { applyMove, moveProblem } = await Promise.resolve().then(() => (init_wbs_move(), wbs_move_exports));
30526
+ const s = get();
30527
+ const problem = moveProblem(s, move);
30528
+ if (problem) return problem;
30529
+ const rows = applyMove(s, move, stamp());
30530
+ if (!rows) return null;
30531
+ write(rows);
30532
+ const name = move.kind === "task" ? s.tasks.find((t) => t.id === move.id)?.title : move.kind === "project" ? s.projects.find((p) => p.id === move.id)?.name : s.programs.find((p) => p.id === move.id)?.name;
30533
+ const where = move.kind === "task" ? move.into.kind === "task" ? `/projects/${s.tasks.find((t) => t.id === move.into.id)?.projectId ?? ""}` : `/projects/${move.into.id}` : move.kind === "project" ? `/programs/${move.into}` : `/portfolios/${move.into}`;
30534
+ get().log(`moved “${name ?? "an item"}” in the breakdown`, where);
30535
+ return null;
30536
+ },
30077
30537
  restoreRows: (rows, links) => {
30078
30538
  const state = get();
30079
30539
  const back = (current, add) => {
@@ -30170,6 +30630,24 @@ function hierarchySlice({ get, write }) {
30170
30630
  get().log("cleared the sample portfolio", "/portfolios");
30171
30631
  return true;
30172
30632
  },
30633
+ addSamplePortfolio: (withSample) => {
30634
+ const state = get();
30635
+ if (hasSample(state)) return false;
30636
+ const next = withSample(state, todayISO());
30637
+ write({
30638
+ people: next.people,
30639
+ portfolios: next.portfolios,
30640
+ programs: next.programs,
30641
+ projects: next.projects,
30642
+ milestones: next.milestones,
30643
+ tasks: next.tasks,
30644
+ raidItems: next.raidItems,
30645
+ comments: next.comments,
30646
+ boardConfigs: next.boardConfigs
30647
+ });
30648
+ get().log("added the sample portfolio", `/portfolios/${SAMPLE_PORTFOLIO_ID}`);
30649
+ return true;
30650
+ },
30173
30651
  setBoardConfig: (projectId, config) => {
30174
30652
  write({ boardConfigs: {
30175
30653
  ...get().boardConfigs ?? {},
package/lib/cli.mjs CHANGED
@@ -76,6 +76,7 @@ import {
76
76
  convoysText,
77
77
  convoyText,
78
78
  saltsText,
79
+ wbsText,
79
80
  heedSaltText,
80
81
  rankText,
81
82
  setRankText,
@@ -384,6 +385,9 @@ export const HELP = `harbor: Harbor from the terminal
384
385
  harbor salts PROJECT [--risk N|--task N|--put-away N]
385
386
  old salts: what finished projects
386
387
  like it ran into
388
+ harbor wbs PROJECT|PROGRAM|PORTFOLIO [--depth N] [--open]
389
+ the work breakdown: all the work
390
+ under it, numbered 1, 1.1, 1.1.2
387
391
  harbor rank PORTFOLIO [--order "A, B, C"|--clear]
388
392
  which ship docks first: the
389
393
  order a portfolio's projects
@@ -1529,6 +1533,17 @@ const DETAIL = {
1529
1533
  " CONVOY is its words (a part is enough when only one matches) or its id from",
1530
1534
  " harbor convoys --json. harbor convoys lists them.",
1531
1535
  ],
1536
+ wbs: [
1537
+ " harbor wbs NAME reads the work breakdown of a project,",
1538
+ " program or portfolio: one numbered line",
1539
+ " each (1, 1.1, 1.1.2) with its owner,",
1540
+ " dates and how much is done, as the",
1541
+ " website's Breakdown view numbers them",
1542
+ " harbor wbs NAME --depth N only N levels down (1: its children)",
1543
+ " harbor wbs NAME --open leaves finished work out (the numbers",
1544
+ " stay as they were)",
1545
+ " harbor wbs NAME --kind program when a project and a program share it",
1546
+ ],
1532
1547
  salts: [
1533
1548
  " harbor salts PROJECT reads what finished projects like it",
1534
1549
  " ran into: risks that came true,",
@@ -1987,6 +2002,8 @@ const OTHER_NAMES = {
1987
2002
  ranking: "harbor rank PORTFOLIO says which ship docks first.",
1988
2003
  salt: "harbor salts PROJECT lists its old salts.",
1989
2004
  "old-salts": "harbor salts PROJECT lists its old salts.",
2005
+ breakdown: "harbor wbs NAME shows a project, program or portfolio as its work breakdown.",
2006
+ tree: "harbor wbs NAME shows a project, program or portfolio as its work breakdown.",
1990
2007
  night:
1991
2008
  "Harbor at night is the portfolio chart room's evening scene for a wall screen, a picture to look at; harbor programs and harbor reports read the same projects.",
1992
2009
  };
@@ -4994,6 +5011,32 @@ export async function run(argv, io = {}) {
4994
5011
  convoyText,
4995
5012
  );
4996
5013
  }
5014
+ case "wbs": {
5015
+ const { positionals, values, harbor } = parse(spec(["open"], ["depth", "kind", "offset"]));
5016
+ const of = text(positionals, "which project, program or portfolio");
5017
+ const depth = values.depth === undefined ? undefined : Number(values.depth);
5018
+ if (depth !== undefined && !(Number.isInteger(depth) && depth >= 1 && depth <= 4))
5019
+ throw new HarborError("--depth takes 1 to 4: how many levels under it to show.");
5020
+ const kind = values.kind?.trim().toLowerCase();
5021
+ if (kind !== undefined && !["project", "program", "portfolio"].includes(kind))
5022
+ throw new HarborError("--kind takes project, program or portfolio.");
5023
+ const offset = values.offset === undefined ? 0 : Number(values.offset);
5024
+ if (!(Number.isInteger(offset) && offset >= 0))
5025
+ throw new HarborError("--offset takes a whole number of lines to skip.");
5026
+ return call(
5027
+ "work_breakdown",
5028
+ {
5029
+ harbor,
5030
+ of,
5031
+ ...(kind ? { kind } : {}),
5032
+ ...(depth ? { depth } : {}),
5033
+ ...(values.open ? { open: true } : {}),
5034
+ ...(offset ? { offset } : {}),
5035
+ limit: 1000,
5036
+ },
5037
+ wbsText,
5038
+ );
5039
+ }
4997
5040
  case "salts": {
4998
5041
  const { positionals, values, harbor } = parse(spec([], ["risk", "task", "put-away"]));
4999
5042
  const project = text(positionals, "which project");
package/lib/format.mjs CHANGED
@@ -1797,6 +1797,38 @@ export function saltsText(r) {
1797
1797
  return lines.join("\n");
1798
1798
  }
1799
1799
 
1800
+ /**
1801
+ * harbor wbs: the work breakdown, one numbered line per program, project,
1802
+ * task and subtask, indented by level, with owner, dates and progress.
1803
+ */
1804
+ export function wbsText(r) {
1805
+ const head = `${r.of.name}: work breakdown · ${r.done} of ${r.tasks} task${r.tasks === 1 ? "" : "s"} done${r.late ? ` · ${r.late} late` : ""}`;
1806
+ if (!r.lines.length) return `${head}\n\nNothing under it yet.`;
1807
+ const width = Math.max(...r.lines.map((l) => l.wbs.length + (l.level - 1) * 2));
1808
+ const out = [head, ""];
1809
+ for (const l of r.lines) {
1810
+ const lead = `${" ".repeat(l.level - 1)}${l.wbs}`.padEnd(width);
1811
+ const dates =
1812
+ l.start && l.end && l.start !== l.end
1813
+ ? `${l.start} to ${l.end}`
1814
+ : l.end && !l.subtasks
1815
+ ? `due ${l.end}`
1816
+ : l.end || (l.start ? `from ${l.start}` : null);
1817
+ const bits = [
1818
+ l.kind === "task" || l.kind === "subtask"
1819
+ ? `${STATUS[l.status] ?? l.status}${l.subtasks ? `, ${l.done}/${l.subtasks} subtasks done` : ""}`
1820
+ : `${l.percent}% (${l.done}/${l.tasks})`,
1821
+ l.owner || null,
1822
+ dates,
1823
+ l.late ? `${l.late} late` : null,
1824
+ l.runsPastEnd ? "runs past its end" : null,
1825
+ ].filter(Boolean);
1826
+ out.push(` ${lead} ${l.name}${l.key ? ` ${l.key}` : ""} (${bits.join(" · ")})`);
1827
+ }
1828
+ if (r.more) out.push("", "More lines: --offset to page, or --depth to stay higher up.");
1829
+ return out.join("\n");
1830
+ }
1831
+
1800
1832
  /** What harbor salts --risk, --task or --put-away did. */
1801
1833
  export function heedSaltText(r) {
1802
1834
  if (r.putAway)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harborppm/cli",
3
- "version": "0.118.0",
3
+ "version": "0.119.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",