create-pmos 0.611.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 +86 -14
- 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/briefing-premium-board-test.js +1 -1
- 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-insights-test.js +1 -1
- package/workspace/briefing-premium-test.js +1 -1
- package/workspace/changelog.json +85 -0
- package/workspace/guide/layout.md +52 -18
- package/workspace/guide/programs.md +3 -3
- package/workspace/guide/routine.md +28 -13
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/lib/board-premium.js +12 -4
- 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 +190 -38
- 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 +196 -24
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/plan-items.js +17 -3
- 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 +47 -10
- package/workspace/lib/routes-library.js +74 -8
- package/workspace/lib/routes-report-setups.js +13 -2
- package/workspace/lib/routine-reports.js +36 -4
- package/workspace/lib/status-when.js +36 -0
- package/workspace/lib/task-items.js +5 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-meet-test.js +2 -1
- package/workspace/premium-vw-notes-test.js +3 -2
- package/workspace/public/pm/artefact-kind.js +87 -0
- package/workspace/public/pm/bd-ini-panel.js +6 -6
- package/workspace/public/pm/bd-span.js +5 -0
- package/workspace/public/pm/bd-work.css +62 -0
- package/workspace/public/pm/bd-work.js +195 -68
- 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 +0 -4
- package/workspace/public/pm/cozy-events-view.js +165 -33
- package/workspace/public/pm/cozy-events.css +75 -3
- package/workspace/public/pm/cozy-events.js +86 -18
- package/workspace/public/pm/cozy-goals.css +172 -0
- package/workspace/public/pm/cozy-library.css +106 -17
- package/workspace/public/pm/cozy-nav.js +2 -3
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pop-work.css +83 -24
- package/workspace/public/pm/cozy-pop-work.js +313 -72
- 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 +139 -31
- package/workspace/public/pm/cozy-routine-pop.js +164 -42
- package/workspace/public/pm/cozy-routine.css +61 -8
- package/workspace/public/pm/cozy-routine.js +207 -28
- package/workspace/public/pm/cozy-settings.js +1 -5
- package/workspace/public/pm/cozy-status-when.js +48 -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-chat.js +4 -2
- package/workspace/public/pm/home-ini.js +8 -6
- 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 +170 -42
- package/workspace/public/pm/library-open.js +8 -5
- package/workspace/public/pm/page-chat.js +12 -2
- package/workspace/public/pm/pop-work-model.js +199 -41
- package/workspace/public/pm/premium-board.js +108 -43
- package/workspace/public/pm/premium-goals.js +213 -0
- package/workspace/public/pm/premium-library.js +376 -62
- 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-events.html +3 -1
- package/workspace/public/premium-goals.html +37 -0
- package/workspace/public/premium-library.html +15 -7
- package/workspace/public/premium-routine.html +2 -0
- package/workspace/server.js +2 -1
- package/workspace/test-lists/doc-path.json +9 -0
- package/workspace/test-lists/goals-place.json +9 -0
- package/workspace/test-lists/status-when.json +9 -0
|
@@ -337,7 +337,7 @@ function build(f) {
|
|
|
337
337
|
// the start too: the Tasks Timeline draws a bar from the start to the due day (batch 9 item 5b)
|
|
338
338
|
taskBy.get(w.ini).push({ uid: w.uid, title: clip(w.title || '', 160), status: w.status || 'To do', owner: w.owner || '', start: w.start || '', end: w.end || '', ...(w.from ? { from: { stage: w.from.stage, finish: w.from.finish } } : {}),
|
|
339
339
|
// one view (feedback batch 6 item 1): its place in the breakdown, and a breakdown item's own stage and order
|
|
340
|
-
...(typeof w.section === 'string' ? { section: w.section } : {}), ...(w.itemStage ? { itemStage: w.itemStage } : {}), ...(Number.isFinite(w.order) ? { order: w.order } : {}), ...(Number.isFinite(w.rank) ? { rank: w.rank } : {}), ...(w.store === 'item' ? { item: true } : {}), ...(w.milestone ? { milestone: true } : {}) });
|
|
340
|
+
...(typeof w.section === 'string' ? { section: w.section } : {}), ...(w.itemStage ? { itemStage: w.itemStage } : {}), ...(Number.isFinite(w.order) ? { order: w.order } : {}), ...(Number.isFinite(w.rank) ? { rank: w.rank } : {}), ...(w.store === 'item' ? { item: true } : {}), ...(w.milestone ? { milestone: true } : {}), ...(w.since ? { since: w.since } : {}) });
|
|
341
341
|
}
|
|
342
342
|
// the milestones of each initiative (feedback batch 11 item 3): its tasks flagged ◇, PMOS and Jira alike, at their due dates. Won't do and
|
|
343
343
|
// Archived take one off the timeline; one with no due date is not drawn (the Tasks list asks for the date)
|
|
@@ -378,14 +378,22 @@ function build(f) {
|
|
|
378
378
|
const sprints = Array.isArray(sp.sprints) ? sp.sprints : [];
|
|
379
379
|
// The current sprint: the active one, else the next to start, else the latest closed by its end date (the list sorts closed sprints by name, oldest first).
|
|
380
380
|
const latestClosed = sprints.filter((s) => s.state === 'closed').sort((a, b) => String(b.end || '').localeCompare(String(a.end || '')) || String(b.name).localeCompare(String(a.name), undefined, { numeric: true }))[0];
|
|
381
|
-
|
|
381
|
+
// Work round 3 (Wawan, 2026-11-19: "it stays on MAD 115 even though it has already moved to the other sprint"): a reading can still mark a
|
|
382
|
+
// sprint active after its end date, or hold two active ones. Today decides: the sprint whose dates hold today (the latest start), else the
|
|
383
|
+
// open one with the latest start; an open one whose end has passed gives way to a later open one, and `passed` names it so the page says so.
|
|
384
|
+
const d10 = (v) => (v ? String(v).slice(0, 10) : '');
|
|
385
|
+
const openS = sprints.filter((s) => s.state !== 'closed').sort((a, b) => d10(b.start).localeCompare(d10(a.start)) || String(b.name).localeCompare(String(a.name), undefined, { numeric: true }));
|
|
386
|
+
const holds = openS.find((s) => d10(s.start) && d10(s.end) && d10(s.start) <= todayIso && todayIso <= d10(s.end));
|
|
387
|
+
const live = holds || openS.find((s) => s.state === 'active') || openS.slice().reverse().find((s) => d10(s.start) > todayIso) || openS[0] || null;
|
|
388
|
+
const stale = sprints.filter((s) => s.state === 'active' && s !== live && d10(s.end) && d10(s.end) < todayIso).sort((a, b) => d10(b.end).localeCompare(d10(a.end)))[0] || null;
|
|
389
|
+
const active = sp.source === 'jira' ? (live || latestClosed || null) : null;
|
|
382
390
|
const goalText = active && active.goal ? (typeof active.goal === 'object' ? active.goal.text || '' : String(active.goal)) : '';
|
|
383
391
|
const wd = (a, b) => { const x = isoDay(a), y = isoDay(b); if (!x || !y) return null; let n = 0; for (const d = new Date(x); d <= y; d.setDate(d.getDate() + 1)) if (d.getDay() % 6) n++; return n; }; // weekdays, both ends counted
|
|
384
392
|
const sprint = active
|
|
385
393
|
? (() => {
|
|
386
394
|
const k = active.counts || {}, c = { done: k.done || 0, doing: k.doing || 0, todo: k.todo || 0 }, tot = c.done + c.doing + c.todo, st = active.start && String(active.start).slice(0, 10), en = active.end && String(active.end).slice(0, 10);
|
|
387
395
|
const open = active.state !== 'closed', len = st && en ? wd(st, en) : null, at = len && todayIso >= st ? Math.min(len, wd(st, todayIso)) : null, left = open && en ? days(todayIso, en) : null;
|
|
388
|
-
return { cap: open && len && at != null ? 'day ' + at + ' of ' + len : active.state || '', name: active.name, state: active.state, start: st ? shortDate(st) : '', end: en ? shortDate(en) : '', counts: c,
|
|
396
|
+
return { cap: open && len && at != null ? 'day ' + at + ' of ' + len : active.state || '', name: active.name, state: active.state, passed: stale ? stale.name : '', over: !!(open && en && en < todayIso), start: st ? shortDate(st) : '', end: en ? shortDate(en) : '', counts: c,
|
|
389
397
|
pct: tot ? { done: +(c.done / tot * 100).toFixed(1), doing: +(c.doing / tot * 100).toFixed(1) } : { done: 0, doing: 0 },
|
|
390
398
|
goal: goalText ? clip(goalText, 300) : '', tickets: (active.issues || []).slice(0, 40).map((i) => ({ key: i.key, title: clip(i.summary || i.key, 120), status: i.status || ({ done: 'Done', doing: 'Doing', todo: 'To do' })[i.category] || '' })), review: left == null ? '' : left < 0 ? 'Sprint ended ' + plural(-left, 'a day', -left + ' days') + ' ago.' : left === 0 ? 'Sprint review is today.' : 'Sprint review in ' + left + ' ' + plural(left, 'day', 'days') + '.' };
|
|
391
399
|
})()
|
|
@@ -443,7 +451,7 @@ function build(f) {
|
|
|
443
451
|
// the Agreed design (premium-agreed-design): the eight steps with the board's own count in each, the Jira read time and the chip counts
|
|
444
452
|
steps: STEPS.map((st, i) => ({ ...st, count: stages.filter((c) => stepIndex(c.stage, c.cat) === i).reduce((n, c) => n + c.count, 0) })),
|
|
445
453
|
jira: { source: sp.source || 'none', readAt: sp.readAt || null, release: nr && nr.at ? { name: nr.name || nr.id, at: shortDate(String(nr.at).slice(0, 10)), iso: String(nr.at).slice(0, 10) } : null,
|
|
446
|
-
sprint: active ? { name: active.name, start: active.start ? String(active.start).slice(0, 10) : null, end: active.end ? String(active.end).slice(0, 10) : null } : null,
|
|
454
|
+
sprint: active ? { name: active.name, start: active.start ? String(active.start).slice(0, 10) : null, end: active.end ? String(active.end).slice(0, 10) : null, passed: stale ? stale.name : '', over: !!(active.state !== 'closed' && d10(active.end) && d10(active.end) < todayIso) } : null,
|
|
447
455
|
// every sprint of the reading, oldest first, with its points where the reading holds them (initiative premium-uncovered-features, BdSprint)
|
|
448
456
|
sprints: sp.source === 'jira' ? sprints.slice().sort((a, b) => String(a.start || '').localeCompare(String(b.start || ''))).map((x) => {
|
|
449
457
|
const iss = x.issues || [], pts = iss.filter((i) => Number.isFinite(i.points)), k = x.counts || {};
|
|
@@ -55,6 +55,7 @@ const RULE = [
|
|
|
55
55
|
'Never from this chat: accept a run, anchor or dispose an initiative, approve a contract, merge a pull request. These stay on the PM-only pages. Say where each one waits and stop.',
|
|
56
56
|
'You are the chief: the one live session over every Program, Product and Project. Each unit has one owner, a record with a daily brief, never a session; an initiative in a program is the program\'s, else its product\'s. Never ask another session; read the records. `pmos units` lists the units and their briefs. You may run these yourself: `pmos owner brief [<unit>]` (a fresh brief now), `pmos team dispatch --unit <unit>` (the roles for the unit\'s first open initiative), `pmos team pause|resume --unit <unit>` (stop or restart the role runs on a unit). When the same lesson shows in two units, file it with `pmos propose` as a workspace rule the PM keeps or drops.',
|
|
57
57
|
'Answer in plain sentences, the answer first. Never start with "I can help with".',
|
|
58
|
+
'Speak to the PM as "you", in the first person ("I archived them"). Never write "The PM says" or speak of the PM in the third person.',
|
|
58
59
|
].join('\n');
|
|
59
60
|
|
|
60
61
|
/** The message as typed into a live session. page: the "You are on …" chip's words, or '' when the PM dropped it. */
|
|
@@ -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) {
|
|
@@ -12,14 +12,26 @@
|
|
|
12
12
|
* schedules [{ id, name, cadence, next }] the enabled report schedules, with the day each fires next ('YYYY-MM-DD')
|
|
13
13
|
* drafts [{ ws, cadence, slot, title? }] report drafts that wait to be issued (lib/report-needs.js reportsOf: a draft, not issued)
|
|
14
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
|
|
15
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)
|
|
16
20
|
*
|
|
17
|
-
* AN ITEM: { key, kind, date, time, until, title, line, product, work, task, own, jira, fixed, canFix, editable, tone, days,
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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.
|
|
20
31
|
* group late (before today, not done) · today · coming (the next WINDOW_DAYS days; a meeting the next MEET_DAYS) · later
|
|
21
32
|
* tone late · risk (a milestone of an initiative at risk, or whose Jira forecast says it will miss) · ''
|
|
22
|
-
* suggest { op: done | move | drop, to?, with?, text, why, sig } or null. What PMOS suggests; the PM says yes (✓)
|
|
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.
|
|
23
35
|
*
|
|
24
36
|
* THE RULES OF A SUGGESTION. A suggestion is made only from a record; PMOS does not invent a date.
|
|
25
37
|
* done a late PMOS item whose stage is behind the stage its initiative is in now: "It looks done. Mark it done".
|
|
@@ -27,12 +39,27 @@
|
|
|
27
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.
|
|
28
40
|
* A milestone whose stage has a task that moves later moves with it: "Moves with <task>, to <day>".
|
|
29
41
|
* Coming up: only a milestone at risk, to the day the Jira forecast gives.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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. */
|
|
32
55
|
const BP = require('./board-premium.js');
|
|
33
56
|
|
|
34
|
-
const KINDS = Object.freeze(['milestone', 'task', 'report', 'meeting']);
|
|
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;
|
|
35
61
|
const DROP_DAYS = 28;
|
|
62
|
+
const OLD_DAYS = 90;
|
|
36
63
|
const WINDOW_DAYS = 30;
|
|
37
64
|
const MEET_DAYS = 7;
|
|
38
65
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
@@ -81,59 +108,103 @@ function groupOf(kind, date, today) {
|
|
|
81
108
|
return d <= (kind === 'meeting' ? MEET_DAYS : WINDOW_DAYS) ? 'coming' : 'later';
|
|
82
109
|
}
|
|
83
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
|
+
|
|
84
115
|
function build(input = {}) {
|
|
85
116
|
const today = isDay(input.today) ? day10(input.today) : null;
|
|
86
|
-
if (!today) return { today: null, items: [], later: { count: 0, next: null } };
|
|
117
|
+
if (!today) return { today: null, items: [], later: { count: 0, next: null }, filters: { products: [], programs: [], projects: [] } };
|
|
87
118
|
const marks = input.marks || {};
|
|
88
119
|
const fixedSet = marks.fixed instanceof Set ? marks.fixed : new Set(marks.fixed || []);
|
|
89
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 || {}));
|
|
90
122
|
const items = [];
|
|
91
123
|
const put = (x) => {
|
|
92
|
-
if (!isDay(x.date)) return;
|
|
124
|
+
if (!isDay(x.date) || gone.has(x.key)) return;
|
|
93
125
|
x.date = day10(x.date);
|
|
94
126
|
x.days = daysBetween(today, x.date);
|
|
95
127
|
x.group = groupOf(x.kind, x.date, today);
|
|
96
128
|
if (x.kind === 'meeting' && x.group === 'late') return; // a meeting that has passed is not late
|
|
97
129
|
if (x.kind === 'report' && x.group === 'late' && !x.draft) return;
|
|
130
|
+
x.type = x.type || x.kind;
|
|
98
131
|
x.fixed = !!(x.canFix && fixedSet.has(x.key));
|
|
99
132
|
x.tone = x.group === 'late' ? 'late' : x.tone || '';
|
|
133
|
+
x.source = x.source || null;
|
|
100
134
|
items.push(x);
|
|
101
135
|
};
|
|
102
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
|
+
|
|
103
147
|
for (const b of input.boards || []) {
|
|
104
148
|
const product = clip(b.name || b.ws || '', 80);
|
|
149
|
+
const pkey = b.ws || '';
|
|
105
150
|
for (const r of b.rows || []) {
|
|
106
151
|
if (!r || !r.id || r.closed || r.status === 'done' || r.status === 'cancelled' || r.status === 'on hold') continue;
|
|
107
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);
|
|
108
154
|
const risk = atRisk(r);
|
|
109
155
|
const open = (r.milestones || []).filter((m) => m && !m.done && isDay(m.date));
|
|
110
156
|
for (const m of open) {
|
|
111
157
|
const st = stageName(r, m.sec);
|
|
112
158
|
put({ key: 'ms:' + work.ws + '|' + work.board + '|' + m.id, kind: 'milestone', date: m.date, time: null, until: null, title: clip(m.name, 140),
|
|
113
|
-
line:
|
|
114
|
-
own: null, jira: !!m.jira, canFix: true, editable: !m.jira, tone: risk ? 'risk' : '', sec: m.sec || '', row: r, act: null });
|
|
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 });
|
|
115
161
|
}
|
|
116
162
|
// the plan end stands for the delivery when the initiative names no open milestone (as Work's "Plan end")
|
|
117
163
|
if (!open.length && isDay(r.end)) {
|
|
118
164
|
put({ key: 'end:' + work.ws + '|' + work.board + '|' + r.id, kind: 'milestone', date: r.end, time: null, until: null, title: work.title,
|
|
119
|
-
line: '
|
|
120
|
-
tone: risk ? 'risk' : '', sec: '', row: r, act: null });
|
|
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 });
|
|
121
167
|
}
|
|
122
168
|
for (const t of r.tasks || []) {
|
|
123
169
|
if (!t || !t.uid || t.milestone || CLOSED.test(String(t.status || '')) || !isDay(t.end)) continue;
|
|
124
170
|
if (t.owner && !MINE.test(String(t.owner).trim())) continue; // the PM's tasks: no owner, or the PM
|
|
125
171
|
const sec = typeof t.section === 'string' && t.section ? t.section : t.from && t.from.stage ? t.from.stage : '';
|
|
126
172
|
put({ key: 'task:' + work.ws + '|' + work.board + '|' + t.uid, kind: 'task', date: t.end, time: null, until: null, title: clip(t.title, 140),
|
|
127
|
-
line:
|
|
128
|
-
canFix: true, editable: true, sec, row: r, act: null });
|
|
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 });
|
|
129
175
|
}
|
|
130
176
|
}
|
|
131
177
|
}
|
|
132
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
|
+
|
|
133
189
|
for (const o of input.own || []) {
|
|
134
190
|
if (!o || !o.id || o.done || !isDay(o.due)) continue;
|
|
135
|
-
put({ key: 'own:' + o.id, kind: 'task', date: o.due, time: null, until: null, title: clip(o.title, 140), line: '
|
|
136
|
-
own: String(o.id), jira: false, canFix: true, editable: true, sec: '', row: null, act: null });
|
|
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
|
+
}
|
|
137
208
|
}
|
|
138
209
|
|
|
139
210
|
const draftOf = new Map();
|
|
@@ -143,57 +214,114 @@ function build(input = {}) {
|
|
|
143
214
|
for (const d of draftOf.values()) {
|
|
144
215
|
if (outToday.has(d.cadence)) continue;
|
|
145
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),
|
|
146
|
-
line: '
|
|
147
|
-
act: { label: 'Read the draft', href: '/premium-intelligence.html?tab=library' } });
|
|
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' } });
|
|
148
219
|
}
|
|
149
220
|
for (const s of input.schedules || []) {
|
|
150
221
|
if (!s || !isDay(s.next)) continue;
|
|
151
222
|
const name = clip(s.name || cap(s.cadence) + ' report', 120);
|
|
152
223
|
const d = draftOf.get(s.cadence);
|
|
224
|
+
const waits = d && daysBetween(today, s.next) === 0;
|
|
153
225
|
put({ key: 'rep:' + (s.id || s.cadence) + ':' + day10(s.next), kind: 'report', date: s.next, time: null, until: null, title: name,
|
|
154
|
-
line:
|
|
155
|
-
|
|
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 });
|
|
156
228
|
}
|
|
157
229
|
|
|
230
|
+
// the meetings, and focus time, from the calendar (the same read as Today's agenda)
|
|
158
231
|
for (const e of input.meetings || []) {
|
|
159
232
|
if (!e || !e.title || typeof e.at !== 'string' || !isDay(e.at)) continue;
|
|
160
233
|
const time = /T(\d{2}:\d{2})/.exec(e.at);
|
|
161
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;
|
|
162
235
|
const work = e.initiative ? { id: String(e.initiative), title: '', ws: '', board: '' } : null;
|
|
163
|
-
put({ key: 'mtg:' + (e.id || e.at + '|' + e.title), kind: 'meeting', date: e.at, time: time ? time[1] : null, until: until ? until[1] : null, title: clip(e.title, 140),
|
|
164
|
-
line: time ? '
|
|
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 });
|
|
165
248
|
}
|
|
166
249
|
|
|
167
|
-
// the work a meeting is about,
|
|
168
|
-
const
|
|
169
|
-
for (const x of items)
|
|
170
|
-
|
|
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);
|
|
171
270
|
|
|
172
271
|
// suggestions, first from the item's own record
|
|
173
272
|
const say = (x, s) => {
|
|
174
273
|
const sig = x.key + '|' + s.op + '|' + (s.to || '');
|
|
175
274
|
return declined.has(sig) ? null : { ...s, sig };
|
|
176
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
|
+
};
|
|
177
292
|
for (const x of items) {
|
|
178
293
|
x.suggest = null;
|
|
179
|
-
if (x.kind !== 'milestone' && x.kind !== 'task') continue;
|
|
180
|
-
if (x.jira || x.planEnd) continue;
|
|
181
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; }
|
|
182
310
|
if (x.group === 'late') {
|
|
183
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; }
|
|
184
|
-
if (x.kind === 'task' && -x.days >= DROP_DAYS) { x.suggest = say(x, { op: 'drop', text: 'Drop it', why: 'It is ' + (-x.days) + ' days late.' }); 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; }
|
|
185
313
|
if (x.fixed || !r) continue;
|
|
186
314
|
const fc = x.kind === 'milestone' && r.forecast && isDay(r.forecast.likely) && daysBetween(today, r.forecast.likely) > 0 ? day10(r.forecast.likely) : null;
|
|
187
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; }
|
|
188
|
-
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
|
|
189
|
-
} else if (x.group === 'coming' && x.kind === 'milestone' && x.tone === 'risk' &&
|
|
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) {
|
|
190
318
|
const fc = day10(r.forecast.likely);
|
|
191
|
-
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) + ', after this date.' });
|
|
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.' });
|
|
192
320
|
}
|
|
193
321
|
}
|
|
194
322
|
// then a milestone moves with a task of its stage that moves later
|
|
195
323
|
for (const x of items) {
|
|
196
|
-
if (x.kind !== 'milestone' || x.jira || x.planEnd || x.fixed || !x.sec || (x.group !== 'late' && x.tone !== 'risk')) continue;
|
|
324
|
+
if (x.kind !== 'milestone' || x.jira || x.planEnd || x.programMs || x.fixed || !x.sec || (x.group !== 'late' && x.tone !== 'risk')) continue;
|
|
197
325
|
if (x.suggest && x.suggest.op === 'done') continue;
|
|
198
326
|
let best = null;
|
|
199
327
|
for (const t of items) {
|
|
@@ -205,12 +333,36 @@ function build(input = {}) {
|
|
|
205
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) + '.' });
|
|
206
334
|
if (s) x.suggest = s;
|
|
207
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
|
+
}
|
|
208
350
|
|
|
209
351
|
const ORDER = { late: 0, today: 1, coming: 2, later: 3 };
|
|
210
|
-
|
|
211
|
-
|
|
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; }
|
|
212
355
|
const ahead = items.filter((x) => x.group === 'later' && x.kind === 'milestone');
|
|
213
|
-
|
|
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) } };
|
|
214
366
|
}
|
|
215
367
|
|
|
216
|
-
module.exports = { build, shortDay, daysBetween, KINDS, DROP_DAYS, WINDOW_DAYS, MEET_DAYS };
|
|
368
|
+
module.exports = { build, shortDay, daysBetween, KINDS, TYPES, TYPE_WORD, FOCUS, DROP_DAYS, OLD_DAYS, WINDOW_DAYS, MEET_DAYS };
|