create-pmos 0.610.0 → 0.611.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.
Files changed (114) hide show
  1. package/package.json +50 -14
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/board-columns-test.js +2 -1
  7. package/workspace/board-deliveries-test.js +2 -1
  8. package/workspace/board-programs-test.js +7 -3
  9. package/workspace/board-publish-ui-test.js +2 -1
  10. package/workspace/board-shared-ui-test.js +2 -1
  11. package/workspace/board-workflows-test.js +2 -1
  12. package/workspace/briefing-premium-board-test.js +3 -2
  13. package/workspace/briefing-premium-doc-edit-test.js +2 -1
  14. package/workspace/briefing-premium-insights-test.js +4 -3
  15. package/workspace/briefing-premium-test.js +3 -2
  16. package/workspace/calm-timeline-test.js +2 -1
  17. package/workspace/changelog.json +49 -0
  18. package/workspace/core-docs-workflow-test.js +2 -1
  19. package/workspace/ev-everywhere-test.js +3 -2
  20. package/workspace/guide/home.md +2 -2
  21. package/workspace/guide/index.md +4 -0
  22. package/workspace/guide/layout.md +62 -2
  23. package/workspace/guide/programs.md +16 -2
  24. package/workspace/guide/routine.md +50 -0
  25. package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
  26. package/workspace/guide/settings-and-switches.md +1 -1
  27. package/workspace/impact-screens-test.js +3 -1
  28. package/workspace/ini-workflow-test.js +2 -1
  29. package/workspace/lib/classic-board.js +15 -0
  30. package/workspace/lib/events-place.js +216 -0
  31. package/workspace/lib/library-items.js +78 -0
  32. package/workspace/lib/notes.js +6 -1
  33. package/workspace/lib/route-modules.js +4 -0
  34. package/workspace/lib/routes-events-place.js +166 -0
  35. package/workspace/lib/routes-library.js +89 -0
  36. package/workspace/lib/routes-pop-work.js +39 -0
  37. package/workspace/lib/routes-report-setups.js +20 -0
  38. package/workspace/lib/routes-today-log.js +48 -0
  39. package/workspace/lib/routine-reports.js +52 -0
  40. package/workspace/lib/today-log.js +131 -0
  41. package/workspace/live-pill-round-test.js +10 -7
  42. package/workspace/metric-drafts-ui-test.js +3 -1
  43. package/workspace/milestone-pins-test.js +2 -1
  44. package/workspace/milestone-suggest-test.js +3 -1
  45. package/workspace/package-lock.json +2 -2
  46. package/workspace/package.json +1 -1
  47. package/workspace/panels-test.js +2 -1
  48. package/workspace/premium-board-actions-test.js +3 -1
  49. package/workspace/premium-rec-tab-test.js +2 -1
  50. package/workspace/premium-vw-backlog-test.js +3 -1
  51. package/workspace/premium-vw-item-test.js +3 -1
  52. package/workspace/premium-vw-jira-test.js +3 -1
  53. package/workspace/product-lane-test.js +2 -1
  54. package/workspace/program-charter-test.js +3 -1
  55. package/workspace/program-leave-test.js +2 -1
  56. package/workspace/program-order-test.js +2 -1
  57. package/workspace/program-panel-test.js +3 -1
  58. package/workspace/public/pm/bd-ini-panel.js +72 -7
  59. package/workspace/public/pm/bd-prog-panel.js +55 -8
  60. package/workspace/public/pm/bd-work.css +130 -0
  61. package/workspace/public/pm/bd-work.js +356 -0
  62. package/workspace/public/pm/cozy-ev.css +2 -1
  63. package/workspace/public/pm/cozy-events-view.js +142 -0
  64. package/workspace/public/pm/cozy-events.css +107 -0
  65. package/workspace/public/pm/cozy-events.js +210 -0
  66. package/workspace/public/pm/cozy-evmodel.js +1 -1
  67. package/workspace/public/pm/cozy-library.css +36 -0
  68. package/workspace/public/pm/cozy-live-pill.js +1 -0
  69. package/workspace/public/pm/cozy-nav.js +5 -5
  70. package/workspace/public/pm/cozy-pop-work.css +165 -0
  71. package/workspace/public/pm/cozy-pop-work.js +427 -0
  72. package/workspace/public/pm/cozy-routine-model.js +111 -0
  73. package/workspace/public/pm/cozy-routine-pop.js +196 -0
  74. package/workspace/public/pm/cozy-routine.css +102 -0
  75. package/workspace/public/pm/cozy-routine.js +156 -0
  76. package/workspace/public/pm/cozy-schedwork.js +6 -5
  77. package/workspace/public/pm/cozy-today-app.js +236 -0
  78. package/workspace/public/pm/cozy-today-model.js +176 -0
  79. package/workspace/public/pm/cozy-today-page.css +100 -0
  80. package/workspace/public/pm/cozy-today-view.js +76 -0
  81. package/workspace/public/pm/home-app.js +18 -3
  82. package/workspace/public/pm/home-ini.js +36 -5
  83. package/workspace/public/pm/library-model.js +69 -0
  84. package/workspace/public/pm/library-open.js +34 -0
  85. package/workspace/public/pm/pop-work-model.js +335 -0
  86. package/workspace/public/pm/premium-board.js +130 -8
  87. package/workspace/public/pm/premium-library.js +122 -0
  88. package/workspace/public/premium-board.html +1 -0
  89. package/workspace/public/premium-events.html +42 -0
  90. package/workspace/public/premium-library.html +31 -0
  91. package/workspace/public/premium-routine.html +31 -0
  92. package/workspace/public/today.html +50 -0
  93. package/workspace/ready-dash-ui-test.js +3 -1
  94. package/workspace/rename-test.js +2 -1
  95. package/workspace/run-tests.js +4 -1
  96. package/workspace/server.js +3 -2
  97. package/workspace/sort-order-test.js +2 -1
  98. package/workspace/split-merge-ui-test.js +3 -1
  99. package/workspace/stage-card-tasks-test.js +3 -1
  100. package/workspace/stage-card-test.js +2 -1
  101. package/workspace/task-delete-test.js +2 -1
  102. package/workspace/task-links-test.js +2 -1
  103. package/workspace/task-milestones-test.js +4 -2
  104. package/workspace/task-plans-test.js +3 -1
  105. package/workspace/task-press-test.js +3 -1
  106. package/workspace/task-views-test.js +3 -1
  107. package/workspace/test-lists/events-place.json +11 -0
  108. package/workspace/test-lists/library-place.json +9 -0
  109. package/workspace/test-lists/pop-work.json +9 -0
  110. package/workspace/test-lists/routine-place.json +9 -0
  111. package/workspace/test-lists/today-log.json +9 -0
  112. package/workspace/test-lists/work-view.json +9 -0
  113. package/workspace/timeline-holds-test.js +3 -1
  114. package/workspace/tk-tasks-test.js +2 -1
