create-pmos 0.748.0 → 0.749.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 (44) hide show
  1. package/package.json +38 -21
  2. package/payload/AGENTS.md +1 -0
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/planning/evals/eval-calibration.md +1 -1
  5. package/payload/planning/okrs/health-budgets.md +1 -1
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/changelog.json +37 -0
  8. package/workspace/guide/backlog.md +13 -1
  9. package/workspace/guide/cli.md +12 -1
  10. package/workspace/guide/home.md +1 -1
  11. package/workspace/guide/layout.md +6 -6
  12. package/workspace/lib/idle-lab.js +16 -6
  13. package/workspace/lib/outcome-props.js +14 -4
  14. package/workspace/lib/outcomes-cli.js +44 -6
  15. package/workspace/lib/pmos-verbs.js +3 -0
  16. package/workspace/lib/proposals.js +12 -2
  17. package/workspace/lib/route-modules.js +1 -0
  18. package/workspace/lib/routes-lab.js +19 -0
  19. package/workspace/lib/routes-proposals.js +13 -0
  20. package/workspace/lib/routes-standing-rules.js +44 -0
  21. package/workspace/lib/routes-your-move.js +7 -1
  22. package/workspace/lib/rules-cli.js +74 -0
  23. package/workspace/lib/smallest-test.js +200 -0
  24. package/workspace/lib/sprint-draft.js +24 -0
  25. package/workspace/lib/standing-rules.js +187 -0
  26. package/workspace/package-lock.json +2 -2
  27. package/workspace/package.json +1 -1
  28. package/workspace/public/pm/bd-backlog-ds.js +58 -1
  29. package/workspace/public/pm/bd-backlog.js +14 -2
  30. package/workspace/public/pm/cozy-day-pick.js +34 -2
  31. package/workspace/public/pm/cozy-pop-work.js +13 -5
  32. package/workspace/public/pm/cozy-settings.js +6 -2
  33. package/workspace/public/pm/cozy-today-app.js +12 -6
  34. package/workspace/public/pm/cozy-today-model.js +88 -45
  35. package/workspace/public/pm/cozy-today-page.css +6 -0
  36. package/workspace/public/pm/cozy-today-view.js +72 -13
  37. package/workspace/public/pm/range-pick.css +1 -0
  38. package/workspace/public/pm/range-pick.js +21 -4
  39. package/workspace/public/pm/standing-rules-ui.js +100 -0
  40. package/workspace/task-card-test.js +16 -0
  41. package/workspace/test-lists/smallest-test.json +9 -0
  42. package/workspace/test-lists/sprint-draft.json +9 -0
  43. package/workspace/test-lists/standing-rules-list.json +9 -0
  44. package/workspace/test-lists/your-move-today.json +9 -0
@@ -4,8 +4,9 @@
4
4
  *
5
5
  * The job of Today: show the few things only the PM can move today, and let them finish or move each one here, so nothing is left hanging.
6
6
  *
7
- * logModel(o) → { rows, first, todayRows, wait, done, counts, types, merged, line } Today's log, kept the Bullet Journal way, in
8
- * three groups (Do first, Today, Can wait; groupLog) with a Type for each line
7
+ * logModel(o) → { rows, move, first, more, todayRows, wait, done, counts, types, merged, line } Today's log, kept the Bullet Journal
8
+ * way, in three groups (Your move ranked by the cost of waiting, Today, Can wait; groupLog) with a Type for each line
9
+ * yourMove(open, today, { shipOf }) · costOf(row, today, shipOf) Your move's rank (your-move, bet A468)
9
10
  * overviewModel(L, A) → { said, suggest, chips } the Overview on top: where to start and why, PMOS's suggestions, the type chips
10
11
  * agendaModel(o) → { items, from, to, now, sub, empty } today's agenda, one column of hours
11
12
  * headModel(now) → { when, hello } the page head
