@harborppm/cli 0.114.0 → 0.116.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 +1 -1
- package/dist/app.mjs +1462 -472
- package/lib/cli.mjs +2 -1
- package/lib/format.mjs +94 -30
- package/package.json +1 -1
package/dist/app.mjs
CHANGED
|
@@ -671,205 +671,64 @@ function useHarbor(selector) {
|
|
|
671
671
|
return useStore(useDeps().store, selector);
|
|
672
672
|
}
|
|
673
673
|
|
|
674
|
-
// src/lib/
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
for (let n = 2;; n++) if (!taken.has(`${base}${n}`)) return `${base}${n}`;
|
|
686
|
-
}
|
|
687
|
-
/** Whether `a` has the better claim to the number both hold. */
|
|
688
|
-
function first$3(a, b, stored) {
|
|
689
|
-
const ka = kept(a, stored);
|
|
690
|
-
if (ka !== kept(b, stored)) return ka;
|
|
691
|
-
return made(a, b) <= 0;
|
|
674
|
+
// src/lib/account-deletion.ts
|
|
675
|
+
var FORMER_MEMBER;
|
|
676
|
+
var init_account_deletion = __esmMin((() => {
|
|
677
|
+
FORMER_MEMBER = "Former member";
|
|
678
|
+
}));
|
|
679
|
+
|
|
680
|
+
// src/lib/former-crew.ts
|
|
681
|
+
function isFormerCrew(person, gone) {
|
|
682
|
+
if (person.kind === "agent") return false;
|
|
683
|
+
if (person.name === "Former member" && !person.accountId) return true;
|
|
684
|
+
return Boolean(person.accountId && gone.includes(person.accountId));
|
|
692
685
|
}
|
|
686
|
+
var useFormerAccounts;
|
|
687
|
+
var init_former_crew = __esmMin((() => {
|
|
688
|
+
init_esm();
|
|
689
|
+
init_account_deletion();
|
|
690
|
+
useFormerAccounts = create$1(() => ({ ids: [] }));
|
|
691
|
+
}));
|
|
692
|
+
|
|
693
|
+
// src/lib/agent-check.ts
|
|
693
694
|
/**
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* used its key already; otherwise the task made first does. Returns the same
|
|
698
|
-
* object when nothing needed doing.
|
|
695
|
+
* Who checks an agent's work on a task: whoever gave it the task, else
|
|
696
|
+
* whoever put the agent on the crew. A person still aboard, never an agent;
|
|
697
|
+
* null when there's nobody (the work still waits in In review).
|
|
699
698
|
*/
|
|
700
|
-
function
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
const ok = !!p.key && KEY.test(p.key) && !taken.has(p.key);
|
|
705
|
-
if (ok) taken.add(p.key);
|
|
706
|
-
return ok;
|
|
707
|
-
});
|
|
708
|
-
if (keeps.includes(false)) projects = projects.map((p, i) => {
|
|
709
|
-
if (keeps[i]) return p;
|
|
710
|
-
const key = projectKeyFor(p.name, taken);
|
|
711
|
-
taken.add(key);
|
|
712
|
-
return {
|
|
713
|
-
...p,
|
|
714
|
-
key
|
|
715
|
-
};
|
|
716
|
-
});
|
|
717
|
-
const byProject = /* @__PURE__ */ new Map();
|
|
718
|
-
for (const t of data.tasks) {
|
|
719
|
-
const list = byProject.get(t.projectId);
|
|
720
|
-
if (list) list.push(t);
|
|
721
|
-
else byProject.set(t.projectId, [t]);
|
|
722
|
-
}
|
|
723
|
-
const renumber = /* @__PURE__ */ new Map();
|
|
724
|
-
for (const list of byProject.values()) {
|
|
725
|
-
let max = 0;
|
|
726
|
-
const holder = /* @__PURE__ */ new Map();
|
|
727
|
-
const loose = [];
|
|
728
|
-
for (const t of list) {
|
|
729
|
-
const n = t.number;
|
|
730
|
-
if (!Number.isInteger(n) || n < 1) {
|
|
731
|
-
loose.push(t);
|
|
732
|
-
continue;
|
|
733
|
-
}
|
|
734
|
-
const other = holder.get(n);
|
|
735
|
-
if (other) {
|
|
736
|
-
const [keep, move] = first$3(other, t, stored) ? [other, t] : [t, other];
|
|
737
|
-
holder.set(n, keep);
|
|
738
|
-
loose.push(move);
|
|
739
|
-
} else holder.set(n, t);
|
|
740
|
-
if (n > max) max = n;
|
|
741
|
-
}
|
|
742
|
-
if (loose.length === 0) continue;
|
|
743
|
-
loose.sort(made);
|
|
744
|
-
for (const t of loose) renumber.set(t.id, ++max);
|
|
699
|
+
function agentChecker(people, task, agent, gone = []) {
|
|
700
|
+
for (const id of [task.assignedBy, agent.addedById]) {
|
|
701
|
+
const p = id ? people.find((x) => x.id === id) : void 0;
|
|
702
|
+
if (p && p.kind !== "agent" && !isFormerCrew(p, gone)) return p;
|
|
745
703
|
}
|
|
746
|
-
|
|
747
|
-
const tasks = renumber.size === 0 ? data.tasks : data.tasks.map((t) => renumber.has(t.id) ? {
|
|
748
|
-
...t,
|
|
749
|
-
number: renumber.get(t.id)
|
|
750
|
-
} : t);
|
|
751
|
-
return {
|
|
752
|
-
...data,
|
|
753
|
-
projects,
|
|
754
|
-
tasks
|
|
755
|
-
};
|
|
704
|
+
return null;
|
|
756
705
|
}
|
|
757
706
|
/**
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
...after,
|
|
783
|
-
projects
|
|
784
|
-
};
|
|
785
|
-
const was = byId(before.tasks);
|
|
786
|
-
const holders = /* @__PURE__ */ new Map();
|
|
787
|
-
for (const t of after.tasks) {
|
|
788
|
-
if (!Number.isInteger(t.number)) continue;
|
|
789
|
-
const k = `${t.projectId}:${t.number}`;
|
|
790
|
-
holders.set(k, (holders.get(k) ?? 0) + 1);
|
|
791
|
-
}
|
|
792
|
-
const keepsNumber = (t) => Number.isInteger(t.number) && holders.get(`${t.projectId}:${t.number}`) === 1;
|
|
793
|
-
const fresh = (t) => {
|
|
794
|
-
const old = was.get(t.id);
|
|
795
|
-
if (!old) return !keepsNumber(t);
|
|
796
|
-
return old.projectId !== t.projectId && old.number === t.number;
|
|
797
|
-
};
|
|
798
|
-
if (!after.tasks.some(fresh)) return projects === after.projects ? after : {
|
|
799
|
-
...after,
|
|
800
|
-
projects
|
|
801
|
-
};
|
|
802
|
-
const max = /* @__PURE__ */ new Map();
|
|
803
|
-
for (const t of after.tasks) {
|
|
804
|
-
if (fresh(t) || !Number.isInteger(t.number)) continue;
|
|
805
|
-
if (t.number > (max.get(t.projectId) ?? 0)) max.set(t.projectId, t.number);
|
|
806
|
-
}
|
|
807
|
-
const tasks = after.tasks.map((t) => {
|
|
808
|
-
if (!fresh(t)) return t;
|
|
809
|
-
const n = (max.get(t.projectId) ?? 0) + 1;
|
|
810
|
-
max.set(t.projectId, n);
|
|
811
|
-
return {
|
|
812
|
-
...t,
|
|
813
|
-
number: n
|
|
814
|
-
};
|
|
815
|
-
});
|
|
816
|
-
return {
|
|
817
|
-
...after,
|
|
818
|
-
projects,
|
|
819
|
-
tasks
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
/** "RR-42", or null for a task without a number yet. */
|
|
823
|
-
function taskKey(task, project) {
|
|
824
|
-
return project?.key && task.number ? `${project.key}-${task.number}` : null;
|
|
825
|
-
}
|
|
826
|
-
/** The task a key names ("rr-42" works too), or null. */
|
|
827
|
-
function findByKey(data, text) {
|
|
828
|
-
const m = KEY_TEXT.exec(text.trim());
|
|
829
|
-
if (!m) return null;
|
|
830
|
-
const project = data.projects.find((p) => p.key === m[1].toUpperCase());
|
|
831
|
-
if (!project) return null;
|
|
832
|
-
const n = Number(m[2]);
|
|
833
|
-
return data.tasks.find((t) => t.projectId === project.id && t.number === n) ?? null;
|
|
834
|
-
}
|
|
835
|
-
var MAX_KEY, KEY, made, kept, KEY_TEXT;
|
|
836
|
-
var init_task_keys = __esmMin((() => {
|
|
837
|
-
init_indexes();
|
|
838
|
-
MAX_KEY = 5;
|
|
839
|
-
KEY = /^[A-Z][A-Z0-9]{0,9}$/;
|
|
840
|
-
made = (a, b) => a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
841
|
-
kept = (t, stored) => {
|
|
842
|
-
const was = stored?.get(t.id);
|
|
843
|
-
return !!was && was.number === t.number && was.projectId === t.projectId;
|
|
844
|
-
};
|
|
845
|
-
KEY_TEXT = /^([A-Za-z][A-Za-z0-9]{0,9})-(\d{1,7})$/;
|
|
846
|
-
}));
|
|
847
|
-
|
|
848
|
-
// src/lib/agents.ts
|
|
849
|
-
/** What an agent should work on: its open tasks not yet waiting on review, in progress first, then most urgent and soonest. */
|
|
850
|
-
function agentQueue(data, agentId) {
|
|
851
|
-
return data.tasks.filter((t) => t.assigneeId === agentId && (t.status === "todo" || t.status === "doing" || t.status === "backlog")).sort((a, b) => Number(b.status === "doing") - Number(a.status === "doing") || Number(a.status === "backlog") - Number(b.status === "backlog") || RANK$1[a.priority] - RANK$1[b.priority] || (a.dueDate ?? "9999").localeCompare(b.dueDate ?? "9999"));
|
|
852
|
-
}
|
|
853
|
-
/** The agent an app means: the one named, else the only one on the crew. */
|
|
854
|
-
function pickAgent(people, key) {
|
|
855
|
-
const agents = people.filter(isAgent);
|
|
856
|
-
if (agents.length === 0) return "There are no agents on this harbor's crew yet. Someone adds one on People with Add an agent.";
|
|
857
|
-
if (!key) {
|
|
858
|
-
if (agents.length === 1) return agents[0];
|
|
859
|
-
return `This harbor has ${agents.length} agents (${agents.map((a) => a.name).join(", ")}). Say which with agent.`;
|
|
860
|
-
}
|
|
861
|
-
const k = key.trim().toLowerCase();
|
|
862
|
-
return agents.find((a) => a.id === key.trim() || a.name.trim().toLowerCase() === k) ?? `No agent called "${key}". The crew's agents: ${agents.map((a) => a.name).join(", ")}.`;
|
|
863
|
-
}
|
|
864
|
-
var isAgent, RANK$1;
|
|
865
|
-
var init_agents = __esmMin((() => {
|
|
707
|
+
* What moving a task by hand does to an agent's ask, which stands for one
|
|
708
|
+
* hand-in and only while it waits in In review: a person who finishes the
|
|
709
|
+
* task has checked it (approved, by them); moved anywhere else, the ask is
|
|
710
|
+
* withdrawn, so nobody approves work being redone and the next hand-in asks
|
|
711
|
+
* afresh. `undefined` leaves the approval as it is (a person's ask, an
|
|
712
|
+
* answer already given).
|
|
713
|
+
*/
|
|
714
|
+
function agentAskAfterMove(people, task, next, by, at) {
|
|
715
|
+
const a = task.approval;
|
|
716
|
+
if (!a || a.status !== "pending" || next === task.status || next === "review") return void 0;
|
|
717
|
+
if (!isAgent(people.find((p) => p.id === a.askedById))) return void 0;
|
|
718
|
+
if (next !== "done") return null;
|
|
719
|
+
const person = people.find((p) => p.id === by);
|
|
720
|
+
return person && !isAgent(person) ? {
|
|
721
|
+
...a,
|
|
722
|
+
approverId: by,
|
|
723
|
+
status: "approved",
|
|
724
|
+
note: null,
|
|
725
|
+
decidedAt: at
|
|
726
|
+
} : void 0;
|
|
727
|
+
}
|
|
728
|
+
var isAgent;
|
|
729
|
+
var init_agent_check = __esmMin((() => {
|
|
730
|
+
init_former_crew();
|
|
866
731
|
isAgent = (p) => p?.kind === "agent";
|
|
867
|
-
RANK$1 = {
|
|
868
|
-
urgent: 0,
|
|
869
|
-
high: 1,
|
|
870
|
-
medium: 2,
|
|
871
|
-
low: 3
|
|
872
|
-
};
|
|
873
732
|
}));
|
|
874
733
|
|
|
875
734
|
// src/lib/task-people.ts
|
|
@@ -915,7 +774,7 @@ function projectFiles(data, projectId, kind) {
|
|
|
915
774
|
}
|
|
916
775
|
var init_task_people = __esmMin((() => {
|
|
917
776
|
init_indexes();
|
|
918
|
-
|
|
777
|
+
init_agent_check();
|
|
919
778
|
}));
|
|
920
779
|
|
|
921
780
|
// node_modules/date-fns/constants.js
|
|
@@ -2390,9 +2249,9 @@ function isSubtask(task, tasks) {
|
|
|
2390
2249
|
}
|
|
2391
2250
|
/** The subtasks of `parent`, in list order. Empty for a task that is itself a subtask. */
|
|
2392
2251
|
function subtasksOf(parent, tasks) {
|
|
2393
|
-
if (isSubtask(parent, tasks)) return NONE$
|
|
2252
|
+
if (isSubtask(parent, tasks)) return NONE$3;
|
|
2394
2253
|
const list = childrenByParent(tasks).get(parent.id);
|
|
2395
|
-
if (!list) return NONE$
|
|
2254
|
+
if (!list) return NONE$3;
|
|
2396
2255
|
return list.filter((t) => t.projectId === parent.projectId && t.id !== parent.id);
|
|
2397
2256
|
}
|
|
2398
2257
|
/** The tasks that stand on their own: what a board or a list shows. */
|
|
@@ -2416,11 +2275,11 @@ function subtaskProblem(childId, parentId, tasks) {
|
|
|
2416
2275
|
if (subtasksOf(parent, tasks).filter((t) => t.id !== childId).length >= 50) return `A task can hold up to ${50} subtasks.`;
|
|
2417
2276
|
return null;
|
|
2418
2277
|
}
|
|
2419
|
-
var SUBTASKS_MAX, NONE$
|
|
2278
|
+
var SUBTASKS_MAX, NONE$3;
|
|
2420
2279
|
var init_subtasks = __esmMin((() => {
|
|
2421
2280
|
init_indexes();
|
|
2422
2281
|
SUBTASKS_MAX = 50;
|
|
2423
|
-
NONE$
|
|
2282
|
+
NONE$3 = Object.freeze([]);
|
|
2424
2283
|
}));
|
|
2425
2284
|
|
|
2426
2285
|
// src/lib/swatches.ts
|
|
@@ -2708,6 +2567,180 @@ var init_board = __esmMin((() => {
|
|
|
2708
2567
|
];
|
|
2709
2568
|
}));
|
|
2710
2569
|
|
|
2570
|
+
// src/lib/task-keys.ts
|
|
2571
|
+
/** "Ridge Runner" → "RR", "Website" → "WEB", "Q4 launch plan" → "QLP". */
|
|
2572
|
+
function baseKey(name) {
|
|
2573
|
+
const words = name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^A-Za-z0-9 ]+/g, " ").split(/\s+/).filter((w) => /[A-Za-z]/.test(w));
|
|
2574
|
+
if (words.length === 0) return "P";
|
|
2575
|
+
return (words.length === 1 ? words[0].replace(/[^A-Za-z]/g, "").slice(0, 3) : words.map((w) => w.replace(/[^A-Za-z]/g, "")[0] ?? "").join("").slice(0, MAX_KEY)).toUpperCase() || "P";
|
|
2576
|
+
}
|
|
2577
|
+
/** A key for `name` that none of `taken` has: "RR", then "RR2", "RR3"… */
|
|
2578
|
+
function projectKeyFor(name, taken) {
|
|
2579
|
+
const base = baseKey(name);
|
|
2580
|
+
if (!taken.has(base)) return base;
|
|
2581
|
+
for (let n = 2;; n++) if (!taken.has(`${base}${n}`)) return `${base}${n}`;
|
|
2582
|
+
}
|
|
2583
|
+
/** Whether `a` has the better claim to the number both hold. */
|
|
2584
|
+
function first$3(a, b, stored) {
|
|
2585
|
+
const ka = kept$1(a, stored);
|
|
2586
|
+
if (ka !== kept$1(b, stored)) return ka;
|
|
2587
|
+
return made(a, b) <= 0;
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Every project keyed, every task numbered, no number given twice in a
|
|
2591
|
+
* project. When two tasks hold one number, a task already stored with it
|
|
2592
|
+
* (`stored`: the document before this write) keeps it, since people may have
|
|
2593
|
+
* used its key already; otherwise the task made first does. Returns the same
|
|
2594
|
+
* object when nothing needed doing.
|
|
2595
|
+
*/
|
|
2596
|
+
function settleKeys(data, stored) {
|
|
2597
|
+
let projects = data.projects;
|
|
2598
|
+
const taken = /* @__PURE__ */ new Set();
|
|
2599
|
+
const keeps = projects.map((p) => {
|
|
2600
|
+
const ok = !!p.key && KEY.test(p.key) && !taken.has(p.key);
|
|
2601
|
+
if (ok) taken.add(p.key);
|
|
2602
|
+
return ok;
|
|
2603
|
+
});
|
|
2604
|
+
if (keeps.includes(false)) projects = projects.map((p, i) => {
|
|
2605
|
+
if (keeps[i]) return p;
|
|
2606
|
+
const key = projectKeyFor(p.name, taken);
|
|
2607
|
+
taken.add(key);
|
|
2608
|
+
return {
|
|
2609
|
+
...p,
|
|
2610
|
+
key
|
|
2611
|
+
};
|
|
2612
|
+
});
|
|
2613
|
+
const byProject = /* @__PURE__ */ new Map();
|
|
2614
|
+
for (const t of data.tasks) {
|
|
2615
|
+
const list = byProject.get(t.projectId);
|
|
2616
|
+
if (list) list.push(t);
|
|
2617
|
+
else byProject.set(t.projectId, [t]);
|
|
2618
|
+
}
|
|
2619
|
+
const renumber = /* @__PURE__ */ new Map();
|
|
2620
|
+
for (const list of byProject.values()) {
|
|
2621
|
+
let max = 0;
|
|
2622
|
+
const holder = /* @__PURE__ */ new Map();
|
|
2623
|
+
const loose = [];
|
|
2624
|
+
for (const t of list) {
|
|
2625
|
+
const n = t.number;
|
|
2626
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
2627
|
+
loose.push(t);
|
|
2628
|
+
continue;
|
|
2629
|
+
}
|
|
2630
|
+
const other = holder.get(n);
|
|
2631
|
+
if (other) {
|
|
2632
|
+
const [keep, move] = first$3(other, t, stored) ? [other, t] : [t, other];
|
|
2633
|
+
holder.set(n, keep);
|
|
2634
|
+
loose.push(move);
|
|
2635
|
+
} else holder.set(n, t);
|
|
2636
|
+
if (n > max) max = n;
|
|
2637
|
+
}
|
|
2638
|
+
if (loose.length === 0) continue;
|
|
2639
|
+
loose.sort(made);
|
|
2640
|
+
for (const t of loose) renumber.set(t.id, ++max);
|
|
2641
|
+
}
|
|
2642
|
+
if (projects === data.projects && renumber.size === 0) return data;
|
|
2643
|
+
const tasks = renumber.size === 0 ? data.tasks : data.tasks.map((t) => renumber.has(t.id) ? {
|
|
2644
|
+
...t,
|
|
2645
|
+
number: renumber.get(t.id)
|
|
2646
|
+
} : t);
|
|
2647
|
+
return {
|
|
2648
|
+
...data,
|
|
2649
|
+
projects,
|
|
2650
|
+
tasks
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
/**
|
|
2654
|
+
* The browser's half: number the tasks this change adds, and the ones it
|
|
2655
|
+
* moves to another project, after the highest number in their project. Old
|
|
2656
|
+
* tasks without a number are left for the server. Same object when nothing
|
|
2657
|
+
* was added or moved.
|
|
2658
|
+
*/
|
|
2659
|
+
function numberNewTasks(before, after) {
|
|
2660
|
+
if (after.tasks === before.tasks && after.projects === before.projects) return after;
|
|
2661
|
+
let projects = after.projects;
|
|
2662
|
+
if (projects !== before.projects) {
|
|
2663
|
+
const known = new Set(before.projects.map((p) => p.id));
|
|
2664
|
+
if (projects.some((p) => !known.has(p.id) && !p.key)) {
|
|
2665
|
+
const taken = new Set(projects.flatMap((p) => p.key ? [p.key] : []));
|
|
2666
|
+
projects = projects.map((p) => {
|
|
2667
|
+
if (known.has(p.id) || p.key) return p;
|
|
2668
|
+
const key = projectKeyFor(p.name, taken);
|
|
2669
|
+
taken.add(key);
|
|
2670
|
+
return {
|
|
2671
|
+
...p,
|
|
2672
|
+
key
|
|
2673
|
+
};
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
if (after.tasks === before.tasks) return projects === after.projects ? after : {
|
|
2678
|
+
...after,
|
|
2679
|
+
projects
|
|
2680
|
+
};
|
|
2681
|
+
const was = byId(before.tasks);
|
|
2682
|
+
const holders = /* @__PURE__ */ new Map();
|
|
2683
|
+
for (const t of after.tasks) {
|
|
2684
|
+
if (!Number.isInteger(t.number)) continue;
|
|
2685
|
+
const k = `${t.projectId}:${t.number}`;
|
|
2686
|
+
holders.set(k, (holders.get(k) ?? 0) + 1);
|
|
2687
|
+
}
|
|
2688
|
+
const keepsNumber = (t) => Number.isInteger(t.number) && holders.get(`${t.projectId}:${t.number}`) === 1;
|
|
2689
|
+
const fresh = (t) => {
|
|
2690
|
+
const old = was.get(t.id);
|
|
2691
|
+
if (!old) return !keepsNumber(t);
|
|
2692
|
+
return old.projectId !== t.projectId && old.number === t.number;
|
|
2693
|
+
};
|
|
2694
|
+
if (!after.tasks.some(fresh)) return projects === after.projects ? after : {
|
|
2695
|
+
...after,
|
|
2696
|
+
projects
|
|
2697
|
+
};
|
|
2698
|
+
const max = /* @__PURE__ */ new Map();
|
|
2699
|
+
for (const t of after.tasks) {
|
|
2700
|
+
if (fresh(t) || !Number.isInteger(t.number)) continue;
|
|
2701
|
+
if (t.number > (max.get(t.projectId) ?? 0)) max.set(t.projectId, t.number);
|
|
2702
|
+
}
|
|
2703
|
+
const tasks = after.tasks.map((t) => {
|
|
2704
|
+
if (!fresh(t)) return t;
|
|
2705
|
+
const n = (max.get(t.projectId) ?? 0) + 1;
|
|
2706
|
+
max.set(t.projectId, n);
|
|
2707
|
+
return {
|
|
2708
|
+
...t,
|
|
2709
|
+
number: n
|
|
2710
|
+
};
|
|
2711
|
+
});
|
|
2712
|
+
return {
|
|
2713
|
+
...after,
|
|
2714
|
+
projects,
|
|
2715
|
+
tasks
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
/** "RR-42", or null for a task without a number yet. */
|
|
2719
|
+
function taskKey(task, project) {
|
|
2720
|
+
return project?.key && task.number ? `${project.key}-${task.number}` : null;
|
|
2721
|
+
}
|
|
2722
|
+
/** The task a key names ("rr-42" works too), or null. */
|
|
2723
|
+
function findByKey(data, text) {
|
|
2724
|
+
const m = KEY_TEXT.exec(text.trim());
|
|
2725
|
+
if (!m) return null;
|
|
2726
|
+
const project = data.projects.find((p) => p.key === m[1].toUpperCase());
|
|
2727
|
+
if (!project) return null;
|
|
2728
|
+
const n = Number(m[2]);
|
|
2729
|
+
return data.tasks.find((t) => t.projectId === project.id && t.number === n) ?? null;
|
|
2730
|
+
}
|
|
2731
|
+
var MAX_KEY, KEY, made, kept$1, KEY_TEXT;
|
|
2732
|
+
var init_task_keys = __esmMin((() => {
|
|
2733
|
+
init_indexes();
|
|
2734
|
+
MAX_KEY = 5;
|
|
2735
|
+
KEY = /^[A-Z][A-Z0-9]{0,9}$/;
|
|
2736
|
+
made = (a, b) => a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
2737
|
+
kept$1 = (t, stored) => {
|
|
2738
|
+
const was = stored?.get(t.id);
|
|
2739
|
+
return !!was && was.number === t.number && was.projectId === t.projectId;
|
|
2740
|
+
};
|
|
2741
|
+
KEY_TEXT = /^([A-Za-z][A-Za-z0-9]{0,9})-(\d{1,7})$/;
|
|
2742
|
+
}));
|
|
2743
|
+
|
|
2711
2744
|
// src/lib/first-voyage.ts
|
|
2712
2745
|
function isVoyageProject(projectId) {
|
|
2713
2746
|
return projectId === VOYAGE_PROJECT_ID;
|
|
@@ -4560,7 +4593,7 @@ const ZOOMS = [
|
|
|
4560
4593
|
const day$6 = (iso) => /* @__PURE__ */ new Date(`${iso.slice(0, 10)}T12:00:00`);
|
|
4561
4594
|
/** Names in the order people expect: "Phase 2" before "Phase 10". */
|
|
4562
4595
|
const byName = (a, b) => a.localeCompare(b, void 0, { numeric: true });
|
|
4563
|
-
const isoDay$
|
|
4596
|
+
const isoDay$4 = (d) => format(d, "yyyy-MM-dd");
|
|
4564
4597
|
/**
|
|
4565
4598
|
* Whole months, opening a month before today so what just happened stays in
|
|
4566
4599
|
* view; `shift` pages earlier (negative) or later by the zoom's step.
|
|
@@ -4574,15 +4607,15 @@ function roadmapWindow(zoom, today, shift = 0) {
|
|
|
4574
4607
|
const m = addMonths$1(first, i);
|
|
4575
4608
|
const next = addMonths$1(first, i + 1);
|
|
4576
4609
|
return {
|
|
4577
|
-
start: isoDay$
|
|
4610
|
+
start: isoDay$4(m),
|
|
4578
4611
|
label: format(m, i === 0 || m.getMonth() === 0 ? "MMM yyyy" : "MMM"),
|
|
4579
4612
|
left: differenceInCalendarDays(m, first) / days,
|
|
4580
4613
|
width: differenceInCalendarDays(next, m) / days
|
|
4581
4614
|
};
|
|
4582
4615
|
});
|
|
4583
4616
|
return {
|
|
4584
|
-
start: isoDay$
|
|
4585
|
-
end: isoDay$
|
|
4617
|
+
start: isoDay$4(first),
|
|
4618
|
+
end: isoDay$4(after),
|
|
4586
4619
|
days,
|
|
4587
4620
|
months
|
|
4588
4621
|
};
|
|
@@ -4597,7 +4630,7 @@ function at(iso, w) {
|
|
|
4597
4630
|
function span$1(start, end, w) {
|
|
4598
4631
|
if (!start || !end || end < w.start || start >= w.end) return null;
|
|
4599
4632
|
const from = start < w.start ? w.start : start;
|
|
4600
|
-
const until = end >= w.end ? w.end : isoDay$
|
|
4633
|
+
const until = end >= w.end ? w.end : isoDay$4(new Date(day$6(end).getTime() + 864e5));
|
|
4601
4634
|
const left = differenceInCalendarDays(day$6(from), day$6(w.start)) / w.days;
|
|
4602
4635
|
const right = differenceInCalendarDays(day$6(until), day$6(w.start)) / w.days;
|
|
4603
4636
|
return {
|
|
@@ -7510,27 +7543,27 @@ var init_csv = __esmMin((() => {
|
|
|
7510
7543
|
*/
|
|
7511
7544
|
function pickData(s) {
|
|
7512
7545
|
return {
|
|
7513
|
-
people: s.people ?? NONE$
|
|
7514
|
-
portfolios: s.portfolios ?? NONE$
|
|
7515
|
-
programs: s.programs ?? NONE$
|
|
7516
|
-
projects: s.projects ?? NONE$
|
|
7517
|
-
milestones: s.milestones ?? NONE$
|
|
7518
|
-
raidItems: s.raidItems ?? NONE$
|
|
7519
|
-
constraints: s.constraints ?? NONE$
|
|
7520
|
-
tasks: s.tasks ?? NONE$
|
|
7521
|
-
comments: s.comments ?? NONE$
|
|
7522
|
-
attachments: s.attachments ?? NONE$
|
|
7523
|
-
activity: s.activity ?? NONE$
|
|
7546
|
+
people: s.people ?? NONE$2,
|
|
7547
|
+
portfolios: s.portfolios ?? NONE$2,
|
|
7548
|
+
programs: s.programs ?? NONE$2,
|
|
7549
|
+
projects: s.projects ?? NONE$2,
|
|
7550
|
+
milestones: s.milestones ?? NONE$2,
|
|
7551
|
+
raidItems: s.raidItems ?? NONE$2,
|
|
7552
|
+
constraints: s.constraints ?? NONE$2,
|
|
7553
|
+
tasks: s.tasks ?? NONE$2,
|
|
7554
|
+
comments: s.comments ?? NONE$2,
|
|
7555
|
+
attachments: s.attachments ?? NONE$2,
|
|
7556
|
+
activity: s.activity ?? NONE$2,
|
|
7524
7557
|
currentUserId: s.currentUserId,
|
|
7525
7558
|
boardConfigs: s.boardConfigs ?? NO_CONFIGS,
|
|
7526
|
-
readPingIds: s.readPingIds ?? NONE$
|
|
7527
|
-
ropes: s.ropes ?? NONE$
|
|
7528
|
-
checkIns: s.checkIns ?? NONE$
|
|
7529
|
-
spendEntries: s.spendEntries ?? NONE$
|
|
7530
|
-
reflections: s.reflections ?? NONE$
|
|
7559
|
+
readPingIds: s.readPingIds ?? NONE$2,
|
|
7560
|
+
ropes: s.ropes ?? NONE$2,
|
|
7561
|
+
checkIns: s.checkIns ?? NONE$2,
|
|
7562
|
+
spendEntries: s.spendEntries ?? NONE$2,
|
|
7563
|
+
reflections: s.reflections ?? NONE$2,
|
|
7531
7564
|
priorityRules: s.priorityRules ?? null,
|
|
7532
7565
|
workCalendar: s.workCalendar ?? null,
|
|
7533
|
-
dashboards: s.dashboards ?? NONE$
|
|
7566
|
+
dashboards: s.dashboards ?? NONE$2
|
|
7534
7567
|
};
|
|
7535
7568
|
}
|
|
7536
7569
|
/** The document as sent to the server: normalized and without inline file data. */
|
|
@@ -7548,9 +7581,9 @@ function payloadOf(s) {
|
|
|
7548
7581
|
} : a)
|
|
7549
7582
|
};
|
|
7550
7583
|
}
|
|
7551
|
-
var NONE$
|
|
7584
|
+
var NONE$2, NO_CONFIGS;
|
|
7552
7585
|
var init_payload = __esmMin((() => {
|
|
7553
|
-
NONE$
|
|
7586
|
+
NONE$2 = [];
|
|
7554
7587
|
NO_CONFIGS = {};
|
|
7555
7588
|
}));
|
|
7556
7589
|
|
|
@@ -8301,7 +8334,7 @@ function planSetAt(project, tasks) {
|
|
|
8301
8334
|
for (const t of tasks) if (!first || t.createdAt < first) first = t.createdAt;
|
|
8302
8335
|
first = (first ?? project.startDate).slice(0, 10);
|
|
8303
8336
|
return {
|
|
8304
|
-
since: `${isoDay$
|
|
8337
|
+
since: `${isoDay$3(addDays(noon$2(first), 7))}T00:00:00`,
|
|
8305
8338
|
from: "start"
|
|
8306
8339
|
};
|
|
8307
8340
|
}
|
|
@@ -8313,7 +8346,7 @@ function planSetAt(project, tasks) {
|
|
|
8313
8346
|
function barnaclesOf(project, tasks, people, now, slip = null) {
|
|
8314
8347
|
const { since, from } = planSetAt(project, tasks);
|
|
8315
8348
|
const today = todayISO(now);
|
|
8316
|
-
const weekAgo = isoDay$
|
|
8349
|
+
const weekAgo = isoDay$3(addDays(noon$2(today), -7));
|
|
8317
8350
|
let planned = 0;
|
|
8318
8351
|
const added = [];
|
|
8319
8352
|
for (const t of tasks) if (t.createdAt > since) added.push(t);
|
|
@@ -8321,7 +8354,7 @@ function barnaclesOf(project, tasks, people, now, slip = null) {
|
|
|
8321
8354
|
const first = startOfWeek(noon$2(since), { weekStartsOn: 1 });
|
|
8322
8355
|
const span = Math.max(0, Math.floor(differenceInCalendarDays(noon$2(today), first) / 7));
|
|
8323
8356
|
const weeks = Array.from({ length: Math.min(span + 1, 104) }, (_, i) => ({
|
|
8324
|
-
week: isoDay$
|
|
8357
|
+
week: isoDay$3(addDays(first, i * 7)),
|
|
8325
8358
|
added: 0
|
|
8326
8359
|
}));
|
|
8327
8360
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -8405,7 +8438,7 @@ function barnaclesShort(b) {
|
|
|
8405
8438
|
function briefWorthy(b) {
|
|
8406
8439
|
return b.from === "baseline" && !b.caveat && b.added >= 3 && (b.share == null || b.share >= .15);
|
|
8407
8440
|
}
|
|
8408
|
-
var SETTLE_DAYS, THIN_PLANNED, THIN_WEEKS, BULK_SHARE, BULK_MIN, BRIEF_MIN_ADDED, BRIEF_MIN_SHARE, noon$2, isoDay$
|
|
8441
|
+
var SETTLE_DAYS, THIN_PLANNED, THIN_WEEKS, BULK_SHARE, BULK_MIN, BRIEF_MIN_ADDED, BRIEF_MIN_SHARE, noon$2, isoDay$3, plural$8;
|
|
8409
8442
|
var init_barnacles = __esmMin((() => {
|
|
8410
8443
|
init_date_fns();
|
|
8411
8444
|
init_format();
|
|
@@ -8418,7 +8451,7 @@ var init_barnacles = __esmMin((() => {
|
|
|
8418
8451
|
BRIEF_MIN_ADDED = 3;
|
|
8419
8452
|
BRIEF_MIN_SHARE = .15;
|
|
8420
8453
|
noon$2 = (iso) => /* @__PURE__ */ new Date(`${iso.slice(0, 10)}T12:00:00`);
|
|
8421
|
-
isoDay$
|
|
8454
|
+
isoDay$3 = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
8422
8455
|
plural$8 = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
8423
8456
|
}));
|
|
8424
8457
|
|
|
@@ -8945,7 +8978,7 @@ function windFor(late) {
|
|
|
8945
8978
|
function capital(s) {
|
|
8946
8979
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
8947
8980
|
}
|
|
8948
|
-
function list$
|
|
8981
|
+
function list$3(names) {
|
|
8949
8982
|
if (names.length <= 1) return names.join("");
|
|
8950
8983
|
return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
8951
8984
|
}
|
|
@@ -8961,7 +8994,7 @@ function shippingForecast(data, opts) {
|
|
|
8961
8994
|
const areas = programs.filter((p) => ORDER[p.health] != null).sort((a, b) => (ORDER[a.health] ?? 9) - (ORDER[b.health] ?? 9) || a.endDate.localeCompare(b.endDate)).map((program) => area(data, program, now, today));
|
|
8962
8995
|
const opening = `And now the harbor forecast for ${opts.harborName?.trim() || "Harbor"}, issued at ${issuedAt(now)} on ${format(now, "EEEE d MMMM")}.`;
|
|
8963
8996
|
const gales = areas.filter((a) => a.health === "off-track").map((a) => a.name);
|
|
8964
|
-
const warnings = gales.length ? `There are warnings of gales in ${list$
|
|
8997
|
+
const warnings = gales.length ? `There are warnings of gales in ${list$3(gales)}.` : null;
|
|
8965
8998
|
const projectIds = new Set(data.projects.filter((p) => programs.some((g) => g.id === p.programId)).map((p) => p.id));
|
|
8966
8999
|
const tasks = data.tasks.filter((t) => projectIds.has(t.projectId));
|
|
8967
9000
|
const weekAgo = todayISO(subDays(now, 6));
|
|
@@ -8976,9 +9009,9 @@ function shippingForecast(data, opts) {
|
|
|
8976
9009
|
coda.push(`${capital(count$1(rest.length, "more area"))}, ${fair ? "fair, visibility good" : "mixed"}.`);
|
|
8977
9010
|
}
|
|
8978
9011
|
const port = programs.filter((p) => p.health === "done").map((p) => p.name);
|
|
8979
|
-
if (port.length) coda.push(`In port: ${list$
|
|
9012
|
+
if (port.length) coda.push(`In port: ${list$3(port)}.`);
|
|
8980
9013
|
const anchor = programs.filter((p) => p.health === "paused").map((p) => p.name);
|
|
8981
|
-
if (anchor.length) coda.push(`At anchor: ${list$
|
|
9014
|
+
if (anchor.length) coda.push(`At anchor: ${list$3(anchor)}.`);
|
|
8982
9015
|
const closing = areas.length || coda.length ? "That ends the harbor forecast." : "No programs at sea. That ends the harbor forecast.";
|
|
8983
9016
|
return {
|
|
8984
9017
|
opening,
|
|
@@ -12353,12 +12386,107 @@ var init_empty = __esmMin((() => {
|
|
|
12353
12386
|
STARTER_PROGRAM = "The work";
|
|
12354
12387
|
}));
|
|
12355
12388
|
|
|
12389
|
+
// src/lib/rollup-lock.ts
|
|
12390
|
+
/** "Jira RR" for a linked project, "Jira RR-42" for a task from it; the name when there's no key. */
|
|
12391
|
+
function sourceLine(external) {
|
|
12392
|
+
const tail = external.key || ("name" in external ? external.name : "");
|
|
12393
|
+
return tail ? `${sourceLabel(external.from)} ${tail}` : sourceLabel(external.from);
|
|
12394
|
+
}
|
|
12395
|
+
/**
|
|
12396
|
+
* The fields Harbor may not change on this task: none for Harbor's own tasks
|
|
12397
|
+
* and for ones gone from the other tool. Jira owns priority and subtask
|
|
12398
|
+
* parents; Asana owns the start day instead.
|
|
12399
|
+
*/
|
|
12400
|
+
function lockedFields(t) {
|
|
12401
|
+
if (!isExternal(t)) return NONE$1;
|
|
12402
|
+
return t.external.from === "asana" ? ASANA_LOCKED : JIRA_LOCKED;
|
|
12403
|
+
}
|
|
12404
|
+
/** `patch` without the fields the other tool owns; the same object when it held none. */
|
|
12405
|
+
function withoutLocked(t, patch) {
|
|
12406
|
+
const locked = lockedFields(t);
|
|
12407
|
+
if (locked.length === 0 || !locked.some((k) => k in patch)) return patch;
|
|
12408
|
+
const out = { ...patch };
|
|
12409
|
+
for (const k of locked) delete out[k];
|
|
12410
|
+
return out;
|
|
12411
|
+
}
|
|
12412
|
+
/**
|
|
12413
|
+
* Why `patch` can't be made to this task, as one sentence, or null when it
|
|
12414
|
+
* can: the task is Harbor's own, or the patch leaves the other tool's fields
|
|
12415
|
+
* as they are. Say it wherever a silent no-op would puzzle (an agent's tool
|
|
12416
|
+
* answer, a drop on the board).
|
|
12417
|
+
*/
|
|
12418
|
+
function externalRefusal(t, patch) {
|
|
12419
|
+
const touched = lockedFields(t).filter((k) => k in patch && !sameValue(patch[k], t[k]));
|
|
12420
|
+
if (touched.length === 0) return null;
|
|
12421
|
+
const ext = t.external;
|
|
12422
|
+
const tool = sourceLabel(ext.from);
|
|
12423
|
+
const from = `“${t.title}” is kept in step from ${tool}${ext.key ? ` (${ext.key})` : ""}`;
|
|
12424
|
+
const words = [...new Set(touched.flatMap((k) => FIELD_WORD[k] ?? []))];
|
|
12425
|
+
if (words.length === 0) return `${from}, so it can't ${touched.includes("repeat") ? "repeat" : "be sent for approval"} here.`;
|
|
12426
|
+
return `${from}. Change its ${words.length === 1 ? words[0] : `${words.slice(0, -1).join(", ")} and ${words[words.length - 1]}`} there; Harbor follows.`;
|
|
12427
|
+
}
|
|
12428
|
+
/** Why this task can't be deleted here, or null when it can. */
|
|
12429
|
+
function externalDeleteRefusal(t) {
|
|
12430
|
+
if (!isExternal(t)) return null;
|
|
12431
|
+
const ext = t.external;
|
|
12432
|
+
const tool = sourceLabel(ext.from);
|
|
12433
|
+
return `“${t.title}” is kept in step from ${tool}${ext.key ? ` (${ext.key})` : ""}. Remove it there, or unlink the project; Harbor follows.`;
|
|
12434
|
+
}
|
|
12435
|
+
var SOURCE_LABEL, sourceLabel, isExternal, JIRA_LOCKED, ASANA_LOCKED, NONE$1, FIELD_WORD, sameValue;
|
|
12436
|
+
var init_rollup_lock = __esmMin((() => {
|
|
12437
|
+
SOURCE_LABEL = {
|
|
12438
|
+
jira: "Jira",
|
|
12439
|
+
asana: "Asana"
|
|
12440
|
+
};
|
|
12441
|
+
sourceLabel = (from) => SOURCE_LABEL[from] ?? "Jira";
|
|
12442
|
+
isExternal = (t) => !!t.external && !t.external.goneAt;
|
|
12443
|
+
JIRA_LOCKED = [
|
|
12444
|
+
"title",
|
|
12445
|
+
"status",
|
|
12446
|
+
"completedAt",
|
|
12447
|
+
"assigneeId",
|
|
12448
|
+
"dueDate",
|
|
12449
|
+
"priority",
|
|
12450
|
+
"parentTaskId",
|
|
12451
|
+
"projectId",
|
|
12452
|
+
"approval",
|
|
12453
|
+
"repeat"
|
|
12454
|
+
];
|
|
12455
|
+
ASANA_LOCKED = [
|
|
12456
|
+
"title",
|
|
12457
|
+
"status",
|
|
12458
|
+
"completedAt",
|
|
12459
|
+
"assigneeId",
|
|
12460
|
+
"dueDate",
|
|
12461
|
+
"startDate",
|
|
12462
|
+
"projectId",
|
|
12463
|
+
"approval",
|
|
12464
|
+
"repeat"
|
|
12465
|
+
];
|
|
12466
|
+
NONE$1 = Object.freeze([]);
|
|
12467
|
+
FIELD_WORD = {
|
|
12468
|
+
title: "title",
|
|
12469
|
+
status: "status",
|
|
12470
|
+
completedAt: "status",
|
|
12471
|
+
assigneeId: "owner",
|
|
12472
|
+
dueDate: "due day",
|
|
12473
|
+
startDate: "start day",
|
|
12474
|
+
priority: "priority",
|
|
12475
|
+
parentTaskId: "parent task",
|
|
12476
|
+
projectId: "project"
|
|
12477
|
+
};
|
|
12478
|
+
sameValue = (a, b) => (a ?? null) === (b ?? null) || JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
|
|
12479
|
+
}));
|
|
12480
|
+
|
|
12356
12481
|
// src/tui/moves.ts
|
|
12357
12482
|
init_empty();
|
|
12358
12483
|
init_board();
|
|
12484
|
+
init_rollup_lock();
|
|
12359
12485
|
function moveTask(store, go, task, status) {
|
|
12360
12486
|
const s = store.getState();
|
|
12361
12487
|
if (task.status === status) return;
|
|
12488
|
+
const refusal = externalRefusal(task, { status });
|
|
12489
|
+
if (refusal) return go.notify(refusal);
|
|
12362
12490
|
const overflow = columnWip(s, task.projectId, status, 1);
|
|
12363
12491
|
if (!overflow) return s.moveTask(task.id, status);
|
|
12364
12492
|
if (s.myRole !== "owner") return go.notify(wipFullMessage(overflow));
|
|
@@ -12922,14 +13050,14 @@ const CREATED = {
|
|
|
12922
13050
|
decision: "recorded decision",
|
|
12923
13051
|
hold: "named what's holding it back:"
|
|
12924
13052
|
};
|
|
12925
|
-
const whole = new Intl.NumberFormat("en-US", {
|
|
13053
|
+
const whole$1 = new Intl.NumberFormat("en-US", {
|
|
12926
13054
|
style: "currency",
|
|
12927
13055
|
currency: "USD",
|
|
12928
13056
|
maximumFractionDigits: 0
|
|
12929
13057
|
});
|
|
12930
13058
|
function dollars(value) {
|
|
12931
13059
|
const n = Number(value ?? 0);
|
|
12932
|
-
return whole.format(Number.isFinite(n) ? n : 0);
|
|
13060
|
+
return whole$1.format(Number.isFinite(n) ? n : 0);
|
|
12933
13061
|
}
|
|
12934
13062
|
function day$3(value) {
|
|
12935
13063
|
return value ? shortDate(value) : "no date";
|
|
@@ -14002,8 +14130,8 @@ function inboxOf(data, personId, now = clockNow()) {
|
|
|
14002
14130
|
pings.push({
|
|
14003
14131
|
id: `task-approve:${task.id}:${shortHash(a.askedAt)}`,
|
|
14004
14132
|
kind: "approval",
|
|
14005
|
-
title: `${by ? firstName$3(by.name) : "Someone"} asked for your approval`,
|
|
14006
|
-
detail: `${where} · approve it, or ask for changes`,
|
|
14133
|
+
title: by?.kind === "agent" ? `${firstName$3(by.name)} handed in work for you to check` : `${by ? firstName$3(by.name) : "Someone"} asked for your approval`,
|
|
14134
|
+
detail: `${where} · approve it, or ${by?.kind === "agent" ? "send it back with a note" : "ask for changes"}`,
|
|
14007
14135
|
at: a.askedAt,
|
|
14008
14136
|
taskId: task.id,
|
|
14009
14137
|
personId: a.askedById,
|
|
@@ -14332,7 +14460,7 @@ var init_load = __esmMin((() => {
|
|
|
14332
14460
|
/** Everything a person carries that someone else would have to pick up, grouped in KIND_ORDER. */
|
|
14333
14461
|
function handoverItems(data, personId) {
|
|
14334
14462
|
const projects = byId(data.projects);
|
|
14335
|
-
const tasks = data.tasks.filter((t) => t.assigneeId === personId && t.status !== "done").map((t) => {
|
|
14463
|
+
const tasks = data.tasks.filter((t) => t.assigneeId === personId && t.status !== "done" && !lockedFields(t).includes("assigneeId")).map((t) => {
|
|
14336
14464
|
const project = projects.get(t.projectId);
|
|
14337
14465
|
const key = taskKey(t, project);
|
|
14338
14466
|
return {
|
|
@@ -14416,7 +14544,7 @@ function noTakerReason(data, fromId, today) {
|
|
|
14416
14544
|
function suggestTakers(data, fromId, items, now, today) {
|
|
14417
14545
|
const people = takers(data, fromId, today);
|
|
14418
14546
|
const ids = new Set(people.map((p) => p.id));
|
|
14419
|
-
const weekEnd = isoDay$
|
|
14547
|
+
const weekEnd = isoDay$2(addDays(startOfWeek(now, { weekStartsOn: 1 }), 6));
|
|
14420
14548
|
const room = new Map(people.map((p) => [p.id, p.weeklyCapacity ?? 5]));
|
|
14421
14549
|
const inProject = /* @__PURE__ */ new Map();
|
|
14422
14550
|
for (const t of data.tasks) {
|
|
@@ -14482,7 +14610,7 @@ function roomLabel(room) {
|
|
|
14482
14610
|
if (room <= 0) return "full this week";
|
|
14483
14611
|
return null;
|
|
14484
14612
|
}
|
|
14485
|
-
function isoDay$
|
|
14613
|
+
function isoDay$2(d) {
|
|
14486
14614
|
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
14487
14615
|
const day = String(d.getDate()).padStart(2, "0");
|
|
14488
14616
|
return `${d.getFullYear()}-${m}-${day}`;
|
|
@@ -14505,7 +14633,7 @@ function returnable(data, person) {
|
|
|
14505
14633
|
switch (m.kind) {
|
|
14506
14634
|
case "task": {
|
|
14507
14635
|
const t = tasks.get(m.id);
|
|
14508
|
-
return Boolean(t && t.assigneeId === m.toId && t.status !== "done");
|
|
14636
|
+
return Boolean(t && t.assigneeId === m.toId && t.status !== "done" && !lockedFields(t).includes("assigneeId"));
|
|
14509
14637
|
}
|
|
14510
14638
|
case "signoff": {
|
|
14511
14639
|
const ms = milestones.get(m.id);
|
|
@@ -14540,6 +14668,7 @@ var init_handover = __esmMin((() => {
|
|
|
14540
14668
|
init_load();
|
|
14541
14669
|
init_task_keys();
|
|
14542
14670
|
init_indexes();
|
|
14671
|
+
init_rollup_lock();
|
|
14543
14672
|
KIND_HEADING = {
|
|
14544
14673
|
task: "Tasks",
|
|
14545
14674
|
signoff: "Sign-offs waiting on them",
|
|
@@ -14563,7 +14692,7 @@ init_handover();
|
|
|
14563
14692
|
const SOON_DAYS = 21;
|
|
14564
14693
|
/** This many open tasks in one project that only one person has touched read as their corner of it. */
|
|
14565
14694
|
const CLUSTER = 4;
|
|
14566
|
-
const isoDay = (d) => d.toISOString().slice(0, 10);
|
|
14695
|
+
const isoDay$1 = (d) => d.toISOString().slice(0, 10);
|
|
14567
14696
|
const md = (iso) => format(parseIso(iso), "MMM d");
|
|
14568
14697
|
/** Everyone a task has passed through. */
|
|
14569
14698
|
function taskHands(task, commentsBy, attachedBy) {
|
|
@@ -14598,8 +14727,8 @@ function byTask(rows, who) {
|
|
|
14598
14727
|
const plural$5 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
14599
14728
|
/** Work only one person has touched, soonest-needed first. `scope` narrows it to some programs. */
|
|
14600
14729
|
function lifeboats(data, now, opts = {}) {
|
|
14601
|
-
const today = isoDay(now);
|
|
14602
|
-
const soon = isoDay(addDays(now, SOON_DAYS));
|
|
14730
|
+
const today = isoDay$1(now);
|
|
14731
|
+
const soon = isoDay$1(addDays(now, SOON_DAYS));
|
|
14603
14732
|
const people = byId(data.people);
|
|
14604
14733
|
const projects = byId(data.projects);
|
|
14605
14734
|
const programs = byId(data.programs);
|
|
@@ -14728,8 +14857,8 @@ function lifeboats(data, now, opts = {}) {
|
|
|
14728
14857
|
}
|
|
14729
14858
|
/** Who could be a second pair of hands: room this week, and already working nearby. */
|
|
14730
14859
|
function withSuggestions(data, lines, now) {
|
|
14731
|
-
const today = isoDay(now);
|
|
14732
|
-
const weekEnd = isoDay(addDays(startOfWeek(now, { weekStartsOn: 1 }), 6));
|
|
14860
|
+
const today = isoDay$1(now);
|
|
14861
|
+
const weekEnd = isoDay$1(addDays(startOfWeek(now, { weekStartsOn: 1 }), 6));
|
|
14733
14862
|
const people = data.people.filter((p) => p.kind !== "agent" && !isAway(p, today));
|
|
14734
14863
|
const room = new Map(people.map((p) => [p.id, p.weeklyCapacity ?? 5]));
|
|
14735
14864
|
const inProject = /* @__PURE__ */ new Map();
|
|
@@ -17657,9 +17786,10 @@ init_date_fns();
|
|
|
17657
17786
|
init_format();
|
|
17658
17787
|
init_indexes();
|
|
17659
17788
|
init_load();
|
|
17789
|
+
init_rollup_lock();
|
|
17660
17790
|
init_task_keys();
|
|
17661
17791
|
init_tide();
|
|
17662
|
-
const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
17792
|
+
const ISO_DAY$1 = /^\d{4}-\d{2}-\d{2}$/;
|
|
17663
17793
|
const MAX_ADD = 200;
|
|
17664
17794
|
/**
|
|
17665
17795
|
* The changes a saved dry dock holds, read tolerantly: it travels in the
|
|
@@ -17690,7 +17820,7 @@ function readDock(raw) {
|
|
|
17690
17820
|
break;
|
|
17691
17821
|
}
|
|
17692
17822
|
case "due":
|
|
17693
|
-
if (str("taskId") && (r.dueDate === null || ISO_DAY.test(str("dueDate") ?? ""))) out.push({
|
|
17823
|
+
if (str("taskId") && (r.dueDate === null || ISO_DAY$1.test(str("dueDate") ?? ""))) out.push({
|
|
17694
17824
|
kind: "due",
|
|
17695
17825
|
taskId: str("taskId"),
|
|
17696
17826
|
dueDate: str("dueDate")
|
|
@@ -17704,7 +17834,7 @@ function readDock(raw) {
|
|
|
17704
17834
|
});
|
|
17705
17835
|
break;
|
|
17706
17836
|
case "end":
|
|
17707
|
-
if (ISO_DAY.test(str("endDate") ?? "")) out.push({
|
|
17837
|
+
if (ISO_DAY$1.test(str("endDate") ?? "")) out.push({
|
|
17708
17838
|
kind: "end",
|
|
17709
17839
|
endDate: str("endDate")
|
|
17710
17840
|
});
|
|
@@ -17963,12 +18093,48 @@ function describeChange(c, data) {
|
|
|
17963
18093
|
}
|
|
17964
18094
|
}
|
|
17965
18095
|
/**
|
|
18096
|
+
* The changes applying would leave out because Jira (or Asana) owns what they
|
|
18097
|
+
* touch: dropping a task kept in step from it, its due day or its owner, and
|
|
18098
|
+
* taking someone off when every open task of theirs here is such a task.
|
|
18099
|
+
*/
|
|
18100
|
+
function dockHeld(data, projectId, changes) {
|
|
18101
|
+
const tasks = byId(data.tasks);
|
|
18102
|
+
const owns = (id, field) => {
|
|
18103
|
+
const t = tasks.get(id);
|
|
18104
|
+
return !!t && t.projectId === projectId && lockedFields(t).includes(field);
|
|
18105
|
+
};
|
|
18106
|
+
return changes.filter((c) => {
|
|
18107
|
+
switch (c.kind) {
|
|
18108
|
+
case "drop": {
|
|
18109
|
+
const t = tasks.get(c.taskId);
|
|
18110
|
+
return !!t && t.projectId === projectId && isExternal(t);
|
|
18111
|
+
}
|
|
18112
|
+
case "due": return owns(c.taskId, "dueDate");
|
|
18113
|
+
case "assign": return owns(c.taskId, "assigneeId");
|
|
18114
|
+
case "release": {
|
|
18115
|
+
const theirs = tasksOf(data.tasks, projectId).filter((t) => t.assigneeId === c.personId && t.status !== "done");
|
|
18116
|
+
return theirs.length > 0 && theirs.every((t) => lockedFields(t).includes("assigneeId"));
|
|
18117
|
+
}
|
|
18118
|
+
default: return false;
|
|
18119
|
+
}
|
|
18120
|
+
});
|
|
18121
|
+
}
|
|
18122
|
+
/** "2 changes left out: Jira owns what they would change." Empty when none were. */
|
|
18123
|
+
function heldText(data, projectId, held) {
|
|
18124
|
+
if (held.length === 0) return "";
|
|
18125
|
+
const from = tasksOf(data.tasks, projectId).find(isExternal)?.external?.from ?? "jira";
|
|
18126
|
+
return held.length === 1 ? `1 change left out: ${sourceLabel(from)} owns what it would change.` : `${held.length} changes left out: ${sourceLabel(from)} owns what they would change.`;
|
|
18127
|
+
}
|
|
18128
|
+
/**
|
|
17966
18129
|
* Makes the changes for real, in order, through the store's own actions,
|
|
17967
18130
|
* and clears a saved dry dock from the project. Changes that no longer fit
|
|
17968
|
-
* are skipped
|
|
18131
|
+
* are skipped, and so are the ones `dockHeld` names: those stay on a saved
|
|
18132
|
+
* dry dock, so the plan someone agreed to isn't lost with them. Returns how
|
|
18133
|
+
* many were made.
|
|
17969
18134
|
*/
|
|
17970
18135
|
function applyDock(actions, projectId, changes) {
|
|
17971
|
-
const
|
|
18136
|
+
const start = actions.getState();
|
|
18137
|
+
const project = start.projects.find((p) => p.id === projectId);
|
|
17972
18138
|
if (!project) return 0;
|
|
17973
18139
|
const has = (id) => actions.getState().tasks.some((t) => t.id === id && t.projectId === projectId);
|
|
17974
18140
|
const person = (id) => !id || actions.getState().people.some((p) => p.id === id);
|
|
@@ -17976,8 +18142,11 @@ function applyDock(actions, projectId, changes) {
|
|
|
17976
18142
|
allowOverCap: true,
|
|
17977
18143
|
allowBlocked: true
|
|
17978
18144
|
};
|
|
18145
|
+
const held = dockHeld(start, projectId, changes);
|
|
18146
|
+
const left = new Set(held);
|
|
17979
18147
|
let made = 0;
|
|
17980
18148
|
for (const c of changes) {
|
|
18149
|
+
if (left.has(c)) continue;
|
|
17981
18150
|
switch (c.kind) {
|
|
17982
18151
|
case "drop":
|
|
17983
18152
|
if (!has(c.taskId)) continue;
|
|
@@ -18021,7 +18190,11 @@ function applyDock(actions, projectId, changes) {
|
|
|
18021
18190
|
}
|
|
18022
18191
|
made += 1;
|
|
18023
18192
|
}
|
|
18024
|
-
|
|
18193
|
+
const saved = actions.getState().projects.find((p) => p.id === projectId)?.dryDock;
|
|
18194
|
+
if (saved) actions.updateProject(projectId, { dryDock: held.length ? {
|
|
18195
|
+
...saved,
|
|
18196
|
+
changes: held
|
|
18197
|
+
} : null });
|
|
18025
18198
|
return made;
|
|
18026
18199
|
}
|
|
18027
18200
|
|
|
@@ -18395,6 +18568,597 @@ function oldSalts(data, project) {
|
|
|
18395
18568
|
return out.slice(0, 3);
|
|
18396
18569
|
}
|
|
18397
18570
|
|
|
18571
|
+
// src/lib/assignment.ts
|
|
18572
|
+
/**
|
|
18573
|
+
* Record who set a task's assignee and when. Only a change of assignee
|
|
18574
|
+
* stamps; clearing the assignee clears the stamp.
|
|
18575
|
+
*/
|
|
18576
|
+
function stampAssignment(before, next, by, at) {
|
|
18577
|
+
if (before && before.assigneeId === next.assigneeId) return next;
|
|
18578
|
+
if (!next.assigneeId) return {
|
|
18579
|
+
...next,
|
|
18580
|
+
assignedBy: null,
|
|
18581
|
+
assignedAt: null
|
|
18582
|
+
};
|
|
18583
|
+
return {
|
|
18584
|
+
...next,
|
|
18585
|
+
assignedBy: by,
|
|
18586
|
+
assignedAt: at
|
|
18587
|
+
};
|
|
18588
|
+
}
|
|
18589
|
+
var init_assignment = __esmMin((() => {}));
|
|
18590
|
+
|
|
18591
|
+
// src/lib/scuttle-rows.ts
|
|
18592
|
+
/** Whether it's scuttled: closed through Scuttle or sail and not raised since. */
|
|
18593
|
+
function isScuttled(project) {
|
|
18594
|
+
return Boolean(project.scuttled) && project.healthOverride === "done";
|
|
18595
|
+
}
|
|
18596
|
+
/**
|
|
18597
|
+
* Scuttle a project: Done by hand with the reason as its note, its open
|
|
18598
|
+
* tasks unassigned and undated (kept in `scuttled.freed`; tasks kept in step
|
|
18599
|
+
* from Jira are left as they are), and a decision on the register. Null for a project that's already scuttled or gone, or a
|
|
18600
|
+
* blank why.
|
|
18601
|
+
*/
|
|
18602
|
+
function scuttleRows(data, projectId, why, byId, at, decisionId, context = "Closed through Scuttle or sail.") {
|
|
18603
|
+
const project = data.projects.find((p) => p.id === projectId);
|
|
18604
|
+
const reason = why.trim().slice(0, 600);
|
|
18605
|
+
if (!project || !reason || isScuttled(project)) return null;
|
|
18606
|
+
const freed = [];
|
|
18607
|
+
const tasks = [];
|
|
18608
|
+
for (const t of tasksOf(data.tasks, projectId)) {
|
|
18609
|
+
if (t.status === "done" || !t.assigneeId && !t.dueDate || kept(t)) continue;
|
|
18610
|
+
freed.push({
|
|
18611
|
+
taskId: t.id,
|
|
18612
|
+
assigneeId: t.assigneeId,
|
|
18613
|
+
dueDate: t.dueDate
|
|
18614
|
+
});
|
|
18615
|
+
tasks.push(stampAssignment(t, {
|
|
18616
|
+
...t,
|
|
18617
|
+
assigneeId: null,
|
|
18618
|
+
dueDate: null,
|
|
18619
|
+
touchedAt: at
|
|
18620
|
+
}, byId, at));
|
|
18621
|
+
}
|
|
18622
|
+
const decision = normalizeRaidItem({
|
|
18623
|
+
id: decisionId,
|
|
18624
|
+
kind: "decision",
|
|
18625
|
+
projectId,
|
|
18626
|
+
title: `Scuttle ${project.name}`,
|
|
18627
|
+
description: context,
|
|
18628
|
+
status: "decided",
|
|
18629
|
+
severity: "low",
|
|
18630
|
+
ownerId: byId,
|
|
18631
|
+
dueDate: null,
|
|
18632
|
+
resolution: "Stop the project. Its open tasks come off people’s lists.",
|
|
18633
|
+
rationale: reason,
|
|
18634
|
+
decidedById: byId,
|
|
18635
|
+
decidedAt: at,
|
|
18636
|
+
createdById: byId,
|
|
18637
|
+
createdAt: at,
|
|
18638
|
+
updatedAt: at,
|
|
18639
|
+
updates: []
|
|
18640
|
+
});
|
|
18641
|
+
return {
|
|
18642
|
+
project: {
|
|
18643
|
+
...project,
|
|
18644
|
+
health: "done",
|
|
18645
|
+
healthOverride: "done",
|
|
18646
|
+
healthNote: `Scuttled: ${reason}`,
|
|
18647
|
+
scuttled: {
|
|
18648
|
+
at,
|
|
18649
|
+
byId,
|
|
18650
|
+
why: reason,
|
|
18651
|
+
decisionId,
|
|
18652
|
+
freed
|
|
18653
|
+
}
|
|
18654
|
+
},
|
|
18655
|
+
tasks,
|
|
18656
|
+
decision
|
|
18657
|
+
};
|
|
18658
|
+
}
|
|
18659
|
+
/**
|
|
18660
|
+
* Raise a scuttled project: the scuttle cleared (the caller clears its Done), and each
|
|
18661
|
+
* freed task given back its person and date, unless someone has since given
|
|
18662
|
+
* it others, it's done, or the person has left the crew. Null when it isn't
|
|
18663
|
+
* scuttled.
|
|
18664
|
+
*/
|
|
18665
|
+
function raiseRows(data, projectId, at, byId) {
|
|
18666
|
+
const project = data.projects.find((p) => p.id === projectId);
|
|
18667
|
+
if (!project?.scuttled) return null;
|
|
18668
|
+
const people = new Set(data.people.map((p) => p.id));
|
|
18669
|
+
const byTask = new Map(project.scuttled.freed.map((f) => [f.taskId, f]));
|
|
18670
|
+
const tasks = [];
|
|
18671
|
+
for (const t of tasksOf(data.tasks, projectId)) {
|
|
18672
|
+
const f = byTask.get(t.id);
|
|
18673
|
+
if (!f || t.status === "done" || kept(t)) continue;
|
|
18674
|
+
const assigneeId = !t.assigneeId && f.assigneeId && people.has(f.assigneeId) ? f.assigneeId : t.assigneeId;
|
|
18675
|
+
const dueDate = t.dueDate ?? f.dueDate;
|
|
18676
|
+
if (assigneeId === t.assigneeId && dueDate === t.dueDate) continue;
|
|
18677
|
+
tasks.push(stampAssignment(t, {
|
|
18678
|
+
...t,
|
|
18679
|
+
assigneeId,
|
|
18680
|
+
dueDate,
|
|
18681
|
+
touchedAt: at
|
|
18682
|
+
}, byId, at));
|
|
18683
|
+
}
|
|
18684
|
+
return {
|
|
18685
|
+
project: {
|
|
18686
|
+
...project,
|
|
18687
|
+
scuttled: null,
|
|
18688
|
+
voyageCall: {
|
|
18689
|
+
call: "sail",
|
|
18690
|
+
at,
|
|
18691
|
+
byId
|
|
18692
|
+
}
|
|
18693
|
+
},
|
|
18694
|
+
tasks
|
|
18695
|
+
};
|
|
18696
|
+
}
|
|
18697
|
+
var WHY_MAX, kept;
|
|
18698
|
+
var init_scuttle_rows = __esmMin((() => {
|
|
18699
|
+
init_assignment();
|
|
18700
|
+
init_indexes();
|
|
18701
|
+
init_raid();
|
|
18702
|
+
init_rollup_lock();
|
|
18703
|
+
WHY_MAX = 600;
|
|
18704
|
+
kept = (t) => {
|
|
18705
|
+
const locked = lockedFields(t);
|
|
18706
|
+
return locked.includes("assigneeId") || locked.includes("dueDate");
|
|
18707
|
+
};
|
|
18708
|
+
}));
|
|
18709
|
+
|
|
18710
|
+
// src/lib/sea-trial.ts
|
|
18711
|
+
init_date_fns();
|
|
18712
|
+
init_first_voyage();
|
|
18713
|
+
init_format();
|
|
18714
|
+
init_indexes();
|
|
18715
|
+
init_scuttle_rows();
|
|
18716
|
+
init_tide();
|
|
18717
|
+
const TRIAL_MAX_CHANGES = 30;
|
|
18718
|
+
const TRIAL_MAX_TASKS = 200;
|
|
18719
|
+
const TRIAL_MAX_WEEKS = 104;
|
|
18720
|
+
const TRIAL_MAX_CREW = 20;
|
|
18721
|
+
const NAME_MAX = 120;
|
|
18722
|
+
const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
18723
|
+
const whole = (v, min, max) => {
|
|
18724
|
+
const n = Math.round(Number(v));
|
|
18725
|
+
return Number.isFinite(n) && n >= min ? Math.min(max, n) : null;
|
|
18726
|
+
};
|
|
18727
|
+
/**
|
|
18728
|
+
* The changes a saved sea trial holds, read tolerantly: it travels in the
|
|
18729
|
+
* document, so anything that isn't a change Harbor knows is left out.
|
|
18730
|
+
*/
|
|
18731
|
+
function readTrial(raw) {
|
|
18732
|
+
if (!Array.isArray(raw)) return [];
|
|
18733
|
+
const out = [];
|
|
18734
|
+
for (const c of raw) {
|
|
18735
|
+
if (out.length >= 30) break;
|
|
18736
|
+
if (!c || typeof c !== "object") continue;
|
|
18737
|
+
const r = c;
|
|
18738
|
+
const str = (k) => typeof r[k] === "string" && r[k] ? r[k] : null;
|
|
18739
|
+
switch (r.kind) {
|
|
18740
|
+
case "start": {
|
|
18741
|
+
const name = str("name")?.trim().slice(0, NAME_MAX);
|
|
18742
|
+
const programId = str("programId");
|
|
18743
|
+
const tasks = whole(r.tasks, 1, 200);
|
|
18744
|
+
const weeks = whole(r.weeks, 1, 104);
|
|
18745
|
+
const crewIds = Array.isArray(r.crewIds) ? [...new Set(r.crewIds.filter((id) => typeof id === "string" && !!id))] : [];
|
|
18746
|
+
if (name && programId && tasks && weeks) out.push({
|
|
18747
|
+
kind: "start",
|
|
18748
|
+
name,
|
|
18749
|
+
programId,
|
|
18750
|
+
tasks,
|
|
18751
|
+
weeks,
|
|
18752
|
+
crewIds: crewIds.slice(0, 20)
|
|
18753
|
+
});
|
|
18754
|
+
break;
|
|
18755
|
+
}
|
|
18756
|
+
case "pause":
|
|
18757
|
+
case "stop":
|
|
18758
|
+
if (str("projectId")) out.push({
|
|
18759
|
+
kind: r.kind,
|
|
18760
|
+
projectId: str("projectId")
|
|
18761
|
+
});
|
|
18762
|
+
break;
|
|
18763
|
+
case "move": {
|
|
18764
|
+
const days = whole(r.days, 1, 5);
|
|
18765
|
+
const personId = str("personId");
|
|
18766
|
+
const from = str("fromProjectId");
|
|
18767
|
+
const to = str("toProjectId");
|
|
18768
|
+
if (personId && from && to && from !== to && days) out.push({
|
|
18769
|
+
kind: "move",
|
|
18770
|
+
personId,
|
|
18771
|
+
fromProjectId: from,
|
|
18772
|
+
toProjectId: to,
|
|
18773
|
+
days
|
|
18774
|
+
});
|
|
18775
|
+
break;
|
|
18776
|
+
}
|
|
18777
|
+
case "end": {
|
|
18778
|
+
const endDate = str("endDate");
|
|
18779
|
+
if (str("projectId") && endDate && ISO_DAY.test(endDate)) out.push({
|
|
18780
|
+
kind: "end",
|
|
18781
|
+
projectId: str("projectId"),
|
|
18782
|
+
endDate
|
|
18783
|
+
});
|
|
18784
|
+
break;
|
|
18785
|
+
}
|
|
18786
|
+
}
|
|
18787
|
+
}
|
|
18788
|
+
return out;
|
|
18789
|
+
}
|
|
18790
|
+
/** The projects a portfolio's sea trial can touch: its own, open ones (First voyage is practice). */
|
|
18791
|
+
function trialProjects(data, portfolioId) {
|
|
18792
|
+
const programs = new Set(data.programs.filter((p) => p.portfolioId === portfolioId).map((p) => p.id));
|
|
18793
|
+
return ownProjects(data.projects).filter((p) => programs.has(p.programId) && p.health !== "done");
|
|
18794
|
+
}
|
|
18795
|
+
/** The id a started project carries on the copy: its place among the changes. */
|
|
18796
|
+
const trialProjectId = (index) => `trial-${index}`;
|
|
18797
|
+
const isoDay = (d) => todayISO(d);
|
|
18798
|
+
/** The portfolio as it would be with the changes, on a copy. */
|
|
18799
|
+
function trialPlan(data, portfolioId, changes, now) {
|
|
18800
|
+
if (!data.portfolios.some((p) => p.id === portfolioId)) return null;
|
|
18801
|
+
const open = new Map(trialProjects(data, portfolioId).map((p) => [p.id, p]));
|
|
18802
|
+
const programs = new Map(data.programs.filter((p) => p.portfolioId === portfolioId).map((p) => [p.id, p]));
|
|
18803
|
+
const people = byId(data.people);
|
|
18804
|
+
const today = isoDay(now);
|
|
18805
|
+
const at = now.toISOString();
|
|
18806
|
+
const projects = /* @__PURE__ */ new Map();
|
|
18807
|
+
/** Per project, the tasks that replace its real ones. */
|
|
18808
|
+
const swapped = /* @__PURE__ */ new Map();
|
|
18809
|
+
const added = [];
|
|
18810
|
+
const startedProjects = [];
|
|
18811
|
+
const dock = /* @__PURE__ */ new Map();
|
|
18812
|
+
const touched = [];
|
|
18813
|
+
const started = /* @__PURE__ */ new Set();
|
|
18814
|
+
const touchedPeople = /* @__PURE__ */ new Set();
|
|
18815
|
+
const stale = [];
|
|
18816
|
+
/** A project stopped or paused earlier in the list can't take a later move. */
|
|
18817
|
+
const closed = /* @__PURE__ */ new Set();
|
|
18818
|
+
const touch = (id) => {
|
|
18819
|
+
if (!touched.includes(id)) touched.push(id);
|
|
18820
|
+
};
|
|
18821
|
+
const tasksNow = (id) => swapped.get(id) ?? tasksOf(data.tasks, id);
|
|
18822
|
+
const projectNow = (id) => projects.get(id) ?? open.get(id);
|
|
18823
|
+
changes.forEach((c, i) => {
|
|
18824
|
+
switch (c.kind) {
|
|
18825
|
+
case "start": {
|
|
18826
|
+
const program = programs.get(c.programId);
|
|
18827
|
+
const crew = c.crewIds.filter((id) => people.has(id));
|
|
18828
|
+
if (!program || crew.length !== c.crewIds.length) {
|
|
18829
|
+
stale.push(c);
|
|
18830
|
+
break;
|
|
18831
|
+
}
|
|
18832
|
+
const id = trialProjectId(i);
|
|
18833
|
+
startedProjects.push(startedProject(id, c, program, today));
|
|
18834
|
+
const span = c.weeks * 7;
|
|
18835
|
+
for (let n = 1; n <= c.tasks; n++) {
|
|
18836
|
+
const assigneeId = crew.length ? crew[(n - 1) % crew.length] : null;
|
|
18837
|
+
added.push({
|
|
18838
|
+
id: `${id}-${n}`,
|
|
18839
|
+
projectId: id,
|
|
18840
|
+
title: startTaskTitle(c.name, n),
|
|
18841
|
+
description: "",
|
|
18842
|
+
status: "todo",
|
|
18843
|
+
priority: "medium",
|
|
18844
|
+
assigneeId,
|
|
18845
|
+
dueDate: isoDay(addDays(/* @__PURE__ */ new Date(`${today}T12:00:00`), Math.ceil(n * span / c.tasks))),
|
|
18846
|
+
createdAt: at,
|
|
18847
|
+
completedAt: null,
|
|
18848
|
+
checklist: [],
|
|
18849
|
+
blockedById: null
|
|
18850
|
+
});
|
|
18851
|
+
}
|
|
18852
|
+
for (const p of crew) touchedPeople.add(p);
|
|
18853
|
+
started.add(id);
|
|
18854
|
+
touch(id);
|
|
18855
|
+
break;
|
|
18856
|
+
}
|
|
18857
|
+
case "pause":
|
|
18858
|
+
if (!open.has(c.projectId) || closed.has(c.projectId) || open.get(c.projectId).health === "paused") {
|
|
18859
|
+
stale.push(c);
|
|
18860
|
+
break;
|
|
18861
|
+
}
|
|
18862
|
+
projects.set(c.projectId, {
|
|
18863
|
+
...projectNow(c.projectId),
|
|
18864
|
+
health: "paused"
|
|
18865
|
+
});
|
|
18866
|
+
closed.add(c.projectId);
|
|
18867
|
+
touch(c.projectId);
|
|
18868
|
+
break;
|
|
18869
|
+
case "stop": {
|
|
18870
|
+
if (!open.has(c.projectId) || closed.has(c.projectId)) {
|
|
18871
|
+
stale.push(c);
|
|
18872
|
+
break;
|
|
18873
|
+
}
|
|
18874
|
+
const rows = scuttleRows({
|
|
18875
|
+
projects: [projectNow(c.projectId)],
|
|
18876
|
+
tasks: [...tasksNow(c.projectId)]
|
|
18877
|
+
}, c.projectId, STOP_WHY, "", at, "");
|
|
18878
|
+
if (!rows) {
|
|
18879
|
+
stale.push(c);
|
|
18880
|
+
break;
|
|
18881
|
+
}
|
|
18882
|
+
const freed = new Map(rows.tasks.map((t) => [t.id, t]));
|
|
18883
|
+
for (const t of tasksNow(c.projectId)) if (freed.has(t.id) && t.assigneeId) touchedPeople.add(t.assigneeId);
|
|
18884
|
+
swapped.set(c.projectId, tasksNow(c.projectId).map((t) => freed.get(t.id) ?? t));
|
|
18885
|
+
projects.set(c.projectId, rows.project);
|
|
18886
|
+
closed.add(c.projectId);
|
|
18887
|
+
touch(c.projectId);
|
|
18888
|
+
break;
|
|
18889
|
+
}
|
|
18890
|
+
case "move": {
|
|
18891
|
+
if (!people.has(c.personId) || !open.has(c.fromProjectId) || !open.has(c.toProjectId) || closed.has(c.fromProjectId) || closed.has(c.toProjectId)) {
|
|
18892
|
+
stale.push(c);
|
|
18893
|
+
break;
|
|
18894
|
+
}
|
|
18895
|
+
swapped.set(c.fromProjectId, tasksNow(c.fromProjectId).map((t) => t.assigneeId === c.personId && t.status !== "done" ? {
|
|
18896
|
+
...t,
|
|
18897
|
+
assigneeId: null
|
|
18898
|
+
} : t));
|
|
18899
|
+
const leaving = dock.get(c.fromProjectId) ?? [];
|
|
18900
|
+
if (!leaving.some((d) => d.kind === "release" && d.personId === c.personId)) dock.set(c.fromProjectId, [...leaving, {
|
|
18901
|
+
kind: "release",
|
|
18902
|
+
personId: c.personId
|
|
18903
|
+
}]);
|
|
18904
|
+
dock.set(c.toProjectId, [...dock.get(c.toProjectId) ?? [], {
|
|
18905
|
+
kind: "borrow",
|
|
18906
|
+
personId: c.personId,
|
|
18907
|
+
days: c.days
|
|
18908
|
+
}]);
|
|
18909
|
+
touchedPeople.add(c.personId);
|
|
18910
|
+
touch(c.fromProjectId);
|
|
18911
|
+
touch(c.toProjectId);
|
|
18912
|
+
break;
|
|
18913
|
+
}
|
|
18914
|
+
case "end":
|
|
18915
|
+
if (!open.has(c.projectId) || closed.has(c.projectId)) {
|
|
18916
|
+
stale.push(c);
|
|
18917
|
+
break;
|
|
18918
|
+
}
|
|
18919
|
+
projects.set(c.projectId, {
|
|
18920
|
+
...projectNow(c.projectId),
|
|
18921
|
+
endDate: c.endDate
|
|
18922
|
+
});
|
|
18923
|
+
touch(c.projectId);
|
|
18924
|
+
}
|
|
18925
|
+
});
|
|
18926
|
+
const pace = /* @__PURE__ */ new Map();
|
|
18927
|
+
for (const [id, list] of dock) pace.set(id, dockPace(open.get(id), tasksOf(data.tasks, id), list, now));
|
|
18928
|
+
const tasks = swapped.size === 0 && added.length === 0 ? data.tasks : [...data.tasks.filter((t) => !swapped.has(t.projectId)), ...swapped.values()].flat();
|
|
18929
|
+
if (added.length) tasks.push(...added);
|
|
18930
|
+
return {
|
|
18931
|
+
projects: projects.size === 0 && startedProjects.length === 0 ? data.projects : [...data.projects.map((p) => projects.get(p.id) ?? p), ...startedProjects],
|
|
18932
|
+
tasks,
|
|
18933
|
+
touched,
|
|
18934
|
+
started,
|
|
18935
|
+
pace,
|
|
18936
|
+
people: touchedPeople,
|
|
18937
|
+
stale
|
|
18938
|
+
};
|
|
18939
|
+
}
|
|
18940
|
+
const STOP_WHY = "Stopped from a what-if plan.";
|
|
18941
|
+
/** "Loyalty relaunch: task 3": a placeholder to rename once the project is real. */
|
|
18942
|
+
function startTaskTitle(name, n) {
|
|
18943
|
+
return `${name}: task ${n}`;
|
|
18944
|
+
}
|
|
18945
|
+
function startedProject(id, c, program, today) {
|
|
18946
|
+
return {
|
|
18947
|
+
id,
|
|
18948
|
+
programId: program.id,
|
|
18949
|
+
name: c.name,
|
|
18950
|
+
description: "",
|
|
18951
|
+
swatch: program.swatch,
|
|
18952
|
+
ownerId: program.ownerId,
|
|
18953
|
+
health: "on-track",
|
|
18954
|
+
startDate: today,
|
|
18955
|
+
endDate: isoDay(addDays(/* @__PURE__ */ new Date(`${today}T12:00:00`), c.weeks * 7)),
|
|
18956
|
+
budget: 0,
|
|
18957
|
+
spent: 0
|
|
18958
|
+
};
|
|
18959
|
+
}
|
|
18960
|
+
const likelyOf = (t) => t && t.kind === "forecast" ? t.likely : null;
|
|
18961
|
+
/** A forecast with no day in it: at this pace it doesn't finish inside two years. */
|
|
18962
|
+
const never$1 = (t) => !!t && t.kind === "forecast" && !t.likely;
|
|
18963
|
+
function finishLine(row) {
|
|
18964
|
+
const t = row.trial;
|
|
18965
|
+
if (row.started) return `Starts today, planned to finish ${shortDate(row.trialEnd)}. No pace to forecast from until its crew finishes some tasks.`;
|
|
18966
|
+
if (t.kind === "paused") return "Paused: no finish date while it rests.";
|
|
18967
|
+
if (t.kind === "done") return row.real?.kind === "done" ? "Nothing left open." : "Stopped: its open work is let go.";
|
|
18968
|
+
if (t.kind === "empty") return "No tasks yet.";
|
|
18969
|
+
if (t.kind === "no-pace") return "No pace to forecast from yet.";
|
|
18970
|
+
if (!t.likely) return "Not likely to finish in two years at this pace.";
|
|
18971
|
+
const was = likelyOf(row.real);
|
|
18972
|
+
const moved = row.shift == null ? was ? "" : "" : row.shift === 0 ? ", the same day as today's plan" : `, ${Math.abs(row.shift)} day${Math.abs(row.shift) === 1 ? "" : "s"} ${row.shift < 0 ? "sooner" : "later"}`;
|
|
18973
|
+
const end = t.likely > row.trialEnd ? ` That is after its end date, ${shortDate(row.trialEnd)}.` : row.trialEnd !== row.realEnd ? ` Its end date would be ${shortDate(row.trialEnd)}.` : "";
|
|
18974
|
+
return `Likely done ${shortDate(t.likely)}${moved}.${end}`;
|
|
18975
|
+
}
|
|
18976
|
+
/** Today's portfolio and the changed one side by side. */
|
|
18977
|
+
function trialCompare(data, portfolioId, changes, now) {
|
|
18978
|
+
const plan = trialPlan(data, portfolioId, changes, now);
|
|
18979
|
+
if (!plan) return null;
|
|
18980
|
+
const opts = tideOptions(data);
|
|
18981
|
+
const realProjects = byId(data.projects);
|
|
18982
|
+
const trialProjectsById = byId(plan.projects);
|
|
18983
|
+
const peopleById = byId(data.people);
|
|
18984
|
+
const projects = plan.touched.map((id) => {
|
|
18985
|
+
const project = trialProjectsById.get(id);
|
|
18986
|
+
const real = realProjects.get(id) ?? null;
|
|
18987
|
+
const started = plan.started.has(id);
|
|
18988
|
+
const pace = plan.pace.get(id) ?? 1;
|
|
18989
|
+
const realTide = real ? tideForecast(real, tasksOf(data.tasks, id), now, opts) : null;
|
|
18990
|
+
const trialTide = tideForecast(project, tasksOf(plan.tasks, id), now, {
|
|
18991
|
+
...opts,
|
|
18992
|
+
pace
|
|
18993
|
+
});
|
|
18994
|
+
const a = likelyOf(realTide);
|
|
18995
|
+
const b = likelyOf(trialTide);
|
|
18996
|
+
const base = {
|
|
18997
|
+
project,
|
|
18998
|
+
started,
|
|
18999
|
+
real: realTide,
|
|
19000
|
+
trial: trialTide,
|
|
19001
|
+
realEnd: real?.endDate ?? null,
|
|
19002
|
+
trialEnd: project.endDate,
|
|
19003
|
+
pace,
|
|
19004
|
+
shift: a && b ? differenceInCalendarDays(/* @__PURE__ */ new Date(`${b}T12:00:00`), /* @__PURE__ */ new Date(`${a}T12:00:00`)) : null
|
|
19005
|
+
};
|
|
19006
|
+
const lateBefore = !!a && !!real && a > real.endDate;
|
|
19007
|
+
const nowLate = !!b && b > project.endDate && !lateBefore || never$1(trialTide) && !never$1(realTide);
|
|
19008
|
+
return {
|
|
19009
|
+
...base,
|
|
19010
|
+
line: finishLine(base),
|
|
19011
|
+
nowLate
|
|
19012
|
+
};
|
|
19013
|
+
});
|
|
19014
|
+
const people = [];
|
|
19015
|
+
for (const id of plan.people) {
|
|
19016
|
+
const person = peopleById.get(id);
|
|
19017
|
+
if (!person) continue;
|
|
19018
|
+
const real = personLoadLine(data, person, now, opts.calendar);
|
|
19019
|
+
const trial = personLoadLine({ tasks: plan.tasks }, person, now, opts.calendar);
|
|
19020
|
+
people.push({
|
|
19021
|
+
person,
|
|
19022
|
+
real,
|
|
19023
|
+
trial,
|
|
19024
|
+
nowOver: !!trial && trial.over > 0 && !(real && real.over > 0)
|
|
19025
|
+
});
|
|
19026
|
+
}
|
|
19027
|
+
people.sort((x, y) => x.person.name.localeCompare(y.person.name));
|
|
19028
|
+
const rowOf = new Map(projects.map((r) => [r.project.id, r]));
|
|
19029
|
+
const goals = trialGoals(data, projects);
|
|
19030
|
+
const convoys = trialConvoys(data, rowOf);
|
|
19031
|
+
const notes = [];
|
|
19032
|
+
if (changes.some((c) => c.kind === "pause" && !plan.stale.includes(c))) notes.push("A paused project keeps its tasks with their owners and their due dates, so pausing by itself frees nobody. Stop it, or move people off it, to see their load change.");
|
|
19033
|
+
if (changes.some((c) => c.kind === "move" && !plan.stale.includes(c))) notes.push("Moving someone changes a crew's pace by their share of what it finished lately. With little finished work to read, the dates move less than you'd expect. Applying it takes their open tasks on the first project off them and, across programs, moves that share of their promised time; giving them tasks on the second is yours to do.");
|
|
19034
|
+
if (plan.started.size > 0) notes.push("A project started here gets placeholder tasks, shared out among its crew and due evenly up to its end date. That is what loads people in this comparison.");
|
|
19035
|
+
const comparison = {
|
|
19036
|
+
projects,
|
|
19037
|
+
people,
|
|
19038
|
+
goals,
|
|
19039
|
+
convoys,
|
|
19040
|
+
stale: plan.stale,
|
|
19041
|
+
notes
|
|
19042
|
+
};
|
|
19043
|
+
return {
|
|
19044
|
+
...comparison,
|
|
19045
|
+
summary: trialSummary(comparison, changes.length - plan.stale.length)
|
|
19046
|
+
};
|
|
19047
|
+
}
|
|
19048
|
+
function trialGoals(data, rows) {
|
|
19049
|
+
const out = /* @__PURE__ */ new Map();
|
|
19050
|
+
const linked = /* @__PURE__ */ new Map();
|
|
19051
|
+
for (const portfolio of data.portfolios) for (const goal of portfolio.goals ?? []) for (const id of new Set(goal.keyResults.flatMap((k) => k.kind === "work" ? k.linkIds ?? [] : []))) linked.set(id, [...linked.get(id) ?? [], {
|
|
19052
|
+
portfolio,
|
|
19053
|
+
goal
|
|
19054
|
+
}]);
|
|
19055
|
+
const known = /* @__PURE__ */ new Set();
|
|
19056
|
+
for (const p of data.projects) known.add(p.id).add(p.programId);
|
|
19057
|
+
const taskLinked = [...linked.keys()].some((id) => !known.has(id));
|
|
19058
|
+
for (const row of rows) {
|
|
19059
|
+
if (row.started) continue;
|
|
19060
|
+
const p = row.project;
|
|
19061
|
+
const links = /* @__PURE__ */ new Map();
|
|
19062
|
+
for (const id of [p.id, p.programId]) for (const l of linked.get(id) ?? []) links.set(`${l.portfolio.id}:${l.goal.id}`, l);
|
|
19063
|
+
if (taskLinked) {
|
|
19064
|
+
for (const t of tasksOf(data.tasks, p.id)) if (t.status !== "done") for (const l of linked.get(t.id) ?? []) links.set(`${l.portfolio.id}:${l.goal.id}`, l);
|
|
19065
|
+
}
|
|
19066
|
+
for (const link of links.values()) {
|
|
19067
|
+
const { goal } = link;
|
|
19068
|
+
let line = null;
|
|
19069
|
+
const likely = likelyOf(row.trial);
|
|
19070
|
+
const was = likelyOf(row.real);
|
|
19071
|
+
if (row.trial.kind === "done" && row.real?.kind !== "done") line = `${p.name} stops, so its open work no longer moves this goal.`;
|
|
19072
|
+
else if (row.trial.kind === "paused" && row.real?.kind !== "paused") line = `${p.name} is paused, so this goal waits on it.`;
|
|
19073
|
+
else if (never$1(row.trial) && !never$1(row.real)) line = `${p.name} would not finish in two years at that pace, so this goal is at risk.`;
|
|
19074
|
+
else if (goal.due && likely && likely > goal.due && !(was && was > goal.due)) line = `${p.name} would likely finish ${shortDate(likely)}, after this goal is due (${shortDate(goal.due)}).`;
|
|
19075
|
+
else if (goal.due && likely && was && was > goal.due && likely <= goal.due) line = `${p.name} would likely finish ${shortDate(likely)}, back inside this goal's date (${shortDate(goal.due)}).`;
|
|
19076
|
+
if (!line) continue;
|
|
19077
|
+
const key = `${link.portfolio.id}:${goal.id}`;
|
|
19078
|
+
const have = out.get(key);
|
|
19079
|
+
if (have) have.lines.push(line);
|
|
19080
|
+
else out.set(key, {
|
|
19081
|
+
portfolio: link.portfolio,
|
|
19082
|
+
goal,
|
|
19083
|
+
lines: [line]
|
|
19084
|
+
});
|
|
19085
|
+
}
|
|
19086
|
+
}
|
|
19087
|
+
return [...out.values()];
|
|
19088
|
+
}
|
|
19089
|
+
function trialConvoys(data, rows) {
|
|
19090
|
+
const out = [];
|
|
19091
|
+
const late = (date, by) => date ? differenceInCalendarDays(/* @__PURE__ */ new Date(`${date}T12:00:00`), /* @__PURE__ */ new Date(`${by}T12:00:00`)) : null;
|
|
19092
|
+
for (const asker of data.programs) for (const convoy of asker.convoys ?? []) {
|
|
19093
|
+
if (convoy.status !== "accepted" || !convoy.projectId) continue;
|
|
19094
|
+
const row = rows.get(convoy.projectId);
|
|
19095
|
+
if (!row || row.started) continue;
|
|
19096
|
+
const realLate = late(likelyOf(row.real) ?? (row.real?.kind === "done" ? null : row.realEnd), convoy.by);
|
|
19097
|
+
let trialLate;
|
|
19098
|
+
let line;
|
|
19099
|
+
const name = row.project.name;
|
|
19100
|
+
if (row.trial.kind === "done" && row.real?.kind !== "done") {
|
|
19101
|
+
trialLate = null;
|
|
19102
|
+
line = `${name} stops, so "${convoy.what}" would never reach ${asker.name}.`;
|
|
19103
|
+
} else if (row.trial.kind === "paused" && row.real?.kind !== "paused") {
|
|
19104
|
+
trialLate = null;
|
|
19105
|
+
line = `${name} is paused, so "${convoy.what}" for ${asker.name} has no date while it rests.`;
|
|
19106
|
+
} else if (never$1(row.trial) && !never$1(row.real)) {
|
|
19107
|
+
trialLate = null;
|
|
19108
|
+
line = `${name} would not finish in two years at that pace, so "${convoy.what}" for ${asker.name} has no date.`;
|
|
19109
|
+
} else {
|
|
19110
|
+
const trialDate = likelyOf(row.trial) ?? (row.trial.kind === "done" ? null : row.trialEnd);
|
|
19111
|
+
trialLate = late(trialDate, convoy.by);
|
|
19112
|
+
if (trialLate === realLate || trialDate == null) continue;
|
|
19113
|
+
const days = (n) => `${n} day${n === 1 ? "" : "s"}`;
|
|
19114
|
+
line = trialLate != null && trialLate > 0 ? `"${convoy.what}" would reach ${asker.name} about ${shortDate(trialDate)}, ${days(trialLate)} after the ${shortDate(convoy.by)} it was promised${realLate != null && realLate > 0 ? ` (today it is ${days(realLate)} late)` : " (today it is in time)"}.` : `"${convoy.what}" would reach ${asker.name} about ${shortDate(trialDate)}, in time for ${shortDate(convoy.by)}${realLate != null && realLate > 0 ? ` (today it is ${days(realLate)} late)` : ""}.`;
|
|
19115
|
+
}
|
|
19116
|
+
out.push({
|
|
19117
|
+
what: convoy.what,
|
|
19118
|
+
asker,
|
|
19119
|
+
project: row.project,
|
|
19120
|
+
by: convoy.by,
|
|
19121
|
+
realLate,
|
|
19122
|
+
trialLate,
|
|
19123
|
+
line
|
|
19124
|
+
});
|
|
19125
|
+
}
|
|
19126
|
+
return out;
|
|
19127
|
+
}
|
|
19128
|
+
function trialSummary(c, live) {
|
|
19129
|
+
if (live === 0) return "No changes to try yet.";
|
|
19130
|
+
const parts = [];
|
|
19131
|
+
for (const r of c.projects) parts.push(`${r.project.name}: ${r.line}`);
|
|
19132
|
+
const over = c.people.filter((p) => p.nowOver).map((p) => p.person.name);
|
|
19133
|
+
const lighter = c.people.filter((p) => p.real && p.trial && p.trial.cargo < p.real.cargo).map((p) => p.person.name);
|
|
19134
|
+
if (over.length) parts.push(`Past their load line with these changes: ${list$2(over)}.`);
|
|
19135
|
+
else if (c.people.length) parts.push("Nobody new goes past their load line.");
|
|
19136
|
+
if (lighter.length) parts.push(`Lighter load: ${list$2(lighter)}.`);
|
|
19137
|
+
for (const g of c.goals) parts.push(`Goal "${g.goal.title}": ${g.lines.join(" ")}`);
|
|
19138
|
+
for (const v of c.convoys) parts.push(`Promise: ${v.line}`);
|
|
19139
|
+
return parts.join(" ");
|
|
19140
|
+
}
|
|
19141
|
+
function list$2(names) {
|
|
19142
|
+
if (names.length <= 1) return names.join("");
|
|
19143
|
+
return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
19144
|
+
}
|
|
19145
|
+
/** One change in words: "Pause Checkout redesign", "Move Sam from Mobile app to Loyalty, 3 days a week". */
|
|
19146
|
+
function describeTrialChange(c, data) {
|
|
19147
|
+
const project = (id) => byId(data.projects).get(id)?.name ?? "a project since removed";
|
|
19148
|
+
const person = (id) => byId(data.people).get(id)?.name ?? "someone who left";
|
|
19149
|
+
switch (c.kind) {
|
|
19150
|
+
case "start": {
|
|
19151
|
+
const program = byId(data.programs).get(c.programId)?.name ?? "a program since removed";
|
|
19152
|
+
const crew = c.crewIds.length ? ` with ${list$2(c.crewIds.map(person))}` : " with nobody on it yet";
|
|
19153
|
+
return `Start ${c.name} in ${program}: ${c.tasks} task${c.tasks === 1 ? "" : "s"} over ${c.weeks} week${c.weeks === 1 ? "" : "s"}${crew}`;
|
|
19154
|
+
}
|
|
19155
|
+
case "pause": return `Pause ${project(c.projectId)}`;
|
|
19156
|
+
case "stop": return `Stop ${project(c.projectId)}`;
|
|
19157
|
+
case "move": return `Move ${person(c.personId)} from ${project(c.fromProjectId)} to ${project(c.toProjectId)}, ${c.days === 5 ? "full time" : `${c.days} day${c.days === 1 ? "" : "s"} a week`}`;
|
|
19158
|
+
case "end": return `Move ${project(c.projectId)}'s end date to ${shortDate(c.endDate)}`;
|
|
19159
|
+
}
|
|
19160
|
+
}
|
|
19161
|
+
|
|
18398
19162
|
// src/lib/dock-order.ts
|
|
18399
19163
|
/** The same key for a pair whichever way round it comes. */
|
|
18400
19164
|
const pairKey = (a, b) => a < b ? `${a}|${b}` : `${b}|${a}`;
|
|
@@ -24512,6 +25276,32 @@ function movedText(m, healthLabel) {
|
|
|
24512
25276
|
return `${m.project.name}: ${bits.join(", ")}`;
|
|
24513
25277
|
}
|
|
24514
25278
|
|
|
25279
|
+
// src/lib/agents.ts
|
|
25280
|
+
init_agent_check();
|
|
25281
|
+
const RANK$1 = {
|
|
25282
|
+
urgent: 0,
|
|
25283
|
+
high: 1,
|
|
25284
|
+
medium: 2,
|
|
25285
|
+
low: 3
|
|
25286
|
+
};
|
|
25287
|
+
/** Sent back by the person who checked it, with a note saying what to change. */
|
|
25288
|
+
const sentBack = (t) => t.approval?.status === "changes_requested" && t.status !== "done" && t.status !== "review";
|
|
25289
|
+
/** What an agent should work on: its open tasks not yet waiting on review, what was sent back first, then in progress, then most urgent and soonest. */
|
|
25290
|
+
function agentQueue(data, agentId) {
|
|
25291
|
+
return data.tasks.filter((t) => t.assigneeId === agentId && (t.status === "todo" || t.status === "doing" || t.status === "backlog")).sort((a, b) => Number(sentBack(b)) - Number(sentBack(a)) || Number(b.status === "doing") - Number(a.status === "doing") || Number(a.status === "backlog") - Number(b.status === "backlog") || RANK$1[a.priority] - RANK$1[b.priority] || (a.dueDate ?? "9999").localeCompare(b.dueDate ?? "9999"));
|
|
25292
|
+
}
|
|
25293
|
+
/** The agent an app means: the one named, else the only one on the crew. */
|
|
25294
|
+
function pickAgent(people, key) {
|
|
25295
|
+
const agents = people.filter(isAgent);
|
|
25296
|
+
if (agents.length === 0) return "There are no agents on this harbor's crew yet. Someone adds one on People with Add an agent.";
|
|
25297
|
+
if (!key) {
|
|
25298
|
+
if (agents.length === 1) return agents[0];
|
|
25299
|
+
return `This harbor has ${agents.length} agents (${agents.map((a) => a.name).join(", ")}). Say which with agent.`;
|
|
25300
|
+
}
|
|
25301
|
+
const k = key.trim().toLowerCase();
|
|
25302
|
+
return agents.find((a) => a.id === key.trim() || a.name.trim().toLowerCase() === k) ?? `No agent called "${key}". The crew's agents: ${agents.map((a) => a.name).join(", ")}.`;
|
|
25303
|
+
}
|
|
25304
|
+
|
|
24515
25305
|
// src/lib/fog.ts
|
|
24516
25306
|
function latestBy(cache, items, key, at) {
|
|
24517
25307
|
const hit = cache.get(items);
|
|
@@ -24587,6 +25377,15 @@ function foggyTasks(data, today, projectIds) {
|
|
|
24587
25377
|
}
|
|
24588
25378
|
return out.sort((a, b) => b.days - a.days);
|
|
24589
25379
|
}
|
|
25380
|
+
/**
|
|
25381
|
+
* Why the sweep can't give this task a new date or drop it, as one line, or
|
|
25382
|
+
* null when it can: the other tool owns the due day and whether it's there.
|
|
25383
|
+
* Still needed and Skip are left.
|
|
25384
|
+
*/
|
|
25385
|
+
function fogLock(task) {
|
|
25386
|
+
if (!isExternal(task)) return null;
|
|
25387
|
+
return `Kept in step from ${sourceLine(task.external)}: change its due day or remove it there. Here it can be kept or skipped.`;
|
|
25388
|
+
}
|
|
24590
25389
|
/** Whether opening this task should count as touching it: only when it is in fog. */
|
|
24591
25390
|
function isFoggy(task, data, today) {
|
|
24592
25391
|
return task.status !== "done" && daysUntouched(task, data, today) >= 21;
|
|
@@ -24595,146 +25394,13 @@ var FOG_DAYS, THICK_FOG_DAYS, commentCache, fileCache;
|
|
|
24595
25394
|
var init_fog = __esmMin((() => {
|
|
24596
25395
|
init_date_fns();
|
|
24597
25396
|
init_date_text();
|
|
25397
|
+
init_rollup_lock();
|
|
24598
25398
|
FOG_DAYS = 21;
|
|
24599
25399
|
THICK_FOG_DAYS = 35;
|
|
24600
25400
|
commentCache = /* @__PURE__ */ new WeakMap();
|
|
24601
25401
|
fileCache = /* @__PURE__ */ new WeakMap();
|
|
24602
25402
|
}));
|
|
24603
25403
|
|
|
24604
|
-
// src/lib/assignment.ts
|
|
24605
|
-
/**
|
|
24606
|
-
* Record who set a task's assignee and when. Only a change of assignee
|
|
24607
|
-
* stamps; clearing the assignee clears the stamp.
|
|
24608
|
-
*/
|
|
24609
|
-
function stampAssignment(before, next, by, at) {
|
|
24610
|
-
if (before && before.assigneeId === next.assigneeId) return next;
|
|
24611
|
-
if (!next.assigneeId) return {
|
|
24612
|
-
...next,
|
|
24613
|
-
assignedBy: null,
|
|
24614
|
-
assignedAt: null
|
|
24615
|
-
};
|
|
24616
|
-
return {
|
|
24617
|
-
...next,
|
|
24618
|
-
assignedBy: by,
|
|
24619
|
-
assignedAt: at
|
|
24620
|
-
};
|
|
24621
|
-
}
|
|
24622
|
-
var init_assignment = __esmMin((() => {}));
|
|
24623
|
-
|
|
24624
|
-
// src/lib/scuttle-rows.ts
|
|
24625
|
-
/** Whether it's scuttled: closed through Scuttle or sail and not raised since. */
|
|
24626
|
-
function isScuttled(project) {
|
|
24627
|
-
return Boolean(project.scuttled) && project.healthOverride === "done";
|
|
24628
|
-
}
|
|
24629
|
-
/**
|
|
24630
|
-
* Scuttle a project: Done by hand with the reason as its note, its open
|
|
24631
|
-
* tasks unassigned and undated (kept in `scuttled.freed`), and a decision on
|
|
24632
|
-
* the register. Null for a project that's already scuttled or gone, or a
|
|
24633
|
-
* blank why.
|
|
24634
|
-
*/
|
|
24635
|
-
function scuttleRows(data, projectId, why, byId, at, decisionId, context = "Closed through Scuttle or sail.") {
|
|
24636
|
-
const project = data.projects.find((p) => p.id === projectId);
|
|
24637
|
-
const reason = why.trim().slice(0, 600);
|
|
24638
|
-
if (!project || !reason || isScuttled(project)) return null;
|
|
24639
|
-
const freed = [];
|
|
24640
|
-
const tasks = [];
|
|
24641
|
-
for (const t of tasksOf(data.tasks, projectId)) {
|
|
24642
|
-
if (t.status === "done" || !t.assigneeId && !t.dueDate) continue;
|
|
24643
|
-
freed.push({
|
|
24644
|
-
taskId: t.id,
|
|
24645
|
-
assigneeId: t.assigneeId,
|
|
24646
|
-
dueDate: t.dueDate
|
|
24647
|
-
});
|
|
24648
|
-
tasks.push(stampAssignment(t, {
|
|
24649
|
-
...t,
|
|
24650
|
-
assigneeId: null,
|
|
24651
|
-
dueDate: null,
|
|
24652
|
-
touchedAt: at
|
|
24653
|
-
}, byId, at));
|
|
24654
|
-
}
|
|
24655
|
-
const decision = normalizeRaidItem({
|
|
24656
|
-
id: decisionId,
|
|
24657
|
-
kind: "decision",
|
|
24658
|
-
projectId,
|
|
24659
|
-
title: `Scuttle ${project.name}`,
|
|
24660
|
-
description: context,
|
|
24661
|
-
status: "decided",
|
|
24662
|
-
severity: "low",
|
|
24663
|
-
ownerId: byId,
|
|
24664
|
-
dueDate: null,
|
|
24665
|
-
resolution: "Stop the project. Its open tasks come off people’s lists.",
|
|
24666
|
-
rationale: reason,
|
|
24667
|
-
decidedById: byId,
|
|
24668
|
-
decidedAt: at,
|
|
24669
|
-
createdById: byId,
|
|
24670
|
-
createdAt: at,
|
|
24671
|
-
updatedAt: at,
|
|
24672
|
-
updates: []
|
|
24673
|
-
});
|
|
24674
|
-
return {
|
|
24675
|
-
project: {
|
|
24676
|
-
...project,
|
|
24677
|
-
health: "done",
|
|
24678
|
-
healthOverride: "done",
|
|
24679
|
-
healthNote: `Scuttled: ${reason}`,
|
|
24680
|
-
scuttled: {
|
|
24681
|
-
at,
|
|
24682
|
-
byId,
|
|
24683
|
-
why: reason,
|
|
24684
|
-
decisionId,
|
|
24685
|
-
freed
|
|
24686
|
-
}
|
|
24687
|
-
},
|
|
24688
|
-
tasks,
|
|
24689
|
-
decision
|
|
24690
|
-
};
|
|
24691
|
-
}
|
|
24692
|
-
/**
|
|
24693
|
-
* Raise a scuttled project: the scuttle cleared (the caller clears its Done), and each
|
|
24694
|
-
* freed task given back its person and date, unless someone has since given
|
|
24695
|
-
* it others, it's done, or the person has left the crew. Null when it isn't
|
|
24696
|
-
* scuttled.
|
|
24697
|
-
*/
|
|
24698
|
-
function raiseRows(data, projectId, at, byId) {
|
|
24699
|
-
const project = data.projects.find((p) => p.id === projectId);
|
|
24700
|
-
if (!project?.scuttled) return null;
|
|
24701
|
-
const people = new Set(data.people.map((p) => p.id));
|
|
24702
|
-
const byTask = new Map(project.scuttled.freed.map((f) => [f.taskId, f]));
|
|
24703
|
-
const tasks = [];
|
|
24704
|
-
for (const t of tasksOf(data.tasks, projectId)) {
|
|
24705
|
-
const f = byTask.get(t.id);
|
|
24706
|
-
if (!f || t.status === "done") continue;
|
|
24707
|
-
const assigneeId = !t.assigneeId && f.assigneeId && people.has(f.assigneeId) ? f.assigneeId : t.assigneeId;
|
|
24708
|
-
const dueDate = t.dueDate ?? f.dueDate;
|
|
24709
|
-
if (assigneeId === t.assigneeId && dueDate === t.dueDate) continue;
|
|
24710
|
-
tasks.push(stampAssignment(t, {
|
|
24711
|
-
...t,
|
|
24712
|
-
assigneeId,
|
|
24713
|
-
dueDate,
|
|
24714
|
-
touchedAt: at
|
|
24715
|
-
}, byId, at));
|
|
24716
|
-
}
|
|
24717
|
-
return {
|
|
24718
|
-
project: {
|
|
24719
|
-
...project,
|
|
24720
|
-
scuttled: null,
|
|
24721
|
-
voyageCall: {
|
|
24722
|
-
call: "sail",
|
|
24723
|
-
at,
|
|
24724
|
-
byId
|
|
24725
|
-
}
|
|
24726
|
-
},
|
|
24727
|
-
tasks
|
|
24728
|
-
};
|
|
24729
|
-
}
|
|
24730
|
-
var WHY_MAX;
|
|
24731
|
-
var init_scuttle_rows = __esmMin((() => {
|
|
24732
|
-
init_assignment();
|
|
24733
|
-
init_indexes();
|
|
24734
|
-
init_raid();
|
|
24735
|
-
WHY_MAX = 600;
|
|
24736
|
-
}));
|
|
24737
|
-
|
|
24738
25404
|
// src/lib/scuttle.ts
|
|
24739
25405
|
init_date_fns();
|
|
24740
25406
|
init_fog();
|
|
@@ -25100,10 +25766,27 @@ function gapText(gap) {
|
|
|
25100
25766
|
function awaitingApproval(task) {
|
|
25101
25767
|
return Boolean(task?.approval && task.approval.status === "pending" && task.status !== "done");
|
|
25102
25768
|
}
|
|
25769
|
+
/** The patch that asks `approverId` to approve the task (again, after changes). */
|
|
25770
|
+
function askApprovalPatch(task, approverId, opts) {
|
|
25771
|
+
if (task.status === "done") throw new ApprovalError("It's already done.");
|
|
25772
|
+
if (approverId === opts.by) throw new ApprovalError("Ask someone else. Your own approval is just finishing it.");
|
|
25773
|
+
return { approval: {
|
|
25774
|
+
approverId,
|
|
25775
|
+
askedById: opts.by,
|
|
25776
|
+
askedAt: opts.at,
|
|
25777
|
+
status: "pending",
|
|
25778
|
+
note: null,
|
|
25779
|
+
decidedAt: null
|
|
25780
|
+
} };
|
|
25781
|
+
}
|
|
25103
25782
|
/** Open tasks waiting on this person's approval, oldest ask first. */
|
|
25104
25783
|
function approvalsWaitingOn(tasks, personId) {
|
|
25105
25784
|
return tasks.filter((t) => awaitingApproval(t) && t.approval.approverId === personId).sort((a, b) => a.approval.askedAt.localeCompare(b.approval.askedAt));
|
|
25106
25785
|
}
|
|
25786
|
+
var ApprovalError;
|
|
25787
|
+
var init_task_approval = __esmMin((() => {
|
|
25788
|
+
ApprovalError = class extends Error {};
|
|
25789
|
+
}));
|
|
25107
25790
|
|
|
25108
25791
|
// src/lib/mcp/tools.ts
|
|
25109
25792
|
init_project_messages();
|
|
@@ -25133,7 +25816,7 @@ init_date_text();
|
|
|
25133
25816
|
init_date_fns();
|
|
25134
25817
|
init_shipping_forecast();
|
|
25135
25818
|
init_handover();
|
|
25136
|
-
|
|
25819
|
+
init_rollup_lock();
|
|
25137
25820
|
init_work();
|
|
25138
25821
|
init_task_people();
|
|
25139
25822
|
init_fog();
|
|
@@ -25142,6 +25825,7 @@ init_board();
|
|
|
25142
25825
|
init_swatches();
|
|
25143
25826
|
init_holidays();
|
|
25144
25827
|
init_soundings();
|
|
25828
|
+
init_task_approval();
|
|
25145
25829
|
/** A task's logged time for get_task: the total and the latest entries. */
|
|
25146
25830
|
function timeOut(t, people) {
|
|
25147
25831
|
const entries = entriesNewestFirst(t);
|
|
@@ -25459,6 +26143,45 @@ function milestoneOut(data, m, today, progress = milestoneProgress(data)) {
|
|
|
25459
26143
|
})) } : {}
|
|
25460
26144
|
};
|
|
25461
26145
|
}
|
|
26146
|
+
/** What update_task and the approval tools call the fields the other tool owns. */
|
|
26147
|
+
const READ_ONLY_WORD = {
|
|
26148
|
+
title: "title",
|
|
26149
|
+
status: "status",
|
|
26150
|
+
assigneeId: "assignee",
|
|
26151
|
+
dueDate: "due",
|
|
26152
|
+
startDate: "starts",
|
|
26153
|
+
priority: "priority",
|
|
26154
|
+
parentTaskId: "parent",
|
|
26155
|
+
projectId: "project",
|
|
26156
|
+
approval: "approval",
|
|
26157
|
+
repeat: "repeat"
|
|
26158
|
+
};
|
|
26159
|
+
/**
|
|
26160
|
+
* Where a task kept in step from Jira or Asana comes from, and what can't be
|
|
26161
|
+
* changed here (`readOnly`, in update_task's words): it changes there and
|
|
26162
|
+
* Harbor follows. Nothing for Harbor's own tasks.
|
|
26163
|
+
*/
|
|
26164
|
+
function fromOf(t) {
|
|
26165
|
+
if (!isExternal(t)) return {};
|
|
26166
|
+
const ext = t.external;
|
|
26167
|
+
const url = safeLink(ext.url);
|
|
26168
|
+
return { from: {
|
|
26169
|
+
tool: sourceLabel(ext.from),
|
|
26170
|
+
...ext.key ? { key: ext.key } : {},
|
|
26171
|
+
...url ? { url } : {},
|
|
26172
|
+
readOnly: lockedFields(t).flatMap((k) => READ_ONLY_WORD[k] ?? [])
|
|
26173
|
+
} };
|
|
26174
|
+
}
|
|
26175
|
+
/** The Jira or Asana project a Harbor project's tasks are kept in step from. */
|
|
26176
|
+
function linkedToOf(p) {
|
|
26177
|
+
const ext = p.external;
|
|
26178
|
+
if (!ext) return {};
|
|
26179
|
+
return { linkedTo: {
|
|
26180
|
+
tool: sourceLabel(ext.from),
|
|
26181
|
+
name: ext.name,
|
|
26182
|
+
...ext.key ? { key: ext.key } : {}
|
|
26183
|
+
} };
|
|
26184
|
+
}
|
|
25462
26185
|
function taskLine(t, people, projects, all, data) {
|
|
25463
26186
|
const waitingOn = blockersOf(t, all).filter(isOpen).length;
|
|
25464
26187
|
const project = projects.get(t.projectId);
|
|
@@ -25476,7 +26199,8 @@ function taskLine(t, people, projects, all, data) {
|
|
|
25476
26199
|
assignee: nameOf$2(people, t.assigneeId),
|
|
25477
26200
|
...alsoOnOf(t, people),
|
|
25478
26201
|
project: project?.name ?? null,
|
|
25479
|
-
...waitingOn ? { waitingOn } : {}
|
|
26202
|
+
...waitingOn ? { waitingOn } : {},
|
|
26203
|
+
...fromOf(t)
|
|
25480
26204
|
};
|
|
25481
26205
|
}
|
|
25482
26206
|
/** Everyone also on a task beside its owner, by name; nothing when it's the owner's alone. */
|
|
@@ -25931,7 +26655,7 @@ const HARBOR_TOOLS = [
|
|
|
25931
26655
|
tool({
|
|
25932
26656
|
name: "get_project",
|
|
25933
26657
|
title: "Project details",
|
|
25934
|
-
description: "One project: health and why, dates, budget, task counts, late tasks, what it waits on, milestones and open risks, when it will likely finish at the crew's recent pace (finish: shortHistory when there's under two weeks of it; lastDue names the open task whose due date the dates wait for, when the pace alone would finish sooner), notes the crew left for later (notesForLater: a sealed one shows only who left it and what opens it, unless it's the person's own), its charter (why, in, out, doneWhen, callsBy; null until someone writes one, and outOfScope lists open tasks whose titles name something it leaves out), its landfall (what should be true some days after it's Done, when Harbor asks, and the answer: yes, partly or no with a number; null until someone sets one; state is sailing while not Done, unset, waiting, due or answered), the project's own task fields (fields: name, type and options, when it has any), and its url on the website." + DATA_NOTE,
|
|
26658
|
+
description: "One project: health and why, dates, budget, task counts, late tasks, what it waits on, milestones and open risks, when it will likely finish at the crew's recent pace (finish: shortHistory when there's under two weeks of it; lastDue names the open task whose due date the dates wait for, when the pace alone would finish sooner), notes the crew left for later (notesForLater: a sealed one shows only who left it and what opens it, unless it's the person's own), its charter (why, in, out, doneWhen, callsBy; null until someone writes one, and outOfScope lists open tasks whose titles name something it leaves out), its landfall (what should be true some days after it's Done, when Harbor asks, and the answer: yes, partly or no with a number; null until someone sets one; state is sailing while not Done, unset, waiting, due or answered), the project's own task fields (fields: name, type and options, when it has any), the Jira project its tasks are kept in step from (linkedTo, when it's linked), and its url on the website." + DATA_NOTE,
|
|
25935
26659
|
input: object({
|
|
25936
26660
|
harbor: harborArg,
|
|
25937
26661
|
project: string().min(1).max(200).describe("Project id or name.")
|
|
@@ -25979,6 +26703,7 @@ const HARBOR_TOOLS = [
|
|
|
25979
26703
|
healthSetBy: "a person",
|
|
25980
26704
|
healthNote: p.healthNote ?? null
|
|
25981
26705
|
} : {},
|
|
26706
|
+
...linkedToOf(p),
|
|
25982
26707
|
starts: dayOf(p.startDate),
|
|
25983
26708
|
ends: dayOf(p.endDate),
|
|
25984
26709
|
...p.baselineStart ? { baselineStarts: dayOf(p.baselineStart) } : {},
|
|
@@ -26056,7 +26781,7 @@ const HARBOR_TOOLS = [
|
|
|
26056
26781
|
tool({
|
|
26057
26782
|
name: "get_task",
|
|
26058
26783
|
title: "Task details",
|
|
26059
|
-
description: "One task: its owner (assignee) and anyone also on it (alsoOn), notes, checklist, its files, what it waits on, what waits on it, its latest comments, the earliest due date its owner's queue suggests (pilotDue: fits says whether the due date holds; absent with no owner, an agent owner, or once done), its place in its board column (`position`, from 1 at the top), time logged on it (timeLogged: the total and the latest entries, when there is any), its values for the project's own fields by name (fields, when it has any; set them with set_field), its subtasks or the task it's a subtask of (subtaskOf), the milestone it's tied to (milestone: its due day, whether it's reached, and how many of its tasks are done of all tied to it), and its url on the website." + DATA_NOTE,
|
|
26784
|
+
description: "One task: its owner (assignee) and anyone also on it (alsoOn), notes, checklist, its files, what it waits on, what waits on it, its latest comments, the earliest due date its owner's queue suggests (pilotDue: fits says whether the due date holds; absent with no owner, an agent owner, or once done), its place in its board column (`position`, from 1 at the top), time logged on it (timeLogged: the total and the latest entries, when there is any), its values for the project's own fields by name (fields, when it has any; set them with set_field), its subtasks or the task it's a subtask of (subtaskOf), the milestone it's tied to (milestone: its due day, whether it's reached, and how many of its tasks are done of all tied to it), where it comes from when it's kept in step from Jira (from: the tool, its key and link there, and readOnly, the fields that change there and can't be changed here), and its url on the website." + DATA_NOTE,
|
|
26060
26785
|
input: object({
|
|
26061
26786
|
harbor: harborArg,
|
|
26062
26787
|
task: string().min(1).max(100).describe("Task id or key (\"RR-42\"), from search_tasks or my_work.")
|
|
@@ -26100,6 +26825,7 @@ const HARBOR_TOOLS = [
|
|
|
26100
26825
|
...alsoOnOf(t, people),
|
|
26101
26826
|
project: project?.name ?? null,
|
|
26102
26827
|
projectId: t.projectId,
|
|
26828
|
+
...fromOf(t),
|
|
26103
26829
|
created: dayOf(t.createdAt),
|
|
26104
26830
|
...t.completedAt ? { finished: dayOf(t.completedAt) } : {},
|
|
26105
26831
|
...t.repeat ? { repeats: t.repeat } : {},
|
|
@@ -26178,7 +26904,7 @@ const HARBOR_TOOLS = [
|
|
|
26178
26904
|
tool({
|
|
26179
26905
|
name: "my_work",
|
|
26180
26906
|
title: "My work",
|
|
26181
|
-
description: "What's yours in a harbor: your open tasks (late first), open tasks others own that you're also on (alsoOn), what others are waiting on you for, the risks you own, and tasks waiting on your approval (approvalsToGive; answer with decide_approval)." + DATA_NOTE,
|
|
26907
|
+
description: "What's yours in a harbor: your open tasks (late first), open tasks others own that you're also on (alsoOn), what others are waiting on you for, the risks you own, and tasks waiting on your approval (approvalsToGive; answer with decide_approval, except an agent's hand-in, marked askedByAgent, which the person approves in Harbor itself)." + DATA_NOTE,
|
|
26182
26908
|
input: object({
|
|
26183
26909
|
harbor: harborArg,
|
|
26184
26910
|
limit: limitArg(50, 25)
|
|
@@ -26231,7 +26957,8 @@ const HARBOR_TOOLS = [
|
|
|
26231
26957
|
...taskKey(t, projects.get(t.projectId)) ? { key: taskKey(t, projects.get(t.projectId)) } : {},
|
|
26232
26958
|
title: t.title,
|
|
26233
26959
|
askedBy: nameOf$2(people, t.approval.askedById),
|
|
26234
|
-
asked: dayOf(t.approval.askedAt)
|
|
26960
|
+
asked: dayOf(t.approval.askedAt),
|
|
26961
|
+
...isAgent(people.get(t.approval.askedById)) ? { askedByAgent: true } : {}
|
|
26235
26962
|
}))
|
|
26236
26963
|
};
|
|
26237
26964
|
}
|
|
@@ -27308,7 +28035,7 @@ const HARBOR_TOOLS = [
|
|
|
27308
28035
|
tool({
|
|
27309
28036
|
name: "agent_work",
|
|
27310
28037
|
title: "Work for an agent on the crew",
|
|
27311
|
-
description: "If you are working as one of this harbor's agents (an AI crew member on People, like \"Claude\"), the tasks people have given it: in progress first, then most urgent and soonest, each with its notes, checklist and latest comments. Do the work the person running you agrees to, then call agent_update to say what you did; that moves the task to In review for a person to check. Never mark an agent's task Done. Tasks waiting for review are listed under forReview so you don't redo them." + DATA_NOTE,
|
|
28038
|
+
description: "If you are working as one of this harbor's agents (an AI crew member on People, like \"Claude\"), the tasks people have given it: in progress first, then most urgent and soonest, each with its notes, checklist and latest comments. Do the work the person running you agrees to, then call agent_update to say what you did; that moves the task to In review for a person to check. Never mark an agent's task Done. A task a person sent back comes first, with sentBack saying who, when and what to change: fix that before anything else. Tasks waiting for review are listed under forReview, with who was asked to check each, so you don't redo them. Pass agentId (or the agent's name) as agent when the crew has more than one; if you don't know which agent you are, ask the person." + DATA_NOTE,
|
|
27312
28039
|
input: object({
|
|
27313
28040
|
harbor: harborArg,
|
|
27314
28041
|
agent: string().max(200).optional().describe("The agent's name or id. Needed when the crew has more than one."),
|
|
@@ -27341,11 +28068,17 @@ const HARBOR_TOOLS = [
|
|
|
27341
28068
|
};
|
|
27342
28069
|
return {
|
|
27343
28070
|
agent: agent.name,
|
|
28071
|
+
agentId: agent.id,
|
|
27344
28072
|
addedBy: nameOf$2(people, agent.addedById),
|
|
27345
28073
|
total: queue.length,
|
|
27346
28074
|
tasks: queue.slice(0, input.limit).map((t) => ({
|
|
27347
28075
|
...line(t),
|
|
27348
28076
|
status: t.status,
|
|
28077
|
+
...sentBack(t) ? { sentBack: {
|
|
28078
|
+
by: nameOf$2(people, t.approval.approverId),
|
|
28079
|
+
at: t.approval.decidedAt,
|
|
28080
|
+
note: t.approval.note
|
|
28081
|
+
} } : {},
|
|
27349
28082
|
priority: t.priority,
|
|
27350
28083
|
due: dayOf(t.dueDate),
|
|
27351
28084
|
project: projects.get(t.projectId)?.name ?? null,
|
|
@@ -27361,7 +28094,10 @@ const HARBOR_TOOLS = [
|
|
|
27361
28094
|
})),
|
|
27362
28095
|
...webLink(ctx, { task: t.id })
|
|
27363
28096
|
})),
|
|
27364
|
-
forReview: data.tasks.filter((t) => t.assigneeId === agent.id && t.status === "review").map(
|
|
28097
|
+
forReview: data.tasks.filter((t) => t.assigneeId === agent.id && t.status === "review").map((t) => ({
|
|
28098
|
+
...line(t),
|
|
28099
|
+
...t.approval?.status === "pending" ? { waitingOn: nameOf$2(people, t.approval.approverId) } : {}
|
|
28100
|
+
})),
|
|
27365
28101
|
otherAgents: data.people.filter((p) => isAgent(p) && p.id !== agent.id).map((p) => p.name)
|
|
27366
28102
|
};
|
|
27367
28103
|
}
|
|
@@ -27632,6 +28368,133 @@ const HARBOR_TOOLS = [
|
|
|
27632
28368
|
}))
|
|
27633
28369
|
};
|
|
27634
28370
|
}
|
|
28371
|
+
}),
|
|
28372
|
+
tool({
|
|
28373
|
+
name: "what_if",
|
|
28374
|
+
title: "Try a what-if plan for a portfolio",
|
|
28375
|
+
description: "Sea trial: big moves tried on a copy of a portfolio, read against today's plan. Nothing is changed. Give `moves` (start a project with about how many tasks, over how many weeks, and who works on it; pause or stop a project; move a person from one project to another for some days a week; move a project's end date), or leave them out to read the what-if plan someone saved on the portfolio. Answers each touched project's likely finish today and with the moves, each touched person's load line before and after (open tasks due in the next 3 weeks against what they can close), the goals put at risk, the promises to other programs (convoys) that slip, any move that no longer fits, and a summary in sentences. Pausing keeps tasks with their owners; stopping lets them go." + DATA_NOTE,
|
|
28376
|
+
input: object({
|
|
28377
|
+
harbor: harborArg,
|
|
28378
|
+
portfolio: string().min(1).max(200).describe("Portfolio id or name."),
|
|
28379
|
+
moves: array(object({
|
|
28380
|
+
move: _enum([
|
|
28381
|
+
"start",
|
|
28382
|
+
"pause",
|
|
28383
|
+
"stop",
|
|
28384
|
+
"move",
|
|
28385
|
+
"end"
|
|
28386
|
+
]),
|
|
28387
|
+
project: string().max(200).optional().describe("Project id or name: the one to pause, stop or re-date, or the one a person leaves."),
|
|
28388
|
+
to: string().max(200).optional().describe("For move: the project the person joins."),
|
|
28389
|
+
person: string().max(200).optional().describe("For move: person id or name."),
|
|
28390
|
+
days: number().int().min(1).max(5).optional().describe("For move: days a week on the new project (default 3)."),
|
|
28391
|
+
endDate: string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("For end: the new end date."),
|
|
28392
|
+
name: string().max(120).optional().describe("For start: the new project's name."),
|
|
28393
|
+
program: string().max(200).optional().describe("For start: program id or name in this portfolio (optional when it has one)."),
|
|
28394
|
+
tasks: number().int().min(1).max(200).optional().describe("For start: about how many tasks (default 10)."),
|
|
28395
|
+
weeks: number().int().min(1).max(104).optional().describe("For start: over how many weeks (default 8)."),
|
|
28396
|
+
crew: array(string().max(200)).max(20).optional().describe("For start: who works on it, ids or names.")
|
|
28397
|
+
})).max(30).optional()
|
|
28398
|
+
}),
|
|
28399
|
+
run: (ctx, input) => {
|
|
28400
|
+
const { data } = ctx;
|
|
28401
|
+
const portfolio = findOne(data.portfolios, input.portfolio, "portfolio");
|
|
28402
|
+
const open = trialProjects(data, portfolio.id);
|
|
28403
|
+
const programs = data.programs.filter((p) => p.portfolioId === portfolio.id);
|
|
28404
|
+
const need = (v, what) => {
|
|
28405
|
+
if (v === void 0 || v === "") throw new ToolError(`That move needs ${what}.`);
|
|
28406
|
+
return v;
|
|
28407
|
+
};
|
|
28408
|
+
const project = (ref) => findOne(open, need(ref, "a project"), "open project in this portfolio").id;
|
|
28409
|
+
const person = (ref) => findOne(data.people, ref, "person").id;
|
|
28410
|
+
const changes = input.moves ? input.moves.map((m) => {
|
|
28411
|
+
switch (m.move) {
|
|
28412
|
+
case "start": return {
|
|
28413
|
+
kind: "start",
|
|
28414
|
+
name: need(m.name?.trim(), "a name"),
|
|
28415
|
+
programId: m.program ? findOne(programs, m.program, "program in this portfolio").id : programs.length === 1 ? programs[0].id : need(void 0, "a program"),
|
|
28416
|
+
tasks: m.tasks ?? 10,
|
|
28417
|
+
weeks: m.weeks ?? 8,
|
|
28418
|
+
crewIds: [...new Set((m.crew ?? []).map(person))]
|
|
28419
|
+
};
|
|
28420
|
+
case "pause":
|
|
28421
|
+
case "stop": return {
|
|
28422
|
+
kind: m.move,
|
|
28423
|
+
projectId: project(m.project)
|
|
28424
|
+
};
|
|
28425
|
+
case "move": {
|
|
28426
|
+
const from = project(m.project);
|
|
28427
|
+
const to = project(need(m.to, "a project to move to"));
|
|
28428
|
+
if (from === to) throw new ToolError("A move needs two different projects.");
|
|
28429
|
+
return {
|
|
28430
|
+
kind: "move",
|
|
28431
|
+
personId: person(need(m.person, "a person")),
|
|
28432
|
+
fromProjectId: from,
|
|
28433
|
+
toProjectId: to,
|
|
28434
|
+
days: m.days ?? 3
|
|
28435
|
+
};
|
|
28436
|
+
}
|
|
28437
|
+
case "end": return {
|
|
28438
|
+
kind: "end",
|
|
28439
|
+
projectId: project(m.project),
|
|
28440
|
+
endDate: need(m.endDate, "an end date")
|
|
28441
|
+
};
|
|
28442
|
+
}
|
|
28443
|
+
}) : readTrial(portfolio.seaTrial?.changes);
|
|
28444
|
+
const saved = !input.moves && portfolio.seaTrial ? portfolio.seaTrial : null;
|
|
28445
|
+
const cmp = trialCompare(data, portfolio.id, changes, ctx.now);
|
|
28446
|
+
const line = (l) => l ? {
|
|
28447
|
+
cargo: l.cargo,
|
|
28448
|
+
capacity: l.capacity,
|
|
28449
|
+
over: l.over,
|
|
28450
|
+
text: loadLineText(l)
|
|
28451
|
+
} : null;
|
|
28452
|
+
const likely = (t) => t && t.kind === "forecast" ? t.likely ?? null : null;
|
|
28453
|
+
return {
|
|
28454
|
+
portfolio: portfolio.name,
|
|
28455
|
+
...saved ? { saved: {
|
|
28456
|
+
by: data.people.find((p) => p.id === saved.savedBy)?.name ?? null,
|
|
28457
|
+
at: saved.savedAt
|
|
28458
|
+
} } : {},
|
|
28459
|
+
moves: changes.filter((c) => !cmp.stale.includes(c)).map((c) => describeTrialChange(c, data)),
|
|
28460
|
+
noLongerFits: cmp.stale.map((c) => describeTrialChange(c, data)),
|
|
28461
|
+
projects: cmp.projects.map((r) => ({
|
|
28462
|
+
project: r.project.name,
|
|
28463
|
+
...r.started ? { started: true } : {},
|
|
28464
|
+
today: r.started ? null : {
|
|
28465
|
+
state: r.real?.kind ?? null,
|
|
28466
|
+
likely: likely(r.real),
|
|
28467
|
+
endDate: r.realEnd
|
|
28468
|
+
},
|
|
28469
|
+
withMoves: {
|
|
28470
|
+
state: r.trial.kind,
|
|
28471
|
+
likely: likely(r.trial),
|
|
28472
|
+
endDate: r.trialEnd
|
|
28473
|
+
},
|
|
28474
|
+
daysMoved: r.shift,
|
|
28475
|
+
text: r.line
|
|
28476
|
+
})),
|
|
28477
|
+
people: cmp.people.map((r) => ({
|
|
28478
|
+
who: r.person.name,
|
|
28479
|
+
today: line(r.real),
|
|
28480
|
+
withMoves: line(r.trial),
|
|
28481
|
+
...r.nowOver ? { newlyOver: true } : {}
|
|
28482
|
+
})),
|
|
28483
|
+
goals: cmp.goals.map((g) => ({
|
|
28484
|
+
goal: g.goal.title,
|
|
28485
|
+
text: g.lines.join(" ")
|
|
28486
|
+
})),
|
|
28487
|
+
promises: cmp.convoys.map((v) => ({
|
|
28488
|
+
what: v.what,
|
|
28489
|
+
to: v.asker.name,
|
|
28490
|
+
from: v.project.name,
|
|
28491
|
+
by: v.by,
|
|
28492
|
+
text: v.line
|
|
28493
|
+
})),
|
|
28494
|
+
notes: cmp.notes,
|
|
28495
|
+
summary: cmp.summary
|
|
28496
|
+
};
|
|
28497
|
+
}
|
|
27635
28498
|
})
|
|
27636
28499
|
];
|
|
27637
28500
|
const TOOL_BY_NAME = new Map(HARBOR_TOOLS.map((t) => [t.name, t]));
|
|
@@ -28008,13 +28871,17 @@ function stamp() {
|
|
|
28008
28871
|
function initialsOf(name) {
|
|
28009
28872
|
return name.split(/\s+/).filter(Boolean).map((p) => p[0]).join("").slice(0, 2).toUpperCase();
|
|
28010
28873
|
}
|
|
28011
|
-
function withStatus(task, status) {
|
|
28874
|
+
function withStatus(task, status, mover) {
|
|
28012
28875
|
if (task.status === status) return task;
|
|
28013
28876
|
const next = {
|
|
28014
28877
|
...task,
|
|
28015
28878
|
status,
|
|
28016
28879
|
touchedAt: stamp()
|
|
28017
28880
|
};
|
|
28881
|
+
if (mover) {
|
|
28882
|
+
const ask = agentAskAfterMove(mover.people, task, status, mover.by, next.touchedAt);
|
|
28883
|
+
if (ask !== void 0) next.approval = ask;
|
|
28884
|
+
}
|
|
28018
28885
|
if (status === "done") next.completedAt = stamp();
|
|
28019
28886
|
else if (task.status === "done") {
|
|
28020
28887
|
next.completedAt = null;
|
|
@@ -28022,7 +28889,9 @@ function withStatus(task, status) {
|
|
|
28022
28889
|
}
|
|
28023
28890
|
return next;
|
|
28024
28891
|
}
|
|
28025
|
-
var init_shared = __esmMin((() => {
|
|
28892
|
+
var init_shared = __esmMin((() => {
|
|
28893
|
+
init_agent_check();
|
|
28894
|
+
}));
|
|
28026
28895
|
|
|
28027
28896
|
// src/lib/undo-state.ts
|
|
28028
28897
|
function clearUndo() {
|
|
@@ -28066,7 +28935,7 @@ function sessionSlice({ set, get, write }) {
|
|
|
28066
28935
|
if (get().currentUserId !== hit.id) set({ currentUserId: hit.id });
|
|
28067
28936
|
return hit.id;
|
|
28068
28937
|
}
|
|
28069
|
-
const named = personId ? get().people.find((p) => p.id === personId && !p.accountId) : null;
|
|
28938
|
+
const named = personId ? get().people.find((p) => p.id === personId && !p.accountId && p.kind !== "agent") : null;
|
|
28070
28939
|
if (named) {
|
|
28071
28940
|
set({
|
|
28072
28941
|
people: get().people.map((p) => p.id === named.id ? {
|
|
@@ -28820,64 +29689,69 @@ function matches(rule, prev, next, created) {
|
|
|
28820
29689
|
function runActions(actions, start, ctx) {
|
|
28821
29690
|
let task = start;
|
|
28822
29691
|
const comments = [];
|
|
28823
|
-
|
|
28824
|
-
|
|
28825
|
-
|
|
28826
|
-
|
|
28827
|
-
|
|
28828
|
-
|
|
28829
|
-
|
|
28830
|
-
|
|
28831
|
-
|
|
28832
|
-
|
|
28833
|
-
|
|
29692
|
+
const locked = lockedFields(start);
|
|
29693
|
+
for (const action of actions) {
|
|
29694
|
+
const field = ACTION_FIELD[action.type];
|
|
29695
|
+
if (field && locked.includes(field)) continue;
|
|
29696
|
+
switch (action.type) {
|
|
29697
|
+
case "set_status": {
|
|
29698
|
+
if (!action.status) break;
|
|
29699
|
+
if (action.status === "done" && task.status !== "done" && ctx.waiting?.(task)) {
|
|
29700
|
+
comments.push({
|
|
29701
|
+
taskId: task.id,
|
|
29702
|
+
authorId: ctx.authorId,
|
|
29703
|
+
body: "Left open: this still waits on unfinished work, so the rule didn’t finish it.",
|
|
29704
|
+
createdAt: ctx.now,
|
|
29705
|
+
mentionedIds: []
|
|
29706
|
+
});
|
|
29707
|
+
break;
|
|
29708
|
+
}
|
|
29709
|
+
const wasDone = task.status === "done";
|
|
29710
|
+
const completedAt = action.status === "done" ? task.completedAt ?? ctx.now : wasDone ? null : task.completedAt;
|
|
29711
|
+
task = {
|
|
29712
|
+
...task,
|
|
29713
|
+
status: action.status,
|
|
29714
|
+
completedAt
|
|
29715
|
+
};
|
|
28834
29716
|
break;
|
|
28835
29717
|
}
|
|
28836
|
-
|
|
28837
|
-
|
|
28838
|
-
|
|
28839
|
-
|
|
28840
|
-
|
|
28841
|
-
|
|
28842
|
-
|
|
28843
|
-
|
|
28844
|
-
|
|
28845
|
-
|
|
28846
|
-
|
|
28847
|
-
|
|
28848
|
-
|
|
28849
|
-
|
|
28850
|
-
|
|
28851
|
-
|
|
28852
|
-
|
|
28853
|
-
|
|
28854
|
-
|
|
28855
|
-
}
|
|
28856
|
-
|
|
28857
|
-
|
|
28858
|
-
|
|
28859
|
-
|
|
28860
|
-
|
|
28861
|
-
|
|
28862
|
-
|
|
28863
|
-
|
|
28864
|
-
|
|
28865
|
-
|
|
28866
|
-
|
|
28867
|
-
|
|
28868
|
-
|
|
28869
|
-
|
|
28870
|
-
|
|
28871
|
-
};
|
|
28872
|
-
break;
|
|
29718
|
+
case "set_priority":
|
|
29719
|
+
if (action.priority) task = {
|
|
29720
|
+
...task,
|
|
29721
|
+
priority: action.priority
|
|
29722
|
+
};
|
|
29723
|
+
break;
|
|
29724
|
+
case "set_assignee":
|
|
29725
|
+
task = {
|
|
29726
|
+
...task,
|
|
29727
|
+
assigneeId: action.assigneeId ?? null
|
|
29728
|
+
};
|
|
29729
|
+
break;
|
|
29730
|
+
case "set_due": {
|
|
29731
|
+
const n = Math.min(365, Math.max(0, Math.round(action.inDays ?? 0)));
|
|
29732
|
+
task = {
|
|
29733
|
+
...task,
|
|
29734
|
+
dueDate: dayAfter(ctx.today, n)
|
|
29735
|
+
};
|
|
29736
|
+
break;
|
|
29737
|
+
}
|
|
29738
|
+
case "add_follower": {
|
|
29739
|
+
const id = action.personId;
|
|
29740
|
+
if (!id || id === task.assigneeId || task.followerIds?.includes(id)) break;
|
|
29741
|
+
task = {
|
|
29742
|
+
...task,
|
|
29743
|
+
followerIds: [...task.followerIds ?? [], id]
|
|
29744
|
+
};
|
|
29745
|
+
break;
|
|
29746
|
+
}
|
|
29747
|
+
case "add_comment": if (action.commentBody?.trim()) comments.push({
|
|
29748
|
+
taskId: task.id,
|
|
29749
|
+
authorId: ctx.authorId,
|
|
29750
|
+
body: action.commentBody.trim(),
|
|
29751
|
+
createdAt: ctx.now,
|
|
29752
|
+
mentionedIds: []
|
|
29753
|
+
});
|
|
28873
29754
|
}
|
|
28874
|
-
case "add_comment": if (action.commentBody?.trim()) comments.push({
|
|
28875
|
-
taskId: task.id,
|
|
28876
|
-
authorId: ctx.authorId,
|
|
28877
|
-
body: action.commentBody.trim(),
|
|
28878
|
-
createdAt: ctx.now,
|
|
28879
|
-
mentionedIds: []
|
|
28880
|
-
});
|
|
28881
29755
|
}
|
|
28882
29756
|
return {
|
|
28883
29757
|
task,
|
|
@@ -28914,12 +29788,19 @@ function applyAutomations(project, prev, next, opts) {
|
|
|
28914
29788
|
comments
|
|
28915
29789
|
};
|
|
28916
29790
|
}
|
|
28917
|
-
var dayAfter;
|
|
29791
|
+
var dayAfter, ACTION_FIELD;
|
|
28918
29792
|
var init_automations = __esmMin((() => {
|
|
28919
29793
|
init_date_fns();
|
|
28920
29794
|
init_date_text();
|
|
28921
29795
|
init_format();
|
|
29796
|
+
init_rollup_lock();
|
|
28922
29797
|
dayAfter = (day, n) => format(addDays(parseIso(day), n), "yyyy-MM-dd");
|
|
29798
|
+
ACTION_FIELD = {
|
|
29799
|
+
set_status: "status",
|
|
29800
|
+
set_priority: "priority",
|
|
29801
|
+
set_assignee: "assigneeId",
|
|
29802
|
+
set_due: "dueDate"
|
|
29803
|
+
};
|
|
28923
29804
|
}));
|
|
28924
29805
|
|
|
28925
29806
|
// src/lib/focus.ts
|
|
@@ -28983,6 +29864,7 @@ function nextOccurrence(task, id, today, createdAt, siblings = []) {
|
|
|
28983
29864
|
status: "todo",
|
|
28984
29865
|
dueDate,
|
|
28985
29866
|
milestoneId: null,
|
|
29867
|
+
approval: null,
|
|
28986
29868
|
...task.startDate ? { startDate: lead != null && lead >= 0 ? format(addDays(/* @__PURE__ */ new Date(`${dueDate}T12:00:00`), -lead), "yyyy-MM-dd") : null } : {},
|
|
28987
29869
|
createdAt,
|
|
28988
29870
|
completedAt: null,
|
|
@@ -29041,6 +29923,13 @@ function applyBulk(task, change) {
|
|
|
29041
29923
|
priority: change.priority
|
|
29042
29924
|
};
|
|
29043
29925
|
}
|
|
29926
|
+
/** The task field a bulk change sets. */
|
|
29927
|
+
function bulkField(change) {
|
|
29928
|
+
if ("status" in change) return "status";
|
|
29929
|
+
if ("assigneeId" in change) return "assigneeId";
|
|
29930
|
+
if ("priority" in change) return "priority";
|
|
29931
|
+
return "dueDate";
|
|
29932
|
+
}
|
|
29044
29933
|
/** What the change did, for the Activity line and the tray's notice: "moved 4 tasks to In play". */
|
|
29045
29934
|
function bulkText(change, n, names = {}) {
|
|
29046
29935
|
const tasks = plural$2(n);
|
|
@@ -29054,12 +29943,14 @@ function bulkText(change, n, names = {}) {
|
|
|
29054
29943
|
}
|
|
29055
29944
|
return `set ${tasks} to ${PRIORITY_LABEL[change.priority].toLowerCase()} priority`;
|
|
29056
29945
|
}
|
|
29057
|
-
var plural$2;
|
|
29946
|
+
var bulkLocked, plural$2;
|
|
29058
29947
|
var init_bulk = __esmMin((() => {
|
|
29059
29948
|
init_date_fns();
|
|
29060
29949
|
init_date_text();
|
|
29061
29950
|
init_format();
|
|
29062
29951
|
init_swatches();
|
|
29952
|
+
init_rollup_lock();
|
|
29953
|
+
bulkLocked = (task, change) => lockedFields(task).includes(bulkField(change));
|
|
29063
29954
|
plural$2 = (n) => `${n} ${n === 1 ? "task" : "tasks"}`;
|
|
29064
29955
|
}));
|
|
29065
29956
|
|
|
@@ -29138,6 +30029,13 @@ function tasksSlice({ set, get, write }) {
|
|
|
29138
30029
|
},
|
|
29139
30030
|
updateTask: (id, patch, opts) => {
|
|
29140
30031
|
const task = get().tasks.find((row) => row.id === id);
|
|
30032
|
+
if (task) {
|
|
30033
|
+
const mine = withoutLocked(task, patch);
|
|
30034
|
+
if (mine !== patch) {
|
|
30035
|
+
if (Object.keys(mine).length === 0) return;
|
|
30036
|
+
patch = mine;
|
|
30037
|
+
}
|
|
30038
|
+
}
|
|
29141
30039
|
if (task && patch.parentTaskId && subtaskProblem(id, patch.parentTaskId, get().tasks)) {
|
|
29142
30040
|
patch = { ...patch };
|
|
29143
30041
|
delete patch.parentTaskId;
|
|
@@ -29158,7 +30056,9 @@ function tasksSlice({ set, get, write }) {
|
|
|
29158
30056
|
}
|
|
29159
30057
|
}
|
|
29160
30058
|
const moving = task && patch.projectId && patch.projectId !== task.projectId;
|
|
29161
|
-
const
|
|
30059
|
+
const under = moving ? subtasksOf(task, get().tasks) : [];
|
|
30060
|
+
const carried = moving ? new Set(under.filter((t) => !lockedFields(t).includes("projectId")).map((t) => t.id)) : null;
|
|
30061
|
+
const left = new Set(under.filter((t) => !carried?.has(t.id)).map((t) => t.id));
|
|
29162
30062
|
if (moving && task.parentTaskId && !("parentTaskId" in patch)) patch = {
|
|
29163
30063
|
...patch,
|
|
29164
30064
|
parentTaskId: null
|
|
@@ -29171,6 +30071,10 @@ function tasksSlice({ set, get, write }) {
|
|
|
29171
30071
|
projectId: patch.projectId,
|
|
29172
30072
|
touchedAt: stamp()
|
|
29173
30073
|
};
|
|
30074
|
+
if (left.has(row.id)) return {
|
|
30075
|
+
...row,
|
|
30076
|
+
parentTaskId: null
|
|
30077
|
+
};
|
|
29174
30078
|
if (row.id !== id) return row;
|
|
29175
30079
|
const next = {
|
|
29176
30080
|
...row,
|
|
@@ -29179,7 +30083,12 @@ function tasksSlice({ set, get, write }) {
|
|
|
29179
30083
|
};
|
|
29180
30084
|
if (next.startDate) next.startDate = fitStart(next.startDate, next.dueDate);
|
|
29181
30085
|
if (next.assigneeId && next.followerIds?.includes(next.assigneeId)) next.followerIds = alsoOnIds(next);
|
|
30086
|
+
if (!("approval" in patch) && patch.assigneeId !== void 0 && patch.assigneeId !== row.assigneeId && row.approval?.status === "changes_requested" && isAgent(get().people.find((p) => p.id === row.approval.askedById)) && !isAgent(get().people.find((p) => p.id === patch.assigneeId))) next.approval = null;
|
|
29182
30087
|
if (patch.status && patch.status !== row.status) {
|
|
30088
|
+
if (!("approval" in patch)) {
|
|
30089
|
+
const ask = agentAskAfterMove(get().people, row, patch.status, get().currentUserId, next.touchedAt);
|
|
30090
|
+
if (ask !== void 0) next.approval = ask;
|
|
30091
|
+
}
|
|
29183
30092
|
if (patch.status === "done" && !patch.completedAt) next.completedAt = stamp();
|
|
29184
30093
|
else if (row.status === "done" && patch.status !== "done") {
|
|
29185
30094
|
next.completedAt = null;
|
|
@@ -29211,6 +30120,7 @@ function tasksSlice({ set, get, write }) {
|
|
|
29211
30120
|
moveTask: (id, status, opts) => {
|
|
29212
30121
|
const task = get().tasks.find((row) => row.id === id);
|
|
29213
30122
|
if (!task || task.status === status) return;
|
|
30123
|
+
if (isExternal(task)) return;
|
|
29214
30124
|
if (status === "done" && !opts?.allowBlocked && isBlocked$1(task, get().tasks)) {
|
|
29215
30125
|
set({ blockPending: {
|
|
29216
30126
|
blockerTitle: openBlockerNames(task, get().tasks) || "another task",
|
|
@@ -29224,7 +30134,10 @@ function tasksSlice({ set, get, write }) {
|
|
|
29224
30134
|
if (!opts?.allowOverCap && !isSubtask(task, get().tasks)) {
|
|
29225
30135
|
if (columnWip(get(), task.projectId, status, 1)) return;
|
|
29226
30136
|
}
|
|
29227
|
-
const nextRow = withStatus(task, status
|
|
30137
|
+
const nextRow = withStatus(task, status, {
|
|
30138
|
+
people: get().people,
|
|
30139
|
+
by: get().currentUserId
|
|
30140
|
+
});
|
|
29228
30141
|
if (status === "done" && isBlocked$1(task, get().tasks)) Object.assign(nextRow, blockersPatch([]));
|
|
29229
30142
|
const project = get().projects.find((p) => p.id === task.projectId);
|
|
29230
30143
|
const { task: finalRow, comments: autoComments } = applyAutomations(project, task, nextRow, {
|
|
@@ -29254,6 +30167,7 @@ function tasksSlice({ set, get, write }) {
|
|
|
29254
30167
|
},
|
|
29255
30168
|
deleteTask: (id) => {
|
|
29256
30169
|
const task = get().tasks.find((t) => t.id === id);
|
|
30170
|
+
if (task && isExternal(task)) return;
|
|
29257
30171
|
write({
|
|
29258
30172
|
tasks: get().tasks.filter((t) => t.id !== id),
|
|
29259
30173
|
comments: get().comments.filter((c) => c.taskId !== id),
|
|
@@ -29293,8 +30207,25 @@ function tasksSlice({ set, get, write }) {
|
|
|
29293
30207
|
const task = get().tasks.find((t) => t.id === taskId);
|
|
29294
30208
|
const text = body.trim();
|
|
29295
30209
|
if (!task || !text) return;
|
|
29296
|
-
|
|
30210
|
+
const external = isExternal(task);
|
|
30211
|
+
if (status !== "same" && task.status !== status && !external) get().moveTask(taskId, status, { allowOverCap: opts?.allowOverCap });
|
|
29297
30212
|
const at = stamp();
|
|
30213
|
+
const moved = get().tasks.find((t) => t.id === taskId);
|
|
30214
|
+
const agent = get().people.find((p) => p.id === agentId);
|
|
30215
|
+
const waiting = awaitingApproval(moved);
|
|
30216
|
+
const gone = [...useFormerAccounts.getState().ids, ...opts?.gone ?? []];
|
|
30217
|
+
const asked = get().people.find((p) => p.id === moved?.approval?.approverId);
|
|
30218
|
+
const lost = waiting && isAgent(get().people.find((p) => p.id === moved.approval.askedById)) && (!asked || isFormerCrew(asked, gone));
|
|
30219
|
+
if (status === "review" && moved?.status === "review" && agent && !external && (!waiting || lost)) {
|
|
30220
|
+
const checker = agentChecker(get().people, moved, agent, gone);
|
|
30221
|
+
if (checker) write({ tasks: get().tasks.map((t) => t.id === taskId ? {
|
|
30222
|
+
...t,
|
|
30223
|
+
...askApprovalPatch(t, checker.id, {
|
|
30224
|
+
by: agentId,
|
|
30225
|
+
at
|
|
30226
|
+
})
|
|
30227
|
+
} : t) });
|
|
30228
|
+
}
|
|
29298
30229
|
write({
|
|
29299
30230
|
comments: [...get().comments, {
|
|
29300
30231
|
id: uid("c"),
|
|
@@ -29302,7 +30233,9 @@ function tasksSlice({ set, get, write }) {
|
|
|
29302
30233
|
authorId: agentId,
|
|
29303
30234
|
body: text,
|
|
29304
30235
|
createdAt: at,
|
|
29305
|
-
mentionedIds: parseMentions(text, get().people).filter((id) => id !== agentId)
|
|
30236
|
+
mentionedIds: parseMentions(text, get().people).filter((id) => id !== agentId),
|
|
30237
|
+
...opts?.ranById ? { ranById: opts.ranById } : {},
|
|
30238
|
+
...opts?.via ? { via: opts.via } : {}
|
|
29306
30239
|
}],
|
|
29307
30240
|
people: get().people.map((p) => p.id === agentId ? {
|
|
29308
30241
|
...p,
|
|
@@ -29451,10 +30384,13 @@ function tasksSlice({ set, get, write }) {
|
|
|
29451
30384
|
set({ readPingIds: [...have] });
|
|
29452
30385
|
},
|
|
29453
30386
|
tickVoyage: (ids) => {
|
|
29454
|
-
const
|
|
29455
|
-
const ticked = get().tasks.filter((t) => tick.has(t.id) && t.status !== "done");
|
|
30387
|
+
const ticked = get().tasks.filter((t) => ids.includes(t.id) && t.status !== "done" && !isExternal(t));
|
|
29456
30388
|
if (ticked.length === 0) return;
|
|
29457
|
-
|
|
30389
|
+
const tick = new Set(ticked.map((t) => t.id));
|
|
30390
|
+
write({ tasks: get().tasks.map((t) => tick.has(t.id) ? withStatus(t, "done", {
|
|
30391
|
+
people: get().people,
|
|
30392
|
+
by: get().currentUserId
|
|
30393
|
+
}) : t) });
|
|
29458
30394
|
for (const t of ticked) get().log(`ticked off “${t.title}” on First voyage`, `/projects/${t.projectId}`);
|
|
29459
30395
|
},
|
|
29460
30396
|
keepTasks: (ids) => {
|
|
@@ -29471,7 +30407,7 @@ function tasksSlice({ set, get, write }) {
|
|
|
29471
30407
|
editTasks: (ids, change, opts) => {
|
|
29472
30408
|
const s = get();
|
|
29473
30409
|
const pick = new Set(ids.slice(0, 500));
|
|
29474
|
-
const moving = s.tasks.filter((t) => pick.has(t.id)).filter((t) => applyBulk(t, change) !== t);
|
|
30410
|
+
const moving = s.tasks.filter((t) => pick.has(t.id) && !bulkLocked(t, change)).filter((t) => applyBulk(t, change) !== t);
|
|
29475
30411
|
if (moving.length === 0) return { changed: 0 };
|
|
29476
30412
|
if ("status" in change) {
|
|
29477
30413
|
if (change.status === "done" && !opts?.allowBlocked) {
|
|
@@ -29503,7 +30439,10 @@ function tasksSlice({ set, get, write }) {
|
|
|
29503
30439
|
if (!moved.has(row.id)) return row;
|
|
29504
30440
|
let next = applyBulk(row, change);
|
|
29505
30441
|
if ("status" in change) {
|
|
29506
|
-
next = withStatus(row, change.status
|
|
30442
|
+
next = withStatus(row, change.status, {
|
|
30443
|
+
people: s.people,
|
|
30444
|
+
by: s.currentUserId
|
|
30445
|
+
});
|
|
29507
30446
|
if (change.status === "done" && isBlocked$1(row, s.tasks)) Object.assign(next, blockersPatch([]));
|
|
29508
30447
|
}
|
|
29509
30448
|
const { task: automated, comments } = applyAutomations(projects.get(row.projectId), row, next, {
|
|
@@ -29624,6 +30563,9 @@ function tasksSlice({ set, get, write }) {
|
|
|
29624
30563
|
}
|
|
29625
30564
|
}
|
|
29626
30565
|
var init_tasks = __esmMin((() => {
|
|
30566
|
+
init_agent_check();
|
|
30567
|
+
init_former_crew();
|
|
30568
|
+
init_task_approval();
|
|
29627
30569
|
init_github_refs();
|
|
29628
30570
|
init_board();
|
|
29629
30571
|
init_automations();
|
|
@@ -29643,6 +30585,7 @@ var init_tasks = __esmMin((() => {
|
|
|
29643
30585
|
init_task_people();
|
|
29644
30586
|
init_subtasks();
|
|
29645
30587
|
init_task_start();
|
|
30588
|
+
init_rollup_lock();
|
|
29646
30589
|
}));
|
|
29647
30590
|
|
|
29648
30591
|
// src/lib/raid-history.ts
|
|
@@ -30326,7 +31269,8 @@ function peopleSpendSlice({ set, get, write }) {
|
|
|
30326
31269
|
/**
|
|
30327
31270
|
* One handover's changes as a single write: each item to its new person, the
|
|
30328
31271
|
* line that travels with it (a comment on a task, an update on a RAID item),
|
|
30329
|
-
* and the moves that actually applied. Done or missing items are skipped
|
|
31272
|
+
* and the moves that actually applied. Done or missing items are skipped, and
|
|
31273
|
+
* so are tasks whose owner Jira sets.
|
|
30330
31274
|
*/
|
|
30331
31275
|
function applyMoves(s, moves, lineFor) {
|
|
30332
31276
|
const by = s.currentUserId;
|
|
@@ -30347,7 +31291,7 @@ function applyMoves(s, moves, lineFor) {
|
|
|
30347
31291
|
const patch = {};
|
|
30348
31292
|
if (tasksTo.size) patch.tasks = s.tasks.map((t) => {
|
|
30349
31293
|
const m = tasksTo.get(t.id);
|
|
30350
|
-
if (!m || t.status === "done" || t.assigneeId === m.toId) return t;
|
|
31294
|
+
if (!m || t.status === "done" || t.assigneeId === m.toId || lockedFields(t).includes("assigneeId")) return t;
|
|
30351
31295
|
done(m);
|
|
30352
31296
|
comments.push({
|
|
30353
31297
|
id: uid("c"),
|
|
@@ -30416,6 +31360,7 @@ var init_people_spend = __esmMin((() => {
|
|
|
30416
31360
|
init_format();
|
|
30417
31361
|
init_handover();
|
|
30418
31362
|
init_assignment();
|
|
31363
|
+
init_rollup_lock();
|
|
30419
31364
|
init_spend();
|
|
30420
31365
|
init_utils();
|
|
30421
31366
|
init_countries();
|
|
@@ -32819,6 +33764,11 @@ async function tryHere(opts) {
|
|
|
32819
33764
|
}
|
|
32820
33765
|
if (opts.apply) {
|
|
32821
33766
|
const s = store.getState();
|
|
33767
|
+
const held = heldText(s, project.id, dockHeld(s, project.id, changes));
|
|
33768
|
+
if (held) {
|
|
33769
|
+
result.held = held;
|
|
33770
|
+
result.lines.push("", held);
|
|
33771
|
+
}
|
|
32822
33772
|
result.applied = applyDock({
|
|
32823
33773
|
getState: store.getState,
|
|
32824
33774
|
deleteTask: s.deleteTask,
|
|
@@ -33013,6 +33963,7 @@ function DockPanel({ id, width, height, go, active, onClose }) {
|
|
|
33013
33963
|
});
|
|
33014
33964
|
go.confirm(`Make ${changes.length === 1 ? "this change" : `these ${changes.length} changes`} to ${project.name} for real?${drops.length ? ` That removes ${drops.join(", ")}.` : ""} u undoes it.`, () => {
|
|
33015
33965
|
const s = store.getState();
|
|
33966
|
+
const held = heldText(s, project.id, dockHeld(s, project.id, changes));
|
|
33016
33967
|
const made = applyDock({
|
|
33017
33968
|
getState: store.getState,
|
|
33018
33969
|
deleteTask: s.deleteTask,
|
|
@@ -33022,7 +33973,7 @@ function DockPanel({ id, width, height, go, active, onClose }) {
|
|
|
33022
33973
|
setAllocation: s.setAllocation
|
|
33023
33974
|
}, project.id, changes);
|
|
33024
33975
|
setChanges([]);
|
|
33025
|
-
go.notify(`Made ${made} change${made === 1 ? "" : "s"}
|
|
33976
|
+
go.notify(`Made ${made} change${made === 1 ? "" : "s"}.${held ? ` ${held}` : ""}`);
|
|
33026
33977
|
onClose();
|
|
33027
33978
|
}, "Apply");
|
|
33028
33979
|
};
|
|
@@ -34503,6 +35454,7 @@ function taskFromTemplate(template, opts) {
|
|
|
34503
35454
|
init_swatches();
|
|
34504
35455
|
init_format();
|
|
34505
35456
|
init_task_people();
|
|
35457
|
+
init_rollup_lock();
|
|
34506
35458
|
init_hill();
|
|
34507
35459
|
init_bottle();
|
|
34508
35460
|
init_clock();
|
|
@@ -34663,7 +35615,11 @@ function ProjectView({ projectId, active, width, height, go, onBack }) {
|
|
|
34663
35615
|
if (key.return && selected) return go.openTask(selected.id);
|
|
34664
35616
|
if (input === "n") return go.newTask(projectId, mode === "board" ? column?.status : void 0);
|
|
34665
35617
|
if (input === "x" && selected) return moveTask(store, go, selected, "done");
|
|
34666
|
-
if (input === "d" && selected)
|
|
35618
|
+
if (input === "d" && selected) {
|
|
35619
|
+
const refusal = externalDeleteRefusal(selected);
|
|
35620
|
+
if (refusal) return go.notify(refusal);
|
|
35621
|
+
return go.confirm(`Delete ${keyOf$1({ projects }, selected)} “${selected.title}”? u undoes it.`, () => store.getState().deleteTask(selected.id), "Delete");
|
|
35622
|
+
}
|
|
34667
35623
|
if (mode === "board") {
|
|
34668
35624
|
if (key.leftArrow || input === "h") setCol((c) => step$1(c, -1, columns.length));
|
|
34669
35625
|
else if (key.rightArrow || input === "l") setCol((c) => step$1(c, 1, columns.length));
|
|
@@ -35880,6 +36836,14 @@ function offer(def, t) {
|
|
|
35880
36836
|
return opts.length ? `“${t}” isn't one of ${def.name}'s options: ${opts.join(", ")}.` : `${def.name} has no options yet.`;
|
|
35881
36837
|
}
|
|
35882
36838
|
|
|
36839
|
+
// src/tui/locks.ts
|
|
36840
|
+
init_rollup_lock();
|
|
36841
|
+
/** Why this field can't be changed here, before any new value is typed; null when it can. */
|
|
36842
|
+
function fieldLock(task, field) {
|
|
36843
|
+
if (!lockedFields(task).includes(field)) return null;
|
|
36844
|
+
return externalRefusal(task, { [field]: Symbol("other") });
|
|
36845
|
+
}
|
|
36846
|
+
|
|
35883
36847
|
// src/tui/views/sounding.ts
|
|
35884
36848
|
init_soundings();
|
|
35885
36849
|
const nameOf = (people, id) => people.find((p) => p.id === id)?.name ?? "someone";
|
|
@@ -36020,6 +36984,7 @@ init_task_people();
|
|
|
36020
36984
|
init_search();
|
|
36021
36985
|
init_swatches();
|
|
36022
36986
|
init_task_milestones();
|
|
36987
|
+
init_rollup_lock();
|
|
36023
36988
|
const FIELDS = [
|
|
36024
36989
|
{
|
|
36025
36990
|
field: "title",
|
|
@@ -36058,6 +37023,16 @@ const FIELDS = [
|
|
|
36058
37023
|
label: "Notes"
|
|
36059
37024
|
}
|
|
36060
37025
|
];
|
|
37026
|
+
/** The task field each row changes, for the ones Jira or Asana may own. */
|
|
37027
|
+
const LOCKABLE = {
|
|
37028
|
+
title: "title",
|
|
37029
|
+
status: "status",
|
|
37030
|
+
assignee: "assigneeId",
|
|
37031
|
+
due: "dueDate",
|
|
37032
|
+
priority: "priority",
|
|
37033
|
+
project: "projectId",
|
|
37034
|
+
repeat: "repeat"
|
|
37035
|
+
};
|
|
36061
37036
|
const REPEATS = [
|
|
36062
37037
|
null,
|
|
36063
37038
|
"weekly",
|
|
@@ -36139,10 +37114,14 @@ function TaskPanel({ taskId, width, height, go, active = true, onClose }) {
|
|
|
36139
37114
|
}
|
|
36140
37115
|
}, task.title);
|
|
36141
37116
|
}
|
|
36142
|
-
if (input === "d")
|
|
36143
|
-
|
|
36144
|
-
|
|
36145
|
-
|
|
37117
|
+
if (input === "d") {
|
|
37118
|
+
const refusal = externalDeleteRefusal(task);
|
|
37119
|
+
if (refusal) return go.notify(refusal);
|
|
37120
|
+
return go.confirm(`Delete ${keyOf$1({ projects }, task)} “${task.title}”? u undoes it.`, () => {
|
|
37121
|
+
store.getState().deleteTask(task.id);
|
|
37122
|
+
onClose();
|
|
37123
|
+
}, "Delete");
|
|
37124
|
+
}
|
|
36146
37125
|
const custom = own[at - FIELDS.length];
|
|
36147
37126
|
if (custom && key.return) return editCustom(custom);
|
|
36148
37127
|
const item = task.checklist[at - stepsFrom];
|
|
@@ -36163,10 +37142,16 @@ function TaskPanel({ taskId, width, height, go, active = true, onClose }) {
|
|
|
36163
37142
|
field: "also"
|
|
36164
37143
|
});
|
|
36165
37144
|
}
|
|
36166
|
-
if (key.return && FIELDS[at])
|
|
36167
|
-
|
|
36168
|
-
|
|
36169
|
-
|
|
37145
|
+
if (key.return && FIELDS[at]) {
|
|
37146
|
+
const field = FIELDS[at].field;
|
|
37147
|
+
const owned = LOCKABLE[field];
|
|
37148
|
+
const refusal = owned ? fieldLock(task, owned) : null;
|
|
37149
|
+
if (refusal) return go.notify(refusal);
|
|
37150
|
+
return setEditing({
|
|
37151
|
+
kind: "field",
|
|
37152
|
+
field
|
|
37153
|
+
});
|
|
37154
|
+
}
|
|
36170
37155
|
}, { isActive: active && editing === null });
|
|
36171
37156
|
if (!task) return null;
|
|
36172
37157
|
const project = projects.find((p) => p.id === task.projectId);
|
|
@@ -38032,12 +39017,17 @@ async function sweepFog(opts) {
|
|
|
38032
39017
|
].filter(Boolean).join(" · ");
|
|
38033
39018
|
say(`${i + 1} of ${queue.length} ${task.title}`);
|
|
38034
39019
|
say(` ${where}`);
|
|
39020
|
+
const lock = fogLock(task);
|
|
39021
|
+
if (lock) say(` ${lock}`);
|
|
38035
39022
|
for (;;) {
|
|
38036
39023
|
const key = (await ask(" k, d, x, s or q: ")).trim().toLowerCase();
|
|
38037
39024
|
if (key === "k") {
|
|
38038
39025
|
store.getState().keepTasks([task.id]);
|
|
38039
39026
|
tally.kept++;
|
|
38040
39027
|
say(" Kept. The fog's off it.\n");
|
|
39028
|
+
} else if (lock && (key === "d" || key === "x")) {
|
|
39029
|
+
say(` ${lock}`);
|
|
39030
|
+
continue;
|
|
38041
39031
|
} else if (key === "d") {
|
|
38042
39032
|
let due = null;
|
|
38043
39033
|
while (!due) {
|