@@ -0,0 +1,166 @@
1
+ 'use strict';
2
+ /* routes-events-place.js — the Events place (slice 6 of the six-place navigation, initiative events-place).
3
+ *
4
+ * GET /api/events-place → 200 { ok, state: 'ready', today, items, later, missing } | 202 { ok, state: 'reading' }
5
+ * every date PMOS holds, as lib/events-place.js build() makes it: each product's Board model (GET /api/board-premium, the route the
6
+ * Board reads: milestones, plan ends, tasks, forecasts), the calendar (lib/calendar-events.js), the report schedules and the drafts
7
+ * that wait (lib/report-needs.js), and the PM's own items (lib/pm-items.js). While a Board is still being read the answer is 202 and
8
+ * the page asks again. A source that cannot be read is named in `missing`, never read as nothing.
9
+ * POST /api/events-place/mark { key, fixed } → { ok } a date is fixed (true) or not (false): Events never offers it a new date
10
+ * POST /api/events-place/mark { sig, no } → { ok } the PM said no to a suggestion (no: true), or took the no back (no: false)
11
+ *
12
+ * STATE. <runtime>/events/marks.jsonl, append-only, one line per press: { at, by, kind: fixed | unfixed | no | unno, key | sig }. The fold
13
+ * keeps the last line of each key or sig. Writes pass pm-guard requirePagePress: the page only. Every other write of Events (✓ on a
14
+ * suggestion, a new day, +) goes through the routes that already make it: /api/boards/tasks/state, /api/boards/tasks/edit, /api/pm-items/*. */
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const EP = require('./events-place.js');
18
+
19
+ const MAX_LEN = 400;
20
+ const pad = (n) => String(n).padStart(2, '0');
21
+ const localDay = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
22
+ const reason = (e) => String((e && e.message) || e).slice(0, 160);
23
+
24
+ /* ── the marks ── */
25
+ const marksFile = (runtimeDir) => path.join(runtimeDir, 'events', 'marks.jsonl');
26
+ /** The marks folded: { fixed: Set<key>, declined: Set<sig> }. PURE over the lines. */
27
+ function foldMarks(lines) {
28
+ const fixed = new Map(), no = new Map();
29
+ for (const l of lines || []) {
30
+ if (!l || typeof l !== 'object') continue;
31
+ if ((l.kind === 'fixed' || l.kind === 'unfixed') && typeof l.key === 'string') fixed.set(l.key, l.kind === 'fixed');
32
+ if ((l.kind === 'no' || l.kind === 'unno') && typeof l.sig === 'string') no.set(l.sig, l.kind === 'no');
33
+ }
34
+ return { fixed: new Set([...fixed].filter(([, v]) => v).map(([k]) => k)), declined: new Set([...no].filter(([, v]) => v).map(([k]) => k)) };
35
+ }
36
+ function readMarks(runtimeDir) {
37
+ let text = '';
38
+ try { text = fs.readFileSync(marksFile(runtimeDir), 'utf8'); } catch { return foldMarks([]); }
39
+ return foldMarks(text.split('\n').filter(Boolean).map((s) => { try { return JSON.parse(s); } catch { return null; } }));
40
+ }
41
+ /** One mark line from a page press body, or { error }. PURE. */
42
+ function markLine(body, by, at) {
43
+ const b = body && typeof body === 'object' && !Array.isArray(body) ? body : {};
44
+ const okStr = (s) => typeof s === 'string' && s.length > 0 && s.length <= MAX_LEN;
45
+ if (okStr(b.key) && typeof b.fixed === 'boolean') return { at, by, kind: b.fixed ? 'fixed' : 'unfixed', key: b.key };
46
+ if (okStr(b.sig) && typeof b.no === 'boolean') return { at, by, kind: b.no ? 'no' : 'unno', sig: b.sig };
47
+ return { error: 'send { key, fixed: true | false } or { sig, no: true | false }' };
48
+ }
49
+
50
+ /* ── the readers ── */
51
+ async function via(mod, pathAndQuery, req, ctx) {
52
+ let out = { status: 500, body: null };
53
+ const c = Object.assign({}, ctx, { json: (res, obj, code) => { out = { status: code || 200, body: obj }; } });
54
+ const handled = await mod.handle({ method: 'GET', headers: (req && req.headers) || {} }, {}, new URL('http://local' + pathAndQuery), c);
55
+ return handled === false ? { status: 404, body: null } : out;
56
+ }
57
+ /** Every product's Board model, the way the Board's All products reads them: { state: 'reading' } | { boards, missing }. */
58
+ async function readBoards(req, ctx) {
59
+ const BPR = require('./routes-board-premium.js');
60
+ const first = await via(BPR, '/api/board-premium', req, ctx);
61
+ if (first.status === 202 || (first.body && first.body.state === 'reading')) return { state: 'reading' };
62
+ if (!first.body || !first.body.ok || !first.body.model) return { boards: [], missing: ['the boards'] };
63
+ const home = first.body.model;
64
+ const nameOf = (m) => (m.board && (m.board.product || m.board.name)) || '';
65
+ const rowsOf = (m) => (m.initiatives && m.initiatives.list && m.initiatives.list.rows) || [];
66
+ const boards = [{ ws: home.board.ws || '', id: home.board.id || '', name: nameOf(home), rows: rowsOf(home) }];
67
+ const missing = [];
68
+ const others = (home.board.switcher || []).filter((b) => !(b.ws === home.board.ws && b.id === home.board.id));
69
+ const q = (b) => '?ws=' + encodeURIComponent(b.ws) + '&board=' + encodeURIComponent(b.id);
70
+ const got = await Promise.all(others.map((b) => via(BPR, '/api/board-premium' + q(b), req, ctx)));
71
+ if (got.some((g) => g.status === 202 || (g.body && g.body.state === 'reading'))) return { state: 'reading' };
72
+ got.forEach((g, i) => {
73
+ if (g.body && g.body.ok && g.body.model) boards.push({ ws: others[i].ws, id: others[i].id, name: nameOf(g.body.model) || others[i].name, rows: rowsOf(g.body.model) });
74
+ else missing.push((others[i].name || others[i].ws) + ' board');
75
+ });
76
+ return { boards, missing };
77
+ }
78
+ /** The enabled report schedules, each with the local day it fires next. */
79
+ function readSchedules(now) {
80
+ const RN = require('./report-needs.js');
81
+ const logic = require('./schedule-logic.js');
82
+ const out = [];
83
+ for (const s of RN.readSchedules()) {
84
+ if (!s || !s.enabled) continue;
85
+ const cadence = RN.cadenceOfSchedule(s);
86
+ if (!cadence) continue;
87
+ const next = logic.nextRun(s, now);
88
+ if (!next) continue;
89
+ out.push({ id: String(s.id || s.name || cadence), name: s.name || '', cadence, next: localDay(new Date(next)) });
90
+ }
91
+ return out;
92
+ }
93
+ /** The newest report of each cadence when it is a draft not issued: a draft that waits for the PM. */
94
+ function readDrafts(roots) {
95
+ const RN = require('./report-needs.js');
96
+ const out = [];
97
+ for (const { ws, root } of roots) {
98
+ const seen = new Set();
99
+ for (const r of RN.reportsOf(root).reports) { // newest slot first
100
+ if (/^scan-/.test(r.cadence) || seen.has(r.cadence)) continue;
101
+ seen.add(r.cadence);
102
+ if (r.status === 'draft' && !r.issued) { const fm = RN.frontmatter(path.join(root, r.path)); out.push({ ws, cadence: r.cadence, slot: r.slot, ...(fm.title ? { title: fm.title } : {}) }); }
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ function readOwn(runtimeDir) {
108
+ const P = require('./pm-items.js');
109
+ return P.fold(P.readLines(path.join(runtimeDir, 'pm-items', 'items.jsonl'))).map((o) => ({ id: o.id, title: o.title, due: o.due || null, done: !!o.done }));
110
+ }
111
+
112
+ /** The pure handler. deps: { today, readBoards() → { state } | { boards, missing }, readMeetings(), readSchedules(), readDrafts(boards), readOwn(),
113
+ * readMarks() }. A reader that throws names its source in `missing`. */
114
+ async function handle(deps) {
115
+ const b = await deps.readBoards();
116
+ if (b && b.state === 'reading') return { status: 202, body: { ok: true, state: 'reading' } };
117
+ const missing = [...((b && b.missing) || [])];
118
+ const boards = (b && b.boards) || [];
119
+ const tryRead = (name, fn, fallback) => { try { const v = fn(); return v == null ? fallback : v; } catch (e) { missing.push(name + ' (' + reason(e) + ')'); return fallback; } };
120
+ const meetings = tryRead('the calendar', () => deps.readMeetings(), []);
121
+ const schedules = tryRead('the report schedules', () => deps.readSchedules(), []);
122
+ const drafts = tryRead('the report drafts', () => deps.readDrafts(boards), []);
123
+ const own = tryRead('your items', () => deps.readOwn(), []);
124
+ const marks = tryRead('your marks', () => deps.readMarks(), { fixed: new Set(), declined: new Set() });
125
+ const model = EP.build({ today: deps.today, boards, meetings, schedules, drafts, own, marks });
126
+ return { status: 200, body: { ok: true, state: 'ready', today: model.today, items: model.items, later: model.later, missing } };
127
+ }
128
+
129
+ module.exports = {
130
+ foldMarks, markLine, handlePure: handle, readers: { readSchedules, readDrafts, readOwn, readMarks },
131
+ prefixes: ['/api/events-place'],
132
+ handle: async (req, res, url, ctx) => {
133
+ if (url.pathname === '/api/events-place/mark') {
134
+ if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
135
+ const got = await ctx.readJson(req);
136
+ if (!got.ok) { ctx.json(res, { ok: false, error: 'the body must be JSON' }, 400); return true; }
137
+ const g = require('./pm-guard.js').requirePagePress(req, got.body);
138
+ if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
139
+ if (!ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'this server has no runtime folder, so the mark cannot be kept' }, 409); return true; }
140
+ const line = markLine(got.body, g.actor && g.actor.by ? g.actor.by : 'pm', new Date().toISOString());
141
+ if (line.error) { ctx.json(res, { ok: false, error: line.error }, 400); return true; }
142
+ try {
143
+ fs.mkdirSync(path.dirname(marksFile(ctx.runtimeDir)), { recursive: true });
144
+ fs.appendFileSync(marksFile(ctx.runtimeDir), JSON.stringify(line) + '\n');
145
+ } catch (e) { ctx.json(res, { ok: false, error: 'the mark could not be kept: ' + reason(e) }, 500); return true; }
146
+ ctx.json(res, { ok: true });
147
+ return true;
148
+ }
149
+ if (url.pathname !== '/api/events-place') return false;
150
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
151
+ const now = new Date();
152
+ try {
153
+ const out = await handle({
154
+ today: localDay(now),
155
+ readBoards: () => readBoards(req, ctx),
156
+ readMeetings: () => (ctx.runtimeDir ? require('./calendar-events.js').readAll(ctx.runtimeDir, { now: now.getTime() }) : []),
157
+ readSchedules: () => readSchedules(now),
158
+ readDrafts: (boards) => readDrafts([...new Set(boards.map((x) => x.ws))].map((ws) => ({ ws, w: ctx.getWs ? ctx.getWs(ws || null) : null })).filter((x) => x.w && x.w.root).map((x) => ({ ws: x.ws, root: x.w.root }))),
159
+ readOwn: () => (ctx.runtimeDir ? readOwn(ctx.runtimeDir) : []),
160
+ readMarks: () => (ctx.runtimeDir ? readMarks(ctx.runtimeDir) : foldMarks([])),
161
+ });
162
+ ctx.json(res, out.body, out.status);
163
+ } catch (e) { ctx.json(res, { ok: false, state: 'error', error: reason(e) }, 500); }
164
+ return true;
165
+ },
166
+ };
@@ -0,0 +1,89 @@
1
+ 'use strict';
2
+ /* routes-library.js — GET /api/library-items[?ws=<id>&initiative=<id>] (initiative library-place, slice 7 of the six-place navigation).
3
+ *
4
+ * The Library place reads every product; slice 3's Artefacts table reads one initiative. → { ok, items } (lib/library-items.js ITEM),
5
+ * newest first. READ ONLY: it folds what is already recorded and writes nothing.
6
+ * files lib/doc-library.js library() — the tracked markdown files, attributed to the initiative that owns them (server.js initiativeIndex)
7
+ * links lib/custom-docs.js — the links the PM added to an initiative (Confluence, Google Docs, Google Slides)
8
+ * rounds lib/idle-lab.js roundsOf over lib/proposals.js — the prototype rounds of each initiative
9
+ * notes lib/notes.js list() — the meeting notes of the runtime directory
10
+ * A source that cannot be read is left out, and the answer says which in `unread` (the page says nothing about it unless every source failed).
11
+ * (/api/library is the old file tree of one workspace, server.js; this route is a different one.) */
12
+ const Items = require('./library-items.js');
13
+
14
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
15
+
16
+ function titlesOf(w, ctx) {
17
+ const m = new Map();
18
+ try { const b = require('./routes-boards.js').baseRows(w, ctx); if (b && b.ok) for (const r of b.rows || []) if (r && r.id) m.set(r.id, r.title || r.id); } catch { /* none yet */ }
19
+ return m;
20
+ }
21
+ function ownersOf(ctx, root) {
22
+ const own = new Map();
23
+ if (typeof ctx.initiativeIndex !== 'function') return own;
24
+ for (const g of ctx.initiativeIndex(root).initiatives || []) {
25
+ for (const a of g.artifacts || []) { const rel = String(a.path).split(require('path').sep).join('/'); if (!a.shared && !own.has(rel)) own.set(rel, { id: g.id, title: g.title || g.id }); }
26
+ }
27
+ return own;
28
+ }
29
+ function roundsOf(dir) {
30
+ const PR = require('./proposals.js'), LAB = require('./idle-lab.js');
31
+ const P = PR.read(dir), all = [...P.props.values()];
32
+ const inis = [...new Set(all.filter((x) => x.group === 'prototyped' && x.ini).map((x) => x.ini))];
33
+ const out = [];
34
+ for (const ini of inis) {
35
+ const roots = new Map(all.filter((x) => x.group === 'prototyped' && x.ini === ini).map((x) => [x.id, x]));
36
+ for (const r of LAB.roundsOf(P, ini)) {
37
+ const root = roots.get(r.id) || all.find((x) => x.id === r.id) || {};
38
+ const of = (root.data && root.data.of) || r.id;
39
+ const top = roots.get(of) || root;
40
+ const brief = (top.data && top.data.live && top.data.live.brief) || String(top.title || '').replace(/^Round \d+ · [^:]*:\s*/, '');
41
+ const newest = all.filter((x) => x.group === 'improved' && x.ini === ini && x.data && x.data.of === of).reduce((a, x) => (String(x.at) > a ? String(x.at) : a), String(r.at || ''));
42
+ out.push({ id: r.id, ini, board: top.board || '', name: brief || 'Prototype', at: newest || r.at, made: r.rounds || r.made || 0 });
43
+ }
44
+ }
45
+ return out;
46
+ }
47
+
48
+ function gather(ctx, list) {
49
+ const unread = [];
50
+ const products = [];
51
+ for (const w of list) {
52
+ const p = { ws: w.id, name: w.label || w.name || w.id, titles: titlesOf(w, ctx), files: [], links: [], rounds: [] };
53
+ try {
54
+ const lib = require('./doc-library.js').library(w.root, { stateDir: ctx.runtimeDir, owners: () => ownersOf(ctx, w.root) });
55
+ if (lib.ok) {
56
+ p.files = lib.files.filter((f) => f.initiative);
57
+ for (const [id, t] of Object.entries(lib.initiatives || {})) if (!p.titles.has(id)) p.titles.set(id, t.title);
58
+ }
59
+ } catch { unread.push({ ws: w.id, source: 'documents' }); }
60
+ try {
61
+ const C = require('./custom-docs.js');
62
+ p.links = C.readLines(C.ledgerFile(w.root)).filter((l) => l.link && C.KINDS.includes(l.link.kind) && typeof l.link.url === 'string' && /^https?:\/\//i.test(l.link.url));
63
+ } catch { unread.push({ ws: w.id, source: 'links' }); }
64
+ try { const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null; if (dir) p.rounds = roundsOf(dir); } catch { unread.push({ ws: w.id, source: 'prototypes' }); }
65
+ products.push(p);
66
+ }
67
+ let notes = [];
68
+ try { const l = require('./notes.js').list(ctx.runtimeDir); notes = l.ok ? l.notes : []; } catch { unread.push({ ws: null, source: 'meeting notes' }); }
69
+ return { items: Items.build({ products, notes }), unread };
70
+ }
71
+
72
+ async function handle(req, res, url, ctx) {
73
+ if (url.pathname !== '/api/library-items') return false;
74
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
75
+ const ws = url.searchParams.get('ws') || '', ini = url.searchParams.get('initiative') || '';
76
+ if (ini && !ID_RE.test(ini)) { ctx.json(res, { ok: false, error: 'initiative names an initiative' }, 400); return true; }
77
+ let list = [];
78
+ try { list = typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : []; } catch { list = []; }
79
+ if (ws) {
80
+ const w = list.find((x) => x.id === ws);
81
+ if (!w) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
82
+ list = [w];
83
+ }
84
+ const { items, unread } = gather(ctx, list);
85
+ ctx.json(res, { ok: true, items: Items.narrow(items, { ws: ws || null, initiative: ini || null }), unread });
86
+ return true;
87
+ }
88
+
89
+ module.exports = { prefixes: ['/api/library-items'], handle, gather, roundsOf };
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+ /* routes-pop-work.js — the summary of an initiative changed or confirmed in place, in the popup (initiative popup-work-contents, slice 3 of
3
+ * the six-place navigation; board 3: "You change a value where you see it: the summary … It saves when you leave, with Undo for a moment").
4
+ *
5
+ * POST /api/initiative/describe { ws, id, text } → { ok, id, from, text, same? } the record's description line
6
+ * POST /api/initiative/describe-undo { ws, id, from, to } → { ok, kept? } back to `from` while the line still says `to`
7
+ *
8
+ * The writer is lib/initiative-writer.js setDescription and restoreDescription, the same as `pmos initiative describe` and the ✓ on PMOS's
9
+ * description ✦ (lib/routes-proposals.js). Both POSTs pass pm-guard requirePagePress: the launch nonce and the page's origin, so an agent
10
+ * session cannot write here. A record the PM edited since the Undo was offered keeps its edit (→ { ok: true, kept: true }). */
11
+ const guard = require('./pm-guard.js');
12
+ const W = require('./initiative-writer.js');
13
+
14
+ const text = (v) => (typeof v === 'string' ? v : '');
15
+ const bad = (status, error) => ({ status, body: { ok: false, error } });
16
+
17
+ async function handle(req, res, url, ctx) {
18
+ const send = (r) => { ctx.json(res, r.body, r.status); return true; };
19
+ const sub = url.pathname.replace(/^\/api\/initiative\/?/, '');
20
+ if (sub !== 'describe' && sub !== 'describe-undo') return send(bad(404, 'no such route'));
21
+ if (req.method !== 'POST') return send(bad(405, 'POST only'));
22
+ const read = await ctx.readJson(req);
23
+ if (!read.ok || !read.body || typeof read.body !== 'object') return send(bad(400, 'the body must be a JSON object'));
24
+ const body = read.body;
25
+ const g = guard.requirePagePress(req, body);
26
+ if (!g.ok) return send(bad(g.status, g.error));
27
+ const id = text(body.id);
28
+ if (!id || !W.ID_RE.test(id)) return send(bad(400, 'id must name an initiative'));
29
+ const w = ctx.getWs(text(body.ws) || null);
30
+ if (!w || (body.ws && w.id !== body.ws)) return send(bad(404, 'no such workspace'));
31
+ const r = sub === 'describe'
32
+ ? W.setDescription(w.root, id, text(body.text), { actor: g.actor })
33
+ : W.restoreDescription(w.root, id, text(body.from), text(body.to), { actor: g.actor });
34
+ if (!r.ok) return send(bad(r.status || 400, r.error || 'nothing was saved'));
35
+ try { if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id); } catch { /* the next read catches up */ }
36
+ return send({ status: 200, body: sub === 'describe' ? { ok: true, id, from: r.from || '', text: r.text, ...(r.same ? { same: true } : {}) } : { ok: true, ...(r.kept ? { kept: true } : {}) } });
37
+ }
38
+
39
+ module.exports = { prefixes: ['/api/initiative/describe', '/api/initiative/describe-undo'], handle };
@@ -30,6 +30,8 @@
30
30
  * report from Intelligence and drafts issue 1 from the live model (source intelligence:<scope>)
31
31
  * POST /api/report-setups/strip-dismiss { ws, id } → { ok } Not now on a report the ✦ strip proposed
32
32
  * GET /api/report-documents?ws → { docs: [{ path, id, setup, name, slot, state: draft|issued, source, output, made_by: schedule|you|agent, v, copy }] }
33
+ * GET /api/report-setups/routine?ws → { ok, ws, name, reports: [row] } every report of the workspace as one row of Routine (lib/routine-reports.js;
34
+ * slice 8 of the six-place navigation). Read-only: it settles nothing and migrates nothing.
33
35
  * POST /api/report-documents/discard { ws, path } → { ok, doc } delete an UNISSUED draft; an issued report is 409 and untouched (L3)
34
36
  * POST /api/report-documents/archive { ws, path, archived } → { ok, doc, archived } hide (or bring back) an ISSUED report; a draft is 409 (L4)
35
37
  * GET /api/report-export?ws&path&fmt=pptx|xlsx|docx|csv → the file, Content-Disposition: attachment. PDF is printed by the browser: there is no route.
@@ -335,6 +337,24 @@ async function handle(req, res, url, ctx) {
335
337
  const preview = IR.documentOf(m, { id: 'preview', name: S.name, audience: defaults.audience, output: defaults.output, source: IR.sourceOf(scope), storyline: story }, { slot: m.today, issue: 1 });
336
338
  return send({ status: 200, body: { ok: true, storyline: S, defaults, checks: IR.storyChecks(preview), proposals: IR.proposalsOf(m, { findings, dismissed: [...st.stripDismissed], weekly: weeklyOpen(ctx, w.id), covered: [...st.setups.values()].map((x) => IR.scopeOf(x.source)).filter(Boolean) }), as_of: m.today } });
337
339
  }
340
+ if (sub === 'routine') {
341
+ // Routine (slice 8 of the six-place navigation, lib/routine-reports.js): every report of the workspace as one row, with its one ✓. Read-only.
342
+ if (req.method !== 'GET') return send(bad(405, 'GET only'));
343
+ const w = wsOf(ctx, url.searchParams.get('ws'));
344
+ if (!w) return send(bad(404, 'no such workspace'));
345
+ const now = new Date();
346
+ let defs = [];
347
+ try { defs = RS.definitionsOf(w.root); } catch { defs = []; }
348
+ const boards = typeof ctx.workspaceList === 'function' ? ctx.workspaceList().map((x) => ({ ws: x.id, name: x.name })) : [];
349
+ // the setups as the ledger holds them, read only (listAnswer would settle a stale ask: a write); next is the same nextDraftAt it uses
350
+ const setups = [...RS.fold(RS.readLines(RS.ledgerFile(w.root))).setups.values()].map((s) => {
351
+ let next = null;
352
+ if (s.status === 'active' && s.schedule) { try { const n = RS.nextDraftAt(s.schedule, s.last_run, now); next = n ? n.toISOString() : null; } catch { next = null; } }
353
+ return { id: s.id, name: s.name, purpose: s.purpose, audience: s.audience, source: s.source, output: s.output, schedule: s.schedule, label: RS.scheduleLabel(s.schedule), next_draft: next, status: s.status };
354
+ });
355
+ const reports = require('./routine-reports.js').routineReports({ setups, docs: documentsOf(ctx, w).docs, defs, boards, here: w.id });
356
+ return send({ status: 200, body: { ok: true, ws: w.id, name: w.name || w.id, reports } });
357
+ }
338
358
  if (!docPost && (isDocs || isExport || (sub === '' && req.method === 'GET'))) {
339
359
  if (req.method !== 'GET') return send(bad(405, 'GET only'));
340
360
  if ((isDocs && p !== '/api/report-documents') || (isExport && p !== '/api/report-export')) return send(bad(404, 'no such report route'));
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+ /* routes-today-log.js — Today's log (slice 5 of the six-place navigation; lib/today-log.js is the store).
3
+ *
4
+ * GET /api/today-log?day=YYYY-MM-DD → { ok, day, entries, marks } the PM's own entries and the marks on the rows of that day
5
+ * POST /api/today-log/add { text, day, bullet?, first? } → { ok, entry } a task, an event or a note typed in the first line
6
+ * POST /api/today-log/mark { key, act, day, until?, snap? } → { ok } done, undone, later (until a later day), now (back to today), drop, undrop, keep
7
+ *
8
+ * The day is the PM's local day, sent by the page. Every POST passes pm-guard requirePagePress: the page only. A mark changes only the
9
+ * log: done on a task or an item of the PM is sent to that record's own route by the page, and the mark is the log's line beside it.
10
+ * STATE: <runtime>/today-log/log.jsonl, append-only, one writer (lib/today-log.js appendLine). */
11
+ const path = require('path');
12
+ const crypto = require('crypto');
13
+ const guard = require('./pm-guard.js');
14
+ const TL = require('./today-log.js');
15
+
16
+ const fileOf = (ctx) => path.join(ctx.runtimeDir, 'today-log', 'log.jsonl');
17
+ const localDay = (now = new Date()) => new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 10);
18
+
19
+ module.exports = {
20
+ prefixes: ['/api/today-log'],
21
+ fileOf,
22
+ handle: async (req, res, url, ctx) => {
23
+ const p = url.pathname;
24
+ if (!ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'PMOS has no state folder here, so Today cannot keep a log' }, 503); return true; }
25
+ if (p === '/api/today-log' && req.method === 'GET') {
26
+ const day = url.searchParams.get('day') || localDay();
27
+ if (!TL.DAY_RE.test(day)) { ctx.json(res, { ok: false, error: 'day is YYYY-MM-DD' }, 400); return true; }
28
+ const f = TL.fold(TL.readLines(fileOf(ctx)), day);
29
+ ctx.json(res, { ok: true, day, entries: f.entries, marks: f.marks });
30
+ return true;
31
+ }
32
+ if (req.method !== 'POST' || (p !== '/api/today-log/add' && p !== '/api/today-log/mark')) return false;
33
+ const got = await ctx.readJson(req);
34
+ if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
35
+ const body = got.body || {};
36
+ const g = guard.requirePagePress(req, body);
37
+ if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
38
+ const day = String(body.day || '');
39
+ const r = p === '/api/today-log/add' ? TL.addEvent(body, day, 'tl-' + crypto.randomBytes(6).toString('hex')) : TL.markEvent(body, day);
40
+ if (r.error) { ctx.json(res, { ok: false, error: r.error }, 400); return true; }
41
+ TL.appendLine(fileOf(ctx), r.event);
42
+ if (p === '/api/today-log/add') {
43
+ const e = r.event;
44
+ ctx.json(res, { ok: true, entry: { id: e.id, key: 'own:' + e.id, bullet: e.bullet, text: e.text, first: e.first, time: e.time, day: e.day, done: false } });
45
+ } else ctx.json(res, { ok: true });
46
+ return true;
47
+ },
48
+ };
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+ /* routine-reports.js — every report of a workspace as one row of Routine (initiative routine-place, slice 8 of the six-place navigation;
3
+ * board 11 on Exploring 2; done test planning/done-tests/routine-place.md T1).
4
+ *
5
+ * routineReports({ setups, docs, defs, boards, here }) → [row] PURE
6
+ * setups GET /api/report-setups setups (lib/routes-report-setups.js listAnswer): { id, name, purpose, audience, source, output, schedule,
7
+ * label, next_draft, status: active | paused }
8
+ * docs the report documents (routes-report-setups.js documentsOf docs): { path, setup, name, slot, state: draft | issued, archived, source, output }
9
+ * defs the definitions (lib/report-setups.js definitionsOf): { id, title, audience, status, source, output }
10
+ * boards [{ ws, name }] and here: the workspace the reports sit in (for the ✦ Move of lib/report-acts.js)
11
+ * row: { id, name, audience, purpose, when, schedule, next, status: 'active' | 'paused' | null, output, source, act, issues, latest }
12
+ * when the setup's schedule in words; '' when no setup says it (a definition drafted by a skill has no schedule here)
13
+ * next the setup's next draft (ISO) while it is active, else null
14
+ * act the report's one ✓ (lib/report-acts.js reportActOf): move | confirm | issue | resume, or null
15
+ * issues its files, newest first: { path, slot, state, archived }; latest is the newest one not archived, or null
16
+ *
17
+ * A report is a row when it has a setup or at least one issue. A definition with neither is not drawn (zero is silence). Nothing is filled with a
18
+ * guess: a field the records leave silent is '' or null. Read-only: nothing here writes.
19
+ */
20
+ const RA = require('./report-acts.js');
21
+
22
+ const str = (v) => (typeof v === 'string' ? v : '');
23
+
24
+ function routineReports(f = {}) {
25
+ const setups = (f.setups || []).filter((s) => s && s.id);
26
+ const docs = (f.docs || []).filter((d) => d && d.path);
27
+ const defs = new Map((f.defs || []).filter((d) => d && d.id).map((d) => [d.id, d]));
28
+ const cadenceOf = (d) => d.setup || str(d.cadence) || String(d.path).split('/').slice(-2, -1)[0] || '';
29
+ const ids = [...new Set(setups.map((s) => s.id).concat(docs.map(cadenceOf)).filter(Boolean))];
30
+ const out = [];
31
+ for (const id of ids) {
32
+ const s = setups.find((x) => x.id === id) || null, def = defs.get(id) || null;
33
+ const issues = docs.filter((d) => cadenceOf(d) === id).map((d) => ({ path: d.path, slot: str(d.slot), state: d.state === 'issued' ? 'issued' : 'draft', archived: !!d.archived }))
34
+ .sort((a, b) => (a.slot < b.slot ? 1 : a.slot > b.slot ? -1 : 0));
35
+ const setup = s ? { ...s, paused: s.status === 'paused' } : null;
36
+ const about = setup ? RA.reportAboutOf([s.name, s.purpose].join(' · '), f.boards, f.here) : null;
37
+ const act = RA.reportActOf({ id, setup, rows: issues, def, about });
38
+ const named = docs.find((d) => cadenceOf(d) === id && d.name && d.name !== id);
39
+ out.push({
40
+ id, name: (s && s.name) || RA.defTitleOf(def) || (named && named.name) || id,
41
+ audience: str(s && s.audience) || str(def && def.audience), purpose: str(s && s.purpose),
42
+ when: s ? str(s.label) : '', schedule: s && s.schedule ? s.schedule : null, next: s && s.status === 'active' ? s.next_draft || null : null,
43
+ status: s ? (s.status === 'paused' ? 'paused' : 'active') : null,
44
+ output: str(s && s.output) || str(def && def.output) || str(named && named.output), source: str(s && s.source) || str(def && def.source) || str(named && named.source),
45
+ act, issues, latest: issues.find((x) => !x.archived) || null,
46
+ });
47
+ }
48
+ // a set-up report first, then by name: the table's order inside its group
49
+ return out.sort((a, b) => (a.status ? 0 : 1) - (b.status ? 0 : 1) || a.name.localeCompare(b.name));
50
+ }
51
+
52
+ module.exports = { routineReports };
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+ /* today-log.js — Today's log, the store (slice 5 of the six-place navigation, board 1 on Exploring 2; build plan
3
+ * /mnt/project-files/nav-structure/build-plan.md, initiative today-log-page).
4
+ *
5
+ * Today's log is a table kept the Bullet Journal way. Most rows come from what PMOS already reads (the ranked asks, the PM's tasks,
6
+ * the next steps, the PM's own items); this file keeps only what Today adds:
7
+ * - the PM's own entries typed in the first line: a task (•), an event (○, with a time when the words name one) or a note (–),
8
+ * "!" in front marks what comes first;
9
+ * - the PM's marks on any row of the log: done today, moved to a later day (and back), dropped from the log, kept after PMOS suggested
10
+ * to drop it.
11
+ * A mark never changes the record a row comes from. Done on a task or an item goes through that record's own route; the mark is the
12
+ * log's own line, so the row keeps its × for the rest of the day.
13
+ *
14
+ * parseEntry(text) → { bullet: 'task' | 'event' | 'note', text, first, time } | null PURE
15
+ * fold(lines, day) → { entries, marks } PURE. entries: open own entries of `day` and of the days before it
16
+ * (carried), and the ones done on `day`; marks: { [key]: { done?, until?, dropped?, kept? } }
17
+ * addEvent(body, day, id) → { event } | { error } PURE: the line POST /api/today-log/add appends
18
+ * markEvent(body, day) → { event } | { error } PURE: the line POST /api/today-log/mark appends
19
+ * readLines(file) · appendLine(file, line, now) the one file, append-only, <runtime>/today-log/log.jsonl
20
+ *
21
+ * SINGLE WRITER: appendLine() is the only function that writes the file. `at` is set there. The day is the PM's local day, sent by
22
+ * the page (the server may run on a host in another time zone), and checked to be YYYY-MM-DD.
23
+ */
24
+ const fs = require('fs');
25
+ const path = require('path');
26
+
27
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
28
+ const KEY_RE = /^[A-Za-z0-9][A-Za-z0-9._:@/+-]{0,199}$/;
29
+ const ID_RE = /^tl-[0-9a-z]{6,20}$/;
30
+ const BULLETS = ['task', 'event', 'note'];
31
+ const ACTS = ['done', 'undone', 'later', 'now', 'drop', 'undrop', 'keep'];
32
+ const MAX_TEXT = 240;
33
+ const SNAP = ['title', 'work', 'job'];
34
+
35
+ /** One line the PM typed. A leading "!" marks it first; "o " or "○ " makes it an event, "- " or "– " a note, "• " or nothing a task.
36
+ * An event's time ("10:30", "9.15", "14:00") is read from its words and kept apart. */
37
+ function parseEntry(text) {
38
+ let t = String(text == null ? '' : text).replace(/\s+/g, ' ').trim();
39
+ let first = false, bullet = 'task';
40
+ for (let i = 0; i < 2; i++) {
41
+ if (/^!\s*/.test(t)) { first = true; t = t.replace(/^!\s*/, ''); continue; }
42
+ const b = /^([o○•\-–—])\s+/.exec(t);
43
+ if (b) { bullet = /[o○]/.test(b[1]) ? 'event' : /[-–—]/.test(b[1]) ? 'note' : 'task'; t = t.slice(b[0].length); continue; }
44
+ }
45
+ let time = null;
46
+ if (bullet === 'event') {
47
+ const m = /(?:^|\s)(?:at\s+)?([01]?\d|2[0-3])[:.]([0-5]\d)(?=\s|$)/i.exec(t);
48
+ if (m) { time = String(m[1]).padStart(2, '0') + ':' + m[2]; t = (t.slice(0, m.index) + ' ' + t.slice(m.index + m[0].length)).replace(/\s+/g, ' ').trim(); }
49
+ }
50
+ t = t.slice(0, MAX_TEXT).trim();
51
+ if (!t) return null;
52
+ return { bullet, text: t, first, time };
53
+ }
54
+
55
+ /** The line POST /api/today-log/add appends. body: { text, day, bullet? (overrides the typed bullet), first? }. */
56
+ function addEvent(body, day, id) {
57
+ if (!DAY_RE.test(String(day || ''))) return { error: 'day is YYYY-MM-DD' };
58
+ if (!ID_RE.test(String(id || ''))) return { error: 'bad id' };
59
+ const e = parseEntry(body && body.text);
60
+ if (!e) return { error: 'write the task, the event or the note first' };
61
+ if (body.bullet != null && !BULLETS.includes(body.bullet)) return { error: 'bullet is task, event or note' };
62
+ const bullet = body.bullet || e.bullet;
63
+ return { event: { event: 'added', id, day, bullet, text: e.text, first: !!(body.first || e.first), time: bullet === 'event' ? e.time : null } };
64
+ }
65
+
66
+ /** The line POST /api/today-log/mark appends. body: { key, act, day, until? (later), snap? { title, work, job } (done: what the row
67
+ * said, so its × still reads after the source has let it go) }. */
68
+ function markEvent(body, day) {
69
+ const b = body || {};
70
+ if (!DAY_RE.test(String(day || ''))) return { error: 'day is YYYY-MM-DD' };
71
+ if (!KEY_RE.test(String(b.key || ''))) return { error: 'key names the row' };
72
+ if (!ACTS.includes(b.act)) return { error: 'act is ' + ACTS.join(', ') };
73
+ const ev = { event: 'mark', key: String(b.key), act: b.act, day };
74
+ if (b.act === 'later') {
75
+ if (!DAY_RE.test(String(b.until || '')) || b.until <= day) return { error: 'until is a later day, YYYY-MM-DD' };
76
+ ev.until = b.until;
77
+ }
78
+ if (b.act === 'done' && b.snap && typeof b.snap === 'object') {
79
+ const s = {};
80
+ for (const k of SNAP) if (typeof b.snap[k] === 'string' && b.snap[k].trim()) s[k] = b.snap[k].replace(/\s+/g, ' ').trim().slice(0, MAX_TEXT);
81
+ if (Object.keys(s).length) ev.snap = s;
82
+ }
83
+ return { event: ev };
84
+ }
85
+
86
+ /** Fold the lines for one day. An own entry shows on its day and every day after until it is done or dropped (carried); a done
87
+ * entry shows only on the day it was done. A mark holds by key: the last done/undone wins, a later day hides the row until then,
88
+ * a drop hides it until an undrop, a keep is remembered with its day (PMOS suggests a drop again only a while after it). */
89
+ function fold(lines, day) {
90
+ const d = DAY_RE.test(String(day || '')) ? day : '9999-12-31';
91
+ const own = new Map(), marks = {};
92
+ const M = (k) => (marks[k] = marks[k] || {});
93
+ for (const ev of lines || []) {
94
+ if (!ev || typeof ev !== 'object' || !DAY_RE.test(String(ev.day || '')) || ev.day > d) continue;
95
+ if (ev.event === 'added' && ID_RE.test(String(ev.id || '')) && BULLETS.includes(ev.bullet)) {
96
+ own.set(ev.id, { id: ev.id, key: 'own:' + ev.id, bullet: ev.bullet, text: String(ev.text || ''), first: !!ev.first, time: ev.time || null, day: ev.day, at: ev.at || null });
97
+ continue;
98
+ }
99
+ if (ev.event !== 'mark' || !KEY_RE.test(String(ev.key || '')) || !ACTS.includes(ev.act)) continue;
100
+ const m = M(ev.key);
101
+ if (ev.act === 'done') { m.done = ev.day; if (ev.snap) m.snap = ev.snap; }
102
+ else if (ev.act === 'undone') { delete m.done; delete m.snap; }
103
+ else if (ev.act === 'later') { if (ev.until > d) m.until = ev.until; else delete m.until; }
104
+ else if (ev.act === 'now') delete m.until;
105
+ else if (ev.act === 'drop') m.dropped = ev.day;
106
+ else if (ev.act === 'undrop') delete m.dropped;
107
+ else if (ev.act === 'keep') m.kept = ev.day;
108
+ }
109
+ // a done mark of an earlier day is history: the row is gone from today's log (an own entry), or it is back as its source says
110
+ for (const k of Object.keys(marks)) { const m = marks[k]; if (m.done && m.done !== d) { m.doneBefore = m.done; delete m.done; delete m.snap; } if (!Object.keys(m).length) delete marks[k]; }
111
+ const entries = [];
112
+ for (const e of own.values()) {
113
+ const m = marks[e.key] || {};
114
+ if (m.dropped) continue;
115
+ if (m.doneBefore && !m.done) continue;
116
+ entries.push({ ...e, done: !!m.done });
117
+ }
118
+ return { entries, marks };
119
+ }
120
+
121
+ function readLines(file) {
122
+ let raw = '';
123
+ try { raw = fs.readFileSync(file, 'utf8'); } catch { return []; }
124
+ return raw.split('\n').filter(Boolean).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean);
125
+ }
126
+ function appendLine(file, line, now = new Date()) {
127
+ fs.mkdirSync(path.dirname(file), { recursive: true });
128
+ fs.appendFileSync(file, JSON.stringify({ ...line, at: now.toISOString() }) + '\n');
129
+ }
130
+
131
+ module.exports = { DAY_RE, KEY_RE, BULLETS, ACTS, parseEntry, addEvent, markEvent, fold, readLines, appendLine };
@@ -10,6 +10,7 @@
10
10
  * F2 a phone: no fold · every page: no page error