@@ -156,7 +157,8 @@ function typeOf(r) {
156
157
  /**
157
158
  * o: { rank: { rows, wait } (rankMove), move: home-list move rows, items: my-work-premium Today rows ({ key, id, title, ini, at, due?, overdue }),
158
159
  * drafts: [{ id, title, ini? }], review: { title } | null, own: today-log entries, marks: today-log marks, lab: [{ ws, board, id, title, why }],
159
- * questions: GET /api/open-questions lines, each with its ws (open-questions-today), titleOf(ini) → the initiative's name, now }
160
+ * questions: GET /api/open-questions lines, each with its ws (open-questions-today), titleOf(ini) → the initiative's name,
161
+ * shipOf(ini) → its ship date 'YYYY-MM-DD' or '' (Your move: a line with no default on work that ships soon blocks it), now }
160
162
  * A row: { key, src, bullet, first, title, work, ini, ws, job, when, late, carried, done, dates: 'task' | 'item' | 'mark', drop, ref }
161
163
  */
162
164
  export function logModel(o = {}) {
@@ -246,7 +248,9 @@ export function logModel(o = {}) {
246
248
  // open-questions-today (A420): the register (GET /api/open-questions) is the Decide tab's two groups; a line waiting on the PM whose
247
249
  // default is due today or earlier is also one Decide row in All, so the day's log names it once
248
250
  const Q = questionRows(o.questions || [], today);
249
- for (const q of Q.mine) if (q.dueToday) put({ key: q.key, src: 'question', bullet: 'task', title: q.title, ini: iniOnly(q.ini), ws: q.ws, work: q.meta, job: 'Decide', carried: 0, late: false, when: '', reason: q.under, ref: q });
251
+ // your-move (A468): every line waiting on the PM is one Decide row, so Your move can rank it; its age and its default ride along
252
+ for (const q of Q.mine) put({ key: q.key, src: 'question', bullet: 'task', title: q.title, ini: iniOnly(q.ini), ws: q.ws, work: q.meta, job: 'Decide', carried: 0, late: false, when: '', reason: q.under,
253
+ age: q.age || 0, due: q.due || '', hasDefault: !!(q.line && q.line.default), ref: q });
250
254
  oneLine(out);
251
255
  // a row done today whose source has let it go keeps its × from what it said when it was done
252
256
  for (const [k, m] of Object.entries(marks)) {
@@ -266,13 +270,13 @@ export function logModel(o = {}) {
266
270
  // one quiet line counts the log; a part that is zero is left out
267
271
  const line = [counts.decide && counts.decide + ' to decide', counts.do && counts.do + ' to do', counts.reply && counts.reply + ' to reply', counts.send && counts.send + ' to send'].filter(Boolean).join(' · ');
268
272
  const types = {}; for (const r of open) types[r.type] = (types[r.type] || 0) + 1;
269
- const G = groupLog(open, today);
270
- // every row says why it is on Today, in a short phrase after its title (round 3 point 12); Do first keeps the reason that ranked it
273
+ const G = groupLog(open, today, { shipOf: o.shipOf });
274
+ // every row says why it is on Today, in a short phrase after its title (round 3 point 12); a Your move row also has its ✦ why (its place)
271
275
  for (const r of open) if (!r.reason) { const w = whyOf(r, today); if (w) r.reason = w; }
272
- for (const r of G.first) r.group = 'first'; for (const r of G.today) r.group = 'today'; for (const r of G.wait) r.group = 'wait';
276
+ for (const r of G.first) r.group = 'first'; for (const r of G.more) r.group = 'more'; for (const r of G.today) r.group = 'today'; for (const r of G.wait) r.group = 'wait';
273
277
  for (const r of done) r.group = 'today';
274
278
  const merged = open.reduce((k, r) => k + (r.merged ? r.merged - 1 : 0), 0);
275
- return { rows: G.first.concat(G.today, done, G.wait), first: G.first, todayRows: G.today.concat(done), wait: G.wait, open: open.length, done: done.length, counts, types, merged, line, today, old,
279
+ return { rows: G.first.concat(G.more, G.today, done, G.wait), move: G.move, first: G.first, more: G.more, todayRows: G.today.concat(done), wait: G.wait, open: open.length, done: done.length, counts, types, merged, line, today, old,
276
280
  questions: { mine: Q.mine, others: Q.others } };
277
281
  }
278
282
  /** ONE THING, ONE LINE (Wawan's live Today, 2026-11-19): the lines of one brief item or one Jira ticket (srcOf) are one line, with every key
@@ -369,42 +373,80 @@ export function whyOf(r, today) {
369
373
  return '';
370
374
  }
371
375
 
372
- /* ── where to start: the three groups of the log (round 2 of Today) ──
373
- * DO FIRST, five lines at most, each with the reason PMOS picked it, read from the line itself (never guessed):
374
- * 1 the PM marked it first · 2 a date that is late · 3 a date that is today, or a send that goes out today · 4 a session that waits on the PM
375
- * (its work is blocked) · 5 the person who waits longest (an ask, a day or more).
376
- * A line PMOS suggests to drop, a note and a Lab finding are never in it.
376
+ /* ── where to start: Your move, then Today and Can wait (your-move, bet A468; boards YourMoveDS and YourMovePhone, agreed 2026-11-23) ──
377
+ * YOUR MOVE gathers every open line that waits on the PM (an ask, an open question, a draft to look at, the weekly review, a late task or
378
+ * item, what the PM marked first) and ranks it by the COST OF WAITING. Each row gets `why`: the ✦ line that says why it is in that place.
379
+ * 0 the PM marked it first ("You marked it first")
380
+ * 1 it blocks a ship date: its initiative ships within SHIP_SOON days and it has no safe default ("Friday’s ship waits on it"); soonest first
381
+ * 2 a default that lands within DEFAULT_SOON days (what PMOS does if nobody answers), or a send that goes out today; soonest first
382
+ * 3 days late (a dated task or item, a person who waits on a reply, a session whose work stops); most first
383
+ * 4 the rest, by age; oldest first
384
+ * Ties go by key, so the order never depends on where a line came from. YM_CAP rows show; the rest fold, in the same order (`more`).
385
+ * Never in it: a done row, a note, an event, a Lab finding, a line PMOS suggests to drop, an ask that looks answered, an ask with no person.
386
+ * SAY IT ONCE: Today and Can wait hold only what Your move does not.
377
387
  * TODAY: the rest that is new today (carried 0 days: dated today, logged today, filed today), then what was done today.
378
388
  * CAN WAIT: the rest, by type (the order of TYPES) and then the oldest first; folded to one line. */
379
- export const FIRST_CAP = 5;
380
- function reasonOf(r, today) {
381
- const ref = r.ref || {}, c = ref.call || null;
382
- if (r.first && r.src === 'own') return [1, 0, 'You marked it first'];
383
- if (r.dates !== 'mark' && r.late && r.carried > 0) return [2, r.carried, plural(r.carried, 'day', 'days') + ' late'];
384
- const due = ref.due || (ref.task && ref.task.end) || '';
385
- if (due && due === today) return [3, 0, 'Due today'];
386
- if (c && c.kind === 'update' && /^(today|now)/i.test(String(c.when || ''))) return [3, 0, 'Goes out ' + c.when];
387
- if (c && (c.state === 'blocked' || c.state === 'needs') && c.kind === 'session') return [4, 0, 'A session waits on you; its work stops until you answer'];
388
- if (r.type === 'Ask' && r.carried >= 1) return [5, r.carried, (r.who && r.who.length ? names(r.who) : 'They') + ' ' + (r.who && r.who.length > 1 ? 'wait' : 'waits') + ' on you ' + plural(r.carried, 'day', 'days')];
389
- return null;
389
+ export const YM_CAP = 5;
390
+ export const SHIP_SOON = 14; // days: a ship date this close makes a line with no default block it
391
+ export const DEFAULT_SOON = 7; // days: a default this close ranks before lateness
392
+ /** Kept for old callers: Your move shows YM_CAP rows. */
393
+ export const FIRST_CAP = YM_CAP;
394
+ const WDAY = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
395
+ /** "Friday’s ship waits on it": the weekday inside a week, else the date. */
396
+ function shipWhy(ship, today) {
397
+ const d = between(today, ship);
398
+ if (d === 0) return 'Today’s ship waits on it';
399
+ if (d === 1) return 'Tomorrow’s ship waits on it';
400
+ if (d <= 6) return WDAY[new Date(dayMs(ship)).getDay()] + '’s ship waits on it';
401
+ return 'The ship on ' + dm(ship, today) + ' waits on it';
390
402
  }
391
- export function groupLog(open, today) {
392
- const cand = [];
393
- for (const r of open) {
394
- // an ask that looks answered (someone else may have answered it, round 3 point 10d) is not first and not today: it waits for his ✓ ✕
395
- if (r.drop || r.looks || r.bullet === 'note' || r.src === 'lab' || r.src === 'note' || (r.type === 'Ask' && !(r.who && r.who.length))) continue;
396
- const w = reasonOf(r, today); if (w) cand.push({ r, k: w[0], d: w[1], why: w[2] });
397
- }
398
- cand.sort((a, b) => a.k - b.k || b.d - a.d);
399
- const first = cand.slice(0, FIRST_CAP).map((x) => { x.r.reason = x.why; return x.r; });
400
- const inFirst = new Set(first);
401
- const rest = open.filter((r) => !inFirst.has(r));
403
+ /** Days late of a dated line: a task past its date, an item past its due day, an own line carried LATE_DAYS or more. 0 when it is not late. */
404
+ function lateDays(r, today) {
405
+ const ref = r.ref || {};
406
+ if (r.src === 'move') return r.late && r.carried > 0 ? r.carried : 0;
407
+ if (r.src === 'item') return ref.due && ref.due < today ? between(ref.due, today) : 0;
408
+ if (r.src === 'own') return r.late ? r.carried : 0;
409
+ return 0;
410
+ }
411
+ /** The cost of waiting on one open row: [tier, order within the tier, the ✦ why], or null when it does not wait on the PM. PURE. */
412
+ export function costOf(r, today, shipOf = () => '') {
413
+ if (!r || r.done || r.drop || r.looks || r.bullet !== 'task' || r.src === 'gone' || r.src === 'note' || r.src === 'lab') return null;
414
+ if (r.type === 'Ask' && !(r.who && r.who.length)) return null; // nobody waits on the answer
415
+ const ref = r.ref || {}, c = ref.call || null, ld = lateDays(r, today);
416
+ const waits = r.src === 'ask' || r.src === 'question' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
417
+ if (!waits) return null;
418
+ if (r.src === 'own' && r.first) return [0, 0, 'You marked it first'];
419
+ const age = r.src === 'question' ? r.age || 0 : r.carried || 0;
420
+ const ship = r.ini ? String(shipOf(r.ini) || '') : '', sd = ship ? between(today, ship) : null;
421
+ const dflt = r.src === 'question' && r.hasDefault && r.due ? r.due : '';
422
+ if (sd != null && sd >= 0 && sd <= SHIP_SOON && !dflt) return [1, sd, shipWhy(ship, today) + (r.src === 'question' ? '; no safe default' : '')];
423
+ if (dflt) { const dd = between(today, dflt); if (dd != null && dd <= DEFAULT_SOON) return [2, dd, r.reason || 'Its default lands ' + dm(dflt, today)]; }
424
+ if (c && c.kind === 'update' && /^(today|now)/i.test(String(c.when || ''))) return [2, 0, 'Goes out ' + c.when];
425
+ if (ld > 0) return [3, -ld, plural(ld, 'day', 'days') + ' late'];
426
+ if (r.type === 'Ask' && r.carried >= 1) return [3, -r.carried, names(r.who) + ' ' + (r.who.length > 1 ? 'wait' : 'waits') + ' on you ' + plural(r.carried, 'day', 'days')];
427
+ if (c && c.kind === 'session' && (c.state === 'blocked' || c.state === 'needs')) return [3, 0, 'A session waits on you; its work stops until you answer'];
428
+ if (r.src === 'question') return [4, -age, r.reason || 'Waits on you ' + plural(age, 'day', 'days')];
429
+ const w = whyOf(r, today);
430
+ return [4, -age, w && !/^Waits on you$/.test(w) ? w : age ? 'Waits on you ' + plural(age, 'day', 'days') : 'Waits on you'];
431
+ }
432
+ /** Your move: every open row that waits on the PM, ranked by the cost of waiting, each with its ✦ why (r.why) and tier (r.tier). PURE but
433
+ * for those two fields. o: { shipOf(ini) → 'YYYY-MM-DD' | '' (the initiative's ship date) } */
434
+ export function yourMove(open, today, o = {}) {
435
+ const shipOf = typeof o.shipOf === 'function' ? o.shipOf : () => '';
436
+ const c = [];
437
+ for (const r of open || []) { const k = costOf(r, today, shipOf); if (k) c.push({ r, t: k[0], s: k[1], why: k[2] }); }
438
+ c.sort((a, b) => a.t - b.t || a.s - b.s || String(a.r.key).localeCompare(String(b.r.key)));
439
+ return c.map((x) => { x.r.why = x.why; x.r.tier = x.t; return x.r; });
440
+ }
441
+ export function groupLog(open, today, o = {}) {
442
+ const move = yourMove(open, today, o), inMove = new Set(move);
443
+ const rest = open.filter((r) => !inMove.has(r));
402
444
  // an ask with no person behind it can wait: nobody waits on the answer
403
445
  const todayRows = rest.filter((r) => !r.drop && !r.looks && r.bullet !== 'note' && r.src !== 'note' && (r.carried || 0) === 0 && !r.late && !(r.type === 'Ask' && !(r.who && r.who.length)));
404
446
  const inToday = new Set(todayRows);
405
447
  const order = (t) => { const i = TYPES.indexOf(t); return i < 0 ? TYPES.length : i; };
406
448
  const wait = rest.filter((r) => !inToday.has(r)).sort((a, b) => order(a.type) - order(b.type) || (b.carried || 0) - (a.carried || 0));
407
- return { first, today: todayRows, wait };
449
+ return { move, first: move.slice(0, YM_CAP), more: move.slice(YM_CAP), today: todayRows, wait };
408
450
  }
409
451
 
410
452
  /** The Overview at the top of Today (written by PMOS, ✦): one or two sentences, the suggestions with ✓ ✕, and the type chips.
@@ -415,20 +457,21 @@ export const OLD_CHECK_DAYS = 60;
415
457
  const clipT = (t, n) => { t = String(t || ''); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
416
458
  export function overviewModel(L, A = {}) {
417
459
  const parts = [];
418
- // the lines for today: Do first and what waits today (not done, not a note); the rail's number on every place
419
- const forToday = (L.first || []).length + (L.todayRows || []).filter((r) => !r.done && r.type !== 'Note').length;
420
- if (L.open) parts.push(plural(L.open, 'line is', 'lines are') + ' open' + (forToday && forToday < L.open ? ', ' + forToday + ' of them for today.' : '.'));
460
+ // the lines for today: Your move and what waits today (not done, not a note); the rail's number on every place
461
+ const mv = L.move || L.first || [];
462
+ const forToday = mv.length + (L.todayRows || []).filter((r) => !r.done && r.type !== 'Note').length;
463
+ if (L.open && !mv.length) parts.push(plural(L.open, 'line is', 'lines are') + ' open' + (forToday && forToday < L.open ? ', ' + forToday + ' of them for today.' : '.'));
421
464
  // an ask is said by who asked ("Chen’s ask, 22 days"); another line by its title, clipped, with its reason
422
465
  // refs: the item names in the sentence, so the page makes each one open its item (the Summary block's links)
423
466
  const said = new Set(), refs = [];
424
- const top = (L.first || []).slice(0, 3).map((r) => {
425
- const ask = r.type === 'Ask' && r.who && r.who.length && !said.has(names(r.who)) && said.add(names(r.who));
467
+ // your-move (A468): the first row of Your move and why it is first, said once; the rest of Your move is the list itself
468
+ if (mv.length) {
469
+ const r = mv[0], ask = r.type === 'Ask' && r.who && r.who.length && !said.has(names(r.who)) && said.add(names(r.who));
426
470
  const text = ask ? names(r.who) + '’s ask' : clipT(r.title, 48);
427
471
  refs.push({ text, key: r.key });
428
- return text + ' (' + (ask ? plural(r.carried, 'day', 'days') : r.reason.replace(/^(Late|Due|Goes|You|A)\b/, (w) => w.toLowerCase())) + ')';
429
- });
430
- const qs = questionsSay(L.questions); if (qs) parts.push(qs);
431
- if (top.length) parts.push('Start with ' + (top.length === 1 ? top[0] : top.slice(0, -1).join(', ') + ' and ' + top[top.length - 1]) + '.');
472
+ const why = String(r.why || r.reason || 'it waits on you').replace(/^(You|If|Its|Waits|Goes|Asked|A|No|The)\b/, (w) => w.toLowerCase()).replace(/\.\s.*$/, '').replace(/[.]+$/, ''); // its first sentence
473
+ parts.push(plural(mv.length, 'thing waits', 'things wait') + ' on you; start with ' + text + ', because ' + why + '.');
474
+ } else { const qs = questionsSay(L.questions); if (qs) parts.push(qs); }
432
475
  const freeW = A.free ? 'You have ' + durWord(A.free) + ' free' : '';
433
476
  const nextW = A.next ? (A.nextFirst ? 'your first meeting is at ' : 'your next meeting is at ') + A.next : '';
434
477
  if (freeW || nextW) parts.push(cap1([freeW, nextW].filter(Boolean).join('; ')) + '.');
@@ -54,6 +54,10 @@ button.td-t:focus-visible, .td-ln:focus-visible, .td-evl:focus-visible { outline
54
54
  .td-fold .pm-ic { margin-left: auto; }
55
55
  .td-fold[aria-expanded="true"] .pm-ic { transform: rotate(180deg); }
56
56
  .td-none { margin: 0; padding: var(--space-4) var(--space-16) var(--space-16); }
57
+ /* Your move (your-move, bet A468; board YourMoveDS): its place, then the ✦ line that says why it is there. Tokens only. */
58
+ .ym-n { flex: none; min-width: var(--space-16); text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
59
+ .td-li .ym-why { display: flex; align-items: center; gap: var(--space-4); }
60
+ .ym-why .pm-star { flex: none; color: var(--blue); }
57
61
 
58
62
  /* the agenda: each event at its time, the now line where it falls */
59
63
  .td-evl { font-size: var(--fs-meta); color: var(--blue); }
@@ -140,6 +144,8 @@ button.td-ev:focus-visible { outline: none; box-shadow: var(--glow); }
140
144
  .tdp-cw { all: unset; display: flex; align-items: center; gap: var(--space-8); padding: 14px 0; font-size: var(--fs-body); color: var(--cz-ink3); cursor: pointer; line-height: var(--lh-body); }
141
145
  .tdp-cw b { color: var(--cz-ink); font-weight: var(--fw-strong); }
142
146
  .tdp-cw[aria-expanded="true"] svg { transform: rotate(180deg); }
147
+ .tdp-ym .tdp-lh { border-bottom: 0; padding-top: var(--space-8); } /* your-move (board YourMovePhone): the same five, rows with a dot */
148
+ .tdp-ym .ym-why { color: var(--cz-blue); }
143
149
  .tdp-cw0 h2 { padding: 22px 0 6px; font-size: var(--fs-label); font-weight: var(--fw-regular); letter-spacing: .08em; text-transform: uppercase; color: var(--cz-ink3); line-height: var(--lh-label); }
144
150
  .tdp-cw0 h2 em { font-style: normal; margin-left: 6px; }
145
151
  .tdp-cwl { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 48px; font-size: var(--fs-body); color: var(--cz-ink); cursor: pointer; }
@@ -6,8 +6,8 @@
6
6
  * Exploring 3 canvas, page today, 2026-11-20). Layout Main + side:
7
7
  * Main the head (the day, then the greeting); the Overview, a Summary block (pm-block): one sentence whose item names open the item, and
8
8
  * PMOS's Suggestions (pm-sug, ✓ primary, ✕ outline); Today's log, a List block (pm-block list): its heading and one set of Tabs
9
- * (pm-tabs: All, Reply, Do, Decide, Send with counts, a zero tab left out), the capture Input (pm-input), then the groups: Do first
10
- * (the Now group, pm-group now, its first row lit), Today (pm-group), and Later folded (pm-fold "N can wait"), PMOS handled folded last.
9
+ * (pm-tabs: All, Reply, Do, Decide, Send with counts, a zero tab left out), the capture Input (pm-input), then the groups: Your move
10
+ * (the Now group, pm-group now: ranked rows with a ✦ why, five and a fold; its first row lit), Today (pm-group), and Later folded (pm-fold "N can wait"), PMOS handled folded last.
11
11
  * Row a ListRow (pm-li): the kind icon, the title, a why line ("for <work> · due <date>", or who waits), a late Badge (pm-badge alert),
12
12
  * and on hover or focus icon Buttons: first by job (Done, Reply, Decide, Send), then Move to tomorrow and Set a date. A ✦ Suggestion
13
13
  * under the row when PMOS proposes something on it (drop it, looks answered, draft them).
@@ -59,7 +59,7 @@ export function whyLine(r) {
59
59
  /** The first action of a row, by its job: Done for a thing to do, else the item opens where the PM replies, decides or sends. */
60
60
  const JOB_ACT = { Reply: ['open', 'Reply', I.reply], Decide: ['open', 'Decide', I.decide], Send: ['open', 'Send', I.send] };
61
61
 
62
- /** One row of the log: a ListRow (pm-li). o.lit: the lit first row of Do first; o.sopen: its members are listed. */
62
+ /** One row of the log: a ListRow (pm-li). o.lit: the lit first row of a group; o.sopen: its members are listed. */
63
63
  export function rowHtml(r, o = {}) {
64
64
  const [kd, kl] = kindOf(r);
65
65
  const t = r.title;
@@ -105,10 +105,55 @@ export function overviewHtml(O) {
105
105
  const sug = (O.suggest || []).map((x) => sugHtml(x.text, ['ov-yes', x.text], ['ov-no', 'Keep them: ' + x.text], x.key, 'td-ovs')).join('');
106
106
  return `<section class="td-ov pm-block" aria-label="Overview"><h2 class="pm-h-sm pm-row">${ic(I.spark, 16, 'pm-star')}Overview</h2>${said ? `<p>${said}</p>` : ''}${sug}</section>`;
107
107
  }
108
+ /* ── Your move (your-move, bet A468; board YourMoveDS, agreed 2026-11-23) ──
109
+ * The group that leads Today's log: every line that waits on the PM, ranked by the cost of waiting (cozy-today-model.js yourMove). Five
110
+ * show; the fold line holds the rest in the same order and names the next one. A row: its place, the kind icon, the title, a meta line (the
111
+ * work, the kind, the age), the ✦ line that says why it is in that place, and two icon Buttons: one action for its kind, and Put off a day. */
112
+ export const YM_SHOW = 5;
113
+ const KIND_WORD = { Ask: 'reply', Decision: 'a decision', Check: 'a check', Milestone: 'a date change', Task: 'task', Report: 'a draft to send' };
114
+ const ageOf = (r) => Math.max(0, r.src === 'question' ? r.age || 0 : r.carried || 0);
115
+ /** The one action of a Your move row: an answer, a reply, a decision or a send opens the item; a thing to do is Done. */
116
+ function moveAct(r) {
117
+ const t = r.title;
118
+ if (r.src === 'question') return ib('open', 'Answer: ' + t, I.decide, r.key);
119
+ const j = JOB_ACT[r.job];
120
+ if (j) return ib('open', j[1] + ': ' + t, j[2], r.key);
121
+ if (r.members) return ib('open', 'Show them: ' + t, I.more, r.key, ` aria-expanded="false"`);
122
+ return ib('done', 'Done: ' + t, I.done, r.key);
123
+ }
124
+ /** One Your move row (a ListRow, pm-li): n is its place, 1 to n. */
125
+ export function moveRowHtml(r, n, o = {}) {
126
+ const [kd, kl] = kindOf(r);
127
+ const late = lateOf(r), age = ageOf(r);
128
+ const meta = [r.work || '', r.src === 'question' ? '' : KIND_WORD[r.type] || '', !late && r.tier !== 3 && age ? plural(age, 'day', 'days') : ''].filter(Boolean).join(' · ');
129
+ // what the PM typed opens nothing: its words are the whole of it
130
+ const title = r.src === 'own' ? `<span class="t td-t">${esc(r.title)}</span>`
131
+ : `<button type="button" class="t td-t" data-td="open" data-key="${esc(r.key)}"${r.members ? ` aria-expanded="${!!o.sopen}"` : ''}>${esc(r.title)}${r.members ? ic(I.more, 14) : ''}</button>`;
132
+ return `<div class="td-li pm-li ym-r${n === 1 ? ' now' : ''}" data-key="${esc(r.key)}"><span class="ym-n pm-meta" aria-hidden="true">${n}</span>`
133
+ + `<span class="td-kind" role="img" aria-label="${esc(kl)}">${ic(kd)}</span><span class="txt">${title}${meta ? `<span class="w td-rs">${esc(meta)}</span>` : ''}`
134
+ + `<span class="w td-rs ym-why">${ic(I.spark, 13, 'pm-star')}${esc(r.why || '')}</span></span>${late ? `<span class="pm-badge alert">${esc(late)}</span>` : ''}`
135
+ + `<span class="acts td-a">${moveAct(r)}${ib('tomorrow', 'Put off a day: ' + r.title, I.tomorrow, r.key)}</span></div>`
136
+ + (r.members && o.sopen ? r.members.map((m) => rowHtml(m)).join('') : '');
137
+ }
138
+ /** "4 more, in the same order · the next one: <title>, <age>". */
139
+ const nextWord = (r) => r.title + (ageOf(r) ? ', ' + plural(ageOf(r), 'day', 'days') : '');
140
+ /** The Your move group: the heading, five rows, the fold line (open: the rest, in the same order). '' when nothing waits (zero is
141
+ * silence). rows: the ranked rows (logModel().move, filtered by the tab). o: { ymOpen, sopen } */
142
+ export function moveHtml(rows, o = {}) {
143
+ if (!rows || !rows.length) return '';
144
+ const so = new Set(o.sopen || []), shown = rows.slice(0, YM_SHOW), rest = rows.slice(YM_SHOW);
145
+ const n = rest.length ? shown.length + ' of ' + rows.length : String(rows.length);
146
+ let h = `<div class="td-gr pm-group now ym-g">${ic(I.sun, 14)}Your move <span class="td-n">${esc(n)} · what costs most to wait comes first</span></div>`
147
+ + `<div class="rows">${shown.map((r, i) => moveRowHtml(r, i + 1, { sopen: so.has(r.key) })).join('')}`;
148
+ if (rest.length && o.ymOpen) h += rest.map((r, i) => moveRowHtml(r, YM_SHOW + i + 1, { sopen: so.has(r.key) })).join('');
149
+ h += '</div>';
150
+ if (rest.length) h += `<button type="button" class="td-fold pm-fold ym-fold" data-td="ym-fold" aria-expanded="${!!o.ymOpen}">${esc(rest.length + ' more, in the same order')} <span class="td-n">${esc('· the next one: ' + nextWord(rest[0]))}</span>${ic(I.more, 14)}</button>`;
151
+ return h;
152
+ }
108
153
  /** The jobs the log's Tabs filter by, in order. */
109
154
  export const JOBS = [['Reply', 'reply'], ['Do', 'do'], ['Decide', 'decide'], ['Send', 'send']];
110
155
 
111
- /** Today's log, a List block: the heading and the Tabs, the capture Input, the groups Do first, Today, Later (folded) and PMOS handled.
156
+ /** Today's log, a List block: the heading and the Tabs, the capture Input, the groups Your move, Today, Later (folded) and PMOS handled.
112
157
  * L: logModel(). o: { draft: the line being typed, job: the tab that filters ('' is All), open: Later is unfolded, handled, hopen, sopen } */
113
158
  export function logHtml(L, o = {}) {
114
159
  const c = L.counts || {}, job = o.job || '';
@@ -123,9 +168,9 @@ export function logHtml(L, o = {}) {
123
168
  const pick = (rows) => (job ? (rows || []).filter((r) => r.job === job && !(job === 'Decide' && r.src === 'question')) : rows || []);
124
169
  const so = new Set(o.sopen || []);
125
170
  const one = (r, lit) => (r.members ? rowHtml(r, { sopen: so.has(r.key), lit }) + (so.has(r.key) ? r.members.map((m) => rowHtml(m)).join('') : '') : rowHtml(r, { lit }));
126
- const first = pick(L.first), today = pick(L.todayRows), wait = pick(L.wait);
171
+ const today = pick(L.todayRows), wait = pick(L.wait);
127
172
  let body = job === 'Decide' ? questionGroups(L.questions) : '';
128
- if (first.length) body += `<div class="td-gr pm-group now">${ic(I.sun, 14)}Do first</div><div class="rows">${first.map((r, i) => one(r, i === 0)).join('')}</div>`;
173
+ body += moveHtml(pick(L.move || L.first), o);
129
174
  if (today.length) body += `<div class="td-gr pm-group">Today</div><div class="rows">${today.map((r) => one(r)).join('')}</div>`;
130
175
  if (wait.length) {
131
176
  const oldest = Math.max(0, ...wait.map((r) => r.carried || 0));
@@ -207,6 +252,8 @@ export function swipeActs(r) {
207
252
  if (r.drop) return { right: 'drop', left: 'keep' }; // PMOS suggests to drop it: right accepts the suggestion, left keeps the line
208
253
  if (r.looks) return { right: 'lk-yes', left: 'lk-no' };
209
254
  if (r.members && r.drafts) return { right: 'same-yes', left: 'same-no' };
255
+ // a Your move row (your-move): right does its action, so a reply, an answer, a decision or a send opens the item; left puts it off a day
256
+ if (r.tier != null && (r.src === 'question' || JOB_ACT[r.job] || r.members)) return { right: 'open', left: 'tomorrow' };
210
257
  return { right: 'done', left: 'tomorrow' };
211
258
  }
212
259
  /** The next event of the day for the phone's one line: { key, title, sub, play } or the quiet line when there is none. A: agendaModel(). */
@@ -238,7 +285,7 @@ export function fixLine(r) {
238
285
  return '';
239
286
  }
240
287
  /** One row of the phone's log (PhoneTodayDS): a dot, the title, then the job with its icon and the work (and the late word); PMOS's fix
241
- * line under it when PMOS proposes something. o.wait: the row is in Can wait. */
288
+ * line under it when PMOS proposes something. o.wait: the row is in Can wait. o.ym: a Your move row, whose ✦ line says why it is there. */
242
289
  export function phoneRowHtml(r, o = {}) {
243
290
  const sw = swipeActs(r);
244
291
  const opens = !r.done && r.src !== 'own' && r.src !== 'gone' && r.src !== 'note';
@@ -247,8 +294,9 @@ export function phoneRowHtml(r, o = {}) {
247
294
  const late = lateOf(r);
248
295
  const meta = [jb ? `${svg(JOB_IC[jb] || (jb === 'Event' ? KIND.event[0] : TI.Note), 13, 1.8)}<span>${esc(jb)}</span>` : '', r.work ? esc(r.work) : '',
249
296
  late ? `<em>${esc(late)}</em>` : r.when && !r.done ? esc(r.when) : ''].filter(Boolean).join('<i aria-hidden="true">·</i>');
250
- const fx = fixLine(r);
251
- const fix = fx ? `<span class="tdp-pro">${svg(PI.spark, 13, 1.9)}<span>${esc(fx)}</span></span>` : '';
297
+ const fx = o.ym ? '' : fixLine(r);
298
+ const fix = o.ym && r.why ? `<span class="tdp-pro ym-why">${svg(PI.spark, 13, 1.9)}<span>${esc(r.why)}</span></span>`
299
+ : fx ? `<span class="tdp-pro">${svg(PI.spark, 13, 1.9)}<span>${esc(fx)}</span></span>` : '';
252
300
  const dot = rowDot(r, o), dl = r.done ? 'Done' : dot === 'alert' ? 'Late' : dot === 'blue' ? 'For today' : 'Can wait';
253
301
  const say = sw.right ? ` aria-describedby="tdpHint"` : '';
254
302
  return `<li class="tdp-r${r.done ? ' done' : ''}${r.first && !r.done ? ' first' : ''}" data-key="${esc(r.key)}"${sw.right ? ` data-sw-right="${sw.right}"` : ''}${sw.left ? ` data-sw-left="${sw.left}"` : ''}${say}>`
@@ -308,9 +356,10 @@ export function phonePageHtml(L, A, O, o = {}) {
308
356
  + `<button type="button" class="tdp-ib pm-btn outline" data-td="filed-undo" data-key="${esc(o.filed.id)}" aria-label="${esc('Undo: take the recording out of ' + o.filed.title)}" title="Undo">${svg(PI.undo, 18, 1.8)}</button></section>` : '';
309
357
  const job = o.job || '';
310
358
  const pick = (rows) => (job ? (rows || []).filter((r) => r.job === job && !(job === 'Decide' && r.src === 'question')) : rows || []);
311
- const all = [...(L.first || []), ...(L.todayRows || [])];
359
+ const all = [...(L.move || L.first || []), ...(L.todayRows || [])];
312
360
  const qg = job === 'Decide' ? phoneQuestionGroups(L.questions) : ''; // open-questions-today: the left phone of board QuestionsPhone
313
- const shown = pick(L.first).concat(pick(L.todayRows));
361
+ const ym = phoneMoveHtml(pick(L.move || L.first), o); // your-move (board YourMovePhone): the same five, in the same order
362
+ const shown = pick(L.todayRows);
314
363
  const wait = pick(L.wait);
315
364
  const sg = O && O.suggest && O.suggest[0];
316
365
  const anySwipe = !!sg || shown.some((r) => swipeActs(r).right);
@@ -333,7 +382,7 @@ export function phonePageHtml(L, A, O, o = {}) {
333
382
  + jobs.map(([j, k]) => `<option value="${esc(j)}"${job === j ? ' selected' : ''}>${esc(j + ' ' + c[k])}</option>`).join('') + `</select>${svg(PI.down, 14)}</label>` : '';
334
383
  const log = zero ? '' : `<section class="tdp-log" aria-label="Today’s log"><div class="tdp-lh"><h2>Today’s log · ${esc(job ? shown.length : L.open || shown.length)}</h2>${filter}</div>`
335
384
  + qg + (shown.length ? `<ul class="tdp-rows">${shown.map((r) => phoneRowHtml(r) + (r.members && (o.sopen || []).includes(r.key) ? r.members.map((m) => phoneRowHtml(m)).join('') : '')).join('')}</ul>`
336
- : qg ? '' : `<p class="tdp-none">${esc('Nothing to ' + job.toLowerCase() + ' today.')}</p>`) + '</section>';
385
+ : qg || ym ? '' : `<p class="tdp-none">${esc(job ? 'Nothing to ' + job.toLowerCase() + ' today.' : 'Nothing else for today.')}</p>`) + '</section>';
337
386
  // Can wait: one line, folded; a zero day says it as its own short section (Ph2_todayzero)
338
387
  let cw = '';
339
388
  if (wait.length) {
@@ -344,9 +393,19 @@ export function phonePageHtml(L, A, O, o = {}) {
344
393
  if (o.open) cw += `<ul class="tdp-rows tdp-waitl">${wait.map((r) => phoneRowHtml(r, { wait: true })).join('')}</ul>`;
345
394
  }
346
395
  const sheet = o.sheet && sg && o.sheet === sg.key ? phoneSheetHtml(sg) : '';
347
- return `${H}${filed}${ov}${ev}${log}${cw}${phoneCapHtml(o)}${sheet}`;
396
+ return `${H}${filed}${ym}${ov}${ev}${log}${cw}${phoneCapHtml(o)}${sheet}`;
348
397
  }
349
398
  const cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
399
+ /** Your move on a phone (board YourMovePhone): the same five rows in the same order as the desk, rows with a dot (the alert colour when
400
+ * late) and the ✦ line, no cards; the fold line holds the rest. '' when nothing waits. rows: logModel().move, filtered by the job. */
401
+ export function phoneMoveHtml(rows, o = {}) {
402
+ if (!rows || !rows.length) return '';
403
+ const shown = rows.slice(0, YM_SHOW), rest = rows.slice(YM_SHOW);
404
+ const n = rest.length ? shown.length + ' of ' + rows.length : String(rows.length);
405
+ return `<section class="tdp-ym" aria-label="Your move"><div class="tdp-lh"><h2>${esc('Your move · ' + n)}</h2></div>`
406
+ + `<ul class="tdp-rows">${shown.concat(o.ymOpen ? rest : []).map((r) => phoneRowHtml(r, { ym: true })).join('')}</ul>`
407
+ + (rest.length ? `<button type="button" class="tdp-cw ym-fold" data-td="ym-fold" aria-expanded="${!!o.ymOpen}"><b>${esc(rest.length + ' more, in the same order')}</b>${svg(PI.down, 14)}</button>` : '') + '</section>';
408
+ }
350
409
  /** Lines that wait on someone else: they keep the Decide tab even when none waits on the PM. */
351
410
  const qOthers = (L) => !!(L && L.questions && L.questions.others && L.questions.others.length);
352
411
  const plural3 = (n) => n + (n === 1 ? ' line' : ' lines');
@@ -30,6 +30,7 @@
30
30
  .rp .rp-d:focus-visible { outline: 0; }
31
31
  .rp .rp-d:focus-visible span { box-shadow: 0 0 0 2px var(--cz-card), 0 0 0 4px var(--cz-blue); }
32
32
  .rp-msg { margin: 0; font-size: var(--fs-meta); color: var(--cz-late); }
33
+ .rp-msg.hint { color: var(--cz-ink2); } /* the day a typed word reads as, before Enter */
33
34
  .rp-ft { display: flex; border-top: 1px solid var(--cz-hair); padding-top: var(--space-8); }
34
35
  .rp .rp-clear { border: 0; background: none; font: inherit; font-size: var(--fs-row); font-weight: var(--fw-strong); color: var(--cz-ink2); padding: 6px 10px; border-radius: var(--radius-md); cursor: pointer; }
35
36
  /* a pointer that hovers: the presses light up; a touch or the keys (:focus-visible) show the same without it */
@@ -6,16 +6,18 @@
6
6
  * before the second tap. A tap before the start moves the start and still waits for the due day. A press on Start or Due picks which end
7
7
  * the next tap sets. A milestone (one) has one Date, and one tap sets it. Each tap saves (nothing is lost when the picker closes early);
8
8
  * the second tap closes it. "No date" clears both. Typing works too: "15 Oct", "2026-10-15", "15/10/2026" in an end's field, then Enter.
9
+ * Words work as well (bet A488): "friday", "+2w", "in 3 days", "end of month", "end of sprint" (o.sprintEnd). While the PM types, the
10
+ * message line says the day it read ("Reads as Friday 27 Nov 2026 · Enter saves") before anything is saved; a word form taken logs dateWords.
9
11
  * Keyboard: arrows move a day or a week, Page Up/Down a month, Home/End the week's ends, Enter or Space picks.
10
12
  *
11
13
  * rangeHtml(s, o) → markup pure, for node tests. s: { start, due, field: 'start'|'due', month: 'YYYY-MM', one, focus }
12
14
  * o: { today, head (html drawn first), coarse (a phone: the fields do not open the keyboard) }
13
15
  * rangeTap(s, iso) → { patch, field, done } pure: what one tap (or a typed day, or '' for "No date") writes, and what comes next
14
- * mountRange(el, o) → { state } draws into el and wires it. o: { start, due, one, field, today, head,
16
+ * mountRange(el, o) → { state } draws into el and wires it. o: { start, due, one, field, today, head, sprintEnd (an ISO day, or a function that gives one),
15
17
  * onPick(patch, done, state) — after each tap; done: the range is complete, the host closes;
16
18
  * onState(state) — after each draw, so a host that redraws can open it where it was }
17
19
  * Its own presses stop at el, so a popup's click handler around it sees only the host's own buttons (a sheet's ✕). */
18
- import { dayText, parseDay, localToday } from './cozy-day-pick.js';
20
+ import { dayText, dayLong, parseDay, wordsOnly, localToday } from './cozy-day-pick.js';
19
21
 
20
22
  const CSS = new URL('./range-pick.css', import.meta.url).href;
21
23
  if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l); }
@@ -126,15 +128,30 @@ export function mountRange(el, o = {}) {
126
128
  });
127
129
  el.onpointerover = (e) => { const day = e.target.closest && e.target.closest('.rp-g [data-rp-day]'); if (day) preview(day.dataset.rpDay); };
128
130
  el.onpointerleave = () => preview(null);
131
+ // a typed day: words or a date, read against today; "end of sprint" only where the host knows the sprint (it never guesses one)
132
+ const sprintEnd = () => { try { return typeof o.sprintEnd === 'function' ? o.sprintEnd() : o.sprintEnd; } catch { return ''; } };
133
+ const read = (t) => parseDay(t, today, { sprintEnd: sprintEnd() });
134
+ const isSprint = (t) => /^\s*(end of (the )?sprint|sprint end|eos)\s*$/i.test(t);
135
+ const say = (t, hint) => { const p = el.querySelector('.rp-msg'); if (p) { p.textContent = t; p.hidden = !t; p.classList.toggle('hint', !!hint); } };
129
136
  const take = (inp) => {
130
137
  if (drawing || !inp.isConnected) return;
131
138
  const t = inp.value.trim(), k = inp.closest('[data-rp-end]').dataset.rpEnd;
132
139
  if (t === dayText(s[k])) return;
133
140
  if (!t) { msg = ''; return; }
134
- const v = parseDay(t, today);
135
- if (!v) { msg = 'Write a day like 15 Oct 2026.'; const p = el.querySelector('.rp-msg'); if (p) { p.textContent = msg; p.hidden = false; } return; }
141
+ const v = read(t);
142
+ if (!v) { msg = isSprint(t) ? 'No sprint is known here. Type a day.' : 'Write a day like 15 Oct, friday or +2w.'; say(msg); return; }
143
+ if (wordsOnly(t)) { try { import('./use-log.js').then((U) => { if (U && typeof U.noteUse === 'function') U.noteUse('dateWords'); }).catch(() => {}); } catch { /* the log is optional */ } }
136
144
  s.field = k; tap(v, 'type');
137
145
  };
146
+ // while the PM types: the day it reads, before anything is saved
147
+ el.addEventListener('input', (e) => {
148
+ const inp = e.target.closest && e.target.closest('.rp-in'); if (!inp) return;
149
+ const t = inp.value.trim(), v = t ? read(t) : null;
150
+ msg = '';
151
+ if (v && t !== dayText(v)) say('Reads as ' + dayLong(v) + ' · Enter saves', true);
152
+ else if (!v && isSprint(t)) say('No sprint is known here. Type a day.');
153
+ else say('');
154
+ });
138
155
  el.addEventListener('keydown', (e) => {
139
156
  const inp = e.target.closest && e.target.closest('.rp-in');
140
157
  if (inp) { if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); take(inp); } return; }
@@ -0,0 +1,100 @@
1
+ /* pm/standing-rules-ui.js — Settings › How PMOS decides › Standing rules (bet A470, initiative standing-rules-list).
2
+ *
3
+ * One plain list per product of the rules PMOS learned from the PM's corrections (lib/standing-rules.js): the rule, where it came from
4
+ * (how many corrections, the latest words), how many times it fired and when it last fired. Edit and Retire on each; a retired rule waits
5
+ * under Retired with Bring back. Zero rules is one quiet line. GET and POST /api/standing-rules; `pmos rules` is the chat's way to the same
6
+ * list. A change shows at once (EDITS SHOW AT ONCE): the row changes before the server answers, and goes back when the server refuses.
7
+ *
8
+ * S the state: { by: { wsId: { ok, rules, retired } | { ok: false, error } }, edit: 'wsId|ruleId' | null }
9
+ * load(products, draw) read each product's list (opening the list once counts as a use for that day)
10
+ * html(products, row) the block, drawn with the Settings row (pm/set-ds.js row)
11
+ * click(t, draw, say) → true when the press was one of this block's
12
+ */
13
+ import { pmGet, pmPost } from './http.js';
14
+ import { esc } from './set-ds.js';
15
+
16
+ export const S = { by: {}, edit: null };
17
+ const dayOf = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }) : ''; };
18
+ const times = (n) => n + (n === 1 ? ' time' : ' times');
19
+
20
+ export function reset() { S.by = {}; S.edit = null; }
21
+ export async function load(products, draw) {
22
+ await Promise.all((products || []).map(async (w) => {
23
+ const r = await pmGet('/api/standing-rules?view=1&ws=' + encodeURIComponent(w.id)).catch(() => null);
24
+ S.by[w.id] = r && r.ok ? { ok: true, rules: r.rules || [], retired: r.retired || [] } : { ok: false, error: (r && r.error) || 'the server did not answer' };
25
+ }));
26
+ draw();
27
+ }
28
+
29
+ function subOf(r) {
30
+ const from = r.from && r.from.n ? 'From ' + r.from.n + ' of your corrections' + (r.from.latest ? ', latest “' + r.from.latest + '”' : '') : 'Kept ' + dayOf(r.keptAt);
31
+ const fired = r.fired ? 'Fired ' + times(r.fired) + ', last ' + dayOf(r.lastFired) : 'Not fired since you kept it';
32
+ return [from, fired, r.quiet ? 'Quiet for 30 days' : ''].filter(Boolean).join(' · ');
33
+ }
34
+ function ruleRow(w, r, row) {
35
+ const key = w.id + '|' + r.id;
36
+ if (S.edit === key) {
37
+ return `<div class="ev-trow pm-set"><div class="ev-tx"><label for="evSr-${esc(r.id)}"><b>Edit the rule</b></label><p class="pm-meta">${esc(subOf(r))}</p>`
38
+ + `<textarea id="evSr-${esc(r.id)}" class="ev-inp ev-rules" rows="2" maxlength="600" spellcheck="true">${esc(r.text)}</textarea></div>`
39
+ + `<span class="ev-dr-pl"><button type="button" class="ev-btn sm pri" data-ev-sr="save" data-ev-sr-ws="${esc(w.id)}" data-ev-sr-id="${esc(r.id)}">Save</button>`
40
+ + `<button type="button" class="ev-btn sm" data-ev-sr="cancel">Cancel</button></span></div>`;
41
+ }
42
+ return row(r.text, subOf(r), `<span class="ev-dr-pl"><button type="button" class="ev-btn sm" data-ev-sr="edit" data-ev-sr-ws="${esc(w.id)}" data-ev-sr-id="${esc(r.id)}" aria-label="${esc('Edit the rule ' + r.text)}">Edit</button>`
43
+ + `<button type="button" class="ev-btn sm" data-ev-sr="retire" data-ev-sr-ws="${esc(w.id)}" data-ev-sr-id="${esc(r.id)}" aria-label="${esc('Retire the rule ' + r.text)}">Retire</button></span>`);
44
+ }
45
+ export function html(products, row) {
46
+ const ps = (products || []).filter((w) => S.by[w.id]);
47
+ if (!ps.length) return '';
48
+ const many = ps.length > 1;
49
+ const body = ps.map((w) => {
50
+ const L = S.by[w.id], name = w.label || w.name || w.id;
51
+ if (L.ok === false) return `<p class="pm-meta">${esc(many ? name + ': ' : '')}The standing rules could not be read: ${esc(L.error)}.</p>`;
52
+ if (!L.rules.length && !L.retired.length) return many ? '' : '<p class="pm-meta">No standing rules yet. When you correct the same kind of thing 3 times, PMOS offers one in the Lab.</p>';
53
+ return (many ? `<h4 class="pm-h-sm">${esc(name)}</h4>` : '')
54
+ + L.rules.map((r) => ruleRow(w, r, row)).join('')
55
+ + (L.retired.length ? '<h4 class="pm-h-sm">Retired</h4>' + L.retired.map((r) => row(r.text, 'Retired ' + dayOf(r.at) + '. No run reads it.',
56
+ `<button type="button" class="ev-btn sm" data-ev-sr="restore" data-ev-sr-ws="${esc(w.id)}" data-ev-sr-id="${esc(r.text)}" aria-label="${esc('Bring back the rule ' + r.text)}">Bring back</button>`)).join('') : '');
57
+ }).join('');
58
+ return `<section class="pm-block" aria-label="Standing rules" id="evStanding"><div class="head"><h3 class="pm-h">Standing rules</h3></div>`
59
+ + '<p class="pm-meta ev-lead">Rules PMOS learned from your corrections. Every run follows them. A rule fires when you correct the same kind of thing again.</p>'
60
+ + (body || '<p class="pm-meta">No standing rules yet. When you correct the same kind of thing 3 times, PMOS offers one in the Lab.</p>') + '</section>';
61
+ }
62
+
63
+ export async function click(t, draw, say) {
64
+ const a = t.dataset.evSr;
65
+ if (!a) return false;
66
+ if (a === 'cancel') { S.edit = null; draw(); return true; }
67
+ const ws = t.dataset.evSrWs, id = t.dataset.evSrId, L = S.by[ws];
68
+ if (!L || L.ok === false) return true;
69
+ if (a === 'edit') { S.edit = ws + '|' + id; draw(); const f = document.getElementById('evSr-' + id); if (f) f.focus(); return true; }
70
+ const was = { rules: L.rules.slice(), retired: L.retired.slice() };
71
+ if (a === 'save') {
72
+ const f = document.getElementById('evSr-' + id), text = f ? f.value.replace(/\s+/g, ' ').trim() : '';
73
+ if (!text) { say('A rule needs its words.'); return true; }
74
+ const r0 = L.rules.find((x) => x.id === id); if (r0) L.rules = L.rules.map((x) => (x.id === id ? { ...x, text } : x));
75
+ S.edit = null; draw();
76
+ const r = await pmPost('/api/standing-rules', { ws, op: 'edit', id, text });
77
+ if (!(r && r.ok)) { Object.assign(L, was); say((r && r.error) || 'Not saved.'); } else say('Saved. Every run follows the new words.');
78
+ draw(); return true;
79
+ }
80
+ if (a === 'retire') {
81
+ const r0 = L.rules.find((x) => x.id === id);
82
+ if (r0) { L.rules = L.rules.filter((x) => x.id !== id); L.retired = [{ id, text: r0.text, at: new Date().toISOString() }, ...L.retired]; }
83
+ draw();
84
+ const r = await pmPost('/api/standing-rules', { ws, op: 'retire', id });
85
+ if (!(r && r.ok)) { Object.assign(L, was); say((r && r.error) || 'Not retired.'); } else say('Retired. No run reads it now. Bring back is under Retired.');
86
+ draw(); return true;
87
+ }
88
+ if (a === 'restore') {
89
+ const r0 = L.retired.find((x) => x.text === id);
90
+ if (r0) { L.retired = L.retired.filter((x) => x.text !== id); L.rules = [{ id: 'new', text: r0.text, from: { n: 0, latest: '' }, fired: 0, lastFired: null, keptAt: new Date().toISOString() }, ...L.rules]; }
91
+ draw();
92
+ const r = await pmPost('/api/standing-rules', { ws, op: 'restore', id });
93
+ if (!(r && r.ok)) { Object.assign(L, was); say((r && r.error) || 'Not brought back.'); draw(); return true; }
94
+ say('Back. Every run follows it again.');
95
+ const g = await pmGet('/api/standing-rules?ws=' + encodeURIComponent(ws)).catch(() => null);
96
+ if (g && g.ok) S.by[ws] = { ok: true, rules: g.rules || [], retired: g.retired || [] };
97
+ draw(); return true;
98
+ }
99
+ return false;
100
+ }
@@ -243,6 +243,22 @@ async function pure() {
243
243
  const wk = [await fd()];
244
244
  for (const k of ['Home', 'End', 'PageDown', 'PageUp']) { await p.keyboard.press(k); wk.push(await fd()); }
245
245
  ok('D4 the keys: Home and End go to the week ends, Page Down and Page Up move a month and redraw it', wk.join() === '2026-10-23,2026-10-19,2026-10-25,2026-11-25,2026-10-25', JSON.stringify(wk));
246
+ // words (bet A488, done test dates-in-words W6): the day read shows before anything is saved; Enter saves it; an unknown sprint saves nothing
247
+ const fri = await p.evaluate(async () => (await import('/pm/cozy-day-pick.js')).parseDay('friday'));
248
+ const n0 = A.posts.filter((x) => x.path === '/api/boards/tasks/edit').length;
249
+ await p.click(C + ' .tkc-dp [data-rp-end="due"] .rp-in'); await p.fill(C + ' .tkc-dp [data-rp-end="due"] .rp-in', 'friday');
250
+ const said = await until(() => p.evaluate((c) => { const m = document.querySelector(c + ' .tkc-dp .rp-msg'); return m && !m.hidden ? m.textContent : ''; }, C));
251
+ const longFri = await p.evaluate(async (v) => (await import('/pm/cozy-day-pick.js')).dayLong(v), fri);
252
+ ok('D4 words: "friday" typed in Due shows the day it reads before anything is saved', said === 'Reads as ' + longFri + ' · Enter saves' && /^Friday /.test(longFri) && A.posts.filter((x) => x.path === '/api/boards/tasks/edit').length === n0, JSON.stringify({ said, longFri, n0 }));
253
+ await p.keyboard.press('Enter');
254
+ ok('D4 words: Enter saves the Friday as the due day and closes the picker', await until(() => last(A, '/api/boards/tasks/edit').body.due === fri) && await until(() => p.evaluate((c) => !document.querySelector(c + ' .tkc-dp'), C)), JSON.stringify(last(A, '/api/boards/tasks/edit')));
255
+ await p.click(C + ' [data-tkc="dates"]');
256
+ await until(() => p.evaluate((c) => !!document.querySelector(c + ' .tkc-dp'), C));
257
+ const n1 = A.posts.filter((x) => x.path === '/api/boards/tasks/edit').length;
258
+ await p.click(C + ' .tkc-dp [data-rp-end="due"] .rp-in'); await p.fill(C + ' .tkc-dp [data-rp-end="due"] .rp-in', 'end of sprint'); await p.keyboard.press('Enter');
259
+ const sp = await until(() => p.evaluate((c) => { const m = document.querySelector(c + ' .tkc-dp .rp-msg'); return m && !m.hidden ? m.textContent : ''; }, C));
260
+ await sleep(300);
261
+ ok('D4 words: "end of sprint" where no sprint is known says so and saves nothing', sp === 'No sprint is known here. Type a day.' && A.posts.filter((x) => x.path === '/api/boards/tasks/edit').length === n1, JSON.stringify({ sp, n1 }));
246
262
  await p.mouse.click(5, 5);
247
263
  ok('D4 a press outside closes the picker', await until(() => p.evaluate((c) => !document.querySelector(c + ' .tkc-dp'), C)));
248
264
  // owner
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "smallest test first (factory job #1662, bet A472): lib/outcomes.js untested, smallestTestDraft, recordTest/undoTest, testCount; outcome-props filing; ✓ and Undo through routes-proposals; pmos outcomes test|tests; Your move asks for a result.",
3
+ "modules": [
4
+ "smallest-test.test.js"
5
+ ],
6
+ "seconds": {
7
+ "smallest-test.test.js": 8
8
+ }
9
+ }