create-pmos 0.739.0 → 0.740.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.739.0",
3
+ "version": "0.740.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,19 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.740.0",
38
+ "at": "2026-11-23T08:20:40.488Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1654,
43
+ "t": "A product's own words show their meaning on hover, on every page (A386)",
44
+ "s": "A product's own words show their meaning on hover, on every page (A386)",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
36
49
  {
37
50
  "v": "0.739.0",
38
51
  "at": "2026-11-23T07:58:34.158Z",
@@ -417,31 +430,6 @@
417
430
  "k": "new"
418
431
  }
419
432
  ]
420
- },
421
- {
422
- "v": "0.715.0",
423
- "at": "2026-11-22T20:02:36.257Z",
424
- "f": 4,
425
- "prs": [
426
- {
427
- "n": 1581,
428
- "t": "The ? list is sized by tokens and uses Komorebi parts only (Checker K5, action-keys)",
429
- "s": "The ?",
430
- "k": "fix"
431
- },
432
- {
433
- "n": 1582,
434
- "t": "Key hints step back once a key is learned (A480)",
435
- "s": "Key hints step back once a key is learned (A480)",
436
- "k": "new"
437
- },
438
- {
439
- "n": 1584,
440
- "t": "Set a task's sprint and priority in place, with one Undo (job #1563)",
441
- "s": "Set a task's sprint and priority in place, with one Undo (job #1563)",
442
- "k": "new"
443
- }
444
- ]
445
433
  }
446
434
  ]
447
435
  }
package/payload/AGENTS.md CHANGED
@@ -113,6 +113,7 @@ The PM talks to you from an initiative's popup in the workspace. PMOS acts by it
113
113
  - **The merge ✦ ("7 references and 2 retros can each be one artefact. Merge them?").** The popup derives it from the files: it shows while several different files of one kind belong to the initiative. When you merge files, put `superseded_by: <path of the merged file>` in the frontmatter of each old file. The Artefacts list then shows the merged file, folds each old file under it as an earlier version, and the ✦ goes away by itself. Delete nothing.
114
114
  - **The case card (Problem, Goal, Done when).** It reads the Experiment and Done test artefacts first, then the record's Problem, Goal and Done test sections. When the PM says yes to a case line, save it where the card reads it: `pmos artefacts set experiment:<id> experiment why --text "<problem>"`, `pmos artefacts set experiment:<id> experiment hypothesis --text "<goal>"`, and `pmos artefacts set experiment:<id> done-test check --text "<one check>"` once for each check. `pmos why` and `pmos ready check` read the same lines.
115
115
  - **The Positioning part of the Strategy card.** When the PM agrees a positioning statement or key message, keep it with `pmos positioning keep --text "<line>" --cites <keys> [--kind positioning]`, citing the strategy lines it comes from (`pmos positioning strategy` lists the keys). Drop one with `pmos positioning drop <id>`. The Board shows what these write.
