@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/README.md +9 -0
- package/dist/app.mjs +695 -244
- package/dist/words.mjs +16 -7
- package/lib/cli.mjs +175 -6
- package/lib/errors.mjs +15 -0
- package/lib/format.mjs +111 -2
- package/lib/mcp.mjs +5 -4
- package/package.json +1 -1
package/dist/words.mjs
CHANGED
|
@@ -198,6 +198,7 @@ function readTaskWords(input, ctx) {
|
|
|
198
198
|
break;
|
|
199
199
|
}
|
|
200
200
|
let owner = null;
|
|
201
|
+
const nobody = [];
|
|
201
202
|
if (!skip.has("owner")) {
|
|
202
203
|
const byKey = (key) => {
|
|
203
204
|
const full = ctx.people.filter((p) => loose(p.name) === key);
|
|
@@ -208,16 +209,23 @@ function readTaskWords(input, ctx) {
|
|
|
208
209
|
return key.length >= 3 && begins.length === 1 ? begins[0] : null;
|
|
209
210
|
};
|
|
210
211
|
for (const m of text.matchAll(/(?:^|\s)@([\p{L}\p{N}._-]+)/gu)) {
|
|
211
|
-
const hit = byKey(loose(m[1]));
|
|
212
|
-
if (!hit) continue;
|
|
213
212
|
const start = m.index + (m[0].length - m[0].trimStart().length);
|
|
214
|
-
|
|
213
|
+
const end = m.index + m[0].length;
|
|
214
|
+
const hit = byKey(loose(m[1]));
|
|
215
|
+
if (!hit) {
|
|
216
|
+
if (free(start, end)) nobody.push({
|
|
217
|
+
value: text.slice(start, end),
|
|
218
|
+
start,
|
|
219
|
+
end
|
|
220
|
+
});
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (owner || !free(start, end)) continue;
|
|
215
224
|
owner = {
|
|
216
225
|
value: hit.id,
|
|
217
226
|
start,
|
|
218
|
-
end
|
|
227
|
+
end
|
|
219
228
|
};
|
|
220
|
-
break;
|
|
221
229
|
}
|
|
222
230
|
if (!owner) for (const m of text.matchAll(/(?:^|[\s,])(?:assign(?:ed)? (?:it )?to|owner(?: is)?:?) (\p{L}+(?: \p{L}+)?)/giu)) {
|
|
223
231
|
const words = m[1].split(" ");
|
|
@@ -255,7 +263,7 @@ function readTaskWords(input, ctx) {
|
|
|
255
263
|
break;
|
|
256
264
|
}
|
|
257
265
|
if (!due) {
|
|
258
|
-
const rest = without(text, taken);
|
|
266
|
+
const rest = without(text, [...taken, ...nobody]);
|
|
259
267
|
const tail = new RegExp(`(?:^|[\\s,])(${WHEN})[.!]?$`, "i").exec(rest);
|
|
260
268
|
const short = tail && /^(?:sun|mon|tue|wed|thu|fri|sat)$/i.test(tail[1]);
|
|
261
269
|
const said = tail && /\b(?:to|for|from|after|with|since)$/i.test(rest.slice(0, tail.index).trimEnd());
|
|
@@ -294,7 +302,8 @@ function readTaskWords(input, ctx) {
|
|
|
294
302
|
project: project ? {
|
|
295
303
|
value: project.value,
|
|
296
304
|
text: span(project)
|
|
297
|
-
} : null
|
|
305
|
+
} : null,
|
|
306
|
+
nobody: nobody.filter((n) => free(n.start, n.end)).map((n) => n.value)
|
|
298
307
|
};
|
|
299
308
|
}
|
|
300
309
|
|
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,
|
|
@@ -84,6 +90,7 @@ import {
|
|
|
84
90
|
weekText,
|
|
85
91
|
} from "./format.mjs";
|
|
86
92
|
import { colourDepth, logoLines } from "./logo.mjs";
|
|
93
|
+
import { NO_HARBOR } from "./errors.mjs";
|
|
87
94
|
import { HarborError, createClient } from "./mcp.mjs";
|
|
88
95
|
import { jsonText, plain } from "./plain.mjs";
|
|
89
96
|
import { dayFromWords, readTaskWords } from "./words.mjs";
|
|
@@ -364,6 +371,21 @@ export const HELP = `harbor: Harbor from the terminal
|
|
|
364
371
|
months out of the line-up
|
|
365
372
|
harbor scuttle PROJECT --why "TEXT" stop it on purpose: Done, on the
|
|
366
373
|
register, its tasks set free
|
|
374
|
+
harbor convoys [PROGRAM] promises between programs: what
|
|
375
|
+
each waits on, and who waits on it
|
|
376
|
+
harbor convoy ask PROGRAM --to OTHER --by DATE "WHAT"
|
|
377
|
+
one program asks another for
|
|
378
|
+
a thing by a day
|
|
379
|
+
harbor convoy accept|decline|deliver|undeliver|move|withdraw CONVOY
|
|
380
|
+
answer one, or move or take back
|
|
381
|
+
your ask
|
|
382
|
+
harbor salts PROJECT [--risk N|--task N|--put-away N]
|
|
383
|
+
old salts: what finished projects
|
|
384
|
+
like it ran into
|
|
385
|
+
harbor rank PORTFOLIO [--order "A, B, C"|--clear]
|
|
386
|
+
which ship docks first: the
|
|
387
|
+
order a portfolio's projects
|
|
388
|
+
matter in
|
|
367
389
|
harbor watch [--project P] [--bell] a live ticker of the harbor's
|
|
368
390
|
changes; yours bright, q stops
|
|
369
391
|
harbor watch --once [--since TIME] [--json] the latest changes (or all since
|
|
@@ -701,10 +723,17 @@ async function readTitles(client, harbor, titles, values, today = todayLocal())
|
|
|
701
723
|
skip,
|
|
702
724
|
});
|
|
703
725
|
const read = r.owner || r.due || r.priority || r.project;
|
|
704
|
-
return read && r.title
|
|
726
|
+
return read && r.title
|
|
727
|
+
? r
|
|
728
|
+
: { title, owner: null, due: null, priority: null, project: null, nobody: r.nobody ?? [] };
|
|
705
729
|
});
|
|
706
730
|
}
|
|
707
731
|
|
|
732
|
+
/** Each @name in a title that matches nobody: it stays in the title, and nobody is made up. */
|
|
733
|
+
function nobodyLines(r) {
|
|
734
|
+
return (r?.nobody ?? []).map((n) => `${n}: no one by that name, kept in the title.`);
|
|
735
|
+
}
|
|
736
|
+
|
|
708
737
|
/** "Fri 2026-11-13": a day with its weekday, so "next friday" shows which Friday it became. */
|
|
709
738
|
export function dayWithWeekday(iso) {
|
|
710
739
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(iso)) return iso;
|
|
@@ -878,10 +907,7 @@ export function hint(message, project) {
|
|
|
878
907
|
/^Say which project or program it belongs to\.$/,
|
|
879
908
|
"Say where it belongs: --project NAME or --program NAME.",
|
|
880
909
|
)
|
|
881
|
-
.replace(
|
|
882
|
-
/^You don't belong to a harbor yet\..*$/s,
|
|
883
|
-
"You aren't in a harbor yet. Run harbor to make one, or open the invite a team sent you.",
|
|
884
|
-
);
|
|
910
|
+
.replace(/^You don't belong to a harbor yet\..*$/s, NO_HARBOR);
|
|
885
911
|
}
|
|
886
912
|
|
|
887
913
|
/** get_premortem's answer with its note naming the command, not the agent tool, since --json shows it. */
|
|
@@ -956,6 +982,7 @@ const DETAIL = {
|
|
|
956
982
|
" to\"; a day after by, due, on, before or until, or as the very last",
|
|
957
983
|
" words (\"Call the mill friday\"), never after to, for or from (\"Move",
|
|
958
984
|
" the call to Friday\" keeps it); !high or \"high priority\"; #Project.",
|
|
985
|
+
" An @name that matches nobody stays in the title, and Harbor says so.",
|
|
959
986
|
" With --dry-run --literal it says what the words would have read as.",
|
|
960
987
|
"",
|
|
961
988
|
" --assignee me|none|NAME, --also \"NAME, NAME\" (others on it with the",
|
|
@@ -1452,6 +1479,54 @@ const DETAIL = {
|
|
|
1452
1479
|
" Nothing is deleted: harbor health auto --project P raises a scuttled project",
|
|
1453
1480
|
" again and gives its tasks back.",
|
|
1454
1481
|
],
|
|
1482
|
+
convoys: [
|
|
1483
|
+
" harbor convoys reads every convoy: one program's ask",
|
|
1484
|
+
" of another, by a day, and how it",
|
|
1485
|
+
" stands (waiting for an answer, in",
|
|
1486
|
+
" time, late on the forecast, declined,",
|
|
1487
|
+
" delivered)",
|
|
1488
|
+
" harbor convoys PROGRAM reads what it waits on, and what",
|
|
1489
|
+
" others wait on it for",
|
|
1490
|
+
"",
|
|
1491
|
+
" harbor convoy ask PROGRAM … and its answers write them (harbor help convoy).",
|
|
1492
|
+
],
|
|
1493
|
+
convoy: [
|
|
1494
|
+
" harbor convoy ask PROGRAM --to OTHER --by DATE \"WHAT\"",
|
|
1495
|
+
" writes: PROGRAM asks OTHER for WHAT",
|
|
1496
|
+
" harbor convoy accept CONVOY [--project P]",
|
|
1497
|
+
" writes: the asked program takes it on,",
|
|
1498
|
+
" P (one of its projects) delivering it",
|
|
1499
|
+
' harbor convoy decline CONVOY [--note "WHY"]',
|
|
1500
|
+
" writes: it can't, and why",
|
|
1501
|
+
" harbor convoy deliver CONVOY writes: delivered (undeliver takes it",
|
|
1502
|
+
" back)",
|
|
1503
|
+
" harbor convoy move CONVOY --by DATE writes: the asking side moves the day",
|
|
1504
|
+
" harbor convoy withdraw CONVOY writes: the asking side takes it back",
|
|
1505
|
+
"",
|
|
1506
|
+
" CONVOY is its words (a part is enough when only one matches) or its id from",
|
|
1507
|
+
" harbor convoys --json. harbor convoys lists them.",
|
|
1508
|
+
],
|
|
1509
|
+
salts: [
|
|
1510
|
+
" harbor salts PROJECT reads what finished projects like it",
|
|
1511
|
+
" ran into: risks that came true,",
|
|
1512
|
+
" issues, voyage log lines, tasks that",
|
|
1513
|
+
" ended long late (up to three)",
|
|
1514
|
+
" harbor salts PROJECT --risk N writes: lesson N as an open risk",
|
|
1515
|
+
" harbor salts PROJECT --task N writes: lesson N as a task in To do",
|
|
1516
|
+
" harbor salts PROJECT --put-away N writes: stop showing lesson N",
|
|
1517
|
+
],
|
|
1518
|
+
rank: [
|
|
1519
|
+
" harbor rank PORTFOLIO reads which ship docks first: the",
|
|
1520
|
+
" order kept on the portfolio, and how",
|
|
1521
|
+
" its newest ranking link stands",
|
|
1522
|
+
' harbor rank PORTFOLIO --order "A, B, C"',
|
|
1523
|
+
" writes: its open projects in order,",
|
|
1524
|
+
" first to dock first (commas between)",
|
|
1525
|
+
" harbor rank PORTFOLIO --clear writes: takes the order off",
|
|
1526
|
+
"",
|
|
1527
|
+
" The ranking link the crew answers in pairs is made by the harbor's owner on",
|
|
1528
|
+
" the portfolio page.",
|
|
1529
|
+
],
|
|
1455
1530
|
watch: [
|
|
1456
1531
|
" harbor watch reads, live: each change to the harbor",
|
|
1457
1532
|
" as it lands, one line with its time",
|
|
@@ -1844,8 +1919,12 @@ const OTHER_NAMES = {
|
|
|
1844
1919
|
dashboards: "harbor reports lists the Reports page's dashboards, each chart as its numbers.",
|
|
1845
1920
|
report: "harbor report PROGRAM is a program's status report; harbor reports lists the dashboards.",
|
|
1846
1921
|
decide: 'harbor decision "TITLE" --project P logs a decision.',
|
|
1847
|
-
dock: "harbor try PROJECT is the dry dock.",
|
|
1922
|
+
dock: "harbor try PROJECT is the dry dock; harbor rank PORTFOLIO says which ship docks first.",
|
|
1848
1923
|
"dry-dock": "harbor try PROJECT is the dry dock.",
|
|
1924
|
+
ranking: "harbor rank PORTFOLIO says which ship docks first.",
|
|
1925
|
+
salt: "harbor salts PROJECT lists its old salts.",
|
|
1926
|
+
"old-salts": "harbor salts PROJECT lists its old salts.",
|
|
1927
|
+
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
1928
|
};
|
|
1850
1929
|
|
|
1851
1930
|
/** A mistyped command, with the one it was probably meant to be. */
|
|
@@ -2598,6 +2677,10 @@ export async function run(argv, io = {}) {
|
|
|
2598
2677
|
case "mine": {
|
|
2599
2678
|
const { positionals, harbor } = parse(spec());
|
|
2600
2679
|
none(positionals);
|
|
2680
|
+
// First voyage's "Try Harbor in your terminal" isn't ticked from here:
|
|
2681
|
+
// my_work only reads, and a read that saves a change would be a
|
|
2682
|
+
// surprise (and History would show it). The full-screen app ticks it
|
|
2683
|
+
// when it opens (src/tui/main.tsx), and the website when it next loads.
|
|
2601
2684
|
return call("my_work", { harbor }, (r) => myWork(r, opts));
|
|
2602
2685
|
}
|
|
2603
2686
|
case "tasks": {
|
|
@@ -3029,6 +3112,7 @@ export async function run(argv, io = {}) {
|
|
|
3029
3112
|
...(values.template ? { template: values.template } : {}),
|
|
3030
3113
|
...(values.comment ? { comment: values.comment } : {}),
|
|
3031
3114
|
...(wordsRead(words) ? { read: wordsRead(words) } : {}),
|
|
3115
|
+
...(words.nobody?.length ? { unknownPeople: words.nobody } : {}),
|
|
3032
3116
|
...(unread && wordsRead(unread[i]) ? { keptWords: wordsRead(unread[i]) } : {}),
|
|
3033
3117
|
...(p.sameAs ? { sameAs: p.sameAs } : {}),
|
|
3034
3118
|
...(p.sameAs && values["unless-exists"] ? { skipped: true } : {}),
|
|
@@ -3070,6 +3154,7 @@ export async function run(argv, io = {}) {
|
|
|
3070
3154
|
` ${l.title}${l.skipped ? " (already there, skipped)" : ""}`,
|
|
3071
3155
|
` ${bits.join(" · ")}`,
|
|
3072
3156
|
...(wordsLine(words) ? [` ${wordsLine(words)} --literal keeps them in the title.`] : []),
|
|
3157
|
+
...nobodyLines(words).map((x) => ` ${x}`),
|
|
3073
3158
|
...(l.keptWords
|
|
3074
3159
|
? [` --literal kept the words as typed. ${wordsLine(unread[i]).replace("Read from your words", "Without it, they'd read as")}`]
|
|
3075
3160
|
: []),
|
|
@@ -3119,6 +3204,7 @@ export async function run(argv, io = {}) {
|
|
|
3119
3204
|
// The words read out of the title, field by field, and the title as typed.
|
|
3120
3205
|
const read = wordsRead(words);
|
|
3121
3206
|
if (read) r.read = { ...read, typed: titles[i] };
|
|
3207
|
+
if (words.nobody?.length) r.unknownPeople = words.nobody;
|
|
3122
3208
|
added.push(r);
|
|
3123
3209
|
}
|
|
3124
3210
|
await stalePromptCache(env);
|
|
@@ -3136,6 +3222,7 @@ export async function run(argv, io = {}) {
|
|
|
3136
3222
|
...(values.template ? { template: values.template } : {}),
|
|
3137
3223
|
...(r.comment ? { comment: r.comment } : {}),
|
|
3138
3224
|
...(r.read ? { read: r.read } : {}),
|
|
3225
|
+
...(r.unknownPeople ? { unknownPeople: r.unknownPeople } : {}),
|
|
3139
3226
|
...(r.pilot ? { pilot: r.pilot } : {}),
|
|
3140
3227
|
...(r.milestoneReached ? { milestoneReached: r.milestoneReached } : {}),
|
|
3141
3228
|
...(r.milestoneReopened ? { milestoneReopened: r.milestoneReopened } : {}),
|
|
@@ -3168,6 +3255,7 @@ export async function run(argv, io = {}) {
|
|
|
3168
3255
|
`You typed “${r.read.typed}”. ${wordsLine(reads[added.indexOf(r)])} --literal keeps the words in the title.`,
|
|
3169
3256
|
]
|
|
3170
3257
|
: []),
|
|
3258
|
+
...nobodyLines({ nobody: r.unknownPeople }),
|
|
3171
3259
|
// --due in words ("next friday"): the day it became, weekday and all.
|
|
3172
3260
|
...(dueWords(values.due) ? [`--due ${values.due}: ${dayWithWeekday(dueDate(values.due))}.`] : []),
|
|
3173
3261
|
// Pilot speaks up only when a date was given that the queue says won't hold.
|
|
@@ -4647,6 +4735,87 @@ export async function run(argv, io = {}) {
|
|
|
4647
4735
|
scuttleText,
|
|
4648
4736
|
);
|
|
4649
4737
|
}
|
|
4738
|
+
case "convoys": {
|
|
4739
|
+
const { positionals, harbor } = parse(spec());
|
|
4740
|
+
const program = positionals.join(" ").trim();
|
|
4741
|
+
return call("list_convoys", { harbor, ...(program ? { program } : {}) }, convoysText);
|
|
4742
|
+
}
|
|
4743
|
+
case "convoy": {
|
|
4744
|
+
const { positionals, values, harbor } = parse(spec([], ["to", "by", "project", "note"]));
|
|
4745
|
+
const [act, ...words] = positionals;
|
|
4746
|
+
const ACTS = ["ask", "accept", "decline", "deliver", "undeliver", "move", "withdraw"];
|
|
4747
|
+
if (act === undefined) {
|
|
4748
|
+
return call("list_convoys", { harbor }, convoysText);
|
|
4749
|
+
}
|
|
4750
|
+
if (!ACTS.includes(act))
|
|
4751
|
+
throw new HarborError(
|
|
4752
|
+
`harbor convoy ${act}? Say ask, accept, decline, deliver, undeliver, move or withdraw; harbor convoys lists them.`,
|
|
4753
|
+
);
|
|
4754
|
+
const only = (allowed) => {
|
|
4755
|
+
const extra = ["to", "by", "project", "note"].filter(
|
|
4756
|
+
(k) => values[k] !== undefined && !allowed.includes(k),
|
|
4757
|
+
);
|
|
4758
|
+
if (extra.length)
|
|
4759
|
+
throw new HarborError(`--${extra[0]} doesn't go with harbor convoy ${act}.`);
|
|
4760
|
+
};
|
|
4761
|
+
if (act === "ask") {
|
|
4762
|
+
only(["to", "by"]);
|
|
4763
|
+
const [program, ...what] = words;
|
|
4764
|
+
if (!program || !what.length || values.to === undefined || values.by === undefined)
|
|
4765
|
+
throw new HarborError('An ask: harbor convoy ask PROGRAM --to OTHER --by DATE "WHAT".');
|
|
4766
|
+
return call(
|
|
4767
|
+
"convoy",
|
|
4768
|
+
{ harbor, act, program, to: values.to, what: what.join(" "), by: dueDate(values.by) },
|
|
4769
|
+
convoyText,
|
|
4770
|
+
);
|
|
4771
|
+
}
|
|
4772
|
+
const convoy = text(words, "which convoy (its words or id)");
|
|
4773
|
+
only({ accept: ["project"], decline: ["note"], move: ["by"] }[act] ?? []);
|
|
4774
|
+
if (act === "move" && values.by === undefined)
|
|
4775
|
+
throw new HarborError("Moving it needs the new day: harbor convoy move CONVOY --by DATE.");
|
|
4776
|
+
return call(
|
|
4777
|
+
"convoy",
|
|
4778
|
+
{
|
|
4779
|
+
harbor,
|
|
4780
|
+
act,
|
|
4781
|
+
convoy,
|
|
4782
|
+
...(values.project !== undefined ? { project: values.project } : {}),
|
|
4783
|
+
...(values.note !== undefined ? { note: values.note } : {}),
|
|
4784
|
+
...(values.by !== undefined ? { by: dueDate(values.by) } : {}),
|
|
4785
|
+
},
|
|
4786
|
+
convoyText,
|
|
4787
|
+
);
|
|
4788
|
+
}
|
|
4789
|
+
case "salts": {
|
|
4790
|
+
const { positionals, values, harbor } = parse(spec([], ["risk", "task", "put-away"]));
|
|
4791
|
+
const project = text(positionals, "which project");
|
|
4792
|
+
const acts = ["risk", "task", "put-away"].filter((k) => values[k] !== undefined);
|
|
4793
|
+
if (acts.length > 1)
|
|
4794
|
+
throw new HarborError("One at a time: --risk N, --task N or --put-away N.");
|
|
4795
|
+
if (!acts.length) return call("old_salts", { harbor, project }, saltsText);
|
|
4796
|
+
const as = acts[0];
|
|
4797
|
+
const lesson = String(values[as]).trim();
|
|
4798
|
+
if (!/^[1-9]\d*$/.test(lesson))
|
|
4799
|
+
throw new HarborError(`--${as} takes the lesson's number from harbor salts "${project}".`);
|
|
4800
|
+
return call("heed_old_salt", { harbor, project, lesson, as }, heedSaltText);
|
|
4801
|
+
}
|
|
4802
|
+
case "rank": {
|
|
4803
|
+
const { positionals, values, harbor } = parse(spec(["clear"], ["order"]));
|
|
4804
|
+
const portfolio = text(positionals, "which portfolio");
|
|
4805
|
+
if (values.clear && values.order !== undefined)
|
|
4806
|
+
throw new HarborError("--order or --clear, not both.");
|
|
4807
|
+
if (values.clear) return call("set_dock_order", { harbor, portfolio, clear: true }, setRankText);
|
|
4808
|
+
if (values.order !== undefined) {
|
|
4809
|
+
const projects = values.order
|
|
4810
|
+
.split(",")
|
|
4811
|
+
.map((p) => p.trim())
|
|
4812
|
+
.filter(Boolean);
|
|
4813
|
+
if (projects.length < 2)
|
|
4814
|
+
throw new HarborError('Name at least two projects, commas between: --order "A, B".');
|
|
4815
|
+
return call("set_dock_order", { harbor, portfolio, projects }, setRankText);
|
|
4816
|
+
}
|
|
4817
|
+
return call("dock_order", { harbor, portfolio }, rankText);
|
|
4818
|
+
}
|
|
4650
4819
|
case "bridge": {
|
|
4651
4820
|
const { positionals, values, harbor } = parse(spec(["list"], ["program"]));
|
|
4652
4821
|
none(positionals);
|
package/lib/errors.mjs
CHANGED
|
@@ -8,6 +8,21 @@ export class HarborError extends Error {
|
|
|
8
8
|
name = "HarborError";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* No harbor yet, said the same by every command: the full-screen app (harbor
|
|
13
|
+
* on its own) makes one, so that's where it points rather than the website.
|
|
14
|
+
*/
|
|
15
|
+
export const NO_HARBOR =
|
|
16
|
+
"You aren't in a harbor yet. Run harbor on its own and it helps you make one, or open the invite a team sent you.";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Harbor's own "no harbor yet" (worded for any app) in the terminal's words.
|
|
20
|
+
* @param {string} said
|
|
21
|
+
*/
|
|
22
|
+
export function terminalWords(said) {
|
|
23
|
+
return /^You don't belong to a harbor yet\./.test(said) ? NO_HARBOR : said;
|
|
24
|
+
}
|
|
25
|
+
|
|
11
26
|
/**
|
|
12
27
|
* fetch, with "the server isn't there" said plainly rather than as
|
|
13
28
|
* "fetch failed" (no network, a wrong --server, the server down).
|
package/lib/format.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NO_HARBOR } from "./errors.mjs";
|
|
2
|
+
|
|
1
3
|
/** Plain text for a terminal: one task per line, its key (or id) first so it can be copied. */
|
|
2
4
|
|
|
3
5
|
/** Statuses in the board's words, as the website, the app and an export say them. */
|
|
@@ -230,7 +232,7 @@ export function whoami(r, creds) {
|
|
|
230
232
|
else if (list.length === 1) lines.push(`Commands use ${list[0].name}, your only harbor.`);
|
|
231
233
|
else if (list.length)
|
|
232
234
|
lines.push("No harbor set: say --harbor NAME, or set one with harbor use NAME.");
|
|
233
|
-
else lines.push(
|
|
235
|
+
else lines.push(NO_HARBOR);
|
|
234
236
|
// Shown from whoamiData (build), or straight from list_harbors (server).
|
|
235
237
|
lines.push(serverLine(r.build ?? (typeof r.server === "object" ? r.server : null)));
|
|
236
238
|
return lines.join("\n");
|
|
@@ -269,7 +271,7 @@ export function whoamiData(r, creds) {
|
|
|
269
271
|
|
|
270
272
|
export function harbors(r) {
|
|
271
273
|
const list = r.harbors ?? [];
|
|
272
|
-
if (!list.length) return
|
|
274
|
+
if (!list.length) return NO_HARBOR;
|
|
273
275
|
// The website's words for a role, not the stored ones; names, not ids
|
|
274
276
|
// (harbor use and --harbor take a name).
|
|
275
277
|
const label = (role) =>
|
|
@@ -1622,3 +1624,110 @@ export function chatsText(r) {
|
|
|
1622
1624
|
}
|
|
1623
1625
|
return out.join("\n");
|
|
1624
1626
|
}
|
|
1627
|
+
const convoyLine = (c, side) =>
|
|
1628
|
+
side === "giver"
|
|
1629
|
+
? ` ${c.from} asks for “${c.what}” by ${c.by.slice(0, 10)} · ${c.text}`
|
|
1630
|
+
: ` “${c.what}” from ${c.to ?? "a deleted program"} by ${c.by.slice(0, 10)} · ${c.text}`;
|
|
1631
|
+
|
|
1632
|
+
/** harbor convoys: promises between programs, every one or one program's both ways. */
|
|
1633
|
+
export function convoysText(r) {
|
|
1634
|
+
if (!r.program) {
|
|
1635
|
+
if (!r.convoys.length)
|
|
1636
|
+
return 'No convoys yet. One program asks another with harbor convoy ask PROGRAM --to OTHER "WHAT" --by DATE.';
|
|
1637
|
+
const lines = [`${r.convoys.length} ${r.convoys.length === 1 ? "convoy" : "convoys"}:`, ""];
|
|
1638
|
+
for (const c of r.convoys)
|
|
1639
|
+
lines.push(` ${c.from} asks ${c.to ?? "a deleted program"} for “${c.what}” by ${c.by.slice(0, 10)}`, ` ${c.text}`);
|
|
1640
|
+
return lines.join("\n");
|
|
1641
|
+
}
|
|
1642
|
+
if (!r.waitingOn.length && !r.waitedOnBy.length)
|
|
1643
|
+
return `${r.program} has no convoys: it isn't waiting on another program, and none waits on it.`;
|
|
1644
|
+
const lines = [];
|
|
1645
|
+
if (r.waitingOn.length) {
|
|
1646
|
+
lines.push(`${r.program} waits on`);
|
|
1647
|
+
for (const c of r.waitingOn) lines.push(convoyLine(c, "asker"));
|
|
1648
|
+
}
|
|
1649
|
+
if (r.waitedOnBy.length) {
|
|
1650
|
+
if (lines.length) lines.push("");
|
|
1651
|
+
lines.push(`Others wait on ${r.program}`);
|
|
1652
|
+
for (const c of r.waitedOnBy) lines.push(convoyLine(c, "giver"));
|
|
1653
|
+
}
|
|
1654
|
+
return lines.join("\n");
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
/** What harbor convoy ask, accept, decline, deliver, move or withdraw did. */
|
|
1658
|
+
export function convoyText(r) {
|
|
1659
|
+
if (r.withdrawn)
|
|
1660
|
+
return r.what
|
|
1661
|
+
? `Withdrew ${r.from}'s ask of ${r.to ?? "a deleted program"} for “${r.what}”.`
|
|
1662
|
+
: "Withdrawn.";
|
|
1663
|
+
const c = r.convoy;
|
|
1664
|
+
const head = `${c.from} asks ${c.to ?? "a deleted program"} for “${c.what}” by ${c.by.slice(0, 10)}`;
|
|
1665
|
+
return `${head}.\n${c.text}.`;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
/** harbor salts PROJECT: what finished projects like it ran into. */
|
|
1669
|
+
export function saltsText(r) {
|
|
1670
|
+
if (r.note) return r.note;
|
|
1671
|
+
if (!r.lessons.length)
|
|
1672
|
+
return `No old salts for ${r.project}: no finished project like it left a lesson that's still out.`;
|
|
1673
|
+
const lines = [`Old salts for ${r.project}: what projects like it ran into`, ""];
|
|
1674
|
+
for (const l of r.lessons) {
|
|
1675
|
+
lines.push(` ${l.n}. ${l.text}`);
|
|
1676
|
+
if (l.helped) lines.push(` What helped: ${l.helped}`);
|
|
1677
|
+
}
|
|
1678
|
+
lines.push(
|
|
1679
|
+
"",
|
|
1680
|
+
`harbor salts "${r.project}" --risk N puts one on the register, --task N adds it as a task, --put-away N stops showing it.`,
|
|
1681
|
+
);
|
|
1682
|
+
return lines.join("\n");
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/** What harbor salts --risk, --task or --put-away did. */
|
|
1686
|
+
export function heedSaltText(r) {
|
|
1687
|
+
if (r.putAway) return `Put away “${r.putAway}” (from ${r.from}); it won't show on ${r.project} again.`;
|
|
1688
|
+
if (r.added === "risk") return `Added a risk to ${r.project}: “${r.title}” (from ${r.from}).`;
|
|
1689
|
+
return `Added a task to ${r.project}${r.key ? ` as ${r.key}` : ""}: “${r.title}” (from ${r.from}).`;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
/** harbor rank PORTFOLIO: the order kept on it, and how its ranking link stands. */
|
|
1693
|
+
export function rankText(r) {
|
|
1694
|
+
const lines = [];
|
|
1695
|
+
if (r.kept && r.kept.order.length) {
|
|
1696
|
+
const who = [r.kept.by ? `by ${r.kept.by}` : null, r.kept.at ? `on ${r.kept.at.slice(0, 10)}` : null]
|
|
1697
|
+
.filter(Boolean)
|
|
1698
|
+
.join(" ");
|
|
1699
|
+
const from = r.kept.voters > 1 ? `, from ${r.kept.voters} people's answers` : "";
|
|
1700
|
+
lines.push(`Which ship docks first in ${r.portfolio}${who ? ` (set ${who}${from})` : ""}`);
|
|
1701
|
+
for (const p of r.kept.order) lines.push(` ${p.place.padEnd(5)} ${p.project}`);
|
|
1702
|
+
if (r.kept.notRanked.length) lines.push(` Not ranked: ${r.kept.notRanked.join(", ")}`);
|
|
1703
|
+
} else {
|
|
1704
|
+
lines.push(
|
|
1705
|
+
r.openProjects < 2
|
|
1706
|
+
? `${r.portfolio} has ${r.openProjects ? "one open project" : "no open projects"}, so there's nothing to rank.`
|
|
1707
|
+
: `${r.portfolio} has no docking order yet (${r.openProjects} open projects).`,
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
if (r.link) {
|
|
1711
|
+
lines.push("");
|
|
1712
|
+
const state = r.link.open ? "open" : "closed";
|
|
1713
|
+
const counted = `${r.link.voters} ${r.link.voters === 1 ? "person" : "people"}, ${r.link.answers} ${r.link.answers === 1 ? "answer" : "answers"}`;
|
|
1714
|
+
lines.push(`The ranking link made ${r.link.made.slice(0, 10)} is ${state}: ${counted}${r.link.url ? `\n ${r.link.url}` : ""}`);
|
|
1715
|
+
for (const p of r.link.standing)
|
|
1716
|
+
lines.push(` ${p.place.padEnd(5)} ${p.project}${p.overNext ? ` · ${p.overNext} over the next` : ""}`);
|
|
1717
|
+
}
|
|
1718
|
+
if (r.openProjects >= 2)
|
|
1719
|
+
lines.push(
|
|
1720
|
+
"",
|
|
1721
|
+
`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.`,
|
|
1722
|
+
);
|
|
1723
|
+
return lines.join("\n");
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/** What harbor rank --order or --clear did. */
|
|
1727
|
+
export function setRankText(r) {
|
|
1728
|
+
if (r.cleared) return `Took the docking order off ${r.portfolio}.`;
|
|
1729
|
+
const lines = [`Docking order on ${r.portfolio}:`];
|
|
1730
|
+
r.order.forEach((name, i) => lines.push(` ${String(i + 1).padStart(2)}. ${name}`));
|
|
1731
|
+
if (r.notRanked.length) lines.push(` Not ranked: ${r.notRanked.join(", ")}`);
|
|
1732
|
+
return lines.join("\n");
|
|
1733
|
+
}
|
package/lib/mcp.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* refreshed once and the call retried.
|
|
5
5
|
*/
|
|
6
6
|
import { refresh } from "./auth.mjs";
|
|
7
|
-
import { HarborError, reach } from "./errors.mjs";
|
|
7
|
+
import { HarborError, reach, terminalWords } from "./errors.mjs";
|
|
8
8
|
|
|
9
9
|
export { HarborError };
|
|
10
10
|
|
|
@@ -51,7 +51,7 @@ export function createClient({ creds, save, fetcher = fetch, now = Date.now }) {
|
|
|
51
51
|
throw new HarborError("Harbor asked to slow down. Try again in a minute.");
|
|
52
52
|
if (!res.ok) throw new HarborError(`Harbor answered ${res.status}.`);
|
|
53
53
|
const msg = await res.json();
|
|
54
|
-
if (msg.error) throw new HarborError(msg.error.message);
|
|
54
|
+
if (msg.error) throw new HarborError(terminalWords(msg.error.message));
|
|
55
55
|
const result = msg.result ?? {};
|
|
56
56
|
if (result.isError) {
|
|
57
57
|
const said = result.content?.map((c) => c.text).join("\n") || "Harbor said no.";
|
|
@@ -60,7 +60,7 @@ export function createClient({ creds, save, fetcher = fetch, now = Date.now }) {
|
|
|
60
60
|
throw new HarborError(
|
|
61
61
|
`${new URL(current.server).host} doesn't have this yet. Try again after the next site update.`,
|
|
62
62
|
);
|
|
63
|
-
throw new HarborError(said);
|
|
63
|
+
throw new HarborError(terminalWords(said));
|
|
64
64
|
}
|
|
65
65
|
return result.structuredContent ?? JSON.parse(result.content?.[0]?.text ?? "{}");
|
|
66
66
|
},
|
|
@@ -79,7 +79,8 @@ export function createClient({ creds, save, fetcher = fetch, now = Date.now }) {
|
|
|
79
79
|
}
|
|
80
80
|
if (res.status === 401) throw new HarborError("Signed out. Run harbor login.");
|
|
81
81
|
const answer = await res.json().catch(() => ({}));
|
|
82
|
-
if (!res.ok)
|
|
82
|
+
if (!res.ok)
|
|
83
|
+
throw new HarborError(terminalWords(answer.error ?? `Harbor answered ${res.status}.`));
|
|
83
84
|
return answer;
|
|
84
85
|
},
|
|
85
86
|
};
|