create-pmos 0.610.0 → 0.612.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 +135 -27
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.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 +7 -3
- 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-board-test.js +3 -2
- package/workspace/briefing-premium-calendar-2-test.js +3 -2
- package/workspace/briefing-premium-calendar-3-test.js +1 -1
- package/workspace/briefing-premium-calendar-test.js +1 -1
- package/workspace/briefing-premium-doc-edit-test.js +2 -1
- package/workspace/briefing-premium-insights-test.js +4 -3
- package/workspace/briefing-premium-test.js +3 -2
- package/workspace/calm-timeline-test.js +2 -1
- package/workspace/changelog.json +134 -0
- package/workspace/core-docs-workflow-test.js +2 -1
- package/workspace/ev-everywhere-test.js +3 -2
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +4 -0
- package/workspace/guide/layout.md +97 -3
- package/workspace/guide/programs.md +16 -2
- package/workspace/guide/routine.md +65 -0
- package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
- package/workspace/guide/settings-and-switches.md +2 -2
- package/workspace/impact-screens-test.js +3 -1
- package/workspace/ini-workflow-test.js +2 -1
- package/workspace/lib/board-premium.js +12 -4
- package/workspace/lib/classic-board.js +15 -0
- package/workspace/lib/cos-chat.js +1 -0
- package/workspace/lib/doc-library.js +43 -12
- package/workspace/lib/doc-path.js +30 -0
- package/workspace/lib/engine/boards.js +4 -2
- package/workspace/lib/events-place.js +368 -0
- package/workspace/lib/events-stated.js +129 -0
- package/workspace/lib/initiative-chat.js +1 -0
- package/workspace/lib/insights-premium.js +13 -1
- package/workspace/lib/library-find.js +162 -0
- package/workspace/lib/library-items.js +250 -0
- package/workspace/lib/notes.js +9 -1
- package/workspace/lib/plan-items.js +17 -3
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-artefacts.js +5 -2
- package/workspace/lib/routes-boards.js +6 -2
- package/workspace/lib/routes-doc-sheet.js +1 -0
- package/workspace/lib/routes-events-place.js +203 -0
- package/workspace/lib/routes-library.js +155 -0
- package/workspace/lib/routes-pop-work.js +39 -0
- package/workspace/lib/routes-report-setups.js +32 -1
- package/workspace/lib/routes-today-log.js +48 -0
- package/workspace/lib/routine-reports.js +84 -0
- package/workspace/lib/status-when.js +36 -0
- package/workspace/lib/task-items.js +5 -3
- package/workspace/lib/today-log.js +131 -0
- package/workspace/live-pill-round-test.js +10 -7
- 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 +2 -1
- package/workspace/premium-board-actions-test.js +3 -1
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-backlog-test.js +3 -1
- package/workspace/premium-vw-item-test.js +3 -1
- package/workspace/premium-vw-jira-test.js +3 -1
- package/workspace/premium-vw-meet-test.js +2 -1
- package/workspace/premium-vw-notes-test.js +3 -2
- package/workspace/product-lane-test.js +2 -1
- package/workspace/program-charter-test.js +3 -1
- package/workspace/program-leave-test.js +2 -1
- package/workspace/program-order-test.js +2 -1
- package/workspace/program-panel-test.js +3 -1
- package/workspace/public/pm/artefact-kind.js +87 -0
- package/workspace/public/pm/bd-ini-panel.js +77 -12
- package/workspace/public/pm/bd-prog-panel.js +55 -8
- package/workspace/public/pm/bd-span.js +5 -0
- package/workspace/public/pm/bd-work.css +192 -0
- package/workspace/public/pm/bd-work.js +483 -0
- package/workspace/public/pm/cozy-bar.css +11 -0
- package/workspace/public/pm/cozy-bar.js +99 -0
- package/workspace/public/pm/cozy-day-pick.css +27 -0
- package/workspace/public/pm/cozy-day-pick.js +97 -0
- package/workspace/public/pm/cozy-ev.css +2 -5
- package/workspace/public/pm/cozy-events-view.js +274 -0
- package/workspace/public/pm/cozy-events.css +179 -0
- package/workspace/public/pm/cozy-events.js +278 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-goals.css +172 -0
- package/workspace/public/pm/cozy-library.css +125 -0
- package/workspace/public/pm/cozy-live-pill.js +1 -0
- package/workspace/public/pm/cozy-nav.js +6 -7
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pop-work.css +224 -0
- package/workspace/public/pm/cozy-pop-work.js +668 -0
- package/workspace/public/pm/cozy-popup.css +11 -2
- package/workspace/public/pm/cozy-popup.js +67 -9
- package/workspace/public/pm/cozy-routine-job.js +203 -0
- package/workspace/public/pm/cozy-routine-model.js +219 -0
- package/workspace/public/pm/cozy-routine-pop.js +318 -0
- package/workspace/public/pm/cozy-routine.css +155 -0
- package/workspace/public/pm/cozy-routine.js +335 -0
- package/workspace/public/pm/cozy-schedwork.js +6 -5
- package/workspace/public/pm/cozy-settings.js +1 -5
- package/workspace/public/pm/cozy-status-when.js +48 -0
- 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 +19 -8
- package/workspace/public/pm/cozy-vw-mtg.css +39 -0
- package/workspace/public/pm/goals-model.js +205 -0
- package/workspace/public/pm/goals-open.js +124 -0
- package/workspace/public/pm/home-app.js +18 -3
- package/workspace/public/pm/home-chat.js +4 -2
- package/workspace/public/pm/home-ini.js +43 -10
- package/workspace/public/pm/ini-edit.js +3 -1
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/library-model.js +197 -0
- package/workspace/public/pm/library-open.js +37 -0
- package/workspace/public/pm/page-chat.js +12 -2
- package/workspace/public/pm/pop-work-model.js +493 -0
- package/workspace/public/pm/premium-board.js +204 -17
- package/workspace/public/pm/premium-goals.js +213 -0
- package/workspace/public/pm/premium-library.js +436 -0
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +79 -1
- package/workspace/public/pm/scope-chip.js +204 -0
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-events.html +44 -0
- package/workspace/public/premium-goals.html +37 -0
- package/workspace/public/premium-library.html +39 -0
- package/workspace/public/premium-routine.html +33 -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 +4 -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 +3 -1
- package/workspace/stage-card-test.js +2 -1
- package/workspace/task-delete-test.js +2 -1
- package/workspace/task-links-test.js +2 -1
- 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 +3 -1
- package/workspace/test-lists/doc-path.json +9 -0
- package/workspace/test-lists/events-place.json +11 -0
- package/workspace/test-lists/goals-place.json +9 -0
- package/workspace/test-lists/library-place.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/status-when.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 +2 -1
|
@@ -62,12 +62,38 @@ const git = (cwd, args) => execFileSync('git', args, { cwd, encoding: 'utf8', ma
|
|
|
62
62
|
/** path → YYYY-MM-DD of its last commit (one git log; merge commits are skipped, their changes are in their parents). */
|
|
63
63
|
function commitDates(root) {
|
|
64
64
|
const out = new Map();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
for (const [p, c] of commitInfo(root)) out.set(p, c.day);
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Who wrote a commit, for the Library's By column: 'PMOS' when an agent wrote it (the author or a Co-Authored-By trailer is an agent or a
|
|
70
|
+
* bot), 'You' when the author is the repository's own git user, null for a squash merge of a pull request with no agent trailer (the
|
|
71
|
+
* merger is not the writer), else the author's name. PURE. */
|
|
72
|
+
const AGENT_RE = /noreply@anthropic\.com|claude\.ai\/code|\bclaude\b|\bpmos\b|\[bot\]|github-actions|dependabot|copilot|codex/i;
|
|
73
|
+
function byOf({ name = '', email = '', co = '', subject = '' } = {}, me = '') {
|
|
74
|
+
if (AGENT_RE.test(name) || AGENT_RE.test(email) || AGENT_RE.test(co)) return 'PMOS';
|
|
75
|
+
// a squash merge of a pull request ("… (#1362)") names who merged it, not who wrote the file: By cannot be told
|
|
76
|
+
if (/\(#\d+\)\s*$/.test(subject)) return null;
|
|
77
|
+
if (me && email && email.toLowerCase() === String(me).toLowerCase()) return 'You';
|
|
78
|
+
return String(name || '').trim() || null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** path → { day, by } of its last commit (one git log). */
|
|
82
|
+
function commitInfo(root) {
|
|
83
|
+
const out = new Map();
|
|
84
|
+
let text = '', me = '';
|
|
85
|
+
try { me = git(root, ['config', 'user.email']).trim(); } catch { me = ''; }
|
|
86
|
+
try { text = git(root, ['log', '--format=%x01%cs%x02%an%x02%ae%x02%s%x02%(trailers:key=Co-Authored-By,key=Claude-Session,valueonly,separator=%x03)%x04', '--name-only', '--', '*.md']); } catch { return out; }
|
|
87
|
+
let cur = null;
|
|
88
|
+
for (const raw of text.split('\n')) {
|
|
89
|
+
const line = raw.trim();
|
|
90
|
+
if (raw.startsWith('\x01')) {
|
|
91
|
+
const [day, name, email, subject, rest] = raw.slice(1).split('\x02');
|
|
92
|
+
const co = String(rest || '').split('\x04')[0];
|
|
93
|
+
cur = { day, by: byOf({ name, email, co, subject }, me) };
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (line && cur && !line.includes('\x04') && !out.has(line)) out.set(line, cur);
|
|
71
97
|
}
|
|
72
98
|
return out;
|
|
73
99
|
}
|
|
@@ -86,7 +112,7 @@ const cache = new Map(); // root -> { key, value }
|
|
|
86
112
|
* The library of one repository.
|
|
87
113
|
* owners: () => Map path → { id, title } — the library's own attribution (server.js initiativeIndex), real initiatives
|
|
88
114
|
* only. It is called only when the repository state changed, because the index reads every planning file.
|
|
89
|
-
* Returns { ok, files: [{path,title,category,date,initiative}], initiatives: {id: {title, short}}, kinds, edges: [[from, to, kind]], categories }.
|
|
115
|
+
* Returns { ok, files: [{path,title,category,date,initiative,status,type,by}], initiatives: {id: {title, short}}, kinds, edges: [[from, to, kind]], categories }.
|
|
90
116
|
* `from` and `to` index `files`; `kind` indexes `kinds`.
|
|
91
117
|
*/
|
|
92
118
|
function library(root, { stateDir, owners = () => new Map() } = {}) {
|
|
@@ -97,12 +123,16 @@ function library(root, { stateDir, owners = () => new Map() } = {}) {
|
|
|
97
123
|
const { graph, unreadable } = kgCli.graphFor(root, stateDir ? { stateDir } : {});
|
|
98
124
|
let own = new Map();
|
|
99
125
|
try { own = owners() || new Map(); } catch { /* no attribution: every file has no initiative */ }
|
|
100
|
-
const
|
|
126
|
+
const info = commitInfo(root);
|
|
101
127
|
const dirty = dirtyPaths(root);
|
|
102
128
|
const dayOf = (rel) => {
|
|
103
|
-
if (!dirty.has(rel) &&
|
|
104
|
-
try { return fs.statSync(path.join(root, rel)).mtime.toISOString().slice(0, 10); } catch { return
|
|
129
|
+
if (!dirty.has(rel) && info.has(rel)) return info.get(rel).day;
|
|
130
|
+
try { return fs.statSync(path.join(root, rel)).mtime.toISOString().slice(0, 10); } catch { return info.has(rel) ? info.get(rel).day : null; }
|
|
105
131
|
};
|
|
132
|
+
// an uncommitted change is the PM's own, until it is committed
|
|
133
|
+
// the file's own frontmatter (author, by, owner) names who wrote it first; then the last commit
|
|
134
|
+
const writer = (n) => { const m = /(?:^|\s)(?:author|by|owner):\s*"?([^"\n]{2,60}?)"?(?=\s+[a-z_]+:|\s*---|$)/i.exec(String(n.card || '')); return m ? m[1].trim() : null; };
|
|
135
|
+
const byOfPath = (rel, n) => writer(n) || (dirty.has(rel) || !info.has(rel) ? 'You' : info.get(rel).by);
|
|
106
136
|
// An initiative is named by its record's title (planning/initiatives/<id>.md), else by the index's title for it.
|
|
107
137
|
const titleOf = new Map(graph.nodes.map((n) => [n.id, n.title]));
|
|
108
138
|
const named = (o) => String(titleOf.get(`planning/initiatives/${o.id}.md`) || o.title || o.id);
|
|
@@ -110,7 +140,8 @@ function library(root, { stateDir, owners = () => new Map() } = {}) {
|
|
|
110
140
|
const files = graph.nodes.map((n) => {
|
|
111
141
|
const o = own.get(n.id) || null;
|
|
112
142
|
if (o && !initiatives[o.id]) initiatives[o.id] = { title: named(o), short: shortTitle(named(o)) };
|
|
113
|
-
return { path: n.id, title: String(n.title || n.id), category: categoryOf(n.id, n.type), date: dayOf(n.id), initiative: o ? o.id : null
|
|
143
|
+
return { path: n.id, title: String(n.title || n.id), category: categoryOf(n.id, n.type), date: dayOf(n.id), initiative: o ? o.id : null, status: n.status ? String(n.status) : null,
|
|
144
|
+
type: n.type ? String(n.type) : null, by: byOfPath(n.id, n) };
|
|
114
145
|
});
|
|
115
146
|
const index = new Map(files.map((f, i) => [f.path, i]));
|
|
116
147
|
const seen = new Set();
|
|
@@ -128,4 +159,4 @@ function library(root, { stateDir, owners = () => new Map() } = {}) {
|
|
|
128
159
|
return value;
|
|
129
160
|
}
|
|
130
161
|
|
|
131
|
-
module.exports = { CATEGORIES, KINDS, categoryOf, shortTitle, kindOf, library, commitDates };
|
|
162
|
+
module.exports = { CATEGORIES, KINDS, categoryOf, shortTitle, kindOf, library, commitDates, commitInfo, byOf };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* doc-path.js — one way to find a document a record names (popup round 3 point 17: "pmos/planning/prd/smrt-news-feed-prd.md could not be
|
|
3
|
+
* read").
|
|
4
|
+
*
|
|
5
|
+
* candidates(rel) → the paths to try, in order: as given; then, in a kit repository, the same path with its leading "pmos/" taken
|
|
6
|
+
* off or put on (a record written from the repository root says "pmos/planning/…", one written from the kit
|
|
7
|
+
* folder says "planning/…"); a doubled "pmos/pmos/" once only. Never a path that leaves the root (the callers
|
|
8
|
+
* still guard every read with their own root check).
|
|
9
|
+
* resolve(root, rel, exists?) → the first candidate that exists under root, else rel unchanged (the caller's read then says why it failed)
|
|
10
|
+
*
|
|
11
|
+
* Pure but for exists (fs.existsSync by default). Used by GET /api/doc (server.js readTextDocWhy) and the document page's reads
|
|
12
|
+
* (lib/routes-doc-sheet.js resolveDoc), so both find the same file. */
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
|
|
16
|
+
function candidates(rel) {
|
|
17
|
+
const r = String(rel == null ? '' : rel).trim().replace(/\\/g, '/').replace(/^\.\//, '');
|
|
18
|
+
if (!r) return [];
|
|
19
|
+
const out = [r];
|
|
20
|
+
const once = r.replace(/^(pmos\/)+/, 'pmos/');
|
|
21
|
+
if (once !== r) out.push(once);
|
|
22
|
+
if (/^pmos\//.test(once)) out.push(once.slice(5)); else out.push('pmos/' + r);
|
|
23
|
+
return [...new Set(out)];
|
|
24
|
+
}
|
|
25
|
+
function resolve(root, rel, exists = (p) => { try { return fs.statSync(p).isFile(); } catch { return false; } }) {
|
|
26
|
+
if (!root) return rel;
|
|
27
|
+
for (const c of candidates(rel)) if (exists(path.resolve(root, c))) return c;
|
|
28
|
+
return rel;
|
|
29
|
+
}
|
|
30
|
+
module.exports = { candidates, resolve };
|
|
@@ -301,7 +301,9 @@ function fold(events) {
|
|
|
301
301
|
if (typeof e.title === 'string' && e.title.trim()) t.title = e.title.trim(); // a rename (canvas RnATask)
|
|
302
302
|
if (typeof e.owner === 'string') t.owner = e.owner.trim() || null; // the Viewer's edits (canvas XetX1Rest); '' clears
|
|
303
303
|
if (typeof e.notes === 'string') t.notes = e.notes;
|
|
304
|
-
|
|
304
|
+
// happened: the day a status move really happened, apart from `at`, when it was recorded (popup round 3 point 18)
|
|
305
|
+
t.history.push({ at: e.at || null, by: e.by || null, state: e.state || null, start: e.start || null, due: e.due || null, why: e.why || '', ...(typeof e.happened === 'string' ? { happened: e.happened } : {}) });
|
|
306
|
+
if (taskState(e.state)) t.since = typeof e.happened === 'string' ? e.happened : String(e.at || '').slice(0, 10) || null;
|
|
305
307
|
} else if (e.kind === 'task-section' && typeof e.task === 'string' && e.task && typeof e.section === 'string') {
|
|
306
308
|
sections.set(e.task, e.section);
|
|
307
309
|
} else if (e.kind === 'task-milestone' && typeof e.task === 'string' && e.task && typeof e.milestone === 'boolean') {
|
|
@@ -414,7 +416,7 @@ function itemStatus(status, category) {
|
|
|
414
416
|
/** A PMOS task as a work item. */
|
|
415
417
|
function taskItem(t) {
|
|
416
418
|
return { uid: t.id, key: '', kind: t.kind === 'Epic' ? 'Epic' : 'Task', src: 'pmos', title: t.title, status: t.state, blocked: false, owner: t.owner || null, notes: t.notes || '',
|
|
417
|
-
ini: t.initiative, epic: t.epic || null, start: t.start || null, end: t.due || null, ref: t.id, board: t.board, ...(t.from ? { from: { ...t.from } } : {}) };
|
|
419
|
+
ini: t.initiative, epic: t.epic || null, start: t.start || null, end: t.due || null, ref: t.id, board: t.board, ...(t.since ? { since: t.since } : {}), ...(t.from ? { from: { ...t.from } } : {}) };
|
|
418
420
|
}
|
|
419
421
|
/** Progress per item, and an epic's status, progress, blocked flag and dates rolled up from its items. Mutates and returns items. */
|
|
420
422
|
function rollupItems(items) {
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/events-place.js — Events, the place for everything with a date (slice 6 of the six-place navigation, initiative events-place; board 2,
|
|
3
|
+
* StEvPlan, on Exploring 2, page "Navigation: Today, Work, Goals, Events, Library, Routine").
|
|
4
|
+
*
|
|
5
|
+
* build(input) → { today, items, later } PURE. No I/O and no clock: `today` comes in as 'YYYY-MM-DD'.
|
|
6
|
+
* shortDay(day, today) · daysBetween(a, b) · KINDS · DROP_DAYS · WINDOW_DAYS · MEET_DAYS
|
|
7
|
+
*
|
|
8
|
+
* INPUT (plain data that lib/routes-events-place.js reads from the routes and files that already exist):
|
|
9
|
+
* boards [{ ws, id, name, rows }] every product's Board model (lib/board-premium.js): the open rows, each with `milestones` (◇ tasks with a
|
|
10
|
+
* due day, PMOS and Jira), `tasks` (the PMOS tasks), `end` (the plan end), `stage`, `status`, `forecast`
|
|
11
|
+
* meetings [{ id, at, end, title, initiative }] lib/calendar-events.js readAll
|
|
12
|
+
* schedules [{ id, name, cadence, next }] the enabled report schedules, with the day each fires next ('YYYY-MM-DD')
|
|
13
|
+
* drafts [{ ws, cadence, slot, title? }] report drafts that wait to be issued (lib/report-needs.js reportsOf: a draft, not issued)
|
|
14
|
+
* own [{ id, title, due, done }] the PM's own items (lib/pm-items.js)
|
|
15
|
+
* jira [{ key, title, url, due, category, initiative }] the Jira tickets assigned to the PM (<runtime>/my-work/read.json), with a due day
|
|
16
|
+
* stated [{ key, source, from, who, said, date, title, text, link, initiative, line }] the dates people state in the sources
|
|
17
|
+
* (lib/events-stated.js: an ask with a deadline in Slack or mail, a date decided in meeting notes)
|
|
18
|
+
* programs [{ id, title, owner, members: [{ ws, initiative }], milestones: [{ id, name, date, done }] }] lib/routes-programs.js all
|
|
19
|
+
* marks { fixed: Set<key>, declined: Set<sig> } the PM's fixed dates and the suggestions they said no to (lib/routes-events-place.js)
|
|
20
|
+
*
|
|
21
|
+
* AN ITEM: { key, kind, type, date, time, until, title, line, product, work, task, own, jira, source, scope, fixed, canFix, editable, tone, days,
|
|
22
|
+
* group, suggest, act }
|
|
23
|
+
* kind milestone (a ◇ task, a program milestone, or the plan end of an initiative that has no open milestone) · task · report · meeting
|
|
24
|
+
* · deadline (a date stated in a source)
|
|
25
|
+
* type the one word the row starts its grey line with (TYPE_WORD), and the filter of the key: meeting · focus · milestone · task · report
|
|
26
|
+
* · deadline. Focus time is a calendar event whose title says so (FOCUS); PMOS keeps no focus time of its own.
|
|
27
|
+
* line the rest of the grey line, after the type word: "Deliver · Tender new CIAM", "Plan end · pmos-cas", "From Slack · Ang, 18 Nov"
|
|
28
|
+
* scope the filter tokens the item is under: 'p:<ws>' (its product, as the saved product pick names it), 'g:<program id>' (each program that holds its work),
|
|
29
|
+
* 'j:<ws>|<initiative>' (its project). A meeting with no work is under the product its title names, else under none: it then
|
|
30
|
+
* shows only when no product, program or project is picked.
|
|
31
|
+
* group late (before today, not done) · today · coming (the next WINDOW_DAYS days; a meeting the next MEET_DAYS) · later
|
|
32
|
+
* tone late · risk (a milestone of an initiative at risk, or whose Jira forecast says it will miss) · ''
|
|
33
|
+
* suggest { op: done | move | drop | met | gone | ask, to?, with?, ask?, text, why, sig } or null. What PMOS suggests; the PM says yes (✓)
|
|
34
|
+
* or no (✕). met and gone are kept by Events (the date is met, or dropped: Events stops listing it); ask adds a task for the PM.
|
|
35
|
+
*
|
|
36
|
+
* THE RULES OF A SUGGESTION. A suggestion is made only from a record; PMOS does not invent a date.
|
|
37
|
+
* done a late PMOS item whose stage is behind the stage its initiative is in now: "It looks done. Mark it done".
|
|
38
|
+
* drop a late task, not a milestone, DROP_DAYS days late or more: "Drop it".
|
|
39
|
+
* move a late PMOS item: to the day the Jira forecast gives (a milestone), else to the plan end when that is later than today.
|
|
40
|
+
* A milestone whose stage has a task that moves later moves with it: "Moves with <task>, to <day>".
|
|
41
|
+
* Coming up: only a milestone at risk, to the day the Jira forecast gives.
|
|
42
|
+
* A Jira item and a plan end: no route here writes them, so what PMOS suggests is kept by Events or is a task for the PM:
|
|
43
|
+
* met late, and its initiative is in a stage after Deliver: "It looks done. Mark it done". Events stops listing it.
|
|
44
|
+
* gone late OLD_DAYS days or more: "Drop this date". Events stops listing it.
|
|
45
|
+
* ask any other late one: "Ask the owner for a new date". Coming up and at risk: "Ask the owner if <day> holds". ✓ adds the ask as the
|
|
46
|
+
* PM's own task, due today.
|
|
47
|
+
* EVERY LATE AND AT-RISK ROW HAS ONE (round 2, point 5). What the rules above leave empty:
|
|
48
|
+
* a late PMOS task or your own item: "Move to today" (nothing names a later day); when it is fixed, "It is fixed. Mark it done".
|
|
49
|
+
* a late PMOS milestone (fixed, or no later plan end): as a date PMOS cannot write (met, gone, ask).
|
|
50
|
+
* a late Jira ticket of yours: "Set a new date in Jira", a task for you; 90 days late, "Drop this date".
|
|
51
|
+
* a late stated date: "Ask <who> where it stands", a task for you; DROP_DAYS late, "Drop this date".
|
|
52
|
+
* a coming date at risk with no later forecast: "Ask the owner if <day> holds".
|
|
53
|
+
* never a fixed date is never offered a new date (done, drop and ask still are). A suggestion the PM said no to (its sig is in
|
|
54
|
+
* marks.declined) does not come back. A date the PM marked met or gone (marks.gone) is not listed. */
|
|
55
|
+
const BP = require('./board-premium.js');
|
|
56
|
+
|
|
57
|
+
const KINDS = Object.freeze(['milestone', 'task', 'report', 'meeting', 'deadline']);
|
|
58
|
+
const TYPES = Object.freeze(['meeting', 'focus', 'milestone', 'task', 'report', 'deadline']);
|
|
59
|
+
const TYPE_WORD = Object.freeze({ meeting: 'Meeting', focus: 'Focus time', milestone: 'Milestone', task: 'Task', report: 'Report', deadline: 'Deadline' });
|
|
60
|
+
const FOCUS = /\b(focus(\s+time)?|deep\s+work|heads?[- ]down|no[- ]meetings?)\b/i;
|
|
61
|
+
const DROP_DAYS = 28;
|
|
62
|
+
const OLD_DAYS = 90;
|
|
63
|
+
const WINDOW_DAYS = 30;
|
|
64
|
+
const MEET_DAYS = 7;
|
|
65
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
66
|
+
const CLOSED = /^(done|won't do|archived|cancelled)$/i;
|
|
67
|
+
const MINE = /^(pm|me|you)$/i;
|
|
68
|
+
|
|
69
|
+
const isDay = (s) => typeof s === 'string' && /^\d{4}-\d{2}-\d{2}/.test(s) && !Number.isNaN(Date.parse(s.slice(0, 10) + 'T00:00:00Z'));
|
|
70
|
+
const day10 = (s) => String(s).slice(0, 10);
|
|
71
|
+
const ms = (d) => Date.parse(day10(d) + 'T00:00:00Z');
|
|
72
|
+
/** Days from a to b (b later: positive). */
|
|
73
|
+
const daysBetween = (a, b) => Math.round((ms(b) - ms(a)) / 86400000);
|
|
74
|
+
/** '25 Nov', or '3 Mar 2027' outside the year of today. */
|
|
75
|
+
function shortDay(d, today) {
|
|
76
|
+
if (!isDay(d)) return '';
|
|
77
|
+
const [y, m, dd] = day10(d).split('-').map(Number);
|
|
78
|
+
return dd + ' ' + MON[m - 1] + (today && String(y) !== String(today).slice(0, 4) ? ' ' + y : '');
|
|
79
|
+
}
|
|
80
|
+
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
81
|
+
const cap = (s) => String(s || '').replace(/[-_]+/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
82
|
+
|
|
83
|
+
/** The name of a stage key or name, from the row's own workflow when it has one. */
|
|
84
|
+
function stageName(r, sec) {
|
|
85
|
+
if (!sec) return '';
|
|
86
|
+
const own = (r.wfStages || []).find((s) => s && (s.key === sec || s.name === sec));
|
|
87
|
+
if (own && own.name) return own.name;
|
|
88
|
+
const k = BP.stepIndex(sec);
|
|
89
|
+
return k >= 0 ? BP.STEPS[k].label : cap(sec);
|
|
90
|
+
}
|
|
91
|
+
/** Is the stage `sec` behind the stage the initiative is in now? Only when both are known. */
|
|
92
|
+
function stagePast(r, sec) {
|
|
93
|
+
if (!sec || !r.stage) return false;
|
|
94
|
+
const own = (r.wfStages || []).map((s) => s && s.key);
|
|
95
|
+
const ownNames = (r.wfStages || []).map((s) => s && s.name);
|
|
96
|
+
const i = own.indexOf(sec) >= 0 ? own.indexOf(sec) : ownNames.indexOf(sec);
|
|
97
|
+
const j = own.indexOf(r.stage) >= 0 ? own.indexOf(r.stage) : ownNames.indexOf(r.stage);
|
|
98
|
+
if (i >= 0 && j >= 0) return i < j;
|
|
99
|
+
const a = BP.stepIndex(sec), b = BP.stepIndex(r.stage, r.cat);
|
|
100
|
+
return a >= 0 && b >= 0 && a < b;
|
|
101
|
+
}
|
|
102
|
+
const atRisk = (r) => r.status === 'at risk' || r.status === 'late' || !!(r.forecast && (r.forecast.state === 'at-risk' || r.forecast.state === 'will-miss'));
|
|
103
|
+
|
|
104
|
+
function groupOf(kind, date, today) {
|
|
105
|
+
const d = daysBetween(today, date);
|
|
106
|
+
if (d < 0) return 'late';
|
|
107
|
+
if (d === 0) return 'today';
|
|
108
|
+
return d <= (kind === 'meeting' ? MEET_DAYS : WINDOW_DAYS) ? 'coming' : 'later';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const norm = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
|
|
112
|
+
/** Does `text` hold `phrase` as whole words? */
|
|
113
|
+
const hasWords = (text, phrase) => { const p = norm(phrase); return p.length >= 3 && (' ' + norm(text) + ' ').includes(' ' + p + ' '); };
|
|
114
|
+
|
|
115
|
+
function build(input = {}) {
|
|
116
|
+
const today = isDay(input.today) ? day10(input.today) : null;
|
|
117
|
+
if (!today) return { today: null, items: [], later: { count: 0, next: null }, filters: { products: [], programs: [], projects: [] } };
|
|
118
|
+
const marks = input.marks || {};
|
|
119
|
+
const fixedSet = marks.fixed instanceof Set ? marks.fixed : new Set(marks.fixed || []);
|
|
120
|
+
const declined = marks.declined instanceof Set ? marks.declined : new Set(marks.declined || []);
|
|
121
|
+
const gone = marks.gone instanceof Map ? marks.gone : new Map(Object.entries(marks.gone || {}));
|
|
122
|
+
const items = [];
|
|
123
|
+
const put = (x) => {
|
|
124
|
+
if (!isDay(x.date) || gone.has(x.key)) return;
|
|
125
|
+
x.date = day10(x.date);
|
|
126
|
+
x.days = daysBetween(today, x.date);
|
|
127
|
+
x.group = groupOf(x.kind, x.date, today);
|
|
128
|
+
if (x.kind === 'meeting' && x.group === 'late') return; // a meeting that has passed is not late
|
|
129
|
+
if (x.kind === 'report' && x.group === 'late' && !x.draft) return;
|
|
130
|
+
x.type = x.type || x.kind;
|
|
131
|
+
x.fixed = !!(x.canFix && fixedSet.has(x.key));
|
|
132
|
+
x.tone = x.group === 'late' ? 'late' : x.tone || '';
|
|
133
|
+
x.source = x.source || null;
|
|
134
|
+
items.push(x);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// the products, and the work each initiative is (for a meeting, a Jira ticket or a stated date that names only an id)
|
|
138
|
+
const products = [];
|
|
139
|
+
const workOf = new Map(); // initiative id → { work, product, pkey, row }
|
|
140
|
+
for (const b of input.boards || []) {
|
|
141
|
+
const pkey = b.ws || '';
|
|
142
|
+
if (!products.some((p) => p.id === 'p:' + pkey)) products.push({ id: 'p:' + pkey, name: clip(b.name || b.ws || '', 80) });
|
|
143
|
+
for (const r of b.rows || []) if (r && r.id && !workOf.has(r.id)) workOf.set(r.id, { work: { id: r.id, title: clip(r.title || r.id, 140), ws: b.ws || '', board: b.id || '' }, product: clip(b.name || b.ws || '', 80), pkey, row: r });
|
|
144
|
+
}
|
|
145
|
+
const scopeOf = (pkey, work) => [pkey ? 'p:' + pkey : null, work && work.ws != null && work.id ? 'j:' + work.ws + '|' + work.id : null].filter(Boolean);
|
|
146
|
+
|
|
147
|
+
for (const b of input.boards || []) {
|
|
148
|
+
const product = clip(b.name || b.ws || '', 80);
|
|
149
|
+
const pkey = b.ws || '';
|
|
150
|
+
for (const r of b.rows || []) {
|
|
151
|
+
if (!r || !r.id || r.closed || r.status === 'done' || r.status === 'cancelled' || r.status === 'on hold') continue;
|
|
152
|
+
const work = { id: r.id, title: clip(r.title || r.id, 140), ws: b.ws || '', board: b.id || '' };
|
|
153
|
+
const scope = scopeOf(pkey, work);
|
|
154
|
+
const risk = atRisk(r);
|
|
155
|
+
const open = (r.milestones || []).filter((m) => m && !m.done && isDay(m.date));
|
|
156
|
+
for (const m of open) {
|
|
157
|
+
const st = stageName(r, m.sec);
|
|
158
|
+
put({ key: 'ms:' + work.ws + '|' + work.board + '|' + m.id, kind: 'milestone', date: m.date, time: null, until: null, title: clip(m.name, 140),
|
|
159
|
+
line: (st ? st + ' · ' : '') + work.title, product, work, task: m.jira ? null : { uid: m.id, ws: work.ws, board: work.board },
|
|
160
|
+
own: null, jira: !!m.jira, jiraKey: m.jira ? String(m.id) : null, canFix: true, editable: !m.jira, tone: risk ? 'risk' : '', sec: m.sec || '', row: r, scope, act: null });
|
|
161
|
+
}
|
|
162
|
+
// the plan end stands for the delivery when the initiative names no open milestone (as Work's "Plan end")
|
|
163
|
+
if (!open.length && isDay(r.end)) {
|
|
164
|
+
put({ key: 'end:' + work.ws + '|' + work.board + '|' + r.id, kind: 'milestone', date: r.end, time: null, until: null, title: work.title,
|
|
165
|
+
line: 'Planned finish · ' + product, product, work, task: null, own: null, jira: false, canFix: true, editable: false, planEnd: true,
|
|
166
|
+
tone: risk ? 'risk' : '', sec: '', row: r, scope, act: null });
|
|
167
|
+
}
|
|
168
|
+
for (const t of r.tasks || []) {
|
|
169
|
+
if (!t || !t.uid || t.milestone || CLOSED.test(String(t.status || '')) || !isDay(t.end)) continue;
|
|
170
|
+
if (t.owner && !MINE.test(String(t.owner).trim())) continue; // the PM's tasks: no owner, or the PM
|
|
171
|
+
const sec = typeof t.section === 'string' && t.section ? t.section : t.from && t.from.stage ? t.from.stage : '';
|
|
172
|
+
put({ key: 'task:' + work.ws + '|' + work.board + '|' + t.uid, kind: 'task', date: t.end, time: null, until: null, title: clip(t.title, 140),
|
|
173
|
+
line: work.title, product, work, task: { uid: t.uid, ws: work.ws, board: work.board, status: t.status || 'To do' }, own: null, jira: false,
|
|
174
|
+
canFix: true, editable: true, sec, row: r, scope, act: null });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// the Jira tickets assigned to the PM with a due day; one the Board already shows as a ◇ milestone is not said twice
|
|
180
|
+
const shown = new Set(items.filter((x) => x.jiraKey).map((x) => x.jiraKey.toUpperCase()));
|
|
181
|
+
for (const j of input.jira || []) {
|
|
182
|
+
if (!j || !j.key || !j.title || j.category === 'done' || !isDay(j.due) || shown.has(String(j.key).toUpperCase())) continue;
|
|
183
|
+
const w = j.initiative ? workOf.get(j.initiative) : null;
|
|
184
|
+
put({ key: 'jira:' + j.key, kind: 'task', date: j.due, time: null, until: null, title: clip(j.title, 140), line: 'Jira ' + j.key + (w ? ' · ' + w.work.title : ''),
|
|
185
|
+
product: w ? w.product : '', work: w ? { ...w.work } : null, task: null, own: null, jira: true, jiraTicket: true, link: j.url || null, canFix: true, editable: false,
|
|
186
|
+
sec: '', row: w ? w.row : null, scope: w ? scopeOf(w.pkey, w.work) : [], act: null });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
for (const o of input.own || []) {
|
|
190
|
+
if (!o || !o.id || o.done || !isDay(o.due)) continue;
|
|
191
|
+
put({ key: 'own:' + o.id, kind: 'task', date: o.due, time: null, until: null, title: clip(o.title, 140), line: 'Yours', product: '', work: null, task: null,
|
|
192
|
+
own: String(o.id), jira: false, canFix: true, editable: true, sec: '', row: null, scope: [], act: null });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// the program milestones: a date on a program's charter (a program check, or a milestone that waits on its initiatives)
|
|
196
|
+
const progOf = new Map(); // 'ws|initiative' → [program id]
|
|
197
|
+
const programs = [];
|
|
198
|
+
for (const p of input.programs || []) {
|
|
199
|
+
if (!p || !p.id || p.archived) continue;
|
|
200
|
+
programs.push({ id: 'g:' + p.id, name: clip(p.title || p.id, 80) });
|
|
201
|
+
for (const m of p.members || []) if (m && m.initiative) { const k = (m.ws || '') + '|' + m.initiative; if (!progOf.has(k)) progOf.set(k, []); progOf.get(k).push('g:' + p.id); }
|
|
202
|
+
for (const m of p.milestones || []) {
|
|
203
|
+
if (!m || m.done || !isDay(m.date) || !m.name) continue;
|
|
204
|
+
put({ key: 'pg:' + p.id + '|' + (m.id || m.name), kind: 'milestone', date: m.date, time: null, until: null, title: clip(m.name, 140), line: 'Program · ' + clip(p.title || p.id, 80),
|
|
205
|
+
product: '', work: null, task: null, own: null, jira: false, canFix: true, editable: false, programMs: true, owner: p.owner || '',
|
|
206
|
+
tone: m.risk ? 'risk' : '', sec: '', row: { owner: p.owner || '' }, scope: ['g:' + p.id], act: null });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const draftOf = new Map();
|
|
211
|
+
for (const d of input.drafts || []) if (d && d.cadence && !draftOf.has(d.cadence)) draftOf.set(d.cadence, d);
|
|
212
|
+
// a draft whose report goes out today is said on that report's row, not on a row of its own
|
|
213
|
+
const outToday = new Set((input.schedules || []).filter((s) => s && isDay(s.next) && day10(s.next) === today).map((s) => s.cadence));
|
|
214
|
+
for (const d of draftOf.values()) {
|
|
215
|
+
if (outToday.has(d.cadence)) continue;
|
|
216
|
+
put({ key: 'draft:' + (d.ws || '') + '|' + d.cadence + '|' + (d.slot || ''), kind: 'report', date: today, time: null, until: null, title: clip(d.title || cap(d.cadence) + ' report', 120),
|
|
217
|
+
line: 'The draft' + (isDay(d.slot) && day10(d.slot) !== today ? ' of ' + shortDay(d.slot, today) : '') + ' waits for you to issue it', product: '', work: null, task: null, own: null, jira: false, canFix: false, editable: false, draft: true,
|
|
218
|
+
scope: d.ws ? ['p:' + d.ws] : [], act: { label: 'Read the draft', href: '/premium-intelligence.html?tab=library' } });
|
|
219
|
+
}
|
|
220
|
+
for (const s of input.schedules || []) {
|
|
221
|
+
if (!s || !isDay(s.next)) continue;
|
|
222
|
+
const name = clip(s.name || cap(s.cadence) + ' report', 120);
|
|
223
|
+
const d = draftOf.get(s.cadence);
|
|
224
|
+
const waits = d && daysBetween(today, s.next) === 0;
|
|
225
|
+
put({ key: 'rep:' + (s.id || s.cadence) + ':' + day10(s.next), kind: 'report', date: s.next, time: null, until: null, title: name,
|
|
226
|
+
line: [s.cadence ? 'Goes out ' + String(s.cadence).replace(/[-_]+/g, ' ') : 'Goes out', waits ? 'the draft waits for you' : ''].filter(Boolean).join(' · '), product: '', work: null, task: null, own: null, jira: false, canFix: false, editable: false,
|
|
227
|
+
scope: [], act: waits ? { label: 'Read the draft', href: '/premium-intelligence.html?tab=library' } : null });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// the meetings, and focus time, from the calendar (the same read as Today's agenda)
|
|
231
|
+
for (const e of input.meetings || []) {
|
|
232
|
+
if (!e || !e.title || typeof e.at !== 'string' || !isDay(e.at)) continue;
|
|
233
|
+
const time = /T(\d{2}:\d{2})/.exec(e.at);
|
|
234
|
+
const until = typeof e.end === 'string' && e.end.slice(0, 10) === e.at.slice(0, 10) ? /T(\d{2}:\d{2})/.exec(e.end) : null;
|
|
235
|
+
const work = e.initiative ? { id: String(e.initiative), title: '', ws: '', board: '' } : null;
|
|
236
|
+
put({ key: 'mtg:' + (e.id || e.at + '|' + e.title), kind: 'meeting', type: FOCUS.test(e.title) ? 'focus' : 'meeting', date: e.at, time: time ? time[1] : null, until: until ? until[1] : null, title: clip(e.title, 140),
|
|
237
|
+
line: time ? '' : 'All day', product: '', work, task: null, own: null, jira: false, canFix: false, editable: false, scope: [], act: null });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// the dates people state in the sources: proven only (lib/events-stated.js), each names its source
|
|
241
|
+
for (const d of input.stated || []) {
|
|
242
|
+
if (!d || !d.key || !isDay(d.date) || !d.title) continue;
|
|
243
|
+
const w = d.initiative ? workOf.get(d.initiative) : null;
|
|
244
|
+
put({ key: d.key, kind: 'deadline', date: d.date, time: null, until: null, title: clip(d.title, 140), line: clip(d.line || 'From ' + (d.from || d.source), 120),
|
|
245
|
+
product: w ? w.product : '', work: w ? { ...w.work } : null, task: null, own: null, jira: false, canFix: false, editable: false,
|
|
246
|
+
source: { from: d.from || d.source, who: d.who || '', said: d.said || null, text: clip(d.text || d.title, 240), link: d.link || null },
|
|
247
|
+
who: d.who || '', scope: w ? scopeOf(w.pkey, w.work) : [], act: null });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// the work a meeting is about: its link, else the one initiative or the one product its title names
|
|
251
|
+
const prodNames = products.filter((p) => norm(p.name).length >= 3);
|
|
252
|
+
for (const x of items) {
|
|
253
|
+
if (x.kind !== 'meeting') continue;
|
|
254
|
+
let w = x.work ? workOf.get(x.work.id) : null;
|
|
255
|
+
if (!w) {
|
|
256
|
+
const hits = [...workOf.values()].filter((v) => norm(v.work.title).length >= 8 && hasWords(x.title, v.work.title));
|
|
257
|
+
if (hits.length === 1) w = hits[0];
|
|
258
|
+
}
|
|
259
|
+
if (w) {
|
|
260
|
+
x.work = { ...w.work }; x.product = w.product; x.scope = scopeOf(w.pkey, w.work);
|
|
261
|
+
x.line = (x.line ? x.line + ' · ' : '') + w.work.title;
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (x.work && !x.work.title) x.work = null;
|
|
265
|
+
const ps = prodNames.filter((p) => hasWords(x.title, p.name) || hasWords(x.title, p.name.replace(/^pmos[- ]/i, '')));
|
|
266
|
+
if (ps.length === 1) { x.scope = [ps[0].id]; x.product = ps[0].name; }
|
|
267
|
+
}
|
|
268
|
+
// the programs that hold each item's work
|
|
269
|
+
for (const x of items) if (x.work && x.work.id) for (const g of progOf.get((x.work.ws || '') + '|' + x.work.id) || []) if (!x.scope.includes(g)) x.scope.push(g);
|
|
270
|
+
|
|
271
|
+
// suggestions, first from the item's own record
|
|
272
|
+
const say = (x, s) => {
|
|
273
|
+
const sig = x.key + '|' + s.op + '|' + (s.to || '');
|
|
274
|
+
return declined.has(sig) ? null : { ...s, sig };
|
|
275
|
+
};
|
|
276
|
+
// a Jira date or a plan end: Events keeps the PM's answer (met, gone), or the PM asks the owner
|
|
277
|
+
const owner = (r) => (r && r.owner && !MINE.test(String(r.owner).trim()) ? clip(r.owner, 40) : 'the owner');
|
|
278
|
+
const askHolds = (x, r, why) => { const who = owner(r), d = shortDay(x.date, today); return say(x, { op: 'ask', ask: 'Ask ' + who + ' if ' + d + ' holds: ' + x.title, text: 'Ask ' + who + ' if ' + d + ' holds', why }); };
|
|
279
|
+
const noWrite = (x, r) => {
|
|
280
|
+
if (x.group === 'late') {
|
|
281
|
+
const k = r && r.stage ? BP.stepIndex(r.stage, r.cat) : -1;
|
|
282
|
+
if (k > BP.stepIndex('deliver')) return say(x, { op: 'met', text: 'It looks done. Mark it done', why: 'The work is in ' + (r.stage || '') + ', after Deliver.' });
|
|
283
|
+
if (-x.days >= OLD_DAYS) return say(x, { op: 'gone', text: 'Drop this date', why: 'It is ' + (-x.days) + ' days late, and nothing moved it.' });
|
|
284
|
+
const who = owner(r);
|
|
285
|
+
return say(x, { op: 'ask', ask: 'Ask ' + who + ' for a new date: ' + x.title, text: 'Ask ' + who + ' for a new date', why: 'PMOS cannot write this date here. ' + (r && r.owner && who !== 'the owner' ? cap(who) : 'The owner') + ' can.' });
|
|
286
|
+
}
|
|
287
|
+
if (x.group === 'coming' && x.tone === 'risk' && r && r.forecast && isDay(r.forecast.likely) && daysBetween(x.date, r.forecast.likely) > 0) {
|
|
288
|
+
return askHolds(x, r, 'The Jira forecast says the work lands about ' + shortDay(r.forecast.likely, today) + ', after this date.');
|
|
289
|
+
}
|
|
290
|
+
return null;
|
|
291
|
+
};
|
|
292
|
+
for (const x of items) {
|
|
293
|
+
x.suggest = null;
|
|
294
|
+
const r = x.row;
|
|
295
|
+
if (x.kind === 'deadline') {
|
|
296
|
+
if (x.group !== 'late') continue;
|
|
297
|
+
if (-x.days >= DROP_DAYS) { x.suggest = say(x, { op: 'gone', text: 'Drop this date', why: 'It is ' + (-x.days) + ' days past, and no source names a new one.' }); continue; }
|
|
298
|
+
const who = x.who ? clip(x.who, 40) : 'them';
|
|
299
|
+
x.suggest = say(x, { op: 'ask', ask: 'Ask ' + who + ' where it stands: ' + x.title, text: 'Ask ' + who + ' where it stands', why: 'The day ' + x.source.from + ' named has passed.' });
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (x.jiraTicket) {
|
|
303
|
+
if (x.group !== 'late') continue;
|
|
304
|
+
if (-x.days >= OLD_DAYS) { x.suggest = say(x, { op: 'gone', text: 'Drop this date', why: 'It is ' + (-x.days) + ' days late, and nothing moved it.' }); continue; }
|
|
305
|
+
x.suggest = say(x, { op: 'ask', ask: 'Set a new due date in Jira for ' + x.line.replace(/^Jira /, '').split(' · ')[0] + ': ' + x.title, text: 'Set a new date in Jira', why: 'PMOS cannot write a Jira date here. It adds this as a task for you.' });
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (x.kind !== 'milestone' && x.kind !== 'task') continue;
|
|
309
|
+
if (x.jira || x.planEnd || x.programMs) { x.suggest = noWrite(x, r); continue; }
|
|
310
|
+
if (x.group === 'late') {
|
|
311
|
+
if (r && x.sec && stagePast(r, x.sec)) { x.suggest = say(x, { op: 'done', text: 'It looks done. Mark it done', why: 'Its stage, ' + stageName(r, x.sec) + ', is behind the stage the work is in now, ' + (r.stage || '') + '.' }); continue; }
|
|
312
|
+
if ((x.kind === 'task' && -x.days >= DROP_DAYS) || -x.days >= OLD_DAYS) { x.suggest = say(x, { op: 'drop', text: x.kind === 'task' ? 'Drop it' : 'Drop this date', why: 'It is ' + (-x.days) + ' days late.' }); continue; }
|
|
313
|
+
if (x.fixed || !r) continue;
|
|
314
|
+
const fc = x.kind === 'milestone' && r.forecast && isDay(r.forecast.likely) && daysBetween(today, r.forecast.likely) > 0 ? day10(r.forecast.likely) : null;
|
|
315
|
+
if (fc) { x.suggest = say(x, { op: 'move', to: fc, text: 'Move to ' + shortDay(fc, today), why: 'The Jira forecast says the work lands about ' + shortDay(fc, today) + '.' }); continue; }
|
|
316
|
+
if (isDay(r.end) && daysBetween(today, r.end) > 0) x.suggest = say(x, { op: 'move', to: day10(r.end), text: 'Move to ' + shortDay(r.end, today) + ', the planned finish', why: x.work.title + ' is planned to finish ' + shortDay(r.end, today) + '.' });
|
|
317
|
+
} else if (x.group === 'coming' && x.kind === 'milestone' && x.tone === 'risk' && r && r.forecast && isDay(r.forecast.likely) && daysBetween(x.date, r.forecast.likely) > 0) {
|
|
318
|
+
const fc = day10(r.forecast.likely);
|
|
319
|
+
x.suggest = x.fixed ? noWrite(x, r) : say(x, { op: 'move', to: fc, text: 'Move to ' + shortDay(fc, today), why: 'The Jira forecast says the work lands about ' + shortDay(fc, today) + ', after this date.' });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// then a milestone moves with a task of its stage that moves later
|
|
323
|
+
for (const x of items) {
|
|
324
|
+
if (x.kind !== 'milestone' || x.jira || x.planEnd || x.programMs || x.fixed || !x.sec || (x.group !== 'late' && x.tone !== 'risk')) continue;
|
|
325
|
+
if (x.suggest && x.suggest.op === 'done') continue;
|
|
326
|
+
let best = null;
|
|
327
|
+
for (const t of items) {
|
|
328
|
+
if (t.kind !== 'task' || !t.work || !x.work || t.work.id !== x.work.id || t.work.ws !== x.work.ws || t.sec !== x.sec) continue;
|
|
329
|
+
if (!t.suggest || t.suggest.op !== 'move' || daysBetween(x.date, t.suggest.to) <= 0) continue;
|
|
330
|
+
if (!best || t.suggest.to > best.suggest.to) best = t;
|
|
331
|
+
}
|
|
332
|
+
if (!best || (x.suggest && x.suggest.to && x.suggest.to > best.suggest.to)) continue;
|
|
333
|
+
const s = say(x, { op: 'move', to: best.suggest.to, with: best.title, text: 'Moves with ' + best.title + ', to ' + shortDay(best.suggest.to, today), why: best.title + ' is a task of the same stage, and it moves to ' + shortDay(best.suggest.to, today) + '.' });
|
|
334
|
+
if (s) x.suggest = s;
|
|
335
|
+
}
|
|
336
|
+
// last, every late and at-risk row the rules above left empty (round 2, point 5)
|
|
337
|
+
for (const x of items) {
|
|
338
|
+
if (x.suggest || (x.kind !== 'milestone' && x.kind !== 'task')) continue;
|
|
339
|
+
const declinedAll = (s) => s === null;
|
|
340
|
+
if (x.group === 'late') {
|
|
341
|
+
if (x.kind === 'task') {
|
|
342
|
+
x.suggest = x.fixed ? say(x, { op: 'done', text: 'It is fixed. Mark it done', why: 'Its day has passed, and it is fixed, so PMOS does not move it.' })
|
|
343
|
+
: say(x, { op: 'move', to: today, text: 'Move to today', why: 'It is ' + (-x.days) + ' ' + (x.days === -1 ? 'day' : 'days') + ' late, and no record names a later day.' });
|
|
344
|
+
} else x.suggest = noWrite(x, x.row);
|
|
345
|
+
if (declinedAll(x.suggest)) x.suggest = null;
|
|
346
|
+
} else if (x.group === 'coming' && x.tone === 'risk') {
|
|
347
|
+
x.suggest = askHolds(x, x.row, 'The work is at risk.');
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const ORDER = { late: 0, today: 1, coming: 2, later: 3 };
|
|
352
|
+
// Late: the newest first, so the dates you can still save come before the old ones. A day: the dates with no time first, then by time
|
|
353
|
+
items.sort((a, b) => ORDER[a.group] - ORDER[b.group] || (a.group === 'late' ? b.date.localeCompare(a.date) : a.date.localeCompare(b.date)) || String(a.time || '').localeCompare(String(b.time || '')) || a.title.localeCompare(b.title));
|
|
354
|
+
for (const x of items) { delete x.row; delete x.jiraKey; }
|
|
355
|
+
const ahead = items.filter((x) => x.group === 'later' && x.kind === 'milestone');
|
|
356
|
+
const years = [...new Set(ahead.map((x) => x.date.slice(0, 4)))];
|
|
357
|
+
|
|
358
|
+
// the filter: the products, programs and projects that hold at least one date, with how many
|
|
359
|
+
const count = new Map();
|
|
360
|
+
for (const x of items) for (const t of x.scope) count.set(t, (count.get(t) || 0) + 1);
|
|
361
|
+
const named = (list) => list.filter((f) => count.get(f.id)).map((f) => ({ ...f, n: count.get(f.id) })).sort((a, b) => a.name.localeCompare(b.name));
|
|
362
|
+
const projects = [];
|
|
363
|
+
for (const [id, w] of workOf) { const t = 'j:' + w.work.ws + '|' + id; if (count.get(t) && !projects.some((p) => p.id === t)) projects.push({ id: t, name: w.work.title, product: w.product }); }
|
|
364
|
+
return { today, items, later: { count: ahead.length, year: years.length === 1 && years[0] !== today.slice(0, 4) ? years[0] : null, next: ahead[0] ? { date: ahead[0].date, title: ahead[0].title, key: ahead[0].key } : null },
|
|
365
|
+
filters: { products: named(products), programs: named(programs), projects: named(projects) } };
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
module.exports = { build, shortDay, daysBetween, KINDS, TYPES, TYPE_WORD, FOCUS, DROP_DAYS, OLD_DAYS, WINDOW_DAYS, MEET_DAYS };
|