create-pmos 0.609.0 → 0.611.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/package.json +69 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-columns-test.js +2 -1
- package/workspace/board-deliveries-test.js +2 -1
- package/workspace/board-programs-test.js +9 -5
- package/workspace/board-publish-ui-test.js +2 -1
- package/workspace/board-shared-ui-test.js +2 -1
- package/workspace/board-workflows-test.js +2 -1
- package/workspace/briefing-premium-adddoc-test.js +2 -1
- package/workspace/briefing-premium-board-test.js +10 -9
- package/workspace/briefing-premium-doc-edit-test.js +2 -1
- package/workspace/briefing-premium-initiative-test.js +7 -6
- package/workspace/briefing-premium-insights-test.js +12 -11
- package/workspace/briefing-premium-products-test.js +4 -2
- package/workspace/briefing-premium-sources-test.js +1 -1
- package/workspace/briefing-premium-test.js +6 -5
- package/workspace/briefing-premium-work-test.js +1 -1
- package/workspace/calm-timeline-test.js +2 -1
- package/workspace/changelog.json +68 -0
- package/workspace/core-docs-workflow-test.js +2 -1
- package/workspace/ev-everywhere-test.js +11 -10
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +4 -0
- package/workspace/guide/layout.md +92 -11
- package/workspace/guide/programs.md +16 -2
- package/workspace/guide/routine.md +50 -0
- package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/home-other-product-test.js +2 -1
- package/workspace/home-railcard-test.js +2 -1
- package/workspace/impact-screens-test.js +3 -1
- package/workspace/ini-workflow-test.js +2 -1
- package/workspace/lib/beside-page.js +15 -0
- package/workspace/lib/classic-board.js +15 -0
- package/workspace/lib/events-place.js +216 -0
- package/workspace/lib/library-items.js +78 -0
- package/workspace/lib/notes.js +6 -1
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-events-place.js +166 -0
- package/workspace/lib/routes-library.js +89 -0
- package/workspace/lib/routes-pop-work.js +39 -0
- package/workspace/lib/routes-report-setups.js +20 -0
- package/workspace/lib/routes-today-log.js +48 -0
- package/workspace/lib/routine-reports.js +52 -0
- package/workspace/lib/today-log.js +131 -0
- package/workspace/live-pill-round-test.js +11 -9
- package/workspace/metric-drafts-ui-test.js +3 -1
- package/workspace/milestone-pins-test.js +2 -1
- package/workspace/milestone-suggest-test.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +6 -4
- package/workspace/premium-board-actions-test.js +3 -1
- package/workspace/premium-chat-context-test.js +6 -6
- package/workspace/premium-chat-line-test.js +1 -1
- package/workspace/premium-chat-notes-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +2 -1
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-backlog-test.js +3 -1
- package/workspace/premium-vw-cal-test.js +1 -1
- package/workspace/premium-vw-doc-test.js +2 -1
- package/workspace/premium-vw-item-test.js +3 -1
- package/workspace/premium-vw-jira-test.js +3 -1
- package/workspace/product-lane-test.js +2 -1
- package/workspace/program-charter-test.js +3 -1
- package/workspace/program-leave-test.js +3 -1
- package/workspace/program-order-test.js +2 -1
- package/workspace/program-panel-test.js +5 -3
- package/workspace/public/pm/bd-ini-panel.js +75 -8
- package/workspace/public/pm/bd-prog-panel.js +55 -8
- package/workspace/public/pm/bd-scroll.js +4 -2
- package/workspace/public/pm/bd-work.css +130 -0
- package/workspace/public/pm/bd-work.js +356 -0
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-ev.css +52 -0
- package/workspace/public/pm/cozy-events-view.js +142 -0
- package/workspace/public/pm/cozy-events.css +107 -0
- package/workspace/public/pm/cozy-events.js +210 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-library.css +36 -0
- package/workspace/public/pm/cozy-live-pill.js +3 -1
- package/workspace/public/pm/cozy-nav.js +70 -7
- package/workspace/public/pm/cozy-panels.js +1 -1
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pick.js +6 -2
- package/workspace/public/pm/cozy-pop-work.css +165 -0
- package/workspace/public/pm/cozy-pop-work.js +427 -0
- package/workspace/public/pm/cozy-popup.css +113 -0
- package/workspace/public/pm/cozy-popup.js +408 -0
- package/workspace/public/pm/cozy-routine-model.js +111 -0
- package/workspace/public/pm/cozy-routine-pop.js +196 -0
- package/workspace/public/pm/cozy-routine.css +102 -0
- package/workspace/public/pm/cozy-routine.js +156 -0
- package/workspace/public/pm/cozy-schedwork.js +6 -5
- package/workspace/public/pm/cozy-settings.js +10 -1
- package/workspace/public/pm/cozy-today-app.js +236 -0
- package/workspace/public/pm/cozy-today-model.js +176 -0
- package/workspace/public/pm/cozy-today-page.css +100 -0
- package/workspace/public/pm/cozy-today-view.js +76 -0
- package/workspace/public/pm/cozy-viewer.js +66 -18
- package/workspace/public/pm/home-app.js +29 -6
- package/workspace/public/pm/home-ini.js +39 -7
- package/workspace/public/pm/library-model.js +69 -0
- package/workspace/public/pm/library-open.js +34 -0
- package/workspace/public/pm/page-chat.js +16 -4
- package/workspace/public/pm/pop-sessions.js +65 -0
- package/workspace/public/pm/pop-work-model.js +335 -0
- package/workspace/public/pm/premium-board.js +137 -11
- package/workspace/public/pm/premium-insights.js +14 -2
- package/workspace/public/pm/premium-library.js +122 -0
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-events.html +42 -0
- package/workspace/public/premium-library.html +31 -0
- package/workspace/public/premium-routine.html +31 -0
- package/workspace/public/today.html +50 -0
- package/workspace/ready-dash-ui-test.js +3 -1
- package/workspace/rename-test.js +2 -1
- package/workspace/run-tests.js +4 -1
- package/workspace/server.js +3 -2
- package/workspace/sort-order-test.js +2 -1
- package/workspace/split-merge-ui-test.js +3 -1
- package/workspace/stage-card-tasks-test.js +5 -3
- package/workspace/stage-card-test.js +2 -1
- package/workspace/task-card-test.js +2 -1
- package/workspace/task-delete-test.js +3 -1
- package/workspace/task-links-test.js +4 -2
- package/workspace/task-milestones-test.js +4 -2
- package/workspace/task-plans-test.js +3 -1
- package/workspace/task-press-test.js +3 -1
- package/workspace/task-views-test.js +10 -8
- package/workspace/test-lists/events-place.json +11 -0
- package/workspace/test-lists/library-place.json +9 -0
- package/workspace/test-lists/one-popup.json +9 -0
- package/workspace/test-lists/pop-work.json +9 -0
- package/workspace/test-lists/routine-place.json +9 -0
- package/workspace/test-lists/today-log.json +9 -0
- package/workspace/test-lists/work-view.json +9 -0
- package/workspace/timeline-holds-test.js +3 -1
- package/workspace/tk-tasks-test.js +3 -1
- package/workspace/viewer-trail-test.js +1 -1
- package/workspace/workflows-setup-test.js +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* pm/pop-sessions.js — the sessions of the popup's chat (slice 2 of the six-place navigation, boards 3, 7 and 23). Pure: no DOM, no fetch,
|
|
2
|
+
* so Node tests it.
|
|
3
|
+
*
|
|
4
|
+
* sessionRows(list, { titleOf(ini) → name | '', now }) → { now: [row], earlier: [row], all: [row] }
|
|
5
|
+
* list is GET /api/sessions .sessions. Now: live sessions. Earlier: ended ones (a chat that ended stays as Earlier, newest run only, and
|
|
6
|
+
* never beside its live run). Newest first in each. A PMOS-started session that asks nothing, and a start shell, are not listed (as Home).
|
|
7
|
+
* row: { id, key, ini, ws, name, work, state: 'wait'|'work'|'', word, live, at }
|
|
8
|
+
* work the name of the work it is about, or "No work"
|
|
9
|
+
* state 'wait' (it waits for you), 'work' (PMOS is working), '' (idle or ended)
|
|
10
|
+
* word "Waits for you", "PMOS is working", or when it was last used ("14:05", "Yesterday", "Mon", "12 Nov")
|
|
11
|
+
* pickSession(rows) → the row the chat icon opens: the newest that waits for you, else the newest live, else the newest; null for none
|
|
12
|
+
* recent(rows, n) → the chooser's rows: the newest n of all, live ones first
|
|
13
|
+
* nextKey(base, list) → base + ':' + the first free number from 2 (a new session about the same work, as Home's newIn)
|
|
14
|
+
* timeWord(iso, now) → the last-used word */
|
|
15
|
+
import { keyOfSession, iniOfSession, nameOf, startShell } from './home-data.js';
|
|
16
|
+
|
|
17
|
+
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
18
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
20
|
+
const ended = (s) => s.shown === 'exited' || s.state === 'exited';
|
|
21
|
+
const atOf = (s) => String(s.touched_at || s.last || s.updated || s.created || '');
|
|
22
|
+
const t = (iso) => { const n = Date.parse(iso || ''); return Number.isNaN(n) ? 0 : n; };
|
|
23
|
+
|
|
24
|
+
export function timeWord(iso, now = Date.now()) {
|
|
25
|
+
const d = new Date(iso); if (Number.isNaN(d.getTime())) return '';
|
|
26
|
+
const n = new Date(now), y = new Date(now); y.setDate(n.getDate() - 1);
|
|
27
|
+
if (d.toDateString() === n.toDateString()) return pad(d.getHours()) + ':' + pad(d.getMinutes());
|
|
28
|
+
if (d.toDateString() === y.toDateString()) return 'Yesterday';
|
|
29
|
+
if (now - d.getTime() < 6 * 86400000 && d.getTime() <= now) return DOW[d.getDay()];
|
|
30
|
+
return d.getDate() + ' ' + MON[d.getMonth()];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function sessionRows(list, { titleOf = () => '', now = Date.now() } = {}) {
|
|
34
|
+
const L = (Array.isArray(list) ? list : []).filter((s) => s && s.id && !startShell(s) && !s.away)
|
|
35
|
+
// a session PMOS started is listed only while it works or asks you something (Home's rule, home-data.js homeSessions)
|
|
36
|
+
.filter((s) => !(s.automatic && (ended(s) || s.shown === 'needs' || s.shown === 'quiet') && !s.ask));
|
|
37
|
+
const liveKeys = new Set(L.filter((s) => !ended(s)).map(keyOfSession).filter(Boolean));
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
const rows = [];
|
|
40
|
+
for (const s of L.slice().sort((a, b) => t(atOf(b)) - t(atOf(a)))) {
|
|
41
|
+
const key = keyOfSession(s), live = !ended(s);
|
|
42
|
+
if (!live && key && (liveKeys.has(key) || seen.has(key))) continue; // one row per conversation: its live run, else its newest ended run
|
|
43
|
+
if (!live && !key && !s.headless && s.agent === 'shell') continue; // an ended terminal shell has nothing to go back to
|
|
44
|
+
if (key) seen.add(key);
|
|
45
|
+
const ini = iniOfSession(s);
|
|
46
|
+
const state = live && (s.shown === 'needs' || s.shown === 'blocked' || s.ask) ? 'wait' : live && s.shown === 'working' ? 'work' : '';
|
|
47
|
+
const at = atOf(s);
|
|
48
|
+
rows.push({ id: s.id, key, ini, ws: s.ws || '', name: nameOf(s) || 'Session', work: (ini && titleOf(ini)) || (ini ? ini : 'No work'), state, live,
|
|
49
|
+
word: state === 'wait' ? 'Waits for you' : state === 'work' ? 'PMOS is working' : timeWord(at, now), at });
|
|
50
|
+
}
|
|
51
|
+
const nowRows = rows.filter((r) => r.live), earlier = rows.filter((r) => !r.live);
|
|
52
|
+
return { now: nowRows, earlier, all: nowRows.concat(earlier) };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function pickSession(rows) {
|
|
56
|
+
const L = Array.isArray(rows) ? rows : [];
|
|
57
|
+
return L.find((r) => r.state === 'wait') || L.find((r) => r.live) || L[0] || null;
|
|
58
|
+
}
|
|
59
|
+
export const recent = (rows, n = 5) => (Array.isArray(rows) ? rows : []).slice(0, n);
|
|
60
|
+
|
|
61
|
+
export function nextKey(base, list) {
|
|
62
|
+
const used = new Set((Array.isArray(list) ? list : []).map(keyOfSession).filter(Boolean));
|
|
63
|
+
let n = 2; while (used.has(base + ':' + n)) n++;
|
|
64
|
+
return base + ':' + n;
|
|
65
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/* pm/pop-work-model.js — what the popup shows for work, as data (slice 3 of the six-place navigation; boards 3, 20, 21, 22, 25 on Exploring 2,
|
|
2
|
+
* page "Navigation: Today, Work, Goals, Events, Library, Routine"; build plan /mnt/project-files/nav-structure/build-plan.md). Pure: no DOM, no
|
|
3
|
+
* reads. pm/cozy-pop-work.js draws it; pop-work.test.js checks it.
|
|
4
|
+
*
|
|
5
|
+
* workOf(r, v, o) → { title, overview, suggests, rowSuggests, more, rows, span, artefacts, many } one initiative in the popup
|
|
6
|
+
* r the initiative row as GET /api/board-premium sends it (Board and Home both read it)
|
|
7
|
+
* v pm/ini-view-model.js iniView(r, ctx): the stage, its dates, the tasks by stage, what PMOS proposes (v.props)
|
|
8
|
+
* o { steps (Product feature's eight), today ('YYYY-MM-DD'), docs (home-ini-model.js docRows of the initiative's read), items (the
|
|
9
|
+
* Library's rows for this initiative, GET /api/library-items, when that route is there), product (its name), program ({ title } | null),
|
|
10
|
+
* goal (the goal's name, else the anchor), mode ('full' | 'quarter' | 'half' | 'year' | '2y' | '5y': the timeline's span), open (Set of
|
|
11
|
+
* stage keys the PM unfolded), shut (Set of stage keys the PM folded), doneOpen (Set of stage keys whose done tasks show), farOpen (bool) }
|
|
12
|
+
* levelOf(L, o) → the same parts one level up: a program or a product (boards 26, 27). L: { kind, title, path, summary, facts, rows, docs, props }
|
|
13
|
+
* spanOf(dates, mode, today) → { a, b } ISO the window of the timeline: Full runs from the earliest start to the latest end (no bar is cut)
|
|
14
|
+
* barOf(x, span, today) → { l, w, pass, late, ms, dot } in % of the window one bar: the plan, the part that has passed, the missed date
|
|
15
|
+
* dayText(iso, today) → "4 Nov", "13 Jan 2027" dateLate(iso, today) → "4 Nov · 14 days late" | "4 Nov"
|
|
16
|
+
* summaryOf(r, v, o) → { text, own } own: the PM's words (the record's description); else PMOS wrote it (✦)
|
|
17
|
+
*
|
|
18
|
+
* THE RULES (design notes st2, boards 3, 20, 21, 22, 25):
|
|
19
|
+
* 1 Overview: the summary, then "PMOS suggests" (at most three; absent when there is none), then the facts. With many tasks the Overview
|
|
20
|
+
* folds to its summary and "Details" opens the facts (many: more than 6 rows of tasks in the open stage).
|
|
21
|
+
* 2 A suggestion about one task sits under that task (rowSuggests by uid); the same suggestion never shows twice.
|
|
22
|
+
* 3 The breakdown: a stage is a row that folds ("3 of 9 done"). Only the stage in progress opens by itself. In the open stage late tasks
|
|
23
|
+
* come first, then by date; done tasks fold to one line ("3 tasks done"). The stages after the next one fold into one row
|
|
24
|
+
* ("Prioritize to Evaluate, 5 stages").
|
|
25
|
+
* 4 Bars: light grey the plan, dark grey the part that has passed, the missed date a diamond, a red line from it to today. A row with no
|
|
26
|
+
* date has no bar: PMOS does not invent a date.
|
|
27
|
+
* 5 Artefacts: one table: Artefact, Kind, Updated. A core document a gate needs that is not written is a grey row that says which gate. */
|
|
28
|
+
|
|
29
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
30
|
+
const DAY = 864e5;
|
|
31
|
+
const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
32
|
+
const iso = (d) => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
|
|
33
|
+
const between = (a, b) => Math.round((b - a) / DAY);
|
|
34
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
35
|
+
const todayOf = (o) => day(o && o.today) || (() => { const d = new Date(); return new Date(d.getFullYear(), d.getMonth(), d.getDate()); })();
|
|
36
|
+
const norm = (s) => String(s || '').trim().toLowerCase().replace(/\s+/g, ' ');
|
|
37
|
+
export const MAX_SUGGEST = 3;
|
|
38
|
+
export const MANY = 6;
|
|
39
|
+
export const MODES = [['quarter', 'Quarter'], ['half', 'Half'], ['year', 'Year'], ['2y', '2 yr'], ['5y', '5 yr'], ['full', 'Full']];
|
|
40
|
+
|
|
41
|
+
/** "4 Nov" this year, "13 Jan 2027" in any other. */
|
|
42
|
+
export function dayText(v, today) {
|
|
43
|
+
const d = day(v); if (!d) return '';
|
|
44
|
+
const t = today instanceof Date ? today : day(today) || new Date();
|
|
45
|
+
return d.getDate() + ' ' + MON[d.getMonth()] + (d.getFullYear() !== t.getFullYear() ? ' ' + d.getFullYear() : '');
|
|
46
|
+
}
|
|
47
|
+
/** A date and, when it has passed and the thing is open, how late: "4 Nov · 14 days late". */
|
|
48
|
+
export function dateLate(v, today, open = true) {
|
|
49
|
+
const d = day(v), t = today instanceof Date ? today : day(today); if (!d || !t) return { text: dayText(v, t), late: false };
|
|
50
|
+
const late = open && d < t;
|
|
51
|
+
return { text: dayText(v, t) + (late ? ' · ' + plural(between(d, t), 'day', 'days') + ' late' : ''), late };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ── the timeline ── */
|
|
55
|
+
/** The window: Full from the earliest date to the latest (and today), so no bar is cut; the others start at the period that holds today. */
|
|
56
|
+
export function spanOf(dates, mode, today) {
|
|
57
|
+
const t = today instanceof Date ? today : day(today) || new Date();
|
|
58
|
+
const ds = (dates || []).map(day).filter(Boolean).concat([t]);
|
|
59
|
+
if (!mode || mode === 'full') {
|
|
60
|
+
let a = new Date(Math.min(...ds)), b = new Date(Math.max(...ds));
|
|
61
|
+
if (between(a, b) < 28) b = new Date(a.getFullYear(), a.getMonth(), a.getDate() + 28);
|
|
62
|
+
const pad = Math.max(2, Math.round(between(a, b) * 0.03));
|
|
63
|
+
a = new Date(a.getFullYear(), a.getMonth(), a.getDate() - pad); b = new Date(b.getFullYear(), b.getMonth(), b.getDate() + pad);
|
|
64
|
+
return { a: iso(a), b: iso(b) };
|
|
65
|
+
}
|
|
66
|
+
const y = t.getFullYear(), m = t.getMonth();
|
|
67
|
+
const start = mode === 'quarter' ? new Date(y, m - (m % 3), 1) : mode === 'half' ? new Date(y, m < 6 ? 0 : 6, 1) : new Date(y, 0, 1);
|
|
68
|
+
const months = { quarter: 3, half: 6, year: 12, '2y': 24, '5y': 60 }[mode] || 12;
|
|
69
|
+
return { a: iso(start), b: iso(new Date(start.getFullYear(), start.getMonth() + months, 0)) };
|
|
70
|
+
}
|
|
71
|
+
const pct = (d, S) => { const a = day(S.a), b = day(S.b); return ((d - a) / Math.max(DAY, b - a)) * 100; };
|
|
72
|
+
const clamp = (n) => Math.max(0, Math.min(100, n));
|
|
73
|
+
/** One bar in the window. x: { start, end, done, open }. A row with neither date has no bar (null). */
|
|
74
|
+
export function barOf(x, S, today) {
|
|
75
|
+
const t = today instanceof Date ? today : day(today) || new Date();
|
|
76
|
+
const a0 = day(x.start), b0 = day(x.end);
|
|
77
|
+
if (!a0 && !b0) return null;
|
|
78
|
+
const a = a0 || b0, b = b0 || a0;
|
|
79
|
+
const l = clamp(pct(a, S)), r = clamp(pct(new Date(b.getFullYear(), b.getMonth(), b.getDate() + 1), S));
|
|
80
|
+
if (r <= 0 || l >= 100) return { off: true };
|
|
81
|
+
const tx = clamp(pct(t, S));
|
|
82
|
+
const pass = x.done ? r - l : Math.max(0, Math.min(r, tx) - l);
|
|
83
|
+
const missed = !x.done && x.open !== false && !!b0 && b0 < t;
|
|
84
|
+
return { l, w: Math.max(0.6, r - l), pass: Math.max(0, pass), dot: !a0 || !b0,
|
|
85
|
+
late: missed ? { l: clamp(pct(b0, S)), w: Math.max(0.3, tx - clamp(pct(b0, S))) } : null, ms: missed ? clamp(pct(b0, S)) : null };
|
|
86
|
+
}
|
|
87
|
+
/** The month marks on the header: the first of each month that fits, thinned to about six. */
|
|
88
|
+
export function marksOf(S, today) {
|
|
89
|
+
const a = day(S.a), b = day(S.b), t = today instanceof Date ? today : day(today) || new Date(), out = [];
|
|
90
|
+
const n = (b.getFullYear() - a.getFullYear()) * 12 + b.getMonth() - a.getMonth();
|
|
91
|
+
const step = n <= 6 ? 1 : n <= 14 ? 3 : n <= 30 ? 6 : 12;
|
|
92
|
+
for (let d = new Date(a.getFullYear(), a.getMonth() + 1, 1); d < b; d = new Date(d.getFullYear(), d.getMonth() + 1, 1)) {
|
|
93
|
+
if (d.getMonth() % step) continue;
|
|
94
|
+
out.push({ x: pct(d, S), label: d.getMonth() === 0 && step < 12 ? String(d.getFullYear()) : step >= 12 ? String(d.getFullYear()) : MON[d.getMonth()] });
|
|
95
|
+
}
|
|
96
|
+
const tx = pct(t, S);
|
|
97
|
+
return { months: out.filter((m) => m.x > 2 && m.x < 98), today: tx >= 0 && tx <= 100 ? tx : null };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* ── the stages and the dates they ran (the record only) ── */
|
|
101
|
+
function ranOf(r, list) {
|
|
102
|
+
const tr = r.trail || {}, moves = Array.isArray(tr.moves) ? tr.moves : [];
|
|
103
|
+
const idx = (to) => list.findIndex((s) => s.key === to || norm(s.name) === norm(to));
|
|
104
|
+
const ran = list.map(() => ({ from: null, to: null }));
|
|
105
|
+
moves.forEach((m, i) => { const j = idx(m.to); if (j < 0) return; ran[j].from = m.at; const nx = moves[i + 1]; ran[j].to = nx ? nx.at : null; });
|
|
106
|
+
const cur = list.findIndex((s) => s.status === 'now');
|
|
107
|
+
if (cur >= 0 && tr.since) ran[cur].from = tr.since;
|
|
108
|
+
if (list.length && !ran[0].from && r.start) ran[0].from = String(r.start).slice(0, 10);
|
|
109
|
+
const fr = (r.found && r.found.ran) || {};
|
|
110
|
+
list.forEach((s, i) => { const f = fr[s.key] || fr[s.name]; if (f && f.from) ran[i].from = f.from; if (f && f.to) ran[i].to = f.to; });
|
|
111
|
+
return ran;
|
|
112
|
+
}
|
|
113
|
+
const isoOf = (v) => (v ? String(v).slice(0, 10) : '');
|
|
114
|
+
const taskSpan = (ts) => {
|
|
115
|
+
const a = ts.map((x) => x.start || x.end).filter(Boolean).sort(), b = ts.map((x) => x.end || x.start).filter(Boolean).sort();
|
|
116
|
+
return [a[0] || '', b[b.length - 1] || ''];
|
|
117
|
+
};
|
|
118
|
+
const urgent = (a, b) => (b.late - a.late) || (a.end || '9999').localeCompare(b.end || '9999');
|
|
119
|
+
const STATUS = { done: 'Done', now: 'In progress', next: 'To do', skip: 'Skipped' };
|
|
120
|
+
const taskStatus = (x) => (x.wont ? "Won't do" : x.status || 'To do');
|
|
121
|
+
|
|
122
|
+
/* ── the suggestions: what PMOS proposes (r.props, lib/proposals.js), and its split or merge ── */
|
|
123
|
+
const PROP_TITLE = {
|
|
124
|
+
status: (p) => plural(p.items.length, 'task looks', 'tasks look') + ' done. Mark ' + (p.items.length === 1 ? 'it' : 'them') + ' done?',
|
|
125
|
+
names: (p) => 'Tidy ' + plural(p.items.length, 'name', 'names') + '?',
|
|
126
|
+
description: () => 'Keep this description?',
|
|
127
|
+
build: () => 'Open a draft pull request?',
|
|
128
|
+
outcome: (p) => (p.type === 'date' ? 'Set a date to check the outcome?' : 'Say what should change once it ships?'),
|
|
129
|
+
};
|
|
130
|
+
/** One line of a proposal, in plain words. */
|
|
131
|
+
export function sayOf(p) {
|
|
132
|
+
if (!p) return '';
|
|
133
|
+
if (p.title) return String(p.title);
|
|
134
|
+
const f = PROP_TITLE[p.group];
|
|
135
|
+
if (f) return f(p);
|
|
136
|
+
if (p.group === 'dates') return 'New dates for ' + plural(p.items.length, 'task', 'tasks') + '?';
|
|
137
|
+
if (p.group === 'found') return 'Add what PMOS found elsewhere?';
|
|
138
|
+
return 'A change PMOS suggests';
|
|
139
|
+
}
|
|
140
|
+
/** The task a proposal is about, when it is about one task only (it then sits under that row). */
|
|
141
|
+
const aboutTask = (p) => { const it = p.items || []; return it.length === 1 && (it[0].task || it[0].uid) ? String(it[0].task || it[0].uid) : ''; };
|
|
142
|
+
export function suggestsOf(v) {
|
|
143
|
+
const P = (((v && v.props) || {}).groups || []).flatMap((g) => g.props || []).filter((p) => p && p.id && p.section !== 'unplaced' && p.group !== 'grill' && p.group !== 'description');
|
|
144
|
+
const seen = new Set(), rows = new Map(), top = [];
|
|
145
|
+
for (const p of P) {
|
|
146
|
+
const say = sayOf(p), k = norm(say);
|
|
147
|
+
if (seen.has(k)) continue; // the same suggestion never shows twice
|
|
148
|
+
seen.add(k);
|
|
149
|
+
const s = { id: p.id, sig: p.sig || '', say, why: p.why || '', group: p.group, type: p.type || '', sources: p.sources || [], items: p.items || [], data: p.data || {}, sure: p.section === 'sure' };
|
|
150
|
+
const t = aboutTask(p);
|
|
151
|
+
if (t && !rows.has(t)) rows.set(t, s); else top.push(s);
|
|
152
|
+
}
|
|
153
|
+
// split or merge (batch 11 item 14) is a suggestion about the whole initiative
|
|
154
|
+
if (v && v.suggest && v.suggest.kind && v.suggest.title) top.unshift({ id: 'sm', sm: true, say: String(v.suggest.title), why: v.suggest.why || v.suggest.reason || '', group: v.suggest.kind, sources: [], items: [] });
|
|
155
|
+
return { top: top.slice(0, MAX_SUGGEST), more: Math.max(0, top.length - MAX_SUGGEST), rows };
|
|
156
|
+
}
|
|
157
|
+
/** The description PMOS drafted for this initiative, waiting under the ✦ (lib/description-props.js), or null. */
|
|
158
|
+
export function draftDesc(v) {
|
|
159
|
+
const p = (((v && v.props) || {}).groups || []).flatMap((g) => g.props || []).find((x) => x && x.group === 'description' && x.data && x.data.text);
|
|
160
|
+
return p ? { id: p.id, sig: p.sig || '', text: String(p.data.text) } : null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* ── the Overview ── */
|
|
164
|
+
const firstSentences = (s, n = 2) => { const parts = String(s || '').replace(/\s+/g, ' ').trim().match(/[^.!?]+[.!?]+(\s|$)|[^.!?]+$/g) || []; return parts.slice(0, n).join('').trim(); };
|
|
165
|
+
/** The summary: what it is (the record's description, else PMOS's draft), then where it stands, in PMOS's words. own: the PM's words lead. */
|
|
166
|
+
export function summaryOf(r, v, o = {}) {
|
|
167
|
+
const t = todayOf(o), st = v.stage || {}, d = st.dates || {}, said = [];
|
|
168
|
+
const desc = v.desc ? String(v.desc) : '', draft = !desc ? draftDesc(v) : null;
|
|
169
|
+
const lead = desc || (draft && draft.text) || '';
|
|
170
|
+
if (st.name && st.n) said.push('It is in ' + st.name + (d.left ? (/over$/.test(d.left) ? ' and ' + d.left + ' its plan' : ', ' + d.left) : '') + '.');
|
|
171
|
+
const late = ((v.tasks || {}).sections || []).flatMap((s) => (s.top || []).concat(...(s.groups || []).map((g) => g.rows || []))).filter((x) => x.late);
|
|
172
|
+
if (late.length === 1) said.push('One task holds it: ' + late[0].title + ' is ' + late[0].lateText + '.');
|
|
173
|
+
else if (late.length > 1) said.push(plural(late.length, 'task is', 'tasks are') + ' late.');
|
|
174
|
+
const gate = st.gate && (st.gate.parts || []).filter((x) => !x.ok).map((x) => x.text);
|
|
175
|
+
if (gate && gate.length) said.push(gate.join(' and ').replace(/^./, (c) => c.toUpperCase()) + ', so it cannot pass the ' + String(st.gate.label || 'gate').replace(/^Gate/, 'gate') + '.');
|
|
176
|
+
return { lead: firstSentences(lead, 3), own: !!desc, draft, status: said.join(' '), text: [firstSentences(lead, 3), said.join(' ')].filter(Boolean).join(' ') };
|
|
177
|
+
}
|
|
178
|
+
/** The facts: name on the left, value on the right (a Confluence page). act: what a press on the value does (the host has it). */
|
|
179
|
+
export function factsOf(r, v, o = {}) {
|
|
180
|
+
const t = todayOf(o), st = v.stage || {}, d = st.dates || {}, F = [];
|
|
181
|
+
if (st.name) F.push({ k: 'Stage', v: st.name + (st.n ? ' · ' + (r.status === 'done' ? 'Done' : r.ended ? 'Ended' : 'In progress') : ''), act: 'stage' });
|
|
182
|
+
if (r.start || r.end) {
|
|
183
|
+
const p = [r.start ? dayText(r.start, t) : '', r.end ? dayText(r.end, t) : ''].filter(Boolean).join(' to ');
|
|
184
|
+
F.push({ k: 'Plan dates', v: p, note: d.over ? d.left : '', warn: !!d.over, act: 'dates' });
|
|
185
|
+
}
|
|
186
|
+
const nm = nextMilestone(v, t);
|
|
187
|
+
if (nm) F.push({ k: 'Next milestone', v: nm.name, note: nm.date, warn: nm.late, act: nm.uid ? 'task:' + nm.uid : '' });
|
|
188
|
+
else if (r.end) F.push({ k: 'Next milestone', v: 'Plan end', note: dayText(r.end, t), grey: true });
|
|
189
|
+
if (st.next && st.next.name) F.push({ k: 'Next stage', v: st.next.name, act: 'next' });
|
|
190
|
+
const wf = v.summary && v.summary.wf;
|
|
191
|
+
if (wf && wf.name) F.push({ k: 'Workflow', v: wf.name + (st.of ? ', ' + plural(st.of, 'stage', 'stages') : ''), act: 'wf' });
|
|
192
|
+
if (o.goal || v.anchor) F.push({ k: 'Goal', v: o.goal || v.anchor });
|
|
193
|
+
if (o.product) F.push({ k: 'Product', v: o.product, act: o.canProduct ? 'product' : '' }); // board 27: one level up
|
|
194
|
+
if (o.program) F.push({ k: 'Program', v: o.program.title, act: 'program' }); // board 26
|
|
195
|
+
if (st.gate && (st.gate.parts || []).length) {
|
|
196
|
+
const no = st.gate.parts.filter((x) => !x.ok);
|
|
197
|
+
const say = (no.length ? no : st.gate.parts).map((x) => x.text).join(' · ');
|
|
198
|
+
F.push({ k: st.gate.label || 'Gate', v: say.charAt(0).toUpperCase() + say.slice(1), warn: no.length > 0, read: true });
|
|
199
|
+
}
|
|
200
|
+
const tk = v.tasks || {}, docs = (o.docs || []).filter((x) => x.path).length;
|
|
201
|
+
const open = [tk.open ? plural(tk.open, 'task', 'tasks') : '', docs ? plural(docs, 'document', 'documents') : ''].filter(Boolean).join(' · ');
|
|
202
|
+
if (open) F.push({ k: 'Open', v: open, read: true });
|
|
203
|
+
return F;
|
|
204
|
+
}
|
|
205
|
+
/** The next open milestone task (◇), else null. */
|
|
206
|
+
function nextMilestone(v, t) {
|
|
207
|
+
const all = ((v.tasks || {}).sections || []).flatMap((s) => (s.top || []).concat(...(s.groups || []).map((g) => g.rows || [])));
|
|
208
|
+
const ms = all.filter((x) => x.ms && !x.closed && x.end).sort((a, b) => a.end.localeCompare(b.end))[0];
|
|
209
|
+
if (!ms) {
|
|
210
|
+
const g = (((v.stage || {}).gates || {}).open || [])[0];
|
|
211
|
+
return g ? { name: g.name, date: g.iso ? dateLate(g.iso, t).text : '', late: !!g.late, uid: g.id } : null;
|
|
212
|
+
}
|
|
213
|
+
const dl = dateLate(ms.end, t);
|
|
214
|
+
return { name: ms.title, date: dl.text, late: dl.late, uid: ms.uid };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* ── the work breakdown ── */
|
|
218
|
+
function taskRow(x, t) {
|
|
219
|
+
const dl = x.end ? dateLate(x.end, t, !x.closed) : { text: x.start ? 'from ' + dayText(x.start, t) : '', late: false };
|
|
220
|
+
return { kind: 'task', uid: x.uid, title: x.title, status: taskStatus(x), date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck };
|
|
221
|
+
}
|
|
222
|
+
export function breakdownOf(r, v, o = {}) {
|
|
223
|
+
const t = todayOf(o), list = ((v.stage || {}).ladder || []).map((s, i) => ({ name: s.name, status: s.cls, ms: !!s.ms, i }));
|
|
224
|
+
const secs = (v.tasks || {}).sections || [];
|
|
225
|
+
const ran = ranOf(r, secs.filter((s) => s.kind === 'stage').map((s) => ({ key: s.key, name: s.name, status: s.status })));
|
|
226
|
+
const open = o.open || new Set(), shut = o.shut || new Set(), dOpen = o.doneOpen || new Set();
|
|
227
|
+
const stages = secs.filter((s) => s.kind === 'stage');
|
|
228
|
+
const cur = stages.findIndex((s) => s.status === 'now');
|
|
229
|
+
const rows = [];
|
|
230
|
+
let many = false;
|
|
231
|
+
const stageRow = (s, i) => {
|
|
232
|
+
const ts = (s.top || []).concat(...(s.groups || []).map((g) => g.rows || []));
|
|
233
|
+
const all = ts.concat(s.done || []);
|
|
234
|
+
const nDone = (s.done || []).length, n = all.length;
|
|
235
|
+
const [ta, tb] = taskSpan(all);
|
|
236
|
+
const rn = ran[i] || {};
|
|
237
|
+
let a = '', b = '';
|
|
238
|
+
if (s.status === 'done') { a = isoOf(rn.from) || ta; b = isoOf(rn.to) || tb; }
|
|
239
|
+
else if (s.status === 'now') { const pv = ran.slice(0, i).reverse().find((q) => q.to || q.from) || {}; a = isoOf(rn.from) || isoOf(pv.to) || ta || isoOf(pv.from); b = isoOf(r.end) || tb; } // no recorded start: since the last date the record holds before it // the stage in progress runs to the plan end: late is said against the plan
|
|
240
|
+
else if (s.status !== 'skip') { a = ta; b = tb; }
|
|
241
|
+
const live = s.status === 'now' && r.status !== 'done' && !r.ended;
|
|
242
|
+
const dl = b && (s.status === 'now' || s.status === 'next') ? dateLate(b, t, live || ts.some((x) => !x.closed)) : { text: b && s.status === 'done' ? '' : '', late: false };
|
|
243
|
+
const isOpen = shut.has(s.key) ? false : open.has(s.key) ? true : s.status === 'now' || ts.some((x) => x.late);
|
|
244
|
+
const count = n ? (s.status === 'next' && !nDone ? plural(n, 'task', 'tasks') : nDone + ' of ' + n + ' done') : '';
|
|
245
|
+
rows.push({ kind: 'stage', key: s.key, n: s.n, name: s.name, ms: !!s.ms, status: STATUS[s.status] || '', count, date: dl.text, late: dl.late, start: a, end: b,
|
|
246
|
+
done: s.status === 'done', open: isOpen && n > 0, can: n > 0, now: s.status === 'now', skip: s.status === 'skip' });
|
|
247
|
+
if (!(isOpen && n > 0)) return;
|
|
248
|
+
const sorted = ts.slice().sort(urgent);
|
|
249
|
+
if (s.status === 'now' && sorted.length > MANY) many = true;
|
|
250
|
+
for (const x of sorted) rows.push({ ...taskRow(x, t), sec: s.key });
|
|
251
|
+
if (nDone) {
|
|
252
|
+
const dd = s.done.map((x) => x.end).filter(Boolean).sort();
|
|
253
|
+
rows.push({ kind: 'done', key: s.key, n: nDone, label: plural(nDone, 'task', 'tasks') + ' done', open: dOpen.has(s.key), start: (s.done.map((x) => x.start).filter(Boolean).sort()[0]) || dd[0] || '', end: dd[dd.length - 1] || '' });
|
|
254
|
+
if (dOpen.has(s.key)) for (const x of s.done) rows.push({ ...taskRow(x, t), sec: s.key });
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
// the stages after the next one fold into one row (board 20), unless the PM opened it
|
|
258
|
+
const farFrom = cur >= 0 ? cur + 2 : -1;
|
|
259
|
+
stages.forEach((s, i) => {
|
|
260
|
+
if (farFrom > 0 && i >= farFrom && stages.length - farFrom >= 2 && !o.farOpen) {
|
|
261
|
+
if (i === farFrom) {
|
|
262
|
+
const far = stages.slice(farFrom), n = far.reduce((k, x) => k + (x.top || []).length + (x.done || []).length + (x.groups || []).reduce((m, g) => m + g.n, 0), 0);
|
|
263
|
+
rows.push({ kind: 'far', n: s.n, name: far[0].name + ' to ' + far[far.length - 1].name, count: plural(far.length, 'stage', 'stages'), status: 'To do', tasks: n });
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
stageRow(s, i);
|
|
268
|
+
});
|
|
269
|
+
const loose = secs.find((s) => s.kind === 'none');
|
|
270
|
+
if (loose) {
|
|
271
|
+
const ts = (loose.top || []).concat(...(loose.groups || []).map((g) => g.rows || [])), isOpen = !shut.has('');
|
|
272
|
+
rows.push({ kind: 'stage', key: '', n: '', name: 'Not in a stage', status: '', count: plural(ts.length, 'open task', 'open tasks'), date: '', start: '', end: '', open: isOpen && ts.length > 0, can: ts.length > 0 });
|
|
273
|
+
if (isOpen) for (const x of ts.slice().sort(urgent)) rows.push({ ...taskRow(x, t), sec: '' });
|
|
274
|
+
}
|
|
275
|
+
return { rows, many, list };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* ── the artefacts ── */
|
|
279
|
+
const KIND_OF_ITEM = { doc: 'Document', link: 'Link', meeting: 'Meeting notes', proto: 'Prototype', design: 'Design' };
|
|
280
|
+
/** One table: the Library's rows when that route answers, else the core documents the page already reads; then the missing ones a gate needs. */
|
|
281
|
+
export function artefactsOf(v, o = {}) {
|
|
282
|
+
const t = todayOf(o), out = [], seen = new Set();
|
|
283
|
+
const key = (s) => norm(s).replace(/[^a-z0-9]+/g, ' ').trim();
|
|
284
|
+
for (const it of o.items || []) {
|
|
285
|
+
if (!it || !it.name || seen.has(key(it.name))) continue;
|
|
286
|
+
seen.add(key(it.name));
|
|
287
|
+
out.push({ id: it.id, title: it.name, kind: it.kindText || KIND_OF_ITEM[it.kind] || 'Document', when: it.updated ? dayText(it.updated, t) || it.updated : '', item: it, link: it.kind === 'link' });
|
|
288
|
+
}
|
|
289
|
+
for (const d of o.docs || []) {
|
|
290
|
+
if (!d || !d.title || seen.has(key(d.title))) continue;
|
|
291
|
+
if (d.path || d.link) {
|
|
292
|
+
seen.add(key(d.title));
|
|
293
|
+
const lk = d.link && d.link.url;
|
|
294
|
+
out.push({ id: d.key, title: d.title, kind: lk ? 'Link · ' + (d.link.kind || 'page') : d.kind === 'Slides' ? 'Slides' : 'Document', when: whenOf(d.when, t), path: d.path || '', url: lk || '', link: !!lk });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// what a gate needs and is not written: grey rows that say which gate (board 21)
|
|
298
|
+
const st = (v && v.stage) || {}, gate = st.gate, next = (st.next && st.next.name) || '';
|
|
299
|
+
const gateName = gate && gate.label ? gate.label.replace(/^Gate to /, '') : next;
|
|
300
|
+
if (gate && (gate.parts || []).some((x) => !x.ok)) {
|
|
301
|
+
for (const d of o.docs || []) {
|
|
302
|
+
if (!d || d.path || d.link || !d.core || seen.has(key(d.title))) continue;
|
|
303
|
+
if (!/\b(prd|rubric|done test|brief|spec)\b/i.test(d.title) && !gate.parts.some((x) => !x.ok && norm(x.text).includes(norm(d.title).split(' ')[0]))) continue;
|
|
304
|
+
seen.add(key(d.title));
|
|
305
|
+
out.push({ id: d.key, title: d.title, kind: 'Document', missing: 'Not written · needed for the gate to ' + (gateName || 'the next stage'), key: d.key, act: d.act || null });
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return out;
|
|
309
|
+
}
|
|
310
|
+
const whenOf = (w, t) => { const s = String(w || ''); return day(s) ? dayText(s, t) : s.replace(/^added\s+/, ''); };
|
|
311
|
+
|
|
312
|
+
/* ── one initiative ── */
|
|
313
|
+
export function workOf(r, v, o = {}) {
|
|
314
|
+
const t = todayOf(o);
|
|
315
|
+
const sum = summaryOf(r, v, o), sug = suggestsOf(v), bd = breakdownOf(r, v, o);
|
|
316
|
+
const dates = [r.start, r.end].concat(bd.rows.flatMap((x) => [x.start, x.end])).filter(Boolean);
|
|
317
|
+
const span = spanOf(dates, o.mode || 'full', t);
|
|
318
|
+
return { title: v.title || r.title || '', summary: sum, suggests: sug.top, more: sug.more, rowSuggests: sug.rows, facts: factsOf(r, v, o),
|
|
319
|
+
rows: bd.rows, many: bd.many, span, today: iso(t), artefacts: artefactsOf(v, o) };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/* ── one level up: a program or a product (boards 26, 27) ── */
|
|
323
|
+
/** L: { kind: 'program' | 'product', title, summary, facts: [{ k, v, warn?, note? }], rows: [{ id, kind, title, stage, start, end, done, sub? }],
|
|
324
|
+
* docs: [{ title, kind, when, path?, url? }], props? }. The rows one level down keep their own dates; a row with none has no bar. */
|
|
325
|
+
export function levelOf(L, o = {}) {
|
|
326
|
+
const t = todayOf(o);
|
|
327
|
+
const rows = (L.rows || []).map((x) => {
|
|
328
|
+
const dl = x.end ? dateLate(x.end, t, !x.done) : { text: '', late: false };
|
|
329
|
+
return { ...x, date: dl.text, late: dl.late };
|
|
330
|
+
});
|
|
331
|
+
const span = spanOf(rows.flatMap((x) => [x.start, x.end]).filter(Boolean), o.mode || 'full', t);
|
|
332
|
+
const late = rows.filter((x) => x.late).length;
|
|
333
|
+
return { kind: L.kind, title: L.title, summary: L.summary || '', facts: L.facts || [], rows, span, today: iso(t), late, artefacts: (L.docs || []).map((d) => ({ ...d, when: whenOf(d.when, t) })),
|
|
334
|
+
suggests: suggestsOf({ props: L.props || null }).top };
|
|
335
|
+
}
|