11
11
  * PMOS_SHOTS=<dir> also saves the screenshots. */
12
12
  const path = require('path');
13
+ const { classicBoard } = require('./lib/classic-board'); // these checks are about the four Board views, not Work (work-one-view)
13
14
  const fs = require('fs');
14
15
  const { spawn } = require('child_process');
15
16
  const { findBrowser } = require('./lib/find-browser');
@@ -46,7 +47,7 @@ const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items',
46
47
  try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
47
48
  srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
48
49
  await T.waitForServer(BASE);
49
- browser = await chromium.launch({ executablePath: exe });
50
+ browser = classicBoard(await chromium.launch({ executablePath: exe }));
50
51
  if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
51
52
  const shot = async (page, name) => { if (SHOTS) { await sleep(300); await page.screenshot({ path: path.join(SHOTS, name + '.png') }); } };
52
53
 
@@ -70,10 +71,12 @@ const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items',
70
71
  const l = document.getElementById('czLive'), f = document.querySelector('#czMenu.ev-rail [data-cz-chat]') || document.getElementById('czFab'); if (!l || l.hidden) return null; // a desktop: the rail's chat icon (slice 1)
71
72
  const a = l.getBoundingClientRect(), b = f.getBoundingClientRect();
72
73
  return { text: l.textContent.trim(), w: Math.round(a.width), h: Math.round(a.height), round: getComputedStyle(l).borderRadius, marks: l.querySelectorAll('.lv-m').length,
73
- above: a.bottom <= b.top, centred: Math.abs((a.left + a.width / 2) - (b.left + b.width / 2)) <= 1, label: l.getAttribute('aria-label'), asks: l.classList.contains('asks') };
74
+ above: a.bottom <= b.top, centred: Math.abs((a.left + a.width / 2) - (b.left + b.width / 2)) <= 1, label: l.getAttribute('aria-label'), asks: l.classList.contains('asks'), chatpop: document.body.classList.contains('cz-chatpop') };
74
75
  }));
