create-pmos 0.442.0 → 0.444.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 (81) hide show
  1. package/package.json +25 -25
  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/briefing-premium-board-test.js +8 -2
  7. package/workspace/briefing-premium-insights-test.js +40 -38
  8. package/workspace/briefing-premium-test.js +2 -1
  9. package/workspace/changelog.json +24 -0
  10. package/workspace/goals-clear-ui-test.js +263 -0
  11. package/workspace/guide/home.md +12 -2
  12. package/workspace/guide/metric-drafts.md +8 -2
  13. package/workspace/home-railcard-test.js +193 -0
  14. package/workspace/intel-report-ui-test.js +1 -1
  15. package/workspace/intelligence-gaps-ui-test.js +16 -14
  16. package/workspace/lib/board-premium.js +1 -1
  17. package/workspace/lib/engine/boards.js +9 -2
  18. package/workspace/lib/engine/records/index.js +9 -2
  19. package/workspace/lib/initiative-layout.js +3 -1
  20. package/workspace/lib/insights-premium.js +22 -1
  21. package/workspace/lib/metric-drafts.js +37 -10
  22. package/workspace/lib/metric-read-runs.js +20 -13
  23. package/workspace/lib/metric-reads.js +208 -23
  24. package/workspace/lib/metrics-cli.js +62 -5
  25. package/workspace/lib/routes-boards.js +40 -1
  26. package/workspace/lib/routes-goal-status.js +89 -6
  27. package/workspace/lib/routes-insights-premium.js +1 -1
  28. package/workspace/lib/routes-metric-drafts.js +26 -3
  29. package/workspace/live-pill-round-test.js +178 -0
  30. package/workspace/metric-drafts-ui-test.js +5 -2
  31. package/workspace/okr-goals-ui-test.js +27 -23
  32. package/workspace/package-lock.json +2 -2
  33. package/workspace/package.json +1 -1
  34. package/workspace/panels-test.js +231 -0
  35. package/workspace/premium-board-actions-test.js +2 -2
  36. package/workspace/premium-rec-tab-test.js +2 -1
  37. package/workspace/premium-vw-item-test.js +10 -2
  38. package/workspace/premium-vw-jira-test.js +3 -0
  39. package/workspace/public/pm/bd-ini-panel.js +3 -2
  40. package/workspace/public/pm/cozy-adler.js +21 -0
  41. package/workspace/public/pm/cozy-divider.css +32 -0
  42. package/workspace/public/pm/cozy-divider.js +45 -0
  43. package/workspace/public/pm/cozy-insights.css +96 -0
  44. package/workspace/public/pm/cozy-live-pill.css +16 -17
  45. package/workspace/public/pm/cozy-live-pill.js +28 -17
  46. package/workspace/public/pm/cozy-panels.css +59 -0
  47. package/workspace/public/pm/cozy-panels.js +524 -0
  48. package/workspace/public/pm/cozy-today.css +15 -0
  49. package/workspace/public/pm/cozy-viewer.js +173 -69
  50. package/workspace/public/pm/cozy-vw-shell.css +4 -0
  51. package/workspace/public/pm/goals-clear.js +265 -0
  52. package/workspace/public/pm/home-app.js +73 -14
  53. package/workspace/public/pm/home-ini.js +9 -3
  54. package/workspace/public/pm/home-today.js +55 -12
  55. package/workspace/public/pm/ini-edit.js +401 -0
  56. package/workspace/public/pm/ini-groups.js +14 -8
  57. package/workspace/public/pm/ini-tasks.js +84 -26
  58. package/workspace/public/pm/ini-versions.js +18 -4
  59. package/workspace/public/pm/ini-view-model.js +45 -18
  60. package/workspace/public/pm/ini-view.css +117 -5
  61. package/workspace/public/pm/ini-view.js +51 -17
  62. package/workspace/public/pm/metric-drafts.js +4 -1
  63. package/workspace/public/pm/mission.js +11 -7
  64. package/workspace/public/pm/premium-board.js +8 -6
  65. package/workspace/public/pm/premium-insights.js +375 -59
  66. package/workspace/public/pm/task-card.css +2 -0
  67. package/workspace/public/pm/task-card.js +4 -1
  68. package/workspace/server.js +6 -2
  69. package/workspace/skills/metric-read.skill +7 -5
  70. package/workspace/stage-card-tasks-test.js +396 -0
  71. package/workspace/stage-card-test.js +12 -4
  72. package/workspace/task-delete-test.js +9 -1
  73. package/workspace/task-milestones-test.js +3 -3
  74. package/workspace/task-press-test.js +12 -4
  75. package/workspace/task-views-test.js +198 -5
  76. package/workspace/test-lists/batch18-live-pill-round.json +10 -0
  77. package/workspace/test-lists/batch18-panels.json +9 -0
  78. package/workspace/test-lists/goals-clear.json +15 -0
  79. package/workspace/test-lists/home-railcard.json +9 -0
  80. package/workspace/test-lists/stage-card-tasks.json +6 -0
  81. package/workspace/tk-tasks-test.js +2 -2
@@ -5,8 +5,16 @@
5
5
  * GET /api/goal-status?ws=<id> → { ok, on, behind: [title], broken: [title], close: [title], none, dots: [{ id, title, dot }], line }
6
6
  * the product page's Goals line: the same status as Intelligence's goal list, never initiative risk
7
7
  * POST /api/goals/notify { ws, id, notify: push | intel | quiet } → { ok } the goal Viewer ⋯: how a broken limit reaches the PM
8
- * POST /api/goal-status/recipe { ws, id, recipe: { connector, query, cadence } | null, close_band? } → { ok } how the goal is read, and its band
9
- * POST /api/goal-status/read { ws, id? } → { ok, run, rids } Read now: one goal, or every goal with a recipe
8
+ * POST /api/goal-status/recipe { ws, id, recipe: recipeOf shape | null, rhythm?: { cadence, at?, day? }, close_band? } → { ok, rhythm? }
9
+ * how the goal is read, and its band. rhythm alone changes only how often (batch 18 item 11)
10
+ * POST /api/goal-status/read { ws, id? } → { ok, run, rids } Read now: one goal (any time; the next scheduled read stays), or every goal
11
+ *
12
+ * Batch 18 item 11 (goals made clear; contract next18/11-okr-clarity/api-contract.md):
13
+ * POST /api/goal-status/file-held { ws, id, held } → { ok } held = the held reading's at; the PM's "file it": a held reading goes on the record after all; its ticket clears
14
+ * POST /api/goal-status/compare { ws, goal | id, value, period? } → { ok, pct, apart, differs, compare } the PM's own number. goal is a
15
+ * record rid or a drafted row id. Over 2% apart: a first reason from the reading's parts at once, and a
16
+ * compare run that finds why (its --why lands on the GET's compare)
17
+ * POST /api/goal-status/compare-pick { ws, goal, pick: mine | yours } → { ok, counts, query } yours rewrites counts.what and the query
10
18
  * POST /api/goal-status/test { ws, rows: [draft row id] } → { ok, run, rids } a test read of drafted rows before the ✓ (no record is written)
11
19
  * POST /api/goal-status/csv { ws, id, csv, source? } → { ok, added, skipped } the fallback: a CSV or sheet export's readings, via csv
12
20
  *
@@ -44,6 +52,72 @@ function afterRead(ctx, w, rids, now = Date.now()) {
44
52
  tell: (rec, reading) => { if (ctx.tellGoalAlert) ctx.tellGoalAlert(w, rec, reading); } });
