@harborppm/cli 0.101.0 → 0.102.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/dist/app.mjs +247 -27
- package/lib/cli.mjs +26 -0
- package/lib/format.mjs +25 -0
- package/package.json +1 -1
package/dist/app.mjs
CHANGED
|
@@ -262,6 +262,20 @@ function tasksByProject(tasks) {
|
|
|
262
262
|
function tasksOf(tasks, projectId) {
|
|
263
263
|
return tasksByProject(tasks).get(projectId) ?? EMPTY;
|
|
264
264
|
}
|
|
265
|
+
/** Open (not done) tasks grouped by who holds them; unheld ones under "". Read-only. */
|
|
266
|
+
function openTasksByAssignee(tasks) {
|
|
267
|
+
return cached$1(assigneeTasks, tasks, () => {
|
|
268
|
+
const out = /* @__PURE__ */ new Map();
|
|
269
|
+
for (const t of tasks) {
|
|
270
|
+
if (t.status === "done") continue;
|
|
271
|
+
const key = t.assigneeId ?? "";
|
|
272
|
+
const list = out.get(key);
|
|
273
|
+
if (list) list.push(t);
|
|
274
|
+
else out.set(key, [t]);
|
|
275
|
+
}
|
|
276
|
+
return out;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
265
279
|
/** For each task id, the tasks that wait on it. */
|
|
266
280
|
function waitersByBlocker(tasks) {
|
|
267
281
|
return cached$1(waiting, tasks, () => {
|
|
@@ -304,12 +318,13 @@ function childrenByParent(tasks) {
|
|
|
304
318
|
return out;
|
|
305
319
|
});
|
|
306
320
|
}
|
|
307
|
-
var ids$1, projectTasks$1, EMPTY, waiting, positions, children;
|
|
321
|
+
var ids$1, projectTasks$1, EMPTY, assigneeTasks, waiting, positions, children;
|
|
308
322
|
var init_indexes = __esmMin((() => {
|
|
309
323
|
init_blockers();
|
|
310
324
|
ids$1 = /* @__PURE__ */ new WeakMap();
|
|
311
325
|
projectTasks$1 = /* @__PURE__ */ new WeakMap();
|
|
312
326
|
EMPTY = Object.freeze([]);
|
|
327
|
+
assigneeTasks = /* @__PURE__ */ new WeakMap();
|
|
313
328
|
waiting = /* @__PURE__ */ new WeakMap();
|
|
314
329
|
positions = /* @__PURE__ */ new WeakMap();
|
|
315
330
|
children = /* @__PURE__ */ new WeakMap();
|
|
@@ -2816,7 +2831,7 @@ function weekOf(day = todayISO()) {
|
|
|
2816
2831
|
const d = at$1(day);
|
|
2817
2832
|
const wd = d.getDay();
|
|
2818
2833
|
const back = wd === 0 ? -1 : wd === 6 ? -2 : wd - 1;
|
|
2819
|
-
return iso$
|
|
2834
|
+
return iso$5(addDays(d, -back));
|
|
2820
2835
|
}
|
|
2821
2836
|
/** Monday to Friday of the week starting `monday`. */
|
|
2822
2837
|
function weekDays(monday) {
|
|
@@ -2827,10 +2842,10 @@ function weekDays(monday) {
|
|
|
2827
2842
|
2,
|
|
2828
2843
|
3,
|
|
2829
2844
|
4
|
|
2830
|
-
].map((i) => iso$
|
|
2845
|
+
].map((i) => iso$5(addDays(d, i)));
|
|
2831
2846
|
}
|
|
2832
2847
|
function shiftWeek(monday, weeks) {
|
|
2833
|
-
return iso$
|
|
2848
|
+
return iso$5(addDays(at$1(monday), weeks * 7));
|
|
2834
2849
|
}
|
|
2835
2850
|
/** Whether a week should read back how it went: from its Friday on. */
|
|
2836
2851
|
function isReviewTime(monday, today = todayISO()) {
|
|
@@ -2879,7 +2894,7 @@ function weekPlan(data, personId, monday) {
|
|
|
2879
2894
|
function weekReview(data, personId, monday) {
|
|
2880
2895
|
const plan = weekPlan(data, personId, monday);
|
|
2881
2896
|
const first = plan.days[0].date;
|
|
2882
|
-
const sunday = iso$
|
|
2897
|
+
const sunday = iso$5(addDays(at$1(monday), 6));
|
|
2883
2898
|
const doneInWeek = (t) => t.status === "done" && Boolean(t.completedAt) && todayISO(new Date(t.completedAt)) >= first && todayISO(new Date(t.completedAt)) <= sunday;
|
|
2884
2899
|
const hoursBy = /* @__PURE__ */ new Map();
|
|
2885
2900
|
for (const d of plan.days) for (const i of d.items) {
|
|
@@ -2919,7 +2934,7 @@ function stalePlacements(data, personId, today = todayISO()) {
|
|
|
2919
2934
|
const cutoff = shiftWeek(weekOf(today), -12);
|
|
2920
2935
|
return new Set(placementsOf(data, personId).filter((r) => (r.date ?? "") < cutoff).map((r) => r.id));
|
|
2921
2936
|
}
|
|
2922
|
-
var DAY_HOURS, DEFAULT_HOURS$1, MIN_HOURS, MAX_HOURS, HOUR_CHOICES, isPassage, iso$
|
|
2937
|
+
var DAY_HOURS, DEFAULT_HOURS$1, MIN_HOURS, MAX_HOURS, HOUR_CHOICES, isPassage, iso$5, at$1, byDue, DAY_WORDS;
|
|
2923
2938
|
var init_passage = __esmMin((() => {
|
|
2924
2939
|
init_date_fns();
|
|
2925
2940
|
init_date_text();
|
|
@@ -2940,7 +2955,7 @@ var init_passage = __esmMin((() => {
|
|
|
2940
2955
|
8
|
|
2941
2956
|
];
|
|
2942
2957
|
isPassage = (r) => r.kind === "passage";
|
|
2943
|
-
iso$
|
|
2958
|
+
iso$5 = (d) => todayISO(d);
|
|
2944
2959
|
at$1 = (day) => parseIso(`${day}T12:00:00`);
|
|
2945
2960
|
byDue = (a, b) => (a.dueDate ?? "9999").localeCompare(b.dueDate ?? "9999");
|
|
2946
2961
|
DAY_WORDS = [
|
|
@@ -3329,16 +3344,16 @@ function easter(year) {
|
|
|
3329
3344
|
const m = Math.floor((a + 11 * h + 22 * l) / 451);
|
|
3330
3345
|
const month = Math.floor((h + l - 7 * m + 114) / 31);
|
|
3331
3346
|
const day = (h + l - 7 * m + 114) % 31 + 1;
|
|
3332
|
-
return iso$
|
|
3347
|
+
return iso$4(year, month, day);
|
|
3333
3348
|
}
|
|
3334
3349
|
/** The nth given weekday (0 Sunday) of a month; n = -1 for the last. */
|
|
3335
3350
|
function nth(year, month, dow, n) {
|
|
3336
3351
|
if (n > 0) {
|
|
3337
|
-
const first = iso$
|
|
3352
|
+
const first = iso$4(year, month, 1);
|
|
3338
3353
|
const shift = (dow - weekday$1(first) + 7) % 7;
|
|
3339
3354
|
return plus$1(first, shift + (n - 1) * 7);
|
|
3340
3355
|
}
|
|
3341
|
-
const last = iso$
|
|
3356
|
+
const last = iso$4(year, month + 1, 0);
|
|
3342
3357
|
return plus$1(last, -((weekday$1(last) - dow + 7) % 7));
|
|
3343
3358
|
}
|
|
3344
3359
|
/** A country's public holidays in a year, by the day they're taken, oldest first. */
|
|
@@ -3454,12 +3469,12 @@ function harborHolidays(data, from, to) {
|
|
|
3454
3469
|
};
|
|
3455
3470
|
});
|
|
3456
3471
|
}
|
|
3457
|
-
var iso$
|
|
3472
|
+
var iso$4, weekday$1, plus$1, isWeekend, onOrBefore, fixed, fromEaster, MATARIKI, RULES, cache, PLAIN_CALENDAR;
|
|
3458
3473
|
var init_holidays = __esmMin((() => {
|
|
3459
3474
|
init_date_fns();
|
|
3460
3475
|
init_format();
|
|
3461
3476
|
init_countries();
|
|
3462
|
-
iso$
|
|
3477
|
+
iso$4 = (y, m, d) => todayISO(new Date(y, m - 1, d, 12));
|
|
3463
3478
|
weekday$1 = (day) => (/* @__PURE__ */ new Date(`${day}T12:00:00`)).getDay();
|
|
3464
3479
|
plus$1 = (day, n) => todayISO(addDays(/* @__PURE__ */ new Date(`${day}T12:00:00`), n));
|
|
3465
3480
|
isWeekend = (day) => {
|
|
@@ -3467,7 +3482,7 @@ var init_holidays = __esmMin((() => {
|
|
|
3467
3482
|
return wd === 0 || wd === 6;
|
|
3468
3483
|
};
|
|
3469
3484
|
onOrBefore = (day, dow) => plus$1(day, -((weekday$1(day) - dow + 7) % 7));
|
|
3470
|
-
fixed = (m, d) => (y) => iso$
|
|
3485
|
+
fixed = (m, d) => (y) => iso$4(y, m, d);
|
|
3471
3486
|
fromEaster = (n) => (y) => plus$1(easter(y), n);
|
|
3472
3487
|
MATARIKI = {
|
|
3473
3488
|
2025: "2025-06-20",
|
|
@@ -3517,7 +3532,7 @@ var init_holidays = __esmMin((() => {
|
|
|
3517
3532
|
"next"
|
|
3518
3533
|
],
|
|
3519
3534
|
["Good Friday", fromEaster(-2)],
|
|
3520
|
-
["Victoria Day", (y) => onOrBefore(iso$
|
|
3535
|
+
["Victoria Day", (y) => onOrBefore(iso$4(y, 5, 24), 1)],
|
|
3521
3536
|
[
|
|
3522
3537
|
"Canada Day",
|
|
3523
3538
|
fixed(7, 1),
|
|
@@ -3564,7 +3579,7 @@ var init_holidays = __esmMin((() => {
|
|
|
3564
3579
|
fixed(1, 1),
|
|
3565
3580
|
"next"
|
|
3566
3581
|
],
|
|
3567
|
-
["St Brigid's Day", (y) => weekday$1(iso$
|
|
3582
|
+
["St Brigid's Day", (y) => weekday$1(iso$4(y, 2, 1)) === 5 ? iso$4(y, 2, 1) : nth(y, 2, 1, 1)],
|
|
3568
3583
|
[
|
|
3569
3584
|
"St Patrick's Day",
|
|
3570
3585
|
fixed(3, 17),
|
|
@@ -3676,7 +3691,7 @@ var init_holidays = __esmMin((() => {
|
|
|
3676
3691
|
NL: [
|
|
3677
3692
|
["Nieuwjaarsdag", fixed(1, 1)],
|
|
3678
3693
|
["Tweede paasdag", fromEaster(1)],
|
|
3679
|
-
["Koningsdag", (y) => weekday$1(iso$
|
|
3694
|
+
["Koningsdag", (y) => weekday$1(iso$4(y, 4, 27)) === 0 ? iso$4(y, 4, 26) : iso$4(y, 4, 27)],
|
|
3680
3695
|
["Hemelvaartsdag", fromEaster(39)],
|
|
3681
3696
|
["Tweede pinksterdag", fromEaster(50)],
|
|
3682
3697
|
["Eerste kerstdag", fixed(12, 25)],
|
|
@@ -9580,7 +9595,7 @@ function programIsBlocked(data, program) {
|
|
|
9580
9595
|
}
|
|
9581
9596
|
function daysOverdue(dueDate, now) {
|
|
9582
9597
|
if (!dueDate) return 0;
|
|
9583
|
-
const today = iso$
|
|
9598
|
+
const today = iso$3(now);
|
|
9584
9599
|
if (today !== overdueDay) {
|
|
9585
9600
|
overdueDay = today;
|
|
9586
9601
|
overdueByDue.clear();
|
|
@@ -9599,7 +9614,7 @@ function daysOverdue(dueDate, now) {
|
|
|
9599
9614
|
}
|
|
9600
9615
|
function daysUntil$1(date, now) {
|
|
9601
9616
|
if (!date) return null;
|
|
9602
|
-
const today = iso$
|
|
9617
|
+
const today = iso$3(now);
|
|
9603
9618
|
if (today !== untilDay) {
|
|
9604
9619
|
untilDay = today;
|
|
9605
9620
|
untilByDate.clear();
|
|
@@ -9664,7 +9679,7 @@ function effectiveProjectHealth(project, data, now) {
|
|
|
9664
9679
|
}
|
|
9665
9680
|
/** Milestones past their date and still open. */
|
|
9666
9681
|
function lateMilestonesOf(milestones, now) {
|
|
9667
|
-
const today = iso$
|
|
9682
|
+
const today = iso$3(now);
|
|
9668
9683
|
return milestones.filter((m) => !m.done && m.dueDate < today);
|
|
9669
9684
|
}
|
|
9670
9685
|
/**
|
|
@@ -9789,7 +9804,7 @@ function programLateCount(programId, data, now) {
|
|
|
9789
9804
|
for (const p of data.projects) if (p.programId === programId) late += lateTasksOf([...tasksOf(data.tasks, p.id)], now).length;
|
|
9790
9805
|
return late;
|
|
9791
9806
|
}
|
|
9792
|
-
var iso$
|
|
9807
|
+
var iso$3, overdueDay, overdueByDue, untilDay, untilByDate;
|
|
9793
9808
|
var init_derived_health = __esmMin((() => {
|
|
9794
9809
|
init_date_fns();
|
|
9795
9810
|
init_date_text();
|
|
@@ -9797,7 +9812,7 @@ var init_derived_health = __esmMin((() => {
|
|
|
9797
9812
|
init_indexes();
|
|
9798
9813
|
init_health_history();
|
|
9799
9814
|
init_clock();
|
|
9800
|
-
iso$
|
|
9815
|
+
iso$3 = (d) => {
|
|
9801
9816
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
9802
9817
|
};
|
|
9803
9818
|
overdueDay = "";
|
|
@@ -12926,13 +12941,13 @@ function InboxView({ active, width, height, go }) {
|
|
|
12926
12941
|
/** Open tasks for one person, bucketed by the week they are due, plus what is already late or has no date. */
|
|
12927
12942
|
function weeklyLoad(tasks, personId, now, weeks = 6, calendar) {
|
|
12928
12943
|
const mine = tasks.filter((t) => t.assigneeId === personId && t.status !== "done");
|
|
12929
|
-
const today = iso$
|
|
12944
|
+
const today = iso$2(now);
|
|
12930
12945
|
const origin = startOfWeek(now, { weekStartsOn: 1 });
|
|
12931
12946
|
const buckets = Array.from({ length: weeks }, (_, i) => {
|
|
12932
|
-
const start = iso$
|
|
12947
|
+
const start = iso$2(addDays(origin, i * 7));
|
|
12933
12948
|
const off = [];
|
|
12934
12949
|
if (calendar?.active) for (let d = 0; d < 5; d++) {
|
|
12935
|
-
const date = iso$
|
|
12950
|
+
const date = iso$2(addDays(origin, i * 7 + d));
|
|
12936
12951
|
const why = calendar.offOn(personId, date);
|
|
12937
12952
|
if (why) off.push({
|
|
12938
12953
|
date,
|
|
@@ -12967,10 +12982,19 @@ function weeklyLoad(tasks, personId, now, weeks = 6, calendar) {
|
|
|
12967
12982
|
weeks: buckets
|
|
12968
12983
|
};
|
|
12969
12984
|
}
|
|
12970
|
-
|
|
12985
|
+
/** A week's capacity, less the weekdays someone is off: 5 a week with two days off is 3. */
|
|
12986
|
+
function weekCapacity(capacity, workDays) {
|
|
12987
|
+
return Math.round(capacity * Math.max(0, Math.min(5, workDays)) / 5 * 10) / 10;
|
|
12988
|
+
}
|
|
12989
|
+
/** Capacity a person has for one program, given the share of their week promised to it. */
|
|
12990
|
+
function allocatedCapacity(weeklyCapacity, percent) {
|
|
12991
|
+
return Math.max(0, Math.round((weeklyCapacity ?? 5) * percent / 100 * 10) / 10);
|
|
12992
|
+
}
|
|
12993
|
+
var DEFAULT_WEEKLY_CAPACITY, iso$2;
|
|
12971
12994
|
var init_load = __esmMin((() => {
|
|
12972
12995
|
init_date_fns();
|
|
12973
|
-
|
|
12996
|
+
DEFAULT_WEEKLY_CAPACITY = 5;
|
|
12997
|
+
iso$2 = (d) => {
|
|
12974
12998
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
12975
12999
|
};
|
|
12976
13000
|
}));
|
|
@@ -16146,6 +16170,158 @@ function dueFrom(value, now) {
|
|
|
16146
16170
|
throw new CommandError(`Can't read the date "${value}". Try today, fri, +3 or 2026-11-02.`);
|
|
16147
16171
|
}
|
|
16148
16172
|
|
|
16173
|
+
// src/lib/load-line.ts
|
|
16174
|
+
init_date_fns();
|
|
16175
|
+
init_load();
|
|
16176
|
+
init_indexes();
|
|
16177
|
+
/** The weeks a load line looks at: this one and the two after. */
|
|
16178
|
+
const LOAD_LINE_WEEKS = 3;
|
|
16179
|
+
const iso$1 = (d) => {
|
|
16180
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
16181
|
+
};
|
|
16182
|
+
/** The window: today, and the last day of the last week looked at (a Sunday). */
|
|
16183
|
+
function loadWindow(now, weeks = 3) {
|
|
16184
|
+
const monday = startOfWeek(now, { weekStartsOn: 1 });
|
|
16185
|
+
return {
|
|
16186
|
+
today: iso$1(now),
|
|
16187
|
+
monday,
|
|
16188
|
+
end: iso$1(addDays(monday, weeks * 7 - 1))
|
|
16189
|
+
};
|
|
16190
|
+
}
|
|
16191
|
+
/**
|
|
16192
|
+
* Weekdays a person is off in the window, by week: from the harbor's
|
|
16193
|
+
* calendar when given (holidays and time away), else their time away alone,
|
|
16194
|
+
* so a picker that doesn't load the holiday rules still sees someone away.
|
|
16195
|
+
*/
|
|
16196
|
+
function offByWeek(calendar, person, monday, weeks) {
|
|
16197
|
+
const away = person.away?.until && person.away.since ? [person.away.since.slice(0, 10), person.away.until.slice(0, 10)] : null;
|
|
16198
|
+
return Array.from({ length: weeks }, (_, w) => {
|
|
16199
|
+
let off = 0;
|
|
16200
|
+
for (let d = 0; d < 5; d++) {
|
|
16201
|
+
const day = iso$1(addDays(monday, w * 7 + d));
|
|
16202
|
+
if (calendar?.active) {
|
|
16203
|
+
if (calendar.offOn(person.id, day)) off += 1;
|
|
16204
|
+
} else if (away && day >= away[0] && day < away[1]) off += 1;
|
|
16205
|
+
}
|
|
16206
|
+
return off;
|
|
16207
|
+
});
|
|
16208
|
+
}
|
|
16209
|
+
function line(cargo, late, capacity, daysOff, undated) {
|
|
16210
|
+
const ratio = cargo === 0 ? 0 : capacity <= 0 ? Number.POSITIVE_INFINITY : cargo / capacity;
|
|
16211
|
+
const tenth = (n) => Math.round(n * 10) / 10;
|
|
16212
|
+
return {
|
|
16213
|
+
cargo,
|
|
16214
|
+
late,
|
|
16215
|
+
capacity: tenth(capacity),
|
|
16216
|
+
ratio,
|
|
16217
|
+
over: tenth(Math.max(0, cargo - capacity)),
|
|
16218
|
+
room: tenth(Math.max(0, capacity - cargo)),
|
|
16219
|
+
daysOff,
|
|
16220
|
+
undated
|
|
16221
|
+
};
|
|
16222
|
+
}
|
|
16223
|
+
/** Count a person's open work: late, due in the window, and undated. */
|
|
16224
|
+
function countWork(tasks, today, end) {
|
|
16225
|
+
let late = 0;
|
|
16226
|
+
let due = 0;
|
|
16227
|
+
let undated = 0;
|
|
16228
|
+
for (const t of tasks) {
|
|
16229
|
+
if (t.status === "done") continue;
|
|
16230
|
+
const d = t.dueDate?.slice(0, 10);
|
|
16231
|
+
if (!d) undated += 1;
|
|
16232
|
+
else if (d < today) late += 1;
|
|
16233
|
+
else if (d <= end) due += 1;
|
|
16234
|
+
}
|
|
16235
|
+
return {
|
|
16236
|
+
late,
|
|
16237
|
+
due,
|
|
16238
|
+
undated
|
|
16239
|
+
};
|
|
16240
|
+
}
|
|
16241
|
+
/**
|
|
16242
|
+
* One person's load line. Null for an agent on the crew: an app has no
|
|
16243
|
+
* week to fill.
|
|
16244
|
+
*/
|
|
16245
|
+
function personLoadLine(data, person, now, calendar, weeks = 3) {
|
|
16246
|
+
if (person.kind === "agent") return null;
|
|
16247
|
+
const { today, monday, end } = loadWindow(now, weeks);
|
|
16248
|
+
const { late, due, undated } = countWork(openTasksByAssignee(data.tasks).get(person.id) ?? [], today, end);
|
|
16249
|
+
const pace = person.weeklyCapacity ?? 5;
|
|
16250
|
+
const off = offByWeek(calendar, person, monday, weeks);
|
|
16251
|
+
const capacity = off.reduce((sum, o) => sum + weekCapacity(pace, 5 - o), 0);
|
|
16252
|
+
return line(late + due, late, capacity, off.reduce((a, b) => a + b, 0), undated);
|
|
16253
|
+
}
|
|
16254
|
+
/**
|
|
16255
|
+
* A program's load line: the crew time promised to it against its open
|
|
16256
|
+
* work in the window. Null while nobody's time is promised to it, since
|
|
16257
|
+
* there's no line to draw.
|
|
16258
|
+
*/
|
|
16259
|
+
function programLoadLine(data, programId, now, calendar, weeks = 3) {
|
|
16260
|
+
const { today, monday, end } = loadWindow(now, weeks);
|
|
16261
|
+
let capacity = 0;
|
|
16262
|
+
let daysOff = 0;
|
|
16263
|
+
let crew = 0;
|
|
16264
|
+
for (const p of data.people) {
|
|
16265
|
+
if (p.kind === "agent") continue;
|
|
16266
|
+
const share = p.allocations?.find((a) => a.programId === programId)?.percent ?? 0;
|
|
16267
|
+
if (share <= 0) continue;
|
|
16268
|
+
crew += 1;
|
|
16269
|
+
const pace = allocatedCapacity(p.weeklyCapacity, share);
|
|
16270
|
+
const off = offByWeek(calendar, p, monday, weeks);
|
|
16271
|
+
for (const o of off) capacity += weekCapacity(pace, 5 - o);
|
|
16272
|
+
daysOff += off.reduce((a, b) => a + b, 0);
|
|
16273
|
+
}
|
|
16274
|
+
if (crew === 0) return null;
|
|
16275
|
+
let late = 0;
|
|
16276
|
+
let due = 0;
|
|
16277
|
+
let undated = 0;
|
|
16278
|
+
let unheld = 0;
|
|
16279
|
+
for (const project of data.projects) {
|
|
16280
|
+
if (project.programId !== programId || project.health === "done") continue;
|
|
16281
|
+
for (const t of tasksOf(data.tasks, project.id)) {
|
|
16282
|
+
if (t.status === "done") continue;
|
|
16283
|
+
const d = t.dueDate?.slice(0, 10);
|
|
16284
|
+
if (!d) {
|
|
16285
|
+
undated += 1;
|
|
16286
|
+
continue;
|
|
16287
|
+
}
|
|
16288
|
+
if (d > end) continue;
|
|
16289
|
+
if (d < today) late += 1;
|
|
16290
|
+
else due += 1;
|
|
16291
|
+
if (!t.assigneeId) unheld += 1;
|
|
16292
|
+
}
|
|
16293
|
+
}
|
|
16294
|
+
return {
|
|
16295
|
+
...line(late + due, late, capacity, daysOff, undated),
|
|
16296
|
+
unheld
|
|
16297
|
+
};
|
|
16298
|
+
}
|
|
16299
|
+
const tasksWord = (n) => `${n} task${n === 1 ? "" : "s"}`;
|
|
16300
|
+
/**
|
|
16301
|
+
* "Past the line by 3 tasks: 11 due in the next 3 weeks (2 late), room for 8.",
|
|
16302
|
+
* or "Room for 4 more in the next 3 weeks (8 of 12)." Said the same in a tooltip,
|
|
16303
|
+
* the terminal and for agents.
|
|
16304
|
+
*/
|
|
16305
|
+
function loadLineText(l, weeks = 3) {
|
|
16306
|
+
const span = `the next ${weeks} weeks`;
|
|
16307
|
+
const lateBit = l.late ? ` (${l.late} late)` : "";
|
|
16308
|
+
if (l.cargo === 0) return l.capacity > 0 ? `Nothing due in ${span}.` : `Nothing due, and off for ${span}.`;
|
|
16309
|
+
if (l.capacity <= 0) return `${tasksWord(l.cargo)} due in ${span}${lateBit}, with no room: off the whole time.`;
|
|
16310
|
+
if (l.over > 0) return `Past the line by ${tasksWord(l.over)}: ${l.cargo} due in ${span}${lateBit}, room for ${l.capacity}.`;
|
|
16311
|
+
if (l.room === 0) return `At the line: ${l.cargo} due in ${span}${lateBit}, room for ${l.capacity}.`;
|
|
16312
|
+
return `Room for ${tasksWord(l.room)} more in ${span}: ${l.cargo} of ${l.capacity}${lateBit}.`;
|
|
16313
|
+
}
|
|
16314
|
+
/** Everyone's line, worst first: the people page's order when it sorts by load. */
|
|
16315
|
+
function crewLoadLines(data, now, calendar) {
|
|
16316
|
+
return data.people.flatMap((person) => {
|
|
16317
|
+
const l = personLoadLine(data, person, now, calendar);
|
|
16318
|
+
return l ? [{
|
|
16319
|
+
person,
|
|
16320
|
+
line: l
|
|
16321
|
+
}] : [];
|
|
16322
|
+
}).sort((a, b) => b.line.ratio - a.line.ratio || b.line.cargo - a.line.cargo);
|
|
16323
|
+
}
|
|
16324
|
+
|
|
16149
16325
|
// src/lib/dry-dock.ts
|
|
16150
16326
|
init_date_fns();
|
|
16151
16327
|
init_format();
|
|
@@ -16382,7 +16558,9 @@ function dockCompare(data, projectId, changes, now) {
|
|
|
16382
16558
|
person,
|
|
16383
16559
|
capacity: person.weeklyCapacity ?? 5,
|
|
16384
16560
|
real: weeklyLoad(data.tasks, id, now),
|
|
16385
|
-
docked: weeklyLoad(plan.allTasks, id, now)
|
|
16561
|
+
docked: weeklyLoad(plan.allTasks, id, now),
|
|
16562
|
+
realLine: personLoadLine(data, person, now),
|
|
16563
|
+
dockedLine: personLoadLine({ tasks: plan.allTasks }, person, now)
|
|
16386
16564
|
});
|
|
16387
16565
|
}
|
|
16388
16566
|
load.sort((x, y) => x.person.name.localeCompare(y.person.name));
|
|
@@ -25665,6 +25843,48 @@ const HARBOR_TOOLS = [
|
|
|
25665
25843
|
};
|
|
25666
25844
|
}
|
|
25667
25845
|
}),
|
|
25846
|
+
tool({
|
|
25847
|
+
name: "load_line",
|
|
25848
|
+
title: "Who is past their load line",
|
|
25849
|
+
description: "Each person's load line: open tasks due in the next 3 weeks plus any already late (cargo), against what they can close in that time (capacity: their tasks a week, less weekdays off for holidays and time away). over is how many tasks past the line, room how many before it; text says it in a sentence. Worst first. Agents on the crew have none. With program, also that program's line: the crew time promised to it (allocations) against its open work in the same weeks, including work nobody holds yet (unheld); null when no one's time is promised to it." + DATA_NOTE,
|
|
25850
|
+
input: object({
|
|
25851
|
+
harbor: harborArg,
|
|
25852
|
+
program: string().max(200).optional().describe("Program id or name.")
|
|
25853
|
+
}),
|
|
25854
|
+
run: (ctx, input) => {
|
|
25855
|
+
const { data } = ctx;
|
|
25856
|
+
const cal = workCalendar(data);
|
|
25857
|
+
const shape = (l) => ({
|
|
25858
|
+
cargo: l.cargo,
|
|
25859
|
+
late: l.late,
|
|
25860
|
+
capacity: l.capacity,
|
|
25861
|
+
over: l.over,
|
|
25862
|
+
room: l.room,
|
|
25863
|
+
daysOff: l.daysOff,
|
|
25864
|
+
undated: l.undated,
|
|
25865
|
+
...l.unheld !== void 0 ? { unheld: l.unheld } : {},
|
|
25866
|
+
text: loadLineText(l)
|
|
25867
|
+
});
|
|
25868
|
+
const people = crewLoadLines(data, ctx.now, cal).map(({ person, line }) => ({
|
|
25869
|
+
who: person.name,
|
|
25870
|
+
...shape(line)
|
|
25871
|
+
}));
|
|
25872
|
+
if (!input.program) return {
|
|
25873
|
+
weeks: 3,
|
|
25874
|
+
people
|
|
25875
|
+
};
|
|
25876
|
+
const program = findOne(data.programs, input.program, "program");
|
|
25877
|
+
const line = programLoadLine(data, program.id, ctx.now, cal);
|
|
25878
|
+
return {
|
|
25879
|
+
weeks: 3,
|
|
25880
|
+
program: {
|
|
25881
|
+
name: program.name,
|
|
25882
|
+
line: line ? shape(line) : null
|
|
25883
|
+
},
|
|
25884
|
+
people
|
|
25885
|
+
};
|
|
25886
|
+
}
|
|
25887
|
+
}),
|
|
25668
25888
|
tool({
|
|
25669
25889
|
name: "handover_plan",
|
|
25670
25890
|
title: "What handing someone's work over would move",
|
package/lib/cli.mjs
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
messagesText,
|
|
37
37
|
charterText,
|
|
38
38
|
landfallText,
|
|
39
|
+
loadLineCliText,
|
|
39
40
|
daysText,
|
|
40
41
|
soundingText,
|
|
41
42
|
lifeboatsText,
|
|
@@ -315,6 +316,10 @@ export const HELP = `harbor: Harbor from the terminal
|
|
|
315
316
|
harbor approvals tasks waiting on your approval
|
|
316
317
|
harbor field TASK NAME VALUE set one of the project's own
|
|
317
318
|
fields on a task ("" clears it)
|
|
319
|
+
harbor load [--program NAME] who is past their load line: work
|
|
320
|
+
due in the next 3 weeks against
|
|
321
|
+
what each person (or a program's
|
|
322
|
+
crew) can close
|
|
318
323
|
harbor ashore [--weeks N] [--country CODES|none] [--person NAME]
|
|
319
324
|
public holidays and time away
|
|
320
325
|
coming up, and whose holidays
|
|
@@ -1140,6 +1145,18 @@ const DETAIL = {
|
|
|
1140
1145
|
" everyone has. Close guesses give the task an estimate; far-apart ones",
|
|
1141
1146
|
" say talk first. The forecast draws on every answer.",
|
|
1142
1147
|
],
|
|
1148
|
+
load: [
|
|
1149
|
+
" harbor load each person's load line: open tasks",
|
|
1150
|
+
" due in the next 3 weeks (and any",
|
|
1151
|
+
" late) against what they can close,",
|
|
1152
|
+
" worst first; ▼ marks past the line",
|
|
1153
|
+
" harbor load --program NAME also the program's line: the crew",
|
|
1154
|
+
" time promised to it against its work",
|
|
1155
|
+
"",
|
|
1156
|
+
" What someone can close is their tasks a week (People, Per week; 5 unless",
|
|
1157
|
+
" set), less weekdays off for holidays and time away (harbor ashore).",
|
|
1158
|
+
" Tasks with no due date aren't counted, but are said.",
|
|
1159
|
+
],
|
|
1143
1160
|
ashore: [
|
|
1144
1161
|
" harbor ashore [--weeks N] reads: holidays and time away in the",
|
|
1145
1162
|
" next N weeks (8 unless you say)",
|
|
@@ -3918,6 +3935,15 @@ export async function run(argv, io = {}) {
|
|
|
3918
3935
|
goalsText(r),
|
|
3919
3936
|
);
|
|
3920
3937
|
}
|
|
3938
|
+
case "load": {
|
|
3939
|
+
const { positionals, values, harbor } = parse(spec([], ["program"]));
|
|
3940
|
+
none(positionals);
|
|
3941
|
+
return call(
|
|
3942
|
+
"load_line",
|
|
3943
|
+
{ harbor, ...(values.program ? { program: values.program } : {}) },
|
|
3944
|
+
(r) => loadLineCliText(r),
|
|
3945
|
+
);
|
|
3946
|
+
}
|
|
3921
3947
|
case "ashore": {
|
|
3922
3948
|
const { positionals, values, harbor } = parse(spec([], ["weeks", "country", "person"]));
|
|
3923
3949
|
none(positionals);
|
package/lib/format.mjs
CHANGED
|
@@ -844,6 +844,31 @@ export function charterText(r) {
|
|
|
844
844
|
return lines.join("\n");
|
|
845
845
|
}
|
|
846
846
|
|
|
847
|
+
/** load_line as the terminal prints it: each person against their line, worst first. */
|
|
848
|
+
export function loadLineCliText(r) {
|
|
849
|
+
const lines = [`Load line · the next ${r.weeks} weeks`];
|
|
850
|
+
if (r.program) {
|
|
851
|
+
lines.push(
|
|
852
|
+
r.program.line
|
|
853
|
+
? ` ${r.program.name}: ${r.program.line.text}${r.program.line.unheld ? ` ${r.program.line.unheld} nobody holds yet.` : ""}`
|
|
854
|
+
: ` ${r.program.name}: nobody's time is promised to it yet, so it has no line. Set crew time on People.`,
|
|
855
|
+
"",
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
if (!r.people?.length) {
|
|
859
|
+
lines.push(" Nobody on the crew yet.");
|
|
860
|
+
return lines.join("\n");
|
|
861
|
+
}
|
|
862
|
+
const width = Math.max(...r.people.map((p) => p.who.length));
|
|
863
|
+
for (const p of r.people) {
|
|
864
|
+
const mark = p.over > 0 ? "▼" : " ";
|
|
865
|
+
lines.push(`${mark} ${p.who.padEnd(width)} ${p.text}`);
|
|
866
|
+
}
|
|
867
|
+
const over = r.people.filter((p) => p.over > 0).length;
|
|
868
|
+
if (over > 0) lines.push("", `${over} past the line (▼).`);
|
|
869
|
+
return lines.join("\n");
|
|
870
|
+
}
|
|
871
|
+
|
|
847
872
|
const LANDFALL_RESULT = { yes: "Paid off", partly: "Partly", no: "Didn't" };
|
|
848
873
|
|
|
849
874
|
/** A project's landfall as get_project, set_landfall or answer_landfall gives it. */
|