create-pmos 0.440.0 → 0.442.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 +25 -25
- 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/adler-seasons-art-test.js +106 -0
- package/workspace/adler-seasons-test.js +111 -0
- package/workspace/briefing-premium-adddoc-test.js +16 -13
- package/workspace/briefing-premium-board-test.js +19 -17
- package/workspace/briefing-premium-initiative-test.js +7 -4
- 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 +24 -0
- package/workspace/guide/adler.md +10 -0
- package/workspace/guide/core-documents.md +2 -2
- package/workspace/guide/data-freshness.md +7 -5
- package/workspace/guide/home.md +3 -1
- package/workspace/guide/horizon-scan.md +1 -1
- package/workspace/ini-workflow-test.js +6 -2
- 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/lib/settings-store.js +38 -0
- package/workspace/metric-drafts-ui-test.js +2 -2
- 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-board-actions-test.js +2 -1
- package/workspace/premium-chat-attach-test.js +2 -0
- package/workspace/premium-core-doc-issue-test.js +9 -8
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-ini-panel.js +6 -13
- package/workspace/public/pm/c3-ini-ui.js +1 -1
- package/workspace/public/pm/cozy-adler.css +21 -0
- package/workspace/public/pm/cozy-adler.js +415 -8
- package/workspace/public/pm/cozy-ev.css +44 -0
- package/workspace/public/pm/cozy-home.css +8 -0
- package/workspace/public/pm/cozy-news.js +186 -22
- package/workspace/public/pm/cozy-seasons.js +318 -0
- package/workspace/public/pm/cozy-settings.js +88 -5
- package/workspace/public/pm/cozy-today.css +5 -0
- package/workspace/public/pm/cozy-viewer.js +12 -7
- package/workspace/public/pm/cozy-vw-shell.css +49 -0
- package/workspace/public/pm/cozy.css +65 -0
- package/workspace/public/pm/dash-view.js +4 -2
- package/workspace/public/pm/home-adddoc.js +46 -26
- package/workspace/public/pm/home-app.js +142 -114
- package/workspace/public/pm/home-chat.js +1 -1
- package/workspace/public/pm/home-day.js +17 -9
- package/workspace/public/pm/home-draft.js +35 -23
- package/workspace/public/pm/home-ini.js +4 -4
- package/workspace/public/pm/home-mentions.js +1 -1
- 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/impact.js +1 -1
- package/workspace/public/pm/ini-groups.js +15 -10
- package/workspace/public/pm/ini-links.js +1 -1
- package/workspace/public/pm/ini-tasks.js +208 -44
- package/workspace/public/pm/ini-view-model.js +8 -2
- package/workspace/public/pm/ini-view.css +305 -1
- package/workspace/public/pm/ini-view.js +190 -80
- package/workspace/public/pm/mission.js +234 -0
- package/workspace/public/pm/premium-board.js +1 -1
- package/workspace/public/pm/premium-welcome.js +2 -2
- package/workspace/public/pm/small-vw.js +128 -0
- package/workspace/public/pm/split-merge.js +1 -1
- package/workspace/public/pm/stage-line.js +2 -2
- package/workspace/server.js +10 -6
- package/workspace/skills/initiative-drive.skill +4 -1
- package/workspace/split-merge-ui-test.js +1 -1
- package/workspace/stage-card-test.js +48 -11
- package/workspace/task-links-test.js +2 -0
- package/workspace/task-milestones-test.js +5 -1
- package/workspace/task-plans-test.js +3 -3
- package/workspace/task-views-test.js +90 -37
- package/workspace/test-lists/adler-seasons-art.json +13 -0
- package/workspace/test-lists/batch18-adler-seasons.json +13 -0
- package/workspace/test-lists/batch18-asks.json +5 -0
- package/workspace/test-lists/mission.json +5 -0
- package/workspace/test-lists/news-viewers.json +13 -0
- package/workspace/test-lists/small-viewers.json +5 -0
- package/workspace/test-lists/viewer-tasks.json +5 -0
- package/workspace/tk-tasks-test.js +25 -30
|
@@ -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);
|
|
@@ -76,6 +76,24 @@ const DEFS = Object.freeze({
|
|
|
76
76
|
'adler.motion': one('adler', 'computer', ['system', 'still'], 'system'),
|
|
77
77
|
'adler.celebrate': one('adler', 'computer', ['real', 'never'], 'real'),
|
|
78
78
|
'adler.quiet': one('adler', 'computer', ['22', 'never'], '22'),
|
|
79
|
+
// Settings > Adler > Dress for the day (feedback batch 18 item 8, canvas AsSet1): the calendar that dresses him (pm/cozy-seasons.js keeps
|
|
80
|
+
// the same defaults in DRESS_DEFAULTS). place '' and climate auto read the computer. days: one switch per day of "More festivals",
|
|
81
|
+
// skip: "Not this one" (a day's key to the year it stays off), wear: Movie night or Music for one day, until midnight.
|
|
82
|
+
'adler.dress.on': bool('adler', 'computer', true),
|
|
83
|
+
'adler.dress.place': { section: 'adler', scope: 'computer', type: 'country', def: '' },
|
|
84
|
+
'adler.dress.climate': one('adler', 'computer', ['auto', 'tropics', 'north', 'south'], 'auto'),
|
|
85
|
+
'adler.dress.holidays': bool('adler', 'computer', true),
|
|
86
|
+
'adler.dress.seasons': bool('adler', 'computer', true),
|
|
87
|
+
'adler.dress.science': bool('adler', 'computer', true),
|
|
88
|
+
'adler.dress.school': bool('adler', 'computer', true),
|
|
89
|
+
'adler.dress.sports': bool('adler', 'computer', false),
|
|
90
|
+
'adler.dress.colors': { section: 'adler', scope: 'computer', type: 'colors', def: ['blue', 'green'] },
|
|
91
|
+
'adler.dress.exam': bool('adler', 'computer', false),
|
|
92
|
+
'adler.dress.pmosday': bool('adler', 'computer', true),
|
|
93
|
+
'adler.dress.birthday': { section: 'adler', scope: 'computer', type: 'monthday', def: '' },
|
|
94
|
+
'adler.dress.days': { section: 'adler', scope: 'computer', type: 'dayswitches', def: {} },
|
|
95
|
+
'adler.dress.skip': { section: 'adler', scope: 'computer', type: 'dayyears', def: {} },
|
|
96
|
+
'adler.dress.wear': { section: 'adler', scope: 'computer', type: 'wear', def: null },
|
|
79
97
|
// Settings > General > Your impact (feedback batch 16 item 7, canvas GmP1Switch): the one switch. Off hides every impact surface, Adler's
|
|
80
98
|
// leaf included, and stops the daily impact run (lib/routes-impact.js, lib/impact-runs.js).
|
|
81
99
|
'impact.on': bool('general', 'computer', true),
|
|
@@ -93,6 +111,8 @@ const ENV = Object.freeze([
|
|
|
93
111
|
]);
|
|
94
112
|
|
|
95
113
|
const WS_ID = /^[A-Za-z0-9_-]{1,80}$/;
|
|
114
|
+
const DRESS_COLORS = Object.freeze(['blue', 'red', 'white', 'gold', 'green', 'ink']);
|
|
115
|
+
const DAY_KEY = /^[a-z]{2,16}$/;
|
|
96
116
|
const clone = (v) => (v && typeof v === 'object' ? JSON.parse(JSON.stringify(v)) : v);
|
|
97
117
|
const fileOf = (stateDir, ws) => (ws ? path.join(stateDir, 'settings-ws', ws + '.json') : path.join(stateDir, 'settings.json'));
|
|
98
118
|
|
|
@@ -138,6 +158,24 @@ function validate(key, value) {
|
|
|
138
158
|
}
|
|
139
159
|
// ['*'] alone is every workspace (the product picker's All, lib/briefing-premium-products.js)
|
|
140
160
|
case 'ids': return value === null || Array.isArray(value) && (value.length === 1 && value[0] === '*' || value.length <= d.max && value.every((x) => typeof x === 'string' && WS_ID.test(x)) && new Set(value).size === value.length) ? null : `${key} must list at most ${d.max} workspace ids, each once, or ['*'] for every one`;
|
|
161
|
+
// Dress for the day (pm/cozy-seasons.js): a day's key is its charm key, as in DAYS there
|
|
162
|
+
case 'country': return value === '' || typeof value === 'string' && /^[A-Z]{2}$/.test(value) ? null : `${key} must be a two-letter country code, or empty for this computer's`;
|
|
163
|
+
case 'colors': return Array.isArray(value) && value.length === 2 && value.every((c) => DRESS_COLORS.includes(c)) ? null : `${key} must be two of ${DRESS_COLORS.join(', ')}`;
|
|
164
|
+
case 'monthday': {
|
|
165
|
+
if (value === '') return null;
|
|
166
|
+
const m = typeof value === 'string' && /^(\d{2})-(\d{2})$/.exec(value);
|
|
167
|
+
return m && +m[1] >= 1 && +m[1] <= 12 && +m[2] >= 1 && +m[2] <= [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][+m[1] - 1] ? null : `${key} must be a month and day such as 03-14, or empty`;
|
|
168
|
+
}
|
|
169
|
+
case 'dayswitches': case 'dayyears': {
|
|
170
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return `${key} must map a day to ${d.type === 'dayswitches' ? 'true or false' : 'a year'}`;
|
|
171
|
+
const es = Object.entries(value);
|
|
172
|
+
const good = (v) => (d.type === 'dayswitches' ? typeof v === 'boolean' : Number.isInteger(v) && v >= 2000 && v <= 2200);
|
|
173
|
+
return es.length <= 60 && es.every(([k, v]) => DAY_KEY.test(k) && good(v)) ? null : `${key} must map at most 60 days to ${d.type === 'dayswitches' ? 'true or false' : 'a year'}`;
|
|
174
|
+
}
|
|
175
|
+
case 'wear': {
|
|
176
|
+
if (value === null) return null;
|
|
177
|
+
return value && typeof value === 'object' && ['movie', 'music'].includes(value.key) && typeof value.day === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value.day) && Object.keys(value).length === 2 ? null : `${key} must be null or { key: movie or music, day: YYYY-MM-DD }`;
|
|
178
|
+
}
|
|
141
179
|
case 'order': {
|
|
142
180
|
// pm/order-model.js keeps a layout this small (trim)
|
|
143
181
|
const SORTS = ['mine', 'turn', 'date', 'stage', 'name'];
|
|
@@ -151,10 +151,10 @@ const INITIATIVE = () => ({
|
|
|
151
151
|
await until(() => p.evaluate(() => { const b = document.querySelector('#czViewer [data-czs-fold="tree"]'); if (b && b.getAttribute('aria-expanded') !== 'true') b.click(); return !!document.querySelector('#czViewer button.pp-open[data-ini="descope-parity"]'); }));
|
|
152
152
|
await p.click('#czViewer button.pp-open[data-ini="descope-parity"]');
|
|
153
153
|
const ic = await until(() => p.evaluate(() => { const c = document.querySelector('#czViewer .iv .md-card'); if (!c) return null;
|
|
154
|
-
return { after: !!(c.previousElementSibling && c.previousElementSibling.classList.contains('iv-
|
|
154
|
+
return { after: !!c.closest('.iv-cl') && !!(c.previousElementSibling && c.previousElementSibling.classList.contains('iv-card')), hd: c.querySelector('.md-hd b').textContent, src: c.querySelector('.md-src').textContent,
|
|
155
155
|
rows: [...c.querySelectorAll('.md-mr')].map((r) => [r.querySelector('.md-role').textContent, r.querySelector('.md-nm b').textContent, (r.querySelector('small') || {}).textContent || '', r.querySelector('.md-now').textContent, r.querySelector('.md-to').textContent].join(' | ')),
|
|
156
156
|
why: c.querySelector('.md-why').textContent, presses: [...c.querySelectorAll('.md-ft .md-ib')].map((b) => ({ label: b.getAttribute('aria-label'), title: b.getAttribute('title'), text: b.textContent.trim(), solid: b.classList.contains('solid'), href: b.getAttribute('href') || '' })) }; }));
|
|
157
|
-
ok('I the proposed success measure sits under the
|
|
157
|
+
ok('I the proposed success measure sits under the card, with where it came from', !!ic && ic.after && ic.hd === 'Proposed success measure' && ic.src === 'from the PRD and the desktop launch', JSON.stringify(ic));
|
|
158
158
|
ok('I three groups in order, each Now → Target', !!ic && ic.rows.join(' / ') === 'Proves it worked · 4 weeks after release | Mobile checkout login drop-off | Moves your key result “drop-off under 15%” | 27% | 19% / Early signal · shows in days | Inline form completion | Ticket ESHOP-981 drafted | — | 80% week 1 / Guardrail | Checkout conversion | A faster login must not cost orders | 3.1% | ≥ 3.1%', ic && ic.rows.join(' / '));
|
|
159
159
|
ok('I one line of why', !!ic && /^Desktop fell 7 points/.test(ic.why));
|
|
160
160
|
ok('I Edit (in place, batch 16) and a solid ✓ Keep this success measure: icon-only, each with a label and a title', !!ic && ic.presses.map((x) => x.label).join() === 'Edit the proposed success measure,Keep this success measure'
|
|
@@ -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
|
+
})();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.442.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.442.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|