75
76
  ok('L2 the pill shows the number of live items and no marks', l2 && l2.text === '2' && l2.marks === 0 && !l2.asks, JSON.stringify(l2));
76
- ok('L2 it is a 44 px round button, stacked above the rail\'s chat icon on its centre line', l2 && l2.w === 44 && l2.h === 44 && l2.round === '50%' && l2.above && l2.centred, JSON.stringify(l2));
77
+ // with the popup's chat (cozy-popup.js sets window.czOpenChat) the rail's chat icon holds the sessions, so the round button gives way
78
+ // (cozy-ev.css cz-chatpop); it comes back only while a panel is put away (panels-test P3)
79
+ ok('L2 beside the rail\'s chat icon it gives way to the popup\'s chat; without it, a 44 px round button stacked above the chat icon on its centre line', l2 && (l2.chatpop ? l2.w === 0 && l2.h === 0 : l2.w === 44 && l2.h === 44 && l2.round === '50%' && l2.above && l2.centred), JSON.stringify(l2));
77
80
  ok('L2 its name still says what it holds and its key', l2 && /^What you work on now: 2 running\. Open \(Ctrl J\)$/.test(l2.label), l2 && l2.label);
78
81
  await shot(page, 'pill-running');
79
82
 
@@ -83,8 +86,8 @@ const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items',
83
86
  ok('L3 PMOS asks: the pill turns blue, with the count', l3 && l3.text === '3' && !/255, 255, 255/.test(l3.bg), JSON.stringify(l3));