116
+ - **The product glossary (a word's meaning on hover).** When the PM asks to explain, add or change one of the product's own words ("add MAGW to the glossary"), run `pmos glossary set <term> "<meaning>"` in the product's repository; `pmos glossary remove <term>` takes one out and `pmos glossary` lists them. Every page reads the same file and shows the meaning on hover, or on a long press on a phone.
116
117
  - **A program's card (For, Goal).** After the PM's yes, run `pmos program charter <program id> --why "<what it is for>"` or `--goal "<goal>"` in the repository where the program was made. Its Done when comes from the last milestone and the target date.
117
118
  - **The ✦ that drafts missing documents.** Save a PRD as a file the record names in `prd_path:`, a rubric in `rubric_path:`, and the done test with `pmos artefacts set experiment:<id> done-test check`. A file that nothing names does not show in the Artefacts list.
118
119
  - **A stage's dates on the timeline.** A stage's bar runs from the earliest start to the latest end of its tasks (a task with no start counts from its due date). To change a stage's dates, change the dates of its tasks, with the PM's yes. Do not edit the workflow history to move a bar.
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@869d46c3
1
+ kernel-source: pmos@96c77699
2
2
  assembled: 2026-11-23
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-23T07:58:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T08:20:36Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-23T07:58:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T08:20:36Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-23T07:58:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T08:20:36Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.740.0",
4
+ "at": "2026-11-23T08:20:40.488Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1654,
9
+ "t": "A product's own words show their meaning on hover, on every page (A386)",
10
+ "s": "A product's own words show their meaning on hover, on every page (A386)",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.739.0",
4
17
  "at": "2026-11-23T07:58:34.158Z",
@@ -278,6 +278,16 @@ The idle lab run uses only the first three commands:
278
278
  - `pmos lab critic checks [--root <dir>]`: the checks the critic uses for the product in that folder. No server is needed.
279
279
  - `pmos lab critic label <run> <n> real|noise`: your word on finding `n` of a critic run. `pmos lab critic stats` counts the runs, the findings, and how many you called real or noise.
280
280
 
281
+ ### pmos glossary: the product's own words, explained on every page
282
+
283
+ Run it in the product's repository, or pass `--root <dir>`. It writes the product's records folder on disk, needs no running workspace and sends nothing.
284
+
285
+ - `pmos glossary` (or `pmos glossary list`) lists the words and what they mean. `--json` prints them for a script.
286
+ - `pmos glossary set <term> <meaning…>` adds a word or changes its meaning, for example `pmos glossary set OTP "One-time password"`. A word is at most 40 characters and a meaning at most 200, each on one line. A word written with a capital letter (OTP) is found in that case only; an all-lowercase word (paywall) is found in any case.
287
+ - `pmos glossary remove <term>` takes a word out.
288
+ - On every workspace page, the words of the products you show get a faint dotted underline. Hover over one, or press and hold it on a phone, to see what it means. When you show more than one product, the card names whose word it is.
289
+ - `pmos glossary uses [--days 7]` prints how many meanings were shown on this computer in the last days, from the local use log. Its last line is the number.
290
+
281
291
  ### pmos questions: every open question in one list
282
292
 
283
293
  Run it in the product's repository, or pass `--root <dir>`. It changes nothing, takes no default and sends nothing.
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+ /* glossary-cli.js — `pmos glossary …`: a product's own words and what they mean (bet A386, initiative glossary-hover; lib/glossary.js).
3
+ *
4
+ * pmos glossary [list] [--json] [--root <dir>] the words, sorted
5
+ * pmos glossary set <term> <meaning…> [--root <dir>] add a word or change its meaning; every page shows it on hover
6
+ * pmos glossary remove <term> [--root <dir>] take a word out
7
+ * pmos glossary uses [--days 7] meanings shown on this computer in the last days; the last line is the number
8
+ *
9
+ * It writes the product's records folder on disk (the same file the workspace reads), so it needs no running server, and the page shows
10
+ * the change the next time it loads. Exit codes: 0 done, 1 refused (the reason is printed), 2 usage. */
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+ const { execFileSync } = require('child_process');
14
+ const G = require('./glossary.js');
15
+
16
+ const COMMANDS = { glossary: ['list', 'set', 'remove', 'uses'] };
17
+ const USAGE = [
18
+ 'usage: pmos glossary [list|set|remove|uses] — the product\'s own words; every page shows a word\'s meaning on hover (a long press on a phone)',
19
+ ' pmos glossary the words and what they mean',
20
+ ' pmos glossary set <term> <meaning…> add a word or change its meaning, for example: pmos glossary set OTP "One-time password"',
21
+ ' pmos glossary remove <term> take a word out',
22
+ ' pmos glossary uses [--days 7] how many meanings were shown on this computer; the last line is the number',
23
+ ' every command: [--root <dir>] [--json]',
24
+ ];
25
+
26
+ function repoRoot(cwd) {
27
+ try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; }
28
+ catch { return cwd; }
29
+ }
30
+
31
+ function parse(argv) {
32
+ const pos = []; const flags = {};
33
+ for (let i = 0; i < argv.length; i++) {
34
+ const a = argv[i];
35
+ if (a === '--root' || a === '--days') flags[a.slice(2)] = argv[++i];
36
+ else if (a.startsWith('--root=')) flags.root = a.slice(7);
37
+ else if (a.startsWith('--days=')) flags.days = a.slice(7);
38
+ else if (a.startsWith('--')) flags[a.slice(2)] = true;
39
+ else if (a === '-h') flags.help = true;
40
+ else pos.push(a);
41
+ }
42
+ return { pos, flags };
43
+ }
44
+
45
+ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Date.now(), runtimeDir = null } = {}) {
46
+ const { pos, flags } = parse(argv[0] === 'glossary' ? argv.slice(1) : argv.slice());
47
+ if (flags.help || pos[0] === 'help') { for (const l of USAGE) say(l); return 0; }
48
+ const cmd = pos[0] || 'list';
49
+ if (!COMMANDS.glossary.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos glossary`); for (const l of USAGE) say(l); return 2; }
50
+ const json = !!flags.json;
51
+
52
+ if (cmd === 'uses') {
53
+ const days = flags.days === undefined ? 7 : Number(flags.days);
54
+ if (!Number.isInteger(days) || days < 1 || days > 30) { say('✗ --days is a whole number from 1 to 30'); return 2; }
55
+ let lines = [];
56
+ try { const dir = runtimeDir || require('./state-root.js').defaultRoot({ env: process.env }); lines = require('./use-log.js').readLines(dir); } catch { lines = []; }
57
+ const n = G.uses(lines, days, now);
58
+ if (json) { say(JSON.stringify({ ok: true, days, uses: n })); return 0; }
59
+ say(`${G.TAG} ${n} meaning${n === 1 ? '' : 's'} shown in the last ${days} day${days === 1 ? '' : 's'} on this computer.`);
60
+ say(String(n));
61
+ return 0;
62
+ }
63
+
64
+ if (flags.root === true || flags.root === '') { say('✗ --root needs a value'); return 2; }
65
+ const root = path.resolve(flags.root || repoRoot(cwd));
66
+ let isDir = false; try { isDir = fs.statSync(root).isDirectory(); } catch { isDir = false; }
67
+ if (!isDir) { say(`✗ ${root} is not a directory`); return 1; }
68
+ const dir = G.dirOf(root);
69
+
70
+ if (cmd === 'list') {
71
+ const terms = G.read(dir);
72
+ if (json) { say(JSON.stringify({ ok: true, terms })); return 0; }
73
+ if (!terms.length) say('The glossary is empty. Add a word: pmos glossary set <term> <meaning>');
74
+ for (const t of terms) say(`${t.term}: ${t.meaning}`);
75
+ return 0;
76
+ }
77
+ if (cmd === 'set') {
78
+ if (pos.length < 3) { say('✗ give the word and its meaning: pmos glossary set <term> <meaning…>'); return 2; }
79
+ const r = G.set(dir, pos[1], pos.slice(2).join(' '), now);
80
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
81
+ if (json) { say(JSON.stringify(r)); return 0; }
82
+ say(`✓ ${r.term} is in the glossary. Every page shows its meaning on hover.`);
83
+ return 0;
84
+ }
85
+ // remove
86
+ if (pos.length !== 2) { say('✗ give one word: pmos glossary remove <term> (quote a word with spaces)'); return 2; }
87
+ const r = G.remove(dir, pos[1], now);
88
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
89
+ if (json) { say(JSON.stringify(r)); return 0; }
90
+ say(`✓ ${r.term} is out of the glossary.`);
91
+ return 0;
92
+ }
93
+
94
+ module.exports = { run, COMMANDS, USAGE };
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+ /* glossary.js — a product's glossary of its own words (bet A386, initiative glossary-hover). THE ONE WRITER and THE ONE FOLD of
3
+ * glossary.jsonl. `pmos glossary` (lib/glossary-cli.js) writes it, GET /api/glossary (lib/routes-glossary.js) reads it for the page,
4
+ * and pm/glossary.js shows a word's meaning on hover (a long press on a phone) on every page.
5
+ *
6
+ * read(dir) → [{ term, meaning, at }] the current words, sorted by term (any case)
7
+ * set(dir, term, meaning, now) → { ok, term, terms } | { ok: false, error } adds a word or changes its meaning
8
+ * remove(dir, term, now) → { ok, term, terms } | { ok: false, error } takes a word out (an empty meaning line)
9
+ * checkTerm(term) · checkMeaning(meaning) → '' when good, else the reason
10
+ * dirOf(root) → the records folder of the product checkout at `root`
11
+ * uses(lines, days, now) → how many meanings were shown (use-log `glossary-show`) in the last `days` days PURE
12
+ *
13
+ * WHERE. `dir` is the product's records folder (lib/records-dir.js): planning/records in the PMOS repo, pmos/state/records in a kit
14
+ * product. The file is append-only: one line { at, term, meaning } per change; an empty meaning takes the word out. The last line for a
15
+ * word wins, and a word is matched with any case, so "otp" changes "OTP" (and the new spelling is kept).
16
+ * Log lines say [glossary]. Nothing is sent anywhere. */
17
+ const fs = require('fs');
18
+ const path = require('path');
19
+
20
+ const FILE = 'glossary.jsonl';
21
+ const MAX_TERM = 40;
22
+ const MAX_MEANING = 200;
23
+ const MAX_TERMS = 300;
24
+ const SHOW = 'glossary-show'; // the use-log control a meaning shown is noted under (pm/glossary.js)
25
+ const TAG = '[glossary]';
26
+ const say = (s) => { try { console.log(TAG + ' ' + s); } catch { /* no console */ } };
27
+ const one = (v) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim();
28
+ const keyOf = (t) => one(t).toLowerCase();
29
+
30
+ function checkTerm(term) {
31
+ const t = one(term);
32
+ if (!t) return 'Name the word.';
33
+ if (t.length > MAX_TERM) return `A word is at most ${MAX_TERM} characters.`;
34
+ if (!/[\p{L}\p{N}]/u.test(t)) return 'A word needs a letter or a digit.';
35
+ return '';
36
+ }
37
+
38
+ function checkMeaning(meaning) {
39
+ const m = one(meaning);
40
+ if (!m) return 'Say what the word means.';
41
+ if (m.length > MAX_MEANING) return `A meaning is at most ${MAX_MEANING} characters.`;
42
+ return '';
43
+ }
44
+
45
+ const fileOf = (dir) => (dir ? path.join(dir, FILE) : null);
46
+
47
+ function readLines(dir) {
48
+ const f = fileOf(dir);
49
+ if (!f) return [];
50
+ let text = '';
51
+ try { text = fs.readFileSync(f, 'utf8'); } catch { return []; }
52
+ const out = [];
53
+ for (const l of text.split('\n')) {
54
+ if (!l.trim()) continue;
55
+ try { const o = JSON.parse(l); if (o && typeof o === 'object' && typeof o.term === 'string') out.push(o); } catch { /* a torn line is skipped */ }
56
+ }
57
+ return out;
58
+ }
59
+
60
+ function read(dir) {
61
+ const by = new Map();
62
+ for (const l of readLines(dir)) {
63
+ const k = keyOf(l.term);
64
+ if (!k) continue;
65
+ const m = one(l.meaning);
66
+ if (m) by.set(k, { term: one(l.term), meaning: m, at: l.at || null });
67
+ else by.delete(k);
68
+ }
69
+ return [...by.values()].sort((a, b) => a.term.localeCompare(b.term, 'en', { sensitivity: 'base' }));
70
+ }
71
+
72
+ function append(dir, line) {
73
+ fs.mkdirSync(dir, { recursive: true });
74
+ fs.appendFileSync(fileOf(dir), JSON.stringify(line) + '\n');
75
+ }
76
+
77
+ function set(dir, term, meaning, now = Date.now()) {
78
+ if (!dir) return { ok: false, error: 'This product has no records folder.' };
79
+ const bad = checkTerm(term) || checkMeaning(meaning);
80
+ if (bad) return { ok: false, error: bad };
81
+ const t = one(term), had = read(dir);
82
+ if (!had.some((x) => keyOf(x.term) === keyOf(t)) && had.length >= MAX_TERMS) return { ok: false, error: `A glossary holds at most ${MAX_TERMS} words. Remove one first.` };
83
+ try { append(dir, { at: new Date(now).toISOString(), term: t, meaning: one(meaning) }); } catch (e) { return { ok: false, error: 'could not save the word: ' + ((e && e.message) || e) }; }
84
+ const terms = read(dir);
85
+ say(`set ${t} (${terms.length} words)`);
86
+ return { ok: true, term: t, terms };
87
+ }
88
+
89
+ function remove(dir, term, now = Date.now()) {
90
+ if (!dir) return { ok: false, error: 'This product has no records folder.' };
91
+ const bad = checkTerm(term);
92
+ if (bad) return { ok: false, error: bad };
93
+ const hit = read(dir).find((x) => keyOf(x.term) === keyOf(term));
94
+ if (!hit) return { ok: false, error: `${one(term)} is not in the glossary.` };
95
+ try { append(dir, { at: new Date(now).toISOString(), term: hit.term, meaning: '' }); } catch (e) { return { ok: false, error: 'could not remove the word: ' + ((e && e.message) || e) }; }
96
+ const terms = read(dir);
97
+ say(`removed ${hit.term} (${terms.length} words)`);
98
+ return { ok: true, term: hit.term, terms };
99
+ }
100
+
101
+ /** The records folder of the product checkout at `root` (scripts/signals/layout-paths.js, as lib/records-dir.js does). */
102
+ function dirOf(root) {
103
+ try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; }
104
+ catch { return path.join(root, 'planning', 'records'); }
105
+ }
106
+
107
+ function uses(lines, days = 7, now = Date.now()) {
108
+ const cut = now - days * 864e5;
109
+ return (lines || []).filter((l) => l && l.kind === 'use' && l.control === SHOW && Date.parse(l.at) >= cut && Date.parse(l.at) <= now + 864e5).length;
110
+ }
111
+
112
+ module.exports = { FILE, MAX_TERM, MAX_MEANING, MAX_TERMS, SHOW, TAG, checkTerm, checkMeaning, readLines, read, set, remove, dirOf, uses };
@@ -130,6 +130,9 @@ const VERBS = Object.freeze({
130
130
  // Not a pm-os-absorb verb (run: null): initiative design-drift-guard added it through the same table.
131
131
  design: Object.freeze({ module: 'design-cli.js', run: null, guide: 'cli.md',
132
132
  help: 'pmos design drift — which pages are built from your design system and which drift from it, read from git (pmos design help)' }),
133
+ // Not a pm-os-absorb verb (run: null): initiative glossary-hover (bet A386) added it through the same table.
134
+ glossary: Object.freeze({ module: 'glossary-cli.js', run: null, guide: 'cli.md',
135
+ help: 'pmos glossary [list|set|remove|uses] — the product\'s own words; every page shows a word\'s meaning on hover (pmos glossary help)' }),
133
136
  // Not a pm-os-absorb verb (run: null): initiative page-fix-count-first (bet A462) added it through the same table.
134
137
  pages: Object.freeze({ module: 'pages-cli.js', run: null, guide: 'cli.md',
135
138
  help: 'pmos pages [show|check] — each page\'s fixes, reverts and restores in the last 14 days, and a feature change that adds to a page that keeps breaking (pmos pages help)' }),
@@ -51,6 +51,7 @@ const MODULES = Object.freeze([
51
51
  'routes-doc-health', // console3 B2: the six document health checks, recomputed from text
52
52
  'routes-outbox', // console3 B3: the outbox queue, hash-bound confirm (no channel connected)
53
53
  'routes-waiting', // home-your-move-waiting: Waiting on others, derived from records, with its exit rule
54
+ 'routes-glossary', // glossary-hover (A386): the glossary of the products a page shows (read only; pmos glossary writes it)
54
55
  'routes-open-questions', // open-questions-register (A420): one register of every unanswered question, with owner, age and default
55
56
  'routes-calendar-views', // console3 C2: Day/Week/Month/Quarter/Year cells, Gantt and the strategy lens (read-only)
56
57
  'routes-events-place', // events-place (nav slice 6): every date PMOS holds, grouped Late / Today / Coming up, and the PM's fixed marks and noes (events/marks.jsonl; page-press POST)
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+ /* routes-glossary.js — the glossary of the products a page shows (bet A386, initiative glossary-hover; lib/glossary.js, pm/glossary.js).
3
+ *
4
+ * GET /api/glossary?ws=<id>[,<id>…] → { ok, terms: [{ term, meaning, ws }] } no ws: the home product
5
+ *
6
+ * Read only: `pmos glossary set|remove` writes the same file (glossary.jsonl in each product's records folder), so a word the chat adds
7
+ * shows on the next page load. An unknown product is left out. Nothing is sent anywhere. */
8
+ const G = require('./glossary.js');
9
+ const { recordsDirFor } = require('./records-dir.js');
10
+
11
+ module.exports = {
12
+ prefixes: ['/api/glossary'],
13
+ handle: async (req, res, url, ctx) => {
14
+ if (url.pathname !== '/api/glossary') return false;
15
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
16
+ const asked = String(url.searchParams.get('ws') || '').split(',').map((s) => s.trim()).filter(Boolean).slice(0, 20);
17
+ const ids = [];
18
+ for (const id of asked.length ? asked : [null]) {
19
+ let w = null;
20
+ try { w = ctx.getWs ? ctx.getWs(id) : null; } catch { w = null; }
21
+ if (!w || !w.id || (id && w.id !== id)) continue; // getWs gives the home product for an unknown id: leave it out
22
+ if (!ids.includes(w.id)) ids.push(w.id);
23
+ }
24
+ const terms = [];
25
+ for (const ws of ids) for (const t of G.read(recordsDirFor(ctx, ws))) terms.push({ term: t.term, meaning: t.meaning, ws });
26
+ ctx.json(res, { ok: true, terms });
27
+ return true;
28
+ },
29
+ };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.739.0",
3
+ "version": "0.740.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.739.0",
9
+ "version": "0.740.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.739.0",
3
+ "version": "0.740.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -556,3 +556,9 @@ body.pm-focus.cz-railon { --cz-railx: var(--space-16); }
556
556
  body.pm-focus .cz-pop-card { inset: 0; border-radius: 0; }
557
557
  .pm-focus-bar { position: fixed; top: var(--space-8); right: var(--space-8); z-index: 1000; }
558
558
  .pm-focus-bar .pm-focus-leave { background: var(--card); color: var(--ink); box-shadow: var(--lift); }
559
+
560
+ /* ── the product glossary (pm/glossary.js, bet A386): its words carry a faint dotted underline (a CSS highlight, the page's markup is
561
+ * untouched), and a hover or a long press shows a small Komorebi card with the word and its meaning. Tokens only. ── */
562
+ ::highlight(pm-term) { text-decoration: underline dotted; text-underline-offset: var(--space-4); } /* the text's own colour: --muted means another thing inside .c3 */
563
+ .gl-tip.pm-ds { position: fixed; z-index: 90; max-width: min(calc(var(--space-64) * 5), calc(100vw - var(--space-16))); background: var(--card); color: var(--ink); border-radius: var(--radius-md); box-shadow: var(--lift); padding: var(--space-8) var(--space-12); font-size: var(--fs-meta); line-height: var(--lh-meta); left: var(--fr-gl-x, 0); top: var(--fr-gl-y, 0); pointer-events: auto; }
564
+ .gl-tip.pm-ds .gl-m { margin: var(--space-4) 0 0; }
@@ -46,6 +46,7 @@ import './draft-keep.js'; // forms-keep-drafts: every text box on every page k
46
46
  import { pmPost } from './http.js'; // Adler (batch 16 item 2): every toast carries his S face; Settings > Adler is read once
47
47
  import { startUseLog } from './use-log.js'; // bet A466: every page mounts the menu, so the menu starts the local use log (this computer only)
48
48
  import { startActionKeys } from './action-keys.js'; // bet A477: y o s p z act on the item under the pointer, ? lists the keys
49
+ import { startGlossary } from './glossary.js'; // bet A386: a product's own words show their meaning on hover (a long press on a phone)
49
50
  import { startFocusMode } from './focus-mode.js'; // bet A335: f shows only the item under the pointer and its chat; f again puts the page back
50
51
 
51
52
  /* The six places (slice 1). A place shows once it has an href: Events, Library and Routine get theirs when their slice ships. Until then
@@ -206,6 +207,7 @@ export function mountNav(here, doc = document, opts = {}) {
206
207
  startUseLog(doc);
207
208
  startActionKeys(doc);
208
209
  startFocusMode(doc);
210
+ startGlossary(doc);
209
211
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
210
212
  const draw = () => {
211
213
  N.rail = railOn();
@@ -0,0 +1,250 @@
1
+ /* pm/glossary.js — a product's own words explain themselves on every page (bet A386, initiative glossary-hover; the store is
2
+ * lib/glossary.js, written by `pmos glossary`, read through GET /api/glossary).
3
+ *
4
+ * The words of the products the page shows (the product pick, pm/cozy-pick.js) get a faint dotted underline. A hover over one, or a long
5
+ * press on a phone, shows a small card: the word, what it means and, when more than one product is shown, whose word it is.
6
+ * The underline is the browser's CSS highlight (::highlight(pm-term) in cozy-ev.css), so the page's own markup is never changed; a browser
7
+ * without CSS highlights shows no underline and the hover still works. Text in inputs, editable text, code, terminals, the menu and the
8
+ * card itself is left alone. Each meaning shown is noted once on this computer (pm/use-log.js noteUse `glossary-show`, no text).
9
+ *
10
+ * startGlossary(doc) called once by the menu (pm/cozy-nav.js mountNav), which every page mounts; a second call does nothing,
11
+ * and so does a call in a browser a script drives (navigator.webdriver)
12
+ * matcherOf(terms) PURE: the matcher for [{ term, meaning, ws }] → { find(text), entries(key) } or null when there are none
13
+ * findTerms(text, terms) PURE: [{ start, end, text, key }] whole words; a term with a capital letter matches that case only,
14
+ * an all-lowercase term any case; the longer term wins where two overlap
15
+ * tipHtml(entries, o) PURE: the card's markup; o.names: show each product's name, o.nameOf(ws) the name
16
+ * skipped(el) true when the text under `el` is left alone (SKIP) */
17
+ import { pmGet } from './http.js';
18
+ import { readPick } from './cozy-pick.js';
19
+ import { productName } from './scope-chip.js';
20
+ import { noteUse } from './use-log.js';
21
+
22
+ export const SKIP = 'input, textarea, select, code, pre, script, style, noscript, svg, [contenteditable=""], [contenteditable="true"], [role="textbox"], .xterm, #czNav, .gl-tip';
23
+ export const HL = 'pm-term';
24
+ export const SHOW = 'glossary-show';
25
+ const MAX_NODES = 5000;
26
+ const MAX_HITS = 800;
27
+ const HOVER_MS = 250;
28
+ const PRESS_MS = 450;
29
+ const AGAIN_MS = 10000; // the same word shown again within this time is not counted again
30
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
31
+ const reEsc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
32
+ const keyOf = (t) => String(t || '').replace(/\s+/g, ' ').trim().toLowerCase();
33
+ const say = (s) => { try { console.info('[glossary] ' + s); } catch { /* no console */ } };
34
+
35
+ /** PURE. The matcher for a list of words, or null when there are none. */
36
+ export function matcherOf(terms) {
37
+ const by = new Map();
38
+ for (const t of terms || []) {
39
+ const k = keyOf(t && t.term);
40
+ if (!k || !String((t && t.meaning) || '').trim()) continue;
41
+ if (!by.has(k)) by.set(k, []);
42
+ by.get(k).push(t);
43
+ }
44
+ if (!by.size) return null;
45
+ const cs = new Set(), ci = new Set();
46
+ for (const list of by.values()) for (const t of list) {
47
+ const w = String(t.term).replace(/\s+/g, ' ').trim();
48
+ (/\p{Lu}/u.test(w) ? cs : ci).add(w);
49
+ }
50
+ const alt = (set) => [...set].sort((a, b) => b.length - a.length).map((w) => reEsc(w).replace(/ /g, '\\s+')).join('|');
51
+ const wrap = (set, flags) => (set.size ? new RegExp('(?<![\\p{L}\\p{N}])(?:' + alt(set) + ')(?![\\p{L}\\p{N}])', flags) : null);
52
+ const res = [wrap(cs, 'gu'), wrap(ci, 'giu')].filter(Boolean);
53
+ const find = (text) => {
54
+ const s = String(text || '');
55
+ if (!s.trim()) return [];
56
+ const hits = [];
57
+ for (const re of res) { re.lastIndex = 0; let m; while ((m = re.exec(s))) { hits.push({ start: m.index, end: m.index + m[0].length, text: m[0], key: keyOf(m[0]) }); if (!m[0].length) re.lastIndex++; } }
58
+ hits.sort((a, b) => a.start - b.start || (b.end - b.start) - (a.end - a.start));
59
+ const out = [];
60
+ for (const h of hits) {
61
+ const last = out[out.length - 1];
62
+ if (last && h.start < last.end) { if (h.end - h.start > last.end - last.start) out[out.length - 1] = h; continue; }
63
+ out.push(h);
64
+ }
65
+ return out.filter((h) => by.has(h.key));
66
+ };
67
+ return { find, entries: (k) => by.get(keyOf(k)) || [], size: by.size };
68
+ }
69
+
70
+ /** PURE. The words found in `text`. */
71
+ export function findTerms(text, terms) { const m = matcherOf(terms); return m ? m.find(text) : []; }
72
+
73
+ /** PURE. The card for one word: its meaning per product (one line each when two products use the same word). */
74
+ export function tipHtml(entries, o = {}) {
75
+ const list = (entries || []).filter((e) => e && e.term && e.meaning);
76
+ if (!list.length) return '';
77
+ const nameOf = o.nameOf || ((ws) => ws);
78
+ const rows = list.map((e) => `<p class="gl-m">${o.names && e.ws ? `<span class="pm-meta">${esc(nameOf(e.ws))}</span> ` : ''}${esc(e.meaning)}</p>`).join('');
79
+ return `<div class="pm-ds gl-tip" role="tooltip" id="glTip"><b class="pm-h-sm">${esc(list[0].term)}</b>${rows}</div>`;
80
+ }
81
+
82
+ export const skipped = (el) => !!(el && el.closest && el.closest(SKIP));
83
+
84
+ let started = false;
85
+ const S = { doc: null, M: null, names: false, nodes: new Map(), ranges: [], tip: null, at: null, hoverT: 0, hideT: 0, pressT: 0, press: null, eat: false, shown: new Map(), scanT: 0, mo: null };
86
+
87
+ function botNow() { try { return !!(typeof navigator !== 'undefined' && navigator.webdriver); } catch { return false; } }
88
+
89
+ /** Find the words in the page's text and underline them. */
90
+ function scan() {
91
+ const doc = S.doc;
92
+ S.nodes = new Map(); S.ranges = [];
93
+ if (!S.M || !doc.body) { paint(); return; }
94
+ const win = doc.defaultView;
95
+ const walker = doc.createTreeWalker(doc.body, 4 /* SHOW_TEXT */, { acceptNode: (n) => (n.nodeValue && n.nodeValue.trim() && n.parentElement && !skipped(n.parentElement) ? 1 : 2) });
96
+ let n, seen = 0, hits = 0;
97
+ while ((n = walker.nextNode()) && seen++ < MAX_NODES && hits < MAX_HITS) {
98
+ const found = S.M.find(n.nodeValue);
99
+ if (!found.length) continue;
100
+ S.nodes.set(n, found);
101
+ for (const h of found) {
102
+ if (hits++ >= MAX_HITS) break;
103
+ try { const r = doc.createRange(); r.setStart(n, h.start); r.setEnd(n, h.end); S.ranges.push({ r, key: h.key }); } catch { /* the node changed */ }
104
+ }
105
+ }
106
+ paint(win);
107
+ }
108
+
109
+ function paint(win = S.doc && S.doc.defaultView) {
110
+ try {
111
+ if (!win || !win.CSS || !win.CSS.highlights || typeof win.Highlight !== 'function') return;
112
+ if (S.ranges.length) win.CSS.highlights.set(HL, new win.Highlight(...S.ranges.map((x) => x.r)));
113
+ else win.CSS.highlights.delete(HL);
114
+ } catch { /* no highlights: the hover still works */ }
115
+ }
116
+
117
+ const inRect = (x, y, b) => x >= b.left - 1 && x <= b.right + 1 && y >= b.top - 1 && y <= b.bottom + 1;
118
+
119
+ /** The word under a point, or null. */
120
+ function hitAt(x, y) {
121
+ const doc = S.doc;
122
+ let node = null, off = -1;
123
+ try {
124
+ if (doc.caretPositionFromPoint) { const p = doc.caretPositionFromPoint(x, y); if (p) { node = p.offsetNode; off = p.offset; } }
125
+ else if (doc.caretRangeFromPoint) { const r = doc.caretRangeFromPoint(x, y); if (r) { node = r.startContainer; off = r.startOffset; } }
126
+ } catch { node = null; }
127
+ const tryRange = (r, key) => { for (const b of r.getClientRects()) if (inRect(x, y, b)) return { r, key, box: r.getBoundingClientRect() }; return null; };
128
+ if (node && S.nodes.has(node)) {
129
+ for (const h of S.nodes.get(node)) {
130
+ if (off < h.start || off > h.end) continue;
131
+ const x2 = S.ranges.find((q) => q.r.startContainer === node && q.r.startOffset === h.start);
132
+ const got = x2 && tryRange(x2.r, x2.key);
133
+ if (got) return got;
134
+ }
135
+ return null;
136
+ }
137
+ if (node) return null;
138
+ for (const q of S.ranges) { const got = tryRange(q.r, q.key); if (got) return got; } // no caret API: look through the words
139
+ return null;
140
+ }
141
+
142
+ function show(hit) {
143
+ const doc = S.doc;
144
+ const html = tipHtml(S.M.entries(hit.key), { names: S.names, nameOf: (ws) => productName(ws, ws) });
145
+ if (!html) return;
146
+ hide();
147
+ const wrap = doc.createElement('div');
148
+ wrap.innerHTML = html;
149
+ const tip = wrap.firstElementChild;
150
+ doc.body.appendChild(tip);
151
+ const win = doc.defaultView, vw = win.innerWidth || 1280, vh = win.innerHeight || 800;
152
+ const tb = tip.getBoundingClientRect(), b = hit.box;
153
+ const left = Math.max(8, Math.min(b.left, vw - tb.width - 8));
154
+ const below = b.bottom + 6 + tb.height <= vh;
155
+ tip.style.setProperty('--fr-gl-x', left + 'px'); // run-time geometry only; the card's look is in cozy-ev.css
156
+ tip.style.setProperty('--fr-gl-y', (below ? b.bottom + 6 : Math.max(8, b.top - tb.height - 6)) + 'px');
157
+ S.tip = tip; S.at = hit.key;
158
+ const last = S.shown.get(hit.key) || 0, now = Date.now();
159
+ if (now - last > AGAIN_MS) { S.shown.set(hit.key, now); noteUse(SHOW); say('shown'); }
160
+ }
161
+
162
+ function hide() { if (S.tip) { S.tip.remove(); S.tip = null; S.at = null; } }
163
+
164
+ let moveQ = null, moveF = 0;
165
+ function onMove(e) {
166
+ if (e.pointerType && e.pointerType !== 'mouse') return;
167
+ moveQ = { clientX: e.clientX, clientY: e.clientY, target: e.target };
168
+ if (moveF) return;
169
+ const w = S.doc.defaultView, raf = w && w.requestAnimationFrame ? (f) => w.requestAnimationFrame(f) : (f) => setTimeout(f, 16);
170
+ moveF = raf(() => { moveF = 0; const q = moveQ; moveQ = null; if (q) onPoint(q); });
171
+ }
172
+
173
+ function onPoint(e) {
174
+ if (S.tip && e.target && e.target.closest && e.target.closest('.gl-tip')) { clearTimeout(S.hideT); return; }
175
+ const hit = S.M ? hitAt(e.clientX, e.clientY) : null;
176
+ clearTimeout(S.hoverT);
177
+ if (hit) {
178
+ clearTimeout(S.hideT);
179
+ if (S.at === hit.key && S.tip) return;
180
+ S.hoverT = setTimeout(() => show(hit), HOVER_MS);
181
+ } else if (S.tip) {
182
+ clearTimeout(S.hideT);
183
+ S.hideT = setTimeout(hide, 150);
184
+ }
185
+ }
186
+
187
+ function onTouchStart(e) {
188
+ if (S.tip && !(e.target && e.target.closest && e.target.closest('.gl-tip'))) hide();
189
+ clearTimeout(S.pressT);
190
+ if (!S.M || !e.touches || e.touches.length !== 1) return;
191
+ const t = e.touches[0];
192
+ S.press = { x: t.clientX, y: t.clientY };
193
+ S.pressT = setTimeout(() => {
194
+ const hit = hitAt(S.press.x, S.press.y);
195
+ if (hit) { S.eat = true; show(hit); }
196
+ }, PRESS_MS);
197
+ }
198
+ function onTouchMove(e) {
199
+ const t = e.touches && e.touches[0];
200
+ if (S.press && t && Math.hypot(t.clientX - S.press.x, t.clientY - S.press.y) > 10) clearTimeout(S.pressT);
201
+ }
202
+ function onTouchEnd() { clearTimeout(S.pressT); }
203
+ // the press that showed a meaning does not also open the row under it, nor the phone's own menu
204
+ function eatClick(e) { if (S.eat) { S.eat = false; e.preventDefault(); e.stopPropagation(); } }
205
+ function eatMenu(e) { if (S.eat) e.preventDefault(); }
206
+
207
+ async function load() {
208
+ let ws = [];
209
+ try { const P = await readPick(); ws = P ? P.products.filter((p) => p.on).map((p) => p.ws) : []; } catch { ws = []; }
210
+ const r = await Promise.resolve(pmGet('/api/glossary' + (ws.length ? '?ws=' + encodeURIComponent(ws.join(',')) : ''))).catch(() => null);
211
+ const terms = r && r.ok && Array.isArray(r.terms) ? r.terms : [];
212
+ S.M = matcherOf(terms);
213
+ S.names = new Set(terms.map((t) => t.ws)).size > 1;
214
+ scan();
215
+ watch();
216
+ }
217
+
218
+ function watch() {
219
+ const doc = S.doc, win = doc.defaultView;
220
+ if (S.mo || !S.M || !win || typeof win.MutationObserver !== 'function') return;
221
+ S.mo = new win.MutationObserver((list) => {
222
+ const ours = (n) => !!(n && n.nodeType === 1 && n.classList && n.classList.contains('gl-tip'));
223
+ // the card coming and going, or a change inside it, is not a change of the page's text
224
+ if (list.every((m) => (m.target && m.target.closest && m.target.closest('.gl-tip')) || (m.type === 'childList' && [...m.addedNodes, ...m.removedNodes].every(ours)))) return;
225
+ clearTimeout(S.scanT);
226
+ S.scanT = setTimeout(scan, 500);
227
+ });
228
+ S.mo.observe(doc.body, { childList: true, subtree: true, characterData: true });
229
+ }
230
+
231
+ export function startGlossary(doc = typeof document !== 'undefined' ? document : null) {
232
+ if (started || !doc || !doc.body) return false;
233
+ if (botNow()) return false; // a browser a script drives: no underline, no meanings, nothing noted
234
+ started = true;
235
+ S.doc = doc;
236
+ const win = doc.defaultView;
237
+ doc.addEventListener('pointermove', onMove, { passive: true });
238
+ doc.addEventListener('touchstart', onTouchStart, { passive: true });
239
+ doc.addEventListener('touchmove', onTouchMove, { passive: true });
240
+ doc.addEventListener('touchend', onTouchEnd, { passive: true });
241
+ doc.defaultView.addEventListener('click', eatClick, true); // capture on the window: runs before the row's own press
242
+ doc.addEventListener('contextmenu', eatMenu, true);
243
+ doc.addEventListener('keydown', (e) => { if (e.key === 'Escape') hide(); });
244
+ if (win) {
245
+ win.addEventListener('scroll', hide, { passive: true, capture: true });
246
+ win.addEventListener('pp:changed', () => { load(); });
247
+ }
248
+ load();
249
+ return true;
250
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "initiative glossary-hover (bet A386): a product's own words explain themselves on hover; the store, matcher, pmos glossary, GET /api/glossary and the page's parts on scratch folders (no server, network or browser).",
3
+ "modules": [
4
+ "product-glossary.test.js"
5
+ ],
6
+ "seconds": {
7
+ "product-glossary.test.js": 2
8
+ }
9
+ }