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,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* page-one-answer.js — the one-call check of "every page opens with one answer" (initiative page-one-answer, job #1889, idea A308).
|
|
3
|
+
*
|
|
4
|
+
* Each page (Today, Work, Board, an initiative) counts the calls to act in its first view once per load (pm/page-one-answer.js
|
|
5
|
+
* firstViewCalls: a primary button or a [data-call] above the fold) and posts the count here. LOCAL ONLY: one line per page and day in
|
|
6
|
+
* <runtime>/page-calls.jsonl, the last count of the day wins. Nothing else reads it but `pmos pages calls`.
|
|
7
|
+
*
|
|
8
|
+
* record(dir, { page, calls, labels }, at) → { ok, wrote } | { ok: false, error }
|
|
9
|
+
* readLines(dir) → [{ at, page, calls, labels }]
|
|
10
|
+
* flagged(lines, { now, days }) PURE → [{ page, calls, labels, at }] pages whose last first view had more than ONE call
|
|
11
|
+
* handle(req, res, url, ctx) POST /api/page-calls { page, calls, labels } (the page's own press guard)
|
|
12
|
+
* run(argv, { say, runtimeDir, now }) `pmos pages calls [--days N] [--json] [--count]`
|
|
13
|
+
* No line here sends anything or calls a model. */
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
|
|
17
|
+
const FILE = 'page-calls.jsonl';
|
|
18
|
+
const PAGES = ['today', 'work', 'board', 'initiative'];
|
|
19
|
+
const MAX_CALLS = 1;
|
|
20
|
+
const DAY = 864e5;
|
|
21
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
22
|
+
|
|
23
|
+
function readLines(dir) {
|
|
24
|
+
if (!dir) return [];
|
|
25
|
+
let txt = '';
|
|
26
|
+
try { txt = fs.readFileSync(path.join(dir, FILE), 'utf8'); } catch { return []; }
|
|
27
|
+
const out = [];
|
|
28
|
+
for (const l of txt.split('\n')) { if (!l.trim()) continue; try { const o = JSON.parse(l); if (isObj(o) && PAGES.includes(o.page)) out.push(o); } catch { /* a torn line is skipped */ } }
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function record(dir, { page, calls, labels } = {}, at = new Date().toISOString()) {
|
|
33
|
+
if (!dir) return { ok: false, error: 'This workspace has no runtime folder.' };
|
|
34
|
+
if (!PAGES.includes(page)) return { ok: false, error: 'page must be one of ' + PAGES.join(', ') };
|
|
35
|
+
const n = Number(calls);
|
|
36
|
+
if (!Number.isInteger(n) || n < 0 || n > 200) return { ok: false, error: 'calls must be a whole number from 0 to 200' };
|
|
37
|
+
const L = (Array.isArray(labels) ? labels : []).slice(0, 10).map((s) => String(s || '').replace(/\s+/g, ' ').slice(0, 60));
|
|
38
|
+
const day = String(at).slice(0, 10);
|
|
39
|
+
const same = readLines(dir).filter((x) => x.page === page && String(x.at).slice(0, 10) === day).pop();
|
|
40
|
+
if (same && same.calls === n && JSON.stringify(same.labels || []) === JSON.stringify(L)) return { ok: true, wrote: false };
|
|
41
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
42
|
+
fs.appendFileSync(path.join(dir, FILE), JSON.stringify({ at, page, calls: n, labels: L }) + '\n');
|
|
43
|
+
return { ok: true, wrote: true };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** PURE. The last line of each page in the window; a page is flagged when that line counted more than one call. */
|
|
47
|
+
function flagged(lines, { now = Date.now(), days = 7 } = {}) {
|
|
48
|
+
const from = now - days * DAY, last = new Map();
|
|
49
|
+
for (const x of lines || []) { const t = Date.parse(x.at); if (!(t >= from)) continue; const p = last.get(x.page); if (!p || Date.parse(p.at) <= t) last.set(x.page, x); }
|
|
50
|
+
return [...last.values()].filter((x) => x.calls > MAX_CALLS).sort((a, b) => b.calls - a.calls || a.page.localeCompare(b.page))
|
|
51
|
+
.map((x) => ({ page: x.page, calls: x.calls, labels: x.labels || [], at: x.at }));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function handle(req, res, url, ctx) {
|
|
55
|
+
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
56
|
+
if (url.pathname !== '/api/page-calls') return false;
|
|
57
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'POST only' });
|
|
58
|
+
if (req.headers && req.headers['x-pmos-session']) return send(403, { ok: false, error: 'An agent session does not open pages. Only the PM\'s own first views are counted.' });
|
|
59
|
+
const read = await ctx.readJson(req);
|
|
60
|
+
if (!read.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
61
|
+
const body = read.body || {};
|
|
62
|
+
const g = require('./pm-guard.js').requirePagePress(req, body);
|
|
63
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
64
|
+
const r = record(ctx.runtimeDir || null, body, new Date().toISOString());
|
|
65
|
+
if (r.ok && r.wrote) console.info(`[page-one-answer] recorded page=${body.page} calls=${body.calls}`);
|
|
66
|
+
return r.ok ? send(200, { ok: true, wrote: r.wrote }) : send(400, { ok: false, error: r.error });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function run(argv, { say = (s) => console.log(s), runtimeDir = null, now = Date.now() } = {}) {
|
|
70
|
+
const a = argv.slice(argv[0] === 'pages' ? 1 : 0).filter((x) => x !== 'calls');
|
|
71
|
+
const flag = (k) => a.includes('--' + k);
|
|
72
|
+
const di = a.indexOf('--days'), days = di >= 0 ? Number(a[di + 1]) : 7;
|
|
73
|
+
if (!(days > 0 && days <= 90)) { say('✗ --days takes a number from 1 to 90'); return 2; }
|
|
74
|
+
let dir = runtimeDir;
|
|
75
|
+
if (!dir) { try { dir = require('./state-root.js').defaultRoot(); } catch { dir = null; } }
|
|
76
|
+
const lines = readLines(dir), F = flagged(lines, { now, days });
|
|
77
|
+
if (flag('json')) { say(JSON.stringify({ days, pages: F }, null, 2)); return 0; }
|
|
78
|
+
if (flag('count')) { say(String(F.length)); return 0; }
|
|
79
|
+
if (!lines.length) { say('No page has counted its first view yet. Open Today, Work, Board or an initiative and run this again.'); return 0; }
|
|
80
|
+
if (!F.length) { say(`Every page counted in the last ${days} days opens with one call to act or none.`); return 0; }
|
|
81
|
+
for (const x of F) say(`● ${x.page}: ${x.calls} calls to act in the first view (${x.labels.filter(Boolean).join(', ') || 'no labels'}), ${String(x.at).slice(0, 10)}`);
|
|
82
|
+
say('A first view should hold one call to act at most. Fold the others under the answer.');
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { FILE, PAGES, MAX_CALLS, record, readLines, flagged, handle, prefixes: ['/api/page-calls'], run };
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* pmos pages [show] [--ref <ref>] [--json] [--count]
|
|
6
6
|
* pmos pages check --base <ref> [--ref <ref>|WORKTREE] [--feature] [--gate] [--json]
|
|
7
|
+
* pmos pages calls [--days N] [--json] [--count] (lib/page-one-answer.js: the pages whose first view had more than one call to act)
|
|
7
8
|
* It reads git only and writes nothing. Exit codes: 0 done, 1 refused (or a finding with --gate), 2 usage.
|
|
8
9
|
*/
|
|
9
10
|
const path = require('path');
|
|
10
11
|
const H = require('./page-health.js');
|
|
11
12
|
const D = require('./design-drift.js');
|
|
12
13
|
|
|
13
|
-
const COMMANDS = { pages: ['show', 'check'] };
|
|
14
|
+
const COMMANDS = { pages: ['show', 'check', 'calls'] };
|
|
14
15
|
const USAGE = [
|
|
15
16
|
'usage: pmos pages — each page\'s fixes, reverts and restores in the last days, so a page that keeps breaking is fixed before it gets new features',
|
|
16
17
|
' pmos pages [show] [--ref <ref>] [--json] [--count]',
|
|
@@ -19,7 +20,9 @@ const USAGE = [
|
|
|
19
20
|
' --base <ref> the commit the change starts from (for example origin/main)',
|
|
20
21
|
' --feature treat the change as a feature even without a feat commit',
|
|
21
22
|
' --gate exit 1 when a feature change touches a page over the limit',
|
|
22
|
-
'
|
|
23
|
+
' pmos pages calls [--days N] [--json] [--count]',
|
|
24
|
+
' names each page (Today, Work, Board, an initiative) whose first view had more than one call to act, from this computer\'s record',
|
|
25
|
+
'show and check read git only. A product sets window_days and limit in page-health.json in its design-system folder; its pages come from design-drift.json.',
|
|
23
26
|
];
|
|
24
27
|
const FLAGS = { show: ['ref', 'json', 'count', 'repo'], check: ['base', 'ref', 'feature', 'gate', 'json', 'repo'] };
|
|
25
28
|
const BOOL = new Set(['json', 'count', 'feature', 'gate']);
|
|
@@ -43,6 +46,7 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Dat
|
|
|
43
46
|
if (['help', '--help', '-h'].includes(args[0])) { for (const l of USAGE) say(l); return 0; }
|
|
44
47
|
const sub = args[0] && !args[0].startsWith('--') ? args[0] : 'show';
|
|
45
48
|
if (args[0] === sub) args = args.slice(1);
|
|
49
|
+
if (sub === 'calls') return require('./page-one-answer.js').run(['calls', ...args], { say, now }); // page-one-answer (A308)
|
|
46
50
|
if (!COMMANDS.pages.includes(sub)) { say(`unknown pages command "${sub}". Use one of: ${COMMANDS.pages.join(', ')}`); return 2; }
|
|
47
51
|
const { pos, flags } = parse(args);
|
|
48
52
|
if (pos.length) { say(`✗ pmos pages ${sub} takes no argument`); return 2; }
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* pmos people settings [--json] whether calendar attendee names are kept
|
|
9
9
|
* pmos people map <initiative> [--json] who decides, must agree, needs to know, and when each last heard (A371)
|
|
10
10
|
* pmos people keep|drop|told|undo <initiative> <person> [--group decides|agree|know] the PM's word on one name (lib/stakeholder-map.js)
|
|
11
|
+
* pmos people prep <person> [--days N] [--json] a 1:1 brief from the tasks they own (lib/people-prep.js, idea A85)
|
|
11
12
|
*
|
|
12
13
|
* The same module the People place reads (lib/people-store.js), so a terminal line and the page cannot disagree.
|
|
13
14
|
* `list` and `show` first record the names this repository's records hold (plan item owners, Live notes speakers), as
|
|
@@ -22,7 +23,7 @@ const path = require('path');
|
|
|
22
23
|
const store = require('./people-store');
|
|
23
24
|
const { parseArgs } = require('./schedule-cli');
|
|
24
25
|
|
|
25
|
-
const COMMANDS = { people: ['list', 'show', 'record', 'settings', 'map', 'keep', 'drop', 'told', 'undo'] };
|
|
26
|
+
const COMMANDS = { people: ['list', 'show', 'record', 'settings', 'map', 'keep', 'drop', 'told', 'undo', 'prep'] };
|
|
26
27
|
const USAGE = [
|
|
27
28
|
'usage: pmos people [list|show|record|settings] — the people you work with in this repository',
|
|
28
29
|
' pmos people [list] [--json] each person, and what waits for you in the review list',
|
|
@@ -32,6 +33,7 @@ const USAGE = [
|
|
|
32
33
|
' pmos people map <initiative> [--json] who decides, who must agree, who needs to know, and when each last heard from you',
|
|
33
34
|
' pmos people keep <initiative> <person> [--group decides|agree|know] keep a name on the map (in that group)',
|
|
34
35
|
' pmos people drop|told|undo <initiative> <person> take a name off, mark that you sent them an update, or take back the last of these',
|
|
36
|
+
' pmos people prep <person> [--days N] [--json] a 1:1 brief: what they shipped, where they are stuck, one thing to recognise',
|
|
35
37
|
'Nothing here removes a person, merges, sets a tone or writes a note. Do that in People. PMOS never sends an update: you do.',
|
|
36
38
|
];
|
|
37
39
|
const BOOL = new Set(['json', 'help']);
|
|
@@ -64,6 +66,12 @@ const toneWord = (t) => (t.confirmed ? t.confirmed : t.proposed ? `${t.proposed}
|
|
|
64
66
|
const handleText = (h) => `${h.kind} ${h.value}`;
|
|
65
67
|
|
|
66
68
|
async function run(argv, { say = console.log, cwd = process.cwd(), env = process.env, now = Date.now() } = {}) {
|
|
69
|
+
// a 1:1 brief reads only the tasks (lib/people-prep.js): its own options, before the people store is scanned
|
|
70
|
+
if (argv[1] === 'prep') {
|
|
71
|
+
const rest = argv.slice(2), r = rest.indexOf('--root');
|
|
72
|
+
const root = r >= 0 && rest[r + 1] ? path.resolve(cwd, rest[r + 1]) : repoRoot(cwd);
|
|
73
|
+
return require('./people-prep.js').run(r >= 0 ? rest.filter((_, i) => i !== r && i !== r + 1) : rest, { say, root, env, now });
|
|
74
|
+
}
|
|
67
75
|
const { pos, flags } = parse(argv.slice(1));
|
|
68
76
|
const sub = pos[0] || 'list';
|
|
69
77
|
if (flags.help || sub === 'help') { USAGE.forEach((l) => say(l)); return 0; }
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* people-prep.js — a 1:1 brief for one person, from the tasks they own (idea A85, factory job #1997, initiative people-prep).
|
|
3
|
+
*
|
|
4
|
+
* prepOf(tasks, who, { today, days }) PURE → { who, owners, shipped, stuck, recognise, days }
|
|
5
|
+
* linesOf(p) PURE → the brief as lines, each with its source
|
|
6
|
+
* matchOf(owners, who) PURE → the owner names that are this person
|
|
7
|
+
* tasksAll(root, stateDir) → every task of the repository: the Board's tasks and the breakdown items, read the way
|
|
8
|
+
* `pmos task list` reads them (lib/routes-boards.js foldOf, lib/task-items.js rowsOf)
|
|
9
|
+
* run(argv, o) → `pmos people prep <person> [--days N] [--json]` (lib/people-cli.js routes it here)
|
|
10
|
+
*
|
|
11
|
+
* THE THREE PARTS. Shipped: their tasks that went to Done in the last `days` days, by the day the state changed, newest first. Stuck:
|
|
12
|
+
* their open tasks (To do, In progress) past the due day, or marked blocked; each says which. Recognise: one Done task of those days,
|
|
13
|
+
* the newest that landed on or before its due day, else the newest Done. Nothing Done, no recognition: nothing is made up.
|
|
14
|
+
* Every line names its source: the task id and its initiative.
|
|
15
|
+
*
|
|
16
|
+
* WHO. An owner matches when its name, with case and a `person:` prefix ignored, is the name asked for. A one-word name also matches a
|
|
17
|
+
* first name, but only when exactly one owner has that first name, so "Dan" never picks up Dana's tasks and "Sam" asks which Sam.
|
|
18
|
+
*
|
|
19
|
+
* READS ONLY. The task ledger and the plan items are read, never written. The one write is a local use-log line (control peoplePrep, the
|
|
20
|
+
* health number), in the runtime folder outside every repository. */
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
const TAG = '[people-prep]';
|
|
24
|
+
const DAYS = 14;
|
|
25
|
+
const DONE = 'Done';
|
|
26
|
+
const OPEN = new Set(['To do', 'In progress']);
|
|
27
|
+
const DAY = 86400000;
|
|
28
|
+
|
|
29
|
+
const nameOf = (o) => String(o == null ? '' : o).replace(/^person:/i, '').replace(/\s+/g, ' ').trim();
|
|
30
|
+
const low = (s) => nameOf(s).toLowerCase().replace(/[-_]+/g, ' '); // a People id (dana-lee) reads as the name
|
|
31
|
+
const dayOf = (v) => { const s = String(v || '').slice(0, 10); return /^\d{4}-\d{2}-\d{2}$/.test(s) ? s : ''; };
|
|
32
|
+
const daysBetween = (a, b) => Math.round((Date.parse(b + 'T00:00:00Z') - Date.parse(a + 'T00:00:00Z')) / DAY);
|
|
33
|
+
|
|
34
|
+
/** The owner names that are this person. PURE. */
|
|
35
|
+
function matchOf(owners, who) {
|
|
36
|
+
const q = low(who);
|
|
37
|
+
if (!q) return [];
|
|
38
|
+
const all = [...new Set((owners || []).map(nameOf).filter(Boolean))];
|
|
39
|
+
const exact = all.filter((o) => low(o) === q);
|
|
40
|
+
if (exact.length || q.includes(' ')) return exact;
|
|
41
|
+
const first = all.filter((o) => low(o).split(' ')[0] === q);
|
|
42
|
+
const people = new Set(first.map(low));
|
|
43
|
+
return people.size === 1 ? first : [];
|
|
44
|
+
}
|
|
45
|
+
/** Several owners share that first name: who they are, so the brief can ask which one. PURE. */
|
|
46
|
+
function ambiguousOf(owners, who) {
|
|
47
|
+
const q = low(who);
|
|
48
|
+
if (!q || q.includes(' ')) return [];
|
|
49
|
+
const first = [...new Set((owners || []).map(nameOf).filter((o) => low(o).split(' ')[0] === q && low(o) !== q))];
|
|
50
|
+
return first.length > 1 ? first.sort() : [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const src = (t) => 'task ' + t.id + (t.initiative ? ' on ' + t.initiative : '');
|
|
54
|
+
|
|
55
|
+
/** The brief. tasks: [{ id, title, state, owner, due, since, blocked, initiative }]. PURE. */
|
|
56
|
+
function prepOf(tasks, who, { today, days = DAYS } = {}) {
|
|
57
|
+
const t0 = dayOf(today) || new Date().toISOString().slice(0, 10);
|
|
58
|
+
const list = Array.isArray(tasks) ? tasks.filter((t) => t && t.id && t.title) : [];
|
|
59
|
+
const owners = matchOf(list.map((t) => t.owner), who);
|
|
60
|
+
const mine = new Set(owners.map(low));
|
|
61
|
+
const own = list.filter((t) => mine.has(low(t.owner)));
|
|
62
|
+
const from = new Date(Date.parse(t0 + 'T00:00:00Z') - days * DAY).toISOString().slice(0, 10);
|
|
63
|
+
const shipped = own.filter((t) => t.state === DONE && dayOf(t.since) && dayOf(t.since) >= from && dayOf(t.since) <= t0)
|
|
64
|
+
.sort((a, b) => dayOf(b.since).localeCompare(dayOf(a.since)) || String(a.id).localeCompare(String(b.id)))
|
|
65
|
+
.map((t) => ({ id: t.id, title: t.title, initiative: t.initiative || '', on: dayOf(t.since), due: dayOf(t.due), source: src(t) }));
|
|
66
|
+
const stuck = own.filter((t) => OPEN.has(t.state) && (t.blocked || (dayOf(t.due) && dayOf(t.due) < t0)))
|
|
67
|
+
.map((t) => {
|
|
68
|
+
const late = dayOf(t.due) && dayOf(t.due) < t0 ? daysBetween(dayOf(t.due), t0) : 0;
|
|
69
|
+
const why = [late ? late + (late === 1 ? ' day late' : ' days late') : '', t.blocked ? 'blocked' + (t.reason ? ': ' + String(t.reason).slice(0, 120) : '') : ''].filter(Boolean).join(', ');
|
|
70
|
+
return { id: t.id, title: t.title, initiative: t.initiative || '', state: t.state, late, blocked: !!t.blocked, why, source: src(t) };
|
|
71
|
+
})
|
|
72
|
+
.sort((a, b) => b.late - a.late || String(a.id).localeCompare(String(b.id)));
|
|
73
|
+
const onTime = shipped.filter((s) => s.due && s.on <= s.due);
|
|
74
|
+
const pick = onTime[0] || shipped[0] || null;
|
|
75
|
+
const recognise = pick ? { ...pick, why: pick.due && pick.on <= pick.due ? (pick.on < pick.due ? 'landed ' + daysBetween(pick.on, pick.due) + (daysBetween(pick.on, pick.due) === 1 ? ' day' : ' days') + ' before its due day' : 'landed on its due day') : 'the newest one Done' } : null;
|
|
76
|
+
return { who: nameOf(who), owners, ambiguous: owners.length ? [] : ambiguousOf(list.map((t) => t.owner), who), days, today: t0, shipped, stuck, recognise };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The brief as lines. PURE. */
|
|
80
|
+
function linesOf(p) {
|
|
81
|
+
const name = p.owners[0] || p.who;
|
|
82
|
+
if (!p.owners.length) {
|
|
83
|
+
if (p.ambiguous && p.ambiguous.length) return [`More than one person is called ${p.who}: ${p.ambiguous.join(', ')}. Name one in full.`];
|
|
84
|
+
return [`No task names ${p.who} as its owner, so there is nothing to prepare from the tasks. pmos people show ${p.who} lists what else PMOS knows.`];
|
|
85
|
+
}
|
|
86
|
+
const out = [`1:1 with ${name} · the last ${p.days} days`];
|
|
87
|
+
out.push(p.shipped.length ? `Shipped (${p.shipped.length}):` : `Shipped: nothing Done in the last ${p.days} days.`);
|
|
88
|
+
for (const s of p.shipped) out.push(` ${s.on} ${s.title} — ${s.source}`);
|
|
89
|
+
out.push(p.stuck.length ? `Stuck (${p.stuck.length}):` : 'Stuck: no open task is late or blocked.');
|
|
90
|
+
for (const s of p.stuck) out.push(` ${s.title} · ${s.why} — ${s.source}`);
|
|
91
|
+
if (p.recognise) out.push(`Recognise: ${p.recognise.title}, ${p.recognise.why} — ${p.recognise.source}`);
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Every task of the repository, read the way `pmos task list` reads them. */
|
|
96
|
+
function tasksAll(root, stateDir) {
|
|
97
|
+
const SR = require('./stage-read.js');
|
|
98
|
+
const { w, ctx } = SR.cliCtx(root, stateDir);
|
|
99
|
+
const out = [];
|
|
100
|
+
try {
|
|
101
|
+
const F = require('./routes-boards.js').foldOf(ctx, w);
|
|
102
|
+
for (const t of (F.tasks || new Map()).values()) {
|
|
103
|
+
if (!t || t.kind === 'Epic') continue;
|
|
104
|
+
out.push({ id: t.id, title: t.title, state: t.state, owner: t.owner || '', due: t.due || '', since: t.since || '', blocked: false, initiative: t.initiative || '' });
|
|
105
|
+
}
|
|
106
|
+
} catch { /* no board ledger: the breakdown items alone */ }
|
|
107
|
+
try {
|
|
108
|
+
for (const x of require('./task-items.js').rowsOf(root, { has: () => true }, null)) {
|
|
109
|
+
out.push({ id: x.uid, title: x.title, state: x.status, owner: x.owner || '', due: x.end || '', since: x.since || '', blocked: !!x.blocked, reason: x.reason || '', initiative: x.ini || '' });
|
|
110
|
+
}
|
|
111
|
+
} catch { /* no plan items */ }
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const USAGE = 'usage: pmos people prep <person> [--days N] [--json] a 1:1 brief: what they shipped, where they are stuck, one thing to recognise';
|
|
116
|
+
|
|
117
|
+
/** `pmos people prep <person> [--days N] [--json]`. argv: the words after `prep`. → exit code */
|
|
118
|
+
function run(argv, { say = console.log, root, stateDir, today, env = process.env, now = Date.now(), useDir } = {}) {
|
|
119
|
+
const pos = [], flags = {};
|
|
120
|
+
for (let i = 0; i < argv.length; i++) {
|
|
121
|
+
const a = argv[i];
|
|
122
|
+
if (a === '--json') flags.json = true;
|
|
123
|
+
else if (a === '--days') flags.days = argv[++i];
|
|
124
|
+
else if (a.startsWith('--')) { say(`✗ --${a.slice(2)} is not an option of pmos people prep`); return 2; }
|
|
125
|
+
else pos.push(a);
|
|
126
|
+
}
|
|
127
|
+
const who = pos.join(' ').trim();
|
|
128
|
+
if (!who) { say(USAGE); return 2; }
|
|
129
|
+
const days = flags.days === undefined ? DAYS : Number(flags.days);
|
|
130
|
+
if (!Number.isInteger(days) || days < 1 || days > 90) { say('✗ --days is a whole number from 1 to 90'); return 2; }
|
|
131
|
+
const dir = stateDir === undefined ? require('./driver.js').stateDirOf(root) : stateDir;
|
|
132
|
+
const p = prepOf(tasksAll(root, dir), who, { today: today || new Date(now).toISOString().slice(0, 10), days });
|
|
133
|
+
try { console.error(`${TAG} ${p.owners.length ? 'prepared' : 'no owner'}: ${p.shipped.length} shipped, ${p.stuck.length} stuck`); } catch { /* no console */ }
|
|
134
|
+
try { require('./use-log.js').record(useDir || require('./state-root.js').defaultRoot({ env }), [{ kind: 'use', page: 'people', control: 'peoplePrep', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
|
|
135
|
+
if (flags.json) { say(JSON.stringify({ ok: true, ...p })); return 0; }
|
|
136
|
+
for (const l of linesOf(p)) say(l);
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = { TAG, DAYS, prepOf, linesOf, matchOf, ambiguousOf, tasksAll, run, USAGE };
|
|
@@ -157,15 +157,22 @@ const VERBS = Object.freeze({
|
|
|
157
157
|
// Not a pm-os-absorb verb (run: null): initiative three-line-why (bet A86) added it through the same table.
|
|
158
158
|
why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
|
|
159
159
|
help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
|
|
160
|
+
// Not a pm-os-absorb verb (run: null): initiative tradeoff-cards (job #1918, A325) added it through the same table.
|
|
161
|
+
tradeoff: Object.freeze({ module: 'tradeoff-cli.js', run: null, guide: 'cli.md',
|
|
162
|
+
help: 'pmos tradeoff [list|show|keep|undo|count] — two close items on the Roadmap side by side, and the reason you kept one first (pmos tradeoff help)' }),
|
|
160
163
|
// Not a pm-os-absorb verb (run: null): initiative next-hire-draft (job #1876, A75) added it through the same table.
|
|
161
164
|
// Not a pm-os-absorb verb (run: null): initiative starter-goals (job #1916, A84) added it through the same table.
|
|
162
165
|
goals: Object.freeze({ module: 'goals-cli.js', run: null, guide: 'cli.md',
|
|
163
166
|
help: 'pmos goals [starter|draft|keep <n>|drop <n>|undo] — starter goals PMOS drafts from your own product, each with its source; keep one and it becomes a goal (pmos goals help)' }),
|
|
164
167
|
hire: Object.freeze({ module: 'hire-draft.js', run: null, guide: 'cli.md',
|
|
165
168
|
help: 'pmos hire [draft|show|count] — the role your open work most needs, per person, and a one-page role brief PMOS drafts for you to edit (pmos hire help)' }),
|
|
169
|
+
prototype: Object.freeze({ module: 'prototype-cli.js', run: null, guide: 'cli.md',
|
|
170
|
+
help: 'pmos prototype findings|personas|persona … — where simulated users (one per persona) got stuck on a prototype, never a score, and the personas that walk it (pmos prototype help)' }),
|
|
166
171
|
// Not a pm-os-absorb verb (run: null): initiative connector-data (job #1920, A150) added it through the same table.
|
|
167
172
|
connectors: Object.freeze({ module: 'connectors-cli.js', run: null, guide: 'cli.md',
|
|
168
173
|
help: 'pmos connectors data [<connector>] — what PMOS reads and writes through each connector, and what leaves this computer (pmos connectors help)' }),
|
|
174
|
+
print: Object.freeze({ module: 'print-cli.js', run: null, guide: 'cli.md',
|
|
175
|
+
help: 'pmos print <file.md|initiative id> [--out file.html] — one clean page to print or save as PDF (pmos print help)' }),
|
|
169
176
|
// Not a pm-os-absorb verb (run: null): initiative press-release-faq (bet A362) added it through the same table.
|
|
170
177
|
'press-release': Object.freeze({ module: 'press-release-cli.js', run: null, guide: 'cli.md',
|
|
171
178
|
help: 'pmos press-release <initiative> | count — a one-page press release and FAQ for a bet, drafted from its record, for you to edit (pmos press-release help)' }),
|
|
@@ -202,6 +209,9 @@ const VERBS = Object.freeze({
|
|
|
202
209
|
// Not a pm-os-absorb verb (run: null): initiative parked-reason-way-back (bet A446) added it through the same table.
|
|
203
210
|
parked: Object.freeze({ module: 'parked-cli.js', run: null, guide: 'cli.md',
|
|
204
211
|
help: 'pmos parked list|hold|back|coverage — parked initiatives: why each is parked, what brings it back, and bringing it back (pmos parked help)' }),
|
|
212
|
+
// Not a pm-os-absorb verb (run: null): initiative team-waits (bet A364) added it through the same table.
|
|
213
|
+
deps: Object.freeze({ module: 'deps-cli.js', run: null, guide: 'cli.md',
|
|
214
|
+
help: 'pmos deps waits|wait|done|undo — what your work waits on outside the team, oldest first (Work › Dependencies; pmos deps help)' }),
|
|
205
215
|
// Not a pm-os-absorb verb (run: null): initiative quiet-work-sweep (bet A503) added it through the same table.
|
|
206
216
|
quiet: Object.freeze({ module: 'quiet-cli.js', run: null, guide: 'cli.md',
|
|
207
217
|
help: 'pmos quiet list|keep|park|close|undo — the weekly sweep of initiatives quiet 30 days or more: keep, park or close each (pmos quiet help)' }),
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* print-cli.js — `pmos print` (initiative print-pdf, job #1911, idea A379). The page comes from lib/print-pdf.js printFile: the same layout
|
|
3
|
+
* as Print or PDF in the workspace. One .html file is written; the PM opens it and chooses Save as PDF. Nothing is sent. */
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { TAG, brandOf, fileOf, printFile } = require('./print-pdf.js');
|
|
7
|
+
|
|
8
|
+
const COMMANDS = { print: ['brand'] };
|
|
9
|
+
const USAGE = [
|
|
10
|
+
'usage: pmos print <file.md | initiative id> [--out <file.html>] — one clean page to print or save as PDF',
|
|
11
|
+
' pmos print <initiative id> the initiative\'s record as a print page: title, date and page N of M on every page',
|
|
12
|
+
' pmos print <file.md> --out x.html any report or document of the product; default <name>.print.html here',
|
|
13
|
+
' pmos print brand the brand printed at the top right (the product\'s own design system), or none',
|
|
14
|
+
'Open the page and choose Save as PDF. Nothing is sent.',
|
|
15
|
+
];
|
|
16
|
+
function repoOf(cwd) {
|
|
17
|
+
let d = path.resolve(cwd);
|
|
18
|
+
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; }
|
|
19
|
+
}
|
|
20
|
+
function used(o) {
|
|
21
|
+
try { const dir = o.stateDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }); require('./use-log.js').record(dir, [{ kind: 'use', page: 'today', control: 'print-pdf', device: 'desk' }], o.now || Date.now()); } catch { /* a count, never a reason to fail */ }
|
|
22
|
+
}
|
|
23
|
+
async function run(argv, o = {}) {
|
|
24
|
+
const say = o.say || ((s) => console.log(s));
|
|
25
|
+
const args = argv[0] === 'print' ? argv.slice(1) : argv.slice();
|
|
26
|
+
const pos = [], flags = {};
|
|
27
|
+
for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root' || a === '--out' || a === '--date') flags[a.slice(2)] = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
|
|
28
|
+
const cmd = pos[0] || 'help';
|
|
29
|
+
if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return pos[0] ? 0 : 2; }
|
|
30
|
+
const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
|
|
31
|
+
if (cmd === 'brand') {
|
|
32
|
+
const b = brandOf(root);
|
|
33
|
+
if (flags.json) { say(JSON.stringify({ ok: true, brand: b })); return 0; }
|
|
34
|
+
say(b ? `Printed pages show the brand ${b}.` : 'No brand: this product has no design system of its own, so printed pages show none.');
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
const file = fileOf(root, cmd);
|
|
38
|
+
const r = await printFile(root, file, { date: flags.date });
|
|
39
|
+
if (!r.ok) { say('✗ ' + r.error); return 1; }
|
|
40
|
+
const out = path.resolve(o.cwd || process.cwd(), flags.out || path.basename(file).replace(/\.md$/i, '') + '.print.html');
|
|
41
|
+
fs.writeFileSync(out, r.html);
|
|
42
|
+
used(o);
|
|
43
|
+
console.log(`${TAG} printed ${path.relative(root, file)} out=${path.basename(out)}`);
|
|
44
|
+
if (flags.json) { say(JSON.stringify({ ok: true, title: r.title, out })); return 0; }
|
|
45
|
+
say(`✓ Wrote ${out}: "${r.title}". Open it and choose Save as PDF.`);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* print-pdf.js — Print or PDF, the Node side (initiative print-pdf, job #1911, idea A379; board BatchMoreADS panel 26). The layout itself is
|
|
3
|
+
* public/pm/print-pdf.js (layoutHtml, cleanHtml), loaded here with import(), so the terminal, the page and a report sent as a copy print
|
|
4
|
+
* the same page.
|
|
5
|
+
*
|
|
6
|
+
* brandOf(root) → the product's own design system brand name (its design-system/brand/tokens.json `name`, idea A1), or '' when
|
|
7
|
+
* the product has none or only PMOS's own. Read only.
|
|
8
|
+
* sectionsHtml(md) PURE → { title, sections: [{ h, html }] } from a markdown file (lib/report-export.js parseReport, sectionsOf)
|
|
9
|
+
* printFile(root, rel, { date }) → Promise { ok, title, html } | { ok: false, error } a file inside the product only
|
|
10
|
+
* fileOf(root, what) → the file `pmos print` prints: a path, or an initiative id (planning/initiatives/<id>.md, a kit's
|
|
11
|
+
* pmos/planning/initiatives or pmos/state/initiatives)
|
|
12
|
+
*
|
|
13
|
+
* THE ROUTE (lib/routes-report-design.js owns the prefix and hands it here): GET /api/print?ws=<id> → { ok, brand }. Read only; nothing is written or sent.
|
|
14
|
+
*
|
|
15
|
+
* THE COMMAND (lib/print-cli.js): pmos print <file.md | initiative id> [--out <file.html>] [--json] · pmos print brand. It writes one .html file (default
|
|
16
|
+
* <name>.print.html in the current folder); the PM opens it and chooses Save as PDF. A file outside the product is refused (exit 1) and
|
|
17
|
+
* nothing is written. Each print logs one `[print-pdf]` line and one use-log line (control print-pdf), the count the kill reads. */
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const { pathToFileURL } = require('url');
|
|
21
|
+
|
|
22
|
+
const TAG = '[print-pdf]';
|
|
23
|
+
const PAGE_JS = path.join(__dirname, '..', 'public', 'pm', 'print-pdf.js');
|
|
24
|
+
let page = null;
|
|
25
|
+
const layout = () => (page = page || import(pathToFileURL(PAGE_JS).href));
|
|
26
|
+
|
|
27
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
28
|
+
const inline = (s) => esc(s).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>');
|
|
29
|
+
|
|
30
|
+
/* ── the brand ── */
|
|
31
|
+
function brandOf(root) {
|
|
32
|
+
if (!root) return '';
|
|
33
|
+
let DS; try { DS = require('./design-system.js'); } catch { return ''; }
|
|
34
|
+
const own = path.resolve(DS.OWN);
|
|
35
|
+
for (const p of DS.PLACES || []) {
|
|
36
|
+
const d = path.join(root, p);
|
|
37
|
+
if (path.resolve(d) === own) continue;
|
|
38
|
+
try { const j = JSON.parse(fs.readFileSync(path.join(d, 'brand', 'tokens.json'), 'utf8')); const n = String((j && j.name) || '').trim(); if (n && n !== 'PMOS Brand') return n.slice(0, 80); } catch { /* no brand there */ }
|
|
39
|
+
}
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* ── markdown to sections ── */
|
|
44
|
+
function blockHtml(blocks) {
|
|
45
|
+
let out = '', list = false;
|
|
46
|
+
for (const b of blocks) {
|
|
47
|
+
if (b.t !== 'li' && list) { out += '</ul>'; list = false; }
|
|
48
|
+
if (b.t === 'li') { if (!list) { out += '<ul>'; list = true; } out += `<li>${inline(b.text)}</li>`; }
|
|
49
|
+
else if (b.t === 'h') out += `<h3>${inline(b.text)}</h3>`;
|
|
50
|
+
else if (b.t === 'p') out += `<p>${inline(b.text)}</p>`;
|
|
51
|
+
else if (b.t === 'table') out += `<table>${b.rows.map((r, i) => `<tr>${r.map((c) => (i ? `<td>${inline(c)}</td>` : `<th>${inline(c)}</th>`)).join('')}</tr>`).join('')}</table>`;
|
|
52
|
+
}
|
|
53
|
+
return out + (list ? '</ul>' : '');
|
|
54
|
+
}
|
|
55
|
+
function sectionsHtml(md) {
|
|
56
|
+
const RE = require('./report-export.js');
|
|
57
|
+
const rep = RE.parseReport(md);
|
|
58
|
+
return { title: rep.title, sections: RE.sectionsOf(rep).map((s) => ({ h: s.heading === rep.title ? '' : s.heading, html: blockHtml(s.blocks) })) };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const inside = (root, abs) => { const r = path.relative(path.resolve(root), abs); return !!r && !r.startsWith('..') && !path.isAbsolute(r); };
|
|
62
|
+
|
|
63
|
+
function fileOf(root, what) {
|
|
64
|
+
const w = String(what || '').trim();
|
|
65
|
+
if (!w) return null;
|
|
66
|
+
if (/^[a-z0-9][a-z0-9-]{0,80}$/.test(w) && !/\.md$/.test(w)) {
|
|
67
|
+
for (const d of ['planning/initiatives', 'pmos/planning/initiatives', 'pmos/state/initiatives']) {
|
|
68
|
+
const f = path.join(root, d, w + '.md');
|
|
69
|
+
if (fs.existsSync(f)) return f;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return path.resolve(root, w);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function printFile(root, file, { date = '' } = {}) {
|
|
76
|
+
const abs = path.resolve(root, file);
|
|
77
|
+
if (!inside(root, abs)) return { ok: false, error: 'That file is outside this product. PMOS prints only the product\'s own files.' };
|
|
78
|
+
let md;
|
|
79
|
+
try { md = fs.readFileSync(abs, 'utf8'); } catch { return { ok: false, error: 'No such file: ' + path.relative(root, abs) }; }
|
|
80
|
+
const { title, sections } = sectionsHtml(md);
|
|
81
|
+
const L = await layout();
|
|
82
|
+
return { ok: true, title, html: L.layoutHtml({ title, date: date || L.dateLine(), brand: brandOf(root), sections }) };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ── the route ── */
|
|
86
|
+
const prefixes = ['/api/print'];
|
|
87
|
+
async function handle(req, res, url, ctx) {
|
|
88
|
+
if (url.pathname !== '/api/print') return false;
|
|
89
|
+
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
90
|
+
let w = null;
|
|
91
|
+
try { w = ctx.getWs ? ctx.getWs(url.searchParams.get('ws') || null) : null; } catch { w = null; }
|
|
92
|
+
ctx.json(res, { ok: true, brand: w && w.root ? brandOf(w.root) : '' });
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = { TAG, brandOf, sectionsHtml, fileOf, printFile, prefixes, handle };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* prototype-cli.js — `pmos prototype`: what simulated users found on a prototype, and the personas that walk it (initiative sim-users,
|
|
3
|
+
* idea A20). The store is the one the Viewer reads (lib/sim-users.js, through the running server's /api/sim-users routes, lib/routes-sim-users.js),
|
|
4
|
+
* so what the chat writes here shows in the Viewer's Findings at once.
|
|
5
|
+
*
|
|
6
|
+
* pmos prototype findings <initiative> [--ws <id>] [--json] the findings of the initiative's prototype now
|
|
7
|
+
* pmos prototype personas [--ws <id>] the personas that walk each prototype (the base four when none is recorded)
|
|
8
|
+
* pmos prototype persona add --name "<who>" --needs <need,…> --from "<the record it comes from>" [--ws <id>]
|
|
9
|
+
* pmos prototype persona remove <id> [--ws <id>] it prints the Undo
|
|
10
|
+
* pmos prototype persona restore <id> [--ws <id>]
|
|
11
|
+
*
|
|
12
|
+
* A finding is a hint for the grilling, never a score. Nothing is sent and no model is called. Exit codes: 0 done, 1 refused, 2 usage. */
|
|
13
|
+
const SU = require('./sim-users.js');
|
|
14
|
+
|
|
15
|
+
const COMMANDS = { prototype: ['findings', 'personas', 'persona'] };
|
|
16
|
+
const USAGE = [
|
|
17
|
+
'usage: pmos prototype findings|personas|persona — simulated users try the prototype before it reaches you; you see findings, never a score',
|
|
18
|
+
' pmos prototype findings <initiative> [--ws <id>] [--json] where the simulated users got stuck on its prototype now, and how many',
|
|
19
|
+
' pmos prototype personas [--ws <id>] the personas that walk each prototype',
|
|
20
|
+
` pmos prototype persona add --name "<who>" --needs <${Object.keys(SU.NEEDS).join('|')},…> --from "<the record it comes from>" [--ws <id>]`,
|
|
21
|
+
' pmos prototype persona remove <id> [--ws <id>] stop one walking (it prints the Undo)',
|
|
22
|
+
' pmos prototype persona restore <id> [--ws <id>] bring it back',
|
|
23
|
+
'With no persona recorded, four base personas walk: New user, Keyboard only, Screen reader, On a phone. Nothing is sent.',
|
|
24
|
+
];
|
|
25
|
+
const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
|
|
26
|
+
const NO_SERVER = '✗ no PMOS server answers: start PMOS, then ask again';
|
|
27
|
+
const needsOf = (p) => (p.needs || []).map((n) => SU.NEEDS[n] || n).join(', ');
|
|
28
|
+
|
|
29
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, call } = {}) {
|
|
30
|
+
const args = argv[0] === 'prototype' ? argv.slice(1) : argv.slice();
|
|
31
|
+
const verb = args[0];
|
|
32
|
+
if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
|
|
33
|
+
if (!COMMANDS.prototype.includes(verb)) { say(`unknown prototype command "${verb}" — one of ${COMMANDS.prototype.join(', ')}`); return 2; }
|
|
34
|
+
if (typeof call !== 'function') { say(NO_SERVER); return 1; }
|
|
35
|
+
const ws = flag(args, 'ws'), wsQ = typeof ws === 'string' ? '&ws=' + encodeURIComponent(ws) : '';
|
|
36
|
+
const get = async (q) => { try { return await call('GET', q); } catch { return null; } };
|
|
37
|
+
|
|
38
|
+
if (verb === 'findings') {
|
|
39
|
+
const ini = args[1] && !args[1].startsWith('--') ? args[1] : '';
|
|
40
|
+
if (!ini) { say('usage: pmos prototype findings <initiative> [--ws <id>] [--json]'); return 2; }
|
|
41
|
+
const r = await get('/api/sim-users/findings?initiative=' + encodeURIComponent(ini) + wsQ);
|
|
42
|
+
if (!r) { say(NO_SERVER); return 1; }
|
|
43
|
+
if (!r.ok) { say('✗ ' + (r.error || 'no findings')); return 1; }
|
|
44
|
+
if (flag(args, 'json')) { say(JSON.stringify({ ok: true, file: r.file, version: r.version, findings: r.findings, personas: (r.personas || []).map((p) => p.id), base: r.base })); return 0; }
|
|
45
|
+
if (!r.file) { say(`${ini} has no prototype yet.`); return 0; }
|
|
46
|
+
if (!r.findings || !(r.findings.rows || []).length) { say(`Version ${r.version || 1} of ${ini} has no key tasks in its flow, so no simulated user walked it.`); return 0; }
|
|
47
|
+
say(`Version ${r.version || 1} of ${ini}, walked by ${r.findings.personas} simulated users${r.base ? ' (the base personas)' : ''}:`);
|
|
48
|
+
for (const x of r.findings.rows) say(`${x.state === 'risk' ? '◐' : '○'} ${x.text}${x.who ? ` (${x.who})` : ''}${x.screen ? ` · screen ${x.screen}` : ''}`);
|
|
49
|
+
say('A finding is a hint for your grilling, never a score.');
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (verb === 'personas') {
|
|
54
|
+
const r = await get('/api/sim-users/personas?' + wsQ.slice(1));
|
|
55
|
+
if (!r) { say(NO_SERVER); return 1; }
|
|
56
|
+
if (!r.ok) { say('✗ ' + (r.error || 'no personas')); return 1; }
|
|
57
|
+
say(r.base ? 'No persona is recorded for this product, so the four base personas walk each prototype:' : 'The personas that walk each prototype:');
|
|
58
|
+
for (const p of r.personas || []) say(`- ${p.name} [${p.id}]: ${needsOf(p)}${p.from ? ` · from ${p.from}` : ''}`);
|
|
59
|
+
if (r.base) say('Add your own from your records: pmos prototype persona add --name "<who>" --needs <need,…> --from "<record>"');
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// persona add | remove | restore
|
|
64
|
+
const sub = args[1];
|
|
65
|
+
if (!['add', 'remove', 'restore'].includes(sub)) { say('usage: pmos prototype persona add|remove|restore … (pmos prototype help)'); return 2; }
|
|
66
|
+
let by = ''; try { by = require('./actor.js').fromCli({ env }).by || ''; } catch { by = ''; }
|
|
67
|
+
const body = { op: sub, ...(typeof ws === 'string' ? { ws } : {}), ...(by ? { by } : {}) };
|
|
68
|
+
if (sub === 'add') {
|
|
69
|
+
for (const k of ['name', 'needs', 'from']) { const v = flag(args, k); if (typeof v === 'string') body[k] = v; }
|
|
70
|
+
// refuse here first, so a persona with no record never reaches the store (the server refuses it too)
|
|
71
|
+
const v = SU.validPersona(body); if (v.error) { say('✗ ' + v.error); return 1; }
|
|
72
|
+
} else {
|
|
73
|
+
const id = args[2] && !args[2].startsWith('--') ? args[2] : '';
|
|
74
|
+
if (!id) { say(`usage: pmos prototype persona ${sub} <id> [--ws <id>]`); return 2; }
|
|
75
|
+
body.id = id;
|
|
76
|
+
}
|
|
77
|
+
let r = null; try { r = await call('POST', '/api/sim-users/personas', body); } catch { r = null; }
|
|
78
|
+
if (!r) { say(NO_SERVER); return 1; }
|
|
79
|
+
if (!r.ok) { say('✗ ' + (r.error || 'nothing changed')); return 1; }
|
|
80
|
+
if (sub === 'add') say(`✓ ${r.persona.name} walks each prototype from now on (${needsOf(r.persona)}).`);
|
|
81
|
+
else if (sub === 'remove') say(`✓ ${r.persona.name} no longer walks. Undo: ${r.undo}${typeof ws === 'string' ? ' --ws ' + ws : ''}`);
|
|
82
|
+
else say(`✓ ${r.persona.name} walks again.`);
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -39,7 +39,7 @@ const actorLib = require('./actor.js');
|
|
|
39
39
|
const RS = require('./report-setups.js');
|
|
40
40
|
const { parseArgs } = require('./schedule-cli');
|
|
41
41
|
|
|
42
|
-
const COMMANDS = { report: ['make', 'read', 'find', 'write', 'check', 'rule', 'draft', 'issue', 'list', 'propose', 'definitions', 'setups', 'finder', 'library', 'language', 'variants'] };
|
|
42
|
+
const COMMANDS = { report: ['make', 'read', 'find', 'write', 'check', 'rule', 'draft', 'issue', 'list', 'propose', 'definitions', 'setups', 'finder', 'library', 'language', 'variants', 'pack'] };
|
|
43
43
|
const USAGE = [
|
|
44
44
|
'usage: pmos report make|read|find|write|check|rule — the report engine: brief, read, find, answer, render (any report, any shape)',
|
|
45
45
|
' pmos report make <id> [--ask "<the question>"] [--readers "<who>"] [--source <kind:ref>,…] [--template <id>] [--slot <date>]',
|
|
@@ -82,12 +82,16 @@ const USAGE = [
|
|
|
82
82
|
' pmos report variants <cadence> [<slot>] [--only executives,engineers,customers]',
|
|
83
83
|
' The draft (default: the newest) in one version each for executives, engineers and customers, beside it',
|
|
84
84
|
' (<slot>.for-<audience>.md). A version holds only numbers and names the draft holds, and ends with its sources. Nothing is sent.',
|
|
85
|
+
' pmos report pack [--redraft] [--now <time>]',
|
|
86
|
+
' The monthly review pack of this product: goals with their state, bets that failed and the lesson, the next big decision and the asks.',
|
|
87
|
+
' Every line names the record it came from; a line with no record is left out. A pack that exists is yours to edit: --redraft writes it again.',
|
|
88
|
+
' Library drafts it by itself when it opens in the last 7 days of the month. Nothing is sent: share it with the Issue press.',
|
|
85
89
|
' every command: [--json] [--root <dir>]. The cadence is the report skill id without "report-", for example biweekly.',
|
|
86
90
|
];
|
|
87
91
|
const BOOL = new Set(['json', 'redraft', 'help', 'off']);
|
|
88
92
|
const VALUE = new Set(['now', 'root', 'ask', 'readers', 'source', 'slot', 'from', 'out', 'template', 'only']);
|
|
89
93
|
const ALLOWED = { make: ['json', 'now', 'root', 'ask', 'readers', 'source', 'slot', 'template'], read: ['json', 'now', 'root', 'slot', 'from', 'source'], find: ['json', 'now', 'root', 'slot', 'from'],
|
|
90
|
-
write: ['json', 'now', 'root', 'slot', 'from'], check: ['json', 'root', 'slot'], rule: ['json', 'root'], draft: ['json', 'redraft', 'now', 'root'], issue: ['root'], list: ['json', 'root'], propose: ['json', 'root'], definitions: ['json', 'root'], setups: ['json', 'root'], finder: ['json', 'root'], language: ['json', 'root', 'off'], variants: ['json', 'root', 'only'], library: ['json', 'out', 'template'] };
|
|
94
|
+
write: ['json', 'now', 'root', 'slot', 'from'], check: ['json', 'root', 'slot'], rule: ['json', 'root'], draft: ['json', 'redraft', 'now', 'root'], issue: ['root'], list: ['json', 'root'], propose: ['json', 'root'], definitions: ['json', 'root'], setups: ['json', 'root'], finder: ['json', 'root'], language: ['json', 'root', 'off'], variants: ['json', 'root', 'only'], library: ['json', 'out', 'template'], pack: ['json', 'redraft', 'now', 'root'] };
|
|
91
95
|
const CADENCE_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
92
96
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
93
97
|
|
|
@@ -156,6 +160,12 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
156
160
|
return 0;
|
|
157
161
|
}
|
|
158
162
|
|
|
163
|
+
if (verb === 'pack') {
|
|
164
|
+
// the monthly review pack (lib/review-pack.js): drafted from the product's records, never sent
|
|
165
|
+
const a = [...(json ? ['--json'] : []), ...(flags.redraft ? ['--redraft'] : []), ...(flags.now ? ['--now', String(flags.now)] : [])];
|
|
166
|
+
return require('./review-pack.js').cli(a, { root, say, now: now ? Number(now) || Date.parse(now) : Date.now() });
|
|
167
|
+
}
|
|
168
|
+
|
|
159
169
|
if (verb === 'library') {
|
|
160
170
|
// the slide library as one page: sanitized as a report render is, with the workspace face inlined so the file shows it anywhere
|
|
161
171
|
const out = path.resolve(cwd || process.cwd(), typeof flags.out === 'string' && flags.out ? flags.out : 'report-library.html');
|