@harborppm/cli 0.102.0 → 0.104.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 +5 -1
- package/dist/app.mjs +172 -0
- package/lib/cli.mjs +282 -6
- package/lib/config.mjs +20 -0
- package/lib/format.mjs +56 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,9 +213,13 @@ harbor export tasks PROJECT|risks|review [--all]
|
|
|
213
213
|
a spreadsheet (CSV) to stdout
|
|
214
214
|
harbor import FILE [--project P] [--portfolio P] [--no-people]
|
|
215
215
|
add tasks from a CSV file
|
|
216
|
+
harbor draft "WORDS" --project P|--program P|--portfolio P|--new program|portfolio [--add]
|
|
217
|
+
Harbor's AI drafts tasks, projects or programs
|
|
218
|
+
harbor draft add add the draft shown last
|
|
216
219
|
harbor premortem PROJECT ["WHAT WENT WRONG"] [--start]
|
|
217
220
|
harbor voyage PROJECT ["YOUR LINE"]
|
|
218
221
|
harbor messages PROJECT ["TEXT"] [--limit N] | messages PROJECT --edit "TEXT" [--message ID]
|
|
222
|
+
harbor chat TASK|PROJECT|PROGRAM ["TEXT"] [--reply N] [--watch]
|
|
219
223
|
harbor note PROJECT ["NOTE"] [--opens DATE|--milestone NAME|--off-track]
|
|
220
224
|
harbor sound TASK [--answer DAYS|--ask NAMES|--settle DAYS] [--why TEXT]
|
|
221
225
|
harbor soundings [PROJECT]
|
|
@@ -269,7 +273,7 @@ A task has one owner (`--assignee`), who answers for it and whose load it counts
|
|
|
269
273
|
|
|
270
274
|
`harbor limit RR` prints how many tasks each of a board's columns takes at once; `harbor limit RR doing 8` changes one (1 to 20, or `none` for no limit), if you own the harbor. `harbor projects --json` carries each board's `limits` too.
|
|
271
275
|
|
|
272
|
-
`harbor premortem` runs a pre-mortem with your crew: `--start` asks everyone "it's after the end date and this project failed: what happened?", each person adds answers alone for five minutes, and then the answers show together on the project's Risks & issues tab, where each becomes a risk in one click. On its own it prints the question and the answers you can see. Once a project is Done, `harbor voyage` prints its voyage log (planned against actual dates, the biggest slips, the risks that came true, who closed the most, and the crew's lines) and adds yours. `harbor messages PROJECT` reads a project's Messages tab, one conversation for the whole project, and `harbor messages PROJECT "TEXT"` writes to it; `@Name` sends it to that person's Inbox. `harbor note` leaves a note for later on a project: it stays sealed (the crew sees only that it's there and who left it) until its day, until one of the program's milestones is reached, or until the project turns Off track, and then it opens at the top of the project and in the brief. `harbor sound TASK --ask crew` takes a sounding: it asks you, the task's owner and whoever has open work on its project how many working days the task will take (`--ask "Sam,Priya"` picks who). Each person answers alone with `harbor sound TASK --answer 4 --why "…"`, and nobody sees the others' numbers until everyone has; then `harbor sound TASK` shows the spread, an estimate when the guesses are close, or "talk about this first" when they're far apart, and `--settle DAYS` records what you agreed. `harbor soundings` lists them, the ones waiting on your answer first. `harbor goals` lists each portfolio's goals, off track first, with each key result's progress. `harbor goal "TITLE" --new` sets one, and `harbor goal "GOAL"` reads or changes one: `--owner`, `--due`, `--why`, `--link "Ridge Runner"` to count a program, project or task toward it, `--kr "Stores signed" --target 40` to add a number key result and `--kr "Stores signed" --at 12` to move it. `harbor milestones` lists a program's milestones soonest first, with how many of their tasks are done, who signs them off and what they wait on; `harbor milestone "NAME" --new --program P --due DATE` adds one, and `harbor milestone "NAME"` moves (`--due`), renames, ticks (`--reached`), sets who signs it off (`--signs-off`), or, if it's yours to sign, `--approve`s it or asks for `--changes`. `harbor reports` prints the Reports page's dashboards, each chart as its numbers. `harbor messages PROJECT --edit "TEXT"` fixes your latest message there. `harbor ashore` lists the public holidays and time away in the next eight weeks; `--country US,GB` sets whose holidays the harbor takes and `--person NAME --country DE` one person's own, which the forecast and the weekly load then count as days off.
|
|
276
|
+
`harbor premortem` runs a pre-mortem with your crew: `--start` asks everyone "it's after the end date and this project failed: what happened?", each person adds answers alone for five minutes, and then the answers show together on the project's Risks & issues tab, where each becomes a risk in one click. On its own it prints the question and the answers you can see. Once a project is Done, `harbor voyage` prints its voyage log (planned against actual dates, the biggest slips, the risks that came true, who closed the most, and the crew's lines) and adds yours. `harbor messages PROJECT` reads a project's Messages tab, one conversation for the whole project, and `harbor messages PROJECT "TEXT"` writes to it; `@Name` sends it to that person's Inbox. `harbor chat` is the same for any piece of work: `harbor chat RR-42` reads a task's comments, `harbor chat Footwear` a program's messages, `harbor chat Footwear "TEXT" --reply 2` replies under message [2], and `--watch` follows the conversation live, printing new lines as they come; in a terminal, type a line to post it. `harbor note` leaves a note for later on a project: it stays sealed (the crew sees only that it's there and who left it) until its day, until one of the program's milestones is reached, or until the project turns Off track, and then it opens at the top of the project and in the brief. `harbor sound TASK --ask crew` takes a sounding: it asks you, the task's owner and whoever has open work on its project how many working days the task will take (`--ask "Sam,Priya"` picks who). Each person answers alone with `harbor sound TASK --answer 4 --why "…"`, and nobody sees the others' numbers until everyone has; then `harbor sound TASK` shows the spread, an estimate when the guesses are close, or "talk about this first" when they're far apart, and `--settle DAYS` records what you agreed. `harbor soundings` lists them, the ones waiting on your answer first. `harbor goals` lists each portfolio's goals, off track first, with each key result's progress. `harbor goal "TITLE" --new` sets one, and `harbor goal "GOAL"` reads or changes one: `--owner`, `--due`, `--why`, `--link "Ridge Runner"` to count a program, project or task toward it, `--kr "Stores signed" --target 40` to add a number key result and `--kr "Stores signed" --at 12` to move it. `harbor milestones` lists a program's milestones soonest first, with how many of their tasks are done, who signs them off and what they wait on; `harbor milestone "NAME" --new --program P --due DATE` adds one, and `harbor milestone "NAME"` moves (`--due`), renames, ticks (`--reached`), sets who signs it off (`--signs-off`), or, if it's yours to sign, `--approve`s it or asks for `--changes`. `harbor reports` prints the Reports page's dashboards, each chart as its numbers. `harbor messages PROJECT --edit "TEXT"` fixes your latest message there. `harbor ashore` lists the public holidays and time away in the next eight weeks; `--country US,GB` sets whose holidays the harbor takes and `--person NAME --country DE` one person's own, which the forecast and the weekly load then count as days off.
|
|
273
277
|
|
|
274
278
|
`harbor brief --say` turns the brief into the BBC's Shipping Forecast: each program an area, wind for late work, visibility for health, gale warnings for anything off track. It prints the forecast and speaks it with your computer's own voice (`say` on a Mac, Windows' speech, or `espeak-ng` on Linux, which you may need to install). With `--json` it prints the forecast and stays quiet.
|
|
275
279
|
|
package/dist/app.mjs
CHANGED
|
@@ -6918,6 +6918,28 @@ function messagesIn(reflections, place) {
|
|
|
6918
6918
|
return (reflections ?? []).filter((r) => inPlace(r, place)).sort(oldestFirst);
|
|
6919
6919
|
}
|
|
6920
6920
|
/**
|
|
6921
|
+
* A conversation as threads, in the order each began. An answer whose
|
|
6922
|
+
* message was deleted stands on its own, so nobody's words go missing.
|
|
6923
|
+
*/
|
|
6924
|
+
function threadsOf(messages) {
|
|
6925
|
+
const sorted = [...messages].sort(oldestFirst);
|
|
6926
|
+
const byId = new Map(sorted.map((m) => [m.id, m]));
|
|
6927
|
+
const rootOf = (m) => {
|
|
6928
|
+
const parent = m.replyToId ? byId.get(m.replyToId) : void 0;
|
|
6929
|
+
return parent && parent.id !== m.id && !parent.replyToId ? parent.id : null;
|
|
6930
|
+
};
|
|
6931
|
+
const threads = /* @__PURE__ */ new Map();
|
|
6932
|
+
for (const m of sorted) if (!rootOf(m)) threads.set(m.id, {
|
|
6933
|
+
message: m,
|
|
6934
|
+
replies: []
|
|
6935
|
+
});
|
|
6936
|
+
for (const m of sorted) {
|
|
6937
|
+
const root = rootOf(m);
|
|
6938
|
+
if (root) threads.get(root).replies.push(m);
|
|
6939
|
+
}
|
|
6940
|
+
return [...threads.values()];
|
|
6941
|
+
}
|
|
6942
|
+
/**
|
|
6921
6943
|
* The message an answer hangs under: the one asked for, or, for an answer
|
|
6922
6944
|
* to an answer, that answer's own message. Null when it isn't a message in
|
|
6923
6945
|
* the same conversation.
|
|
@@ -24271,6 +24293,128 @@ function notesOf(ctx, p) {
|
|
|
24271
24293
|
};
|
|
24272
24294
|
}) };
|
|
24273
24295
|
}
|
|
24296
|
+
const CHAT_KINDS = [
|
|
24297
|
+
"task",
|
|
24298
|
+
"project",
|
|
24299
|
+
"program"
|
|
24300
|
+
];
|
|
24301
|
+
const exactlyNamed = (items, want) => {
|
|
24302
|
+
const w = want.trim().toLowerCase();
|
|
24303
|
+
return items.filter((i) => i.id === want.trim() || i.name.trim().toLowerCase() === w || i.key?.toLowerCase() === w);
|
|
24304
|
+
};
|
|
24305
|
+
/**
|
|
24306
|
+
* The chat `on` names: a task by key or id, a project, or a program, by name,
|
|
24307
|
+
* key or id. With no `kind`, a task key wins, then an exact project or
|
|
24308
|
+
* program name, then the nearest project name, then the nearest program's.
|
|
24309
|
+
* A project and a program with the very same name need `kind`.
|
|
24310
|
+
*/
|
|
24311
|
+
function chatTarget(data, on, kind) {
|
|
24312
|
+
const asTask = (t) => {
|
|
24313
|
+
const project = data.projects.find((p) => p.id === t.projectId);
|
|
24314
|
+
return {
|
|
24315
|
+
kind: "task",
|
|
24316
|
+
task: t,
|
|
24317
|
+
name: t.title,
|
|
24318
|
+
key: taskKey(t, project) ?? null,
|
|
24319
|
+
project: project?.name ?? null
|
|
24320
|
+
};
|
|
24321
|
+
};
|
|
24322
|
+
const asProject = (p) => ({
|
|
24323
|
+
kind: "project",
|
|
24324
|
+
place: {
|
|
24325
|
+
kind: "project",
|
|
24326
|
+
id: p.id
|
|
24327
|
+
},
|
|
24328
|
+
name: p.name
|
|
24329
|
+
});
|
|
24330
|
+
const asProgram = (p) => ({
|
|
24331
|
+
kind: "program",
|
|
24332
|
+
place: {
|
|
24333
|
+
kind: "program",
|
|
24334
|
+
id: p.id
|
|
24335
|
+
},
|
|
24336
|
+
name: p.name
|
|
24337
|
+
});
|
|
24338
|
+
if (kind === "task") return asTask(taskByRef(data, on));
|
|
24339
|
+
if (kind === "project") return asProject(findOne(data.projects, on, "project"));
|
|
24340
|
+
if (kind === "program") return asProgram(findOne(data.programs, on, "program"));
|
|
24341
|
+
const task = data.tasks.find((x) => x.id === on.trim()) ?? findByKey(data, on);
|
|
24342
|
+
if (task) return asTask(task);
|
|
24343
|
+
const projects = exactlyNamed(data.projects, on);
|
|
24344
|
+
const programs = exactlyNamed(data.programs, on);
|
|
24345
|
+
if (projects.length && programs.length) throw new ToolError(`A project and a program are both called "${on.trim()}". Say which: kind project or kind program.`);
|
|
24346
|
+
if (programs.length && !projects.length) return asProgram(findOne(data.programs, on, "program"));
|
|
24347
|
+
try {
|
|
24348
|
+
return asProject(findOne(data.projects, on, "project"));
|
|
24349
|
+
} catch (err) {
|
|
24350
|
+
if (!(err instanceof ToolError) || !/^No project matches/.test(err.message)) throw err;
|
|
24351
|
+
}
|
|
24352
|
+
try {
|
|
24353
|
+
return asProgram(findOne(data.programs, on, "program"));
|
|
24354
|
+
} catch (err) {
|
|
24355
|
+
if (!(err instanceof ToolError) || !/^No program matches/.test(err.message)) throw err;
|
|
24356
|
+
throw new ToolError(`Nothing to chat on called "${on.trim()}": no task key, project or program matches. Try a task key like RR-42, or a project's or program's name.`);
|
|
24357
|
+
}
|
|
24358
|
+
}
|
|
24359
|
+
/** Every line of a chat, oldest first: a task's comments, or a conversation's messages with their numbers. */
|
|
24360
|
+
function chatLines(data, target) {
|
|
24361
|
+
if (target.kind === "task") return data.comments.filter((c) => c.taskId === target.task.id).sort((a, b) => a.createdAt.localeCompare(b.createdAt)).map((c, i) => ({
|
|
24362
|
+
id: c.id,
|
|
24363
|
+
n: i + 1,
|
|
24364
|
+
authorId: c.authorId,
|
|
24365
|
+
body: c.body,
|
|
24366
|
+
at: c.createdAt,
|
|
24367
|
+
editedAt: c.editedAt ?? null,
|
|
24368
|
+
mentionedIds: c.mentionedIds ?? []
|
|
24369
|
+
}));
|
|
24370
|
+
const threads = threadsOf(messagesIn(data.reflections, target.place));
|
|
24371
|
+
const number = new Map(threads.map((t, i) => [t.message.id, i + 1]));
|
|
24372
|
+
const lines = [];
|
|
24373
|
+
for (const t of threads) for (const m of [t.message, ...t.replies]) {
|
|
24374
|
+
const root = m === t.message ? null : t.message.id;
|
|
24375
|
+
lines.push({
|
|
24376
|
+
id: m.id,
|
|
24377
|
+
...root ? { replyTo: {
|
|
24378
|
+
id: root,
|
|
24379
|
+
n: number.get(root)
|
|
24380
|
+
} } : { n: number.get(m.id) },
|
|
24381
|
+
authorId: m.authorId,
|
|
24382
|
+
body: m.body,
|
|
24383
|
+
at: m.createdAt,
|
|
24384
|
+
editedAt: m.editedAt ?? null,
|
|
24385
|
+
mentionedIds: m.mentionedIds ?? []
|
|
24386
|
+
});
|
|
24387
|
+
}
|
|
24388
|
+
return lines.sort((a, b) => a.at.localeCompare(b.at));
|
|
24389
|
+
}
|
|
24390
|
+
/** A chat as the tools give it back: where, and each line with names for ids. */
|
|
24391
|
+
function chatAnswer(data, target, lines) {
|
|
24392
|
+
const people = byId(data.people);
|
|
24393
|
+
return {
|
|
24394
|
+
on: {
|
|
24395
|
+
kind: target.kind,
|
|
24396
|
+
name: target.name,
|
|
24397
|
+
...target.kind === "task" ? {
|
|
24398
|
+
taskId: target.task.id,
|
|
24399
|
+
...target.key ? { key: target.key } : {}
|
|
24400
|
+
} : { id: target.place.id },
|
|
24401
|
+
...target.kind === "task" && target.project ? { project: target.project } : {}
|
|
24402
|
+
},
|
|
24403
|
+
messages: lines.map((l) => ({
|
|
24404
|
+
id: l.id,
|
|
24405
|
+
...l.n ? { n: l.n } : {},
|
|
24406
|
+
from: nameOf$2(people, l.authorId),
|
|
24407
|
+
at: l.at,
|
|
24408
|
+
...l.editedAt ? { edited: l.editedAt } : {},
|
|
24409
|
+
...l.replyTo ? {
|
|
24410
|
+
replyTo: l.replyTo.n,
|
|
24411
|
+
replyToId: l.replyTo.id
|
|
24412
|
+
} : {},
|
|
24413
|
+
body: l.body,
|
|
24414
|
+
...l.mentionedIds.length ? { mentions: l.mentionedIds.map((id) => nameOf$2(people, id)) } : {}
|
|
24415
|
+
}))
|
|
24416
|
+
};
|
|
24417
|
+
}
|
|
24274
24418
|
const HARBOR_TOOLS = [
|
|
24275
24419
|
tool({
|
|
24276
24420
|
name: "harbor_overview",
|
|
@@ -25239,6 +25383,34 @@ const HARBOR_TOOLS = [
|
|
|
25239
25383
|
};
|
|
25240
25384
|
}
|
|
25241
25385
|
}),
|
|
25386
|
+
tool({
|
|
25387
|
+
name: "read_chat",
|
|
25388
|
+
title: "Read the chat on a task, project or program",
|
|
25389
|
+
description: "The conversation on one piece of work, oldest first: a task's comments (on: its key, like RR-42), a project's messages or a program's messages (on: its name). Each line has who wrote it, when, whether it was edited, who it @mentions, and its number n (messages that answer another carry replyTo, that message's number, instead). since leaves out lines written before it, for checking what's new; limit keeps the newest (default 50; more says how many earlier ones were left out). post_chat writes one." + DATA_NOTE,
|
|
25390
|
+
input: object({
|
|
25391
|
+
harbor: harborArg,
|
|
25392
|
+
on: string().min(1).max(200).describe("A task key or id, or a project's or program's name."),
|
|
25393
|
+
kind: _enum(CHAT_KINDS).optional().describe("Only when a project and a program share the name."),
|
|
25394
|
+
since: string().max(40).optional().describe("An ISO time: only lines written after it."),
|
|
25395
|
+
limit: number().int().min(1).max(500).optional()
|
|
25396
|
+
}),
|
|
25397
|
+
run: (ctx, input) => {
|
|
25398
|
+
const { data } = ctx;
|
|
25399
|
+
const target = chatTarget(data, input.on, input.kind);
|
|
25400
|
+
let lines = chatLines(data, target);
|
|
25401
|
+
if (input.since) {
|
|
25402
|
+
const since = Date.parse(input.since);
|
|
25403
|
+
if (!Number.isFinite(since)) throw new ToolError(`since takes an ISO time, not "${input.since}".`);
|
|
25404
|
+
lines = lines.filter((l) => Date.parse(l.at) > since);
|
|
25405
|
+
}
|
|
25406
|
+
const limit = input.limit ?? 50;
|
|
25407
|
+
const shown = lines.slice(-limit);
|
|
25408
|
+
return {
|
|
25409
|
+
...chatAnswer(data, target, shown),
|
|
25410
|
+
...lines.length > shown.length ? { more: lines.length - shown.length } : {}
|
|
25411
|
+
};
|
|
25412
|
+
}
|
|
25413
|
+
}),
|
|
25242
25414
|
tool({
|
|
25243
25415
|
name: "list_soundings",
|
|
25244
25416
|
title: "Soundings",
|
package/lib/cli.mjs
CHANGED
|
@@ -11,7 +11,10 @@ import { login } from "./auth.mjs";
|
|
|
11
11
|
import {
|
|
12
12
|
DEFAULT_SERVER,
|
|
13
13
|
forgetCredentials,
|
|
14
|
+
forgetLastDraft,
|
|
14
15
|
readCredentials,
|
|
16
|
+
readLastDraft,
|
|
17
|
+
writeLastDraft,
|
|
15
18
|
readSettings,
|
|
16
19
|
writeCredentials,
|
|
17
20
|
writeSettings,
|
|
@@ -34,6 +37,9 @@ import {
|
|
|
34
37
|
premortemText,
|
|
35
38
|
notesText,
|
|
36
39
|
messagesText,
|
|
40
|
+
chatText,
|
|
41
|
+
chatLineText,
|
|
42
|
+
chatWhere,
|
|
37
43
|
charterText,
|
|
38
44
|
landfallText,
|
|
39
45
|
loadLineCliText,
|
|
@@ -257,6 +263,10 @@ export const HELP = `harbor: Harbor from the terminal
|
|
|
257
263
|
harbor export harbor [--csv] the whole harbor as JSON (owners)
|
|
258
264
|
harbor import FILE [--project P] [--portfolio P] [--no-people]
|
|
259
265
|
add tasks from a CSV file
|
|
266
|
+
harbor draft "WORDS" --project P|--program P|--portfolio P [--add]
|
|
267
|
+
Harbor's AI drafts tasks, projects
|
|
268
|
+
or programs; harbor draft add adds
|
|
269
|
+
the last one
|
|
260
270
|
harbor premortem PROJECT ["WHAT WENT WRONG"] [--start]
|
|
261
271
|
a project's pre-mortem: start,
|
|
262
272
|
answer or read it
|
|
@@ -265,6 +275,10 @@ export const HELP = `harbor: Harbor from the terminal
|
|
|
265
275
|
harbor messages PROJECT ["TEXT"] [--limit N]
|
|
266
276
|
a project's messages, or write
|
|
267
277
|
one (@Name tells them)
|
|
278
|
+
harbor chat TASK|PROJECT|PROGRAM ["TEXT"] [--reply N] [--watch]
|
|
279
|
+
the conversation on a task,
|
|
280
|
+
project or program: read it,
|
|
281
|
+
write in it, or follow it live
|
|
268
282
|
harbor messages PROJECT --edit "TEXT" [--message ID]
|
|
269
283
|
fix your latest message (or that
|
|
270
284
|
one) in its project
|
|
@@ -409,6 +423,9 @@ function banner(io, env, words) {
|
|
|
409
423
|
}
|
|
410
424
|
|
|
411
425
|
const THEMES = ["auto", "light", "dark"];
|
|
426
|
+
/** harbor chat --watch asks this often while people are talking, and slows to the most once it's quiet. */
|
|
427
|
+
const CHAT_POLL_MS = 5_000;
|
|
428
|
+
const CHAT_POLL_MAX_MS = 30_000;
|
|
412
429
|
|
|
413
430
|
const COMMON = { flags: ["json", "help"], options: ["harbor"] };
|
|
414
431
|
const spec = (flags = [], options = [], repeat = []) => ({
|
|
@@ -581,6 +598,61 @@ export function dueDate(v, today = new Date()) {
|
|
|
581
598
|
return todayLocal(d);
|
|
582
599
|
}
|
|
583
600
|
|
|
601
|
+
/** Where `harbor draft` puts its draft, as draft_plan and add_plan take it. */
|
|
602
|
+
export function draftWhere(values, harbor) {
|
|
603
|
+
const base = harbor ? { harbor } : {};
|
|
604
|
+
if (values.new !== undefined) {
|
|
605
|
+
if (values.new === "program")
|
|
606
|
+
return { ...base, level: "projects", ...(values.portfolio ? { portfolio: values.portfolio } : {}) };
|
|
607
|
+
if (values.new === "portfolio") return { ...base, level: "programs" };
|
|
608
|
+
throw new HarborError("--new is program or portfolio.");
|
|
609
|
+
}
|
|
610
|
+
const given = ["project", "program", "portfolio"].filter((k) => values[k] !== undefined);
|
|
611
|
+
if (given.length !== 1)
|
|
612
|
+
throw new HarborError(
|
|
613
|
+
"Say where it goes: --project P (tasks), --program P (projects), --portfolio P (programs), or --new program|portfolio.",
|
|
614
|
+
);
|
|
615
|
+
const level = { project: "tasks", program: "projects", portfolio: "programs" }[given[0]];
|
|
616
|
+
return { ...base, level, into: values[given[0]] };
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
const draftDue = (days) => (days === 1 ? "due tomorrow" : `due in ${days} days`);
|
|
620
|
+
|
|
621
|
+
/** A draft_plan answer as an indented outline. */
|
|
622
|
+
export function draftText(r) {
|
|
623
|
+
const lines = [];
|
|
624
|
+
const where = r.into
|
|
625
|
+
? ` for ${r.into}`
|
|
626
|
+
: r.level === "projects"
|
|
627
|
+
? ` for a new program${r.portfolio ? ` in ${r.portfolio}` : ""}`
|
|
628
|
+
: r.level === "programs"
|
|
629
|
+
? " for a new portfolio"
|
|
630
|
+
: "";
|
|
631
|
+
lines.push(`Drafted ${r.drafted}${where}:`);
|
|
632
|
+
if (!r.into && r.plan.name) {
|
|
633
|
+
lines.push("", `${r.plan.name}${r.plan.summary ? ` — ${r.plan.summary}` : ""}`);
|
|
634
|
+
}
|
|
635
|
+
const task = (t, pad) =>
|
|
636
|
+
`${pad}· ${t.title} (${draftDue(t.dueInDays)}${t.ownerName ? `, ${t.ownerName}` : ""})`;
|
|
637
|
+
const project = (p, pad) => {
|
|
638
|
+
lines.push(`${pad}${p.name}${p.summary ? ` — ${p.summary}` : ""}`);
|
|
639
|
+
for (const t of p.tasks ?? []) lines.push(task(t, `${pad} `));
|
|
640
|
+
};
|
|
641
|
+
if (r.plan.tasks) {
|
|
642
|
+
lines.push("");
|
|
643
|
+
for (const t of r.plan.tasks) lines.push(task(t, " "));
|
|
644
|
+
}
|
|
645
|
+
for (const p of r.plan.projects ?? []) {
|
|
646
|
+
lines.push("");
|
|
647
|
+
project(p, " ");
|
|
648
|
+
}
|
|
649
|
+
for (const g of r.plan.programs ?? []) {
|
|
650
|
+
lines.push("", ` ${g.name}${g.summary ? ` — ${g.summary}` : ""}`);
|
|
651
|
+
for (const p of g.projects ?? []) project(p, " ");
|
|
652
|
+
}
|
|
653
|
+
return lines.join("\n");
|
|
654
|
+
}
|
|
655
|
+
|
|
584
656
|
/**
|
|
585
657
|
* Each title read in plain words, as the website's new task box reads it:
|
|
586
658
|
* "Book the venue @Quinn by Friday !high #Website". A flag given says that
|
|
@@ -970,14 +1042,16 @@ const DETAIL = {
|
|
|
970
1042
|
" harbor shore PROGRAM --url URL writes: posts go to this Slack, Discord,",
|
|
971
1043
|
" Teams or Google Chat webhook address",
|
|
972
1044
|
" harbor shore PROGRAM --on KINDS writes: turns posts on; KINDS are",
|
|
973
|
-
" forecast, health and
|
|
1045
|
+
" forecast, health, notes and messages,",
|
|
1046
|
+
" with commas",
|
|
974
1047
|
" harbor shore PROGRAM --off KINDS writes: turns them off",
|
|
975
1048
|
" harbor shore PROGRAM --test writes: sends a test post",
|
|
976
1049
|
" harbor shore PROGRAM --remove writes: stops posting and forgets the",
|
|
977
1050
|
" address",
|
|
978
1051
|
"",
|
|
979
1052
|
" forecast is the morning harbor forecast, health a line when the program or",
|
|
980
|
-
" one of its projects changes health, notes a note for later when it opens
|
|
1053
|
+
" one of its projects changes health, notes a note for later when it opens,",
|
|
1054
|
+
" messages each new message or reply on the program or its projects.",
|
|
981
1055
|
" Every post links back to Harbor. A new channel posts nothing until you turn",
|
|
982
1056
|
" something on. The address is a secret: once saved, only a hint of it shows.",
|
|
983
1057
|
],
|
|
@@ -1080,6 +1154,22 @@ const DETAIL = {
|
|
|
1080
1154
|
" --json, rows is one object per row, keyed by column.",
|
|
1081
1155
|
" harbor export harbor > cedar.json keeps a copy of everything.",
|
|
1082
1156
|
],
|
|
1157
|
+
draft: [
|
|
1158
|
+
' harbor draft "WORDS" --project P drafts tasks for a project',
|
|
1159
|
+
' harbor draft "WORDS" --program P drafts projects for a program, each',
|
|
1160
|
+
" with its first tasks",
|
|
1161
|
+
' harbor draft "WORDS" --portfolio P drafts programs for a portfolio, with',
|
|
1162
|
+
" their projects and first tasks",
|
|
1163
|
+
' harbor draft "WORDS" --new program [--portfolio P]',
|
|
1164
|
+
' harbor draft "WORDS" --new portfolio drafts a new program or portfolio and',
|
|
1165
|
+
" what goes in it",
|
|
1166
|
+
" harbor draft add writes: adds the draft shown last",
|
|
1167
|
+
"",
|
|
1168
|
+
" Harbor's own AI drafts from your words and leaves out what's already",
|
|
1169
|
+
" there. Nothing is added until you run harbor draft add (or pass --add to",
|
|
1170
|
+
" draft and add in one go). --ends DAY says when it should all be done.",
|
|
1171
|
+
" Each draft uses one of the harbor's monthly AI drafts.",
|
|
1172
|
+
],
|
|
1083
1173
|
import: [
|
|
1084
1174
|
" harbor import FILE --project P writes: adds the file's tasks",
|
|
1085
1175
|
" harbor import FILE --portfolio P writes: makes projects as the file",
|
|
@@ -1461,6 +1551,24 @@ const DETAIL = {
|
|
|
1461
1551
|
" it explains. The weekly brief names projects that grew a lot since",
|
|
1462
1552
|
" their baseline.",
|
|
1463
1553
|
],
|
|
1554
|
+
chat: [
|
|
1555
|
+
" harbor chat RR-42 reads a task's comments",
|
|
1556
|
+
' harbor chat "Ridge Runner" reads a project\'s messages',
|
|
1557
|
+
" harbor chat Footwear reads a program's messages",
|
|
1558
|
+
' harbor chat RR-42 "TEXT" writes: comments on the task',
|
|
1559
|
+
' harbor chat Footwear "TEXT" --reply 2 writes: replies under message [2]',
|
|
1560
|
+
" harbor chat Footwear --watch follows it live: new lines print as",
|
|
1561
|
+
" they come; in a terminal, type a",
|
|
1562
|
+
' line to post it, "/r N text" to',
|
|
1563
|
+
" reply, Ctrl+C to stop",
|
|
1564
|
+
"",
|
|
1565
|
+
" A task key goes to its comments; a name to that project's messages, or",
|
|
1566
|
+
" the program's when no project has it (--project or --program says which",
|
|
1567
|
+
" when both do). Messages are numbered [1], [2]… with their replies under",
|
|
1568
|
+
" them. @Name sends it to that person's Inbox. Reading shows the newest 50;",
|
|
1569
|
+
" --limit N shows up to 500. --watch asks every 5 seconds while people are",
|
|
1570
|
+
" talking and every 30 once it's quiet.",
|
|
1571
|
+
],
|
|
1464
1572
|
messages: [
|
|
1465
1573
|
" harbor messages PROJECT reads a project's Messages tab",
|
|
1466
1574
|
' harbor messages PROJECT "TEXT" writes: posts to everyone on it',
|
|
@@ -2700,9 +2808,11 @@ export async function run(argv, io = {}) {
|
|
|
2700
2808
|
.split(",")
|
|
2701
2809
|
.map((k) => k.trim().toLowerCase())
|
|
2702
2810
|
.filter(Boolean);
|
|
2703
|
-
const bad = list.find((k) => !["forecast", "health", "notes"].includes(k));
|
|
2811
|
+
const bad = list.find((k) => !["forecast", "health", "notes", "messages"].includes(k));
|
|
2704
2812
|
if (bad || !list.length)
|
|
2705
|
-
throw new HarborError(
|
|
2813
|
+
throw new HarborError(
|
|
2814
|
+
`--${flag} takes forecast, health, notes or messages, with commas between.`,
|
|
2815
|
+
);
|
|
2706
2816
|
return list;
|
|
2707
2817
|
};
|
|
2708
2818
|
const on = kinds("on");
|
|
@@ -2742,10 +2852,11 @@ export async function run(argv, io = {}) {
|
|
|
2742
2852
|
forecast: "morning forecast",
|
|
2743
2853
|
health: "health changes",
|
|
2744
2854
|
notes: "notes when they open",
|
|
2855
|
+
messages: "messages",
|
|
2745
2856
|
};
|
|
2746
|
-
const posts = ["forecast", "health", "notes"].filter((k) => r.hook[k]).map((k) => label[k]);
|
|
2857
|
+
const posts = ["forecast", "health", "notes", "messages"].filter((k) => r.hook[k]).map((k) => label[k]);
|
|
2747
2858
|
const lines = [
|
|
2748
|
-
`${r.program} posts to ${r.hook.service} (${r.hook.hint}): ${posts.length ? posts.join(", ") : "nothing yet; --on forecast,health,notes turns posts on"}.`,
|
|
2859
|
+
`${r.program} posts to ${r.hook.service} (${r.hook.hint}): ${posts.length ? posts.join(", ") : "nothing yet; --on forecast,health,notes,messages turns posts on"}.`,
|
|
2749
2860
|
];
|
|
2750
2861
|
if (r.hook.failures > 0)
|
|
2751
2862
|
lines.push(
|
|
@@ -3364,6 +3475,46 @@ export async function run(argv, io = {}) {
|
|
|
3364
3475
|
(r) => (asJson ? exportData(r) : r),
|
|
3365
3476
|
);
|
|
3366
3477
|
}
|
|
3478
|
+
case "draft": {
|
|
3479
|
+
const { positionals, values, harbor } = parse(
|
|
3480
|
+
spec(["add"], ["project", "program", "portfolio", "new", "ends"]),
|
|
3481
|
+
);
|
|
3482
|
+
if (positionals[0] === "add" && positionals.length === 1) {
|
|
3483
|
+
const last = await readLastDraft(env);
|
|
3484
|
+
if (!last?.plan)
|
|
3485
|
+
throw new HarborError('There\'s no draft to add. Run harbor draft "WORDS" first.');
|
|
3486
|
+
const result = await client.call("add_plan", { ...last.where, ...last.plan });
|
|
3487
|
+
await forgetLastDraft(env);
|
|
3488
|
+
out(asJson ? jsonText(result) : plain(result.added.says));
|
|
3489
|
+
return 0;
|
|
3490
|
+
}
|
|
3491
|
+
const brief = positionals.join(" ").trim();
|
|
3492
|
+
if (!brief)
|
|
3493
|
+
throw new HarborError(
|
|
3494
|
+
'Say what the work is: harbor draft "launch the newsletter" --project NAME.',
|
|
3495
|
+
);
|
|
3496
|
+
const where = draftWhere(values, harbor);
|
|
3497
|
+
const drafted = await client.call("draft_plan", {
|
|
3498
|
+
...where,
|
|
3499
|
+
brief,
|
|
3500
|
+
...(values.ends ? { ends: dueDate(values.ends) } : {}),
|
|
3501
|
+
});
|
|
3502
|
+
const plan = { ...drafted.plan, ...(values.ends ? { ends: dueDate(values.ends) } : {}) };
|
|
3503
|
+
if (values.add) {
|
|
3504
|
+
const result = await client.call("add_plan", { ...where, ...plan });
|
|
3505
|
+
out(asJson ? jsonText({ drafted, ...result }) : plain(`${draftText(drafted)}\n\n${result.added.says}`));
|
|
3506
|
+
return 0;
|
|
3507
|
+
}
|
|
3508
|
+
await writeLastDraft({ where, plan }, env);
|
|
3509
|
+
out(
|
|
3510
|
+
asJson
|
|
3511
|
+
? jsonText(drafted)
|
|
3512
|
+
: plain(
|
|
3513
|
+
`${draftText(drafted)}\n\nNothing is added yet. harbor draft add adds it; drafting again starts afresh.`,
|
|
3514
|
+
),
|
|
3515
|
+
);
|
|
3516
|
+
return 0;
|
|
3517
|
+
}
|
|
3367
3518
|
case "import": {
|
|
3368
3519
|
const { positionals, values, harbor } = parse(spec(["no-people"], ["project", "portfolio"]));
|
|
3369
3520
|
const [file, ...extra] = positionals;
|
|
@@ -4067,6 +4218,131 @@ export async function run(argv, io = {}) {
|
|
|
4067
4218
|
throw new HarborError("--limit is a whole number from 1 to 500.");
|
|
4068
4219
|
return call("list_messages", { harbor, project, ...(limit ? { limit } : {}) }, messagesText);
|
|
4069
4220
|
}
|
|
4221
|
+
case "chat": {
|
|
4222
|
+
const { positionals, values, harbor } = parse(
|
|
4223
|
+
spec(["watch", "task", "project", "program"], ["limit", "reply"]),
|
|
4224
|
+
);
|
|
4225
|
+
const [on, ...words] = positionals;
|
|
4226
|
+
if (!on)
|
|
4227
|
+
throw new HarborError(
|
|
4228
|
+
'Give a task key, project or program, and a message if you\'re writing one: harbor chat RR-42 "TEXT".',
|
|
4229
|
+
);
|
|
4230
|
+
const kinds = ["task", "project", "program"].filter((k) => values[k]);
|
|
4231
|
+
if (kinds.length > 1) throw new HarborError("Say one of --task, --project or --program.");
|
|
4232
|
+
const where = { harbor, on, ...(kinds[0] ? { kind: kinds[0] } : {}) };
|
|
4233
|
+
const quoted = /\s/.test(on) ? `"${on}"` : on;
|
|
4234
|
+
const body = words.join(" ").trim();
|
|
4235
|
+
const limit = values.limit ? Number(values.limit) : undefined;
|
|
4236
|
+
if (limit !== undefined && (!Number.isInteger(limit) || limit < 1 || limit > 500))
|
|
4237
|
+
throw new HarborError("--limit is a whole number from 1 to 500.");
|
|
4238
|
+
const post = (text, replyTo) =>
|
|
4239
|
+
client
|
|
4240
|
+
.call("post_chat", { ...where, body: text, ...(replyTo ? { replyTo } : {}) })
|
|
4241
|
+
.catch((err) => {
|
|
4242
|
+
if (err instanceof HarborError) throw new HarborError(hint(err.message));
|
|
4243
|
+
throw err;
|
|
4244
|
+
});
|
|
4245
|
+
if (body && !values.watch) {
|
|
4246
|
+
if (values.limit) throw new HarborError("--limit is for reading; leave it off when you write.");
|
|
4247
|
+
const r = await post(body, values.reply);
|
|
4248
|
+
if (asJson) {
|
|
4249
|
+
out(jsonText(r));
|
|
4250
|
+
return 0;
|
|
4251
|
+
}
|
|
4252
|
+
const m = r.posted.message;
|
|
4253
|
+
const what = m.replyTo ? `Replied to [${m.replyTo}]` : r.posted.kind === "task" ? "Commented" : `Posted [${m.n}]`;
|
|
4254
|
+
out(plain(`${what} on ${chatWhere(r.posted)}${r.mentioned?.length ? `; told ${r.mentioned.join(", ")}` : ""}.`));
|
|
4255
|
+
return 0;
|
|
4256
|
+
}
|
|
4257
|
+
if (values.reply && !body) throw new HarborError("--reply goes with the words to post.");
|
|
4258
|
+
const read = (n) => client.call("read_chat", { ...where, limit: n }).catch((err) => {
|
|
4259
|
+
if (err instanceof HarborError) throw new HarborError(hint(err.message));
|
|
4260
|
+
throw err;
|
|
4261
|
+
});
|
|
4262
|
+
if (!values.watch) {
|
|
4263
|
+
const r = await read(limit ?? 50);
|
|
4264
|
+
out(asJson ? jsonText(r) : plain(chatText(r, quoted)));
|
|
4265
|
+
return 0;
|
|
4266
|
+
}
|
|
4267
|
+
// --watch: what's there, then each new line as it comes, until Ctrl+C.
|
|
4268
|
+
// It asks every few seconds (no open connection), more slowly while
|
|
4269
|
+
// nothing's said. In a terminal, a line you type is posted; "/r N text"
|
|
4270
|
+
// replies to message N.
|
|
4271
|
+
if (asJson) throw new HarborError("--watch prints lines as they come; leave --json off.");
|
|
4272
|
+
if (body) {
|
|
4273
|
+
const r = await post(body, values.reply);
|
|
4274
|
+
out(plain(`Posted on ${chatWhere(r.posted)}.`));
|
|
4275
|
+
}
|
|
4276
|
+
const first = await read(limit ?? 20);
|
|
4277
|
+
out(plain(chatText(first, quoted)));
|
|
4278
|
+
const seen = new Set(first.messages.map((m) => m.id));
|
|
4279
|
+
const terminal = io.terminal ?? Boolean(process.stdout.isTTY && process.stdin.isTTY);
|
|
4280
|
+
const sleep = io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
|
|
4281
|
+
const task = first.on.kind === "task";
|
|
4282
|
+
out(
|
|
4283
|
+
plain(
|
|
4284
|
+
terminal
|
|
4285
|
+
? `Watching ${chatWhere(first.on)}. Type a line and Enter to post${task ? "" : ', "/r N text" to reply to [N]'}; Ctrl+C stops.`
|
|
4286
|
+
: `Watching ${chatWhere(first.on)}; Ctrl+C stops.`,
|
|
4287
|
+
),
|
|
4288
|
+
);
|
|
4289
|
+
let typing = null;
|
|
4290
|
+
let stopped = false;
|
|
4291
|
+
let delay = CHAT_POLL_MS;
|
|
4292
|
+
if (terminal && (io.stdin ?? process.stdin).isTTY !== false) {
|
|
4293
|
+
const { createInterface } = await import("node:readline");
|
|
4294
|
+
typing = createInterface({ input: io.stdin ?? process.stdin, terminal: false });
|
|
4295
|
+
typing.on("close", () => {
|
|
4296
|
+
stopped = true;
|
|
4297
|
+
});
|
|
4298
|
+
typing.on("line", (line) => {
|
|
4299
|
+
const text = line.trim();
|
|
4300
|
+
if (!text) return;
|
|
4301
|
+
if (text === "/q" || text === "/quit") {
|
|
4302
|
+
typing.close();
|
|
4303
|
+
return;
|
|
4304
|
+
}
|
|
4305
|
+
const reply = /^\/r(?:eply)?\s+(\d+)\s+([\s\S]+)$/.exec(text);
|
|
4306
|
+
if (/^\/r(?:eply)?\b/.test(text) && !reply) {
|
|
4307
|
+
out('To reply: /r N text, where N is the message\'s number in [ ].');
|
|
4308
|
+
return;
|
|
4309
|
+
}
|
|
4310
|
+
post(reply ? reply[2] : text, reply ? reply[1] : undefined).then(
|
|
4311
|
+
(r) => {
|
|
4312
|
+
seen.add(r.posted.message.id);
|
|
4313
|
+
delay = CHAT_POLL_MS;
|
|
4314
|
+
out(plain(` (posted${r.posted.message.n ? ` as [${r.posted.message.n}]` : ""})`));
|
|
4315
|
+
},
|
|
4316
|
+
(err) => out(plain(` Not posted: ${err instanceof Error ? err.message : String(err)}`)),
|
|
4317
|
+
);
|
|
4318
|
+
});
|
|
4319
|
+
}
|
|
4320
|
+
let rounds = io.watchRounds ?? Infinity;
|
|
4321
|
+
try {
|
|
4322
|
+
while (!stopped && rounds-- > 0) {
|
|
4323
|
+
await sleep(delay);
|
|
4324
|
+
if (stopped) break;
|
|
4325
|
+
let r;
|
|
4326
|
+
try {
|
|
4327
|
+
r = await read(50);
|
|
4328
|
+
} catch (err) {
|
|
4329
|
+
// A dropped connection waits and tries again; anything else stops.
|
|
4330
|
+
if (err instanceof HarborError) throw err;
|
|
4331
|
+
delay = CHAT_POLL_MAX_MS;
|
|
4332
|
+
continue;
|
|
4333
|
+
}
|
|
4334
|
+
const fresh = r.messages.filter((m) => !seen.has(m.id));
|
|
4335
|
+
for (const m of fresh) {
|
|
4336
|
+
seen.add(m.id);
|
|
4337
|
+
out(plain(chatLineText(m)));
|
|
4338
|
+
}
|
|
4339
|
+
delay = fresh.length ? CHAT_POLL_MS : Math.min(CHAT_POLL_MAX_MS, Math.round(delay * 1.5));
|
|
4340
|
+
}
|
|
4341
|
+
} finally {
|
|
4342
|
+
typing?.close();
|
|
4343
|
+
}
|
|
4344
|
+
return 0;
|
|
4345
|
+
}
|
|
4070
4346
|
case "watch": {
|
|
4071
4347
|
const { positionals, values, harbor } = parse(spec(["bell", "once"], ["project", "since"]));
|
|
4072
4348
|
none(positionals);
|
package/lib/config.mjs
CHANGED
|
@@ -59,3 +59,23 @@ export async function writeSettings(settings, env = process.env) {
|
|
|
59
59
|
await mkdir(configDir(env), { recursive: true, mode: 0o700 });
|
|
60
60
|
await writeFile(settingsFile(env), JSON.stringify(settings, null, 2));
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
const draftFile = (env) => join(configDir(env), "last-draft.json");
|
|
64
|
+
|
|
65
|
+
/** The last draft `harbor draft` showed, for `harbor draft add`; null when there isn't one. */
|
|
66
|
+
export async function readLastDraft(env = process.env) {
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(await readFile(draftFile(env), "utf8"));
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function writeLastDraft(draft, env = process.env) {
|
|
75
|
+
await mkdir(configDir(env), { recursive: true, mode: 0o700 });
|
|
76
|
+
await writeFile(draftFile(env), JSON.stringify(draft, null, 2), { mode: 0o600 });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function forgetLastDraft(env = process.env) {
|
|
80
|
+
await rm(draftFile(env), { force: true });
|
|
81
|
+
}
|
package/lib/format.mjs
CHANGED
|
@@ -1436,6 +1436,62 @@ export function messagesText(r) {
|
|
|
1436
1436
|
].join("\n\n");
|
|
1437
1437
|
}
|
|
1438
1438
|
|
|
1439
|
+
/** Where a chat is, as its heading says it: "RR-42 Call the printer", "Ridge Runner", "Footwear (program)". */
|
|
1440
|
+
export function chatWhere(on) {
|
|
1441
|
+
if (on.kind === "task") return on.key ? `${on.key} ${on.name}` : on.name;
|
|
1442
|
+
return on.kind === "program" ? `${on.name} (program)` : on.name;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
const chatStamp = (m) => `${m.at.slice(0, 16).replace("T", " ")}${m.edited ? " (edited)" : ""}`;
|
|
1446
|
+
|
|
1447
|
+
/** One new line while watching: "[3] Mara · 2026-11-08 14:10: Launch moved", a reply with ↳. */
|
|
1448
|
+
export function chatLineText(m) {
|
|
1449
|
+
const body = m.body.replace(/\s*\n\s*/g, " / ");
|
|
1450
|
+
const lead = m.replyTo ? ` ↳ [${m.replyTo}]` : m.n ? `[${m.n}]` : "";
|
|
1451
|
+
return `${lead ? `${lead} ` : ""}${m.from ?? "Someone"} · ${chatStamp(m)}: ${body}`;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
/** read_chat: the conversation, each message with its number and its replies under it. */
|
|
1455
|
+
export function chatText(r, quoted) {
|
|
1456
|
+
const where = chatWhere(r.on);
|
|
1457
|
+
const list = r.messages ?? [];
|
|
1458
|
+
const task = r.on.kind === "task";
|
|
1459
|
+
const noun = task ? "comments" : "messages";
|
|
1460
|
+
if (!list.length)
|
|
1461
|
+
return `No ${noun} on ${where} yet. harbor chat ${quoted} "TEXT" writes the first.`;
|
|
1462
|
+
const out = [`${where} · ${noun}`];
|
|
1463
|
+
if (r.more)
|
|
1464
|
+
out.push(
|
|
1465
|
+
`${r.more} earlier ${r.more === 1 ? "line" : "lines"} left out (--limit N shows more).`,
|
|
1466
|
+
);
|
|
1467
|
+
const indent = (text, pad) => text.replace(/\n/g, `\n${pad}`);
|
|
1468
|
+
const shown = new Set(list.filter((m) => m.n).map((m) => m.n));
|
|
1469
|
+
// Replies whose message is older than the lines shown come first, saying what they answer.
|
|
1470
|
+
for (const m of list.filter((x) => x.replyTo && !shown.has(x.replyTo)))
|
|
1471
|
+
out.push(
|
|
1472
|
+
"",
|
|
1473
|
+
` ↳ to [${m.replyTo}] ${m.from ?? "Someone"} · ${chatStamp(m)}`,
|
|
1474
|
+
` ${indent(m.body, " ")}`,
|
|
1475
|
+
);
|
|
1476
|
+
for (const m of list.filter((x) => !x.replyTo)) {
|
|
1477
|
+
out.push(
|
|
1478
|
+
"",
|
|
1479
|
+
`${task ? "" : `[${m.n}] `}${m.from ?? "Someone"} · ${chatStamp(m)}`,
|
|
1480
|
+
` ${indent(m.body, " ")}`,
|
|
1481
|
+
);
|
|
1482
|
+
for (const reply of list.filter((x) => x.replyTo === m.n))
|
|
1483
|
+
out.push(
|
|
1484
|
+
` ↳ ${reply.from ?? "Someone"} · ${chatStamp(reply)}`,
|
|
1485
|
+
` ${indent(reply.body, " ")}`,
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
if (!task) {
|
|
1489
|
+
const first = list.find((m) => m.n)?.n;
|
|
1490
|
+
if (first) out.push("", `--reply ${first} answers message [${first}].`);
|
|
1491
|
+
}
|
|
1492
|
+
return out.join("\n");
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1439
1495
|
const SIGN_OFF = {
|
|
1440
1496
|
pending: "waiting on the sign-off",
|
|
1441
1497
|
approved: "signed off",
|