create-pmos 0.830.0 → 0.832.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 (55) hide show
  1. package/package.json +129 -50
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +128 -36
  7. package/workspace/guide/backlog.md +1 -1
  8. package/workspace/guide/cli.md +27 -1
  9. package/workspace/guide/layout.md +4 -1
  10. package/workspace/guide/programs.md +2 -1
  11. package/workspace/lib/anchor-id.js +226 -0
  12. package/workspace/lib/artefacts-cli.js +25 -1
  13. package/workspace/lib/events-place.js +11 -4
  14. package/workspace/lib/features.json +2 -0
  15. package/workspace/lib/initiative-cli.js +67 -2
  16. package/workspace/lib/layouts-cli.js +6 -0
  17. package/workspace/lib/lessons-draft.js +242 -0
  18. package/workspace/lib/list-balance.js +18 -3
  19. package/workspace/lib/pmos-verbs.js +6 -0
  20. package/workspace/lib/prefs-sync.js +1 -1
  21. package/workspace/lib/route-modules.js +2 -0
  22. package/workspace/lib/routes-c3-strategy.js +2 -1
  23. package/workspace/lib/routes-events-place.js +19 -1
  24. package/workspace/lib/routes-proposals.js +2 -2
  25. package/workspace/lib/routes-screen-layouts.js +56 -0
  26. package/workspace/lib/routes-switches.js +35 -0
  27. package/workspace/lib/switch-owners.js +152 -0
  28. package/workspace/lib/switches-cli.js +85 -0
  29. package/workspace/lib/three-layouts.js +214 -0
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/public/pm/bd-goal.js +33 -0
  33. package/workspace/public/pm/bd-pop-ds.css +16 -0
  34. package/workspace/public/pm/bd-work-ds.css +6 -0
  35. package/workspace/public/pm/bd-work.js +34 -8
  36. package/workspace/public/pm/card-fold.js +123 -0
  37. package/workspace/public/pm/cozy-ev.css +7 -0
  38. package/workspace/public/pm/cozy-events-view.js +8 -4
  39. package/workspace/public/pm/cozy-nav.js +2 -0
  40. package/workspace/public/pm/cozy-pop-work.js +8 -3
  41. package/workspace/public/pm/cozy-today-app.js +28 -1
  42. package/workspace/public/pm/cozy-today-model.js +13 -5
  43. package/workspace/public/pm/cozy-today-view.js +10 -1
  44. package/workspace/public/pm/list-balance.js +16 -2
  45. package/workspace/public/pm/premium-board.js +7 -1
  46. package/workspace/public/pm/readonly.js +2 -0
  47. package/workspace/public/pm/switch-owners.js +70 -0
  48. package/workspace/public/pm/three-layouts.js +66 -0
  49. package/workspace/public/premium-board.html +2 -0
  50. package/workspace/stage-card-tasks-test.js +1 -0
  51. package/workspace/test-lists/anchor-id.json +9 -0
  52. package/workspace/test-lists/card-fold.json +9 -0
  53. package/workspace/test-lists/lessons-on-close.json +9 -0
  54. package/workspace/test-lists/switch-owners.json +9 -0
  55. package/workspace/test-lists/three-layouts.json +9 -0
