create-pmos 0.440.0 → 0.441.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 +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +16 -13
- package/workspace/briefing-premium-products-test.js +4 -4
- package/workspace/briefing-premium-sources-test.js +2 -2
- package/workspace/briefing-premium-test.js +29 -23
- package/workspace/changelog.json +12 -0
- package/workspace/guide/core-documents.md +2 -2
- package/workspace/guide/data-freshness.md +7 -5
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/horizon-scan.md +1 -1
- package/workspace/lib/agent-inbox.js +20 -2
- package/workspace/lib/briefing-premium-sources.js +3 -0
- package/workspace/lib/briefing-premium.js +37 -7
- package/workspace/lib/driver-cli.js +1 -1
- package/workspace/lib/driver-run.js +15 -1
- package/workspace/lib/driver.js +31 -2
- package/workspace/lib/news-for-you.js +24 -9
- package/workspace/lib/pm-idle.js +12 -0
- package/workspace/lib/refresh.js +17 -8
- package/workspace/lib/routes-core-docs.js +1 -1
- package/workspace/lib/routes-news.js +15 -1
- package/workspace/lib/routes-phone-day.js +6 -4
- package/workspace/need-shot.js +57 -0
- package/workspace/news-viewers-test.js +183 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-core-doc-issue-test.js +9 -8
- package/workspace/public/pm/bd-ini-panel.js +4 -11
- package/workspace/public/pm/cozy-ev.css +29 -0
- package/workspace/public/pm/cozy-news.js +186 -22
- package/workspace/public/pm/cozy-today.css +5 -0
- package/workspace/public/pm/cozy-viewer.js +4 -3
- package/workspace/public/pm/cozy-vw-shell.css +49 -0
- package/workspace/public/pm/home-adddoc.js +46 -26
- package/workspace/public/pm/home-app.js +134 -112
- package/workspace/public/pm/home-day.js +10 -5
- package/workspace/public/pm/home-draft.js +35 -23
- package/workspace/public/pm/home-ini.js +2 -2
- package/workspace/public/pm/home-need.js +336 -0
- package/workspace/public/pm/home-today.js +2 -2
- package/workspace/public/pm/home-work.js +51 -4
- package/workspace/public/pm/small-vw.js +128 -0
- package/workspace/server.js +10 -6
- package/workspace/skills/initiative-drive.skill +4 -1
- package/workspace/test-lists/batch18-asks.json +5 -0
- package/workspace/test-lists/news-viewers.json +13 -0
- package/workspace/test-lists/small-viewers.json +5 -0
|
@@ -55,6 +55,16 @@ const dayCheckOpen = (settings, now, inQuiet) => {
|
|
|
55
55
|
const t = hhmm(now);
|
|
56
56
|
return settings && settings.enabled === false ? false : (t >= dc.start && t < dc.end && !inQuiet(now, settings && settings.quiet));
|
|
57
57
|
};
|
|
58
|
+
// feedback batch 18 item 9: deep work (Your impact, metric drafts and reads, the morning ✦ checks, core document drafts; the horizon scan keeps its own time)
|
|
59
|
+
// runs at night, DEEP_NIGHT, or at any hour once the PM has been idle for 30 minutes (lib/pm-idle.js). Quiet hours still hold it. Each run's
|
|
60
|
+
// own due rule keeps it to once a day, so a night that ran leaves nothing for the day; a night PMOS was closed is caught up when the PM steps away.
|
|
61
|
+
const DEEP_NIGHT = Object.freeze({ start: '01:00', end: '05:00' });
|
|
62
|
+
const deepOpen = (settings, now, inQuiet, idleMs = require('./pm-idle.js').idleFor(now)) => {
|
|
63
|
+
if (settings && settings.enabled === false) return false;
|
|
64
|
+
if (inQuiet(now, settings && settings.quiet)) return false;
|
|
65
|
+
const t = hhmm(now);
|
|
66
|
+
return (t >= DEEP_NIGHT.start && t < DEEP_NIGHT.end) || idleMs >= require('./pm-idle.js').IDLE_MS;
|
|
67
|
+
};
|
|
58
68
|
|
|
59
69
|
/** The lines of a plain JSONL file that parse; a missing file is empty. */
|
|
60
70
|
function readJsonl(f) {
|
|
@@ -105,6 +115,10 @@ function create(deps) {
|
|
|
105
115
|
for (const p of retNotes) lines.push(`The PM sent back ${p.id} (${p.what}) with this note: "${p.note}". Revise it and file a new proposal.`);
|
|
106
116
|
const mine = [...state.proposals.values()].filter((p) => D.targetKey(p.target) === D.targetKey(target));
|
|
107
117
|
if (mine.length) lines.push(`Proposals so far: ${mine.map((p) => `${p.id} ${p.what} (${p.state})`).join('; ')}. Do not file one again.`);
|
|
118
|
+
// batch 18 item 2b: "Not an overlap" drops the proposal; the pair is never flagged again, from either side
|
|
119
|
+
const notOverlap = [...state.proposals.values()].filter((p) => p.what === 'overlap' && p.state === 'dropped' && p.data && p.target.ws === target.ws
|
|
120
|
+
&& (p.target.id === target.id || p.data.with === target.id)).map((p) => (p.target.id === target.id ? p.data.with : p.target.id));
|
|
121
|
+
if (notOverlap.length) lines.push(`The PM marked these as not an overlap with this initiative: ${[...new Set(notOverlap)].join(', ')}. Do not file an overlap with them.`);
|
|
108
122
|
return lines;
|
|
109
123
|
}
|
|
110
124
|
|
|
@@ -247,4 +261,4 @@ function create(deps) {
|
|
|
247
261
|
return { tick, active: () => [...active.keys()], loginHeld: (now = Date.now()) => !!(loginFailedAt && now - loginFailedAt < LOGIN_HOLD_MS) };
|
|
248
262
|
}
|
|
249
263
|
|
|
250
|
-
module.exports = { create, off, dayCheckOpen, loginFailure, LOGIN_HOLD_MS };
|
|
264
|
+
module.exports = { create, off, dayCheckOpen, deepOpen, DEEP_NIGHT, loginFailure, LOGIN_HOLD_MS };
|
package/workspace/lib/driver.js
CHANGED
|
@@ -50,7 +50,7 @@ const crypto = require('crypto');
|
|
|
50
50
|
const LEDGER = 'driver.jsonl';
|
|
51
51
|
const KINDS = Object.freeze(['initiative', 'work']);
|
|
52
52
|
const WHATS = Object.freeze({
|
|
53
|
-
initiative: Object.freeze(['problem', 'evidence', 'sizing', 'assumption', 'stakeholders', 'move', 'note', 'doc']),
|
|
53
|
+
initiative: Object.freeze(['problem', 'evidence', 'sizing', 'assumption', 'stakeholders', 'move', 'note', 'doc', 'overlap']),
|
|
54
54
|
work: Object.freeze(['next-step', 'follow-up', 'note']),
|
|
55
55
|
});
|
|
56
56
|
// A claim without a pointer is not a proposal (PRD section 2: "Nothing without a pointer").
|
|
@@ -175,6 +175,12 @@ function checkProposal(input) {
|
|
|
175
175
|
if (!e || !CD.draftable(e)) return { ok: false, error: `a doc proposal needs data.key: one of ${CD.SETS.initiative.filter(CD.draftable).map((x) => x.key).join(', ')}` };
|
|
176
176
|
if (typeof data.slot !== 'string' || !SLOT_RE.test(data.slot)) return { ok: false, error: 'a doc proposal needs data.slot: the slot `pmos coredoc write` printed (YYYY-MM-DD, or YYYY-MM-DD-2)' };
|
|
177
177
|
data = { key: data.key, slot: data.slot };
|
|
178
|
+
} else if (i.what === 'overlap') {
|
|
179
|
+
// batch 18 item 2b: a possible overlap with another open initiative. New for you shows both by name, how much overlaps and how sure,
|
|
180
|
+
// and the PM picks Keep both in this order, Merge or Not an overlap (pm/cozy-news.js). Every part but `with` is optional: absent stays absent.
|
|
181
|
+
const c = checkOverlap(data, t.target.id);
|
|
182
|
+
if (!c.ok) return c;
|
|
183
|
+
data = c.data;
|
|
178
184
|
} else if (i.what === 'next-step') {
|
|
179
185
|
if (!oneLine(data.text, 500)) return { ok: false, error: 'a next step needs data.text: one line of up to 500 characters' };
|
|
180
186
|
if (data.due != null && !(typeof data.due === 'string' && DATE_RE.test(data.due))) return { ok: false, error: 'data.due is YYYY-MM-DD' };
|
|
@@ -201,6 +207,29 @@ function checkProposal(input) {
|
|
|
201
207
|
return { ok: true, proposal: { target: t.target, what: i.what, data, why: i.why.trim(), sources, ...(Object.keys(facts).length ? { facts } : {}) } };
|
|
202
208
|
}
|
|
203
209
|
|
|
210
|
+
/** The data of an overlap proposal (batch 18 item 2b). → { ok, data } | { ok: false, error }. Pure. */
|
|
211
|
+
const SURE = Object.freeze(['high', 'medium', 'low']);
|
|
212
|
+
function checkOverlap(d, self) {
|
|
213
|
+
if (typeof d.with !== 'string' || !ID_RE.test(d.with)) return { ok: false, error: 'an overlap needs data.with: the id of the other open initiative' };
|
|
214
|
+
if (d.with === self) return { ok: false, error: 'an overlap is with another initiative, not this one' };
|
|
215
|
+
const out = { with: d.with };
|
|
216
|
+
const n = (v) => Number.isInteger(v) && v >= 0 && v <= 99;
|
|
217
|
+
if (d.parts != null || d.of != null) {
|
|
218
|
+
if (!n(d.parts) || !n(d.of) || d.parts < 1 || d.parts > d.of) return { ok: false, error: 'data.parts and data.of are whole numbers: how many of this plan\'s parts overlap, of how many (1 ≤ parts ≤ of)' };
|
|
219
|
+
out.parts = d.parts; out.of = d.of;
|
|
220
|
+
}
|
|
221
|
+
if (d.items != null) {
|
|
222
|
+
if (!Array.isArray(d.items) || d.items.length > 12 || !d.items.every((x) => oneLine(x, 200))) return { ok: false, error: 'data.items is a list of at most 12 lines: the parts that overlap' };
|
|
223
|
+
out.items = d.items.map((x) => x.trim());
|
|
224
|
+
}
|
|
225
|
+
if (d.sure != null) { if (!SURE.includes(d.sure)) return { ok: false, error: `data.sure is one of ${SURE.join(', ')}` }; out.sure = d.sure; }
|
|
226
|
+
if (d.sureWhy != null) { if (!oneLine(d.sureWhy, 300)) return { ok: false, error: 'data.sureWhy is one line: why you are that sure' }; out.sureWhy = d.sureWhy.trim(); }
|
|
227
|
+
if (d.first != null) { if (d.first !== 'this' && d.first !== 'other') return { ok: false, error: 'data.first is this or other: which one should go first' }; out.first = d.first; }
|
|
228
|
+
if (d.text != null) { if (!oneLine(d.text, 500)) return { ok: false, error: 'data.text is one line: what overlaps, in plain words' }; out.text = d.text.trim(); }
|
|
229
|
+
if (d.firstWhy != null) { if (!oneLine(d.firstWhy, 300)) return { ok: false, error: 'data.firstWhy is one line: why that order' }; out.firstWhy = d.firstWhy.trim(); }
|
|
230
|
+
return { ok: true, data: out };
|
|
231
|
+
}
|
|
232
|
+
|
|
204
233
|
// ── the fold ─────────────────────────────────────────────────────────────────────────────────────────
|
|
205
234
|
function emptyState() {
|
|
206
235
|
return { epoch: null, proposals: new Map(), order: [], paused: new Map(), modes: new Map(), runs: new Map(), bySession: new Map(),
|
|
@@ -449,6 +478,6 @@ function runOfSession(state, token) {
|
|
|
449
478
|
|
|
450
479
|
module.exports = {
|
|
451
480
|
LEDGER, KINDS, WHATS, NEEDS_SOURCE, MODES, DEFAULT_MODE, WAKES, EVENTS, BUDGET, DAY, PM_WAIT_MS, SWEEP_EVERY_MS, DEFAULT_STALLED_DAYS, ID_RE, WS_RE, PROPOSAL_RE, RUN_RE,
|
|
452
|
-
stateDirOf, ledgerFile, append, readLines, newId, checkTarget, checkProposal, fold, modeOf, isPaused, openProposals, runsOnDay, admit, plan,
|
|
481
|
+
stateDirOf, ledgerFile, append, readLines, newId, checkTarget, checkProposal, checkOverlap, fold, modeOf, isPaused, openProposals, runsOnDay, admit, plan,
|
|
453
482
|
detect, sweepLines, wakesFromLedgers, answeredWakes, runOfSession, moveHeld, localDay, targetKey, wsIdOf,
|
|
454
483
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* news-for-you.js — New for you, which replaces the Inbox (initiative premium-uncovered-features, E2; canvas EvInbox, HmAround).
|
|
3
3
|
*
|
|
4
|
-
* build({ inbox, work, seen }) → { count, groups: [{ key, label, items }] } PURE
|
|
4
|
+
* build({ inbox, work, seen, name }) → { count, groups: [{ key, label, items }] } PURE
|
|
5
5
|
* readSeen(runtimeDir) → Set of ids · appendSeen(runtimeDir, ids, now) · badSeen(body) → null | the reason
|
|
6
6
|
*
|
|
7
|
-
* New for you holds items for the PM's information only, in
|
|
7
|
+
* New for you holds items for the PM's information only, in three groups (EvInbox):
|
|
8
|
+
* propose Claude proposes: an agent's possible-overlap note between two open initiatives (batch 18 item 2b, OvA5), with its pick
|
|
8
9
|
* given a task given to the PM: an open Work item that came from a source (Jira, the work breakdown), not one the PM typed
|
|
9
10
|
* finished what the agents finished while the PM was away: the new items of the agent inbox (GET /api/inbox items)
|
|
10
11
|
* An item leaves once it is seen: its id is in <runtime>/news-seen.jsonl. A passed review or a proposal is its initiative's next step, so it
|
|
@@ -15,7 +16,7 @@ const fs = require('fs');
|
|
|
15
16
|
const path = require('path');
|
|
16
17
|
|
|
17
18
|
const SEEN = 'news-seen.jsonl';
|
|
18
|
-
const ID_RE = /^(men|task|prop|goal|work):[^\s]{1,200}$/;
|
|
19
|
+
const ID_RE = /^(men|task|prop|goal|work|fin):[^\s]{1,200}$/; // fin: a draft of Your day's Drafted for you, read and done with (batch 18 item 2)
|
|
19
20
|
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
20
21
|
const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail', wbs: 'Work breakdown', gmail: 'Gmail', figma: 'Figma' };
|
|
21
22
|
const srcName = (s) => SRC[s] || (s ? String(s)[0].toUpperCase() + String(s).slice(1) : '');
|
|
@@ -23,7 +24,7 @@ const FIN = { 'work-draft': 'Draft ready', 'work-stopped': 'Agent stopped', prop
|
|
|
23
24
|
const at = (x) => { const t = Date.parse(x || ''); return Number.isFinite(t) ? t : null; };
|
|
24
25
|
|
|
25
26
|
/** The open Work items that came from a source, from GET /api/pm-items' answer (its five lists). */
|
|
26
|
-
function givenItems(v, seen) {
|
|
27
|
+
function givenItems(v, seen, name) {
|
|
27
28
|
const w = (v && v.work) || {}, out = [], had = new Set();
|
|
28
29
|
for (const k of ['inbox', 'today', 'upcoming', 'waiting', 'someday']) for (const it of w[k] || []) {
|
|
29
30
|
if (!it || !it.id || it.done || had.has(it.id)) continue;
|
|
@@ -31,24 +32,38 @@ function givenItems(v, seen) {
|
|
|
31
32
|
if (!(it.assigned === true || (src !== 'local' && src !== 'brief' && src !== 'work'))) continue;
|
|
32
33
|
had.add(it.id);
|
|
33
34
|
if (seen.has('task:' + it.id)) continue;
|
|
35
|
+
const a = it.agent && typeof it.agent === 'object' ? it.agent : null;
|
|
34
36
|
out.push({ id: 'task:' + it.id, kind: 'task', tid: it.id, title: clip('New task: ' + (it.title || it.key || it.id), 160), from: srcName(src), key: it.key || '',
|
|
35
|
-
due: it.due || null, initiative: it.initiative || null, link: it.url || it.link || null, at: at(it.created_at)
|
|
37
|
+
due: it.due || null, initiative: it.initiative || null, iniTitle: (it.initiative && name(it.initiative)) || '', link: it.url || it.link || null, at: at(it.created_at),
|
|
38
|
+
status: it.status || '', list: k, why: clip(it.why, 300),
|
|
39
|
+
// the agent on it, only what really ran or is offered (batch 18 item 2, OvA6): ready with its draft's summary, working, or the suggestion
|
|
40
|
+
agent: a && ['suggest', 'queued', 'working', 'sending', 'ready', 'failed'].includes(a.state)
|
|
41
|
+
? { state: a.state, suggest: clip(a.suggest, 200), draft: a.draft && a.draft.summary ? clip(a.draft.summary, 300) : '' } : null });
|
|
36
42
|
}
|
|
37
43
|
return out;
|
|
38
44
|
}
|
|
45
|
+
/** An agent's possible-overlap note (batch 18 item 2b, OvA5): a ✦ Claude proposes item, never a given task. Both initiatives by name. */
|
|
46
|
+
function overlapItem(x, name) {
|
|
47
|
+
const o = x.overlap, a = x.target || {};
|
|
48
|
+
return { id: x.id, kind: 'overlap', title: 'Possible overlap', pid: x.pid, ws: x.pws || x.ws || '', product: x.product || '', at: Number.isFinite(x.at) ? x.at : null, why: clip(x.why, 500),
|
|
49
|
+
a: { id: a.id, title: a.title && a.title !== a.id ? a.title : name(a.id, x.pws) || '' }, b: { id: o.with, title: name(o.with, x.pws) || '' }, overlap: o };
|
|
50
|
+
}
|
|
39
51
|
function finishedItems(inbox, seen) {
|
|
40
52
|
const items = inbox && inbox.ok !== false && Array.isArray(inbox.items) ? inbox.items : [];
|
|
41
|
-
return items.filter((x) => x && x.id && !seen.has(x.id)).map((x) => ({
|
|
53
|
+
return items.filter((x) => x && x.id && !x.overlap && !seen.has(x.id)).map((x) => ({
|
|
42
54
|
id: x.id, kind: 'finished', what: FIN[x.kind] || 'Finished', title: clip(x.title, 160), product: x.product || '', target: x.target && x.target.title ? x.target.title : '',
|
|
43
55
|
at: Number.isFinite(x.at) ? x.at : null, open: x.open || '', pws: x.pws || '', session: x.session || '', agentKind: x.kind || '',
|
|
44
56
|
}));
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
/** The groups, newest first in each; an empty group is left out. inbox: GET /api/inbox; work: GET /api/pm-items
|
|
48
|
-
|
|
59
|
+
/** The groups, newest first in each; an empty group is left out. inbox: GET /api/inbox; work: GET /api/pm-items; name(id, ws?) → an initiative's
|
|
60
|
+
* title, or '' (an id is never shown). */
|
|
61
|
+
function build({ inbox = null, work = null, seen = new Set(), name = () => '' } = {}) {
|
|
49
62
|
const by = (a, b) => (b.at || 0) - (a.at || 0);
|
|
63
|
+
const ib = inbox && inbox.ok !== false && Array.isArray(inbox.items) ? inbox.items : [];
|
|
50
64
|
const groups = [
|
|
51
|
-
{ key: '
|
|
65
|
+
{ key: 'propose', label: 'Claude proposes', items: ib.filter((x) => x && x.id && x.overlap && x.overlap.with && !seen.has(x.id)).map((x) => overlapItem(x, name)).sort(by) },
|
|
66
|
+
{ key: 'given', label: 'Given to you', items: givenItems(work, seen, name).sort(by) },
|
|
52
67
|
{ key: 'finished', label: 'Finished while you were away', items: finishedItems(inbox, seen).sort(by) },
|
|
53
68
|
].filter((g) => g.items.length);
|
|
54
69
|
return { count: groups.reduce((n, g) => n + g.items.length, 0), groups, read: { inbox: !!(inbox && inbox.ok !== false), work: !!(work && work.ok !== false) } };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* pm-idle.js — how long the PM has been away from PMOS (feedback batch 18 item 9).
|
|
3
|
+
*
|
|
4
|
+
* The server calls touch() on every page press (a request that carries the launch nonce, so never an agent session) and on every key the
|
|
5
|
+
* PM types into a terminal. idleFor(now) is the time since the last of those, counted from when the server started. Deep work (lib/driver-run.js
|
|
6
|
+
* deepOpen) starts during the day only after IDLE_MS of it. Memory only: a restart counts as activity.
|
|
7
|
+
*/
|
|
8
|
+
const IDLE_MS = 30 * 60 * 1000;
|
|
9
|
+
let last = Date.now();
|
|
10
|
+
const touch = (now = Date.now()) => { if (now > last) last = now; };
|
|
11
|
+
const idleFor = (now = Date.now()) => Math.max(0, now - last);
|
|
12
|
+
module.exports = { IDLE_MS, touch, idleFor };
|
package/workspace/lib/refresh.js
CHANGED
|
@@ -39,24 +39,26 @@ const SOURCES = Object.freeze([
|
|
|
39
39
|
{ id: 'calendar', label: 'Calendar', group: 'tools', ic: 'cal', run: 'skill', skill: 'calendar-sync', how: 'tool', fresh: 'calendar',
|
|
40
40
|
what: 'Events from your calendars, for Calendar, the phone day, meeting focus and meeting notes.', uses: [],
|
|
41
41
|
impact: 'Calendar, the phone day, meeting focus, meeting notes and the Briefing\'s Today card show the last import.',
|
|
42
|
-
def: { kind: '
|
|
42
|
+
def: { kind: 'every', every: '30', work: true } },
|
|
43
43
|
{ id: 'jira', label: 'Jira tickets and sprints', group: 'tools', ic: 'org', run: 'skill', skill: 'jira-sync', how: 'tool', fresh: 'jira', copy: 'jira',
|
|
44
44
|
what: 'The status of every pushed ticket, the active sprints, and each sprint\'s goal and team summary.', uses: [],
|
|
45
45
|
impact: 'Tickets keep their last status. Sprint summaries stop. The initiative driver cannot see ticket moves or blocked tickets, core documents write the sprint review from old data, and report drafts say Jira was not checked.',
|
|
46
|
-
def: { kind: '
|
|
46
|
+
def: { kind: 'every', every: '60', work: true } },
|
|
47
47
|
{ id: 'mywork', label: 'Work assigned to you', group: 'tools', ic: 'todo', run: 'skill', skill: 'my-work-read', how: 'tool', fresh: 'my-work', copy: 'mywork',
|
|
48
48
|
what: 'Jira tickets assigned to you, for the Work page and the Briefing.', uses: [],
|
|
49
49
|
impact: 'The Work page and the Briefing keep the last list of work assigned to you.',
|
|
50
|
-
def: { kind: '
|
|
50
|
+
def: { kind: 'every', every: '60', work: true } },
|
|
51
51
|
{ id: 'tracker', label: 'Tracker files', group: 'tools', ic: 'sheet', run: 'skill', skill: 'tracker-refresh', how: 'code', fresh: 'tracker',
|
|
52
52
|
what: 'Plan items brought up to date from the tracker files in the workspace.', uses: [],
|
|
53
53
|
impact: 'The bi-weekly report says the tracker was not refreshed.',
|
|
54
54
|
def: { kind: 'weekly', day: 'Fri', times: ['15:30'] } },
|
|
55
55
|
// briefing-source-flow: the brief is derived content, so it reads these saved reads instead of the tools (lib/source-reads.js)
|
|
56
56
|
{ id: 'tools', label: 'Your tools', group: 'tools', ic: 'inbox', run: 'skill', skill: 'sources-read', how: 'tool', fresh: 'tools',
|
|
57
|
-
what: 'Mail, Slack, Wispr Flow, Confluence, GitHub, Drive, Figma and your websites, saved as they are for the Briefing. It runs before the morning briefing.', uses: [],
|
|
57
|
+
what: 'Mail, Slack, Wispr Flow, Confluence, GitHub, Drive, Figma and your websites, saved as they are for the Briefing. It runs every hour in working hours, and before the morning briefing.', uses: [],
|
|
58
58
|
impact: 'The Briefing is built from the last saved read of your tools.',
|
|
59
|
-
|
|
59
|
+
// batch 18 items 7 + 9: once a day before the brief made the read 8 h old every afternoon, with nothing to read it again; every hour in
|
|
60
|
+
// working hours keeps it inside its stale window (lib/freshness.js stale_after_ms), so the amber line means a read really failed
|
|
61
|
+
def: { kind: 'every', every: '60', work: true } },
|
|
60
62
|
{ id: 'brief', label: 'Morning briefing', group: 'pmos', ic: 'sun', run: 'skill', skill: 'morning-brief', how: 'bg',
|
|
61
63
|
what: 'Your Briefing for the day, ranked by what needs you first. When it is due, the sources it is built on that are older than 2 hours are refreshed first.', uses: ['calendar', 'jira', 'mywork', 'tools'],
|
|
62
64
|
impact: 'No new Briefing for the day, and the day check has nothing to update.',
|
|
@@ -72,7 +74,7 @@ const SOURCES = Object.freeze([
|
|
|
72
74
|
{ id: 'scan', label: 'Horizon scan', group: 'pmos', ic: 'search', run: 'job', how: 'bg', setIn: 'Initiatives, Horizon scan',
|
|
73
75
|
what: 'Reads the web and your repositories for changes that matter to your initiatives.', uses: ['repo'],
|
|
74
76
|
impact: 'Core documents cite the older scan.' },
|
|
75
|
-
{ id: 'coredocs', label: 'Core documents', group: 'pmos', ic: 'doc', run: 'job', how: 'bg', fixed: '
|
|
77
|
+
{ id: 'coredocs', label: 'Core documents', group: 'pmos', ic: 'doc', run: 'job', how: 'bg', fixed: 'At night, or when you are away for 30 min; each document at most once a day',
|
|
76
78
|
what: 'Drafts the portfolio, board and initiative documents that are due, old or missing.', uses: ['repo', 'jira', 'scan'],
|
|
77
79
|
impact: 'The initiative driver no longer sees documents that are due or old.' },
|
|
78
80
|
{ id: 'driver', label: 'Initiative driver', group: 'pmos', ic: 'bolt', run: 'job', how: 'bg', fixed: 'Every 30 min in working hours, and when an initiative moves',
|
|
@@ -95,6 +97,12 @@ const BY_ID = new Map(SOURCES.map((s) => [s.id, s]));
|
|
|
95
97
|
const SKILL_OF = new Map(SOURCES.filter((s) => s.skill).map((s) => [s.skill, s.id]));
|
|
96
98
|
const usedBy = (id) => SOURCES.filter((s) => s.uses.includes(id)).map((s) => s.id);
|
|
97
99
|
|
|
100
|
+
// batch 18 items 7 + 9: the quick reads moved to "often, in working hours". A schedule still on its default from before (OLD_DEFS) moves to
|
|
101
|
+
// the new default once; the `cadence` mark is then saved with the settings, so a schedule the PM picks after this release stays as picked.
|
|
102
|
+
const CADENCE = 1;
|
|
103
|
+
const OLD_DEFS = Object.freeze({ calendar: { kind: 'daily', times: ['06:30', '12:30'] }, jira: { kind: 'daily', times: ['06:30'] }, mywork: { kind: 'manual' }, tools: { kind: 'manual' } });
|
|
104
|
+
const sameSchedule = (a, b) => !!a && !!b && a.kind === b.kind && String(a.every || '') === String(b.every || '') && String(a.day || '') === String(b.day || '') && (a.times || []).join() === (b.times || []).join();
|
|
105
|
+
|
|
98
106
|
const RULE_DEFAULTS = Object.freeze({ catchup: true, retry: '15', tell: 'brief', max: '3', keep: '90' });
|
|
99
107
|
const RULE_OPTS = Object.freeze({ retry: ['15', '60', 'no'], tell: ['brief', 'here'], max: ['1', '2', '3', '5'], keep: ['30', '90', '365', 'forever'] });
|
|
100
108
|
|
|
@@ -180,13 +188,14 @@ function withDefaults(raw) {
|
|
|
180
188
|
// briefing-source-flow: Your tools feeds the brief, so until the PM sets it, it is on whenever the brief is
|
|
181
189
|
if ((src.id === 'tools' || src.id === 'leads') && typeof x.on !== 'boolean') on = !!(r.sources && r.sources.brief && r.sources.brief.on === true); // the popup leads follow the reads the same way
|
|
182
190
|
const n = src.run === 'skill' && x.s ? normalize(src, x.s) : null;
|
|
191
|
+
if (n && n.ok && !(r.cadence >= CADENCE) && sameSchedule(n.s, OLD_DEFS[src.id])) n.ok = false; // an old default moves to the new one (above)
|
|
183
192
|
sources[src.id] = { on, s: n && n.ok ? n.s : (src.def ? { ...src.def, ...(src.def.times ? { times: src.def.times.slice() } : {}) } : null), ws: typeof x.ws === 'string' ? x.ws : null };
|
|
184
193
|
}
|
|
185
194
|
const rules = { ...RULE_DEFAULTS };
|
|
186
195
|
const rr = r.rules || {};
|
|
187
196
|
if (typeof rr.catchup === 'boolean') rules.catchup = rr.catchup;
|
|
188
197
|
for (const k of Object.keys(RULE_OPTS)) if (RULE_OPTS[k].includes(String(rr[k]))) rules[k] = String(rr[k]);
|
|
189
|
-
return { sources, rules, migrated: !!r.migrated };
|
|
198
|
+
return { sources, rules, migrated: !!r.migrated, cadence: CADENCE };
|
|
190
199
|
}
|
|
191
200
|
/** Check a rules patch. → { ok, patch } | { ok: false, error } */
|
|
192
201
|
function normalizeRules(p) {
|
|
@@ -417,7 +426,7 @@ function writeJson(f, v) {
|
|
|
417
426
|
const tmp = `${f}.${process.pid}.tmp`; fs.writeFileSync(tmp, JSON.stringify(v, null, 1) + '\n'); fs.renameSync(tmp, f);
|
|
418
427
|
}
|
|
419
428
|
const readSettings = (dir) => withDefaults(readJson(files(dir).settings, null));
|
|
420
|
-
const writeSettings = (dir, s) => writeJson(files(dir).settings, { sources: s.sources, rules: s.rules, migrated: !!s.migrated });
|
|
429
|
+
const writeSettings = (dir, s) => writeJson(files(dir).settings, { sources: s.sources, rules: s.rules, migrated: !!s.migrated, ...(s.cadence ? { cadence: s.cadence } : {}) });
|
|
421
430
|
const readState = (dir) => { const s = readJson(files(dir).state, {}); return s && typeof s === 'object' && !Array.isArray(s) ? s : {}; };
|
|
422
431
|
const writeState = (dir, s) => writeJson(files(dir).state, s);
|
|
423
432
|
|
|
@@ -133,7 +133,7 @@ function tick(ctx, { now = Date.now(), force = false } = {}) {
|
|
|
133
133
|
if (!ctx || typeof ctx.getWs !== 'function') return [];
|
|
134
134
|
if (!force && lastTick != null && now - lastTick < TICK_EVERY_MS) return [];
|
|
135
135
|
const settings = (() => { try { return ctx.proSettings ? ctx.proSettings() : null; } catch { return null; } })();
|
|
136
|
-
const open = require('./driver-run.js').dayCheckOpen(settings || {}, now, ctx.inQuiet || (() => false));
|
|
136
|
+
const open = ctx.deepOpen ? ctx.deepOpen(settings || {}, now) : require('./driver-run.js').dayCheckOpen(settings || {}, now, ctx.inQuiet || (() => false)); // batch 18 item 9: at night or when idle
|
|
137
137
|
if (!open) return [];
|
|
138
138
|
lastTick = now;
|
|
139
139
|
if (headless.switchedOff(process.env) || /^(off|0|false|no)$/i.test(String(process.env.PMOS_CORE_DOCS || ''))) return []; // PMOS_CORE_DOCS=off: no scheduled drafts
|
|
@@ -18,6 +18,20 @@ async function ask(mod, req, ctx, p) {
|
|
|
18
18
|
return body;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/** name(id, ws?) → an initiative's title from the products the Briefing reads (lib/initiative-rows.js peek: the cache only, never a
|
|
22
|
+
* derivation), or '' when it is not known: New for you never shows an id (batch 18 item 2). */
|
|
23
|
+
function namesOf(ctx) {
|
|
24
|
+
const by = new Map();
|
|
25
|
+
let av = [];
|
|
26
|
+
try { av = require('./routes-briefing-premium.js').products(ctx).available || []; } catch { av = []; }
|
|
27
|
+
const rows = require('./initiative-rows.js');
|
|
28
|
+
for (const a of av) {
|
|
29
|
+
if (!a || !a.root) continue;
|
|
30
|
+
try { const r = rows.peek(a.root); if (r && r.ok) for (const x of r.rows) if (x && x.id && x.title) { by.set(a.ws + '|' + x.id, x.title); if (!by.has('|' + x.id)) by.set('|' + x.id, x.title); } } catch { /* its titles stay unknown */ }
|
|
31
|
+
}
|
|
32
|
+
return (id, ws) => (id ? by.get((ws || '') + '|' + id) || by.get('|' + id) || '' : '');
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
module.exports = {
|
|
22
36
|
prefixes: ['/api/news-for-you'],
|
|
23
37
|
handle: async (req, res, url, ctx) => {
|
|
@@ -44,7 +58,7 @@ module.exports = {
|
|
|
44
58
|
ask('./routes-inbox.js', req, ctx, '/api/inbox'),
|
|
45
59
|
ask('./routes-pm-items.js', req, ctx, '/api/pm-items'),
|
|
46
60
|
]);
|
|
47
|
-
const out = News.build({ inbox, work: work && work.ok !== false ? work : null, seen: ctx.runtimeDir ? News.readSeen(ctx.runtimeDir) : new Set() });
|
|
61
|
+
const out = News.build({ inbox, work: work && work.ok !== false ? work : null, seen: ctx.runtimeDir ? News.readSeen(ctx.runtimeDir) : new Set(), name: namesOf(ctx) });
|
|
48
62
|
ctx.json(res, { ok: true, ...out });
|
|
49
63
|
return true;
|
|
50
64
|
},
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* READ ONLY, and built only from what PMOS already holds. Nothing is invented. The companion reads it for three moments:
|
|
7
7
|
* finished working hours, "Finished for you": the agent's tasks of today's day run (goals/<date>.run.json, lib/day-run.js) that have a
|
|
8
|
-
* draft. { id, title, summary, body, at, status, link, source
|
|
8
|
+
* draft. { id, title, summary, body, at, status, link, source, key, seen }; key is the draft's seen id (fin:<date>:<id>) and seen is true
|
|
9
|
+
* once the PM pressed "Done with it" (POST /api/news-for-you/seen); body keeps its lines (markdown, at most 8000 characters); status 'review' (waits for the PM's approval at the desk),
|
|
9
10
|
* 'done' (an auto task) or 'sent'. Newest first, at most 5.
|
|
10
11
|
* recap evening: how the day went. meetings = today's meetings that have ended; decided = the decisions of today's meetings that
|
|
11
12
|
* the PM CONFIRMED in the meeting's Replay (lib/meeting-points.js); to_confirm = the decisions caught in today's notes that
|
|
@@ -57,7 +58,7 @@ function runOf(run) {
|
|
|
57
58
|
failed: T.filter((t) => t.status === 'failed').slice(0, 3).map((t) => ({ id: t.id, title: clip(t.title, 200), error: clip(t.error, 200) })) };
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
/** deps: { events, items, run, notes: [note with final_notes], adapter, points: (noteId) → { [pointId]: 'confirmed' | 'wrong' } }
|
|
61
|
+
/** deps: { events, items, run, notes: [note with final_notes], adapter, points: (noteId) → { [pointId]: 'confirmed' | 'wrong' }, seen: Set of seen ids }
|
|
61
62
|
* notes are today's non-private notes, read in full. A decision's point id is the Replay's (lib/meeting-replay.js): d1, d2, … in caughtOf order. */
|
|
62
63
|
function build(query, deps = {}) {
|
|
63
64
|
const q = query || {};
|
|
@@ -66,7 +67,8 @@ function build(query, deps = {}) {
|
|
|
66
67
|
const today = localDate(now);
|
|
67
68
|
const events = deps.events || []; const items = deps.items || [];
|
|
68
69
|
const agenda = todayAgenda(events, items, now, deps.adapter || {});
|
|
69
|
-
|
|
70
|
+
// seen: the PM pressed "Done with it" in the Finished Viewer (batch 18 item 2, OvA7); its key is New for you's seen id for a draft
|
|
71
|
+
const finished = finishedOf(deps.run).map((t) => { const key = 'fin:' + today + ':' + t.id; return { ...t, key, seen: !!(deps.seen && deps.seen.has(key)) }; });
|
|
70
72
|
const decisions = []; let toConfirm = 0;
|
|
71
73
|
for (const n of deps.notes || []) {
|
|
72
74
|
if (!n || n.private) continue;
|
|
@@ -115,7 +117,7 @@ module.exports = {
|
|
|
115
117
|
const today = localDate(now);
|
|
116
118
|
const events = dir ? require('./calendar-events.js').readAll(dir, { now: now.getTime() }) : [];
|
|
117
119
|
const items = dir ? pmItems.fold(pmItems.readLines(path.join(dir, 'pm-items', 'items.jsonl'))) : [];
|
|
118
|
-
const out = build({ now: now.toISOString() }, { events, items, run: dir ? readRun(dir, today) : null, notes: dir ? todaysNotes(dir, today) : [], adapter: dir ? notesAdapter(dir) : {}, points: (id) => meetingPoints.pointsOf(dir, id) });
|
|
120
|
+
const out = build({ now: now.toISOString() }, { events, items, run: dir ? readRun(dir, today) : null, notes: dir ? todaysNotes(dir, today) : [], adapter: dir ? notesAdapter(dir) : {}, points: (id) => meetingPoints.pointsOf(dir, id), seen: dir ? require('./news-for-you.js').readSeen(dir) : null });
|
|
119
121
|
ctx.json(res, out.body, out.status);
|
|
120
122
|
} catch (e) {
|
|
121
123
|
ctx.json(res, { ok: false, error: 'your day could not be read: ' + (e && e.message ? e.message : String(e)) }, 500);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* need-shot.js — screenshots of the asks in the Viewer (batch 18 item 2-A, OvA1Start … OvA12Edges) at 1440x900 and 390x844, light and dark,
|
|
4
|
+
* against the Briefing's fixture model with a source row and the owner and goal a record holds. Not a suite: a look at the page.
|
|
5
|
+
* OUT=<dir> names where the PNGs go (default: the state folder of this run). */
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { spawn } = require('child_process');
|
|
9
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
10
|
+
const T = require('./test-run').configure({ name: 'need-shot' });
|
|
11
|
+
const B = require('./lib/briefing-premium.js');
|
|
12
|
+
const F = require('./fixtures/briefing-premium-facts.js');
|
|
13
|
+
const OUT = process.env.OUT || T.STATE_DIR;
|
|
14
|
+
|
|
15
|
+
function model() {
|
|
16
|
+
const M = B.build(F.facts());
|
|
17
|
+
const rows = M.list.rows;
|
|
18
|
+
const b = rows.find((r) => r.key === 'blocked:console-3-boards');
|
|
19
|
+
Object.assign(b.detail, { owner: 'pm:wawan', goal: { kind: 'kr', title: 'Lift premium sign-ups' } });
|
|
20
|
+
b.dialog.write.what = 'author the PRD (skills/core/prd.skill) with its done-criteria (D13), then set prd_path';
|
|
21
|
+
const nb = rows.find((r) => r.key === 'blocked:onboarding-scan');
|
|
22
|
+
delete nb.dialog.write;
|
|
23
|
+
rows.push({ kind: 'source', key: 'src:mail-1', title: 'Pricing copy sign-off', subject: 'Mail · Dion · mentions you', prepared: 'Sign off: the paywall copy', skip: 'Why now: copy freezes Thursday.',
|
|
24
|
+
product: 'Across products', from: ['brief:mail-1'], detail: { source: 'mail' },
|
|
25
|
+
dialog: { eye: 'Mail', say: 'Dion asks for your sign-off on the paywall copy before the Thursday freeze. Two lines changed since you last read it.', facts: [['Source', 'Mail'], ['From', 'Dion'], ['Asked', 'Sign off on the paywall copy'], ['Due', 'Thursday']], link: 'https://mail.example/t/1', linkLabel: 'Open in Mail', opts: [] } });
|
|
26
|
+
rows.push({ kind: 'source', key: 'src:mail-2', title: 'Budget question from Anna', subject: 'Mail · Anna Lee', skip: 'Why now: the budget closes Friday.', product: 'Across products', from: ['brief:mail-2'], detail: { source: 'mail' }, unread: { source: 'Mail', date: '2026-10-28' },
|
|
27
|
+
dialog: { eye: 'Mail', say: 'Anna asks which line the tooling cost goes under.', facts: [['From', 'Anna Lee']], link: 'https://mail.example/t/2', opts: [] } });
|
|
28
|
+
return M;
|
|
29
|
+
}
|
|
30
|
+
(async () => {
|
|
31
|
+
const { chromium } = require('playwright-core');
|
|
32
|
+
const srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
33
|
+
await T.waitForServer(T.BASE);
|
|
34
|
+
const browser = await chromium.launch({ executablePath: findBrowser() });
|
|
35
|
+
const M = model();
|
|
36
|
+
const errs = [];
|
|
37
|
+
const keys = (process.env.KEYS || 'blocked:console-3-boards,blocked:onboarding-scan,decision:premium-ux,decision:KC5,waited:reviews,src:mail-1,src:mail-2').split(',');
|
|
38
|
+
const sizes = process.env.SIZES === 'desk' ? [[1440, 900, 'desk']] : [[1440, 900, 'desk'], [390, 844, 'phone']];
|
|
39
|
+
for (const [w, h, name] of sizes) for (const theme of (process.env.THEMES || 'light,dark').split(',')) {
|
|
40
|
+
for (const key of keys) {
|
|
41
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: theme });
|
|
42
|
+
const body = JSON.stringify({ ok: true, model: M, as_of: Date.now() });
|
|
43
|
+
await ctx.route('**/api/briefing-premium?*', (r) => r.fulfill({ contentType: 'application/json', body }));
|
|
44
|
+
await ctx.route('**/api/briefing-premium', (r) => r.fulfill({ contentType: 'application/json', body }));
|
|
45
|
+
const p = await ctx.newPage();
|
|
46
|
+
p.on('pageerror', (e) => errs.push(name + ' ' + key + ': ' + e.message));
|
|
47
|
+
await p.goto(T.BASE + '/premium.html?theme=' + theme + '&open=' + encodeURIComponent(key));
|
|
48
|
+
await p.waitForSelector('#czViewer:not([hidden]) .nv', { timeout: 20000 }).catch(() => errs.push(name + ' ' + key + ': no ask Viewer'));
|
|
49
|
+
await p.waitForTimeout(600);
|
|
50
|
+
fs.mkdirSync(OUT, { recursive: true });
|
|
51
|
+
await p.screenshot({ path: path.join(OUT, 'need-' + key.replace(/[^a-z0-9]+/gi, '-') + '-' + name + '-' + theme + '.png') });
|
|
52
|
+
await ctx.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
console.log(errs.join('\n') || 'no page errors');
|
|
56
|
+
await browser.close(); srv.kill('SIGKILL'); T.killTmux(); process.exit(0);
|
|
57
|
+
})();
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* news-viewers-test.js — New for you's item Viewers and the Finished Viewer (feedback batch 18 items 2 and 2b, slice 2-B; canvas In
|
|
4
|
+
* development OvA5Overlap, OvA6Given, OvA7Drafted). A real server on a scratch repository (c3-scan-fixture.js). The real Home runs at
|
|
5
|
+
* 390 and 1440 wide; GET /api/news-for-you, /api/boards/initiative and /api/phone-day are answered in the browser, so each Viewer has
|
|
6
|
+
* one overlap note, one task given to the PM and one finished draft. The POSTs are caught and answered, never sent.
|
|
7
|
+
* O the overlap note · G a task given to you · F the Finished Viewer from Your day's Drafted for you · D dark and desk widths
|
|
8
|
+
* Set NEWS_VIEWER_SHOTS=<dir> to save screenshots. */
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
12
|
+
require('./test-run').configure({ name: 'news-viewers' });
|
|
13
|
+
const Fx = require('./c3-scan-fixture.js');
|
|
14
|
+
|
|
15
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
16
|
+
const until = async (fn, ms = 15000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
17
|
+
const results = [];
|
|
18
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
|
|
19
|
+
let F = null, browser = null;
|
|
20
|
+
const finish = async (code) => {
|
|
21
|
+
if (browser) await browser.close().catch(() => {});
|
|
22
|
+
if (F) F.stop();
|
|
23
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
24
|
+
console.log(`\n${results.length - bad}/${results.length} news-viewers assertions passed`);
|
|
25
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
26
|
+
};
|
|
27
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
28
|
+
const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
|
|
29
|
+
|
|
30
|
+
const NOW = Date.now();
|
|
31
|
+
const due = (() => { const d = new Date(NOW + 2 * 864e5); return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`; })();
|
|
32
|
+
const OVERLAP = { id: 'prop:wsx:p-0123456789', kind: 'overlap', title: 'Possible overlap', pid: 'p-0123456789', ws: 'WS', product: 'PSLE', at: NOW - 3600e3, why: 'Both change the checkout entry.',
|
|
33
|
+
a: { id: 'psle-article-paywall-lock', title: 'PSLE Article Paywall Lock' }, b: { id: 'psle-companion-addon-follow-on', title: 'PSLE Companion Add-on Follow-on' },
|
|
34
|
+
overlap: { with: 'psle-companion-addon-follow-on', parts: 2, of: 6, sure: 'high', sureWhy: 'Both plans name the same checkout screens.', first: 'this', text: 'Both change the checkout entry and the return after payment. The rest is separate.', items: ['The checkout entry', 'The return after payment'] } };
|
|
35
|
+
const LEGACY = { ...OVERLAP, id: 'prop:wsx:p-aaaaaaaaaa', pid: 'p-aaaaaaaaaa', b: { id: 'psle-companion-addon-follow-on', title: '' }, overlap: { with: 'psle-companion-addon-follow-on', first: 'this' }, why: '' };
|
|
36
|
+
const TASK = { id: 'task:jira:PAY-7', kind: 'task', tid: 'jira:PAY-7', title: 'New task: Review the paywall copy', from: 'Jira', key: 'PAY-7', due, initiative: 'psle-article-paywall-lock', iniTitle: 'PSLE Article Paywall Lock',
|
|
37
|
+
link: 'https://jira.example/PAY-7', at: NOW - 7200e3, status: 'To do', list: 'inbox', why: '', agent: { state: 'suggest', suggest: 'Draft your comments from the thread', draft: '' } };
|
|
38
|
+
const ROWS = { 'psle-article-paywall-lock': { title: 'PSLE Article Paywall Lock', stage: 'Discover', owner: 'you' }, 'psle-companion-addon-follow-on': { title: 'PSLE Companion Add-on Follow-on', stage: 'Plan', owner: 'Mei' } };
|
|
39
|
+
|
|
40
|
+
(async () => {
|
|
41
|
+
const exe = findBrowser();
|
|
42
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
43
|
+
let chromium;
|
|
44
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
45
|
+
F = await Fx.start({ name: 'news-viewers' });
|
|
46
|
+
const ws = F.ws;
|
|
47
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
48
|
+
const shotDir = process.env.NEWS_VIEWER_SHOTS;
|
|
49
|
+
if (shotDir) fs.mkdirSync(shotDir, { recursive: true });
|
|
50
|
+
const shot = async (p, name) => { if (shotDir) await p.screenshot({ path: path.join(shotDir, name + '.png') }); };
|
|
51
|
+
|
|
52
|
+
async function page({ width = 390, scheme = 'light', items = [OVERLAP, TASK], fin = null, fail = {} } = {}) {
|
|
53
|
+
const ctx = await browser.newContext({ viewport: { width, height: 844 }, colorScheme: scheme });
|
|
54
|
+
const p = await ctx.newPage(), posts = [], errs = [];
|
|
55
|
+
p.on('pageerror', (e) => errs.push(String(e)));
|
|
56
|
+
const news = () => { const o = items.filter((x) => x.kind === 'overlap'), t = items.filter((x) => x.kind === 'task');
|
|
57
|
+
const groups = [o.length && { key: 'propose', label: 'Claude proposes', items: o }, t.length && { key: 'given', label: 'Given to you', items: t }].filter(Boolean);
|
|
58
|
+
return { ok: true, count: o.length + t.length, groups, read: { inbox: true, work: true } }; };
|
|
59
|
+
await p.route('**/api/news-for-you', (r) => json(r, news()));
|
|
60
|
+
await p.route('**/api/news-for-you?*', (r) => json(r, news()));
|
|
61
|
+
await p.route('**/api/boards/initiative?*', (r) => { const id = new URL(r.request().url()).searchParams.get('id'); const row = ROWS[id]; return row ? json(r, { ok: true, ws: 'WS', row: { id, ...row }, board: { id: 'b1' } }) : json(r, { ok: false, error: 'no row' }, 404); });
|
|
62
|
+
if (fin) await p.route('**/api/phone-day*', (r) => (fin.read = (fin.read || 0) + 1, json(r, { ok: true, date: '', finished: fin.filter((x) => !x.seen), run: null, recap: { meetings: 0, decided: 0, done: 0, finished: fin.length, moved: [] }, tomorrow: { label: 'Tomorrow', meetings: [] } })));
|
|
63
|
+
for (const route of ['/api/driver/keep', '/api/driver/drop', '/api/boards/notdup', '/api/my-work/act', '/api/pm-items/done', '/api/pm-items/notyet', '/api/news-for-you/seen']) {
|
|
64
|
+
await p.route('**' + route, (r) => { let b = null; try { b = JSON.parse(r.request().postData() || 'null'); } catch { b = null; } posts.push({ path: route, body: b });
|
|
65
|
+
if (route === '/api/news-for-you/seen' && fin) for (const f of fin) if (b && b.ids && b.ids.includes(f.key)) f.seen = true;
|
|
66
|
+
return fail[route] ? json(r, { ok: false, error: fail[route] }, 409) : json(r, { ok: true }); });
|
|
67
|
+
}
|
|
68
|
+
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
|
|
69
|
+
await until(() => p.evaluate(() => !!document.querySelector('#hmList')));
|
|
70
|
+
return { p, ctx, posts, errs };
|
|
71
|
+
}
|
|
72
|
+
const vwText = (p) => p.evaluate(() => (document.querySelector('#czViewer:not([hidden])') || {}).textContent || '');
|
|
73
|
+
const openItem = (p, id) => p.evaluate((x) => import('/pm/cozy-news.js').then((M) => { M.openNews({ view: x }); }), id);
|
|
74
|
+
|
|
75
|
+
/* O — the overlap note */
|
|
76
|
+
{
|
|
77
|
+
const { p, ctx, posts, errs } = await page();
|
|
78
|
+
await openItem(p, OVERLAP.id);
|
|
79
|
+
const shown = await until(() => p.evaluate(() => /Plan · Mei’s/.test((document.querySelector('#czViewer') || {}).textContent || '')));
|
|
80
|
+
const t = await vwText(p);
|
|
81
|
+
ok('O1 the overlap opens as its own Viewer: one header named "Possible overlap", Claude noticed, no second back press', shown && /Possible overlap/.test(await p.evaluate(() => document.querySelector('#czVwTitle').textContent)) && /Claude noticed/.test(t)
|
|
82
|
+
&& !(await p.evaluate(() => !!document.querySelector('#czViewer [data-ev-back]'))), t.slice(0, 300));
|
|
83
|
+
ok('O2 both initiatives by name with stage and owner, first and second; never a slug or "a source"', /PSLE Article Paywall Lock/.test(t) && /Discover · yours/.test(t) && /Plan · Mei’s/.test(t) && /1st/.test(t) && /2nd/.test(t)
|
|
84
|
+
&& !/psle-companion-addon-follow-on|a source|Open in Home/.test(t), t);
|
|
85
|
+
ok('O3 the summary: "2 of 6 parts overlap", the sentence and how sure', /2 of 6 parts overlap/.test(t) && /The rest is separate/.test(t) && /How sure: high\. Both plans name the same checkout screens/.test(t), t);
|
|
86
|
+
const picks = await p.evaluate(() => [...document.querySelectorAll('#czViewer [data-nv-pick]')].map((b) => b.getAttribute('aria-checked') + ':' + b.textContent.trim().slice(0, 60)));
|
|
87
|
+
ok('O4 the pick: Keep both, in this order (Claude\'s, checked), Merge into the first, Not an overlap', picks.length === 3 && /^true:Keep both, in this order/.test(picks[0]) && /Merge into PSLE Article Paywall Lock/.test(picks[1]) && /^false:Not an overlap/.test(picks[2]), picks);
|
|
88
|
+
const fold = await p.evaluate(() => { const b = document.querySelector('#czViewer .czs-row[data-czs-fold="parts"]'); return b ? b.textContent : ''; });
|
|
89
|
+
ok('O5 the parts that overlap fold under the pick', /The 2 parts that overlap/.test(fold), fold);
|
|
90
|
+
const tight = await p.evaluate(() => { const s = document.scrollingElement; return s.scrollWidth <= s.clientWidth + 1 && [...document.querySelectorAll('#czViewer .nv-opt, #czViewer .nv-ini, #czViewer .nv-pri')].every((b) => b.getBoundingClientRect().height >= 44); });
|
|
91
|
+
ok('O6 at 390 px nothing scrolls sideways, and every press is at least 44 px tall', tight);
|
|
92
|
+
await shot(p, 'overlap-390');
|
|
93
|
+
await p.click('#czViewer [data-nv-go]');
|
|
94
|
+
await until(() => posts.some((x) => x.path === '/api/driver/keep'));
|
|
95
|
+
const keep = posts.find((x) => x.path === '/api/driver/keep');
|
|
96
|
+
ok('O7 the primary keeps both: POST /api/driver/keep with the workspace and the proposal, then it is seen', keep && keep.body.ws === 'WS' && keep.body.proposal === OVERLAP.pid && await until(() => posts.some((x) => x.path === '/api/news-for-you/seen' && x.body.ids.includes(OVERLAP.id))), JSON.stringify(posts));
|
|
97
|
+
// Not an overlap: the proposal is dropped and the Board stops flagging the pair
|
|
98
|
+
await openItem(p, OVERLAP.id);
|
|
99
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-nv-pick="not"]')));
|
|
100
|
+
await until(() => p.evaluate(() => /Mei’s/.test(document.querySelector('#czViewer').textContent)));
|
|
101
|
+
await p.click('#czViewer [data-nv-pick="not"]');
|
|
102
|
+
const lbl = await p.evaluate(() => document.querySelector('#czViewer [data-nv-go]').textContent);
|
|
103
|
+
ok('O8 the primary follows the pick', /Not an overlap/.test(lbl), lbl);
|
|
104
|
+
await p.click('#czViewer [data-nv-go]');
|
|
105
|
+
await until(() => posts.some((x) => x.path === '/api/boards/notdup'));
|
|
106
|
+
const drop = posts.find((x) => x.path === '/api/driver/drop'), nd = posts.find((x) => x.path === '/api/boards/notdup');
|
|
107
|
+
ok('O9 Not an overlap drops the note and marks the pair not a duplicate on the Board', drop && drop.body.proposal === OVERLAP.pid && nd && nd.body.id === OVERLAP.a.id && nd.body.of === OVERLAP.b.id && nd.body.board === 'b1', JSON.stringify(posts));
|
|
108
|
+
ok('O10 no page error', !errs.length, errs.join(' | '));
|
|
109
|
+
await ctx.close();
|
|
110
|
+
}
|
|
111
|
+
/* O11 — an older note: only what its words say; the name comes from the Board, never the slug; no parts, no "how sure" invented */
|
|
112
|
+
{
|
|
113
|
+
const { p, ctx, errs } = await page({ items: [LEGACY] });
|
|
114
|
+
await openItem(p, LEGACY.id);
|
|
115
|
+
await until(() => p.evaluate(() => /Mei’s/.test((document.querySelector('#czViewer') || {}).textContent || '')));
|
|
116
|
+
const t = await vwText(p);
|
|
117
|
+
ok('O11 an older "Note: Possible overlap" names both by name, keeps its order and invents no parts or certainty', /PSLE Companion Add-on Follow-on/.test(t) && !/parts overlap|How sure/.test(t) && /1st/.test(t) && !/psle-companion/.test(t), t);
|
|
118
|
+
ok('O12 no page error', !errs.length, errs.join(' | '));
|
|
119
|
+
await ctx.close();
|
|
120
|
+
}
|
|
121
|
+
/* G — a task given to you */
|
|
122
|
+
{
|
|
123
|
+
const { p, ctx, posts, errs } = await page();
|
|
124
|
+
await openItem(p, TASK.id);
|
|
125
|
+
await until(() => p.evaluate(() => /Review the paywall copy/.test((document.querySelector('#czVwTitle') || {}).textContent || '')));
|
|
126
|
+
const t = await vwText(p);
|
|
127
|
+
ok('G1 the task: its own title (no "New task:"), from Jira, due in words, never "a source" or "Open in Home"', !/New task:/.test(t) && /From Jira/.test(t) && /Due /.test(t) && !/a source|Open in Home/.test(t), t);
|
|
128
|
+
ok('G2 the agent\'s part is its offer, not a claim: "I can draft your comments…" with Draft it as the one primary', /I can draft your comments from the thread\./.test(t) && /Draft it/.test(await p.evaluate(() => (document.querySelector('#czViewer .czs-pri') || {}).textContent || '')) && !/I drafted/.test(t), t);
|
|
129
|
+
const icons = await p.evaluate(() => [...document.querySelectorAll('#czViewer .czs-ib')].map((b) => b.getAttribute('aria-label')));
|
|
130
|
+
ok('G3 Done, Not before… and ↗ Jira sit in place as icons', icons.join('|') === 'Done|Not before…|Open in Jira', icons);
|
|
131
|
+
ok('G4 Filed under names the initiative, not its id', /Filed under/.test(t) && /PSLE Article Paywall Lock/.test(t) && !/psle-article/.test(t), t);
|
|
132
|
+
await shot(p, 'given-390');
|
|
133
|
+
await p.click('#czViewer .czs-pri');
|
|
134
|
+
await until(() => posts.some((x) => x.path === '/api/my-work/act'));
|
|
135
|
+
const act = posts.find((x) => x.path === '/api/my-work/act');
|
|
136
|
+
const t2 = await until(() => p.evaluate(() => (/drafting it now/.test(document.querySelector('#czViewer').textContent) ? document.querySelector('#czViewer').textContent : '')));
|
|
137
|
+
ok('G5 Draft it starts the agent on the item (POST /api/my-work/act brief), then says it is drafting', act && act.body.action === 'brief' && act.body.item === TASK.tid && t2, JSON.stringify(act));
|
|
138
|
+
await p.click('#czViewer [data-czs-act="later"]');
|
|
139
|
+
await p.click('#czViewer [data-nv-when="tomorrow"]');
|
|
140
|
+
await until(() => posts.some((x) => x.path === '/api/pm-items/notyet'));
|
|
141
|
+
const ny = posts.find((x) => x.path === '/api/pm-items/notyet');
|
|
142
|
+
ok('G6 Not before… › Tomorrow puts it off on the real item', ny && ny.body.id === TASK.tid && ny.body.when === 'tomorrow', JSON.stringify(ny));
|
|
143
|
+
ok('G7 no page error', !errs.length, errs.join(' | '));
|
|
144
|
+
await ctx.close();
|
|
145
|
+
}
|
|
146
|
+
/* F — the Finished Viewer from Your day's Drafted for you */
|
|
147
|
+
{
|
|
148
|
+
const fin = [{ id: 't-0123456789ab', key: 'fin:today:t-0123456789ab', title: 'Project Ascent status summary', summary: 'Where the tender stands, and what the TC decides.', body: '## Where the tender stands\nTwo of three vendors cleared the security review.\n\n## What the TC decides\nVendor B on cost, or vendor A on support.', at: new Date(new Date().setHours(8, 10, 0, 0)).toISOString(), status: 'done', link: null, seen: false }];
|
|
149
|
+
const { p, ctx, posts, errs } = await page({ items: [], fin });
|
|
150
|
+
// Home reads the day with the list: Your day opens once that read is in
|
|
151
|
+
await until(() => fin.read);
|
|
152
|
+
await sleep(800);
|
|
153
|
+
await p.click('[data-hm-day]');
|
|
154
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-yd="fin"]')));
|
|
155
|
+
await p.evaluate(() => { const f = document.querySelector('#czViewer [data-czs-fold="drafts"]'); if (f && f.getAttribute('aria-expanded') !== 'true') f.click(); });
|
|
156
|
+
await p.click('#czViewer [data-yd="fin"]');
|
|
157
|
+
await until(() => p.evaluate(() => /Project Ascent status summary/.test((document.querySelector('#czVwTitle') || {}).textContent || '')));
|
|
158
|
+
const t = await vwText(p);
|
|
159
|
+
ok('F1 the finished row opens the draft to read: Finished, nothing sent, the text as a document', /Finished · this morning/.test(t) && /Nothing is sent/.test(t) && await p.evaluate(() => /Two of three vendors/.test((document.querySelector('#czViewer article.hv-doc') || {}).textContent || '')), t.slice(0, 300));
|
|
160
|
+
const pri = await p.evaluate(() => [...document.querySelectorAll('#czViewer .czs-pri')].map((b) => b.textContent));
|
|
161
|
+
ok('F2 ONE primary, "Done with it"; the chat icon "Change it in chat" is in the header; no bare "Open it"', pri.join('|') === 'Done with it' && await p.evaluate(() => !!document.querySelector('#czViewer [data-cz-vw-p="chat"][aria-label="Change it in chat"]')) && !/Open it$/.test(t), pri);
|
|
162
|
+
await shot(p, 'finished-390');
|
|
163
|
+
await p.click('#czViewer .czs-pri');
|
|
164
|
+
await until(() => posts.some((x) => x.path === '/api/news-for-you/seen'));
|
|
165
|
+
const seen = posts.find((x) => x.path === '/api/news-for-you/seen');
|
|
166
|
+
const gone = await until(() => p.evaluate(() => { const c = document.querySelector('#czViewer'); return c && /Your day/.test(document.querySelector('#czVwTitle').textContent) && !c.querySelector('[data-yd="fin"]'); }));
|
|
167
|
+
if (!gone) console.log(await p.evaluate(() => document.querySelector('#czVwTitle').textContent + ' | ' + !!document.querySelector('#czViewer [data-yd="fin"]')));
|
|
168
|
+
ok('F3 Done with it marks the draft seen and it leaves Drafted for you', seen && seen.body.ids[0] === fin[0].key && gone, JSON.stringify(seen));
|
|
169
|
+
ok('F4 no page error', !errs.length, errs.join(' | '));
|
|
170
|
+
await ctx.close();
|
|
171
|
+
}
|
|
172
|
+
/* D — dark and desk */
|
|
173
|
+
{
|
|
174
|
+
const { p, ctx, errs } = await page({ width: 1440, scheme: 'dark' });
|
|
175
|
+
await openItem(p, OVERLAP.id);
|
|
176
|
+
await until(() => p.evaluate(() => /Mei’s/.test((document.querySelector('#czViewer') || {}).textContent || '')));
|
|
177
|
+
const c = await p.evaluate(() => { const b = document.querySelector('#czViewer .nv-opt.on'); return b ? getComputedStyle(b).backgroundColor : ''; });
|
|
178
|
+
ok('D1 at 1440 px dark, the overlap Viewer draws beside the chat with the picked choice tinted', c && c !== 'rgb(255, 255, 255)' && !errs.length, c + ' ' + errs.join(' | '));
|
|
179
|
+
await shot(p, 'overlap-1440-dark');
|
|
180
|
+
await ctx.close();
|
|
181
|
+
}
|
|
182
|
+
finish();
|
|
183
|
+
})();
|