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
@@ -0,0 +1,187 @@
1
+ 'use strict';
2
+ /* standing-rules.js — the standing rules PMOS keeps, as one plain list the PM can read, edit and retire (bet A470, initiative
3
+ * standing-rules-list; done test planning/done-tests/standing-rules-list.md).
4
+ *
5
+ * A standing rule is a memory entry (D72, scripts/pmos-memory.js through lib/memory.js) whose source is `rule:<kind>`: the PM kept it from
6
+ * a Lab ✦ when one kind of correction repeated (lib/correction-kinds.js, bet A464). Every run reads it and it never goes stale, so the
7
+ * set only grows unless the PM can see it and prune it. This module is that view, for any product built with PMOS.
8
+ *
9
+ * PER RULE. Its text, kind, when it was kept, where it came from (corrections of its kind in the 30 days before it was kept, and the PM's
10
+ * latest words), FIRED (corrections of its kind recorded after it was kept: the habit came up again; runs cannot say which rule they
11
+ * used, so a later correction is the only signal on file) and LAST FIRED. A rule kept QUIET_DAYS or more ago with no firing in the last
12
+ * QUIET_DAYS is quiet: the monthly Lab ✦ (type `retire`, lib/idle-lab.js) asks once whether to retire the quiet ones.
13
+ *
14
+ * LEDGER. standing-rules.jsonl in the product's PMOS state folder (the folder corrections.jsonl uses), one line per use:
15
+ * { at, op: view|edit|retire|restore|prompt|keep|drop, id?, text?, source?, by? }
16
+ * `view` is written at most once a day. Retired rules are the retire lines not followed by a restore of the same text. Each use also logs
17
+ * one line with TAG (the health number reads the ledger).
18
+ *
19
+ * listOf(root, { now }) → { rules: [rule], retired: [{ id, text, source, kind, at }], quiet: [id] }
20
+ * edit(root, { id, text, by }) · retire(root, { id, by }) · restore(root, { id, by }) → { ok, rule? } | { ok: false, error }
21
+ * promptOf(list, lines, { now }) PURE → the Lab ✦ to file now (lib/idle-lab.js loose input), or null
22
+ * filePrompt(root, labDir, { now }) → the filed ✦ id, or null. Never throws.
23
+ * use(root, line) · readLines(dir) · count(lines, now, days)
24
+ */
25
+ const fs = require('fs');
26
+ const path = require('path');
27
+ const K = require('./correction-kinds.js');
28
+
29
+ const DAY = 86400000;
30
+ const LEDGER = 'standing-rules.jsonl';
31
+ const TAG = '[standing-rules]';
32
+ const QUIET_DAYS = 30;
33
+ const SOURCE_RE = /^rule:([a-z]*)$/;
34
+ const PROMPT_PREFIX = 'retire-';
35
+ const OPS = new Set(['view', 'edit', 'retire', 'restore', 'prompt', 'keep', 'drop']);
36
+
37
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
38
+ const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
39
+ const day = (ms) => new Date(ms).toISOString().slice(0, 10);
40
+
41
+ function mem() { const c = require('./memory.js').core(); if (!c.ok) throw new Error(c.error); return c.core; }
42
+ const kindOfSource = (s) => { const m = SOURCE_RE.exec(String(s || '')); return m ? m[1] : null; };
43
+
44
+ /* ── the ledger ── */
45
+ function readLines(dir) {
46
+ if (!dir) return [];
47
+ let text = '';
48
+ try { text = fs.readFileSync(path.join(dir, LEDGER), 'utf8'); } catch { return []; }
49
+ const out = [];
50
+ for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l) && OPS.has(l.op) && l.at) out.push(l); } catch { /* a torn line is skipped */ } }
51
+ return out;
52
+ }
53
+ /** One use: a ledger line and a log line. Nothing when the product has no state folder. `view` once a day. */
54
+ function use(root, line, { now = Date.now(), log = console.log } = {}) {
55
+ try {
56
+ const dir = K.stateDir(root);
57
+ if (!dir) return null;
58
+ if (line.op === 'view' && readLines(dir).some((l) => l.op === 'view' && String(l.at).slice(0, 10) === day(now))) return null;
59
+ const l = { at: new Date(now).toISOString(), ...line };
60
+ fs.appendFileSync(path.join(dir, LEDGER), JSON.stringify(l) + '\n');
61
+ try { log(`${TAG} ${l.op}${l.id ? ' ' + l.id : ''}`); } catch { /* the line is written */ }
62
+ return l;
63
+ } catch { return null; }
64
+ }
65
+ /** PURE. Uses in the last `days` days (the health number). */
66
+ function count(lines, now = Date.now(), days = 7) {
67
+ const since = now - days * DAY;
68
+ return (lines || []).filter((l) => { const at = Date.parse(l.at) || 0; return at >= since && at <= now; }).length;
69
+ }
70
+
71
+ /* ── the list ── */
72
+ function rulesIn(root) {
73
+ const cur = mem().load(root);
74
+ return (cur.state.entries || []).filter((e) => e && e.target === 'memory' && kindOfSource(e.source) !== null && !e.staged);
75
+ }
76
+ function shape(e, corr, now) {
77
+ const kind = kindOfSource(e.source) || '', kept = Date.parse(e.at) || 0, W = QUIET_DAYS * DAY;
78
+ const of = kind ? corr.filter((l) => l.kind === kind) : [];
79
+ const before = of.filter((l) => { const a = Date.parse(l.at) || 0; return a < kept && a >= kept - W; }).sort((a, b) => String(a.at).localeCompare(String(b.at)));
80
+ const after = of.filter((l) => { const a = Date.parse(l.at) || 0; return a >= kept && a <= now; }).sort((a, b) => String(a.at).localeCompare(String(b.at)));
81
+ const lastFired = after.length ? after[after.length - 1].at : null;
82
+ const quiet = now - kept >= W && !(lastFired && now - (Date.parse(lastFired) || 0) < W);
83
+ const label = (K.KINDS.find((k) => k.id === kind) || {}).label || '';
84
+ return { id: e.id, text: e.text, kind, label, keptAt: e.at, edited: e.updated_at && e.updated_at !== e.at ? e.updated_at : null,
85
+ from: { n: before.length, latest: before.length ? one(before[before.length - 1].why, 140) : '' }, fired: after.length, lastFired, quiet };
86
+ }
87
+ function retiredOf(lines, active) {
88
+ const texts = new Set(active.map((r) => r.text)), out = new Map();
89
+ for (const l of lines) {
90
+ if (l.op === 'retire' && l.text) out.set(l.text, { id: l.id, text: l.text, source: l.source || '', kind: kindOfSource(l.source) || '', at: l.at });
91
+ else if (l.op === 'restore' && l.text) out.delete(l.text);
92
+ }
93
+ return [...out.values()].filter((r) => !texts.has(r.text)).sort((a, b) => String(b.at).localeCompare(String(a.at)));
94
+ }
95
+ /** The product's list. A product with no memory or no state folder has an empty list, not an error. */
96
+ function listOf(root, { now = Date.now() } = {}) {
97
+ const dir = K.stateDir(root), corr = K.readLines(dir);
98
+ let entries = [];
99
+ try { entries = rulesIn(root); } catch { entries = []; }
100
+ const rules = entries.map((e) => shape(e, corr, now)).sort((a, b) => String(b.keptAt).localeCompare(String(a.keptAt)));
101
+ return { rules, retired: retiredOf(readLines(dir), rules), quiet: rules.filter((r) => r.quiet).map((r) => r.id) };
102
+ }
103
+
104
+ /* ── edit, retire, bring back ── */
105
+ const find = (root, id) => { try { return rulesIn(root).find((e) => e.id === id) || null; } catch { return null; } };
106
+ function edit(root, { id, text, by = 'agent:cli', log, now } = {}) {
107
+ const t = one(text, 600);
108
+ if (!t) return { ok: false, error: 'a rule needs its text' };
109
+ const e = find(root, String(id || ''));
110
+ if (!e) return { ok: false, error: 'no standing rule ' + (id || '') };
111
+ if (t === e.text) return { ok: true, rule: { id: e.id, text: e.text }, same: true };
112
+ const r = mem().write(root, { op: 'replace', target: 'memory', old: e.text, text: t, by });
113
+ if (!r.ok) return { ok: false, error: r.error };
114
+ use(root, { op: 'edit', id: e.id, text: t, by }, { log, now });
115
+ return { ok: true, rule: { id: e.id, text: t }, staged: !!r.staged };
116
+ }
117
+ function retire(root, { id, by = 'agent:cli', log, now } = {}) {
118
+ const e = find(root, String(id || ''));
119
+ if (!e) return { ok: false, error: 'no standing rule ' + (id || '') };
120
+ const r = mem().write(root, { op: 'remove', target: 'memory', old: e.text, by });
121
+ if (!r.ok) return { ok: false, error: r.error };
122
+ use(root, { op: 'retire', id: e.id, text: e.text, source: e.source, by }, { log, now });
123
+ return { ok: true, rule: { id: e.id, text: e.text, source: e.source }, staged: !!r.staged };
124
+ }
125
+ /** Bring a retired rule back: `id` is the retired rule's id (or its exact text). */
126
+ function restore(root, { id, by = 'agent:cli', log, now } = {}) {
127
+ const dir = K.stateDir(root), active = (() => { try { return rulesIn(root); } catch { return []; } })();
128
+ const r0 = retiredOf(readLines(dir), active.map((e) => ({ text: e.text }))).find((x) => x.id === id || x.text === id);
129
+ if (!r0) return { ok: false, error: 'no retired rule ' + (id || '') };
130
+ const r = mem().write(root, { op: 'add', target: 'memory', text: r0.text, by, ...(r0.source ? { source: r0.source } : {}) });
131
+ if (!r.ok) return { ok: false, error: r.error };
132
+ const back = (() => { try { return rulesIn(root).find((e) => e.text === r0.text); } catch { return null; } })();
133
+ use(root, { op: 'restore', id: back ? back.id : r0.id, text: r0.text, source: r0.source, by }, { log, now });
134
+ return { ok: true, rule: { id: back ? back.id : r0.id, text: r0.text, source: r0.source }, staged: !!r.staged };
135
+ }
136
+
137
+ /* ── the monthly prompt ── */
138
+ /** PURE. The Lab ✦ to file now: the quiet rules, when no prompt was filed in the last QUIET_DAYS. null otherwise. */
139
+ function promptOf(list, lines, { now = Date.now() } = {}) {
140
+ const quiet = (list && list.rules || []).filter((r) => r.quiet);
141
+ if (!quiet.length) return null;
142
+ const last = (lines || []).filter((l) => l.op === 'prompt').map((l) => Date.parse(l.at) || 0).sort((a, b) => b - a)[0] || 0;
143
+ if (now - last < QUIET_DAYS * DAY) return null;
144
+ const n = quiet.length;
145
+ return { id: PROMPT_PREFIX + day(now), title: n === 1 ? 'Retire 1 standing rule that has not fired in 30 days' : `Retire ${n} standing rules that have not fired in 30 days`,
146
+ why: one('Not corrected again since: ' + quiet.slice(0, 3).map((r) => '"' + one(r.text, 70) + '"').join(', ') + (n > 3 ? ` and ${n - 3} more` : '') + '. Retiring keeps the list small; Bring back is in Settings.', 300),
147
+ sources: quiet.slice(0, 5).map((r) => ({ label: 'Standing rule kept ' + day(Date.parse(r.keptAt) || now) })),
148
+ data: { ids: quiet.map((r) => r.id).slice(0, 20) } };
149
+ }
150
+ /** File the monthly ✦ in the Lab when it is due. Never throws; → the ✦ id or null. */
151
+ function filePrompt(root, labDir, { now = Date.now(), log = console.log } = {}) {
152
+ try {
153
+ if (!root || !labDir) return null;
154
+ const dir = K.stateDir(root);
155
+ if (!dir) return null;
156
+ const p = promptOf(listOf(root, { now }), readLines(dir), { now });
157
+ if (!p) return null;
158
+ const LAB = require('./idle-lab.js');
159
+ const v = LAB.loose('retire', p);
160
+ if (v.error) return null;
161
+ LAB.append(labDir, { by: 'agent:standing-rules' }, { kind: 'propose', ...v.prop });
162
+ use(root, { op: 'prompt', id: v.prop.id }, { now, log });
163
+ return v.prop.id;
164
+ } catch { return null; }
165
+ }
166
+
167
+ module.exports = { LEDGER, TAG, QUIET_DAYS, PROMPT_PREFIX, kindOfSource, readLines, use, count, listOf, edit, retire, restore, promptOf, filePrompt };
168
+
169
+ /* node standing-rules.js count|list [--root <repo>] [--json] */
170
+ if (require.main === module) {
171
+ const argv = process.argv.slice(2), cmd = argv[0];
172
+ const opt = (k) => { const i = argv.indexOf(k); return i >= 0 ? argv[i + 1] : null; };
173
+ const root = path.resolve(opt('--root') || '.'), dir = K.stateDir(root);
174
+ if (cmd === 'count') {
175
+ const n = count(readLines(dir));
176
+ if (argv.includes('--json')) process.stdout.write(JSON.stringify({ dir, last7: n }) + '\n');
177
+ else process.stdout.write(`${dir ? '' : 'No PMOS state folder here, so no uses are recorded.\n'}${n}\n`);
178
+ } else if (cmd === 'list') {
179
+ const L = listOf(root);
180
+ if (argv.includes('--json')) process.stdout.write(JSON.stringify(L) + '\n');
181
+ else if (!L.rules.length) process.stdout.write('No standing rules yet.\n');
182
+ else for (const r of L.rules) process.stdout.write(`${r.text}\n fired ${r.fired} times${r.lastFired ? ', last ' + String(r.lastFired).slice(0, 10) : ''}${r.quiet ? ' (quiet)' : ''}\n`);
183
+ } else {
184
+ process.stdout.write('usage: node standing-rules.js count|list [--root <repo>] [--json]\n');
185
+ process.exitCode = cmd ? 1 : 0;
186
+ }
187
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.748.0",
3
+ "version": "0.749.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.748.0",
9
+ "version": "0.749.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.748.0",
3
+ "version": "0.749.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",
@@ -81,7 +81,9 @@ export function standsOf(B, o = {}) {
81
81
  const most = top.length > 1 && top[0][1] + (top[1] ? top[1][1] : 0) > R.length / 2 ? (top[1][1] > 1 ? `${top[0][0]} and ${top[1][0]}` : top[0][0]) : top.length === 1 && R.length > 1 ? top[0][0] : '';
82
82
  out.push(`${R.length === B.length ? (R.length === 1 ? 'It is' : 'All are') : R.length + (R.length === 1 ? ' is' : ' are')} ready${into}${most ? `; most of them are ${most} work` : ''}.`);
83
83
  }
84
- const tail = [stale ? `${stale} ${stale === 1 ? 'has' : 'have'} not been touched in ${STALE} days` : '', noIni ? `${noIni} ${noIni === 1 ? 'has' : 'have'} no initiative, so nobody owns ${noIni === 1 ? 'it' : 'them'} yet` : ''].filter(Boolean);
84
+ // the sprint draft (sprint-draft-capacity): when the open work alone fills the next sprint, say so; PMOS suggests nothing more
85
+ if (o.draft && o.draft.full) out.push(`${o.draft.from} still has ${o.draft.carry} open ${o.draft.carry === 1 ? 'item' : 'items'}, and the team finishes about ${o.draft.cap} a sprint, so ${o.draft.name} is full before anything new goes in.`);
86
+ const tail = [stale ?`${stale} ${stale === 1 ? 'has' : 'have'} not been touched in ${STALE} days` : '', noIni ? `${noIni} ${noIni === 1 ? 'has' : 'have'} no initiative, so nobody owns ${noIni === 1 ? 'it' : 'them'} yet` : ''].filter(Boolean);
85
87
  if (tail.length) out.push(tail.join(', and ').replace(/^./, (c) => c.toUpperCase()) + '.');
86
88
  return out;
87
89
  }