84
87
  await shot(page, 'pill-asks');
85
88
 
86
- /* L4 */
87
- await page.click('#czLive');
89
+ /* L4 (beside the popup's chat icon the round button gives way, L2: Ctrl J still opens the list) */
90
+ if (l2 && l2.chatpop) await page.keyboard.press('Control+j'); else await page.click('#czLive');
88
91
  const rows = await until(() => page.evaluate(() => { const r = [...document.querySelectorAll('#czLiveList a[data-lv]')]; return r.length ? r.length : null; }));
89
92
  ok('L4 the list opens with its rows (the panels engine drags a[data-lv] to an edge)', rows === 3, String(rows));
90
93
  await shot(page, 'pill-list');
@@ -96,7 +99,7 @@ const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items',
96
99
  await page.evaluate(() => { delete window.czPanels; });
97
100
 
98
101
  /* L5 */
99
- ok('L5 a desktop has no menu to open (the rail is the menu, slice 1): the pill stays at the rail\'s foot', await page.evaluate(() => !document.getElementById('czLive').hidden && getComputedStyle(document.getElementById('czLive')).visibility === 'visible' && getComputedStyle(document.getElementById('czFab')).display === 'none'));
102
+ ok('L5 a desktop has no menu to open (the rail is the menu, slice 1): the pill stays at the rail\'s foot, or gives way to the popup\'s chat icon', await page.evaluate(() => { const l = document.getElementById('czLive'), cs = getComputedStyle(l); return !l.hidden && getComputedStyle(document.getElementById('czFab')).display === 'none' && (document.body.classList.contains('cz-chatpop') ? cs.display === 'none' : cs.visibility === 'visible'); }));
100
103
  await page.keyboard.press('Escape');
101
104
  await page.evaluate(() => { const m = document.getElementById('czMenu'); if (m && !m.hidden) document.getElementById('czFab').click(); });
102
105
 
@@ -145,7 +148,7 @@ const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items',
145
148
 
146
149
  /* L6 */
147
150
  await page.evaluate(() => { window.czPanels = { slideOver: () => false, list: () => [] }; });
148
- await page.click('#czLive');
151
+ if (l2 && l2.chatpop) await page.keyboard.press('Control+j'); else await page.click('#czLive');
149
152
  await until(() => page.$('#czLiveList a[data-lv="s:b"]'));
150
153
  await Promise.all([page.waitForURL(/premium\.html\?session=b/, { timeout: 15000 }).catch(() => null), page.click('#czLiveList a[data-lv="s:b"]')]);
151
154
  ok('L6 czPanels.slideOver(item) gives false (it did nothing): the row opens as today', /premium\.html\?session=b/.test(page.url()), page.url());