45
53
  }
46
54
 
55
+ /* ── batch 18 item 11: a held reading filed after all, and the PM's own number ── */
56
+ const draftRowOf = (dir, ws, rowId) => { try { const S = MD.read(dir).scopes.get(MD.keyOf('product', ws)); const r = S && S.rows.get(rowId); return r && r.state === 'open' ? r : null; } catch { return null; } };
57
+ function heldOrCompare(ctx, w, what, body, { root, id, rec }) {
58
+ const dir = dirOf(ctx, w);
59
+ if (!dir) return bad(409, 'This repository has no PMOS state folder.');
60
+ const now = new Date().toISOString(), F = MR.read(dir), x = F.rids.get(id) || null;
61
+ const row = rec ? null : draftRowOf(dir, w.id, id);
62
+ if (!rec && !row) return bad(404, 'There is no such goal.');
63
+ if (what === 'file-held') {
64
+ if (!rec) return bad(404, 'There is no such goal.');
65
+ const h = x && x.held.find((y) => y.at === text(body.held)); // held = the held reading's at (a body may not carry `at`: pm-guard)
66
+ if (!h) return bad(404, 'There is no such held reading. It may be filed already.');
67
+ const reading = { at: h.day, value: h.value, source: h.source || 'held reading', via: 'held', read_at: h.at };
68
+ for (const k of ['num', 'den']) if (Number.isFinite(h[k])) reading[k] = h[k];
69
+ if (h.period) reading.period = h.period;
70
+ const r = records().addReading(root, rec.rid, reading, UI(), 'The PM filed a reading Claude held');
71
+ if (!r.ok) return bad(400, (r.reasons || []).join('; '));
72
+ MR.append(dir, UI(), { kind: 'filed', rid: rec.rid, held: h.at }, now);
73
+ if (h.ticket) { try { MD.append(dir, UI(), { kind: 'clear', scope: 'product', id: w.id, row: h.ticket }, now); } catch { /* the ticket stays a draft */ } }
74
+ try { afterRead(ctx, w, [rec.rid]); } catch { /* the reading stands */ }
75
+ return { status: 200, body: { ok: true } };
76
+ }
77
+ const recipe = rec ? rec.recipe : row.recipe, unit = rec ? rec.unit || '' : (row.metric && row.metric.unit) || row.unit || '';
78
+ if (what === 'compare') {
79
+ const yours = typeof body.value === 'string' ? Number(body.value.replace(/[,\s%]/g, '')) : body.value;
80
+ if (!Number.isFinite(yours)) return bad(400, 'value is your number.');
81
+ const period = text(body.period).replace(/\s+/g, ' ').trim().slice(0, 40);
82
+ const last = rec ? ((x && x.good) || (() => { const rs = (rec.readings || []); const l = rs[rs.length - 1]; return l ? { value: Number(l.value), day: String(l.at).slice(0, 10) } : null; })()) : (x && x.test && x.test.ok ? x.test : null);
83
+ if (!last || !Number.isFinite(last.value)) return bad(409, rec ? 'I have not read this goal yet, so there is nothing to compare.' : 'Read it first (↻), then compare.');
84
+ const c = MR.compareOf(last.value, yours, unit);
85
+ MR.append(dir, UI(), { kind: 'compare', rid: id, value: yours, period, ours: last.value, pct: c.pct }, now);
86
+ let drafting = false;
87
+ if (c.differs) {
88
+ const sr = MR.segmentReason(last, unit);
89
+ if (sr) {
90
+ const z = ((last.segments || []).find((y) => y.num === 0 && y.den >= MR.MIN_DEN) || {}).name || 'that part';
91
+ const what0 = (recipe && recipe.counts && recipe.counts.what) || '';
92
+ MR.append(dir, UI(), { kind: 'reason', rid: id, why: sr.why, suggest: sr.suggest,
93
+ ...(recipe ? { yours: { what: (what0 ? what0.replace(/\.?\s*$/, '. ') : '') + 'It leaves out ' + z + ', which never sends the success event.', query: recipe.query + '\n-- leave out ' + z + ': it never sends the success event' } } : {}) }, now);
94
+ }
95
+ if (ctx.metricReadRuns && recipe) {
96
+ const r = ctx.metricReadRuns.start({ ws: w.id, rids: [id], why: 'compare', compare: { value: yours, period, ours: last.value, draft: !rec } });
97
+ drafting = !!(r && r.ok);
98
+ }
99
+ }
100
+ const view = MR.compareView(MR.read(dir), id, unit);
101
+ return { status: 200, body: { ok: true, pct: c.pct, apart: c.apart, differs: c.differs, drafting, compare: view } };
102
+ }
103
+ // compare-pick
104
+ const cmp = x && x.compare;
105
+ if (!cmp) return bad(409, 'Compare your number first.');
106
+ if (body.pick !== 'mine' && body.pick !== 'yours') return bad(400, 'pick is mine or yours');
107
+ let next = recipe || null, before = null;
108
+ if (body.pick === 'yours') {
109
+ if (!cmp.yours) return bad(409, 'I have not worked out how you count it yet. Wait for my reason, then pick.');
110
+ if (!recipe) return bad(409, 'This goal has no way to be read yet.');
111
+ before = { what: (recipe.counts && recipe.counts.what) || '', query: recipe.query };
112
+ const r = MD.recipeOf({ ...recipe, query: cmp.yours.query, counts: { ...(recipe.counts || {}), what: cmp.yours.what } });
113
+ if (r.error) return bad(400, r.error);
114
+ next = r.recipe;
115
+ if (rec) { let e; try { e = records().edit(root, 'kr-metrics', rec.rid, { recipe: next }, UI(), 'Counted your way, after you compared your number'); } catch (y) { e = { ok: false, reasons: [String((y && y.message) || y).slice(0, 160)] }; } if (!e.ok) return bad(400, (e.reasons || []).join('; ')); }
116
+ else MD.append(dir, UI(), { kind: 'edit', scope: 'product', id: w.id, row: row.id, set: { recipe: next } }, now);
117
+ }
118
+ MR.append(dir, UI(), { kind: 'pick', rid: id, pick: body.pick, ...(before ? { before } : {}) }, now);
119
+ return { status: 200, body: { ok: true, counts: (next && next.counts) || null, query: next ? next.query : '' } };
120
+ }
47
121
  async function handle(req, res, url, ctx) {
48
122
  const send = (r) => { ctx.json(res, r.body, r.status); return true; };
49
123
  if (url.pathname === '/api/goal-status') {
@@ -53,7 +127,7 @@ async function handle(req, res, url, ctx) {
53
127
  try { return send({ status: 200, body: { ok: true, ...summaryFor(ctx, w, todayIso()) } }); } catch (e) { return send(bad(500, 'The goals could not be read: ' + String((e && e.message) || e).slice(0, 160))); }
54
128
  }
55
129
  const what = url.pathname === '/api/goals/notify' ? 'notify' : url.pathname.replace(/^\/api\/goal-status\/?/, '');
56
- if (!['notify', 'recipe', 'read', 'test', 'csv'].includes(what)) return send(bad(404, 'no such goal-status route'));
130
+ if (!['notify', 'recipe', 'read', 'test', 'csv', 'file-held', 'compare', 'compare-pick'].includes(what)) return send(bad(404, 'no such goal-status route'));
57
131
  if (req.method !== 'POST') return send(bad(405, 'POST only'));
58
132
  if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'Only the PM changes how a goal is read or told, from the page. A run files readings with pmos metrics reading.'));
