create-pmos 0.828.0 → 0.830.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.
- package/package.json +237 -35
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-deliveries-test.js +2 -2
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +1 -1
- package/workspace/changelog.json +236 -8
- package/workspace/guide/agent-capabilities.md +1 -1
- package/workspace/guide/backlog.md +12 -1
- package/workspace/guide/cli.md +46 -1
- package/workspace/guide/home.md +2 -1
- package/workspace/guide/layout.md +1 -0
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/board-premium.js +1 -0
- package/workspace/lib/code-map.js +8 -2
- package/workspace/lib/critical-needs.js +162 -0
- package/workspace/lib/deps-cli.js +102 -0
- package/workspace/lib/engine/boards.js +13 -2
- package/workspace/lib/factory-floor.js +16 -8
- package/workspace/lib/features.json +17 -13
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/page-one-answer.js +86 -0
- package/workspace/lib/pages-cli.js +6 -2
- package/workspace/lib/people-cli.js +9 -1
- package/workspace/lib/people-prep.js +140 -0
- package/workspace/lib/pmos-verbs.js +10 -0
- package/workspace/lib/print-cli.js +49 -0
- package/workspace/lib/print-pdf.js +96 -0
- package/workspace/lib/prototype-cli.js +86 -0
- package/workspace/lib/report-cli.js +12 -2
- package/workspace/lib/report-readers.js +5 -3
- package/workspace/lib/review-pack.js +348 -0
- package/workspace/lib/review-reasons.js +121 -9
- package/workspace/lib/route-modules.js +5 -0
- package/workspace/lib/routes-boards.js +25 -2
- package/workspace/lib/routes-report-design.js +3 -1
- package/workspace/lib/routes-review-pack.js +42 -0
- package/workspace/lib/routes-roadmap-ops.js +53 -1
- package/workspace/lib/routes-sim-users.js +66 -0
- package/workspace/lib/routes-skill-map.js +39 -0
- package/workspace/lib/routes-strategy-card.js +13 -6
- package/workspace/lib/routes-team-waits.js +24 -0
- package/workspace/lib/sim-users.js +329 -0
- package/workspace/lib/skill-map.js +199 -0
- package/workspace/lib/task-store.js +1 -1
- package/workspace/lib/team-cli.js +20 -1
- package/workspace/lib/team-waits.js +167 -0
- package/workspace/lib/tradeoff-cards.js +258 -0
- package/workspace/lib/tradeoff-cli.js +83 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/action-keys.js +1 -0
- package/workspace/public/pm/ask-here-ctx.js +25 -1
- package/workspace/public/pm/ask-here.css +7 -0
- package/workspace/public/pm/ask-here.js +15 -2
- package/workspace/public/pm/bd-backlog.css +61 -0
- package/workspace/public/pm/bd-backlog.js +99 -7
- package/workspace/public/pm/bd-work.js +12 -1
- package/workspace/public/pm/code-map.js +15 -4
- package/workspace/public/pm/cozy-board.css +5 -1
- package/workspace/public/pm/cozy-library.css +5 -0
- package/workspace/public/pm/cozy-pop-work.js +4 -1
- package/workspace/public/pm/cozy-proto.css +5 -0
- package/workspace/public/pm/cozy-proto.js +11 -3
- package/workspace/public/pm/cozy-search.js +2 -2
- package/workspace/public/pm/cozy-today-app.js +5 -2
- package/workspace/public/pm/day-time.js +8 -0
- package/workspace/public/pm/factory.js +199 -0
- package/workspace/public/pm/home-ini.js +3 -2
- package/workspace/public/pm/ini-links.js +2 -1
- package/workspace/public/pm/ini-tasks.js +5 -2
- package/workspace/public/pm/ini-view-model.js +14 -6
- package/workspace/public/pm/ini-view.js +12 -2
- package/workspace/public/pm/library-model.js +1 -1
- package/workspace/public/pm/page-one-answer.css +18 -0
- package/workspace/public/pm/page-one-answer.js +134 -0
- package/workspace/public/pm/pop-cap.js +5 -3
- package/workspace/public/pm/pop-work-model.js +8 -6
- package/workspace/public/pm/portfolio.js +1 -1
- package/workspace/public/pm/premium-board.js +23 -6
- package/workspace/public/pm/premium-library.js +27 -3
- package/workspace/public/pm/premium-report-read.js +11 -2
- package/workspace/public/pm/print-pdf.js +191 -0
- package/workspace/public/pm/range-pick.css +12 -0
- package/workspace/public/pm/range-pick.js +30 -6
- package/workspace/public/pm/review-pack.js +47 -0
- package/workspace/public/pm/review-reasons.js +19 -5
- package/workspace/public/pm/sim-users.js +34 -0
- package/workspace/public/pm/skill-map.js +57 -0
- package/workspace/public/pm/sort-order.js +3 -0
- package/workspace/public/pm/task-card.js +10 -7
- package/workspace/public/pm/team-waits.js +56 -0
- package/workspace/public/pm/tradeoff-cards.css +27 -0
- package/workspace/public/pm/tradeoff-cards.js +183 -0
- package/workspace/public/premium-board.html +3 -0
- package/workspace/public/today.html +1 -0
- package/workspace/run-tests.js +9 -1
- package/workspace/test-lists/critical-needs.json +9 -0
- package/workspace/test-lists/factory-page-ui.json +9 -0
- package/workspace/test-lists/page-one-answer.json +9 -0
- package/workspace/test-lists/people-prep.json +9 -0
- package/workspace/test-lists/print-pdf.json +9 -0
- package/workspace/test-lists/review-pack.json +9 -0
- package/workspace/test-lists/sim-users.json +9 -0
- package/workspace/test-lists/skill-map.json +9 -0
- package/workspace/test-lists/surface-ask-card.json +9 -0
- package/workspace/test-lists/task-time-optional.json +9 -0
- package/workspace/test-lists/team-waits.json +9 -0
- package/workspace/test-lists/tradeoff-cards.json +9 -0
- package/workspace/test-lists/voice-files.json +9 -0
- package/workspace/test-timings.json +25 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* sim-users.js — simulated users try the prototype (initiative sim-users, idea A20, board BatchReleaseDS panel 24, Wawan agreed 2026-11-25).
|
|
3
|
+
*
|
|
4
|
+
* Before a prototype version shows in the Viewer, a few simulated users (one per persona) walk the version's key tasks: the scenarios of
|
|
5
|
+
* its flow.json (lib/live-round.js flowOf). The PM sees findings, not clicks: where they got stuck, why, and how many. Each finding names
|
|
6
|
+
* the screen (and element) it came from, so the Viewer opens that screen. A finding is a hint for the grilling: it NEVER scores the
|
|
7
|
+
* prototype, never changes it, and calls no model. The walk is a fixed set of checks over the version's HTML, so it runs on any product.
|
|
8
|
+
*
|
|
9
|
+
* THE WALK. For each step of a scenario, on the step's screen (data-screen), the press that leads on is the step's tap (data-el) or the
|
|
10
|
+
* element that goes to the next screen (data-go, or a link to #<screen>). Every persona gets stuck where the screen is missing or no
|
|
11
|
+
* press leads on. Then each persona's needs are checked on that press:
|
|
12
|
+
* keyboard the press is a button, a link with href, a field, a summary, or has tabindex ≥ 0
|
|
13
|
+
* reader the press has a name to hear: its words, aria-label, aria-labelledby, title, or an image's alt
|
|
14
|
+
* words the press shows words (not only a symbol), and the screen has a heading
|
|
15
|
+
* thumb the press is not set smaller than 44 px (inline width, height or the attributes)
|
|
16
|
+
* PERSONAS come from the user's records: `pmos prototype persona add --name … --needs … --from <record>` (no --from, no persona). With
|
|
17
|
+
* none recorded, the four base personas walk (BASE: abilities, not made-up people).
|
|
18
|
+
*
|
|
19
|
+
* THE STORE. <state>/sim-users.jsonl, append-only:
|
|
20
|
+
* { at, kind: 'persona', op: 'add' | 'remove' | 'restore', id, persona?, by } the newest line for an id wins
|
|
21
|
+
* { at, kind: 'run', log: '[sim-users]', ini, file, sig, personas: [id], findings } one per version and persona set (forVersion)
|
|
22
|
+
*
|
|
23
|
+
* parse(html) PURE → root node · screensOf(root) PURE → Map(id → node) · pressOf(screen, step, next) PURE → node | null
|
|
24
|
+
* simulate({ html, flow, personas }) PURE → [{ persona, task, done, at?, el?, why? }]
|
|
25
|
+
* findingsOf(tries, { flow, personas }) PURE → { personas: n, rows: [{ state, text, who, screen, el?, task, n }] } | null
|
|
26
|
+
* personasOf(lines) PURE → { mine: [persona], removed: [persona], walking: [persona], base: bool }
|
|
27
|
+
* validPersona(input) PURE → { persona } | { error }
|
|
28
|
+
* read(dir) · addPersona(dir, input, { by }) · removePersona(dir, id, { by }) · restorePersona(dir, id, { by })
|
|
29
|
+
* forVersion(dir, { ini, file, abs, flow }) → findings | null (runs or reads the stored run) · count(dir, { days }) → n
|
|
30
|
+
*/
|
|
31
|
+
const fs = require('fs');
|
|
32
|
+
const path = require('path');
|
|
33
|
+
const crypto = require('crypto');
|
|
34
|
+
|
|
35
|
+
const FILE = 'sim-users.jsonl';
|
|
36
|
+
const LOG = '[sim-users]';
|
|
37
|
+
const MAX_PERSONAS = 6;
|
|
38
|
+
const MIN_PX = 44;
|
|
39
|
+
const NEEDS = Object.freeze({
|
|
40
|
+
keyboard: 'uses only the keyboard',
|
|
41
|
+
reader: 'listens with a screen reader',
|
|
42
|
+
words: 'is new and reads the words',
|
|
43
|
+
thumb: 'taps with a thumb on a phone',
|
|
44
|
+
});
|
|
45
|
+
const BASE = Object.freeze([
|
|
46
|
+
Object.freeze({ id: 'new-user', name: 'New user', needs: ['words'], base: true }),
|
|
47
|
+
Object.freeze({ id: 'keyboard-only', name: 'Keyboard only', needs: ['keyboard'], base: true }),
|
|
48
|
+
Object.freeze({ id: 'screen-reader', name: 'Screen reader', needs: ['reader'], base: true }),
|
|
49
|
+
Object.freeze({ id: 'on-a-phone', name: 'On a phone', needs: ['thumb'], base: true }),
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
53
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
54
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
55
|
+
const hash = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 12);
|
|
56
|
+
const slug = (s) => one(s, 60).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40);
|
|
57
|
+
|
|
58
|
+
/* ── a small HTML reader: enough of the tree to walk screens and presses ── */
|
|
59
|
+
const VOID = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
|
|
60
|
+
const RAW = new Set(['script', 'style', 'template', 'textarea', 'title']);
|
|
61
|
+
function decode(s) {
|
|
62
|
+
return String(s).replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot|apos|nbsp|#39);/gi, (m, e) => {
|
|
63
|
+
const k = e.toLowerCase();
|
|
64
|
+
if (k[0] === '#') { const n = k[1] === 'x' ? parseInt(k.slice(2), 16) : parseInt(k.slice(1), 10); return Number.isFinite(n) && n > 0 && n < 0x110000 ? String.fromCodePoint(n) : ''; }
|
|
65
|
+
return { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' }[k] || m;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function attrsOf(s) {
|
|
69
|
+
const a = {}, re = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
|
|
70
|
+
let m; while ((m = re.exec(s))) a[m[1].toLowerCase()] = decode(m[2] != null ? m[2] : m[3] != null ? m[3] : m[4] != null ? m[4] : '');
|
|
71
|
+
return a;
|
|
72
|
+
}
|
|
73
|
+
/** PURE. The HTML as a tree: { tag, attrs, kids: [node | text] }. Comments, scripts and styles are skipped; an unclosed tag closes with its parent. */
|
|
74
|
+
function parse(html) {
|
|
75
|
+
const root = { tag: '#root', attrs: {}, kids: [] }, stack = [root];
|
|
76
|
+
const src = String(html == null ? '' : html).replace(/<!--[\s\S]*?-->/g, ' ');
|
|
77
|
+
const re = /<\/?([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
78
|
+
let last = 0, m;
|
|
79
|
+
const text = (t) => { if (t && /\S/.test(t)) stack[stack.length - 1].kids.push(decode(t)); };
|
|
80
|
+
while ((m = re.exec(src))) {
|
|
81
|
+
text(src.slice(last, m.index)); last = re.lastIndex;
|
|
82
|
+
const tag = m[1].toLowerCase();
|
|
83
|
+
if (m[0][1] === '/') {
|
|
84
|
+
const i = stack.map((n) => n.tag).lastIndexOf(tag);
|
|
85
|
+
if (i > 0) stack.length = i;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const node = { tag, attrs: attrsOf(m[2]), kids: [] };
|
|
89
|
+
stack[stack.length - 1].kids.push(node);
|
|
90
|
+
if (RAW.has(tag)) {
|
|
91
|
+
const end = src.toLowerCase().indexOf('</' + tag, re.lastIndex);
|
|
92
|
+
const inner = src.slice(re.lastIndex, end < 0 ? src.length : end);
|
|
93
|
+
if (tag === 'textarea' || tag === 'title') node.kids.push(decode(inner));
|
|
94
|
+
re.lastIndex = last = end < 0 ? src.length : src.indexOf('>', end) + 1 || src.length;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (!VOID.has(tag) && !/\/\s*$/.test(m[2])) stack.push(node);
|
|
98
|
+
}
|
|
99
|
+
text(src.slice(last));
|
|
100
|
+
return root;
|
|
101
|
+
}
|
|
102
|
+
function walk(node, fn) { for (const k of node.kids || []) if (isObj(k)) { if (fn(k) === false) return false; if (walk(k, fn) === false) return false; } return true; }
|
|
103
|
+
function find(node, test) { let hit = null; walk(node, (n) => { if (test(n)) { hit = n; return false; } return true; }); return hit; }
|
|
104
|
+
function textOf(node) { return (node.kids || []).map((k) => (typeof k === 'string' ? k : textOf(k))).join(' ').replace(/\s+/g, ' ').trim(); }
|
|
105
|
+
/** PURE. The screens of a prototype: data-screen id → node. */
|
|
106
|
+
function screensOf(root) { const out = new Map(); walk(root, (n) => { const id = n.attrs['data-screen']; if (id && !out.has(id)) out.set(id, n); return true; }); return out; }
|
|
107
|
+
/** PURE. The press that leads from this step to the next: the step's tap (data-el), else what goes to the next screen. */
|
|
108
|
+
function pressOf(screen, step, next) {
|
|
109
|
+
if (!screen) return null;
|
|
110
|
+
const goes = (n) => (next && (n.attrs['data-go'] === next || n.attrs.href === '#' + next));
|
|
111
|
+
if (step && step.tap) {
|
|
112
|
+
const t = find(screen, (n) => n.attrs['data-el'] === step.tap);
|
|
113
|
+
if (t) return goes(t) ? t : (find(t, goes) || t);
|
|
114
|
+
}
|
|
115
|
+
return next ? find(screen, goes) : null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ── each need on a press ── */
|
|
119
|
+
const FOCUSABLE = new Set(['button', 'input', 'select', 'textarea', 'summary']);
|
|
120
|
+
function reachable(n) {
|
|
121
|
+
if (n.attrs.tabindex != null && n.attrs.tabindex !== '' && Number(n.attrs.tabindex) < 0) return false;
|
|
122
|
+
if (FOCUSABLE.has(n.tag) && n.attrs.disabled == null) return true;
|
|
123
|
+
if (n.tag === 'a' && n.attrs.href != null) return true;
|
|
124
|
+
return n.attrs.tabindex != null && Number(n.attrs.tabindex) >= 0;
|
|
125
|
+
}
|
|
126
|
+
function nameOf(n, root) {
|
|
127
|
+
if (one(n.attrs['aria-label'], 200)) return one(n.attrs['aria-label'], 200);
|
|
128
|
+
if (n.attrs['aria-labelledby'] && root) {
|
|
129
|
+
const ids = n.attrs['aria-labelledby'].split(/\s+/), words = ids.map((id) => { const t = find(root, (x) => x.attrs.id === id); return t ? textOf(t) : ''; }).join(' ').trim();
|
|
130
|
+
if (words) return one(words, 200);
|
|
131
|
+
}
|
|
132
|
+
const t = textOf(n); if (/[\p{L}\p{N}]/u.test(t)) return one(t, 200);
|
|
133
|
+
if (n.tag === 'input' && one(n.attrs.value, 200)) return one(n.attrs.value, 200);
|
|
134
|
+
const img = n.tag === 'img' ? n : find(n, (x) => x.tag === 'img' && one(x.attrs.alt, 200));
|
|
135
|
+
if (img && one(img.attrs.alt, 200)) return one(img.attrs.alt, 200);
|
|
136
|
+
return one(n.attrs.title, 200);
|
|
137
|
+
}
|
|
138
|
+
const shown = (n) => { const t = textOf(n) || (n.tag === 'input' ? str(n.attrs.value) : ''); return /[\p{L}\p{N}]{2,}/u.test(t); };
|
|
139
|
+
const hasHeading = (screen) => !!find(screen, (n) => /^h[1-6]$/.test(n.tag) || n.attrs.role === 'heading');
|
|
140
|
+
function px(style, prop) { const m = new RegExp('(?:^|;)\\s*(?:min-)?' + prop + '\\s*:\\s*(\\d+(?:\\.\\d+)?)px', 'i').exec(str(style)); return m ? Number(m[1]) : null; }
|
|
141
|
+
function tooSmall(n) {
|
|
142
|
+
const w = px(n.attrs.style, 'width') ?? (/^\d+$/.test(str(n.attrs.width)) ? Number(n.attrs.width) : null);
|
|
143
|
+
const h = px(n.attrs.style, 'height') ?? (/^\d+$/.test(str(n.attrs.height)) ? Number(n.attrs.height) : null);
|
|
144
|
+
return (w != null && w < MIN_PX) || (h != null && h < MIN_PX);
|
|
145
|
+
}
|
|
146
|
+
/** PURE. Why this persona gets stuck on this press, or '' when it gets past. */
|
|
147
|
+
function blockOf(need, press, screen, root, label) {
|
|
148
|
+
if (need === 'keyboard' && !reachable(press)) return `${label} cannot be reached with the keyboard`;
|
|
149
|
+
if (need === 'reader' && !nameOf(press, root)) return `${label} has no name to hear`;
|
|
150
|
+
if (need === 'words' && !shown(press)) return `${label} shows no words, only a symbol`;
|
|
151
|
+
if (need === 'words' && !hasHeading(screen)) return 'no heading says where they are';
|
|
152
|
+
if (need === 'thumb' && tooSmall(press)) return `${label} is smaller than a thumb (${MIN_PX} px)`;
|
|
153
|
+
return '';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* ── the walk ── */
|
|
157
|
+
/** PURE. Each persona walks each scenario of the flow over the version's HTML. → [{ persona, task, done, at?, el?, why? }] */
|
|
158
|
+
function simulate({ html, flow, personas }) {
|
|
159
|
+
const scen = (flow && Array.isArray(flow.scenarios) ? flow.scenarios : []).filter((s) => s && Array.isArray(s.steps) && s.steps.length);
|
|
160
|
+
const who = Array.isArray(personas) ? personas : [];
|
|
161
|
+
if (!scen.length || !who.length) return [];
|
|
162
|
+
const root = parse(html), screens = screensOf(root), titleOf = titlesOf(flow, screens);
|
|
163
|
+
const out = [];
|
|
164
|
+
for (const s of scen) {
|
|
165
|
+
for (const p of who) {
|
|
166
|
+
let stuck = null;
|
|
167
|
+
for (let i = 0; i < s.steps.length && !stuck; i += 1) {
|
|
168
|
+
const step = s.steps[i], next = i + 1 < s.steps.length ? s.steps[i + 1].screen : '';
|
|
169
|
+
const scr = screens.get(step.screen);
|
|
170
|
+
if (!scr) { stuck = { at: step.screen, why: `the screen ${titleOf(step.screen)} is not in the prototype` }; break; }
|
|
171
|
+
if (!next) break;
|
|
172
|
+
const press = pressOf(scr, step, next);
|
|
173
|
+
if (!press) { stuck = { at: step.screen, why: `nothing on it leads on to ${titleOf(next)}` }; break; }
|
|
174
|
+
const label = pressLabel(press, root);
|
|
175
|
+
for (const need of p.needs || []) { const why = blockOf(need, press, scr, root, label); if (why) { stuck = { at: step.screen, el: str(press.attrs['data-el']), why }; break; } }
|
|
176
|
+
}
|
|
177
|
+
out.push(stuck ? { persona: p.id, task: s.id, done: false, ...stuck } : { persona: p.id, task: s.id, done: true });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
function titlesOf(flow, screens) {
|
|
183
|
+
const t = new Map(((flow && flow.screens) || []).map((x) => [x.id, one(x.title, 60)]));
|
|
184
|
+
return (id) => t.get(id) || one(screens && screens.get(id) ? screens.get(id).attrs['data-label'] : '', 60) || id;
|
|
185
|
+
}
|
|
186
|
+
function pressLabel(n, root) {
|
|
187
|
+
const name = one(n.attrs['data-label'], 40) || one(nameOf(n, root), 40);
|
|
188
|
+
return name ? `the ${name} press` : 'the press';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* ── findings, not clicks ── */
|
|
192
|
+
/** PURE. tries → { personas: n, rows } | null. A stuck place is one row ("k of N personas stuck at "<screen>": why"), stuck rows first,
|
|
193
|
+
* the most stuck first; a task every persona finished is one row ("All N finished "<task>""). No tries: null (zero is silence). */
|
|
194
|
+
function findingsOf(tries, { flow, personas } = {}) {
|
|
195
|
+
if (!Array.isArray(tries) || !tries.length) return null;
|
|
196
|
+
const who = new Map((personas || []).map((p) => [p.id, p.name]));
|
|
197
|
+
const N = new Set(tries.map((t) => t.persona)).size;
|
|
198
|
+
const tasks = new Map(((flow && flow.scenarios) || []).map((s) => [s.id, one(s.name || s.id, 60)]));
|
|
199
|
+
const screenTitle = titlesOf(flow, null);
|
|
200
|
+
const stuck = new Map(), byTask = new Map();
|
|
201
|
+
for (const t of tries) {
|
|
202
|
+
if (!byTask.has(t.task)) byTask.set(t.task, []);
|
|
203
|
+
byTask.get(t.task).push(t);
|
|
204
|
+
if (t.done) continue;
|
|
205
|
+
// one row per place they got stuck (a task's screen), with every reason found there
|
|
206
|
+
const k = t.task + '\u0000' + t.at;
|
|
207
|
+
if (!stuck.has(k)) stuck.set(k, { task: t.task, screen: t.at, el: t.el || '', whys: [], who: new Set() });
|
|
208
|
+
const g = stuck.get(k);
|
|
209
|
+
g.who.add(t.persona);
|
|
210
|
+
if (!g.whys.includes(t.why)) g.whys.push(t.why);
|
|
211
|
+
if (!g.el && t.el) g.el = t.el;
|
|
212
|
+
}
|
|
213
|
+
const rows = [];
|
|
214
|
+
for (const g of stuck.values()) {
|
|
215
|
+
const n = g.who.size;
|
|
216
|
+
// "the Pay press cannot …; the Pay press has no name" says the press once: "the Pay press cannot …; has no name"
|
|
217
|
+
const lead = /^(the (?:.+? )?press) /.exec(g.whys[0]), whys = g.whys.map((w, i) => (i && lead && w.startsWith(lead[1] + ' ') ? w.slice(lead[1].length + 1) : w));
|
|
218
|
+
rows.push({ state: 'risk', n, task: g.task, screen: g.screen, ...(g.el ? { el: g.el } : {}),
|
|
219
|
+
text: `${n === N ? (N === 1 ? 'The persona' : `All ${N} personas`) : `${n} of ${N} personas`} stuck at "${screenTitle(g.screen)}": ${whys.join('; ')}`,
|
|
220
|
+
who: [...g.who].map((id) => who.get(id) || id).join(', ') });
|
|
221
|
+
}
|
|
222
|
+
rows.sort((a, b) => b.n - a.n || a.text.localeCompare(b.text));
|
|
223
|
+
for (const [task, ts] of byTask) {
|
|
224
|
+
if (!ts.every((t) => t.done)) continue;
|
|
225
|
+
const first = ((flow && flow.scenarios) || []).find((s) => s.id === task);
|
|
226
|
+
rows.push({ state: 'on', n: ts.length, task, screen: first ? first.steps[0].screen : '', text: `All ${ts.length} finished "${tasks.get(task) || task}"`, who: '' });
|
|
227
|
+
}
|
|
228
|
+
return { personas: N, rows };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* ── personas, from the user's records ── */
|
|
232
|
+
/** PURE. A persona to add: { name, needs: [need] | "a,b", from: the record it comes from }. → { persona } | { error } */
|
|
233
|
+
function validPersona(input) {
|
|
234
|
+
const x = isObj(input) ? input : {};
|
|
235
|
+
const name = one(x.name, 60);
|
|
236
|
+
if (!name) return { error: 'a persona needs a name (--name "<who they are>")' };
|
|
237
|
+
const from = one(x.from, 200);
|
|
238
|
+
if (!from) return { error: 'a persona needs the record it comes from (--from "<file, page or quote>"): PMOS uses the user\'s real records, never made-up people' };
|
|
239
|
+
const needs = [...new Set((Array.isArray(x.needs) ? x.needs : str(x.needs).split(/[\s,]+/)).map((n) => String(n).trim().toLowerCase()).filter(Boolean))];
|
|
240
|
+
const bad = needs.filter((n) => !NEEDS[n]);
|
|
241
|
+
if (bad.length) return { error: `${bad.join(', ')} is not a need. Needs: ${Object.keys(NEEDS).join(', ')}` };
|
|
242
|
+
if (!needs.length) return { error: `a persona needs at least one need (--needs ${Object.keys(NEEDS).join(',')})` };
|
|
243
|
+
const id = slug(x.id || name);
|
|
244
|
+
if (!id) return { error: 'the name needs a letter or a number' };
|
|
245
|
+
return { persona: { id, name, needs, from } };
|
|
246
|
+
}
|
|
247
|
+
/** PURE. The persona lines folded: the newest line for an id wins. walking: the product's own personas, or BASE when none. */
|
|
248
|
+
function personasOf(lines) {
|
|
249
|
+
const by = new Map();
|
|
250
|
+
for (const l of lines || []) {
|
|
251
|
+
if (!isObj(l) || l.kind !== 'persona' || !str(l.id)) continue;
|
|
252
|
+
const prev = by.get(l.id) || {};
|
|
253
|
+
if (l.op === 'add' && isObj(l.persona)) by.set(l.id, { persona: l.persona, on: true, at: l.at });
|
|
254
|
+
else if (l.op === 'remove' && prev.persona) by.set(l.id, { ...prev, on: false, at: l.at });
|
|
255
|
+
else if (l.op === 'restore' && prev.persona) by.set(l.id, { ...prev, on: true, at: l.at });
|
|
256
|
+
}
|
|
257
|
+
const mine = [...by.values()].filter((x) => x.on).map((x) => x.persona).slice(0, MAX_PERSONAS);
|
|
258
|
+
const removed = [...by.values()].filter((x) => !x.on).map((x) => x.persona);
|
|
259
|
+
return { mine, removed, walking: mine.length ? mine : BASE.slice(), base: !mine.length };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* ── the store ── */
|
|
263
|
+
const fileOf = (dir) => path.join(dir, FILE);
|
|
264
|
+
function read(dir) {
|
|
265
|
+
if (!dir) return [];
|
|
266
|
+
let text = ''; try { text = fs.readFileSync(fileOf(dir), 'utf8'); } catch { return []; }
|
|
267
|
+
const out = [];
|
|
268
|
+
for (const l of text.split('\n')) { if (!l.trim()) continue; try { const j = JSON.parse(l); if (isObj(j)) out.push(j); } catch { /* a torn line */ } }
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
function append(dir, line) { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(fileOf(dir), JSON.stringify(line) + '\n'); }
|
|
272
|
+
function addPersona(dir, input, { by = 'agent:cli', now = Date.now() } = {}) {
|
|
273
|
+
if (!dir) return { ok: false, error: 'This repository has no PMOS state folder.' };
|
|
274
|
+
const v = validPersona(input); if (v.error) return { ok: false, error: v.error };
|
|
275
|
+
const P = personasOf(read(dir));
|
|
276
|
+
if (!P.mine.some((p) => p.id === v.persona.id) && P.mine.length >= MAX_PERSONAS) return { ok: false, error: `at most ${MAX_PERSONAS} personas walk a prototype: remove one first` };
|
|
277
|
+
append(dir, { at: new Date(now).toISOString(), kind: 'persona', op: 'add', id: v.persona.id, persona: v.persona, by });
|
|
278
|
+
return { ok: true, persona: v.persona };
|
|
279
|
+
}
|
|
280
|
+
function turn(op) {
|
|
281
|
+
return (dir, id, { by = 'agent:cli', now = Date.now() } = {}) => {
|
|
282
|
+
if (!dir) return { ok: false, error: 'This repository has no PMOS state folder.' };
|
|
283
|
+
const P = personasOf(read(dir)), list = op === 'remove' ? P.mine : P.removed, p = list.find((x) => x.id === String(id));
|
|
284
|
+
if (!p) return { ok: false, error: op === 'remove' ? `no persona ${id} walks now (pmos prototype personas lists them)` : `no removed persona ${id}` };
|
|
285
|
+
append(dir, { at: new Date(now).toISOString(), kind: 'persona', op, id: p.id, by });
|
|
286
|
+
return { ok: true, persona: p, undo: op === 'remove' ? `pmos prototype persona restore ${p.id}` : `pmos prototype persona remove ${p.id}` };
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const removePersona = turn('remove');
|
|
290
|
+
const restorePersona = turn('restore');
|
|
291
|
+
|
|
292
|
+
/** The findings of one prototype version: the stored run when the version and the persona set are the same, else a new run (stored).
|
|
293
|
+
* Reads the version's HTML; writes only to the state folder, never to the version's folder or the proposals ledger. */
|
|
294
|
+
function forVersion(dir, { ini, file, abs, flow }, { now = Date.now() } = {}) {
|
|
295
|
+
if (!abs || !flow || !Array.isArray(flow.scenarios) || !flow.scenarios.length) return null;
|
|
296
|
+
let html = ''; try { html = fs.readFileSync(abs, 'utf8'); } catch { return null; }
|
|
297
|
+
const lines = read(dir), P = personasOf(lines);
|
|
298
|
+
const sig = hash(JSON.stringify([html, flow.scenarios, flow.screens, P.walking]));
|
|
299
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) { const l = lines[i]; if (l.kind === 'run' && l.file === file && l.sig === sig) return l.findings; }
|
|
300
|
+
const findings = findingsOf(simulate({ html, flow, personas: P.walking }), { flow, personas: P.walking });
|
|
301
|
+
if (dir) {
|
|
302
|
+
try { append(dir, { at: new Date(now).toISOString(), kind: 'run', log: LOG, ini: one(ini, 80), file: one(file, 300), sig, personas: P.walking.map((p) => p.id), findings }); }
|
|
303
|
+
catch (e) { console.warn(LOG, 'not stored:', e.message); }
|
|
304
|
+
}
|
|
305
|
+
return findings;
|
|
306
|
+
}
|
|
307
|
+
/** The runs in the last days (the health number). */
|
|
308
|
+
function count(dir, { days = 7, now = Date.now() } = {}) {
|
|
309
|
+
const since = now - Math.max(1, Number(days) || 7) * 864e5;
|
|
310
|
+
return read(dir).filter((l) => l.kind === 'run' && l.log === LOG && Date.parse(l.at) >= since).length;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
module.exports = { FILE, LOG, NEEDS, BASE, MIN_PX, MAX_PERSONAS, parse, screensOf, pressOf, simulate, findingsOf, validPersona, personasOf, read, addPersona, removePersona, restorePersona, forVersion, count };
|
|
314
|
+
|
|
315
|
+
if (require.main === module) {
|
|
316
|
+
// node lib/sim-users.js count [--days 7] [--dir <state folder>]: the health number on the last line
|
|
317
|
+
const a = process.argv.slice(2), at = (k) => { const i = a.indexOf('--' + k); return i >= 0 ? a[i + 1] : undefined; };
|
|
318
|
+
if (a[0] !== 'count') { console.error('usage: node lib/sim-users.js count [--days 7] [--dir <state folder>]'); process.exit(2); }
|
|
319
|
+
let dir = at('dir');
|
|
320
|
+
// the product's state folder (pmos/state or .pmos, as the server's stateDirFor finds it), from here up; else the per-user folder
|
|
321
|
+
for (let d = process.cwd(); !dir; ) {
|
|
322
|
+
for (const rel of ['pmos/state', '.pmos']) if (!dir && fs.existsSync(path.join(d, rel, FILE))) dir = path.join(d, rel);
|
|
323
|
+
const up = path.dirname(d); if (up === d) break; d = up;
|
|
324
|
+
}
|
|
325
|
+
if (!dir) { try { dir = require('./state-root.js').defaultRoot({ env: process.env }); } catch { dir = ''; } }
|
|
326
|
+
const n = count(dir, { days: at('days') });
|
|
327
|
+
console.log(`${LOG} ${n} simulated-user run${n === 1 ? '' : 's'} on prototype versions in the last ${Number(at('days')) || 7} days`);
|
|
328
|
+
console.log(String(n));
|
|
329
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* skill-map.js — the team skill map: what each person is strong at and often corrected on, and one pairing (bet A208, initiative skill-map;
|
|
3
|
+
* board BatchPeopleDS panel 11, agreed 2026-11-25). THE CORE of `pmos team skills` (lib/team-cli.js), GET/POST /api/team/skills
|
|
4
|
+
* (lib/routes-skill-map.js) and the Team skills block on Work (public/pm/skill-map.js).
|
|
5
|
+
*
|
|
6
|
+
* WHERE IT READS. Only records the product already holds, from the last WINDOW_DAYS days:
|
|
7
|
+
* approves an answered sign-off (lib/signoffs.js): a strong signal for its approver, of the kind its `what` names
|
|
8
|
+
* corrects a journal decision's `against` that starts with a name ("Ana: the dates are wrong"): a strong signal for Ana
|
|
9
|
+
* decides a journal decision whose text starts with a name ("Sam: launch on 9 Dec") or whose `by` is `pm:<slug>`: strong for the decider,
|
|
10
|
+
* unless a later decision replaced it or its outcome check said didnt-work: then a CORRECTED signal for the decider
|
|
11
|
+
* A decision an agent recorded (`by: agent:…`) with no name in its text counts for nobody. A decision logged by a press (`from`) is the PM
|
|
12
|
+
* approving a PMOS proposal, not a team decision, and counts for nobody. The kind comes from lib/correction-kinds.js's word lists; a text
|
|
13
|
+
* that matches none (`other`) is dropped.
|
|
14
|
+
*
|
|
15
|
+
* WHAT IT SHOWS. Per person: `strong` (kinds with MIN_SIGNALS or more strong signals and more strong than corrected) and `corrected` (kinds
|
|
16
|
+
* with MIN_SIGNALS or more corrected signals). A person with neither has no row (zero is silence). Rows are sorted by name: no score, no
|
|
17
|
+
* count and no rank ever leaves this module's view (the counts stay inside fold()).
|
|
18
|
+
* ONE pairing at a time: a person often corrected on a kind with a person strong at it, "Pair A with B on the next <kind> change.". A skip
|
|
19
|
+
* (✕) is one line in skill-map.jsonl in the records folder; the next pairing shows. Undo is a second line; the last line per key wins.
|
|
20
|
+
*
|
|
21
|
+
* WHO SEES IT. The person and their lead. The workspace's own user is the lead and sees every row. `as` (a person's own view) keeps only
|
|
22
|
+
* that person's row and a pairing that names nobody else (so in practice none). It is never in a report or a published page:
|
|
23
|
+
* FOR_REPORTS is false, and the route refuses a published read.
|
|
24
|
+
*
|
|
25
|
+
* signalsOf(root, { now }) → [{ who, kind, strong: bool, source }]
|
|
26
|
+
* fold(signals) → [{ who, strong: [kind], corrected: [kind], n: { strong: {kind: n}, corrected: {kind: n} } }] internal
|
|
27
|
+
* pairsOf(people) → [{ key, a, b, kind, text }] every pairing, in the order they are offered
|
|
28
|
+
* view(root, { now, as, dir }) → { ok, people: [{ who, strong, corrected }], pair, window_days, for_reports: false }
|
|
29
|
+
* act(dir, act, key, { by, now }) → { ok, line } | { ok: false, error } act ∈ skip · undo
|
|
30
|
+
* lines(v) → [string] the CLI's words
|
|
31
|
+
* CLI: node lib/skill-map.js count <root> prints `[skill-map] …` and the people with a row, alone on the last line (the health number)
|
|
32
|
+
*
|
|
33
|
+
* Works on any product built with PMOS, in either layout. Nothing is sent anywhere.
|
|
34
|
+
*/
|
|
35
|
+
const fs = require('fs');
|
|
36
|
+
const path = require('path');
|
|
37
|
+
|
|
38
|
+
const WINDOW_DAYS = 90;
|
|
39
|
+
const MIN_SIGNALS = 2;
|
|
40
|
+
const FILE = 'skill-map.jsonl';
|
|
41
|
+
const TAG = '[skill-map]';
|
|
42
|
+
const FOR_REPORTS = false;
|
|
43
|
+
const ACTS = ['skip', 'undo'];
|
|
44
|
+
const DAY = 864e5;
|
|
45
|
+
const one = (s, n = 300) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
46
|
+
|
|
47
|
+
const CK = () => require('./correction-kinds.js');
|
|
48
|
+
const AM = () => require('./approver-memory.js');
|
|
49
|
+
|
|
50
|
+
/** A kind's word in the map: the correction-kinds label, lower case ("dates", "scope", "wording"). */
|
|
51
|
+
function kindWord(kind) {
|
|
52
|
+
const k = CK().KINDS.find((x) => x.id === kind);
|
|
53
|
+
return k ? k.label.toLowerCase() : '';
|
|
54
|
+
}
|
|
55
|
+
function kindOf(text) { const k = CK().kindOf(text); return k === 'other' ? null : k; }
|
|
56
|
+
|
|
57
|
+
const cap = (s) => s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
|
|
58
|
+
/** The person behind a `by`: `pm:<slug>` → "Slug"; anything else (an agent) → null. */
|
|
59
|
+
function personOfBy(by) {
|
|
60
|
+
const m = /^pm:([a-z0-9_-]{1,40})$/i.exec(String(by || ''));
|
|
61
|
+
return m ? cap(m[1].replace(/[-_]+/g, ' ')) : null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function signoffsOf(root) {
|
|
65
|
+
try { const SO = require('./signoffs.js'); const JT = require('./jira-tickets.js'); return SO.list(SO.fileOf(JT.stateDirOf(root))); } catch { return []; }
|
|
66
|
+
}
|
|
67
|
+
function journalOf(root, today) {
|
|
68
|
+
try { const J = require('./decision-journal.js'); return J.fold(J.read(root).rows, { today }); } catch { return []; }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Every signal in the window, oldest first. */
|
|
72
|
+
function signalsOf(root, { now = Date.now(), signoffs, journal } = {}) {
|
|
73
|
+
const today = new Date(now).toISOString().slice(0, 10);
|
|
74
|
+
const since = new Date(now - WINDOW_DAYS * DAY).toISOString().slice(0, 10);
|
|
75
|
+
const inWindow = (d) => { const s = String(d || '').slice(0, 10); return s >= since && s <= today; };
|
|
76
|
+
const out = [];
|
|
77
|
+
const push = (who, text, strong, source, date) => {
|
|
78
|
+
const kind = kindOf(text);
|
|
79
|
+
if (!who || !kind || !inWindow(date)) return;
|
|
80
|
+
out.push({ who: one(who, 80), kind, strong, source, date: String(date).slice(0, 10) });
|
|
81
|
+
};
|
|
82
|
+
for (const s of signoffs || (root ? signoffsOf(path.resolve(root)) : [])) {
|
|
83
|
+
if (!s || !s.who || s.state !== 'answered') continue;
|
|
84
|
+
push(s.who, s.what, true, 'sign-off ' + (s.id || ''), s.answeredAt || s.asked || s.at);
|
|
85
|
+
}
|
|
86
|
+
const W = AM();
|
|
87
|
+
for (const e of journal || (root ? journalOf(path.resolve(root), today) : [])) {
|
|
88
|
+
if (!e || e.from) continue; // a press-logged line is the PM approving a PMOS proposal
|
|
89
|
+
const date = e.date || String(e.at || '').slice(0, 10);
|
|
90
|
+
const obj = e.against ? W.whoOf(e.against) : null;
|
|
91
|
+
if (obj) push(obj.who, obj.text + ' ' + (e.decided || ''), true, 'decision ' + e.id, date);
|
|
92
|
+
const named = W.whoOf(e.decided);
|
|
93
|
+
const who = named ? named.who : personOfBy(e.by);
|
|
94
|
+
if (!who) continue;
|
|
95
|
+
const text = named ? named.text : e.decided;
|
|
96
|
+
const wrong = !!e.replacedBy || e.state === 'replaced' || !!(e.verdict && e.verdict.verdict === 'didnt-work');
|
|
97
|
+
push(who, text, !wrong, 'decision ' + e.id, date);
|
|
98
|
+
}
|
|
99
|
+
return out.sort((a, b) => a.date.localeCompare(b.date));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** One entry per person (names that are the same person merge), with the counts kept inside. */
|
|
103
|
+
function fold(signals) {
|
|
104
|
+
const W = AM();
|
|
105
|
+
const people = [];
|
|
106
|
+
for (const s of signals || []) {
|
|
107
|
+
let p = people.find((x) => W.same(x.who, s.who));
|
|
108
|
+
if (!p) { p = { who: s.who, n: { strong: {}, corrected: {} } }; people.push(p); }
|
|
109
|
+
if (s.who.length > p.who.length) p.who = s.who;
|
|
110
|
+
const side = s.strong ? p.n.strong : p.n.corrected;
|
|
111
|
+
side[s.kind] = (side[s.kind] || 0) + 1;
|
|
112
|
+
}
|
|
113
|
+
const kinds = CK().IDS;
|
|
114
|
+
for (const p of people) {
|
|
115
|
+
p.strong = kinds.filter((k) => (p.n.strong[k] || 0) >= MIN_SIGNALS && (p.n.strong[k] || 0) > (p.n.corrected[k] || 0));
|
|
116
|
+
p.corrected = kinds.filter((k) => (p.n.corrected[k] || 0) >= MIN_SIGNALS);
|
|
117
|
+
}
|
|
118
|
+
return people.filter((p) => p.strong.length || p.corrected.length).sort((a, b) => a.who.localeCompare(b.who));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const keyOf = (a, b, kind) => [a, b, kind].map((x) => one(x, 80).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')).join(':');
|
|
122
|
+
|
|
123
|
+
/** Every pairing, the most-corrected person first, then the strongest partner, then by name. */
|
|
124
|
+
function pairsOf(people) {
|
|
125
|
+
const out = [];
|
|
126
|
+
for (const a of people || []) {
|
|
127
|
+
for (const kind of a.corrected) {
|
|
128
|
+
for (const b of people) {
|
|
129
|
+
if (b === a || !b.strong.includes(kind)) continue;
|
|
130
|
+
out.push({ key: keyOf(a.who, b.who, kind), a: a.who, b: b.who, kind, text: `Pair ${a.who} with ${b.who} on the next ${kindWord(kind).replace(/s$/, '')} change.`,
|
|
131
|
+
_w: [-(a.n.corrected[kind] || 0), -(b.n.strong[kind] || 0)] });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
out.sort((x, y) => x._w[0] - y._w[0] || x._w[1] - y._w[1] || x.a.localeCompare(y.a) || x.b.localeCompare(y.b) || x.kind.localeCompare(y.kind));
|
|
136
|
+
return out.map(({ _w, ...p }) => p);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function recordsDirOf(root) {
|
|
140
|
+
try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
|
|
141
|
+
}
|
|
142
|
+
function readLines(dir) {
|
|
143
|
+
let text = '';
|
|
144
|
+
try { text = fs.readFileSync(path.join(dir, FILE), 'utf8'); } catch { return []; }
|
|
145
|
+
const out = [];
|
|
146
|
+
for (const l of text.split('\n')) { if (!l.trim()) continue; try { const o = JSON.parse(l); if (o && ACTS.includes(o.act) && typeof o.key === 'string') out.push(o); } catch { /* torn */ } }
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
/** The keys skipped now: the last line per key wins. */
|
|
150
|
+
function skipped(dir) {
|
|
151
|
+
const last = new Map();
|
|
152
|
+
for (const l of readLines(dir)) last.set(l.key, l.act);
|
|
153
|
+
return new Set([...last].filter(([, a]) => a === 'skip').map(([k]) => k));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function act(dir, what, key, { by = 'pm', now = Date.now() } = {}) {
|
|
157
|
+
if (!ACTS.includes(what)) return { ok: false, error: `act must be one of ${ACTS.join(', ')}` };
|
|
158
|
+
if (typeof key !== 'string' || !/^[a-z0-9-]{1,80}:[a-z0-9-]{1,80}:[a-z]{1,20}$/.test(key)) return { ok: false, error: 'an unknown pairing' };
|
|
159
|
+
if (!dir) return { ok: false, error: 'this product has no records folder' };
|
|
160
|
+
const line = { act: what, key, at: new Date(now).toISOString(), by: one(by, 60) };
|
|
161
|
+
try { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(path.join(dir, FILE), JSON.stringify(line) + '\n'); } catch (e) { return { ok: false, error: 'not saved: ' + e.message }; }
|
|
162
|
+
return { ok: true, line };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The map as the page and the CLI show it: names and kind words only, no number. */
|
|
166
|
+
function view(root, { now = Date.now(), as = null, dir = null, signoffs, journal, log = null } = {}) {
|
|
167
|
+
const people = fold(signalsOf(root, { now, signoffs, journal }));
|
|
168
|
+
const W = AM();
|
|
169
|
+
const skips = skipped(dir || (root ? recordsDirOf(path.resolve(root)) : null));
|
|
170
|
+
let pairs = pairsOf(people).filter((p) => !skips.has(p.key));
|
|
171
|
+
let rows = people;
|
|
172
|
+
if (as) {
|
|
173
|
+
rows = people.filter((p) => W.same(p.who, as));
|
|
174
|
+
pairs = pairs.filter((p) => W.same(p.a, as) && W.same(p.b, as)); // a person's own view never names someone else
|
|
175
|
+
}
|
|
176
|
+
const pub = rows.map((p) => ({ who: p.who, strong: p.strong.map(kindWord), corrected: p.corrected.map(kindWord) }));
|
|
177
|
+
const pair = pairs[0] || null;
|
|
178
|
+
if (log) log(`${TAG} ${pub.length} people · ${pair ? 'a pairing' : 'no pairing'}${as ? ' · own view' : ''}`);
|
|
179
|
+
return { ok: true, people: pub, pair, window_days: WINDOW_DAYS, for_reports: FOR_REPORTS };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function lines(v) {
|
|
183
|
+
if (!v || !v.people || !v.people.length) return ['No one has a kind of decision to show yet (last 90 days of sign-offs and decisions).'];
|
|
184
|
+
const out = v.people.map((p) => `${p.who} · strong at: ${p.strong.join(', ') || '—'} · often corrected on: ${p.corrected.join(', ') || '—'}`);
|
|
185
|
+
if (v.pair) out.push(`✦ ${v.pair.text} (skip: pmos team skills skip ${v.pair.key})`);
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function count(root, { now = Date.now() } = {}) { return view(root, { now }).people.length; }
|
|
190
|
+
|
|
191
|
+
module.exports = { WINDOW_DAYS, MIN_SIGNALS, FILE, TAG, FOR_REPORTS, ACTS, kindWord, personOfBy, signalsOf, fold, pairsOf, keyOf, readLines, skipped, act, view, lines, count, recordsDirOf };
|
|
192
|
+
|
|
193
|
+
if (require.main === module) {
|
|
194
|
+
const a = process.argv.slice(2);
|
|
195
|
+
if (a[0] !== 'count') { console.error('usage: node lib/skill-map.js count <root>'); process.exit(2); }
|
|
196
|
+
const n = count(path.resolve(a[1] || '.'));
|
|
197
|
+
console.log(`${TAG} ${n} people have a row on the team skill map (last ${WINDOW_DAYS} days)`);
|
|
198
|
+
console.log(String(n));
|
|
199
|
+
}
|
|
@@ -28,7 +28,7 @@ const path = require('path');
|
|
|
28
28
|
const ledgers = require('./plan-ledgers.js');
|
|
29
29
|
|
|
30
30
|
const LEDGER = 'initiative-tasks.jsonl';
|
|
31
|
-
const TASK_KINDS = Object.freeze(['task', 'task-update', 'task-remove', 'task-restore', 'task-section', 'task-milestone', 'task-pin', 'task-order', 'task-parent', 'task-priority', 'task-description', 'task-comment']);
|
|
31
|
+
const TASK_KINDS = Object.freeze(['task', 'task-update', 'task-remove', 'task-restore', 'task-section', 'task-milestone', 'task-pin', 'task-order', 'task-parent', 'task-priority', 'task-time', 'task-description', 'task-comment']);
|
|
32
32
|
const KINDS = new Set(TASK_KINDS);
|
|
33
33
|
const isTaskKind = (k) => KINDS.has(k);
|
|
34
34
|
const isTaskLine = (r) => !!r && typeof r === 'object' && !Array.isArray(r) && isTaskKind(r.kind);
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* pmos team status [--json] who works on what, what waits, and the inbox entries of ended dispatches
|
|
8
8
|
* pmos team pause|resume <role|all> stop or restart a role's runs (a running run ends on its own)
|
|
9
9
|
* pmos team dispatch --unit <unit> [--roles a,b] · pmos team pause|resume --unit <unit> the same for a whole unit (chief-unit-owners ✦3)
|
|
10
|
+
* pmos team skills [--as <name>] [--json] the team skill map: strong at, often corrected on, one pairing (bet A208)
|
|
11
|
+
* pmos team skills skip|undo <pairing key> skip the ✦ pairing for the next one, or bring it back
|
|
10
12
|
* common: [--root <dir>]
|
|
11
13
|
*
|
|
12
14
|
* INSIDE A ROLE RUN only (the server pins PMOS_TEAM_RUN, _ROLE, _FILE, _ROOT, _INI, _MODE; nothing here takes them as arguments):
|
|
@@ -21,7 +23,7 @@ const { execFileSync } = require('child_process');
|
|
|
21
23
|
const T = require('./agent-team.js');
|
|
22
24
|
const R = require('./team-runs.js');
|
|
23
25
|
|
|
24
|
-
const COMMANDS = { team: ['roles', 'dispatch', 'status', 'pause', 'resume', 'wrote', 'done', 'verdict'] };
|
|
26
|
+
const COMMANDS = { team: ['roles', 'dispatch', 'status', 'pause', 'resume', 'wrote', 'done', 'verdict', 'skills'] };
|
|
25
27
|
const USAGE = [
|
|
26
28
|
'usage: pmos team roles|dispatch|status|pause|resume — the role agents under the chief of staff',
|
|
27
29
|
' pmos team roles what each role owns, what wakes it, its action class and daily budget',
|
|
@@ -30,6 +32,8 @@ const USAGE = [
|
|
|
30
32
|
' pmos team status who works on what, what waits, and the inbox entries of ended dispatches',
|
|
31
33
|
' pmos team pause|resume <role|all> stop or restart a role\'s runs',
|
|
32
34
|
' pmos team dispatch --unit <unit> · pmos team pause|resume --unit <unit> the same for a whole program, product or project (pmos units)',
|
|
35
|
+
' pmos team skills [--as <name>] the team skill map (last 90 days): strong at, often corrected on, one ✦ pairing',
|
|
36
|
+
' pmos team skills skip|undo <key> skip the ✦ pairing for the next one, or bring it back',
|
|
33
37
|
'Inside a role run: pmos team wrote <path> · pmos team done "<summary>" [--propose <path> "<what>"] · pmos team verdict <path> pass|fail "<why>"',
|
|
34
38
|
'every command: [--json] [--root <dir>]',
|
|
35
39
|
];
|
|
@@ -69,6 +73,21 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
69
73
|
const root = inRun ? (env.PMOS_TEAM_ROOT || repoRoot(cwd)) : (flags.root ? path.resolve(cwd, flags.root) : repoRoot(cwd));
|
|
70
74
|
const dir = inRun && env.PMOS_TEAM_FILE ? path.dirname(env.PMOS_TEAM_FILE) : require('./driver.js').stateDirOf(root, { create: ['dispatch', 'pause', 'resume'].includes(verb) });
|
|
71
75
|
|
|
76
|
+
if (verb === 'skills') { // bet A208: the team skill map (lib/skill-map.js), the same view the Work block reads
|
|
77
|
+
if (inRun) return fail('a role run cannot read the team skill map; it is for the person and their lead');
|
|
78
|
+
const SM = require('./skill-map.js');
|
|
79
|
+
const sub = pos[0];
|
|
80
|
+
if (sub === 'skip' || sub === 'undo') {
|
|
81
|
+
const r = SM.act(SM.recordsDirOf(root), sub, pos[1], { by: 'cli', now });
|
|
82
|
+
return r.ok ? ok({ line: r.line }, sub === 'skip' ? '✓ pairing skipped; the next one shows (undo: pmos team skills undo ' + pos[1] + ')' : '✓ pairing back') : fail(r.error);
|
|
83
|
+
}
|
|
84
|
+
if (sub) return fail(`unknown skills command "${sub}" — skip or undo`, 2);
|
|
85
|
+
const v = SM.view(root, { now, as: flags.as || null });
|
|
86
|
+
console.error(`${SM.TAG} ${v.people.length} people · ${v.pair ? 'a pairing' : 'no pairing'}${flags.as ? ' · own view' : ''}`);
|
|
87
|
+
if (json) return ok({ people: v.people, pair: v.pair, window_days: v.window_days, for_reports: v.for_reports });
|
|
88
|
+
for (const l of SM.lines(v)) say(l);
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
72
91
|
if (verb === 'roles') {
|
|
73
92
|
const t = T.tableForPage();
|
|
74
93
|
// launch simulation W3: say whether the Builder can run here, from the files on disk (lib/work-kind.js factoryRuns)
|