@harborppm/cli 0.110.0 → 0.111.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
@@ -253,6 +253,11 @@ harbor watch --once [--since TIME] [--json] the latest changes (or all since TIM
253
253
  harbor lifeboats [--program P] work only one person knows, each with a second pair of hands
254
254
  harbor lifeboats N [--person NAME] adds that second pair of hands
255
255
  harbor follow TASK|"RISK" --person NAME someone follows it too
256
+ harbor convoys [PROGRAM] promises between programs, and how each stands
257
+ harbor convoy ask PROGRAM --to OTHER --by DATE "WHAT"
258
+ harbor convoy accept|decline|deliver|undeliver|move|withdraw CONVOY [--project P] [--note WHY] [--by DATE]
259
+ harbor salts PROJECT [--risk N|--task N|--put-away N] what finished projects like it ran into
260
+ harbor rank PORTFOLIO [--order "A, B, C"|--clear] which ship docks first
256
261
  harbor agent [--agent NAME]
257
262
  harbor agent report TASK "WHAT YOU DID" [--start] [--agent NAME]
258
263
  ```
@@ -263,6 +268,10 @@ harbor agent report TASK "WHAT YOU DID" [--start] [--agent NAME]
263
268
 
264
269
  `harbor watch` turns a narrow split or a tmux pane into a live ticker of your harbor: cards moving, comments, health changes, a line each as they happen, over the same live updates the website uses. Lines about your own work (your tasks, mentions of you, what you lead) are bright and the rest dim; `--bell` rings the terminal's bell when something of yours changes, and `--project` keeps to one project. It starts with the latest few changes and the time it began listening; `--since 14:30` (or a date) starts from then instead, on this computer's clock (`14:30Z` or `14:30 UTC` for UTC); the header names the time zone the ticker's times are in, and Harbor says "Nothing since 14:30 BST." when nothing has. A change the GitHub link made reads "Finished RR-4 … via GitHub", as History does. `q` stops; piped or with `--json` (one JSON object a line) it runs until it's killed, and `--once` prints what's there and returns, for scripts. Harbor keeps the latest 40 changes, so a `--since` further back says where its list starts.
265
270
 
271
+ `harbor convoys` lists the promises between programs: one program's ask of another for a thing by a day, and how it stands (waiting for an answer, in time, late on the delivering project's forecast, declined, delivered); `harbor convoys Footwear` splits one program's into what it waits on and what others wait on it for. `harbor convoy ask "Member App" --to Footwear --by 2026-12-15 "Shoe photos"` asks; the asked side answers with `harbor convoy accept "shoe photos" --project "Ridge Runner"`, `decline … --note WHY` or `deliver`, and the asking side can `move … --by DATE` or `withdraw`. A convoy is named by its words; when they fit two, Harbor lists both.
272
+
273
+ `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
+
266
275
  `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.
267
276
 
268
277
  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 for a person to check. An agent never marks its own work Done.
package/dist/app.mjs CHANGED
@@ -18081,7 +18081,239 @@ function shareOf(e, reading, by = "effort") {
18081
18081
  return (by === "spend" ? e.spent : amountOf(e, reading.measure)) / whole;
18082
18082
  }
18083
18083
 
18084
+ // src/lib/old-salts.ts
18085
+ init_date_fns();
18086
+ init_date_text();
18087
+ init_first_voyage();
18088
+ init_indexes();
18089
+ init_premortem();
18090
+ /** A slip shorter than this isn't a lesson, just a busy week. */
18091
+ const SLIP_DAYS = 7;
18092
+ /** Lessons one project offers, and the most a card shows at once. */
18093
+ const PER_PROJECT = 4;
18094
+ const SHOWN = 3;
18095
+ /** Finished projects a card draws on. */
18096
+ const SOURCES = 2;
18097
+ const days$3 = (from, to) => differenceInCalendarDays(parseIso(localDay(to)), parseIso(from.slice(0, 10)));
18098
+ const clip = (s, n) => {
18099
+ const flat = s.replace(/\s+/g, " ").trim();
18100
+ return flat.length <= n ? flat : `${flat.slice(0, n - 1).replace(/\s+\S*$/, "")}…`;
18101
+ };
18102
+ const lower = (s) => /^[A-Z][a-z]/.test(s) ? s[0].toLowerCase() + s.slice(1) : s;
18103
+ function slipText(task, late) {
18104
+ const weeks = Math.round(late / 7);
18105
+ const when = late >= 14 ? `${weeks} weeks` : `${late} days`;
18106
+ return `“${clip(task.title, 80)}” finished ${when} late`;
18107
+ }
18108
+ /** The lessons one finished project offers, the crew's own words first. */
18109
+ 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")) {
18110
+ const from = {
18111
+ id: project.id,
18112
+ name: project.name
18113
+ };
18114
+ const out = [];
18115
+ for (const l of [...lines].sort((a, b) => a.createdAt.localeCompare(b.createdAt))) {
18116
+ if (!l.body.trim()) continue;
18117
+ out.push({
18118
+ id: `line:${l.id}`,
18119
+ kind: "line",
18120
+ from,
18121
+ text: clip(l.body, 200),
18122
+ helped: null,
18123
+ title: riskTitle(l.body)
18124
+ });
18125
+ }
18126
+ for (const r of raid) if (r.kind === "risk" && r.happened === true) out.push({
18127
+ id: `risk:${r.id}`,
18128
+ kind: "came-true",
18129
+ from,
18130
+ text: `${lower(clip(r.title, 120))} (a risk that came true)`,
18131
+ helped: r.contingency?.trim() || r.mitigation?.trim() || null,
18132
+ title: clip(r.title, 120)
18133
+ });
18134
+ else if (r.kind === "issue") out.push({
18135
+ id: `issue:${r.id}`,
18136
+ kind: "issue",
18137
+ from,
18138
+ text: lower(clip(r.title, 120)),
18139
+ helped: r.resolution?.trim() || null,
18140
+ title: clip(r.title, 120)
18141
+ });
18142
+ const slips = tasksOf(data.tasks, project.id).filter((t) => t.status === "done" && t.dueDate && t.completedAt && !t.parentTaskId).map((t) => ({
18143
+ t,
18144
+ late: days$3(t.dueDate, t.completedAt)
18145
+ })).filter((s) => s.late >= 7).sort((a, b) => b.late - a.late).slice(0, 2);
18146
+ for (const { t, late } of slips) out.push({
18147
+ id: `slip:${t.id}`,
18148
+ kind: "slip",
18149
+ from,
18150
+ text: slipText(t, late),
18151
+ helped: null,
18152
+ title: `Leave room for ${lower(clip(t.title, 100))}`
18153
+ });
18154
+ return out.slice(0, 4);
18155
+ }
18156
+ /**
18157
+ * The finished projects this one sounds like, best first: shared meaningful
18158
+ * words of name and description, with the same program counting as one
18159
+ * more (so a program's finished projects count even with no words shared).
18160
+ * Most recently finished first on a tie.
18161
+ */
18162
+ function kindredProjects(data, project) {
18163
+ const want = contentWords(`${project.name} ${project.description}`);
18164
+ const scored = [];
18165
+ for (const p of data.projects) {
18166
+ if (p.id === project.id || p.health !== "done" || isVoyageProject(p.id)) continue;
18167
+ const theirs = contentWords(`${p.name} ${p.description}`);
18168
+ let score = 0;
18169
+ for (const w of want) if (theirs.has(w)) score += 1;
18170
+ if (p.programId === project.programId) score += 1;
18171
+ if (score === 0) continue;
18172
+ const done = [...p.healthHistory ?? []].reverse().find((h) => h.health === "done")?.at;
18173
+ scored.push({
18174
+ p,
18175
+ score,
18176
+ at: done ?? p.endDate
18177
+ });
18178
+ }
18179
+ return scored.sort((a, b) => b.score - a.score || b.at.localeCompare(a.at)).map((s) => s.p);
18180
+ }
18181
+ /**
18182
+ * What the old salts say to this project: lessons from the finished projects
18183
+ * it looks like, leaving out any put away (or already taken) here. Nothing
18184
+ * for a finished project.
18185
+ */
18186
+ function oldSalts(data, project) {
18187
+ if (project.health === "done" || isVoyageProject(project.id)) return [];
18188
+ const heard = new Set(project.saltsHeard ?? []);
18189
+ const out = [];
18190
+ let sources = 0;
18191
+ for (const p of kindredProjects(data, project).slice(0, 10)) {
18192
+ const fresh = lessonsOf(p, data).filter((l) => !heard.has(l.id));
18193
+ if (fresh.length === 0) continue;
18194
+ out.push(...fresh);
18195
+ if (++sources >= SOURCES) break;
18196
+ }
18197
+ return out.slice(0, 3);
18198
+ }
18199
+
18084
18200
  // src/lib/dock-order.ts
18201
+ /** The same key for a pair whichever way round it comes. */
18202
+ const pairKey = (a, b) => a < b ? `${a}|${b}` : `${b}|${a}`;
18203
+ /** Every vote that counts: answers about projects still in the ranking, each person's latest per pair. */
18204
+ function countedVotes(votes, projectIds) {
18205
+ const live = new Set(projectIds);
18206
+ const latest = /* @__PURE__ */ new Map();
18207
+ for (const v of votes) {
18208
+ if (v.a === v.b || !live.has(v.a) || !live.has(v.b)) continue;
18209
+ if (v.winner !== null && v.winner !== v.a && v.winner !== v.b) continue;
18210
+ const key = `${v.voter}\u0000${pairKey(v.a, v.b)}`;
18211
+ const was = latest.get(key);
18212
+ if (!was || was.at <= v.at) latest.set(key, v);
18213
+ }
18214
+ return [...latest.values()];
18215
+ }
18216
+ /** Bradley-Terry strengths, normalised to average 1. */
18217
+ function strengths(projectIds, votes) {
18218
+ const ids = [...projectIds];
18219
+ const wins = new Map(ids.map((id) => [id, .5]));
18220
+ const games = /* @__PURE__ */ new Map();
18221
+ for (const v of votes) {
18222
+ games.set(pairKey(v.a, v.b), (games.get(pairKey(v.a, v.b)) ?? 0) + 1);
18223
+ if (v.winner === null) {
18224
+ wins.set(v.a, wins.get(v.a) + .5);
18225
+ wins.set(v.b, wins.get(v.b) + .5);
18226
+ } else wins.set(v.winner, wins.get(v.winner) + 1);
18227
+ }
18228
+ let p = new Map(ids.map((id) => [id, 1]));
18229
+ for (let round = 0; round < 200; round++) {
18230
+ const next = /* @__PURE__ */ new Map();
18231
+ let change = 0;
18232
+ for (const i of ids) {
18233
+ let denom = 1 / (p.get(i) + 1);
18234
+ for (const j of ids) {
18235
+ if (i === j) continue;
18236
+ const n = games.get(pairKey(i, j));
18237
+ if (n) denom += n / (p.get(i) + p.get(j));
18238
+ }
18239
+ next.set(i, wins.get(i) / denom);
18240
+ }
18241
+ const mean = ids.reduce((s, id) => s + next.get(id), 0) / Math.max(1, ids.length);
18242
+ for (const id of ids) {
18243
+ const v = next.get(id) / mean;
18244
+ change = Math.max(change, Math.abs(v - p.get(id)));
18245
+ next.set(id, v);
18246
+ }
18247
+ p = next;
18248
+ if (change < 1e-9) break;
18249
+ }
18250
+ return p;
18251
+ }
18252
+ const AGREEMENT_LABEL = {
18253
+ clear: "Clear",
18254
+ leaning: "Leaning",
18255
+ "coin-toss": "Coin toss"
18256
+ };
18257
+ function agreementOf(sure) {
18258
+ return sure >= .8 ? "clear" : sure >= .65 ? "leaning" : "coin-toss";
18259
+ }
18260
+ /**
18261
+ * The order, strongest first (ties broken by name order of the ids given, so
18262
+ * it's stable), and for each place how sure people are it sits above the
18263
+ * next: the share of direct answers between the two when there are at least
18264
+ * two, otherwise what the strengths say.
18265
+ */
18266
+ function dockOrder(projectIds, votes) {
18267
+ const counted = countedVotes(votes, projectIds);
18268
+ const p = strengths(projectIds, counted);
18269
+ const index = new Map(projectIds.map((id, i) => [id, i]));
18270
+ const sorted = [...projectIds].sort((a, b) => p.get(b) - p.get(a) || index.get(a) - index.get(b));
18271
+ const answers = /* @__PURE__ */ new Map();
18272
+ const direct = /* @__PURE__ */ new Map();
18273
+ for (const v of counted) {
18274
+ answers.set(v.a, (answers.get(v.a) ?? 0) + 1);
18275
+ answers.set(v.b, (answers.get(v.b) ?? 0) + 1);
18276
+ const key = pairKey(v.a, v.b);
18277
+ const d = direct.get(key) ?? {
18278
+ games: 0,
18279
+ firstWins: 0
18280
+ };
18281
+ d.games++;
18282
+ const first = v.a < v.b ? v.a : v.b;
18283
+ d.firstWins += v.winner === null ? .5 : v.winner === first ? 1 : 0;
18284
+ direct.set(key, d);
18285
+ }
18286
+ return {
18287
+ places: sorted.map((id, i) => {
18288
+ const below = sorted[i + 1];
18289
+ let overNext = null;
18290
+ if (below) {
18291
+ const d = direct.get(pairKey(id, below));
18292
+ if (d && d.games >= 2) overNext = (id < below ? d.firstWins : d.games - d.firstWins) / d.games;
18293
+ else overNext = p.get(id) / (p.get(id) + p.get(below));
18294
+ }
18295
+ return {
18296
+ projectId: id,
18297
+ place: i + 1,
18298
+ strength: p.get(id),
18299
+ overNext,
18300
+ agreement: overNext === null ? null : agreementOf(overNext),
18301
+ answers: answers.get(id) ?? 0
18302
+ };
18303
+ }),
18304
+ voters: new Set(counted.map((v) => v.voter)).size,
18305
+ answers: counted.length
18306
+ };
18307
+ }
18308
+ /** "1st", "2nd", "3rd", "4th", "11th", "21st". */
18309
+ function ordinal(n) {
18310
+ return `${n}${n % 100 >= 11 && n % 100 <= 13 ? "th" : [
18311
+ "th",
18312
+ "st",
18313
+ "nd",
18314
+ "rd"
18315
+ ][n % 10] ?? "th"}`;
18316
+ }
18085
18317
  /** An order once it's put on the portfolio: only projects still there, and still open, each once. */
18086
18318
  function liveOrder(order, projects) {
18087
18319
  const open = new Set(projects.filter((p) => p.health !== "done").map((p) => p.id));
@@ -26571,6 +26803,81 @@ const HARBOR_TOOLS = [
26571
26803
  };
26572
26804
  }
26573
26805
  }),
26806
+ tool({
26807
+ name: "old_salts",
26808
+ title: "Old salts",
26809
+ 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,
26810
+ input: object({
26811
+ harbor: harborArg,
26812
+ project: string().min(1).max(200).describe("Project id, key or name.")
26813
+ }),
26814
+ run: (ctx, input) => {
26815
+ const project = findOne(ctx.data.projects, input.project, "project");
26816
+ const lessons = oldSalts(ctx.data, project);
26817
+ return {
26818
+ project: project.name,
26819
+ ...project.health === "done" ? { note: `${project.name} is finished; old salts are for the projects still sailing.` } : {},
26820
+ lessons: lessons.map((l, i) => ({
26821
+ n: i + 1,
26822
+ id: l.id,
26823
+ kind: l.kind,
26824
+ from: l.from.name,
26825
+ text: `Last time, on ${l.from.name}: ${l.text}.`,
26826
+ ...l.helped ? { helped: l.helped } : {},
26827
+ title: l.title
26828
+ }))
26829
+ };
26830
+ }
26831
+ }),
26832
+ tool({
26833
+ name: "dock_order",
26834
+ title: "Which ship docks first",
26835
+ 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,
26836
+ input: object({
26837
+ harbor: harborArg,
26838
+ portfolio: string().min(1).max(200).describe("Portfolio id or name.")
26839
+ }),
26840
+ run: (ctx, input) => {
26841
+ const { data } = ctx;
26842
+ const portfolio = findOne(data.portfolios, input.portfolio, "portfolio");
26843
+ const programs = new Set(data.programs.filter((p) => p.portfolioId === portfolio.id).map((p) => p.id));
26844
+ const inIt = data.projects.filter((p) => programs.has(p.programId));
26845
+ const names = byId(data.projects);
26846
+ const name = (id) => names.get(id)?.name ?? null;
26847
+ const kept = portfolio.dockOrder;
26848
+ const order = kept ? liveOrder(kept.projectIds, inIt) : [];
26849
+ const open = inIt.filter((p) => p.health !== "done");
26850
+ const link = ctx.dockLink ?? null;
26851
+ const live = link ? link.projectIds.filter((id) => open.some((p) => p.id === id)) : [];
26852
+ const standing = link && live.length >= 2 ? dockOrder(live, link.votes) : null;
26853
+ return {
26854
+ portfolio: portfolio.name,
26855
+ openProjects: open.length,
26856
+ kept: kept ? {
26857
+ order: order.map((id, i) => ({
26858
+ place: ordinal(i + 1),
26859
+ project: name(id)
26860
+ })),
26861
+ at: kept.at,
26862
+ by: data.people.find((p) => p.id === kept.byId)?.name ?? null,
26863
+ voters: kept.voters,
26864
+ notRanked: open.filter((p) => !order.includes(p.id)).map((p) => p.name)
26865
+ } : null,
26866
+ ...link ? { link: {
26867
+ ...ctx.origin ? { url: `${ctx.origin}/dock/${link.token}` } : {},
26868
+ open: !link.closedAt,
26869
+ made: link.createdAt,
26870
+ voters: standing?.voters ?? 0,
26871
+ answers: standing?.answers ?? 0,
26872
+ standing: (standing?.places ?? []).map((p) => ({
26873
+ place: ordinal(p.place),
26874
+ project: name(p.projectId),
26875
+ ...p.agreement ? { overNext: AGREEMENT_LABEL[p.agreement].toLowerCase() } : {}
26876
+ }))
26877
+ } } : {}
26878
+ };
26879
+ }
26880
+ }),
26574
26881
  tool({
26575
26882
  name: "list_dashboards",
26576
26883
  title: "Dashboards",
package/lib/cli.mjs CHANGED
@@ -72,6 +72,12 @@ import {
72
72
  fogText,
73
73
  scuttleText,
74
74
  scuttleCallText,
75
+ convoysText,
76
+ convoyText,
77
+ saltsText,
78
+ heedSaltText,
79
+ rankText,
80
+ setRankText,
75
81
  agentWorkText,
76
82
  raidDetail,
77
83
  raidList,
@@ -364,6 +370,21 @@ export const HELP = `harbor: Harbor from the terminal
364
370
  months out of the line-up
365
371
  harbor scuttle PROJECT --why "TEXT" stop it on purpose: Done, on the
366
372
  register, its tasks set free
373
+ harbor convoys [PROGRAM] promises between programs: what
374
+ each waits on, and who waits on it
375
+ harbor convoy ask PROGRAM --to OTHER --by DATE "WHAT"
376
+ one program asks another for
377
+ a thing by a day
378
+ harbor convoy accept|decline|deliver|undeliver|move|withdraw CONVOY
379
+ answer one, or move or take back
380
+ your ask
381
+ harbor salts PROJECT [--risk N|--task N|--put-away N]
382
+ old salts: what finished projects
383
+ like it ran into
384
+ harbor rank PORTFOLIO [--order "A, B, C"|--clear]
385
+ which ship docks first: the
386
+ order a portfolio's projects
387
+ matter in
367
388
  harbor watch [--project P] [--bell] a live ticker of the harbor's
368
389
  changes; yours bright, q stops
369
390
  harbor watch --once [--since TIME] [--json] the latest changes (or all since
@@ -1452,6 +1473,54 @@ const DETAIL = {
1452
1473
  " Nothing is deleted: harbor health auto --project P raises a scuttled project",
1453
1474
  " again and gives its tasks back.",
1454
1475
  ],
1476
+ convoys: [
1477
+ " harbor convoys reads every convoy: one program's ask",
1478
+ " of another, by a day, and how it",
1479
+ " stands (waiting for an answer, in",
1480
+ " time, late on the forecast, declined,",
1481
+ " delivered)",
1482
+ " harbor convoys PROGRAM reads what it waits on, and what",
1483
+ " others wait on it for",
1484
+ "",
1485
+ " harbor convoy ask PROGRAM … and its answers write them (harbor help convoy).",
1486
+ ],
1487
+ convoy: [
1488
+ " harbor convoy ask PROGRAM --to OTHER --by DATE \"WHAT\"",
1489
+ " writes: PROGRAM asks OTHER for WHAT",
1490
+ " harbor convoy accept CONVOY [--project P]",
1491
+ " writes: the asked program takes it on,",
1492
+ " P (one of its projects) delivering it",
1493
+ ' harbor convoy decline CONVOY [--note "WHY"]',
1494
+ " writes: it can't, and why",
1495
+ " harbor convoy deliver CONVOY writes: delivered (undeliver takes it",
1496
+ " back)",
1497
+ " harbor convoy move CONVOY --by DATE writes: the asking side moves the day",
1498
+ " harbor convoy withdraw CONVOY writes: the asking side takes it back",
1499
+ "",
1500
+ " CONVOY is its words (a part is enough when only one matches) or its id from",
1501
+ " harbor convoys --json. harbor convoys lists them.",
1502
+ ],
1503
+ salts: [
1504
+ " harbor salts PROJECT reads what finished projects like it",
1505
+ " ran into: risks that came true,",
1506
+ " issues, voyage log lines, tasks that",
1507
+ " ended long late (up to three)",
1508
+ " harbor salts PROJECT --risk N writes: lesson N as an open risk",
1509
+ " harbor salts PROJECT --task N writes: lesson N as a task in To do",
1510
+ " harbor salts PROJECT --put-away N writes: stop showing lesson N",
1511
+ ],
1512
+ rank: [
1513
+ " harbor rank PORTFOLIO reads which ship docks first: the",
1514
+ " order kept on the portfolio, and how",
1515
+ " its newest ranking link stands",
1516
+ ' harbor rank PORTFOLIO --order "A, B, C"',
1517
+ " writes: its open projects in order,",
1518
+ " first to dock first (commas between)",
1519
+ " harbor rank PORTFOLIO --clear writes: takes the order off",
1520
+ "",
1521
+ " The ranking link the crew answers in pairs is made by the harbor's owner on",
1522
+ " the portfolio page.",
1523
+ ],
1455
1524
  watch: [
1456
1525
  " harbor watch reads, live: each change to the harbor",
1457
1526
  " as it lands, one line with its time",
@@ -1844,8 +1913,12 @@ const OTHER_NAMES = {
1844
1913
  dashboards: "harbor reports lists the Reports page's dashboards, each chart as its numbers.",
1845
1914
  report: "harbor report PROGRAM is a program's status report; harbor reports lists the dashboards.",
1846
1915
  decide: 'harbor decision "TITLE" --project P logs a decision.',
1847
- dock: "harbor try PROJECT is the dry dock.",
1916
+ dock: "harbor try PROJECT is the dry dock; harbor rank PORTFOLIO says which ship docks first.",
1848
1917
  "dry-dock": "harbor try PROJECT is the dry dock.",
1918
+ ranking: "harbor rank PORTFOLIO says which ship docks first.",
1919
+ salt: "harbor salts PROJECT lists its old salts.",
1920
+ "old-salts": "harbor salts PROJECT lists its old salts.",
1921
+ night: "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.",
1849
1922
  };
1850
1923
 
1851
1924
  /** A mistyped command, with the one it was probably meant to be. */
@@ -4647,6 +4720,87 @@ export async function run(argv, io = {}) {
4647
4720
  scuttleText,
4648
4721
  );
4649
4722
  }
4723
+ case "convoys": {
4724
+ const { positionals, harbor } = parse(spec());
4725
+ const program = positionals.join(" ").trim();
4726
+ return call("list_convoys", { harbor, ...(program ? { program } : {}) }, convoysText);
4727
+ }
4728
+ case "convoy": {
4729
+ const { positionals, values, harbor } = parse(spec([], ["to", "by", "project", "note"]));
4730
+ const [act, ...words] = positionals;
4731
+ const ACTS = ["ask", "accept", "decline", "deliver", "undeliver", "move", "withdraw"];
4732
+ if (act === undefined) {
4733
+ return call("list_convoys", { harbor }, convoysText);
4734
+ }
4735
+ if (!ACTS.includes(act))
4736
+ throw new HarborError(
4737
+ `harbor convoy ${act}? Say ask, accept, decline, deliver, undeliver, move or withdraw; harbor convoys lists them.`,
4738
+ );
4739
+ const only = (allowed) => {
4740
+ const extra = ["to", "by", "project", "note"].filter(
4741
+ (k) => values[k] !== undefined && !allowed.includes(k),
4742
+ );
4743
+ if (extra.length)
4744
+ throw new HarborError(`--${extra[0]} doesn't go with harbor convoy ${act}.`);
4745
+ };
4746
+ if (act === "ask") {
4747
+ only(["to", "by"]);
4748
+ const [program, ...what] = words;
4749
+ if (!program || !what.length || values.to === undefined || values.by === undefined)
4750
+ throw new HarborError('An ask: harbor convoy ask PROGRAM --to OTHER --by DATE "WHAT".');
4751
+ return call(
4752
+ "convoy",
4753
+ { harbor, act, program, to: values.to, what: what.join(" "), by: dueDate(values.by) },
4754
+ convoyText,
4755
+ );
4756
+ }
4757
+ const convoy = text(words, "which convoy (its words or id)");
4758
+ only({ accept: ["project"], decline: ["note"], move: ["by"] }[act] ?? []);
4759
+ if (act === "move" && values.by === undefined)
4760
+ throw new HarborError("Moving it needs the new day: harbor convoy move CONVOY --by DATE.");
4761
+ return call(
4762
+ "convoy",
4763
+ {
4764
+ harbor,
4765
+ act,
4766
+ convoy,
4767
+ ...(values.project !== undefined ? { project: values.project } : {}),
4768
+ ...(values.note !== undefined ? { note: values.note } : {}),
4769
+ ...(values.by !== undefined ? { by: dueDate(values.by) } : {}),
4770
+ },
4771
+ convoyText,
4772
+ );
4773
+ }
4774
+ case "salts": {
4775
+ const { positionals, values, harbor } = parse(spec([], ["risk", "task", "put-away"]));
4776
+ const project = text(positionals, "which project");
4777
+ const acts = ["risk", "task", "put-away"].filter((k) => values[k] !== undefined);
4778
+ if (acts.length > 1)
4779
+ throw new HarborError("One at a time: --risk N, --task N or --put-away N.");
4780
+ if (!acts.length) return call("old_salts", { harbor, project }, saltsText);
4781
+ const as = acts[0];
4782
+ const lesson = String(values[as]).trim();
4783
+ if (!/^[1-9]\d*$/.test(lesson))
4784
+ throw new HarborError(`--${as} takes the lesson's number from harbor salts "${project}".`);
4785
+ return call("heed_old_salt", { harbor, project, lesson, as }, heedSaltText);
4786
+ }
4787
+ case "rank": {
4788
+ const { positionals, values, harbor } = parse(spec(["clear"], ["order"]));
4789
+ const portfolio = text(positionals, "which portfolio");
4790
+ if (values.clear && values.order !== undefined)
4791
+ throw new HarborError("--order or --clear, not both.");
4792
+ if (values.clear) return call("set_dock_order", { harbor, portfolio, clear: true }, setRankText);
4793
+ if (values.order !== undefined) {
4794
+ const projects = values.order
4795
+ .split(",")
4796
+ .map((p) => p.trim())
4797
+ .filter(Boolean);
4798
+ if (projects.length < 2)
4799
+ throw new HarborError('Name at least two projects, commas between: --order "A, B".');
4800
+ return call("set_dock_order", { harbor, portfolio, projects }, setRankText);
4801
+ }
4802
+ return call("dock_order", { harbor, portfolio }, rankText);
4803
+ }
4650
4804
  case "bridge": {
4651
4805
  const { positionals, values, harbor } = parse(spec(["list"], ["program"]));
4652
4806
  none(positionals);
package/lib/format.mjs CHANGED
@@ -1622,3 +1622,110 @@ export function chatsText(r) {
1622
1622
  }
1623
1623
  return out.join("\n");
1624
1624
  }
1625
+ const convoyLine = (c, side) =>
1626
+ side === "giver"
1627
+ ? ` ${c.from} asks for “${c.what}” by ${c.by.slice(0, 10)} · ${c.text}`
1628
+ : ` “${c.what}” from ${c.to ?? "a deleted program"} by ${c.by.slice(0, 10)} · ${c.text}`;
1629
+
1630
+ /** harbor convoys: promises between programs, every one or one program's both ways. */
1631
+ export function convoysText(r) {
1632
+ if (!r.program) {
1633
+ if (!r.convoys.length)
1634
+ return 'No convoys yet. One program asks another with harbor convoy ask PROGRAM --to OTHER "WHAT" --by DATE.';
1635
+ const lines = [`${r.convoys.length} ${r.convoys.length === 1 ? "convoy" : "convoys"}:`, ""];
1636
+ for (const c of r.convoys)
1637
+ lines.push(` ${c.from} asks ${c.to ?? "a deleted program"} for “${c.what}” by ${c.by.slice(0, 10)}`, ` ${c.text}`);
1638
+ return lines.join("\n");
1639
+ }
1640
+ if (!r.waitingOn.length && !r.waitedOnBy.length)
1641
+ return `${r.program} has no convoys: it isn't waiting on another program, and none waits on it.`;
1642
+ const lines = [];
1643
+ if (r.waitingOn.length) {
1644
+ lines.push(`${r.program} waits on`);
1645
+ for (const c of r.waitingOn) lines.push(convoyLine(c, "asker"));
1646
+ }
1647
+ if (r.waitedOnBy.length) {
1648
+ if (lines.length) lines.push("");
1649
+ lines.push(`Others wait on ${r.program}`);
1650
+ for (const c of r.waitedOnBy) lines.push(convoyLine(c, "giver"));
1651
+ }
1652
+ return lines.join("\n");
1653
+ }
1654
+
1655
+ /** What harbor convoy ask, accept, decline, deliver, move or withdraw did. */
1656
+ export function convoyText(r) {
1657
+ if (r.withdrawn)
1658
+ return r.what
1659
+ ? `Withdrew ${r.from}'s ask of ${r.to ?? "a deleted program"} for “${r.what}”.`
1660
+ : "Withdrawn.";
1661
+ const c = r.convoy;
1662
+ const head = `${c.from} asks ${c.to ?? "a deleted program"} for “${c.what}” by ${c.by.slice(0, 10)}`;
1663
+ return `${head}.\n${c.text}.`;
1664
+ }
1665
+
1666
+ /** harbor salts PROJECT: what finished projects like it ran into. */
1667
+ export function saltsText(r) {
1668
+ if (r.note) return r.note;
1669
+ if (!r.lessons.length)
1670
+ return `No old salts for ${r.project}: no finished project like it left a lesson that's still out.`;
1671
+ const lines = [`Old salts for ${r.project}: what projects like it ran into`, ""];
1672
+ for (const l of r.lessons) {
1673
+ lines.push(` ${l.n}. ${l.text}`);
1674
+ if (l.helped) lines.push(` What helped: ${l.helped}`);
1675
+ }
1676
+ lines.push(
1677
+ "",
1678
+ `harbor salts "${r.project}" --risk N puts one on the register, --task N adds it as a task, --put-away N stops showing it.`,
1679
+ );
1680
+ return lines.join("\n");
1681
+ }
1682
+
1683
+ /** What harbor salts --risk, --task or --put-away did. */
1684
+ export function heedSaltText(r) {
1685
+ if (r.putAway) return `Put away “${r.putAway}” (from ${r.from}); it won't show on ${r.project} again.`;
1686
+ if (r.added === "risk") return `Added a risk to ${r.project}: “${r.title}” (from ${r.from}).`;
1687
+ return `Added a task to ${r.project}${r.key ? ` as ${r.key}` : ""}: “${r.title}” (from ${r.from}).`;
1688
+ }
1689
+
1690
+ /** harbor rank PORTFOLIO: the order kept on it, and how its ranking link stands. */
1691
+ export function rankText(r) {
1692
+ const lines = [];
1693
+ if (r.kept && r.kept.order.length) {
1694
+ const who = [r.kept.by ? `by ${r.kept.by}` : null, r.kept.at ? `on ${r.kept.at.slice(0, 10)}` : null]
1695
+ .filter(Boolean)
1696
+ .join(" ");
1697
+ const from = r.kept.voters > 1 ? `, from ${r.kept.voters} people's answers` : "";
1698
+ lines.push(`Which ship docks first in ${r.portfolio}${who ? ` (set ${who}${from})` : ""}`);
1699
+ for (const p of r.kept.order) lines.push(` ${p.place.padEnd(5)} ${p.project}`);
1700
+ if (r.kept.notRanked.length) lines.push(` Not ranked: ${r.kept.notRanked.join(", ")}`);
1701
+ } else {
1702
+ lines.push(
1703
+ r.openProjects < 2
1704
+ ? `${r.portfolio} has ${r.openProjects ? "one open project" : "no open projects"}, so there's nothing to rank.`
1705
+ : `${r.portfolio} has no docking order yet (${r.openProjects} open projects).`,
1706
+ );
1707
+ }
1708
+ if (r.link) {
1709
+ lines.push("");
1710
+ const state = r.link.open ? "open" : "closed";
1711
+ const counted = `${r.link.voters} ${r.link.voters === 1 ? "person" : "people"}, ${r.link.answers} ${r.link.answers === 1 ? "answer" : "answers"}`;
1712
+ lines.push(`The ranking link made ${r.link.made.slice(0, 10)} is ${state}: ${counted}${r.link.url ? `\n ${r.link.url}` : ""}`);
1713
+ for (const p of r.link.standing)
1714
+ lines.push(` ${p.place.padEnd(5)} ${p.project}${p.overNext ? ` · ${p.overNext} over the next` : ""}`);
1715
+ }
1716
+ if (r.openProjects >= 2)
1717
+ lines.push(
1718
+ "",
1719
+ `harbor rank "${r.portfolio}" --order "First, Second, …" puts an order on it; --clear takes it off. A ranking link for the crew is made on the portfolio page.`,
1720
+ );
1721
+ return lines.join("\n");
1722
+ }
1723
+
1724
+ /** What harbor rank --order or --clear did. */
1725
+ export function setRankText(r) {
1726
+ if (r.cleared) return `Took the docking order off ${r.portfolio}.`;
1727
+ const lines = [`Docking order on ${r.portfolio}:`];
1728
+ r.order.forEach((name, i) => lines.push(` ${String(i + 1).padStart(2)}. ${name}`));
1729
+ if (r.notRanked.length) lines.push(` Not ranked: ${r.notRanked.join(", ")}`);
1730
+ return lines.join("\n");
1731
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harborppm/cli",
3
- "version": "0.110.0",
3
+ "version": "0.111.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",