59
133
  const got = await ctx.readJson(req);
@@ -63,7 +137,7 @@ async function handle(req, res, url, ctx) {
63
137
  if (!g.ok) return send(bad(g.status, g.error));
64
138
  const w = wsOf(ctx, text(body.ws));
65
139
  if (!w) return send(bad(404, 'no such workspace'));
66
- const root = recordsDirFor(ctx, w.id), id = text(body.id);
140
+ const root = recordsDirFor(ctx, w.id), id = text(body.id) || text(body.goal);
67
141
  const rec = id ? liveRecords(ctx, w).find((r) => r.rid === id) : null;
68
142
  const edit = (fields, why) => { let e; try { e = records().edit(root, 'kr-metrics', id, fields, UI(), why); } catch (x) { e = { ok: false, reasons: [String((x && x.message) || x).slice(0, 160)] }; } return e.ok ? { status: 200, body: { ok: true } } : bad(400, (e.reasons || []).join('; ')); };
69
143
 
@@ -77,9 +151,17 @@ async function handle(req, res, url, ctx) {
77
151
  const set = {};
78
152
  if (body.recipe === null) set.recipe = null;
79
153
  else if (body.recipe !== undefined) { const r = MD.recipeOf(body.recipe); if (r.error) return send(bad(400, r.error)); set.recipe = r.recipe; }
154
+ else if (body.rhythm !== undefined) { // how often only: the rest of the recipe stays
155
+ if (!rec.recipe || !body.rhythm || typeof body.rhythm !== 'object') return send(bad(400, rec.recipe ? 'rhythm is { cadence, at?, day? }' : 'This goal has no way to be read yet.'));
156
+ const { at: _a, day: _d, ...keep } = rec.recipe;
157
+ const r = MD.recipeOf({ ...keep, cadence: body.rhythm.cadence, at: body.rhythm.at, day: body.rhythm.day });
158
+ if (r.error) return send(bad(400, r.error)); set.recipe = r.recipe;
159
+ }
80
160
  if (body.close_band !== undefined) { const b = Number(body.close_band); if (!Number.isFinite(b) || b < 0) return send(bad(400, 'close_band is a number, 0 or more')); set.close_band = b; }
81
- if (!Object.keys(set).length) return send(bad(400, 'Say the recipe or the close band.'));
82
- return send(edit(set, 'How Claude reads this goal'));
161
+ if (!Object.keys(set).length) return send(bad(400, 'Say the recipe, the rhythm or the close band.'));
162
+ const out = edit(set, body.recipe === undefined && body.rhythm !== undefined ? 'How often Claude reads this goal' : 'How Claude reads this goal');
163
+ if (out.status === 200 && set.recipe) out.body.rhythm = MR.rhythmOf(set.recipe);
164
+ return send(out);
83
165
  }
84
166
  if (what === 'read' || what === 'test') {
85
167
  if (!ctx.metricReadRuns) return send(bad(503, 'Claude\'s runs are off on this server.'));
@@ -92,6 +174,7 @@ async function handle(req, res, url, ctx) {
92
174
  const r = ctx.metricReadRuns.start({ ws: w.id, rids, why: what === 'test' ? 'test' : 'press' });
93
175
  return send(r && r.ok ? { status: 200, body: { ok: true, run: r.run, rids: r.rids } } : bad(409, (r && r.error) || 'Claude could not start reading.'));
94
176
  }
177
+ if (what === 'file-held' || what === 'compare' || what === 'compare-pick') return send(heldOrCompare(ctx, w, what, body, { root, id, rec }));
95
178
  // csv: the fallback when no connector reads it
96
179
  if (!rec) return send(bad(404, 'There is no such goal.'));
97
180
  const p = MR.parseCsv(text(body.csv));
@@ -101,7 +101,7 @@ module.exports = {
101
101
  wdir = ctx.stateDirFor ? ctx.stateDirFor(ctx.getWs(pick.ws)) : null;
102
102
  const R = require(repoScript('records/index.js')), lines = R.readLines(R.fileOf(recordsDirFor(ctx, ws), 'kr-metrics')), GW = require('./goal-watch.js');
103
103
  const history = Object.fromEntries(Object.keys(goalMeta).map((rid) => [rid, GW.historyOf(lines, rid)]));
104
- watch = { reads: wdir ? require('./metric-reads.js').read(wdir) : null, history, drafts: wdir ? openDrafts(wdir, pick.ws) : 0 };
104
+ watch = { reads: wdir ? require('./metric-reads.js').read(wdir) : null, history, drafts: wdir ? openDrafts(wdir, pick.ws) : 0, now: Date.now(), hours: ctx.metricReadHours ? ctx.metricReadHours() : undefined };
105
105
  } catch { watch = null; }
106
106
  }
107
107
  const model = Insights.build({
@@ -52,7 +52,26 @@ function wsFor(ctx, ws, scope, id) {
52
52
  return w;
53
53
  }
54
54
  const offNow = (ctx) => Runs.off(ctx.env || process.env);
55
- const viewFor = (ctx, w, scope, id) => { const dir = dirOf(ctx, w); return MD.viewOf(dir ? MD.read(dir) : null, scope, id, { off: offNow(ctx) }); };
55
+ const viewFor = (ctx, w, scope, id) => { const dir = dirOf(ctx, w); return liveRows(MD.viewOf(dir ? MD.read(dir) : null, scope, id, { off: offNow(ctx) }), dir); };
56
+ /** Batch 18 item 11 (contract next18/11-okr-clarity/api-contract.md §2, §5): a drafted row with a recipe says how it is counted, how often it is
57
+ * read, its live read with Claude's checks, and the PM's own number against it. */
58
+ function liveRows(view, dir) {
59
+ let F = null; try { F = dir ? require('./metric-reads.js').read(dir) : null; } catch { F = null; }
60
+ const MR = require('./metric-reads.js');
61
+ for (const r of view.rows || []) {
62
+ if (!r.recipe) continue;
63
+ const u = (r.metric && r.metric.unit) || r.unit || '';
64
+ r.counts = r.recipe.counts || null; r.rhythm = MR.rhythmOf(r.recipe);
65
+ const t = F && F.rids.get(r.id) && F.rids.get(r.id).test;
66
+ if (t) {
67
+ r.live = t.ok ? { at: t.at, ok: true, value: t.value, txt: MR.fmt(t.value, u), source: t.source || '', ...(Number.isFinite(t.num) ? { num: t.num } : {}), ...(Number.isFinite(t.den) ? { den: t.den } : {}), ...(t.period ? { period: t.period } : {}), ...(t.held ? { held: true } : {}) }
68
+ : { at: t.at, ok: false, error: t.error };
69
+ if (t.checks) { r.checks = t.checks; r.live.checks = t.checks; }
70
+ }
71
+ const c = F ? MR.compareView(F, r.id, u) : null; if (c) r.compare = c;
72
+ }
73
+ return view;
74
+ }
56
75
 
57
76
  async function handle(req, res, url, ctx) {
58
77
  const send = (r) => { ctx.json(res, r.body, r.status); return true; };
@@ -126,7 +145,7 @@ async function handle(req, res, url, ctx) {
126
145
  let r; try { r = records().add(root, 'kr-metrics', kf.fields, UI(), k === 'outcome' ? 'Kept the outcome Claude drafted for a project-shaped goal' : 'Kept next quarter\'s goal Claude drafted'); } catch (e) { return { error: 'The record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
127
146
  if (!r.ok) return { error: r.reasons.join('; ') };
128
147
  // the test read (lib/metric-reads.js), else the reading it was drafted from, is the first reading, with its source
129
- let test = null; try { const x = require('./metric-reads.js').read(dir).rids.get(row.id); test = x && x.test && x.test.ok ? x.test : null; } catch { test = null; }
148
+ let test = null; try { const x = require('./metric-reads.js').read(dir).rids.get(row.id); test = x && x.test && x.test.ok && !x.test.held ? x.test : null; } catch { test = null; }
130
149
  const first = test ? { at: test.day, value: test.value, source: test.source, via: 'run', read_at: test.at } : kf.reading;
131
150
  if (first) { try { records().addReading(root, r.rid, first, UI(), test ? 'The test read before you kept it' : 'The reading Claude drafted it from'); } catch { /* the record stands */ } }
132
151
  return done({ rid: r.rid });
@@ -147,7 +166,10 @@ async function handle(req, res, url, ctx) {
147
166
  let r;
148
167
  try { r = records().add(root, 'kr-metrics', k.fields, UI(), 'Kept a metric Claude drafted'); } catch (e) { return { error: 'The record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
149
168
  if (!r.ok) return { error: r.reasons.join('; ') };
150
- if (k.reading) { try { records().addReading(root, r.rid, k.reading, UI(), 'The reading Claude drafted it from'); } catch { /* the record stands; the next reading fills it */ } }
169
+ // batch 18 item 11: a good live read (not held) is the first reading, with its counts; else the reading it was drafted from
170
+ let live = null; try { const x = require('./metric-reads.js').read(dir).rids.get(row.id); live = x && x.test && x.test.ok && !x.test.held ? x.test : null; } catch { live = null; }
171
+ const first = live ? { at: live.day, value: live.value, source: live.source, via: 'run', read_at: live.at, ...(Number.isFinite(live.num) ? { num: live.num } : {}), ...(Number.isFinite(live.den) ? { den: live.den } : {}), ...(live.period ? { period: live.period } : {}) } : k.reading;
172
+ if (first) { try { records().addReading(root, r.rid, first, UI(), live ? 'The live read before you kept it' : 'The reading Claude drafted it from'); } catch { /* the record stands; the next reading fills it */ } }
151
173
  MD.append(dir, g.actor, { kind: 'keep', scope, id, row: row.id, rid: r.rid }, at());
152
174
  return { rid: r.rid };
153
175
  };
@@ -165,6 +187,7 @@ async function handle(req, res, url, ctx) {
165
187
  const r = keepOne(row);
166
188
  if (r.error) return send(bad(400, r.error));
167
189
  const out = { ok: true, rid: r.rid || null }; for (const k of ['outbox', 'open', 'connector']) if (r[k]) out[k] = r[k];
190
+ if (row.recipe) out.rhythm = require('./metric-reads.js').rhythmOf(row.recipe); // batch 18 item 11: the Kept toast names the goal's own rhythm
168
191
  return send({ status: 200, body: out });
169
192
  }
170
193
  if (what === 'edit') {
@@ -0,0 +1,178 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* live-pill-round-test.js — the Live pill as a round number, the panel divider's look and the list head's fold (feedback batch 18 item 15,
4
+ * slice 15-B; canvas TbT1Split, TbT4Off, TbT9Divider; brief next18/briefs/15-arrange-panels-build.md rules 9 to 11). The real pages from the
5
+ * real server; GET /api/live is answered by the suite, so the pill's state is the suite's.
6
+ * L1 nothing live: no pill · L2 the pill is a 44 px round button stacked above the menu button, with the number of live items and no marks
7
+ * L3 Claude asks: blue with a glow · L4 with the panels engine a press goes to czPanels.slideOver(item) · L6 false from it: today's open
8
+ * L5 the open menu hides the pill · V1 the first divider wears the sprout, the others only the handle · V2 the day's charm replaces the
9
+ * sprout, fitted to its box · V3 Settings > Adler > Off: the handle only · F1 Home's list head folds the list, and the button brings it back
10
+ * F2 a phone: no fold · every page: no page error
11
+ * PMOS_SHOTS=<dir> also saves the screenshots. */
12
+ const path = require('path');
13
+ const fs = require('fs');
14
+ const { spawn } = require('child_process');
15
+ const { findBrowser } = require('./lib/find-browser');
16
+ const T = require('./test-run').configure({ name: 'live-pill-round' });
17
+
18
+ const BASE = T.BASE;
19
+ const SHOTS = process.env.PMOS_SHOTS || '';
20
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
21
+ const until = async (fn, ms = 10000, 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); } };
22
+ const results = [];
23
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
24
+ let srv = null; let browser = null;
25
+ const finish = async (code) => {
26
+ if (browser) await browser.close().catch(() => {});
27
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
28
+ T.killTmux();
29
+ const bad = results.filter((x) => !x.cond).length;
30
+ console.log(`\n${results.length - bad}/${results.length} live-pill-round assertions passed`);
31
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
32
+ };
33
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
34
+
35
+ const min = (n) => new Date(Date.now() - n * 60000).toISOString();
36
+ const RUNNING = () => [
37
+ { id: 'a', name: 'chat: Draft CIAM tender workflow', shown: 'working', created: min(90), touched_at: min(4), origin: 'chat:init:tender' },
38
+ { id: 'd', name: 'List migration tasks', shown: 'working', created: min(200), touched_at: min(25) },
39
+ ];
40
+ const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items', shown: 'needs', created: min(80), touched_at: min(1), initiative: 'tender' }]);
41
+
42
+ (async () => {
43
+ const exe = process.env.PMOS_CHROME || findBrowser();
44
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the live-pill-round suite cannot run'); return finish(1); }
45
+ let chromium;
46
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
47
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
48
+ await T.waitForServer(BASE);
49
+ browser = await chromium.launch({ executablePath: exe });
50
+ if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
51
+ const shot = async (page, name) => { if (SHOTS) { await sleep(300); await page.screenshot({ path: path.join(SHOTS, name + '.png') }); } };
52
+
53
+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
54
+ let live = [];
55
+ await ctx.route('**/api/live', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, sessions: live, titles: { tender: 'Tender new CIAM' } }) }));
56
+ const page = await ctx.newPage();
57
+ const errors = [];
58
+ page.on('pageerror', (e) => errors.push(String(e)));
59
+ const kick = () => page.evaluate(() => document.dispatchEvent(new Event('cz:live')));
60
+
61
+ /* L1 */
62
+ await page.goto(BASE + '/premium-board.html');
63
+ await until(() => page.evaluate(() => !!document.getElementById('czLive')), 30000);
64
+ await sleep(500);
65
+ ok('L1 nothing live: no pill (zero is silence)', await page.evaluate(() => document.getElementById('czLive').hidden));
66
+
67
+ /* L2 */
68
+ live = RUNNING(); await kick();
69
+ const l2 = await until(() => page.evaluate(() => {
70
+ const l = document.getElementById('czLive'), f = document.getElementById('czFab'); if (!l || l.hidden) return null;
71
+ const a = l.getBoundingClientRect(), b = f.getBoundingClientRect();
72
+ 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
+ }));
75
+ 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 menu button on its centre line', l2 && l2.w === 44 && l2.h === 44 && l2.round === '50%' && l2.above && l2.centred, JSON.stringify(l2));
77
+ 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
+ await shot(page, 'pill-running');
79
+
80
+ /* L3 */
81
+ live = ASKS(); await kick();
82
+ const l3 = await until(() => page.evaluate(() => { const l = document.getElementById('czLive'); return l && l.classList.contains('asks') ? { text: l.textContent.trim(), bg: getComputedStyle(l).backgroundColor, card: getComputedStyle(document.body).getPropertyValue('--cz-card') } : null; }));
83
+ ok('L3 Claude asks: the pill turns blue, with the count', l3 && l3.text === '3' && !/255, 255, 255/.test(l3.bg), JSON.stringify(l3));
84
+ await shot(page, 'pill-asks');
85
+
86
+ /* L4 */
87
+ await page.click('#czLive');
88
+ const rows = await until(() => page.evaluate(() => { const r = [...document.querySelectorAll('#czLiveList a[data-lv]')]; return r.length ? r.length : null; }));
89
+ ok('L4 the list opens with its rows (the panels engine drags a[data-lv] to an edge)', rows === 3, String(rows));
90
+ await shot(page, 'pill-list');
91
+ await page.evaluate(() => { window.__slid = []; window.czPanels = { slideOver: (x) => window.__slid.push(x), list: () => [] }; });
92
+ const before = page.url();
93
+ await page.click('#czLiveList a[data-lv="s:b"]');
94
+ const l4 = await until(() => page.evaluate(() => (window.__slid && window.__slid.length ? { id: window.__slid[0].id, sid: window.__slid[0].sid, open: !document.getElementById('czLiveList').hidden } : null)));
95
+ ok('L4 with the panels engine, a row goes to czPanels.slideOver(item) and the list closes; the page stays', l4 && l4.id === 's:b' && l4.sid === 'b' && !l4.open && page.url() === before, JSON.stringify(l4));
96
+ await page.evaluate(() => { delete window.czPanels; });
97
+
98
+ /* L5 */
99
+ await page.click('#czFab');
100
+ ok('L5 the open menu takes the place above the menu button: the pill hides', await until(() => page.evaluate(() => getComputedStyle(document.getElementById('czLive')).visibility === 'hidden')));
101
+ await page.keyboard.press('Escape');
102
+ await page.evaluate(() => { const m = document.getElementById('czMenu'); if (m && !m.hidden) document.getElementById('czFab').click(); });
103
+
104
+ /* V1–V3: the divider, mounted the way the engine mounts it */
105
+ const v1 = await page.evaluate(async () => {
106
+ const D = await import('/pm/cozy-divider.js'), A = await import('/pm/cozy-adler.js');
107
+ A.setPrefs({ 'adler.amount': 'full' }); A.setDress(null);
108
+ const box = document.createElement('div'); box.id = 'dvTest'; box.style.cssText = 'position:fixed;left:200px;top:100px;width:600px;height:400px;display:flex;gap:12px;z-index:99';
109
+ // as cozy-panels.js mounts it: a 0-wide separator, and the look inside a wrapper centred on it
110
+ const div = (first) => `<div class="cz-pn-div" role="separator" tabindex="0" style="position:relative;width:0;margin:0 -6px"><span class="cz-pn-in" style="position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)">${D.dividerHtml({ first })}</span></div>`;
111
+ box.innerHTML = `<div style="flex:1;background:var(--cz-card)"></div>${div(true)}<div style="flex:1;background:var(--cz-card)"></div>${div(false)}<div style="flex:1;background:var(--cz-card)"></div>`;
112
+ document.body.appendChild(box);
113
+ await new Promise((r) => setTimeout(r, 300));
114
+ const [a, b] = box.querySelectorAll('.cz-pn-div'), hd = a.querySelector('.cz-dv-hd').getBoundingClientRect(), dv = a.getBoundingClientRect();
115
+ const sp = a.querySelector('.cz-dv-top .cz-dv-sp'), spr = sp && sp.getBoundingClientRect();
116
+ return { dots: a.querySelectorAll('.cz-dv-hd b').length, sprout: !!sp, second: !b.querySelector('.cz-dv-top'), hidden: a.querySelector('.cz-dv-top').getAttribute('aria-hidden'),
117
+ centred: Math.abs((hd.left + hd.width / 2) - (dv.left + dv.width / 2)) <= 1 && Math.abs((hd.top + hd.height / 2) - (dv.top + dv.height / 2)) <= 1,
118
+ onTop: !!spr && spr.bottom <= hd.top + 1 && Math.abs((spr.left + spr.width / 2) - (hd.left + hd.width / 2)) <= 2, face: !!a.querySelector('.ad-face') };
119
+ });
120
+ ok('V1 the first divider: a handle with 3 dots in its middle, and Adler\'s sprout on top (never his face)', v1.dots === 3 && v1.sprout && v1.centred && v1.onTop && !v1.face && v1.hidden === 'true', JSON.stringify(v1));
121
+ ok('V1 any other divider: the handle only', v1.second, JSON.stringify(v1));
122
+ const hov = await page.evaluate(async () => { const a = document.querySelector('#dvTest .cz-pn-div'), hd = a.querySelector('.cz-dv-hd'); const rest = getComputedStyle(hd).backgroundColor; a.classList.add('hov'); await new Promise((r) => setTimeout(r, 250)); const on = getComputedStyle(hd).backgroundColor; const lf = getComputedStyle(a.querySelector('.cz-dv-lf.l1')).transform; a.classList.remove('hov'); a.classList.add('drag'); await new Promise((r) => setTimeout(r, 300)); const lean = getComputedStyle(a.querySelector('.cz-dv-sp')).transform; a.classList.remove('drag'); return { rest, on, lf, lean }; });
123
+ ok('V1 hover turns the handle blue and opens the leaves; a drag leans the sprout (the engine draws the line)', hov.rest !== hov.on && hov.lf !== 'none' && hov.lean !== 'none', JSON.stringify(hov));
124
+ await page.evaluate(() => document.querySelector('#dvTest .cz-pn-div').classList.add('hov'));
125
+ await shot(page, 'divider-sprout-hover');
126
+ await page.evaluate(() => document.querySelector('#dvTest .cz-pn-div').classList.remove('hov'));
127
+ const v2 = await page.evaluate(async () => {
128
+ const A = await import('/pm/cozy-adler.js');
129
+ A.setDress({ key: 'deepavali', name: 'Deepavali' });
130
+ await new Promise((r) => setTimeout(r, 300));
131
+ const t = document.querySelector('#dvTest .cz-dv-top'), s = t.querySelector('.cz-dv-ch svg');
132
+ return { charm: t.querySelector('.cz-dv-ch') && t.querySelector('.cz-dv-ch').dataset.charm, sprout: !!t.querySelector('.cz-dv-sp'), fitted: !!s && !s.hasAttribute('data-ad-fit'), box: s && s.getAttribute('viewBox'), w: s && Math.round(s.getBoundingClientRect().width), second: !document.querySelectorAll('#dvTest .cz-pn-div')[1].querySelector('.cz-dv-top') };
133
+ });
134
+ ok('V2 the day\'s charm (Deepavali) sits there instead of the sprout, fitted to its 26 px box, first divider only', v2.charm === 'deepavali' && !v2.sprout && v2.fitted && v2.w === 26 && v2.second, JSON.stringify(v2));
135
+ await shot(page, 'divider-charm');
136
+ const v3 = await page.evaluate(async () => {
137
+ const A = await import('/pm/cozy-adler.js');
138
+ A.setPrefs({ 'adler.amount': 'face' }); await new Promise((r) => setTimeout(r, 100));
139
+ const face = { sprout: !!document.querySelector('#dvTest .cz-dv-sp'), charm: !!document.querySelector('#dvTest .cz-dv-ch') };
140
+ A.setPrefs({ 'adler.amount': 'off' }); await new Promise((r) => setTimeout(r, 100));
141
+ const off = document.querySelector('#dvTest .cz-dv-top').innerHTML === '' && document.querySelectorAll('#dvTest .cz-dv-hd').length === 2;
142
+ A.setPrefs({ 'adler.amount': 'full' }); A.setDress(null); document.getElementById('dvTest').remove();
143
+ return { face, off };
144
+ });
145
+ ok('V3 Settings > Adler > Face only: the sprout, no charm; Off: the handle only', v3.face.sprout && !v3.face.charm && v3.off, JSON.stringify(v3));
146
+
147
+ /* L6 */
148
+ await page.evaluate(() => { window.czPanels = { slideOver: () => false, list: () => [] }; });
149
+ await page.click('#czLive');
150
+ await until(() => page.$('#czLiveList a[data-lv="s:b"]'));
151
+ await Promise.all([page.waitForURL(/premium\.html\?session=b/, { timeout: 15000 }).catch(() => null), page.click('#czLiveList a[data-lv="s:b"]')]);
152
+ ok('L6 czPanels.slideOver(item) gives false (it did nothing): the row opens as today', /premium\.html\?session=b/.test(page.url()), page.url());
153
+
154
+ /* F1 */
155
+ await page.goto(BASE + '/premium.html');
156
+ const f1 = await until(() => page.evaluate(() => { const b = document.querySelector('#hmList .hm-hd [data-hm-fold]'); return b ? { label: b.getAttribute('aria-label'), title: b.title, text: b.textContent.trim(), svg: !!b.querySelector('svg') } : null; }), 30000);
157
+ ok('F1 the list head has an icon-only fold, named and with a tooltip', f1 && f1.label === 'Fold the list to the rail' && f1.title === f1.label && !f1.text && f1.svg, JSON.stringify(f1));
158
+ await shot(page, 'home-fold');
159
+ await page.click('#hmList .hm-hd [data-hm-fold]');
160
+ ok('F1 with no Viewer open, the press folds the list away', await until(() => page.evaluate(() => document.body.classList.contains('hm-folded') && getComputedStyle(document.querySelector('#hmList')).display === 'none')));
161
+ await page.click('#hmUnfold');
162
+ ok('F1 the button at the top left brings it back', await until(() => page.evaluate(() => !document.body.classList.contains('hm-folded') && !!document.querySelector('#hmList .hm-hd [data-hm-fold]'))));
163
+ ok('every page: no page error', errors.length === 0, errors.join(' | '));
164
+
165
+ /* F2 */
166
+ const pctx = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true });
167
+ await pctx.route('**/api/live', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, sessions: ASKS(), titles: {} }) }));
168
+ const ph = await pctx.newPage();
169
+ await ph.goto(BASE + '/premium-board.html');
170
+ const f2 = await until(() => ph.evaluate(() => { const l = document.getElementById('czLive'), f = document.getElementById('czFab'); if (!l || l.hidden) return null; const a = l.getBoundingClientRect(), b = f.getBoundingClientRect(); return { above: a.bottom <= b.top, right: Math.abs((a.left + a.width / 2) - (b.left + b.width / 2)) <= 1, w: Math.round(a.width), text: l.textContent.trim() }; }), 30000);
171
+ ok('F2 a phone: the round pill stacks above the menu button at the bottom right', f2 && f2.above && f2.right && f2.w === 44 && f2.text === '3', JSON.stringify(f2));
172
+ await shot(ph, 'phone-pill');
173
+ await ph.goto(BASE + '/premium.html');
174
+ await until(() => ph.evaluate(() => !!document.querySelector('#hmList .hm-hd')), 30000);
175
+ ok('F2 a phone has no rail, so no fold', await ph.evaluate(() => !document.querySelector('[data-hm-fold]')));
176
+ await pctx.close();
177
+ await finish();
178
+ })();
@@ -40,7 +40,8 @@ const PROGRAM = () => ({
40
40
  rows: [
41
41
  { id: 'g', group: 'Program goal', name: 'Sign-ins on CIAM, all products', type: 'Percentage', now: 12, nowTxt: '12%', target: 100, targetTxt: '100%', by: '2028-06-30',
42
42
  why: 'idpf is 80% of all sign-ins, so it carries the goal. I check it every morning once you keep it.', source: 'Amplitude', ticket: null,
43
- checkpoints: [{ by: '2027-02-27', target: 40, label: 'Legacy IdP off' }, { by: '2027-03-20', target: 85, label: 'All microsites' }], state: 'open' },
43
+ checkpoints: [{ by: '2027-02-27', target: 40, label: 'Legacy IdP off' }, { by: '2027-03-20', target: 85, label: 'All microsites' }], state: 'open',
44
+ recipe: { connector: 'Amplitude', query: 'sign-ins on CIAM ÷ all sign-ins', cadence: 'weekly', at: '07:00', day: 'mon' } },
44
45
  { id: 'r1', group: 'Rolls up from', name: 'idpf · sign-ins on CIAM', type: 'Percentage', now: 15, nowTxt: '15%', target: 100, targetTxt: '100%', by: '2027-02-27', why: '', source: 'Amplitude', ticket: null, state: 'open' },
45
46
  { id: 'r2', group: 'Rolls up from', name: 'Microsites · sign-ins on CIAM', type: 'Percentage', now: null, nowTxt: '', target: 100, targetTxt: '100%', by: '2027-03-20', why: 'No event counts it yet.', source: '', ticket: { key: 'MS-212', text: 'MS-212 drafted' }, state: 'open' },
46
47
  { id: 'gr', group: 'Guardrail', name: 'Sign-in success', type: 'Stay within', now: 99.6, nowTxt: '99.6%', target: 99, targetTxt: 'stays above 99%', by: null, why: '', source: 'Amplitude', ticket: null, state: 'open' },
@@ -138,7 +139,9 @@ const INITIATIVE = () => ({
138
139
  ok('K the Goal row of chips, each with a dot: ok with a reading, off while it waits on a ticket', !!kept && kept.first && kept.per === 'Goal' && !kept.card
139
140
  && kept.chips.join(' / ') === 'ok:Sign-ins on CIAM, all products12% of 100% · Jun 2028 / ok:idpf · sign-ins on CIAM15% of 100% · Feb 27 / off:Microsites · sign-ins on CIAMwaits on MS-212 / ok:Sign-in successstays above 99%', JSON.stringify(kept));
140
141
  ok('K Undo is beside it, icon-only', !!kept && kept.undo === 'Undo');
141
- ok('K the toast says what happens next, in first person', /I check the goal every morning/.test(await p.evaluate(() => (document.querySelector('#bdToast') || {}).textContent || '')));
142
+ // batch 18 item 11: the toast names the goal's own rhythm, never "every morning"
143
+ const kt = await p.evaluate(() => (document.querySelector('#bdToast') || {}).textContent || '');
144
+ ok('K the toast says what happens next, in first person, with the goal\'s own rhythm', kt.includes('Kept. I read the goal every Monday 07:00.') && !/every morning/.test(kt), kt);
142
145
  await shot(p, 'Iq9Program-kept-built');
143
146
 
144
147
  /* ── U: Undo ── */
@@ -4,14 +4,14 @@
4
4
  * GsMetrics, GsMetricsTree, GsNotify). Serves the real page from the real server; GET /api/insights-premium answers the model lib/insights-premium.js
5
5
  * builds from its fixture, with the fields lib/goal-status.js adds (reading, recipe, who, notify, was, history, defn, okr) set on some goals, and
6
6
  * GET /api/metric-drafts answers drafts that sit under their goal. The write routes are stubbed here so each press can be read back.
7
- * L the list: the ✦ line, the North Star, Key results, Health budgets, in that order; a row is a dot, the outcome, its reading and age, and the
8
- * owner, with no sparkline and no initiative status; a goal with no reading has a hollow dot
7
+ * L the dashboard (re-pointed, batch 18 item 11 gap: Iq8Overview with GcJ2FirstMonday): the ✦ line, the North Star card, Key results, Health
8
+ * budgets, in that order; a row is the outcome, Now of target, So far, By its date and Moved by; a goal with no reading shows a dash
9
9
  * D a draft sits under the row it repairs with ✕ / ✎ / ✓; ✓✓ in the ✦ line keeps them all; ✓ posts the row; the ✦ line never says "no insight"
10
- * R a broken limit turns the ✦ line red (the one time) and pulses that row's dot
10
+ * R a broken limit turns the ✦ line red (the one time) and pulses the North Star's dot
11
11
  * V the goal Viewer: the reading against its line, the chart, why, and the folds How I read it, What it counts, History
12
12
  * N the Viewer's ⋯: Notify me, Only in Intelligence (✦ my pick, on), Quiet; a press posts /api/goals/notify
13
13
  * M ⋯ › Metrics: one list, goals first then "watch"; one switch shows the tree
14
- * P on a phone: no sideways scroll, the same list. PMOS_SHOTS=<dir> also saves screenshots. */
14
+ * P on a phone: no sideways scroll, each key result a card with its drafts. PMOS_SHOTS=<dir> also saves screenshots. */
15
15
  const path = require('path');
16
16
  const fs = require('fs');
17
17
  const { spawn } = require('child_process');
@@ -85,29 +85,31 @@ const ROWS = [
85
85
  for (const k of ['keep', 'keep-all', 'drop', 'edit', 'undo', 'start']) await page.route('**/api/metric-drafts/' + k, (r) => { posts.push({ path: '/api/metric-drafts/' + k, body: JSON.parse(r.request().postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: JSON.stringify(k === 'keep' ? { ok: true, rid: 'r1' } : { ok: true, kept: 3 }) }); });
86
86
  await page.route('**/api/goals/notify', (r) => { posts.push({ path: '/api/goals/notify', body: JSON.parse(r.request().postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }); });
87
87
  await page.goto(BASE + '/premium-intelligence.html?theme=' + theme);
88
- await until(() => page.evaluate(() => document.querySelectorAll('#goalTbl .okr-row').length > 0), 20000);
88
+ await until(() => page.evaluate(() => document.querySelectorAll('#goalTbl .ins-row').length > 0), 20000);
89
89
  await until(() => page.evaluate(() => !!document.querySelector('#goalTbl .okr-dr')), 6000);
90
90
  return { ctx, page, errors, posts };
91
91
  };
92
92
  const txt = (p, s) => p.evaluate((x) => { const e = document.querySelector(x); return e ? e.textContent.replace(/\s+/g, ' ').trim() : ''; }, s);
93
93
 
94
- /* L · the list */
94
+ /* L · the dashboard (re-pointed, batch 18 item 11 gap: the agreed goals dashboard is Iq8Overview again, GcJ2FirstMonday and GcJ4Full: the
95
+ * North Star card with its line and its inputs, then one table of key results and health budgets; the owner is on the work in Moved by) */
95
96
  const R = await open(), p = R.page;
96
- const order = await p.evaluate(() => [...document.querySelectorAll('#insHero, #nsRow .okr-h, #goalTbl .okr-h')].filter((e) => e.offsetParent !== null).map((e) => e.id === 'insHero' ? '✦' : e.textContent));
97
+ const order = await p.evaluate(() => [...document.querySelectorAll('#insHero, #nsRow .ins-nsc .ins-lbl2, #goalTbl .ins-th [role="columnheader"]:first-child, #goalTbl .ins-grp [role="cell"]')].filter((e) => e.offsetParent !== null).map((e) => e.id === 'insHero' ? '✦' : e.childNodes[0].textContent.trim()).filter((x) => !/^Objective/.test(x)));
97
98
  ok('L1 top to bottom: the ✦ line, North Star, Key results, Health budgets', order.join('|') === '✦|North Star|Key results|Health budgets', order.join('|'));
98
- const rows = await p.evaluate(() => [...document.querySelectorAll('#goalTbl [data-goal]')].map((r) => ({ id: r.dataset.goal, dot: (r.querySelector('.okr-main .cz-dot') || {}).className || '', meta: r.querySelector('.okr-main .note').textContent, av: !!r.querySelector('.okr-main .okr-av'), svg: !!r.querySelector('.okr-main svg'), pill: !!r.querySelector('.okr-main .cz-pill') })));
99
+ const rows = await p.evaluate(() => [...document.querySelectorAll('#goalTbl .ins-row[data-goal]')].map((r) => ({ id: r.dataset.goal, now: r.querySelector('.val').textContent.replace(/\s+/g, ' ').trim(), sofar: !!r.querySelector('.sofar svg, .sofar .ins-one, .sofar .note'), pace: r.querySelector('.pace').textContent.replace(/\s+/g, ' ').trim(), mv: !!r.querySelector('.mv') })));
99
100
  const act = rows.find((r) => r.id === 'krm-act') || {}, churn = rows.find((r) => r.id === 'krm-churn') || {};
100
- ok('L2 a row is the dot, the outcome, its reading and the owner: no chart and no initiative status', rows.length >= 4 && rows.every((r) => r.av && !r.svg && !r.pill), JSON.stringify(rows));
101
- ok('L3 the reading the status function sent is the row\'s line, behind is amber', act.meta === '+8 of +30 points · its line says +18' && /risk/.test(act.dot), JSON.stringify(act));
102
- ok('L4 a goal with no reading has a hollow dot and says so', /hollow/.test(churn.dot) && /No reading yet/.test(churn.meta), JSON.stringify(churn));
103
- ok('L5 the owner avatar shows the initials; no owner is the dashed circle', await p.evaluate(() => document.querySelector('[data-goal="krm-act"] .okr-av').textContent === 'RP' && !!document.querySelector('[data-goal="krm-churn"] .okr-av.none')));
104
- ok('L6 the North Star is a row in its own card, read and dated', /99\.6% · up 0\.4 since 1 Sep/.test(await txt(p, '#nsRow [data-goal="krm-up"]')));
101
+ ok('L2 a row is the outcome, Now of target, So far, By its date and Moved by', rows.length >= 4 && rows.every((r) => r.sofar && r.mv && r.pace), JSON.stringify(rows));
102
+ ok('L3 a key result says its reading of its target and its pace by its date', /of \+?30|of 50%/.test(act.now) && /by Dec 31/.test(act.pace), JSON.stringify(act));
103
+ ok('L4 a goal with no reading shows a dash and says so', /—/.test(churn.now) && /No reading yet/i.test(JSON.stringify(churn)) , JSON.stringify(churn));
104
+ const ns = await txt(p, '#nsRow .ins-nsc');
105
+ ok('L6 the North Star is its own card with its number, its change and its line', /North Star Partner uptime/.test(ns) && /99\.6%/.test(ns) && !!(await p.$('#nsRow .ins-nsch')), ns);
105
106
  await shot(p, 'okr-desktop-light');
106
107
 
107
108
  /* D · drafts */
108
- const under = await p.evaluate(() => ({ chase: !!document.querySelector('[data-goal="krm-act"] [data-draft="d-chase"]'), out: !!document.querySelector('[data-goal="krm-ttfc"] [data-draft="d-out"]'), kr: !!document.querySelector('#goalTbl [data-draft-row="d-kr"]'),
109
- acts: [...document.querySelectorAll('[data-draft="d-chase"] .acts button')].map((b) => b.getAttribute('aria-label').split(':')[0]), old: (document.querySelector('[data-draft="d-out"] .okr-old') || {}).textContent || '' }));
110
- ok('D1 each draft sits under the row it repairs; a drafted key result is a hollow row of its own', under.chase && under.out && under.kr, JSON.stringify(under));
109
+ const under = await p.evaluate(() => ({ chase: !!document.querySelector('[data-drafts-for="krm-act"] [data-draft="d-chase"]'), out: !!document.querySelector('[data-drafts-for="krm-ttfc"] [data-draft="d-out"]'), kr: !!document.querySelector('#draftBox [data-gc-row="d-kr"]') && !document.querySelector('#goalTbl [data-draft-row="d-kr"]'),
110
+ acts: [...document.querySelectorAll('#goalTbl [data-draft="d-chase"] .acts button')].map((b) => b.getAttribute('aria-label').split(':')[0]), old: (document.querySelector('[data-draft="d-out"] .okr-old') || {}).textContent || '' }));
111
+ // batch 18 item 11 (GcJ1aTable): a drafted key result is a row of the drafts table, no longer a hollow row in the list
112
+ ok('D1 each draft sits under the row it repairs; a drafted key result is a row of the drafts table', under.chase && under.out && under.kr, JSON.stringify(under));
111
113
  ok('D2 a draft has ✕ / ✎ / ✓, and ✓ says its act (Send)', under.acts.join('|') === 'Not now|Edit|Send', under.acts.join('|'));
112
114
  ok('D3 an outcome draft says what it was', under.old === 'Was “Time to first call”', under.old);
113
115
  const line = await p.evaluate(() => ({ t: document.querySelector('#brief').textContent + ' ' + document.querySelector('#insWhy').textContent, all: !!document.querySelector('#insAct [data-okl="keep-all"]') }));
@@ -124,13 +126,14 @@ const ROWS = [
124
126
  ok('D8 ✓ on the edit posts what was typed (a fix row posts its text, lib/metric-drafts.js editOf)', await until(() => R.posts.some((x) => x.path === '/api/metric-drafts/edit' && x.body.row === 'd-out' && x.body.text === 'New partners call us within 3 days' && x.body.name === undefined)));
125
127
 
126
128
  /* V · the goal Viewer */
127
- await p.click('#goalTbl [data-goal="krm-act"] .okr-main');
129
+ await p.click('#goalTbl [data-goal="krm-act"] .nm');
128
130
  const v = await until(() => p.evaluate(() => { const V = document.querySelector('#czViewer'); if (!V || V.hidden) return null; return { title: (V.querySelector('.cz-vw-title') || {}).textContent || '', head: (V.querySelector('.okr-vh') || {}).textContent || '', chart: !!V.querySelector('.ins-gbig svg'), why: (V.querySelector('.okr-why') || {}).textContent || '', folds: [...V.querySelectorAll('.czs-row b')].map((b) => b.textContent) }; }), 5000);
129
131
  ok('V1 the Viewer opens on the goal with its reading against its line and the owner', v && /Partner activation/.test(v.title) && /\+8 of \+30 points/.test(v.head) && /its line says \+18/.test(v.head) && /RP/.test(v.head), JSON.stringify(v));
130
132
  ok('V2 then the chart and why it moved', v && v.chart && /catches up about 3 weeks/.test(v.why), JSON.stringify(v));
131
- ok('V3 then three folds: How I read it, What it counts, History', v && v.folds.slice(0, 3).join('|') === 'How I read it|What it counts|History', v && v.folds.join('|'));
132
- await p.click('#czViewer [data-czs-fold="read"]'); await sleep(120);
133
- ok('V4 How I read it says the source, what is read and how often', /Amplitude/.test(await txt(p, '#czViewer [data-czs-id="read"]')) && /partners active ÷ partners signed/.test(await txt(p, '#czViewer [data-czs-id="read"]')) && /Weekly/.test(await txt(p, '#czViewer [data-czs-id="read"]')));
133
+ // batch 18 item 11 (GcR3Goal): where it is read from, how often and the query are said once above the chart; the first fold is its Readings
134
+ ok('V3 then three folds: Readings, What it counts, History', v && v.folds.slice(0, 3).join('|') === 'Readings|What it counts|History', v && v.folds.join('|'));
135
+ const how = await txt(p, '#czViewer .gc-kr');
136
+ ok('V4 it says once where it is read from, how often and what is read', /From Amplitude, every Monday\. Last /.test(how) && /partners active ÷ partners signed/.test(how), how);
134
137
  await shot(p, 'okr-viewer-desktop');
135
138
 
136
139
  /* N · notify */
@@ -158,7 +161,7 @@ const ROWS = [
158
161
 
159
162
  /* R · a broken limit */
160
163
  const C = await open({ m: model({ crit: true }), rows: [] });
161
- const cr = await C.page.evaluate(() => ({ crit: document.querySelector('#insHero').classList.contains('crit'), t: document.querySelector('#brief').textContent, pulse: !!document.querySelector('#nsRow [data-goal="krm-up"] .cz-dot.m-crit') }));
164
+ const cr = await C.page.evaluate(() => ({ crit: document.querySelector('#insHero').classList.contains('crit'), t: document.querySelector('#brief').textContent, pulse: !!document.querySelector('#nsRow .ins-nsc .cz-dot.m-crit') }));
162
165
  ok('R1 a broken limit is the one time the ✦ line turns red, and its dot pulses', cr.crit && /fell under its floor/.test(cr.t) && cr.pulse, JSON.stringify(cr));
163
166
  await shot(C.page, 'okr-crit', '#stage');
164
167
  await C.ctx.close();
@@ -166,8 +169,9 @@ const ROWS = [
166
169
  /* P · a phone */
167
170
  for (const theme of ['light', 'dark']) {
168
171
  const Q = await open({ w: 390, h: 844, theme });
169
- const ph = await Q.page.evaluate(() => ({ over: document.documentElement.scrollWidth > innerWidth + 1, rows: document.querySelectorAll('#goalTbl .okr-row').length, shown: getComputedStyle(document.querySelector('#goalTbl')).display !== 'none' }));
170
- ok('P1 on a phone (' + theme + ') the same list shows with no sideways scroll', !ph.over && ph.rows >= 4 && ph.shown, JSON.stringify(ph));
172
+ const ph = await Q.page.evaluate(() => ({ over: document.documentElement.scrollWidth > innerWidth + 1, cards: document.querySelectorAll('#goalCards .ins-card').length, drafts: document.querySelectorAll('#goalCards > .okr-dr').length }));
173
+ // re-pointed (batch 18 item 11 gap, Iq8Phone): on a phone each key result is a card, its drafts under it
174
+ ok('P1 on a phone (' + theme + ') the key results are cards with their drafts, with no sideways scroll', !ph.over && ph.cards >= 4 && ph.drafts >= 2, JSON.stringify(ph));
171
175
  await shot(Q.page, 'okr-phone-' + theme);
172
176
  await Q.ctx.close();
173
177
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.442.0",
3
+ "version": "0.444.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.442.0",
9
+ "version": "0.444.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.442.0",
3
+ "version": "0.444.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",