@@ -0,0 +1,152 @@
1
+ 'use strict';
2
+ /* switch-owners.js — who has which switch: every per-customer switch of a product, why it is set and who agreed (idea A263, initiative
3
+ * switch-owners, board BatchReleaseDS panel 23). THE ONE WRITER and THE ONE FOLD of switches.jsonl.
4
+ * lib/switches-cli.js is the verb `pmos switches`; lib/routes-switches.js is the HTTP side; public/pm/switch-owners.js is the Switches block on Work.
5
+ *
6
+ * readLines(dir) · fold(lines) → [row] row: { id, customer, name, on, why, agreedBy, agreedOn, waiting: { to, at, by } | null, marks, at }
7
+ * read(dir) → fold(readLines(dir)), sorted by customer, then switch
8
+ * marks(row) → [] | ['why'] | ['approver'] | ['why', 'approver'] what the switch is missing
9
+ * add(dir, input, { by, now }) → { ok, row } | { ok: false, error } input: { customer, name, why?, agreedBy?, agreedOn?, on? }
10
+ * set(dir, id, input, { by, now }) → { ok, row } | { ok: false, error } fills or changes why / agreedBy / agreedOn
11
+ * undo(dir, id, { by, now }) → { ok, row } | { ok: false, error } takes the last `set` on this switch back
12
+ * turn(dir, id, to, { by, now }) → { ok, row } | { ok: false, error } asks to turn it on or off: the ask WAITS; `on` does not change
13
+ * confirm(dir, id, { by, now }) → { ok, row } | { ok: false, error } the PM's own page press "I turned it": only `by: 'pm'` is taken
14
+ * cancel(dir, id, { by, now }) → { ok, row } | { ok: false, error } drops a waiting ask
15
+ * count(dir, { marked }) → how many switches (or how many are marked)
16
+ * idOf(customer, name) → 's-<8 hex>' the same customer and switch give the same id
17
+ *
18
+ * WHERE. `dir` is the product's records folder (lib/records-dir.js): planning/records in the PMOS repo, pmos/state/records in a kit product.
19
+ * Append-only: one line per event { at, by, ev, id, ... }; nothing rewrites it.
20
+ *
21
+ * TURNING A SWITCH IS AN OUTWARD CHANGE. The switch lives in the user's product, not here, so PMOS never turns one: the chat or the CLI may
22
+ * only write a `turn` ask, which waits for the PM. The recorded state changes on `confirm`, which takes only the PM's own page press
23
+ * (lib/routes-switches.js passes by: 'pm' after pm-guard requirePagePress), and means "I turned it in the product". Nothing here sends anything. */
24
+ const fs = require('fs');
25
+ const path = require('path');
26
+ const crypto = require('crypto');
27
+
28
+ const FILE = 'switches.jsonl';
29
+ const TAG = '[switch-owners]';
30
+ const MAX = 120;
31
+ const EVENTS = ['add', 'set', 'undo', 'turn', 'confirm', 'cancel'];
32
+ const one = (v, max = MAX) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > max ? s.slice(0, max - 1).trimEnd() + '…' : s; };
33
+ const idOf = (customer, name) => 's-' + crypto.createHash('sha256').update(one(customer).toLowerCase() + '\u0000' + one(name).toLowerCase()).digest('hex').slice(0, 8);
34
+ const fileOf = (dir) => path.join(dir, FILE);
35
+ const DAY = /^\d{4}-\d{2}-\d{2}$/;
36
+ const log = (s) => { try { console.log(TAG + ' ' + s); } catch { /* no console */ } };
37
+
38
+ function readLines(dir) {
39
+ let raw = '';
40
+ try { raw = fs.readFileSync(fileOf(dir), 'utf8'); } catch { return []; }
41
+ const out = [];
42
+ for (const l of raw.split('\n')) { if (!l.trim()) continue; try { const x = JSON.parse(l); if (x && EVENTS.includes(x.ev) && x.id) out.push(x); } catch { /* a torn line is skipped */ } }
43
+ return out;
44
+ }
45
+ function append(dir, ev) {
46
+ fs.mkdirSync(dir, { recursive: true });
47
+ fs.appendFileSync(fileOf(dir), JSON.stringify(ev) + '\n');
48
+ }
49
+
50
+ /** What a switch is missing: a reason, an approver, or both. */
51
+ function marks(row) {
52
+ const m = [];
53
+ if (!one(row && row.why)) m.push('why');
54
+ if (!one(row && row.agreedBy)) m.push('approver');
55
+ return m;
56
+ }
57
+
58
+ const FIELDS = { why: 'why', agreedBy: 'agreedBy', agreedOn: 'agreedOn' };
59
+ function fold(lines) {
60
+ const by = new Map();
61
+ for (const e of lines) {
62
+ const r = by.get(e.id);
63
+ if (e.ev === 'add') {
64
+ if (r) continue;
65
+ by.set(e.id, { id: e.id, customer: e.customer, name: e.name, on: e.on !== false, why: e.why || '', agreedBy: e.agreedBy || '', agreedOn: e.agreedOn || '',
66
+ waiting: null, at: e.at, sets: [] });
67
+ continue;
68
+ }
69
+ if (!r) continue;
70
+ if (e.ev === 'set') {
71
+ const before = {}; for (const k of Object.keys(FIELDS)) if (k in (e.fields || {})) { before[k] = r[k]; r[k] = e.fields[k] || ''; }
72
+ r.sets.push(before);
73
+ } else if (e.ev === 'undo') {
74
+ const before = r.sets.pop(); if (before) Object.assign(r, before);
75
+ } else if (e.ev === 'turn') {
76
+ r.waiting = { to: e.to, at: e.at, by: e.by || '' }; // an ask only: `on` stays as it was
77
+ } else if (e.ev === 'confirm') {
78
+ if (e.by === 'pm' && r.waiting) { r.on = r.waiting.to === 'on'; r.waiting = null; }
79
+ } else if (e.ev === 'cancel') {
80
+ r.waiting = null;
81
+ }
82
+ r.at = e.at;
83
+ }
84
+ return [...by.values()].map((r) => { const { sets, ...rest } = r; return { ...rest, canUndo: sets.length > 0, marks: marks(r) }; });
85
+ }
86
+ function read(dir) {
87
+ return fold(readLines(dir)).sort((a, b) => a.customer.localeCompare(b.customer) || a.name.localeCompare(b.name));
88
+ }
89
+ const find = (dir, id) => read(dir).find((r) => r.id === id) || null;
90
+
91
+ function add(dir, input = {}, { by = 'unknown', now = Date.now() } = {}) {
92
+ const customer = one(input.customer), name = one(input.name);
93
+ if (!customer || !name) return { ok: false, error: 'a switch needs a customer and a name' };
94
+ const agreedOn = one(input.agreedOn, 10);
95
+ if (agreedOn && !DAY.test(agreedOn)) return { ok: false, error: 'the day it was agreed is YYYY-MM-DD' };
96
+ const id = idOf(customer, name);
97
+ if (find(dir, id)) return { ok: false, error: `${customer} already has ${name} (${id}); pmos switches set ${id} changes it` };
98
+ append(dir, { at: new Date(now).toISOString(), by, ev: 'add', id, customer, name, on: input.on !== false, why: one(input.why), agreedBy: one(input.agreedBy, 80), agreedOn });
99
+ log(`add ${id} ${customer} · ${name}`);
100
+ return { ok: true, row: find(dir, id) };
101
+ }
102
+ function set(dir, id, input = {}, { by = 'unknown', now = Date.now() } = {}) {
103
+ if (!find(dir, id)) return { ok: false, error: `no switch ${id}` };
104
+ const fields = {};
105
+ if (input.why !== undefined) fields.why = one(input.why);
106
+ if (input.agreedBy !== undefined) fields.agreedBy = one(input.agreedBy, 80);
107
+ if (input.agreedOn !== undefined) { const d = one(input.agreedOn, 10); if (d && !DAY.test(d)) return { ok: false, error: 'the day it was agreed is YYYY-MM-DD' }; fields.agreedOn = d; }
108
+ if (!Object.keys(fields).length) return { ok: false, error: 'name --why, --agreed-by or --agreed-on' };
109
+ append(dir, { at: new Date(now).toISOString(), by, ev: 'set', id, fields });
110
+ log(`set ${id} ${Object.keys(fields).join(',')}`);
111
+ return { ok: true, row: find(dir, id) };
112
+ }
113
+ function undo(dir, id, { by = 'unknown', now = Date.now() } = {}) {
114
+ const r = find(dir, id);
115
+ if (!r) return { ok: false, error: `no switch ${id}` };
116
+ if (!r.canUndo) return { ok: false, error: 'nothing to undo on this switch' };
117
+ append(dir, { at: new Date(now).toISOString(), by, ev: 'undo', id });
118
+ log(`undo ${id}`);
119
+ return { ok: true, row: find(dir, id) };
120
+ }
121
+ function turn(dir, id, to, { by = 'unknown', now = Date.now() } = {}) {
122
+ const r = find(dir, id);
123
+ if (!r) return { ok: false, error: `no switch ${id}` };
124
+ if (to !== 'on' && to !== 'off') return { ok: false, error: 'turn it on or off' };
125
+ if ((to === 'on') === r.on) return { ok: false, error: `${r.name} is already ${to} for ${r.customer}` };
126
+ append(dir, { at: new Date(now).toISOString(), by, ev: 'turn', id, to });
127
+ log(`turn ${id} ${to} waits for the PM`);
128
+ return { ok: true, row: find(dir, id) };
129
+ }
130
+ function confirm(dir, id, { by = 'unknown', now = Date.now() } = {}) {
131
+ if (by !== 'pm') return { ok: false, error: 'only your own press on Work turns a switch; PMOS never does' };
132
+ const r = find(dir, id);
133
+ if (!r) return { ok: false, error: `no switch ${id}` };
134
+ if (!r.waiting) return { ok: false, error: 'nothing waits on this switch' };
135
+ append(dir, { at: new Date(now).toISOString(), by, ev: 'confirm', id });
136
+ log(`confirm ${id} ${r.waiting.to}`);
137
+ return { ok: true, row: find(dir, id) };
138
+ }
139
+ function cancel(dir, id, { by = 'unknown', now = Date.now() } = {}) {
140
+ const r = find(dir, id);
141
+ if (!r) return { ok: false, error: `no switch ${id}` };
142
+ if (!r.waiting) return { ok: false, error: 'nothing waits on this switch' };
143
+ append(dir, { at: new Date(now).toISOString(), by, ev: 'cancel', id });
144
+ log(`cancel ${id}`);
145
+ return { ok: true, row: find(dir, id) };
146
+ }
147
+ function count(dir, { marked = false } = {}) {
148
+ const rows = read(dir);
149
+ return marked ? rows.filter((r) => r.marks.length).length : rows.length;
150
+ }
151
+
152
+ module.exports = { FILE, TAG, idOf, readLines, fold, read, marks, add, set, undo, turn, confirm, cancel, count };
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+ /* switches-cli.js — `pmos switches`: who has which switch, per customer, why, and who agreed (idea A263, initiative switch-owners; the store is
3
+ * lib/switch-owners.js, switches.jsonl in the product's records folder, so what the chat writes shows in the Switches block on Work).
4
+ * `turn` only writes an ask that waits for the PM: PMOS turns nothing. Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const { TAG, read, add, set, undo, turn, cancel, count } = require('./switch-owners.js');
8
+
9
+ /* ─ pmos switches ─────────────────────────────────────────────────────────────────────────────────────── */
10
+ const COMMANDS = { switches: ['list', 'add', 'set', 'undo', 'turn', 'cancel', 'count'] };
11
+ const USAGE = [
12
+ 'usage: pmos switches list|add|set|undo|turn|cancel|count — who has which switch: each customer\'s switch, why, and who agreed',
13
+ ' pmos switches list [--json] every switch; a switch with no reason or no approver is marked',
14
+ ' pmos switches add --customer <name> --switch <name> [--why <text>] [--agreed-by <person>] [--agreed-on <YYYY-MM-DD>] [--off]',
15
+ ' pmos switches set <id> [--why <text>] [--agreed-by <person>] [--agreed-on <YYYY-MM-DD>] fill in a reason or an approver',
16
+ ' pmos switches undo <id> take the last set back',
17
+ ' pmos switches turn <id> on|off ask to turn it: the ask waits for you on Work; PMOS turns nothing',
18
+ ' pmos switches cancel <id> drop an ask that waits',
19
+ ' pmos switches count [--marked] how many switches (or how many are marked); the number is the last line',
20
+ 'Run it in the product\'s repository, or pass --root <dir>. Nothing is sent.',
21
+ ];
22
+ const FLAGS = { customer: 'customer', switch: 'name', why: 'why', 'agreed-by': 'agreedBy', 'agreed-on': 'agreedOn', root: 'root' };
23
+ function parse(args) {
24
+ const pos = [], f = {};
25
+ for (let i = 0; i < args.length; i++) {
26
+ const a = args[i];
27
+ if (a === '--json' || a === '--marked' || a === '--off') { f[a.slice(2)] = true; continue; }
28
+ if (a.startsWith('--')) { const k = a.slice(2); if (!(k in FLAGS)) return { bad: a }; f[FLAGS[k]] = args[i + 1] !== undefined ? args[++i] : ''; continue; }
29
+ pos.push(a);
30
+ }
31
+ return { pos, f };
32
+ }
33
+ function repoOf(cwd) {
34
+ let d = path.resolve(cwd);
35
+ for (;;) { try { if (fs.existsSync(path.join(d, '.git'))) return d; } catch { /* look further up */ } const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
36
+ }
37
+ function recordsDirOf(root) {
38
+ try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
39
+ }
40
+ const missingWords = (r) => (r.marks.length === 2 ? 'no reason, nobody agreed' : r.marks[0] === 'why' ? 'no reason' : 'nobody agreed');
41
+ const lineOf = (r) => ` ${r.id} ${r.customer} · ${r.name} · ${r.on ? 'on' : 'off'} · ${r.why || '—'} · ${r.agreedBy ? r.agreedBy + (r.agreedOn ? ', ' + r.agreedOn : '') : 'nobody'}`
42
+ + (r.marks.length ? ` ! ${missingWords(r)}` : '') + (r.waiting ? ` waits for you: turn ${r.waiting.to}` : '');
43
+
44
+ function run(argv, o = {}) {
45
+ const say = o.say || ((s) => console.log(s)), now = o.now || Date.now();
46
+ const args = argv[0] === 'switches' ? argv.slice(1) : argv.slice();
47
+ const cmd = args[0] || 'list';
48
+ if (cmd === 'help' || cmd === '--help' || cmd === '-h') { USAGE.forEach((l) => say(l)); return 0; }
49
+ if (!COMMANDS.switches.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos switches`); USAGE.forEach((l) => say(l)); return 2; }
50
+ const p = parse(args.slice(1));
51
+ if (p.bad) { say(`✗ ${p.bad} is not an option of pmos switches`); return 2; }
52
+ const { pos, f } = p;
53
+ const root = path.resolve(f.root || o.root || repoOf(o.cwd || process.cwd()));
54
+ const dir = o.dir || recordsDirOf(root);
55
+ const by = o.by || 'cli'; // never 'pm': only the page press is the PM's own turn
56
+ const out = (r, ok) => { if (f.json) say(JSON.stringify(r.ok ? { ok: true, row: r.row } : { ok: false, error: r.error })); else say(r.ok ? ok(r.row) : '✗ ' + r.error); return r.ok ? 0 : 1; };
57
+
58
+ if (cmd === 'list') {
59
+ const rows = read(dir);
60
+ if (f.json) { say(JSON.stringify({ ok: true, switches: rows, marked: rows.filter((r) => r.marks.length).length })); return 0; }
61
+ if (!rows.length) { say('No switch is recorded yet. pmos switches add --customer <name> --switch <name> records one.'); return 0; }
62
+ const m = rows.filter((r) => r.marks.length).length;
63
+ say(`${rows.length} switch${rows.length === 1 ? '' : 'es'}${m ? ` · ${m} without a reason or an approver` : ''}`);
64
+ rows.forEach((r) => say(lineOf(r)));
65
+ return 0;
66
+ }
67
+ if (cmd === 'count') {
68
+ const n = count(dir, { marked: !!f.marked });
69
+ say(`${TAG} ${n} switch${n === 1 ? '' : 'es'}${f.marked ? ' without a reason or an approver' : ' recorded'}.`);
70
+ say(String(n));
71
+ return 0;
72
+ }
73
+ if (cmd === 'add') {
74
+ if (pos.length) { say('✗ usage: pmos switches add --customer <name> --switch <name> [--why <text>] [--agreed-by <person>]'); return 2; }
75
+ return out(add(dir, { ...f, on: !f.off }, { by, now }), (r) => `✓ Recorded ${r.customer} · ${r.name} (${r.id})${r.marks.length ? ` — ${missingWords(r)}, so Work marks it` : ''}.`);
76
+ }
77
+ const id = pos[0];
78
+ if (!id) { say(`✗ usage: pmos switches ${cmd} <id>`); return 2; }
79
+ if (cmd === 'set') return out(set(dir, id, f, { by, now }), (r) => `✓ ${r.customer} · ${r.name}: ${r.why || '—'} · ${r.agreedBy || 'nobody'}. Undo: pmos switches undo ${r.id}`);
80
+ if (cmd === 'undo') return out(undo(dir, id, { by, now }), (r) => `✓ Put back: ${r.customer} · ${r.name}: ${r.why || '—'} · ${r.agreedBy || 'nobody'}.`);
81
+ if (cmd === 'turn') return out(turn(dir, id, pos[1], { by, now }), (r) => `Turning ${r.name} ${r.waiting.to} for ${r.customer} is an outward change, so it waits for you on Work. PMOS turned nothing. Drop the ask: pmos switches cancel ${r.id}`);
82
+ return out(cancel(dir, id, { by, now }), (r) => `✓ The ask on ${r.customer} · ${r.name} is dropped. It stays ${r.on ? 'on' : 'off'}.`);
83
+ }
84
+
85
+ module.exports = { run, COMMANDS, USAGE };
@@ -0,0 +1,214 @@
1
+ 'use strict';
2
+ /* three-layouts.js — three layouts for a new screen, pick one (initiative three-layouts, job #1904, idea A317; board BatchDesignDS panel 19,
3
+ * agreed by Wawan 2026-11-25). The store, the rule that finds a new screen, the ✦ recommendation and `pmos layouts`.
4
+ *
5
+ * When a piece of work adds a screen, the first layout drawn is usually the one that ships. This puts three different layouts of the same
6
+ * parts in front of the PM before the build: A List first, B Summary first, C Action first. Each is drawn with grey sample bars, never the
7
+ * product's data and never the board's example names. The PM picks one; the pick is kept on the initiative as the one to build and the
8
+ * other two are kept beside it. Each pick counts for this product, and the ✦ recommends the kind picked most. No model call; nothing is sent.
9
+ *
10
+ * KINDS the three layouts: { key, letter, name, order: [part], says }
11
+ * optionsOf() PURE → [layout] a copy of KINDS with each part's tall flag (the list is the tall part)
12
+ * isNewScreen({ title, intro, state }) PURE → bool a making word then, within three words, a screen word, in the title or the first
13
+ * paragraph; never a done one
14
+ * tasteOf(lines) PURE → { picks: n, by: { key: n }, last: key | null } the product's picks that still stand
15
+ * recOf(taste) PURE → { key, letter, name, why } most picked (a tie goes to the latest pick); none yet: Summary first
16
+ * pickedOf(lines, ini) PURE → { key, kept: [key], at } | null
17
+ * pickLine({ ini, key, title, by }) PURE → { line } | { error } undoLine({ ini, by }) → { line }
18
+ * fileOf(stateDir) · readLines(stateDir) · append(stateDir, line)
19
+ * recordOf(root, ini) → { id, title, intro, state, path } | null the initiative's record (planning/initiatives or pmos/state/initiatives)
20
+ * viewOf(root, ini, { stateDir }) → { ok, none: true } | { ok, layouts, rec, picked, kept, taste } what the Work popup and `show` read
21
+ * CLI: pmos layouts show <id> | pick <id> <A|B|C> | undo <id> | taste [--root <repo>] [--json]
22
+ * STATE: <product state dir>/layouts.jsonl, append-only, one line per pick or undo: { at, ini, act: 'pick'|'undo', key?, kept?, title?, by }.
23
+ * Every log line carries [three-layouts]. */
24
+ const fs = require('fs');
25
+ const path = require('path');
26
+
27
+ const TAG = '[three-layouts]';
28
+ const FILE = 'layouts.jsonl';
29
+ const ID_RE = /^[a-z0-9][a-z0-9._-]{0,119}$/;
30
+ const KINDS = Object.freeze([
31
+ Object.freeze({ key: 'list', letter: 'A', name: 'List first', order: Object.freeze(['list', 'summary', 'action']), says: 'the rows fill the screen; the summary and the main action sit under them' }),
32
+ Object.freeze({ key: 'summary', letter: 'B', name: 'Summary first', order: Object.freeze(['summary', 'list', 'action']), says: 'one line of answer on top, the rows under it, the main action last' }),
33
+ Object.freeze({ key: 'action', letter: 'C', name: 'Action first', order: Object.freeze(['action', 'summary', 'list']), says: 'the main action on top, then the summary, then the rows' }),
34
+ ]);
35
+ const PART_NAME = Object.freeze({ summary: 'the summary', list: 'the list', action: 'the main action' });
36
+ const DEFAULT = 'summary';
37
+ // a making word, then at most three words, then a screen word: "Add a Layouts page", "A new settings screen", "Build the onboarding view".
38
+ // "Add a column to the Work page" (five words between) and "Make the Today page load faster" (make is not a making word) are not.
39
+ const NEW_SCREEN_RE = /\b(new|add|adds|adding|build|builds|design|designs|create|creates|introduce|introduces)\b(?:[\s,/-]+[\w'’&.-]+){0,3}?[\s,/-]+(screens?|pages?|views?|dashboards?|forms?|popups?|panels?|tabs?|layouts?)\b/i;
40
+ const CLOSED_RE = /^(done|closed|cancel+ed|stopped|killed|shipped|won'?t do|archived)\b/i;
41
+ const one = (s, n = 240) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
42
+ const kindOf = (k) => { const s = String(k || '').trim().toLowerCase(); return KINDS.find((x) => x.key === s || x.letter.toLowerCase() === s) || null; };
43
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
44
+
45
+ /** PURE. The three layouts, each part with its tall flag. */
46
+ function optionsOf() {
47
+ return KINDS.map((k) => ({ key: k.key, letter: k.letter, name: k.name, says: k.says, parts: k.order.map((p) => ({ part: p, name: PART_NAME[p], tall: p === 'list' })) }));
48
+ }
49
+
50
+ /** PURE. The record says it adds a screen: a screen word and a making word in the title, or both in the first paragraph. Never a done one. */
51
+ function isNewScreen(r) {
52
+ if (!r) return false;
53
+ if (CLOSED_RE.test(one(r.state || r.status, 40))) return false;
54
+ return NEW_SCREEN_RE.test(one(r.title)) || NEW_SCREEN_RE.test(one(r.intro, 400));
55
+ }
56
+
57
+ /** PURE. The picks of a product that still stand: the last line of each initiative decides. */
58
+ function standing(lines) {
59
+ const by = new Map();
60
+ for (const l of lines || []) {
61
+ if (!l || !ID_RE.test(String(l.ini || ''))) continue;
62
+ if (l.act === 'pick' && kindOf(l.key)) by.set(l.ini, l);
63
+ else if (l.act === 'undo') by.delete(l.ini);
64
+ }
65
+ return [...by.values()].sort((a, b) => String(a.at).localeCompare(String(b.at)));
66
+ }
67
+ function tasteOf(lines) {
68
+ const S = standing(lines), by = {};
69
+ for (const l of S) by[l.key] = (by[l.key] || 0) + 1;
70
+ return { picks: S.length, by, last: S.length ? S[S.length - 1].key : null };
71
+ }
72
+ /** PURE. The ✦: the kind picked most in this product; a tie goes to the latest pick of the tied kinds. None yet: Summary first. */
73
+ function recOf(taste) {
74
+ const T = taste || { picks: 0, by: {}, last: null };
75
+ if (!T.picks) {
76
+ const k = kindOf(DEFAULT);
77
+ return { key: k.key, letter: k.letter, name: k.name, why: `${k.letter} puts the answer first, as the design principles say (summary first).` };
78
+ }
79
+ const top = Math.max(...Object.values(T.by));
80
+ const tied = KINDS.filter((k) => T.by[k.key] === top).map((k) => k.key);
81
+ const key = tied.length === 1 ? tied[0] : tied.includes(T.last) ? T.last : tied[0];
82
+ const k = kindOf(key);
83
+ const why = T.picks === 1 ? `${k.letter} fits how you picked last time (${k.name.toLowerCase()}).`
84
+ : `${k.letter} fits how you pick for this product: ${k.name.toLowerCase()} in ${T.by[key]} of your ${plural(T.picks, 'pick', 'picks')}.`;
85
+ return { key: k.key, letter: k.letter, name: k.name, why };
86
+ }
87
+ function pickedOf(lines, ini) {
88
+ const l = standing(lines).find((x) => x.ini === ini);
89
+ return l ? { key: l.key, kept: KINDS.map((k) => k.key).filter((k) => k !== l.key), at: l.at } : null;
90
+ }
91
+ function pickLine({ ini, key, title, by } = {}, now = new Date()) {
92
+ if (!ID_RE.test(String(ini || ''))) return { error: 'ini is an initiative id' };
93
+ const k = kindOf(key);
94
+ if (!k) return { error: 'the layout is A, B or C' };
95
+ return { line: { at: now.toISOString(), ini, act: 'pick', key: k.key, kept: KINDS.map((x) => x.key).filter((x) => x !== k.key), title: one(title, 160), by: one(by, 80) || 'pm' } };
96
+ }
97
+ function undoLine({ ini, by } = {}, now = new Date()) {
98
+ if (!ID_RE.test(String(ini || ''))) return { error: 'ini is an initiative id' };
99
+ return { line: { at: now.toISOString(), ini, act: 'undo', by: one(by, 80) || 'pm' } };
100
+ }
101
+
102
+ /* ── the store ── */
103
+ const fileOf = (dir) => (dir ? path.join(dir, FILE) : null);
104
+ function readLines(dir) {
105
+ const f = fileOf(dir); if (!f) return [];
106
+ let raw = ''; try { raw = fs.readFileSync(f, 'utf8'); } catch { return []; }
107
+ const out = [];
108
+ for (const s of raw.split('\n')) { if (!s.trim()) continue; try { out.push(JSON.parse(s)); } catch { /* a torn line is skipped */ } }
109
+ return out;
110
+ }
111
+ function append(dir, line) {
112
+ const f = fileOf(dir); if (!f) throw new Error('no state folder');
113
+ fs.mkdirSync(dir, { recursive: true });
114
+ fs.appendFileSync(f, JSON.stringify(line) + '\n');
115
+ }
116
+ function stateDirOf(root, create = false) {
117
+ try { return require('./driver.js').stateDirOf(root, { create }); } catch { return null; }
118
+ }
119
+
120
+ /** The initiative's record: title, the first paragraph of its body, its state. null when there is none. */
121
+ function recordOf(root, ini) {
122
+ if (!ID_RE.test(String(ini || ''))) return null;
123
+ const I = require('./item-why.js');
124
+ const f = I.recordPathOf(root, ini);
125
+ if (!f) return null;
126
+ let text = ''; try { text = fs.readFileSync(f, 'utf8'); } catch { return null; }
127
+ const fm = I.frontOf(text);
128
+ const body = text.replace(/^---\s*\n[\s\S]*?\n---\s*(\n|$)/, '');
129
+ const intro = body.split(/\n\s*\n/).map((p) => p.trim()).find((p) => p && !/^#/.test(p)) || '';
130
+ return { id: ini, title: one(fm.title || ini, 200), intro: one(intro, 400), state: one(fm.state || fm.status, 60), path: path.relative(root, f).split(path.sep).join('/') };
131
+ }
132
+
133
+ /** What the Work popup and `pmos layouts show` read. Writes nothing. */
134
+ function viewOf(root, ini, { stateDir } = {}) {
135
+ const r = recordOf(root, ini);
136
+ const lines = readLines(stateDir || stateDirOf(root));
137
+ const picked = r ? pickedOf(lines, ini) : null;
138
+ // a picked one stays: the pick is kept on the work item even when its words change later
139
+ if (!r || (!picked && !isNewScreen(r))) return { ok: true, none: true };
140
+ const taste = tasteOf(lines);
141
+ return { ok: true, ini, title: r.title, layouts: optionsOf(), rec: recOf(taste), picked: picked ? picked.key : null, kept: picked ? picked.kept : [], taste };
142
+ }
143
+
144
+ /* ── pmos layouts ── */
145
+ const COMMANDS = { layouts: ['show', 'pick', 'undo', 'taste'] };
146
+ const USAGE = [
147
+ 'usage: pmos layouts show <initiative> | pick <initiative> <A|B|C> | undo <initiative> | taste — three layouts for a new screen, pick one',
148
+ ' pmos layouts show <id> the three layouts, the ✦ recommendation and the pick (an initiative that adds no screen has none)',
149
+ ' pmos layouts pick <id> <A|B|C> keep one as the layout to build; the other two stay on the initiative',
150
+ ' pmos layouts undo <id> take the pick back',
151
+ ' pmos layouts taste the picks of this product, by kind; the ✦ recommends the kind picked most',
152
+ 'Nothing is sent and no model is called. The Work popup shows the same layouts under the stages.',
153
+ ];
154
+ function repoOf(cwd) {
155
+ let d = path.resolve(cwd);
156
+ for (;;) { try { if (fs.existsSync(path.join(d, '.git'))) return d; } catch { /* look further up */ } const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
157
+ }
158
+ function used(o, now) {
159
+ try { const dir = o.runtimeDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }); require('./use-log.js').record(dir, [{ kind: 'use', page: 'premium-board', control: 'layoutPick', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
160
+ }
161
+ const describe = (V, say) => {
162
+ for (const L of V.layouts) {
163
+ const mark = V.picked === L.key ? ' ✓ picked' : V.picked ? ' (kept)' : V.rec.key === L.key ? ' ✦' : '';
164
+ say(`${L.letter} ${L.name}: ${L.parts.map((p) => p.name).join(', then ')}.${mark}`);
165
+ }
166
+ if (!V.picked) say(`✦ ${V.rec.why}`);
167
+ };
168
+ function run(argv, o = {}) {
169
+ const say = o.say || ((s) => console.log(s)), now = o.now ? new Date(o.now) : new Date();
170
+ const args = argv[0] === 'layouts' ? argv.slice(1) : argv.slice();
171
+ const pos = [], flags = {};
172
+ for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root') flags.root = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
173
+ const cmd = pos[0] || 'help';
174
+ if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
175
+ if (!COMMANDS.layouts.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos layouts`); USAGE.forEach((l) => say(l)); return 2; }
176
+ const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
177
+ const dir = o.stateDir || stateDirOf(root, cmd === 'pick' || cmd === 'undo');
178
+ if (cmd === 'taste') {
179
+ const T = tasteOf(readLines(dir)), R = recOf(T);
180
+ if (flags.json) { say(JSON.stringify({ ok: true, ...T, rec: R })); return 0; }
181
+ if (!T.picks) say('No layout picked for this product yet.');
182
+ else say(KINDS.map((k) => `${k.letter} ${k.name}: ${T.by[k.key] || 0}`).join(' · '));
183
+ say(`✦ ${R.why}`);
184
+ return 0;
185
+ }
186
+ const ini = String(pos[1] || '').trim();
187
+ if (!ini) { say('✗ name the initiative: pmos layouts ' + cmd + ' <id>'); return 2; }
188
+ const r = recordOf(root, ini);
189
+ if (!r) { say(`✗ no initiative ${ini} here: nothing was written`); return 1; }
190
+ if (cmd === 'show') {
191
+ const V = viewOf(root, ini, { stateDir: dir });
192
+ if (flags.json) { say(JSON.stringify(V)); return 0; }
193
+ if (V.none) { say(`${r.title} does not add a screen, so it has no layouts.`); return 0; }
194
+ describe(V, say);
195
+ return 0;
196
+ }
197
+ if (cmd === 'undo') {
198
+ if (!pickedOf(readLines(dir), ini)) { say(`No layout is picked for ${r.title}. Nothing was written.`); return 0; }
199
+ append(dir, undoLine({ ini, by: o.by || 'pm:cli' }, now).line);
200
+ console.log(`${TAG} undo ini=${ini}`);
201
+ say(`↺ The pick for ${r.title} is taken back.`);
202
+ return 0;
203
+ }
204
+ const p = pickLine({ ini, key: pos[2], title: r.title, by: o.by || 'pm:cli' }, now);
205
+ if (p.error) { say(`✗ ${p.error}: nothing was written`); return 1; }
206
+ append(dir, p.line);
207
+ console.log(`${TAG} pick ini=${ini} key=${p.line.key}`);
208
+ used(o, now.getTime());
209
+ const k = kindOf(p.line.key);
210
+ say(`✓ ${k.letter} ${k.name} is the layout to build for ${r.title}. The other two stay on it. pmos layouts undo ${ini} takes it back.`);
211
+ return 0;
212
+ }
213
+
214
+ module.exports = { TAG, FILE, KINDS, DEFAULT, optionsOf, isNewScreen, tasteOf, recOf, pickedOf, pickLine, undoLine, fileOf, readLines, append, stateDirOf, recordOf, viewOf, kindOf, run, COMMANDS, USAGE };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.830.0",
3
+ "version": "0.832.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.830.0",
9
+ "version": "0.832.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.830.0",
3
+ "version": "0.832.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",
@@ -3,6 +3,8 @@
3
3
  * readGoals(ws, rows) → Promise<{ goals, of } | null> GET /api/artefacts/goals: the Goal artefact of each anchor the rows carry (D107, derived)
