@harborppm/cli 0.117.0 → 0.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/app.mjs +1280 -226
- package/dist/words.mjs +19 -9
- package/lib/cli.mjs +410 -120
- package/lib/format.mjs +91 -0
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
|
+
import { dirname, join, resolve } from "node:path";
|
|
8
9
|
import { parseArgs } from "./args.mjs";
|
|
9
10
|
import { hasFullAccess, loadApp, tokenSource } from "./app.mjs";
|
|
10
11
|
import { login } from "./auth.mjs";
|
|
@@ -75,10 +76,12 @@ import {
|
|
|
75
76
|
convoysText,
|
|
76
77
|
convoyText,
|
|
77
78
|
saltsText,
|
|
79
|
+
wbsText,
|
|
78
80
|
heedSaltText,
|
|
79
81
|
rankText,
|
|
80
82
|
setRankText,
|
|
81
83
|
agentWorkText,
|
|
84
|
+
agentsText,
|
|
82
85
|
raidDetail,
|
|
83
86
|
raidList,
|
|
84
87
|
reviewList,
|
|
@@ -382,6 +385,9 @@ export const HELP = `harbor: Harbor from the terminal
|
|
|
382
385
|
harbor salts PROJECT [--risk N|--task N|--put-away N]
|
|
383
386
|
old salts: what finished projects
|
|
384
387
|
like it ran into
|
|
388
|
+
harbor wbs PROJECT|PROGRAM|PORTFOLIO [--depth N] [--open]
|
|
389
|
+
the work breakdown: all the work
|
|
390
|
+
under it, numbered 1, 1.1, 1.1.2
|
|
385
391
|
harbor rank PORTFOLIO [--order "A, B, C"|--clear]
|
|
386
392
|
which ship docks first: the
|
|
387
393
|
order a portfolio's projects
|
|
@@ -399,6 +405,11 @@ export const HELP = `harbor: Harbor from the terminal
|
|
|
399
405
|
harbor agent report TASK "WHAT YOU DID" [--start] [--agent NAME]
|
|
400
406
|
the agent's note; moves the task
|
|
401
407
|
to In review (--start: In play)
|
|
408
|
+
harbor agent log "TITLE" --note "WHAT YOU DID" [--project P] [--link URL]
|
|
409
|
+
work nobody gave the agent, handed
|
|
410
|
+
in as a task in review
|
|
411
|
+
harbor agents [--agent NAME] [--project P] every agent's work: for you to
|
|
412
|
+
check, in play, sent back
|
|
402
413
|
|
|
403
414
|
Every command takes --json, and --harbor NAME when you're in more than one
|
|
404
415
|
harbor (or set one with harbor use). harbor help COMMAND shows just that one.
|
|
@@ -585,7 +596,9 @@ async function onlyProject(client, harbor, say = "--project NAME") {
|
|
|
585
596
|
const open = (r.projects ?? []).filter((p) => p.id !== "voyage");
|
|
586
597
|
if (open.length === 1) return open[0].name;
|
|
587
598
|
if (open.length === 0)
|
|
588
|
-
throw new HarborError(
|
|
599
|
+
throw new HarborError(
|
|
600
|
+
'This harbor has no open project yet; harbor project "NAME" --program P makes one.',
|
|
601
|
+
);
|
|
589
602
|
const names = open.slice(0, 3).map((p) => p.name);
|
|
590
603
|
const more = open.length > 3 || r.total > 5 ? ", …" : "";
|
|
591
604
|
throw new HarborError(`Say which project: ${say} (${names.join(", ")}${more}).`);
|
|
@@ -635,7 +648,11 @@ export function draftWhere(values, harbor) {
|
|
|
635
648
|
const base = harbor ? { harbor } : {};
|
|
636
649
|
if (values.new !== undefined) {
|
|
637
650
|
if (values.new === "program")
|
|
638
|
-
return {
|
|
651
|
+
return {
|
|
652
|
+
...base,
|
|
653
|
+
level: "projects",
|
|
654
|
+
...(values.portfolio ? { portfolio: values.portfolio } : {}),
|
|
655
|
+
};
|
|
639
656
|
if (values.new === "portfolio") return { ...base, level: "programs" };
|
|
640
657
|
throw new HarborError("--new is program or portfolio.");
|
|
641
658
|
}
|
|
@@ -772,7 +789,12 @@ function wordsRead(r) {
|
|
|
772
789
|
|
|
773
790
|
/** --due given in words rather than as a date or +N, when it reads as a day. */
|
|
774
791
|
function dueWords(v) {
|
|
775
|
-
if (
|
|
792
|
+
if (
|
|
793
|
+
typeof v !== "string" ||
|
|
794
|
+
/^(\d{4}-\d{2}-\d{2}|\+\d{1,3})$/.test(v) ||
|
|
795
|
+
PILOT.has(v.toLowerCase())
|
|
796
|
+
)
|
|
797
|
+
return false;
|
|
776
798
|
return /^\d{4}-\d{2}-\d{2}$/.test(dueDate(v));
|
|
777
799
|
}
|
|
778
800
|
|
|
@@ -782,7 +804,8 @@ function statusList(typed) {
|
|
|
782
804
|
.split(",")
|
|
783
805
|
.map((x) => x.trim())
|
|
784
806
|
.filter(Boolean);
|
|
785
|
-
if (list.some((x) => x.toLowerCase() === "all"))
|
|
807
|
+
if (list.some((x) => x.toLowerCase() === "all"))
|
|
808
|
+
return ["backlog", "todo", "doing", "review", "done"];
|
|
786
809
|
return list.map(statusWord);
|
|
787
810
|
}
|
|
788
811
|
|
|
@@ -874,7 +897,10 @@ export function hint(message, project) {
|
|
|
874
897
|
(_, list) => `pick one of ${list.replace(/"/g, "").split("|").join(", ")}`,
|
|
875
898
|
)
|
|
876
899
|
// The CLI reads today, tomorrow and +N before Harbor sees the date.
|
|
877
|
-
.replace(
|
|
900
|
+
.replace(
|
|
901
|
+
/^a date as YYYY-MM-DD$/,
|
|
902
|
+
"a date like 2026-11-30, today, tomorrow, friday, next friday or +N days",
|
|
903
|
+
);
|
|
878
904
|
if (!seen.has(flag)) seen.set(flag, said);
|
|
879
905
|
}
|
|
880
906
|
return [...seen].map(([flag, why]) => `${flag}: ${why}`).join("\n");
|
|
@@ -954,7 +980,7 @@ const DETAIL = {
|
|
|
954
980
|
" harbor add --project P < titles.txt writes: one task a line of stdin",
|
|
955
981
|
" harbor add --project P --dry-run reads: says what it would add, and",
|
|
956
982
|
" adds nothing",
|
|
957
|
-
|
|
983
|
+
' harbor add "TITLE" --unless-exists writes: only if no open task in the',
|
|
958
984
|
" project has that title (safe to retry)",
|
|
959
985
|
"",
|
|
960
986
|
" --dry-run asks Harbor to add them on a copy that's thrown away, so it",
|
|
@@ -974,20 +1000,20 @@ const DETAIL = {
|
|
|
974
1000
|
" --project can be left out when the harbor has one open project (First",
|
|
975
1001
|
" voyage aside); the task goes there.",
|
|
976
1002
|
"",
|
|
977
|
-
|
|
978
|
-
|
|
1003
|
+
' Plain words in a title are read as the website reads them: "Book the',
|
|
1004
|
+
' venue @Quinn by friday !high #Website" adds "Book the venue" for',
|
|
979
1005
|
" Quinn, due Friday, high priority, in Website. Harbor says what it read.",
|
|
980
1006
|
" A flag wins over the words (they stay in the title), and --literal keeps",
|
|
981
1007
|
" every title exactly as typed. What's read: a person after @ or \"assign",
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1008
|
+
' to"; a day after by, due, on, before or until, or as the very last',
|
|
1009
|
+
' words ("Call the mill friday"), never after to, for or from ("Move',
|
|
1010
|
+
' the call to Friday" keeps it); !high or "high priority"; #Project.',
|
|
985
1011
|
" An @name that matches nobody stays in the title, and Harbor says so.",
|
|
986
1012
|
" With --dry-run --literal it says what the words would have read as.",
|
|
987
1013
|
"",
|
|
988
|
-
|
|
1014
|
+
' --assignee me|none|NAME, --also "NAME, NAME" (others on it with the',
|
|
989
1015
|
" owner), --due DATE|pilot, --priority low|medium|high|urgent,",
|
|
990
|
-
|
|
1016
|
+
' --status S (backlog, todo, doing, review or done; "in play", "in',
|
|
991
1017
|
" progress\" and the board's other words work too), --comment TEXT and",
|
|
992
1018
|
" --over-limit apply to every task added, so",
|
|
993
1019
|
" ten lines with --comment add the same comment to all ten. More than 100",
|
|
@@ -1491,7 +1517,7 @@ const DETAIL = {
|
|
|
1491
1517
|
" harbor convoy ask PROGRAM … and its answers write them (harbor help convoy).",
|
|
1492
1518
|
],
|
|
1493
1519
|
convoy: [
|
|
1494
|
-
|
|
1520
|
+
' harbor convoy ask PROGRAM --to OTHER --by DATE "WHAT"',
|
|
1495
1521
|
" writes: PROGRAM asks OTHER for WHAT",
|
|
1496
1522
|
" harbor convoy accept CONVOY [--project P]",
|
|
1497
1523
|
" writes: the asked program takes it on,",
|
|
@@ -1507,6 +1533,17 @@ const DETAIL = {
|
|
|
1507
1533
|
" CONVOY is its words (a part is enough when only one matches) or its id from",
|
|
1508
1534
|
" harbor convoys --json. harbor convoys lists them.",
|
|
1509
1535
|
],
|
|
1536
|
+
wbs: [
|
|
1537
|
+
" harbor wbs NAME reads the work breakdown of a project,",
|
|
1538
|
+
" program or portfolio: one numbered line",
|
|
1539
|
+
" each (1, 1.1, 1.1.2) with its owner,",
|
|
1540
|
+
" dates and how much is done, as the",
|
|
1541
|
+
" website's Breakdown view numbers them",
|
|
1542
|
+
" harbor wbs NAME --depth N only N levels down (1: its children)",
|
|
1543
|
+
" harbor wbs NAME --open leaves finished work out (the numbers",
|
|
1544
|
+
" stay as they were)",
|
|
1545
|
+
" harbor wbs NAME --kind program when a project and a program share it",
|
|
1546
|
+
],
|
|
1510
1547
|
salts: [
|
|
1511
1548
|
" harbor salts PROJECT reads what finished projects like it",
|
|
1512
1549
|
" ran into: risks that came true,",
|
|
@@ -1543,7 +1580,7 @@ const DETAIL = {
|
|
|
1543
1580
|
" --json one JSON object a line (at, text, quote, mine, tone;",
|
|
1544
1581
|
" earlier: true for the ones from before it started)",
|
|
1545
1582
|
"",
|
|
1546
|
-
|
|
1583
|
+
' It starts with the latest few changes and a "since HH:MM" line, then',
|
|
1547
1584
|
" prints each new one as it lands. Lines about your own work (your tasks,",
|
|
1548
1585
|
" mentions of you, what you lead) are bright; the rest are dim. It runs",
|
|
1549
1586
|
" until q or Ctrl+C (or until it's killed, when piped or with --json);",
|
|
@@ -1589,12 +1626,30 @@ const DETAIL = {
|
|
|
1589
1626
|
" writes: the note, and moves it to",
|
|
1590
1627
|
" In play",
|
|
1591
1628
|
"",
|
|
1629
|
+
' harbor agent log "TITLE" --note "TEXT" [--project P] [--link URL]',
|
|
1630
|
+
" writes: a task in P for work nobody",
|
|
1631
|
+
" gave the agent, with its note, in",
|
|
1632
|
+
" review for a person to check",
|
|
1633
|
+
"",
|
|
1592
1634
|
" TASK is a task key, like RR-42 (harbor agent lists them), or an id. It",
|
|
1593
1635
|
" has to be assigned to an agent: for anyone else's task, report refuses",
|
|
1594
1636
|
" and nothing changes, so assign it to the agent on the website first.",
|
|
1595
1637
|
" --agent NAME picks the agent when the crew has more than one. An agent",
|
|
1596
1638
|
" never marks its own work Done; a person does, on the website or in the",
|
|
1597
|
-
" terminal app.",
|
|
1639
|
+
" terminal app. log is for work done without a task, like changes in a",
|
|
1640
|
+
" repository: in a folder that ran harbor init it goes to that project",
|
|
1641
|
+
" unless --project says otherwise. An agent logs at most 20 a day.",
|
|
1642
|
+
],
|
|
1643
|
+
agents: [
|
|
1644
|
+
" harbor agents reads every agent's work across the",
|
|
1645
|
+
" harbor: handed in to you, with",
|
|
1646
|
+
" someone else, in play, sent back and",
|
|
1647
|
+
" not picked up, and approved today",
|
|
1648
|
+
" harbor agents --agent NAME one agent's",
|
|
1649
|
+
" harbor agents --project P one project's",
|
|
1650
|
+
"",
|
|
1651
|
+
" The Agents page on the website, as text. harbor approve TASK approves one;",
|
|
1652
|
+
' harbor approve TASK --changes "NOTE" sends it back to the agent.',
|
|
1598
1653
|
],
|
|
1599
1654
|
why: [
|
|
1600
1655
|
" harbor why PROJECT the line of task waits that sets a",
|
|
@@ -1700,8 +1755,8 @@ const DETAIL = {
|
|
|
1700
1755
|
" harbor chats your direct messages, newest first",
|
|
1701
1756
|
"",
|
|
1702
1757
|
" Each with who it's with, what's unread and its last line, and the",
|
|
1703
|
-
|
|
1704
|
-
|
|
1758
|
+
' command that opens it. harbor chat @aya "TEXT" writes to someone;',
|
|
1759
|
+
' harbor chat @aya @ben "TEXT" to a group of just them.',
|
|
1705
1760
|
],
|
|
1706
1761
|
messages: [
|
|
1707
1762
|
" harbor messages PROJECT reads a project's Messages tab",
|
|
@@ -1778,7 +1833,7 @@ const DETAIL = {
|
|
|
1778
1833
|
" newly late or added, risks raised, decisions made. ←→ move between",
|
|
1779
1834
|
" projects; d logs a decision, a an action (who takes it, due in a week),",
|
|
1780
1835
|
" r a risk, m the program's next move, v shows every item behind an",
|
|
1781
|
-
|
|
1836
|
+
' "and N more" (↑↓ scroll); e ends it, Esc or q leaves without ending',
|
|
1782
1837
|
" it. The summary lists what was logged; p posts it to each program's",
|
|
1783
1838
|
" chat channel where one is set (Ship to shore, set on the website), y",
|
|
1784
1839
|
" copies it. The next meeting counts from when this one ended.",
|
|
@@ -1908,24 +1963,49 @@ function distance(a, b) {
|
|
|
1908
1963
|
return d[a.length][b.length];
|
|
1909
1964
|
}
|
|
1910
1965
|
|
|
1966
|
+
/**
|
|
1967
|
+
* The .harbor/harbor.json of the repository (or folder) this runs in, when
|
|
1968
|
+
* harbor init kept it in step with a project; null for a local plan or none.
|
|
1969
|
+
*/
|
|
1970
|
+
export function repoPlanConfig(start) {
|
|
1971
|
+
let dir = resolve(start);
|
|
1972
|
+
for (;;) {
|
|
1973
|
+
try {
|
|
1974
|
+
const config = JSON.parse(readFileSync(join(dir, ".harbor", "harbor.json"), "utf8"));
|
|
1975
|
+
return config && !config.local && config.project?.id ? config : null;
|
|
1976
|
+
} catch {
|
|
1977
|
+
/* not here: look a folder up */
|
|
1978
|
+
}
|
|
1979
|
+
const up = dirname(dir);
|
|
1980
|
+
if (up === dir) return null;
|
|
1981
|
+
dir = up;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1911
1985
|
/** What someone who knows the website, or a feature's name, might type. */
|
|
1912
1986
|
const OTHER_NAMES = {
|
|
1913
1987
|
today: "harbor mine lists what's on you, late first; harbor week plans your days.",
|
|
1914
1988
|
inbox: "harbor catchup says what was handed to you and what moved.",
|
|
1915
|
-
people:
|
|
1989
|
+
people:
|
|
1990
|
+
"harbor lifeboats, harbor clock and harbor ashore cover the crew; the app's People screen (harbor, then 6) shows everyone's load.",
|
|
1916
1991
|
crew: "harbor invite EMAIL brings someone aboard; the app's Crew screen (harbor, then C) lists who's on it.",
|
|
1917
1992
|
longpole: "harbor why PROJECT shows what's holding it up.",
|
|
1918
1993
|
"long-pole": "harbor why PROJECT shows what's holding it up.",
|
|
1919
|
-
pilot:
|
|
1994
|
+
pilot:
|
|
1995
|
+
"harbor show TASK says the date its owner's queue suggests; --due pilot on add or edit takes it.",
|
|
1920
1996
|
dashboards: "harbor reports lists the Reports page's dashboards, each chart as its numbers.",
|
|
1921
|
-
report:
|
|
1997
|
+
report:
|
|
1998
|
+
"harbor report PROGRAM is a program's status report; harbor reports lists the dashboards.",
|
|
1922
1999
|
decide: 'harbor decision "TITLE" --project P logs a decision.',
|
|
1923
2000
|
dock: "harbor try PROJECT is the dry dock; harbor rank PORTFOLIO says which ship docks first.",
|
|
1924
2001
|
"dry-dock": "harbor try PROJECT is the dry dock.",
|
|
1925
2002
|
ranking: "harbor rank PORTFOLIO says which ship docks first.",
|
|
1926
2003
|
salt: "harbor salts PROJECT lists its old salts.",
|
|
1927
2004
|
"old-salts": "harbor salts PROJECT lists its old salts.",
|
|
1928
|
-
|
|
2005
|
+
breakdown: "harbor wbs NAME shows a project, program or portfolio as its work breakdown.",
|
|
2006
|
+
tree: "harbor wbs NAME shows a project, program or portfolio as its work breakdown.",
|
|
2007
|
+
night:
|
|
2008
|
+
"Harbor at night is the portfolio chart room's evening scene for a wall screen, a picture to look at; harbor programs and harbor reports read the same projects.",
|
|
1929
2009
|
};
|
|
1930
2010
|
|
|
1931
2011
|
/** A mistyped command, with the one it was probably meant to be. */
|
|
@@ -2706,7 +2786,11 @@ export async function run(argv, io = {}) {
|
|
|
2706
2786
|
(r) => taskList(r, opts),
|
|
2707
2787
|
(r) =>
|
|
2708
2788
|
r.total > (r.tasks?.length ?? 0)
|
|
2709
|
-
? {
|
|
2789
|
+
? {
|
|
2790
|
+
...r,
|
|
2791
|
+
more: r.total - r.tasks.length,
|
|
2792
|
+
note: "Capped at 20; --all lists every one.",
|
|
2793
|
+
}
|
|
2710
2794
|
: r,
|
|
2711
2795
|
);
|
|
2712
2796
|
// --all pages through every match, PAGE at a time (search_tasks' most).
|
|
@@ -2758,7 +2842,8 @@ export async function run(argv, io = {}) {
|
|
|
2758
2842
|
];
|
|
2759
2843
|
if (t.alsoOn?.length) lines.push(`Also on it: ${t.alsoOn.join(", ")}.`);
|
|
2760
2844
|
if (t.starts) lines.push(`Starts ${t.starts}${t.due ? `, due ${t.due}` : ""}.`);
|
|
2761
|
-
if (t.subtaskOf)
|
|
2845
|
+
if (t.subtaskOf)
|
|
2846
|
+
lines.push(`Subtask of ${t.subtaskOf.key ?? t.subtaskOf.id} ${t.subtaskOf.title}.`);
|
|
2762
2847
|
if (t.milestone)
|
|
2763
2848
|
lines.push(
|
|
2764
2849
|
`Toward the milestone ${t.milestone.name} (${t.milestone.due}): ${t.milestone.reached ? "reached" : `${t.milestone.done} of ${t.milestone.total} of its tasks done`}.`,
|
|
@@ -2784,17 +2869,13 @@ export async function run(argv, io = {}) {
|
|
|
2784
2869
|
lines.push(
|
|
2785
2870
|
"",
|
|
2786
2871
|
"Waits on:",
|
|
2787
|
-
...t.waitingOn.map(
|
|
2788
|
-
(w) => ` ${w.key ?? w.id} ${w.title} (${statusText(w)})`,
|
|
2789
|
-
),
|
|
2872
|
+
...t.waitingOn.map((w) => ` ${w.key ?? w.id} ${w.title} (${statusText(w)})`),
|
|
2790
2873
|
);
|
|
2791
2874
|
if (t.waitedOnBy.length)
|
|
2792
2875
|
lines.push(
|
|
2793
2876
|
"",
|
|
2794
2877
|
"Holds up:",
|
|
2795
|
-
...t.waitedOnBy.map(
|
|
2796
|
-
(w) => ` ${w.key ?? w.id} ${w.title} (${statusText(w)})`,
|
|
2797
|
-
),
|
|
2878
|
+
...t.waitedOnBy.map((w) => ` ${w.key ?? w.id} ${w.title} (${statusText(w)})`),
|
|
2798
2879
|
);
|
|
2799
2880
|
if (t.files?.length) lines.push("", "Files:", ...t.files.map((f) => ` ${fileText(f)}`));
|
|
2800
2881
|
if (t.comments.length)
|
|
@@ -3000,7 +3081,9 @@ export async function run(argv, io = {}) {
|
|
|
3000
3081
|
messages: "messages",
|
|
3001
3082
|
digest: "what changed each morning",
|
|
3002
3083
|
};
|
|
3003
|
-
const posts = ["forecast", "health", "notes", "messages", "digest"]
|
|
3084
|
+
const posts = ["forecast", "health", "notes", "messages", "digest"]
|
|
3085
|
+
.filter((k) => r.hook[k])
|
|
3086
|
+
.map((k) => label[k]);
|
|
3004
3087
|
const lines = [
|
|
3005
3088
|
`${r.program} posts to ${r.hook.service} (${r.hook.hint}): ${posts.length ? posts.join(", ") : "nothing yet; --on forecast,health,notes,messages,digest turns posts on"}.`,
|
|
3006
3089
|
];
|
|
@@ -3021,7 +3104,19 @@ export async function run(argv, io = {}) {
|
|
|
3021
3104
|
const { positionals, values, harbor } = parse(
|
|
3022
3105
|
spec(
|
|
3023
3106
|
["over-limit", "dry-run", "literal", "unless-exists"],
|
|
3024
|
-
[
|
|
3107
|
+
[
|
|
3108
|
+
"project",
|
|
3109
|
+
"assignee",
|
|
3110
|
+
"also",
|
|
3111
|
+
"due",
|
|
3112
|
+
"starts",
|
|
3113
|
+
"priority",
|
|
3114
|
+
"status",
|
|
3115
|
+
"comment",
|
|
3116
|
+
"template",
|
|
3117
|
+
"parent",
|
|
3118
|
+
"milestone",
|
|
3119
|
+
],
|
|
3025
3120
|
),
|
|
3026
3121
|
);
|
|
3027
3122
|
// A subtask goes in its parent's project.
|
|
@@ -3051,9 +3146,16 @@ export async function run(argv, io = {}) {
|
|
|
3051
3146
|
);
|
|
3052
3147
|
// Plain words, as on the website: @person, by Friday, !high, #Project.
|
|
3053
3148
|
// --literal keeps every title exactly as typed.
|
|
3054
|
-
const reads =
|
|
3055
|
-
|
|
3056
|
-
|
|
3149
|
+
const reads =
|
|
3150
|
+
values.literal || fromTemplate
|
|
3151
|
+
? titles.map((title) => ({
|
|
3152
|
+
title,
|
|
3153
|
+
owner: null,
|
|
3154
|
+
due: null,
|
|
3155
|
+
priority: null,
|
|
3156
|
+
project: null,
|
|
3157
|
+
}))
|
|
3158
|
+
: await readTitles(client, harbor, titles, values);
|
|
3057
3159
|
// No --project and no #Project: the harbor's one open project, if that's all there is.
|
|
3058
3160
|
if (!values.project && !reads.every((r) => r.project))
|
|
3059
3161
|
values.project = await onlyProject(client, harbor, "--project NAME or #NAME in the title");
|
|
@@ -3101,7 +3203,8 @@ export async function run(argv, io = {}) {
|
|
|
3101
3203
|
const preview = await client
|
|
3102
3204
|
.call("preview_tasks", { harbor, tasks: reads.map(argsFor) })
|
|
3103
3205
|
.catch((err) => {
|
|
3104
|
-
if (err instanceof HarborError)
|
|
3206
|
+
if (err instanceof HarborError)
|
|
3207
|
+
throw new HarborError(hint(err.message, values.project));
|
|
3105
3208
|
throw err;
|
|
3106
3209
|
});
|
|
3107
3210
|
// --literal: what the words would have read as, so it's plain what it kept.
|
|
@@ -3155,10 +3258,14 @@ export async function run(argv, io = {}) {
|
|
|
3155
3258
|
return [
|
|
3156
3259
|
` ${l.title}${l.skipped ? " (already there, skipped)" : ""}`,
|
|
3157
3260
|
` ${bits.join(" · ")}`,
|
|
3158
|
-
...(wordsLine(words)
|
|
3261
|
+
...(wordsLine(words)
|
|
3262
|
+
? [` ${wordsLine(words)} --literal keeps them in the title.`]
|
|
3263
|
+
: []),
|
|
3159
3264
|
...nobodyLines(words).map((x) => ` ${x}`),
|
|
3160
3265
|
...(l.keptWords
|
|
3161
|
-
? [
|
|
3266
|
+
? [
|
|
3267
|
+
` --literal kept the words as typed. ${wordsLine(unread[i]).replace("Read from your words", "Without it, they'd read as")}`,
|
|
3268
|
+
]
|
|
3162
3269
|
: []),
|
|
3163
3270
|
...(l.comment ? [` with your comment: ${l.comment}`] : []),
|
|
3164
3271
|
...(l.sameAs && !l.skipped
|
|
@@ -3181,15 +3288,13 @@ export async function run(argv, io = {}) {
|
|
|
3181
3288
|
}
|
|
3182
3289
|
const added = [];
|
|
3183
3290
|
for (const [i, words] of reads.entries()) {
|
|
3184
|
-
const r = await client
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
throw err;
|
|
3192
|
-
});
|
|
3291
|
+
const r = await client.call("create_task", { harbor, ...argsFor(words) }).catch((err) => {
|
|
3292
|
+
if (err instanceof HarborError) {
|
|
3293
|
+
const done = added.length ? ` (added ${added.length} before it)` : "";
|
|
3294
|
+
throw new HarborError(`${hint(err.message, projectOf(words))}${done}`);
|
|
3295
|
+
}
|
|
3296
|
+
throw err;
|
|
3297
|
+
});
|
|
3193
3298
|
// --unless-exists found it open already: nothing added, no comment.
|
|
3194
3299
|
if (r.existing) {
|
|
3195
3300
|
added.push(r);
|
|
@@ -3218,7 +3323,11 @@ export async function run(argv, io = {}) {
|
|
|
3218
3323
|
if (asJson) {
|
|
3219
3324
|
const tasks = added.map((r, i) =>
|
|
3220
3325
|
r.existing
|
|
3221
|
-
? {
|
|
3326
|
+
? {
|
|
3327
|
+
...taskEntry(r.existing, titles[i]),
|
|
3328
|
+
sameAs: r.existing.key ?? r.existing.id,
|
|
3329
|
+
skipped: true,
|
|
3330
|
+
}
|
|
3222
3331
|
: {
|
|
3223
3332
|
...taskEntry(r.created, titles[i]),
|
|
3224
3333
|
...(values.template ? { template: values.template } : {}),
|
|
@@ -3241,8 +3350,7 @@ export async function run(argv, io = {}) {
|
|
|
3241
3350
|
...(made.length === 1 && added.length === 1 ? { created: made[0].created } : {}),
|
|
3242
3351
|
}),
|
|
3243
3352
|
);
|
|
3244
|
-
}
|
|
3245
|
-
else
|
|
3353
|
+
} else
|
|
3246
3354
|
out(
|
|
3247
3355
|
plain(
|
|
3248
3356
|
added
|
|
@@ -3250,20 +3358,26 @@ export async function run(argv, io = {}) {
|
|
|
3250
3358
|
r.existing
|
|
3251
3359
|
? `Already there, not added again: ${taskLine(r.existing, opts)}`
|
|
3252
3360
|
: [
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3361
|
+
`Added: ${taskLine(r.created, opts)}${r.comment ? ", with your comment" : ""}`,
|
|
3362
|
+
// What the title's words said, so nothing is read without being seen.
|
|
3363
|
+
...(r.read
|
|
3364
|
+
? [
|
|
3365
|
+
`You typed “${r.read.typed}”. ${wordsLine(reads[added.indexOf(r)])} --literal keeps the words in the title.`,
|
|
3366
|
+
]
|
|
3367
|
+
: []),
|
|
3368
|
+
...nobodyLines({ nobody: r.unknownPeople }),
|
|
3369
|
+
// --due in words ("next friday"): the day it became, weekday and all.
|
|
3370
|
+
...(dueWords(values.due)
|
|
3371
|
+
? [`--due ${values.due}: ${dayWithWeekday(dueDate(values.due))}.`]
|
|
3372
|
+
: []),
|
|
3373
|
+
// Pilot speaks up only when a date was given that the queue says won't hold.
|
|
3374
|
+
...(values.due ? pilotLines(r, r.created) : []),
|
|
3375
|
+
...(r.created.milestone
|
|
3376
|
+
? [`Toward the milestone ${r.created.milestone}.`]
|
|
3377
|
+
: []),
|
|
3378
|
+
...(r.milestoneReopened
|
|
3379
|
+
? [`${r.milestoneReopened} is open again: it has an open task now.`]
|
|
3380
|
+
: []),
|
|
3267
3381
|
].join("\n"),
|
|
3268
3382
|
)
|
|
3269
3383
|
.join("\n"),
|
|
@@ -3330,8 +3444,12 @@ export async function run(argv, io = {}) {
|
|
|
3330
3444
|
[
|
|
3331
3445
|
`${r.updated.title}: ${r.reopened ? "reopened, " : ""}${{ doing: "started", review: "in review", done: "done" }[status]}.`,
|
|
3332
3446
|
r.queuedNext ? `Next one: ${taskLine(r.queuedNext, opts)}` : "",
|
|
3333
|
-
r.milestoneReached
|
|
3334
|
-
|
|
3447
|
+
r.milestoneReached
|
|
3448
|
+
? `That was the last of its tasks: ${r.milestoneReached} is reached.`
|
|
3449
|
+
: "",
|
|
3450
|
+
r.milestoneReopened
|
|
3451
|
+
? `${r.milestoneReopened} is open again: one of its tasks is open.`
|
|
3452
|
+
: "",
|
|
3335
3453
|
r.projectFinished
|
|
3336
3454
|
? `That was the last open task in ${r.projectFinished}. Mark the project Done in the app (harbor) or on the website.`
|
|
3337
3455
|
: "",
|
|
@@ -3411,8 +3529,12 @@ export async function run(argv, io = {}) {
|
|
|
3411
3529
|
? `Toward the milestone ${r.updated.milestone}.`
|
|
3412
3530
|
: "Not tied to a milestone now."
|
|
3413
3531
|
: null,
|
|
3414
|
-
r.milestoneReached
|
|
3415
|
-
|
|
3532
|
+
r.milestoneReached
|
|
3533
|
+
? `That was the last of its tasks: ${r.milestoneReached} is reached.`
|
|
3534
|
+
: null,
|
|
3535
|
+
r.milestoneReopened
|
|
3536
|
+
? `${r.milestoneReopened} is open again: one of its tasks is open.`
|
|
3537
|
+
: null,
|
|
3416
3538
|
values.also !== undefined
|
|
3417
3539
|
? r.updated.alsoOn?.length
|
|
3418
3540
|
? `Also on it: ${r.updated.alsoOn.join(", ")}.`
|
|
@@ -3527,7 +3649,10 @@ export async function run(argv, io = {}) {
|
|
|
3527
3649
|
let zone = values.zone;
|
|
3528
3650
|
if (zone?.toLowerCase() === "here") {
|
|
3529
3651
|
zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
3530
|
-
if (!zone)
|
|
3652
|
+
if (!zone)
|
|
3653
|
+
throw new HarborError(
|
|
3654
|
+
"This machine doesn't say its time zone. Give one, like --zone Europe/London.",
|
|
3655
|
+
);
|
|
3531
3656
|
}
|
|
3532
3657
|
let starts;
|
|
3533
3658
|
let ends;
|
|
@@ -3536,13 +3661,10 @@ export async function run(argv, io = {}) {
|
|
|
3536
3661
|
if (!m) throw new HarborError("--hours is a start and an end, like 9-17 or 8:30-16:30.");
|
|
3537
3662
|
[, starts, ends] = m;
|
|
3538
3663
|
}
|
|
3539
|
-
return call(
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
r.zone
|
|
3544
|
-
? `${r.person}: ${r.zone.replace(/_/g, " ")}, ${r.hours} on weekdays. ${r.working ? `Working now (${r.localTime} there).` : (r.picksUp ?? "")}`.trim()
|
|
3545
|
-
: `${r.person} has no time zone now.`,
|
|
3664
|
+
return call("set_clock", { harbor, person: who || "me", zone, starts, ends }, (r) =>
|
|
3665
|
+
r.zone
|
|
3666
|
+
? `${r.person}: ${r.zone.replace(/_/g, " ")}, ${r.hours} on weekdays. ${r.working ? `Working now (${r.localTime} there).` : (r.picksUp ?? "")}`.trim()
|
|
3667
|
+
: `${r.person} has no time zone now.`,
|
|
3546
3668
|
);
|
|
3547
3669
|
}
|
|
3548
3670
|
case "checkin": {
|
|
@@ -3670,7 +3792,11 @@ export async function run(argv, io = {}) {
|
|
|
3670
3792
|
const plan = { ...drafted.plan, ...(values.ends ? { ends: dueDate(values.ends) } : {}) };
|
|
3671
3793
|
if (values.add) {
|
|
3672
3794
|
const result = await client.call("add_plan", { ...where, ...plan });
|
|
3673
|
-
out(
|
|
3795
|
+
out(
|
|
3796
|
+
asJson
|
|
3797
|
+
? jsonText({ drafted, ...result })
|
|
3798
|
+
: plain(`${draftText(drafted)}\n\n${result.added.says}`),
|
|
3799
|
+
);
|
|
3674
3800
|
return 0;
|
|
3675
3801
|
}
|
|
3676
3802
|
await writeLastDraft({ where, plan }, env);
|
|
@@ -4015,7 +4141,9 @@ export async function run(argv, io = {}) {
|
|
|
4015
4141
|
const { positionals, harbor } = parse(spec());
|
|
4016
4142
|
const [task, field, ...value] = positionals;
|
|
4017
4143
|
if (!task || !field)
|
|
4018
|
-
throw new HarborError(
|
|
4144
|
+
throw new HarborError(
|
|
4145
|
+
'Give a task, a field and a value, like harbor field RR-4 Size L (or "" to clear).',
|
|
4146
|
+
);
|
|
4019
4147
|
return call("set_field", { harbor, task, field, value: value.join(" ") }, (r) => {
|
|
4020
4148
|
const name = r.set.key ?? r.set.title;
|
|
4021
4149
|
const said = Object.entries(r.set.fields ?? {}).find(
|
|
@@ -4061,7 +4189,8 @@ export async function run(argv, io = {}) {
|
|
|
4061
4189
|
),
|
|
4062
4190
|
);
|
|
4063
4191
|
const name = text(positionals, "the milestone");
|
|
4064
|
-
if (values.reached && values.open)
|
|
4192
|
+
if (values.reached && values.open)
|
|
4193
|
+
throw new HarborError("Say --reached or --open, not both.");
|
|
4065
4194
|
const changes =
|
|
4066
4195
|
values.new ||
|
|
4067
4196
|
values.reached ||
|
|
@@ -4070,10 +4199,16 @@ export async function run(argv, io = {}) {
|
|
|
4070
4199
|
["due", "rename", "signs-off", "changes"].some((k) => values[k] !== undefined);
|
|
4071
4200
|
if (!changes) {
|
|
4072
4201
|
// Reading one: the program's (or harbor's) milestones, reached ones too.
|
|
4073
|
-
const r = await client.call("list_milestones", {
|
|
4202
|
+
const r = await client.call("list_milestones", {
|
|
4203
|
+
harbor,
|
|
4204
|
+
program: values.program,
|
|
4205
|
+
done: true,
|
|
4206
|
+
});
|
|
4074
4207
|
const want = name.toLowerCase();
|
|
4075
4208
|
const same = r.milestones.filter((m) => m.name.toLowerCase() === want);
|
|
4076
|
-
const near = same.length
|
|
4209
|
+
const near = same.length
|
|
4210
|
+
? same
|
|
4211
|
+
: r.milestones.filter((m) => m.name.toLowerCase().includes(want));
|
|
4077
4212
|
if (near.length !== 1)
|
|
4078
4213
|
throw new HarborError(
|
|
4079
4214
|
near.length
|
|
@@ -4098,14 +4233,32 @@ export async function run(argv, io = {}) {
|
|
|
4098
4233
|
approve: values.approve || undefined,
|
|
4099
4234
|
changes: values.changes,
|
|
4100
4235
|
},
|
|
4101
|
-
(r) =>
|
|
4236
|
+
(r) =>
|
|
4237
|
+
r.added
|
|
4238
|
+
? `Added to ${r.added.program}: ${milestoneLine(r.added, { program: false })}`
|
|
4239
|
+
: milestoneLine(r.milestone),
|
|
4102
4240
|
);
|
|
4103
4241
|
}
|
|
4104
4242
|
case "goal": {
|
|
4105
4243
|
const { positionals, values, harbor } = parse(
|
|
4106
4244
|
spec(
|
|
4107
4245
|
["new"],
|
|
4108
|
-
[
|
|
4246
|
+
[
|
|
4247
|
+
"portfolio",
|
|
4248
|
+
"title",
|
|
4249
|
+
"owner",
|
|
4250
|
+
"due",
|
|
4251
|
+
"starts",
|
|
4252
|
+
"why",
|
|
4253
|
+
"link",
|
|
4254
|
+
"unlink",
|
|
4255
|
+
"kr",
|
|
4256
|
+
"at",
|
|
4257
|
+
"target",
|
|
4258
|
+
"start",
|
|
4259
|
+
"unit",
|
|
4260
|
+
"counts",
|
|
4261
|
+
],
|
|
4109
4262
|
),
|
|
4110
4263
|
);
|
|
4111
4264
|
const ref = text(positionals, "the goal");
|
|
@@ -4124,10 +4277,20 @@ export async function run(argv, io = {}) {
|
|
|
4124
4277
|
.map((x) => x.trim())
|
|
4125
4278
|
.filter(Boolean);
|
|
4126
4279
|
const day = (flag) =>
|
|
4127
|
-
values[flag] === undefined
|
|
4280
|
+
values[flag] === undefined
|
|
4281
|
+
? undefined
|
|
4282
|
+
: /^none$/i.test(values[flag])
|
|
4283
|
+
? "none"
|
|
4284
|
+
: dueDate(values[flag]);
|
|
4128
4285
|
if (values.new) {
|
|
4129
|
-
if (
|
|
4130
|
-
|
|
4286
|
+
if (
|
|
4287
|
+
values.kr &&
|
|
4288
|
+
(values.at !== undefined || values.counts === undefined) &&
|
|
4289
|
+
values.target === undefined
|
|
4290
|
+
)
|
|
4291
|
+
throw new HarborError(
|
|
4292
|
+
"A new number key result needs --target N (or --counts WORK for work).",
|
|
4293
|
+
);
|
|
4131
4294
|
return call(
|
|
4132
4295
|
"set_goal",
|
|
4133
4296
|
{
|
|
@@ -4141,16 +4304,28 @@ export async function run(argv, io = {}) {
|
|
|
4141
4304
|
? [
|
|
4142
4305
|
values.counts !== undefined
|
|
4143
4306
|
? { title: values.kr, kind: "work", counts: list("counts") }
|
|
4144
|
-
: {
|
|
4307
|
+
: {
|
|
4308
|
+
title: values.kr,
|
|
4309
|
+
kind: "number",
|
|
4310
|
+
start: num("start"),
|
|
4311
|
+
target: num("target"),
|
|
4312
|
+
unit: values.unit,
|
|
4313
|
+
},
|
|
4145
4314
|
]
|
|
4146
4315
|
: [],
|
|
4147
4316
|
},
|
|
4148
|
-
(r) =>
|
|
4317
|
+
(r) =>
|
|
4318
|
+
`Set on ${r.goal.portfolio}: ${r.goal.title} (${r.goal.progress}).${r.goal.keyResults.length ? "" : ` Add a key result with harbor goal "${r.goal.title}" --kr "TITLE" --target N.`}`,
|
|
4149
4319
|
);
|
|
4150
4320
|
}
|
|
4151
4321
|
// The goal as Harbor has it, for its id and key results.
|
|
4152
|
-
const goals = await client.call("list_goals", {
|
|
4153
|
-
|
|
4322
|
+
const goals = await client.call("list_goals", {
|
|
4323
|
+
harbor,
|
|
4324
|
+
...(values.portfolio ? { portfolio: values.portfolio } : {}),
|
|
4325
|
+
});
|
|
4326
|
+
const all = (goals.portfolios ?? []).flatMap((pf) =>
|
|
4327
|
+
(pf.goals ?? []).map((g) => ({ pf, g })),
|
|
4328
|
+
);
|
|
4154
4329
|
const want = ref.trim().toLowerCase();
|
|
4155
4330
|
const exact = all.filter((x) => x.g.title.trim().toLowerCase() === want || x.g.id === ref);
|
|
4156
4331
|
const near = exact.length ? exact : all.filter((x) => x.g.title.toLowerCase().includes(want));
|
|
@@ -4161,12 +4336,17 @@ export async function run(argv, io = {}) {
|
|
|
4161
4336
|
: `No goal matches "${ref}".${all.length ? ` harbor goals lists them.` : ` Set one with harbor goal "TITLE" --new.`}`,
|
|
4162
4337
|
);
|
|
4163
4338
|
const { pf, g } = near[0];
|
|
4164
|
-
const edits = ["title", "owner", "due", "starts", "why", "link", "unlink"].some(
|
|
4339
|
+
const edits = ["title", "owner", "due", "starts", "why", "link", "unlink"].some(
|
|
4340
|
+
(k) => values[k] !== undefined,
|
|
4341
|
+
);
|
|
4165
4342
|
if (!values.kr && !edits) {
|
|
4166
4343
|
out(asJson ? jsonText({ goal: g, portfolio: pf.name }) : plain(goalText(g, pf.name)));
|
|
4167
4344
|
return 0;
|
|
4168
4345
|
}
|
|
4169
|
-
if (
|
|
4346
|
+
if (
|
|
4347
|
+
!values.kr &&
|
|
4348
|
+
["at", "target", "start", "unit", "counts"].some((k) => values[k] !== undefined)
|
|
4349
|
+
)
|
|
4170
4350
|
throw new HarborError('Say which key result with --kr "TITLE".');
|
|
4171
4351
|
const results = [];
|
|
4172
4352
|
if (edits)
|
|
@@ -4184,7 +4364,9 @@ export async function run(argv, io = {}) {
|
|
|
4184
4364
|
}),
|
|
4185
4365
|
);
|
|
4186
4366
|
if (values.kr) {
|
|
4187
|
-
const kr = g.keyResults.find(
|
|
4367
|
+
const kr = g.keyResults.find(
|
|
4368
|
+
(k) => k.title.trim().toLowerCase() === values.kr.trim().toLowerCase(),
|
|
4369
|
+
);
|
|
4188
4370
|
const shape = ["target", "start", "unit"].some((k) => values[k] !== undefined);
|
|
4189
4371
|
if (!kr) {
|
|
4190
4372
|
if (values.at !== undefined && !shape)
|
|
@@ -4192,7 +4374,9 @@ export async function run(argv, io = {}) {
|
|
|
4192
4374
|
`"${g.title}" has no key result "${values.kr}"${g.keyResults.length ? ` (it has ${g.keyResults.map((k) => `"${k.title}"`).join(", ")})` : ""}. --target N adds one.`,
|
|
4193
4375
|
);
|
|
4194
4376
|
if (values.counts === undefined && values.target === undefined)
|
|
4195
|
-
throw new HarborError(
|
|
4377
|
+
throw new HarborError(
|
|
4378
|
+
"A new key result needs --target N for a number, or --counts WORK to count work.",
|
|
4379
|
+
);
|
|
4196
4380
|
results.push(
|
|
4197
4381
|
await client.call("set_goal", {
|
|
4198
4382
|
harbor,
|
|
@@ -4201,7 +4385,13 @@ export async function run(argv, io = {}) {
|
|
|
4201
4385
|
keyResults: [
|
|
4202
4386
|
values.counts !== undefined
|
|
4203
4387
|
? { title: values.kr, kind: "work", counts: list("counts") }
|
|
4204
|
-
: {
|
|
4388
|
+
: {
|
|
4389
|
+
title: values.kr,
|
|
4390
|
+
kind: "number",
|
|
4391
|
+
start: num("start"),
|
|
4392
|
+
target: num("target"),
|
|
4393
|
+
unit: values.unit,
|
|
4394
|
+
},
|
|
4205
4395
|
],
|
|
4206
4396
|
}),
|
|
4207
4397
|
);
|
|
@@ -4211,7 +4401,12 @@ export async function run(argv, io = {}) {
|
|
|
4211
4401
|
await client.call("edit_goal", {
|
|
4212
4402
|
harbor,
|
|
4213
4403
|
goal: g.id,
|
|
4214
|
-
keyResult: {
|
|
4404
|
+
keyResult: {
|
|
4405
|
+
ref: kr.id,
|
|
4406
|
+
start: num("start"),
|
|
4407
|
+
target: num("target"),
|
|
4408
|
+
unit: values.unit,
|
|
4409
|
+
},
|
|
4215
4410
|
...(values.counts !== undefined ? { link: list("counts") } : {}),
|
|
4216
4411
|
}),
|
|
4217
4412
|
);
|
|
@@ -4219,11 +4414,18 @@ export async function run(argv, io = {}) {
|
|
|
4219
4414
|
if (kr.kind !== "number")
|
|
4220
4415
|
throw new HarborError(`"${kr.title}" counts work, so it moves as its tasks finish.`);
|
|
4221
4416
|
results.push(
|
|
4222
|
-
await client.call("update_key_result", {
|
|
4417
|
+
await client.call("update_key_result", {
|
|
4418
|
+
harbor,
|
|
4419
|
+
goal: g.id,
|
|
4420
|
+
keyResult: kr.id,
|
|
4421
|
+
value: num("at"),
|
|
4422
|
+
}),
|
|
4223
4423
|
);
|
|
4224
4424
|
}
|
|
4225
4425
|
if (values.at === undefined && !shape && values.counts === undefined)
|
|
4226
|
-
throw new HarborError(
|
|
4426
|
+
throw new HarborError(
|
|
4427
|
+
`Say what to do with "${kr.title}": --at N, or --target N to change its numbers.`,
|
|
4428
|
+
);
|
|
4227
4429
|
}
|
|
4228
4430
|
}
|
|
4229
4431
|
const last = results.at(-1);
|
|
@@ -4310,7 +4512,11 @@ export async function run(argv, io = {}) {
|
|
|
4310
4512
|
throw new HarborError("--hours is a whole number from 1 to 168.");
|
|
4311
4513
|
return call(
|
|
4312
4514
|
"daily_digest",
|
|
4313
|
-
{
|
|
4515
|
+
{
|
|
4516
|
+
harbor,
|
|
4517
|
+
...(values.program ? { program: values.program } : {}),
|
|
4518
|
+
...(hours ? { hours } : {}),
|
|
4519
|
+
},
|
|
4314
4520
|
(r) => digestText(r, hours),
|
|
4315
4521
|
);
|
|
4316
4522
|
}
|
|
@@ -4373,9 +4579,11 @@ export async function run(argv, io = {}) {
|
|
|
4373
4579
|
const body = words.join(" ").trim();
|
|
4374
4580
|
if (values.edit !== undefined || values.message !== undefined) {
|
|
4375
4581
|
const edit = (values.edit ?? "").trim() || body;
|
|
4376
|
-
if (!edit)
|
|
4582
|
+
if (!edit)
|
|
4583
|
+
throw new HarborError('Say the new words: harbor messages "NAME" --edit "TEXT".');
|
|
4377
4584
|
if (values.edit && body) throw new HarborError("Give the new words once, after --edit.");
|
|
4378
|
-
if (values.limit)
|
|
4585
|
+
if (values.limit)
|
|
4586
|
+
throw new HarborError("--limit is for reading; leave it off when you edit.");
|
|
4379
4587
|
return call(
|
|
4380
4588
|
"edit_message",
|
|
4381
4589
|
{ harbor, project, body: edit, ...(values.message ? { message: values.message } : {}) },
|
|
@@ -4411,10 +4619,11 @@ export async function run(argv, io = {}) {
|
|
|
4411
4619
|
throw new HarborError(
|
|
4412
4620
|
"--task, --project, --program and --reply are for the talk on the work, not direct messages.",
|
|
4413
4621
|
);
|
|
4414
|
-
const who = ats.length
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4622
|
+
const who = ats.length ? { harbor, with: ats.join(",") } : { harbor, chat: positionals[0] };
|
|
4623
|
+
const text = positionals
|
|
4624
|
+
.slice(ats.length || 1)
|
|
4625
|
+
.join(" ")
|
|
4626
|
+
.trim();
|
|
4418
4627
|
const call = (name, args) =>
|
|
4419
4628
|
client.call(name, { ...who, ...args }).catch((err) => {
|
|
4420
4629
|
if (err instanceof HarborError) throw new HarborError(hint(err.message));
|
|
@@ -4467,7 +4676,8 @@ export async function run(argv, io = {}) {
|
|
|
4467
4676
|
wait = CHAT_POLL_MS;
|
|
4468
4677
|
out(" (sent)");
|
|
4469
4678
|
},
|
|
4470
|
-
(err) =>
|
|
4679
|
+
(err) =>
|
|
4680
|
+
out(plain(` Not sent: ${err instanceof Error ? err.message : String(err)}`)),
|
|
4471
4681
|
);
|
|
4472
4682
|
});
|
|
4473
4683
|
}
|
|
@@ -4522,22 +4732,32 @@ export async function run(argv, io = {}) {
|
|
|
4522
4732
|
throw err;
|
|
4523
4733
|
});
|
|
4524
4734
|
if (body && !values.watch) {
|
|
4525
|
-
if (values.limit)
|
|
4735
|
+
if (values.limit)
|
|
4736
|
+
throw new HarborError("--limit is for reading; leave it off when you write.");
|
|
4526
4737
|
const r = await post(body, values.reply);
|
|
4527
4738
|
if (asJson) {
|
|
4528
4739
|
out(jsonText(r));
|
|
4529
4740
|
return 0;
|
|
4530
4741
|
}
|
|
4531
4742
|
const m = r.posted.message;
|
|
4532
|
-
const what = m.replyTo
|
|
4533
|
-
|
|
4743
|
+
const what = m.replyTo
|
|
4744
|
+
? `Replied to [${m.replyTo}]`
|
|
4745
|
+
: r.posted.kind === "task"
|
|
4746
|
+
? "Commented"
|
|
4747
|
+
: `Posted [${m.n}]`;
|
|
4748
|
+
out(
|
|
4749
|
+
plain(
|
|
4750
|
+
`${what} on ${chatWhere(r.posted)}${r.mentioned?.length ? `; told ${r.mentioned.join(", ")}` : ""}.`,
|
|
4751
|
+
),
|
|
4752
|
+
);
|
|
4534
4753
|
return 0;
|
|
4535
4754
|
}
|
|
4536
4755
|
if (values.reply && !body) throw new HarborError("--reply goes with the words to post.");
|
|
4537
|
-
const read = (n) =>
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4756
|
+
const read = (n) =>
|
|
4757
|
+
client.call("read_chat", { ...where, limit: n }).catch((err) => {
|
|
4758
|
+
if (err instanceof HarborError) throw new HarborError(hint(err.message));
|
|
4759
|
+
throw err;
|
|
4760
|
+
});
|
|
4541
4761
|
if (!values.watch) {
|
|
4542
4762
|
const r = await read(limit ?? 50);
|
|
4543
4763
|
out(asJson ? jsonText(r) : plain(chatText(r, quoted)));
|
|
@@ -4583,7 +4803,7 @@ export async function run(argv, io = {}) {
|
|
|
4583
4803
|
}
|
|
4584
4804
|
const reply = /^\/r(?:eply)?\s+(\d+)\s+([\s\S]+)$/.exec(text);
|
|
4585
4805
|
if (/^\/r(?:eply)?\b/.test(text) && !reply) {
|
|
4586
|
-
out(
|
|
4806
|
+
out("To reply: /r N text, where N is the message's number in [ ].");
|
|
4587
4807
|
return;
|
|
4588
4808
|
}
|
|
4589
4809
|
post(reply ? reply[2] : text, reply ? reply[1] : undefined).then(
|
|
@@ -4592,7 +4812,8 @@ export async function run(argv, io = {}) {
|
|
|
4592
4812
|
delay = CHAT_POLL_MS;
|
|
4593
4813
|
out(plain(` (posted${r.posted.message.n ? ` as [${r.posted.message.n}]` : ""})`));
|
|
4594
4814
|
},
|
|
4595
|
-
(err) =>
|
|
4815
|
+
(err) =>
|
|
4816
|
+
out(plain(` Not posted: ${err instanceof Error ? err.message : String(err)}`)),
|
|
4596
4817
|
);
|
|
4597
4818
|
});
|
|
4598
4819
|
}
|
|
@@ -4704,7 +4925,9 @@ export async function run(argv, io = {}) {
|
|
|
4704
4925
|
throw new HarborError(`--why goes with scuttling: harbor scuttle PROJECT --why "TEXT".`);
|
|
4705
4926
|
const project = one(rest, "project");
|
|
4706
4927
|
if (first === "sail" && (values.end !== undefined || values.note !== undefined))
|
|
4707
|
-
throw new HarborError(
|
|
4928
|
+
throw new HarborError(
|
|
4929
|
+
"--end and --note go with a refit: harbor scuttle refit PROJECT --end DATE.",
|
|
4930
|
+
);
|
|
4708
4931
|
if (first === "refit" && values.end === undefined && values.note === undefined)
|
|
4709
4932
|
throw new HarborError('A refit needs --end DATE or --note "what changes".');
|
|
4710
4933
|
return call(
|
|
@@ -4788,6 +5011,32 @@ export async function run(argv, io = {}) {
|
|
|
4788
5011
|
convoyText,
|
|
4789
5012
|
);
|
|
4790
5013
|
}
|
|
5014
|
+
case "wbs": {
|
|
5015
|
+
const { positionals, values, harbor } = parse(spec(["open"], ["depth", "kind", "offset"]));
|
|
5016
|
+
const of = text(positionals, "which project, program or portfolio");
|
|
5017
|
+
const depth = values.depth === undefined ? undefined : Number(values.depth);
|
|
5018
|
+
if (depth !== undefined && !(Number.isInteger(depth) && depth >= 1 && depth <= 4))
|
|
5019
|
+
throw new HarborError("--depth takes 1 to 4: how many levels under it to show.");
|
|
5020
|
+
const kind = values.kind?.trim().toLowerCase();
|
|
5021
|
+
if (kind !== undefined && !["project", "program", "portfolio"].includes(kind))
|
|
5022
|
+
throw new HarborError("--kind takes project, program or portfolio.");
|
|
5023
|
+
const offset = values.offset === undefined ? 0 : Number(values.offset);
|
|
5024
|
+
if (!(Number.isInteger(offset) && offset >= 0))
|
|
5025
|
+
throw new HarborError("--offset takes a whole number of lines to skip.");
|
|
5026
|
+
return call(
|
|
5027
|
+
"work_breakdown",
|
|
5028
|
+
{
|
|
5029
|
+
harbor,
|
|
5030
|
+
of,
|
|
5031
|
+
...(kind ? { kind } : {}),
|
|
5032
|
+
...(depth ? { depth } : {}),
|
|
5033
|
+
...(values.open ? { open: true } : {}),
|
|
5034
|
+
...(offset ? { offset } : {}),
|
|
5035
|
+
limit: 1000,
|
|
5036
|
+
},
|
|
5037
|
+
wbsText,
|
|
5038
|
+
);
|
|
5039
|
+
}
|
|
4791
5040
|
case "salts": {
|
|
4792
5041
|
const { positionals, values, harbor } = parse(spec([], ["risk", "task", "put-away"]));
|
|
4793
5042
|
const project = text(positionals, "which project");
|
|
@@ -4806,7 +5055,8 @@ export async function run(argv, io = {}) {
|
|
|
4806
5055
|
const portfolio = text(positionals, "which portfolio");
|
|
4807
5056
|
if (values.clear && values.order !== undefined)
|
|
4808
5057
|
throw new HarborError("--order or --clear, not both.");
|
|
4809
|
-
if (values.clear)
|
|
5058
|
+
if (values.clear)
|
|
5059
|
+
return call("set_dock_order", { harbor, portfolio, clear: true }, setRankText);
|
|
4810
5060
|
if (values.order !== undefined) {
|
|
4811
5061
|
const projects = values.order
|
|
4812
5062
|
.split(",")
|
|
@@ -4847,7 +5097,8 @@ export async function run(argv, io = {}) {
|
|
|
4847
5097
|
'Say what for and the line: harbor thanks RR-42 "Caught it before launch" (or --milestone NAME, --decision TITLE).',
|
|
4848
5098
|
);
|
|
4849
5099
|
}
|
|
4850
|
-
if (!line)
|
|
5100
|
+
if (!line)
|
|
5101
|
+
throw new HarborError('Add the line of thanks in quotes: harbor thanks RR-42 "Thank you".');
|
|
4851
5102
|
return call(
|
|
4852
5103
|
"give_thanks",
|
|
4853
5104
|
{
|
|
@@ -4897,8 +5148,47 @@ export async function run(argv, io = {}) {
|
|
|
4897
5148
|
},
|
|
4898
5149
|
);
|
|
4899
5150
|
}
|
|
5151
|
+
case "agents": {
|
|
5152
|
+
const { positionals, values, harbor } = parse(spec([], ["agent", "project"]));
|
|
5153
|
+
none(positionals);
|
|
5154
|
+
return call(
|
|
5155
|
+
"agents_overview",
|
|
5156
|
+
{ harbor, agent: values.agent, project: values.project },
|
|
5157
|
+
agentsText,
|
|
5158
|
+
);
|
|
5159
|
+
}
|
|
4900
5160
|
case "agent": {
|
|
4901
|
-
const { positionals, values, harbor } = parse(
|
|
5161
|
+
const { positionals, values, harbor } = parse(
|
|
5162
|
+
spec(["start"], ["agent", "project", "note", "link"]),
|
|
5163
|
+
);
|
|
5164
|
+
if (positionals[0] === "log") {
|
|
5165
|
+
const title = positionals.slice(1).join(" ").trim();
|
|
5166
|
+
const note = (values.note ?? "").trim();
|
|
5167
|
+
if (!title || !note)
|
|
5168
|
+
throw new HarborError(
|
|
5169
|
+
'Give a title and what the agent did: harbor agent log "Rebuilt the pricing page" --note "Moved the plans into one table".',
|
|
5170
|
+
);
|
|
5171
|
+
// In a repository that ran harbor init, the work goes to that project.
|
|
5172
|
+
const plan = values.project ? null : repoPlanConfig(io.cwd ?? process.cwd());
|
|
5173
|
+
const project = values.project ?? plan?.project?.id;
|
|
5174
|
+
if (!project)
|
|
5175
|
+
throw new HarborError(
|
|
5176
|
+
'Say which project: harbor agent log "TITLE" --note "TEXT" --project NAME (or run it in a folder that ran harbor init).',
|
|
5177
|
+
);
|
|
5178
|
+
return call(
|
|
5179
|
+
"agent_report",
|
|
5180
|
+
{
|
|
5181
|
+
harbor: harbor ?? plan?.harbor?.id,
|
|
5182
|
+
project,
|
|
5183
|
+
title,
|
|
5184
|
+
note,
|
|
5185
|
+
link: values.link,
|
|
5186
|
+
agent: values.agent,
|
|
5187
|
+
},
|
|
5188
|
+
(r) =>
|
|
5189
|
+
`${r.created.key ?? r.created.title} is in review for a person to check, with ${r.commentedAs}'s note.${r.toCheck ? ` ${r.toCheck}` : ""}`,
|
|
5190
|
+
);
|
|
5191
|
+
}
|
|
4902
5192
|
if (positionals[0] !== "report") {
|
|
4903
5193
|
none(positionals);
|
|
4904
5194
|
return call("agent_work", { harbor, agent: values.agent }, agentWorkText);
|