@@ -105,6 +107,61 @@ export function pullOf(order, next, n = 4) {
105
107
  return { s, ids: mine.map((t) => t.id), keys: jira.map((t) => t.key) };
106
108
  }
107
109
 
110
+ /* ── the sprint draft (initiative sprint-draft-capacity, bet A471) ────────────────────────────────────────────────────────────────
111
+ * The next sprint, sized at the team's own pace. Capacity is the median number of items the team finished in its newest three kept,
112
+ * closed sprints (two at least), counted in items, not points: points are missing on many tickets and PMOS tasks have none. When the
113
+ * days of the next sprint and of those sprints are known and differ, the number is scaled by their ratio. The active sprint's open work
114
+ * carries over first; the ranked ready work fills the room that is left. Nothing is guessed: no kept sprints, no draft. */
115
+ const daysOf = (s) => { const a = dayNum(s && s.start), b = dayNum(s && s.end); return a != null && b != null && b >= a ? b - a + 1 : null; };
116
+ const median = (L) => { const s = L.slice().sort((a, b) => a - b), m = s.length >> 1; return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2; };
117
+ const andList = (L) => (L.length <= 1 ? L.join('') : L.slice(0, -1).join(', ') + ' and ' + L[L.length - 1]);
118
+
119
+ /** list: the sprint picker's rows (GET /api/backlog sprintList), newest first; next: the next sprint. → { n, done, names, scaled } | null */
120
+ export function capacityOf(list, next) {
121
+ const K = (list || []).filter((x) => x && x.state === 'closed' && x.kept && x.kept !== 'none' && Number.isInteger(x.done)).slice(0, 3);
122
+ if (K.length < 2) return null;
123
+ let n = median(K.map((x) => x.done)), scaled = false;
124
+ const past = K.map(daysOf), want = daysOf(next);
125
+ if (want != null && past.every((d) => d != null)) {
126
+ const usual = median(past);
127
+ if (usual > 0 && want !== usual) { n = n * want / usual; scaled = true; }
128
+ }
129
+ return { n: Math.max(0, Math.round(n)), done: K.map((x) => x.done), names: K.map((x) => x.name), scaled };
130
+ }
131
+
132
+ /** The draft of the next sprint. order: the Backlog in rank order; next: the next sprint (with dates); o.list: the sprint picker's rows;
133
+ * o.now: the active sprints with their rows (lib/sprint-now.js). → { s, ids, keys, over, carry, room, cap, full, name, from } | null
134
+ * s is the Suggestion (null when the carry-over already fills the sprint: full). */
135
+ export function draftOf(order, next, o = {}) {
136
+ if (!next || !next.start || !next.end) return null;
137
+ const c = capacityOf(o.list, next);
138
+ if (!c) return null;
139
+ const open = (o.now || []).flatMap((sp) => (sp.rows || []).filter((r) => r && r.state !== 'Done'));
140
+ const from = (o.now || []).map((sp) => labelOf(sp)).filter(Boolean);
141
+ const carry = open.length, room = Math.max(0, c.n - carry);
142
+ const ready = (order || []).filter(isReady), notReady = (order || []).length - ready.length;
143
+ const fit = ready.slice(0, room), over = ready.slice(room);
144
+ const name = next.label || next.name, where = from.length ? andList(from) : 'the active sprint';
145
+ const base = { carry, room, cap: c.n, name, from: where, over };
146
+ if (!room || !fit.length) return { ...base, s: null, ids: [], keys: [], fit: [], full: !room };
147
+ const mine = fit.filter((t) => t.src === 'pmos'), jira = fit.filter((t) => t.src === 'jira');
148
+ const names = (L) => (L.length <= 3 ? andList(L.map((t) => t.title)) : L.length + ' tasks');
149
+ const pace = `The team finished ${andList(c.done.map(String))} items in ${andList(c.names)}, so ${name} holds about ${c.n}${c.scaled ? ' for its length' : ''}.`;
150
+ const rolls = carry ? ` ${plural(carry, 'item is', 'items are')} still open in ${where} and will likely carry over, which leaves room for ${room}.` : '';
151
+ const left = over.length ? `${plural(over.length, 'ready item does', 'ready items do')} not fit: ${over.length <= 3 ? andList(over.map((t) => t.title)) : andList(over.slice(0, 2).map((t) => t.title).concat([over.length - 2 + ' more']))}.` : '';
152
+ const detail = notReady ? ` ${plural(notReady, 'more item needs', 'more items need')} an owner or an initiative first.` : '';
153
+ const s = {
154
+ title: `Draft ${name}: ${plural(fit.length, 'ranked item fits', 'ranked items fit')}${carry ? ` beside ${carry} carried over` : ''}`,
155
+ why: pace + rolls,
156
+ will: (mine.length ? [`Give ${names(mine)} the dates of ${name} (${dayText(next.start)} to ${dayText(next.end)})`] : [])
157
+ .concat(jira.length ? [`List ${jira.map((t) => t.key).join(', ')} for you to add to ${name} in Jira`] : []),
158
+ changes: (left + detail).trim() + (jira.length ? ' PMOS does not change Jira.' : '') + ' Nothing is sent to anyone.',
159
+ basis: `The last ${c.names.length} finished sprints, ${where}'s open work, and the rank in this backlog`,
160
+ };
161
+ return { ...base, s, ids: mine.map((t) => t.id), keys: jira.map((t) => t.key), fit, full: false };
162
+ }
163
+ const labelOf = (sp) => { const n = String((sp && (sp.label || sp.name)) || ''); const m = /(sprint\s*\d+)\s*$/i.exec(n); return m ? m[1].replace(/^s/, 'S') : n; };
164
+
108
165
  /** The Where it stands block. → '' when there is nothing to say. */