4
4
  * goalGroups(rows, R) → [{ key, goal, rows }] | null PURE. The rows under each goal, key results in the file's order, then the health budgets,
5
5
  * then "No goal yet". null when no row's anchor names a goal (zero is silence)
6
+ * objectiveGroups(rows, R, sort) → [{ key, name, rows, empty }] | null Work › Initiatives: the rows under their key result's objective (TbInitiatives)
7
+ * servesOf(r, R) → 'Serves KR1.1' | '' the line under a row's name there. PURE
6
8
  * goalHeadHtml(g, o) → the Track's goal row: the goal icon, its name, "KR-A1 · no reading yet", the spread of its initiatives over the steps,
7
9
  * and in the Next column its target and where the reading comes from. o: { steps, plain, open }
8
10
  * asGroups(rows, R, sort) → [{ kind: 'goal', key, goal, name, rows }] | null goalGroups shaped as the Board's groups, so every view draws them
@@ -49,6 +51,37 @@ export function goalGroups(rows, R) {
49
51
  return none.rows.length ? G.concat(none) : G;
50
52
  }
51
53
 
54
+ /** Work › Initiatives (board TbInitiatives, Exploring 3 page balanced): the rows under the OBJECTIVE their key result serves, in the OKR file's
55
+ * order (by the objective's id), named "O1 · Sign-in is fast and nobody is locked out"; then each health budget as its own group; then "No goal yet". PURE.
56
+ * A key result whose goal names no objective keeps its own group, so no head is ever empty. → [{ key, name, rows, empty }] | null */
57
+ export function objectiveGroups(rows, R, sort) {
58
+ const G = goalGroups(rows, R);
59
+ if (!G) return null;
60
+ const out = new Map();
61
+ const put = (k, name, pos, rs, empty, id) => { if (!out.has(k)) out.set(k, { key: k, name, pos, id: id || '', rows: [], empty: !!empty }); out.get(k).rows.push(...rs); };
62
+ for (const g of G) {
63
+ const x = g.goal;
64
+ if (!x) put(NONE, 'No goal yet', 3e9, g.rows, true);
65
+ else if (x.kind === 'kr' && x.objective) { const o = objOf(x); put('obj:' + (o.id || x.objective), (o.token ? o.token + ' · ' : '') + x.objective, o.id ? 0 : 1e9, g.rows, false, o.id); }
66
+ else put(g.key, x.title, x.kind === 'budget' ? 2e9 : 1e9, g.rows);
67
+ }
68
+ return [...out.values()].sort((a, b) => a.pos - b.pos || String(a.id).localeCompare(String(b.id), undefined, { numeric: true }) || String(a.name).localeCompare(String(b.name)))
69
+ .map(({ key, name, rows: rs, empty }) => ({ key, name, rows: sort ? sort(rs) : rs, empty }));
70
+ }
71
+ /** A key result's objective, from its goal key "o1::kr1-1" (lib/board-goals.js: the objective's id, then the key result's): its id and the token
72
+ * the OKR file writes ("O1"; "O-A" for an id of letters). Both '' when the key names none. PURE. */
73
+ export function objOf(x) {
74
+ const id = /^([^:]+)::/.exec(String((x && x.key) || '')); if (!id) return { id: '', token: '' };
75
+ const m = /^o(\d+)$/i.exec(id[1]);
76
+ return { id: id[1], token: m ? 'O' + m[1] : 'O-' + id[1].toUpperCase() };
77
+ }
78
+ /** The line under a row's name on Work › Initiatives: "Serves KR1.1", or the health budget it is anchored to. '' when its anchor names no goal. PURE. */
79
+ export function servesOf(r, R) {
80
+ const k = R && R.of ? R.of[String((r && r.anchor) || '')] : null, x = k && (R.goals || []).find((g) => g.key === k);
81
+ if (!x) return '';
82
+ return 'Serves ' + (x.kind === 'kr' ? x.token || x.title : x.title);
83
+ }
84
+
52
85
  /** The goal's fold, as the program and product heads fold (pm/bd-prog.js fold, data-fold). */
