create-pmos 0.611.0 → 0.613.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 +105 -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/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 +104 -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 +7 -1
- 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 +207 -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
|
@@ -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 };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/events-stated.js — the dates people state in the sources, for Events (events round 2, initiative events-place; design
|
|
3
|
+
* /mnt/project-files/nav-structure/audit/events-round2.md point 1).
|
|
4
|
+
*
|
|
5
|
+
* statedDates(reads, { today }) → [{ key, source, from, who, said, date, title, text, link, initiative }] PURE. No I/O and no clock.
|
|
6
|
+
* dateIn(text, { year, after }) → [{ date, at }] the explicit dates in one text ('30 Nov', 'Nov 30', '30 November 2026', '2026-11-30')
|
|
7
|
+
* FROM · CUE
|
|
8
|
+
*
|
|
9
|
+
* INPUT. reads = lib/source-reads.js all(runtimeDir): { <source>: { source, state, items, digests } }. An item holds what the tool says (who,
|
|
10
|
+
* where, the ask, the link) and `due` when the session that read it found a due day in the message.
|
|
11
|
+
*
|
|
12
|
+
* PROVEN ONLY. A date is kept only when the text states it: the item's own `due` (a day), or a day and a month written in the words of the
|
|
13
|
+
* item next to a word that makes it a date to keep (CUE: deadline, due, by, release, launch, decided, …). "Next week", "Friday" and "soon"
|
|
14
|
+
* are not dates here, because PMOS would have to guess the day. A date with no year takes the year of the message, or the next year when
|
|
15
|
+
* that day is more than half a year before the message. A date more than 60 days before today or more than a year after it is left out.
|
|
16
|
+
* A digest's decision line with such a date is kept too ("Decided: release on 2 Dec"): it is a date decided in the meeting notes. */
|
|
17
|
+
|
|
18
|
+
const MON = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
|
|
19
|
+
const MON_SHORT = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
20
|
+
/** The source's name in the grey line: "From Slack · Ang, 18 Nov". */
|
|
21
|
+
const FROM = Object.freeze({ mail: 'email', slack: 'Slack', wispr: 'meeting notes', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Drive', figma: 'Figma', website: 'the website', web: 'the web' });
|
|
22
|
+
/** A word that makes a stated day a date to keep. */
|
|
23
|
+
const CUE = /\b(deadline|due|by|until|before|no later than|release[ds]?|launch(es|ed)?|go[- ]?live|ships?|cut-?off|decided|agreed|accepts?|target|eta|deliver(y|s)?|freeze|submit|sign[- ]?off|demo|kick-?off)\b/i;
|
|
24
|
+
const BACK_DAYS = 60;
|
|
25
|
+
const AHEAD_DAYS = 366;
|
|
26
|
+
|
|
27
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
28
|
+
const isDay = (s) => typeof s === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(s) && !Number.isNaN(Date.parse(s + 'T00:00:00Z'));
|
|
29
|
+
const ms = (d) => Date.parse(d + 'T00:00:00Z');
|
|
30
|
+
const between = (a, b) => Math.round((ms(b) - ms(a)) / 86400000);
|
|
31
|
+
const flat = (s) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim();
|
|
32
|
+
const clip = (s, n) => { s = flat(s); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
33
|
+
/** A real day of the calendar, or null (31 Feb is not one). */
|
|
34
|
+
function mk(y, m, d) {
|
|
35
|
+
if (!(m >= 1 && m <= 12 && d >= 1 && d <= 31)) return null;
|
|
36
|
+
const t = new Date(Date.UTC(y, m - 1, d));
|
|
37
|
+
return t.getUTCMonth() === m - 1 ? `${y}-${pad(m)}-${pad(d)}` : null;
|
|
38
|
+
}
|
|
39
|
+
/** The day a message was written ('YYYY-MM-DD'), from its `at`, or null. */
|
|
40
|
+
function dayOf(at) {
|
|
41
|
+
const s = String(at || '');
|
|
42
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(s)) return s.slice(0, 10);
|
|
43
|
+
const t = Date.parse(s);
|
|
44
|
+
return Number.isNaN(t) ? null : new Date(t).toISOString().slice(0, 10);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The explicit dates in one text, with where each sits. o: { year (when the text gives none), after: 'YYYY-MM-DD' (the message day) }. */
|
|
48
|
+
function dateIn(text, o = {}) {
|
|
49
|
+
const s = String(text || '');
|
|
50
|
+
const out = [];
|
|
51
|
+
const yearOf = (m, d) => {
|
|
52
|
+
let y = Number(o.year) || new Date().getUTCFullYear();
|
|
53
|
+
const k = mk(y, m, d);
|
|
54
|
+
if (k && o.after && between(o.after, k) < -183) y += 1; // "3 Jan" said in December is next year
|
|
55
|
+
return y;
|
|
56
|
+
};
|
|
57
|
+
const push = (day, at) => { if (day && !out.some((x) => x.date === day && x.at === at)) out.push({ date: day, at }); };
|
|
58
|
+
let m;
|
|
59
|
+
const iso = /\b(20\d\d)-(\d\d)-(\d\d)\b/g;
|
|
60
|
+
while ((m = iso.exec(s))) push(mk(+m[1], +m[2], +m[3]), m.index);
|
|
61
|
+
const dm = /\b(\d{1,2})(?:st|nd|rd|th)?\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\.?(?:,?\s+(20\d\d))?\b/gi;
|
|
62
|
+
while ((m = dm.exec(s))) { const mo = MON.indexOf(m[2].slice(0, 3).toLowerCase()) + 1, d = +m[1]; push(mk(m[3] ? +m[3] : yearOf(mo, d), mo, d), m.index); }
|
|
63
|
+
const md = /\b(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\.?\s+(\d{1,2})(?:st|nd|rd|th)?\b(?:,?\s+(20\d\d))?/gi;
|
|
64
|
+
while ((m = md.exec(s))) { const mo = MON.indexOf(m[1].slice(0, 3).toLowerCase()) + 1, d = +m[2]; push(mk(m[3] ? +m[3] : yearOf(mo, d), mo, d), m.index); }
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/** The sentence of `text` around position `at`. */
|
|
68
|
+
function sentenceAt(text, at) {
|
|
69
|
+
const s = String(text);
|
|
70
|
+
const a = Math.max(s.lastIndexOf('. ', at), s.lastIndexOf('? ', at), s.lastIndexOf('! ', at), s.lastIndexOf('\n', at));
|
|
71
|
+
const ends = ['. ', '? ', '! ', '\n'].map((e) => s.indexOf(e, at)).filter((i) => i >= 0);
|
|
72
|
+
const b = ends.length ? Math.min(...ends) + 1 : s.length;
|
|
73
|
+
return s.slice(a < 0 ? 0 : a + 1, b).trim();
|
|
74
|
+
}
|
|
75
|
+
const shortDay = (d) => { const [, m, dd] = d.split('-').map(Number); return dd + ' ' + MON_SHORT[m - 1]; };
|
|
76
|
+
|
|
77
|
+
function statedDates(reads, { today } = {}) {
|
|
78
|
+
if (!isDay(today)) return [];
|
|
79
|
+
const year = Number(today.slice(0, 4));
|
|
80
|
+
const out = [], seen = new Set();
|
|
81
|
+
const keep = (x) => {
|
|
82
|
+
const d = between(today, x.date);
|
|
83
|
+
if (d < -BACK_DAYS || d > AHEAD_DAYS) return;
|
|
84
|
+
const sig = x.date + '|' + x.title.toLowerCase();
|
|
85
|
+
if (seen.has(sig)) return;
|
|
86
|
+
seen.add(sig);
|
|
87
|
+
out.push(x);
|
|
88
|
+
};
|
|
89
|
+
for (const r of Object.values(reads || {})) {
|
|
90
|
+
if (!r || r.state !== 'read' || !FROM[r.source]) continue;
|
|
91
|
+
const from = FROM[r.source];
|
|
92
|
+
for (const it of r.items || []) {
|
|
93
|
+
if (!it || !it.title || it.bot) continue;
|
|
94
|
+
const said = dayOf(it.at);
|
|
95
|
+
const base = { source: r.source, from, who: clip(it.who || '', 60), said, link: it.link || null, initiative: it.initiative_id || null, title: clip(it.ask || it.title, 140) };
|
|
96
|
+
const id = it.id || clip(it.title, 40);
|
|
97
|
+
// the item's own due day: the session that read it found it in the message
|
|
98
|
+
if (isDay(String(it.due || '').slice(0, 10))) {
|
|
99
|
+
const date = String(it.due).slice(0, 10);
|
|
100
|
+
keep({ ...base, key: 'dl:' + r.source + ':' + id + ':' + date, date, text: clip(it.ask || it.about || it.title, 240) });
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const texts = [it.ask, it.title, it.about, ...((it.thread || []).map((t) => t && t.text))].filter(Boolean);
|
|
104
|
+
let found = null;
|
|
105
|
+
for (const t of texts) {
|
|
106
|
+
for (const hit of dateIn(t, { year: said ? Number(said.slice(0, 4)) : year, after: said })) {
|
|
107
|
+
const line = sentenceAt(t, hit.at);
|
|
108
|
+
if (CUE.test(line)) { found = { date: hit.date, text: clip(line, 240) }; break; }
|
|
109
|
+
}
|
|
110
|
+
if (found) break;
|
|
111
|
+
}
|
|
112
|
+
if (found) keep({ ...base, key: 'dl:' + r.source + ':' + id + ':' + found.date, date: found.date, text: found.text });
|
|
113
|
+
}
|
|
114
|
+
for (const g of r.digests || []) {
|
|
115
|
+
if (!g || !g.name) continue;
|
|
116
|
+
for (const line of g.decisions || []) {
|
|
117
|
+
for (const hit of dateIn(line, { year })) {
|
|
118
|
+
if (!CUE.test(sentenceAt(line, hit.at))) continue;
|
|
119
|
+
keep({ source: r.source, from, who: clip(g.name, 60), said: null, link: g.link || null, initiative: null, title: clip(line, 140),
|
|
120
|
+
key: 'dl:' + r.source + ':' + clip(g.name, 40) + ':' + hit.date, date: hit.date, text: clip(line, 240) });
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return out.map((x) => ({ ...x, line: 'From ' + x.from + (x.who || x.said ? ' · ' + [x.who, x.said ? shortDay(x.said) : ''].filter(Boolean).join(', ') : '') }));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = { statedDates, dateIn, FROM, CUE };
|
|
@@ -49,6 +49,7 @@ function rule(info, id) {
|
|
|
49
49
|
(info.ended ? `It ended (${info.ended === 'wontdo' ? "Won't do" : 'Archived'}).` : stageWords(info)));
|
|
50
50
|
out.push('Its stages: ' + info.stages.map((s, i) => `${i + 1}. ${s.name} [${s.key}]${s.status === 'done' ? ' done' : s.status === 'current' ? ' current' : s.status === 'skipped' ? ' skipped' : ''}`).join('; ') + '.');
|
|
51
51
|
} else out.push(`Run \`pmos workflow of ${ini}\` to see the workflow this initiative runs and its current stage.`);
|
|
52
|
+
out.push('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.');
|
|
52
53
|
out.push(
|
|
53
54
|
`Read workflows only through pmos: \`pmos workflow of ${ini}\` gives this initiative's workflow and its stages, \`pmos workflow show <workflow id>\` gives any workflow's stages, and \`pmos workflow list\` names every workflow the PM can pick, the ones saved in Settings included. The workflows are not files in this repository: never search the files for one. If pmos cannot find a workflow, tell the PM so and ask. A workflow is not a lane: never use a lane (feature, discovery, chore, incident, content, prototype) in place of the initiative's workflow.`,
|
|
54
55
|
`The workflow stage is on the initiative: the stage card and the Board show it. \`pmos workflow of ${ini}\` reads it. When the PM asks to move the initiative, run \`pmos workflow move ${ini} --stage <key> --why "<reason>"\`. When the PM asks to change its workflow, run \`pmos workflow switch ${ini} --to <workflow id>\`. Both write what the page's press writes, under your name.`,
|
|
@@ -477,6 +477,16 @@ function budgetWatch(budgets, goals) {
|
|
|
477
477
|
return budgets;
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
+
/** The open initiatives whose anchor names no key result of the OKR file (by id or by name) and no health budget or domain: Goals' Unlinked row.
|
|
481
|
+
* [] with no OKR file, so a product without one never lists all its work as unlinked. PURE. */
|
|
482
|
+
function unlinkedOf(inits, okr) {
|
|
483
|
+
if (!Array.isArray(inits) || !okr || !okr.ok || !(okr.objectives || []).length) return [];
|
|
484
|
+
return inits.filter((r) => r && r.status !== 'done' && r.status !== 'cancelled' && !r.stopped).map(initOf).filter((r) => {
|
|
485
|
+
const a = String(r.anchor || '').trim();
|
|
486
|
+
if (/^(health|domain):/i.test(a)) return false;
|
|
487
|
+
return !OG.matchAnchor(a, okr.objectives) && !OG.byName(r.title, okr.objectives);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
480
490
|
function build(facts) {
|
|
481
491
|
const f = facts || {};
|
|
482
492
|
const outcomes = f.outcomes || [], missing = (f.missing || []).slice();
|
|
@@ -526,6 +536,8 @@ function build(facts) {
|
|
|
526
536
|
model.metrics = GS.metricsOf(model.goals);
|
|
527
537
|
// Intelligence redesign A: the OKR file is the goal list; a KR metric record is a key result's reader (lib/okr-goals.js)
|
|
528
538
|
model.okrFile = OG.build({ okr: f.okr, goals: model.goals, initiatives: (f.initiatives || []).map(initOf), records: f.goalMeta || {}, today: model.today });
|
|
539
|
+
// Goals (slice 9 of the six-place navigation): the open work no key result and no budget names, for the page's Unlinked row
|
|
540
|
+
model.unlinked = unlinkedOf(f.initiatives, f.okr);
|
|
529
541
|
model.lateRows = Array.isArray(f.initiatives) ? f.initiatives.filter((r) => r && r.status === 'late').map(initOf) : [];
|
|
530
542
|
model.okr = okrOf(model, (f.watch && f.watch.drafts) || 0);
|
|
531
543
|
model.lateNow = Array.isArray(f.initiatives) ? f.initiatives.filter((r) => r && r.status === 'late').length : null;
|
|
@@ -536,4 +548,4 @@ function build(facts) {
|
|
|
536
548
|
return model;
|
|
537
549
|
}
|
|
538
550
|
|
|
539
|
-
module.exports = { okrOf, watchFields, budgetWatch, lifeIndex, goalType, goalsOf, outcomesOf, budgetsOf, mdDate, build, peekModel, chartOf, mineOf, findingsOf, findingsOfChart, projectionOf, leadOf, shortDate, num };
|
|
551
|
+
module.exports = { unlinkedOf, okrOf, watchFields, budgetWatch, lifeIndex, goalType, goalsOf, outcomesOf, budgetsOf, mdDate, build, peekModel, chartOf, mineOf, findingsOf, findingsOfChart, projectionOf, leadOf, shortDate, num };
|