109
166
  export function standsHtml(B, o = {}) {
110
167
  const S = standsOf(B, o);
@@ -20,6 +20,7 @@ import * as SP from './bd-sprint.js';
20
20
  import * as WS from './work-select.js'; // the bulk move with one Undo, shared with the initiative popup and This sprint (WorkBulkDS)
21
21
  import * as IF from './inline-fields.js'; // a task's sprint and priority, set in the row (initiative inline-sprint-priority)
22
22
  import * as LE from './live-edit.js'; // a task's status or days show at once in the list, before it is read again; a failed save is put back
23
+ import { noteUse } from './use-log.js'; // the sprint draft's presses, counted on this computer only (sprint-draft-capacity)
23
24
  import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
24
25
 
25
26
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
@@ -181,8 +182,16 @@ function draw() {
181
182
  /* ── the Backlog tab (WorkBacklogDS): Where it stands with one Suggestion, then the Backlog block ───────────────────────── */
182
183
  let ORDER = []; // the backlog in rank order, as drawn last
183
184
  const backlogOf = () => DATA.tasks.filter(BD.inBacklog).filter((t) => BM.keeps(t, new Set(), PICK, partB()));
185
+ /** The Suggestion: the sprint draft at the team's pace when PMOS knows it for one product (sprint-draft-capacity, A471), else the old
186
+ * pull of the top 4. A draft whose sprint is already full suggests nothing (Where it stands says why). */
187
+ function draftFor(order) {
188
+ if (!DATA.next || (DATA.hist || []).length !== 1) return null;
189
+ const h = DATA.hist[0];
190
+ return BD.draftOf(order, DATA.next, { list: h.list, now: (DATA.now || []).filter((n) => n.ws === h.ws && n.board === h.board) });
191
+ }
184
192
  function pullFor(order) {
185
- const p = BD.pullOf(order, DATA.next);
193
+ const d = draftFor(order);
194
+ const p = d ? (d.s ? { ...d, draft: true } : null) : BD.pullOf(order, DATA.next);
186
195
  if (!p) return null;
187
196
  const no = get(PULLNO, []) || [];
188
197
  return no.includes(pullSig(p)) ? null : p;
@@ -202,7 +211,7 @@ function drawBk() {
202
211
  return { k: g.k, n: g.n, sub: g.sub, rows: g.rows, yes: can.length ? ` <button type="button" class="pm-btn" data-bkyes="${g.k}" aria-label="${esc(g.k === 'take' ? 'Give all ' + can.length + ' to PMOS' : 'Place all ' + can.length)}" title="${esc(g.k === 'take' ? 'Give all ' + can.length + ' to PMOS' : 'Place all ' + can.length)}">${SV(I.ok, 16)}</button>` : '' };
203
212
  });
204
213
  host.innerHTML = (DATA.err ? `<p class="bk-err">${esc(DATA.err)}</p>` : '')
205
- + BD.standsHtml(B, { today: DATA.today, next: DATA.next, pull: pullFor(order) })
214
+ + BD.standsHtml(B, { today: DATA.today, next: DATA.next, pull: pullFor(order), draft: draftFor(order) })
206
215
  + BD.tableHtml(order, { tab: BV.tab, group: BV.group, menu: BMENU, today: DATA.today, rank, sel: SEL, picking: host.classList.contains('picking'),
207
216
  act: (t) => actHtml(t, BM.groupOf(t, partB())), stateOf: (t) => { if (!t.agent) return null; const x = BM.stateOf(t); return { text: x.text, tone: x.tone, title: x.text + (x.note ? ' · ' + x.note : '') }; },
208
217
  groupsPmos: pmosGroups, said: showing + said, mode, inline: true });
@@ -229,8 +238,11 @@ async function bkPress(e) {
229
238
  if ((b = hit('data-bksug'))) {
230
239
  const p = pullFor(ORDER); if (!p) return true;
231
240
  const k = b.dataset.bksug, T = p.ids.map((id) => DATA.tasks.find((t) => t.id === id)).filter(Boolean);
241
+ if (p.draft) noteUse(k === 'no' ? 'sprintDraftNo' : k === 'edit' ? 'sprintDraftEdit' : 'sprintDraftYes'); // the health number (lib/sprint-draft.js count)
232
242
  if (k === 'no') { const no = get(PULLNO, []) || []; no.push(pullSig(p)); put(PULLNO, no.slice(-50)); AP().say('PMOS will not suggest this again.', () => { put(PULLNO, (get(PULLNO, []) || []).filter((x) => x !== pullSig(p))); draw(); }); draw(); return true; }
243
+ if (k === 'edit' && !T.length) { AP().say('Add ' + p.keys.join(', ') + ' to ' + (DATA.next.label || DATA.next.name) + ' in Jira, or leave out the ones you do not want. PMOS does not change Jira.'); return true; }
233
244
  if (k === 'edit') { BV.tab = 'ready'; saveBv(); for (const t of T) SEL.add(uidOf(t)); draw(); AP().say(`Ticked ${T.length === 1 ? 'the item' : 'the ' + T.length + ' items'}. Change the ticks, then Set date.`); return true; }
245
+ if (!T.length) { AP().say('Add ' + p.keys.join(', ') + ' to ' + (DATA.next.label || DATA.next.name) + ' in Jira. PMOS does not change Jira.'); return true; }
234
246
  await editMany(T, { start: DATA.next.start, due: DATA.next.end }, 'Into ' + (DATA.next.label || DATA.next.name) + (p.keys.length ? '. Add ' + p.keys.join(', ') + ' in Jira' : ''));
235
247
  return true;
236
248
  }
@@ -4,6 +4,10 @@
4
4
  *
5
5
  * dayText(iso) → "15 Oct 2026" ('' when not a day)
6
6
  * parseDay(text, today) → 'YYYY-MM-DD' or null: "15 Oct 2026", "15 oct", "Oct 15 2026", "2026-10-15", "15/10/2026" (day first)
7
+ * and words (bet A488): today, tomorrow, yesterday, a weekday ("fri", "next friday": the next one after today,
8
+ * never today), "+3d" "+2w" "+1m" "-1w", "in 2 weeks", "end of week" (Friday), "end of month", and "end of sprint"
9
+ * when o.sprintEnd (an ISO day) is given. parseDay(text, today, o)
10
+ * wordsOnly(text) → true when text is a word form above, not a written date (for the use log)
7
11
  * monthGrid(iso, o) → { title, weeks: [[{ iso, n, out, off, on, today }]] } for the month of iso; o: { value, min, max, today }
8
12
  * mountDay(el, o) draws the field into el. o: { label, value, min, max, today, onPick(iso), open } — onPick runs on Enter, on a
9
13
  * change of the field, and on a press in the calendar. A day outside min..max is refused in plain words.
@@ -20,9 +24,33 @@ export const localToday = () => { const d = new Date(); return d.getFullYear() +
20
24
 
21
25
  export function dayText(v) { const n = ms(v); if (n == null) return ''; const d = new Date(n); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()] + ' ' + d.getUTCFullYear(); }
22
26
 
23
- export function parseDay(text, today = localToday()) {
24
- const s = String(text || '').trim().toLowerCase().replace(/,/g, ' ').replace(/\s+/g, ' ');
27
+ const WDAY = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
28
+ const plus = (v, n) => iso(ms(v) + n * 864e5);
29
+ const plusMonths = (v, n) => { const d = new Date(ms(v)), y = d.getUTCFullYear(), m = d.getUTCMonth() + n, last = new Date(Date.UTC(y, m + 1, 0)).getUTCDate(); return iso(Date.UTC(y, m, Math.min(d.getUTCDate(), last))); };
30
+ const UNIT = { d: 'd', day: 'd', days: 'd', w: 'w', wk: 'w', wks: 'w', week: 'w', weeks: 'w', m: 'm', mo: 'm', month: 'm', months: 'm' };
31
+ /** A date said in words, read against today: 'YYYY-MM-DD', null (not a word form, or a sprint end not known), or undefined (not words at all). */
32
+ function wordDay(s, today, o = {}) {
33
+ if (/^(today|tod)$/.test(s)) return today;
34
+ if (/^(tomorrow|tmr|tmrw)$/.test(s)) return plus(today, 1);
35
+ if (s === 'yesterday') return plus(today, -1);
36
+ let m = /^(?:next )?(sun|mon|tue|wed|thu|fri|sat)[a-z]*$/.exec(s);
37
+ if (m && /^(sun(day)?|mon(day)?|tue(s(day)?)?|wed(nesday)?|thu(r(s(day)?)?)?|fri(day)?|sat(urday)?)$/.test(s.replace(/^next /, ''))) {
38
+ const dow = new Date(ms(today)).getUTCDay(); return plus(today, ((WDAY.indexOf(m[1]) - dow + 7) % 7) || 7);
39
+ }
40
+ m = /^([+-]) ?(\d{1,3}) ?([a-z]+)$/.exec(s) || /^(in) (\d{1,3}) ([a-z]+)$/.exec(s);
41
+ if (m && UNIT[m[3]]) { const n = (m[1] === '-' ? -1 : 1) * +m[2], u = UNIT[m[3]]; return u === 'm' ? plusMonths(today, n) : plus(today, u === 'w' ? 7 * n : n); }
42
+ if (/^(end of (the )?week|eow)$/.test(s)) { const dow = new Date(ms(today)).getUTCDay(); return plus(today, dow === 6 ? 6 : dow === 0 ? 5 : 5 - dow); }
43
+ if (/^(end of (the )?month|eom)$/.test(s)) { const d = new Date(ms(today)); return iso(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 0)); }
44
+ if (/^(end of (the )?sprint|sprint end|eos)$/.test(s)) return ms(o.sprintEnd) != null ? String(o.sprintEnd).slice(0, 10) : null;
45
+ return undefined;
46
+ }
47
+ const norm = (text) => String(text || '').trim().toLowerCase().replace(/,/g, ' ').replace(/\s+/g, ' ');
48
+
49
+ export function parseDay(text, today = localToday(), o = {}) {
50
+ const s = norm(text);
25
51
  if (!s) return null;
52
+ const w = ms(today) != null ? wordDay(s, today, o) : undefined;
53
+ if (w !== undefined) return w;
26
54
  let m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s);
27
55
  if (m) return valid(+m[1], +m[2] - 1, +m[3]);
28
56
  m = /^(\d{1,2})[/.](\d{1,2})[/.](\d{4})$/.exec(s); // day first, the app's order
@@ -35,6 +63,10 @@ export function parseDay(text, today = localToday()) {
35
63
  if (m && mon(m[1]) >= 0) return valid(m[3] ? +m[3] : y0, mon(m[1]), +m[2]);
36
64
  return null;
37
65
  }
66
+ /** True when the text is a date said in words (W1 to W4 of planning/done-tests/dates-in-words.md), not a written date. */
67
+ export const wordsOnly = (text) => { const s = norm(text); return !!s && wordDay(s, '2026-01-07', { sprintEnd: '2026-01-09' }) !== undefined; };
68
+ /** "Friday 27 Nov 2026": the day a typed word was read as, said in full before it is saved. */
69
+ export const dayLong = (v) => { const n = ms(v); return n == null ? '' : ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][new Date(n).getUTCDay()] + ' ' + dayText(v); };
38
70
 
39
71
  export function monthGrid(at, o = {}) {
40
72
  const n = ms(at) ?? ms(o.today) ?? ms(localToday()), d = new Date(n), y = d.getUTCFullYear(), m = d.getUTCMonth();
@@ -727,7 +727,7 @@ export function wire(body, h0, x0) {
727
727
  if (d.pwFact) { fact(d.pwFact, b, c, h); return; }
728
728
  if (d.pwStatus) { statusMenu(b, d.pwStatus, h, c); return; }
729
729
  if (d.pwJstat) { jiraStatusMenu(b, d.pwJstat, h, c); return; }
730
- if (d.pwDate) { dateMenu(b, d.pwDate, c, h); return; }
730
+ if (d.pwDate) { dateMenu(b, d.pwDate, c, h, x); return; }
731
731
  if (d.pwName) { rename(b, d.pwName, h); return; }
732
732
  if ('pwPhall' in d) { if (PH_ALL.has(c.id)) PH_ALL.delete(c.id); else PH_ALL.add(c.id); redraw(); return; } // a phone: the other stages unfold (PhoneWorkDS)
733
733
  if (d.pwOpen) { openSmall(d.pwOpen, c, h, x, body); return; }
@@ -935,7 +935,7 @@ function jiraStatusMenu(btn, uid, h, c) {
935
935
  * of the date popup, the row's ⋯, and the add row. A task has Start and Due; a milestone one Date. A Jira task's change is PMOS-only. */
936
936
  const jiraNote = (row) => (row.jira ? '<p class="hi-small pw-jn">PMOS only. Jira is not changed.</p>' : '');
937
937
  function setKind(row, on, h) { ED.milestone(h, { uid: row.uid, start: row.start, end: row.end, ms: row.ms }, on); }
938
- function dateMenu(btn, uid, c, h) {
938
+ function dateMenu(btn, uid, c, h, x) {
939
939
  const row = c.W.rows.find((x) => x.uid === uid) || {};
940
940
  const seg = `<div class="pw-seg" role="radiogroup" aria-label="Task or milestone"><button type="button" role="radio" aria-checked="${!row.ms}" data-ty="task">${SVG(P.box, 13, 2)}Task</button><button type="button" role="radio" aria-checked="${!!row.ms}" data-ty="ms">${SVG(P.dia, 13, 2)}Milestone</button></div>`;
941
941
  // start and due on one calendar (pm/range-pick.js): the first tap sets the start, the second the due day; a milestone one date
@@ -945,7 +945,10 @@ function dateMenu(btn, uid, c, h) {
945
945
  if (b.dataset.ty) { const on = b.dataset.ty === 'ms'; closePop(); if (on !== !!row.ms) setKind(row, on, h); }
946
946
  }, { label: 'Set the date', focus: '.rp-g [tabindex="0"]' });
947
947
  // mountRange draws the markup again, so the day openPop focused is gone: give the focus to the new one
948
- mountRange(el.querySelector('.pw-rp'), { ...R, onPick: (patch, done) => { if (done) closePop(); if (h.dates) h.dates(uid, patch); } }).focus();
948
+ // "end of sprint" typed in a field (bet A488): the task's own sprint, else the active one, from the board's open sprints (the Sprint menu's read)
949
+ let sprintEnd = '';
950
+ sprintsOf(c, h, x).then((L) => { const C = IF.sprintChoices(L, c.W.today), cur = C.find((q) => row.sprint && q.name === String(row.sprint)) || C.find((q) => q.state === 'active'); sprintEnd = cur ? cur.end : ''; }).catch(() => {});
951
+ mountRange(el.querySelector('.pw-rp'), { ...R, sprintEnd: () => sprintEnd, onPick: (patch, done) => { if (done) closePop(); if (h.dates) h.dates(uid, patch); } }).focus();
949
952
  }
950
953
  function rowMenu(btn, uid, c, h, body) {
951
954
  const row = c.W.rows.find((x) => x.uid === uid) || {};
@@ -1273,13 +1276,18 @@ function stageMenu(btn, uid, c, h, x) {
1273
1276
  * answer's `from` back. Sprint lists the board's open sprints (GET /api/boards/sprints, as the tracker holds them) and gives the task the
1274
1277
  * sprint's days; a Jira ticket has neither button (Jira keeps its own). The pop list closes on Esc (pm/hi-pop.js). */
1275
1278
  const SPRINTS = new Map(); // ws|board → the open sprints, read once per popup page
1276
- async function sprintMenu(btn, uid, c, h, x) {
1277
- const row = c.W.rows.find((r) => r.uid === uid) || {};
1279
+ async function sprintKey(c, h, x) {
1278
1280
  const o = (x && x.o && x.o()) || {}, w = h.where ? h.where() : {}, ws = w.ws || o.ws, board = w.board || o.board, k = ws + '|' + board;
1279
1281
  if (!SPRINTS.has(k)) {
1280
1282
  const r = await pmGet('/api/boards/sprints?ws=' + encodeURIComponent(ws || '') + '&board=' + encodeURIComponent(board || '')).catch(() => null);
1281
1283
  SPRINTS.set(k, r && r.ok !== false ? r.sprints || [] : []);
1282
1284
  }
1285
+ return k;
1286
+ }
1287
+ const sprintsOf = async (c, h, x) => SPRINTS.get(await sprintKey(c, h, x)) || [];
1288
+ async function sprintMenu(btn, uid, c, h, x) {
1289
+ const row = c.W.rows.find((r) => r.uid === uid) || {};
1290
+ const k = await sprintKey(c, h, x);
1283
1291
  const L = IF.sprintItems(row, IF.sprintChoices(SPRINTS.get(k), c.W.today));
1284
1292
  openPop(btn, 'pw-sprint', L.map((s, i) => `<button type="button" class="hi-mi" role="menuitemradio" aria-checked="${s.on}" data-i="${i}">${esc(s.label)} <span class="hi-small">${esc(s.dates)}</span></button>`).join('')
1285
1293
  || '<p class="hi-small">No open sprint has dates yet. When the tracker has one, it shows here.</p>', async (b) => {
@@ -62,6 +62,7 @@ import * as SW from './cozy-schedwork.js';
62
62
  import * as AD from './cozy-adler.js';
63
63
  import * as SE from './cozy-seasons.js';
64
64
  import { weeksOf, lineOf, storiesOf } from './upd-weeks.js';
65
+ import * as SRU from './standing-rules-ui.js';
65
66
  import * as SD from './set-ds.js';
66
67
  import { tintOn, setDayTint } from './day-tint.js'; // bet A339: the Light ground follows the clock
67
68
  import { relayState, relayLoad, relayHtml, relayClick } from './cozy-relay.js'; // event-relay (D110): Connectors › Listening
@@ -467,7 +468,8 @@ function decidesSec() {
467
468
  return sug
468
469
  + `<section class="pm-block" aria-label="Changes PMOS makes"><div class="head"><h3 class="pm-h">Changes PMOS makes by itself</h3></div><p class="pm-meta ev-lead">For each kind, how many PMOS made and how many you kept. Quietly: it does it and you can Undo. Show me: it does it and tells you. Ask first: it waits for your yes. Two Undos on a kind and it asks first for 7 days.</p>${kinds}</section>`
469
470
  + `<section class="pm-block" aria-label="Always yours"><div class="head"><h3 class="pm-h">Always yours</h3></div><p class="pm-meta ev-lead">PMOS never does these alone, whatever you set above.</p>${ALWAYS.map(([b, p]) => trow(b, p, '<span class="pm-badge">Always asks</span>')).join('')}</section>`
470
- + lessons;
471
+ + lessons
472
+ + SRU.html((T.ws || []).filter((x) => !x.linked), trow); // Standing rules (bet A470, pm/standing-rules-ui.js)
471
473
  }
472
474
  /** A press on a kind's way: the PM's way is kept, unless it is the automatic one (then the kind follows the automatic way again). */
473
475
  async function saveWay(kind, v) {
@@ -687,6 +689,7 @@ async function press(e) {
687
689
  if ('evUcall' in t.dataset) { const r = await pmPost('/api/use-log/show', { all: true }); if (r && r.ok) { toast(r.shown === 1 ? '1 button is back on its page.' : `${r.shown} buttons are back on their pages.`); loadUseLog(); } else toast((r && r.error) || 'PMOS could not show the hidden buttons.'); return; }
688
690
  if ('evUcshow' in t.dataset) { const [page, control] = t.dataset.evUcshow.split(' '); const r = await pmPost('/api/use-log/show', { page, controls: [control] }); if (r && r.ok) { toast(`Back on ${ulPage(page)}.`); loadUseLog(); } else toast((r && r.error) || 'PMOS could not show that button.'); return; }
689
691
  if ('evUlclear' in t.dataset) { const r = await pmPost('/api/use-log/clear', {}); if (r && r.ok) { T.ul = null; toast('Use log cleared.'); loadUseLog(); } else toast((r && r.error) || 'PMOS could not clear the use log.'); return; }
692
+ if (await SRU.click(t, draw, (m) => { T.msg = m; })) return;
690
693
  if ('evInfo' in t.dataset) { T.info = !T.info; draw(); return; }
691
694
  if ('evFold' in t.dataset) { T.fold = !T.fold; draw(); return; }
692
695
  if (t.dataset.evMore) { T.wkMore.add(t.dataset.evMore); draw(); return; }
@@ -840,6 +843,7 @@ async function load() {
840
843
  const [w, p, s, b] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings'), pmGet('/api/settings'), pmGet('/api/briefing-premium')]);
841
844
  T.ws = w && Array.isArray(w.workspaces) ? w.workspaces : [];
842
845
  JL.load(T.ws.filter((x) => !x.linked), draw); // a linked worktree is its repository: one row each
846
+ SRU.load(T.ws.filter((x) => !x.linked), draw).catch(() => {}); // Settings › How PMOS decides › Standing rules
843
847
  T.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {}; T.con = p && p.ok && p.settings ? { ...p.settings.connectors } : {};
844
848
  T.conn = p && p.connectors && Array.isArray(p.connectors.list) ? p.connectors.list : [];
845
849
  readDir(false).then(() => draw()); // the directory: proposals, ✦ For you signals (initiative connectors-directory)
@@ -861,7 +865,7 @@ export function openSettings(section, o = {}) {
861
865
  const m = MOVED[section];
862
866
  if (m) { T.sec = m[0]; T.sub = m[1]; T.dress = section === 'dress'; } else if (section && BODY[section]) { T.sec = section; T.sub = ''; T.dress = false; }
863
867
  else if (el.hidden) { T.sec = 'general'; T.sub = ''; T.dress = false; } // a fresh open with no section opens on General (R2), not on the section of the last visit
864
- if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.wkMore = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.info = false; T.fold = false; T.dir = null; T.q = ''; T.cat = 'all'; stopWait(); T.dset = {}; T.cl = null; T.gr = null; T.pru = null; T.np = null; T.ck = null; T.ls = null; JL.reset(); SW.swReset(); }
868
+ if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.wkMore = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.info = false; T.fold = false; T.dir = null; T.q = ''; T.cat = 'all'; stopWait(); T.dset = {}; T.cl = null; T.gr = null; T.pru = null; T.np = null; T.ck = null; T.ls = null; JL.reset(); SW.swReset(); SRU.reset(); }
865
869
  el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
866
870
  draw();
867
871
  const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();
@@ -19,11 +19,12 @@ import { productName, whenNames } from './scope-chip.js';
19
19
  import * as TP from './cozy-today-view.js';
20
20
  import * as OM from './mention-one-model.js'; // the one mention's title and the self check's proof line (Today round 3)
21
21
  import { wireSwipe } from './cozy-phone-swipe.js';
22
+ import { noteUse } from './use-log.js'; // your-move (A468): each press on a Your move row is one ym-act line in the local use log (its health number)
22
23
  import * as CC from './change-cues.js'; // idea A313: a short cue on the row that is done, moved or dropped, before the log draws again // the phone: rows and the proposal swipe (phone design, Ph2_today)
23
24
 
24
25
  const ASK_SEND = new Set(['session']);
25
26
  export function mountToday(ctx) {
26
- const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), job: '', sheet: '', open: false, hide: new Set(), sopen: new Set(), unfiled: new Set(), filedOk: new Set() };
27
+ const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), job: '', sheet: '', open: false, hide: new Set(), sopen: new Set(), unfiled: new Set(), filedOk: new Set(), ymOpen: false, ymN: -1 };
27
28
  const el = document.getElementById('tdPage');
28
29
  // a desk and a phone both draw Today here; a phone draws its own one column (TP.phonePageHtml, board Ph2_today) while no conversation is
29
30
  // open over it (body.hm-plist: home-app.js's phone list state). On a phone Home's list is not drawn on today.html (cozy-today-page.css).
@@ -82,7 +83,10 @@ export function mountToday(ctx) {
82
83
  const R = ctx.review();
83
84
  const lab = (S.lab || []).flatMap((l) => (l.items || []).map((f) => ({ ...f, ws: l.ws, board: l.board })));
84
85
  const L = TM.logModel({ rank: ctx.rank(), move, items: tdItems(), drafts, review: R && R.open && !R.done ? { title: 'Your weekly review' } : null,
85
- own: X.log.entries, marks: X.log.marks, lab, questions: X.questions || [], titleOf: ctx.titleOf, productOf, now });
86
+ own: X.log.entries, marks: X.log.marks, lab, questions: X.questions || [], titleOf: ctx.titleOf, productOf, now,
87
+ // your-move (A468): an initiative's ship date is its board end date; a line with no default on work that ships soon blocks it
88
+ shipOf: (id) => { const r = byId.get('i:' + id); return (r && r.board && r.board.end) || ''; } });
89
+ if (L.move.length !== X.ymN) { X.ymN = L.move.length; console.info('[your-move] rows=' + L.move.length + ' shown=' + L.first.length + (L.move[0] ? ' first-tier=' + L.move[0].tier : '')); }
86
90
  const lead = L.rows.find((r) => !r.done && r.src !== 'note' && r.src !== 'own' && r.src !== 'lab');
87
91
  const A = TM.agendaModel({ meetings: ctx.meetings(), own: X.log.entries, reports: X.reports || [], focus: lead ? { key: lead.key, title: lead.title } : null, now,
88
92
  iniOf: (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null });
@@ -99,7 +103,7 @@ export function mountToday(ctx) {
99
103
  const { L, A, O } = models();
100
104
  X.model = L; X.agenda = A; X.overview = O;
101
105
  autoClosed();
102
- // the rail's number on every place: the lines for today (Do first and what waits today), the number the Overview says; kept for the
106
+ // the rail's number on every place: the lines for today (Your move and what waits today), the number the Overview says; kept for the
103
107
  // other places with its day (pm/cozy-nav.js reads it there)
104
108
  if (O.today !== X.calls) {
105
109
  X.calls = O.today;
@@ -112,7 +116,7 @@ export function mountToday(ctx) {
112
116
  if (phone()) {
113
117
  // PhoneTodayDS (job #1540): Where it stands, the log with All ⌄, the capture box at the foot, the ✦ proposal's sheet
114
118
  if (X.sheet && !(O.suggest || []).some((x) => x.key === X.sheet)) X.sheet = '';
115
- const html = TP.phonePageHtml(L, A, O, { head: TM.headModel(ctx.now()), job: X.job, open: X.open, sopen: [...X.sopen], filed: filedLine(), now: ctx.now(), draft, mic: !!SPEECH(), sheet: X.sheet });
119
+ const html = TP.phonePageHtml(L, A, O, { head: TM.headModel(ctx.now()), job: X.job, open: X.open, ymOpen: X.ymOpen, sopen: [...X.sopen], filed: filedLine(), now: ctx.now(), draft, mic: !!SPEECH(), sheet: X.sheet });
116
120
  if (html === X.html && el.firstChild) return;
117
121
  X.html = html; el.classList.add('tdp');
118
122
  document.body.classList.toggle('tdp-sheeton', !!X.sheet);
@@ -122,7 +126,7 @@ export function mountToday(ctx) {
122
126
  return;
123
127
  }
124
128
  el.classList.remove('tdp');
125
- const html = TP.pageHtml(L, A, { draft, overview: O, job: X.job, open: X.open || !!X.job, handled: X.job && X.job !== 'Reply' ? [] : handled(), hopen: X.hopen, sopen: [...X.sopen], filed: filedLine() });
129
+ const html = TP.pageHtml(L, A, { draft, overview: O, job: X.job, open: X.open || !!X.job, ymOpen: X.ymOpen, handled: X.job && X.job !== 'Reply' ? [] : handled(), hopen: X.hopen, sopen: [...X.sopen], filed: filedLine() });
126
130
  if (html === X.html && el.firstChild) return;
127
131
  X.html = html;
128
132
  const st = el.parentNode ? el.parentNode.scrollTop : 0;
@@ -185,7 +189,7 @@ export function mountToday(ctx) {
185
189
  /** The popup's chat hidden for this open (round 3 point 7), until the popup's own per-item rule does it. */
186
190
  const chatOff = () => setTimeout(() => { const h = document.querySelector('.cz-pop:not([hidden]) [data-pop="hide"]'); if (h && !h.closest('.chat-off')) h.click(); }, 60);
187
191
  /** The rows in the order Today shows them, the ones that open something. */
188
- const order = () => { const L = X.model; if (!L) return []; return [...(L.first || []), ...(L.todayRows || []), ...(X.open || X.job ? L.wait || [] : [])].filter((r) => r && !r.done && r.src !== 'note' && r.src !== 'own' && (!X.job || r.job === X.job)); };
192
+ const order = () => { const L = X.model; if (!L) return []; return [...(L.first || []), ...(X.ymOpen ? L.more || [] : []), ...(L.todayRows || []), ...(X.open || X.job ? L.wait || [] : [])].filter((r) => r && !r.done && r.src !== 'note' && r.src !== 'own' && (!X.job || r.job === X.job)); };
189
193
  /** ↑ ↓ (j k) in the popup: the previous or next Today row opens in its place. true when it stepped. */
190
194
  function step(d) {
191
195
  const list = order(), i = list.findIndex((r) => r.key === X.last);
@@ -402,6 +406,7 @@ export function mountToday(ctx) {
402
406
  if (act === 'sheet-x') { X.sheet = ''; draw(); return; }
403
407
  if (act === 'cap-mic') { listen(b); return; }
404
408
  if (act === 'fold') { X.open = !X.open; draw(); return; }
409
+ if (act === 'ym-fold') { X.ymOpen = !X.ymOpen; draw(); return; } // your-move: the rest of Your move, in the same order
405
410
  if (act === 'hfold') { X.hopen = !X.hopen; draw(); return; }
406
411
  if (act === 'h-undo') {
407
412
  b.disabled = true; const m = await ctx.mentionAct(key, 'reopen').catch(() => null);
@@ -439,6 +444,7 @@ export function mountToday(ctx) {
439
444
  ctx.VW.popNext({ keep: true, id: x.key, kind: 'meeting', title: x.title }); ctx.openMeeting(x.ref); return;
440
445
  }
441
446
  const r = rowOf(key); if (!r) return;
447
+ if (r.tier != null && (act === 'open' || act === 'done' || act === 'tomorrow')) noteUse('ym-act'); // your-move's health number
442
448
  if (act === 'q-remind') { remindQuestion(r.ref); return; }
443
449
  if (act === 'open') { open(r); return; }
444
450
  if (act === 'date') { chooseDate(r, b); return; }