53
86
  export function goalHeadHtml(g, o = {}) {
54
87
  const x = g.goal, open = o.open !== false, steps = o.steps || [], N = steps.length || 8;
@@ -139,3 +139,19 @@ div.pwd-art { cursor: default; }
139
139
  /* the grill run the chat said started: running, or failed and why (pm/grill-words.js runStateLine) */
140
140
  .pwd-grun { margin: var(--space-4) 0 0; color: var(--cz-blueink); }
141
141
  .pwd-grun.bad { color: var(--cz-red); }
142
+
143
+ /* ── Layouts: a new screen's three layouts side by side, the ✦ line under them (three-layouts, A317; BatchDesignDS panel 19) ── */
144
+ .tl-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-8); margin: 0; padding: 0; list-style: none; }
145
+ .tl-tile { display: flex; flex-direction: column; gap: var(--space-8); padding: var(--space-8); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
146
+ .tl-tile.on { box-shadow: inset 0 0 0 2px var(--blue); }
147
+ .tl-tile.kept { opacity: .6; }
148
+ .tl-th { gap: var(--space-8); font-size: var(--fs-meta); }
149
+ .tl-bars { display: grid; gap: 3px; }
150
+ .tl-bar { display: block; height: 10px; border-radius: 2px; background: var(--well); }
151
+ .tl-bar.tall { height: 22px; }
152
+ .tl-tile > .pm-btn { align-self: flex-start; }
153
+ .tl-line { margin: 0; }
154
+ /* one ✓ shows, on the recommended tile (panel 19); the other two show theirs on hover or focus, and always on a touch screen */
155
+ .tl-tile:not(.on) > .pm-btn { opacity: 0; transition: opacity var(--duration-quick) var(--ease-out); }
156
+ .tl-tile:hover > .pm-btn, .tl-tile > .pm-btn:focus-visible { opacity: 1; }
157
+ @media (hover: none) { .tl-tile:not(.on) > .pm-btn { opacity: 1; } }
@@ -38,11 +38,17 @@ table.pm-table.wk col.c-ms { width: 150px; }
38
38
  table.pm-table.wk col.c-date { width: 176px; }
39
39
  table.pm-table.wk col.c-status, table.pm-table.wk col.c-wf { width: 120px; }
40
40
  table.pm-table.wk col.c-program, table.pm-table.wk col.c-goal { width: 160px; }
41
+ table.pm-table.wk col.c-tasks { width: 104px; }
42
+ table.pm-table.wk col.c-owner { width: 120px; }
43
+ table.pm-table.wk col.c-epic { width: 140px; }
41
44
  table.pm-table.wk:not(.has-x) col.c-title { width: auto; }
42
45
  @media (max-width: 1280px) { table.pm-table.wk col.c-title { width: 200px; } table.pm-table.wk col.c-ms { width: 130px; } table.pm-table.wk col.c-date { width: 150px; } table.pm-table.wk col.c-stage { width: 96px; } }
43
46
  table.pm-table.wk th, table.pm-table.wk td { height: 40px; box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
44
47
  table.pm-table.wk td.n { font-weight: var(--fw-strong); color: var(--ink); }
45
48
  table.pm-table.wk td.n .wk-sg { margin-right: 8px; } /* the state glyph before the title (state-glyphs) */
49
+ /* grouped by goal, the key result a row serves sits under its name (TbInitiatives); the title wraps there instead of being cut */
50
+ table.pm-table.wk td.n.sv { height: auto; padding-top: 6px; padding-bottom: 6px; white-space: normal; line-height: 1.3; }
51
+ table.pm-table.wk td.n .wk-sv { display: block; font-size: var(--fs-meta); font-weight: var(--fw-regular); color: var(--muted); }
46
52
  table.pm-table.wk tr.wk-i { cursor: pointer; }
47
53
  table.pm-table.wk tr.wk-i:focus-visible { outline: none; box-shadow: inset var(--glow); }
48
54
  table.pm-table.wk tr.wk-i.sel td { background: var(--blue-tint); }