create-pmos 0.823.0 → 0.825.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +107 -37
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +106 -10
  7. package/workspace/guide/backlog.md +8 -0
  8. package/workspace/guide/cli.md +10 -0
  9. package/workspace/guide/home.md +1 -0
  10. package/workspace/guide/settings-and-switches.md +2 -0
  11. package/workspace/lib/autonomy-cli.js +14 -2
  12. package/workspace/lib/connector-data.js +138 -0
  13. package/workspace/lib/connectors-cli.js +6 -0
  14. package/workspace/lib/does-alone.js +67 -0
  15. package/workspace/lib/job-graph.js +1 -0
  16. package/workspace/lib/mention-cli.js +36 -2
  17. package/workspace/lib/name-links.js +203 -0
  18. package/workspace/lib/pmos-verbs.js +3 -0
  19. package/workspace/lib/route-modules.js +1 -0
  20. package/workspace/lib/routes-autonomy.js +9 -0
  21. package/workspace/lib/routes-connector-data.js +17 -0
  22. package/workspace/lib/routes-today-log.js +8 -1
  23. package/workspace/package-lock.json +2 -2
  24. package/workspace/package.json +1 -1
  25. package/workspace/public/pm/bd-backlog-ds.js +1 -1
  26. package/workspace/public/pm/bd-backlog.js +11 -2
  27. package/workspace/public/pm/bd-work-ds.css +15 -0
  28. package/workspace/public/pm/bd-work.js +1 -1
  29. package/workspace/public/pm/connector-data.js +47 -0
  30. package/workspace/public/pm/cozy-name-links.js +118 -0
  31. package/workspace/public/pm/cozy-settings.js +42 -7
  32. package/workspace/public/pm/cozy-today-app.js +26 -0
  33. package/workspace/public/pm/cozy-today-page.css +5 -0
  34. package/workspace/public/pm/cozy-today-view.js +8 -3
  35. package/workspace/public/pm/cozy-today.css +9 -0
  36. package/workspace/public/pm/home-chat.js +16 -1
  37. package/workspace/public/pm/home-hold.js +121 -0
  38. package/workspace/public/pm/list-balance.js +73 -0
  39. package/workspace/public/pm/premium-board.js +11 -3
  40. package/workspace/test-lists/connector-data.json +9 -0
  41. package/workspace/test-lists/does-alone.json +9 -0
  42. package/workspace/test-lists/hold-to-talk.json +9 -0
  43. package/workspace/test-lists/name-links.json +9 -0
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+ /* does-alone.js — one page: what PMOS may do alone (initiative does-alone, job #1890, idea A513; board BatchPagesDS panel 2, agreed
3
+ * 2026-11-25; done test planning/done-tests/does-alone.md).
4
+ *
5
+ * WHAT IT IS. A read-only list of today's rules, one row per kind of action, in plain words: what PMOS does now, since when, and the
6
+ * decision behind it. The kinds and their ways are lib/autonomy.js's own (KIND_LIST, kindsOf, the PM's claude.ways), so this page and
7
+ * Settings › How PMOS decides never disagree. Then the fixed rows: what others see waits for the daily press, and the calls that always
8
+ * ask. Nothing here is set: a kind's way is changed in How PMOS decides (pm/cozy-settings.js).
9
+ *
10
+ * FIXED · DECISION · pmosOf(way) PURE · sinceOf(k) PURE · rowsOf(kinds, { off }) PURE → [row] · stopsOf(lines, { now }) PURE → [kind label]
11
+ * lineOf(stops) PURE → the ✦ line | null · aloneOf(dirs, { now, env, settingsDir }) → { ok, off, rows, stops, line } READ-ONLY
12
+ * row: { key, what, pmos, since, fixed, decision: { id, page } }
13
+ *
14
+ * It writes nothing: no ledger line, no setting. GET /api/autonomy/alone (lib/routes-autonomy.js) and `pmos autonomy alone` read it. */
15
+ const A = require('./autonomy.js');
16
+
17
+ const DAY = 86400000;
18
+ const DECISION = Object.freeze({ id: 'D106', page: 'agent-capabilities' }); // Full autonomy now (2026-11-08): the guide page explains it
19
+ const FIXED = Object.freeze([
20
+ Object.freeze({ key: 'others', what: 'Anything others see: stages and dates in Jira or on Work', pmos: 'Once a day, in one batch' }),
21
+ Object.freeze({ key: 'sends', what: 'Messages to people, Jira writes, merges, deletes and spend', pmos: 'Asks you' }),
22
+ Object.freeze({ key: 'calls', what: 'Starting a new request, and saying if an outcome worked', pmos: 'Asks you' }),
23
+ ]);
24
+
25
+ /** PURE. What PMOS does for a way. */
26
+ const pmosOf = (way) => (way === 'quiet' ? 'Does it, Undo' : way === 'show' ? 'Does it and shows you, Undo' : 'Asks you');
27
+ const dayOf = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' }) : ''; };
28
+ /** PURE. Since when: the PM's way, a demotion's end, or the automatic way. */
29
+ const sinceOf = (k) => (k.set ? 'you set it' : k.until ? 'asks until ' + dayOf(k.until) : 'auto');
30
+
31
+ /** PURE. One row per kind (KIND_LIST order), its way from kindsOf when it has one, then the fixed rows. off: every row asks. */
32
+ function rowsOf(kinds = [], { off = null } = {}) {
33
+ const by = new Map((kinds || []).map((k) => [k.kind, k]));
34
+ const rows = A.KIND_LIST.map((x) => {
35
+ const k = by.get(x.key) || { kind: x.key, set: null, until: null, way: A.autoWay({ kept: 0, demoted: false }) };
36
+ return { key: x.key, what: x.label, pmos: off ? 'Asks you' : pmosOf(k.way), since: off ? 'switched off' : sinceOf(k), fixed: false, decision: DECISION };
37
+ });
38
+ return [...rows, ...FIXED.map((f) => ({ key: f.key, what: f.what, pmos: f.pmos, since: 'always', fixed: true, decision: DECISION }))];
39
+ }
40
+
41
+ /** PURE. The kinds PMOS went back to asking for by itself in the last 7 days (a demote line), one entry per line, newest first. */
42
+ function stopsOf(lines = [], { now } = {}) {
43
+ const t = now == null ? Date.now() : now;
44
+ return (lines || []).filter((l) => l && l.ev === 'demote' && t - Date.parse(l.at) <= 7 * DAY && t >= Date.parse(l.at))
45
+ .sort((a, b) => String(b.at).localeCompare(String(a.at)))
46
+ .map((l) => { const kk = A.kindOf(l.job); const x = A.KIND_LIST.find((y) => y.key === kk); return x ? x.label : String(l.job); });
47
+ }
48
+
49
+ /** PURE. The ✦ line, or null (zero is silence). */
50
+ function lineOf(stops = []) {
51
+ if (!stops.length) return null;
52
+ const names = [...new Set(stops)];
53
+ return `PMOS went back to asking by itself ${stops.length === 1 ? 'once' : stops.length + ' times'} this week, after your Undos (${names.slice(0, 3).join(', ')}${names.length > 3 ? ' and ' + (names.length - 3) + ' more' : ''}).`;
54
+ }
55
+
56
+ /** READ-ONLY. The page over the given state folders. */
57
+ function aloneOf(dirs = [], { now, env = process.env, settingsDir = null } = {}) {
58
+ const off = A.killed({ env, settingsDir });
59
+ const kinds = A.kindsOf(dirs, { now, settingsDir });
60
+ const set = A.waysSet(settingsDir);
61
+ // kindsOf lists only the kinds with a change or a set way; a set way with no change is in it already, so the rest are automatic
62
+ for (const [kk, w] of Object.entries(set)) if (!kinds.some((k) => k.kind === kk)) kinds.push({ kind: kk, set: w, way: w, until: null });
63
+ const stops = stopsOf((dirs || []).flatMap((d) => A.read(d)), { now });
64
+ return { ok: true, off: off || null, rows: rowsOf(kinds, { off }), stops, line: off ? null : lineOf(stops) };
65
+ }
66
+
67
+ module.exports = { FIXED, DECISION, pmosOf, sinceOf, rowsOf, stopsOf, lineOf, aloneOf };
@@ -172,6 +172,7 @@ const JOBS = Object.freeze([
172
172
  ai('past-repeat', 'lib/past-repeat.js', [props], ['repo:DECISIONS.md']),
173
173
  ai('report-readers', 'lib/report-readers.js', [props, '<runtime>/spec-critic.jsonl'], ['report drafts']), // report-reader-review: each report draft read as the CFO, the engineer and the sceptic
174
174
  ai('report-translate', 'lib/report-translate.js', [], ['report drafts', 'report definitions']), // report-reader-language: a translated copy beside each draft, numbers and names checked
175
+ ai('report-variants', 'lib/report-variants.js', [], ['report drafts']), // report-three-audiences: pmos report variants, the draft for executives, engineers and customers
175
176
  ai('decision-memory', 'lib/decision-memory.js', [props], ['repo:DECISIONS.md']),
176
177
  ai('outcomes', 'lib/outcome-props.js', [props, '<state>/outcome-runs.jsonl'], ['initiative records', 'repo:planning/runs/outcome_checks.jsonl', '<state>/metric-reads.jsonl']),
177
178
  ai('descriptions', 'lib/description-props.js', [props], ['initiative records']),
@@ -9,6 +9,8 @@
9
9
  * pmos mention landed <id> --text "<Samuel’s tag landed.>" the watched promise landed: the opening line says so once
10
10
  * pmos mention answered <id> --who "<name>" --text "<their line>" [--on <ISO>] sure someone else answered: it leaves Today, quoted, with Undo
11
11
  * pmos mention looks <id> --who "<name>" --text "<their line>" [--on <ISO>] someone else may have answered: the line, quoted
12
+ * pmos mention names "<line>" [--json] name-links (A536): which names in a line link, and to which record
13
+ * pmos mention plain "<name>" [--undo] keep a name plain (it never links); --undo lets it link again
12
14
  * <id> is a conversation's id (pmos mention list prints it). Claude runs `draft` from the chat where the PM changes a reply ("Reply to
13
15
  * Arif"), and the rest after a source read: the Viewer shows each on its next read. Every mark is one line in
14
16
  * <runtime>/mentions/marks.jsonl with by: agent. This command posts nothing: the PM sends the reply where the mention is. */
@@ -17,7 +19,7 @@ const path = require('path');
17
19
  const stateRoot = require('./state-root');
18
20
  const store = require('./mention-store.js');
19
21
 
20
- const COMMANDS = { mention: ['list', 'draft', 'gist', 'nodraft', 'stands', 'watch', 'landed', 'looks', 'answered'] };
22
+ const COMMANDS = { mention: ['list', 'draft', 'gist', 'nodraft', 'stands', 'watch', 'landed', 'looks', 'answered', 'names', 'plain'] };
21
23
  const USAGE = [
22
24
  'usage: pmos mention list|draft|gist|nodraft|stands|watch|landed|looks|answered — Today\'s Mentions',
23
25
  ' pmos mention list the conversations: Your move, To read, Answered this week',
@@ -29,6 +31,8 @@ const USAGE = [
29
31
  ' pmos mention landed <id> --text "<Samuel’s tag landed.>" the watched promise landed',
30
32
  ' pmos mention looks <id> --who "<name>" --text "<their line>" [--on <ISO>] someone else may have answered: quote the line',
31
33
  ' pmos mention answered <id> --who "<name>" --text "<their line>" [--on <ISO>] you are sure someone else answered it: quote the line',
34
+ ' pmos mention names "<line>" which names in a line link to a person, a meeting or a document (Today draws the same)',
35
+ ' pmos mention plain "<name>" [--undo] keep a name plain: it never links (--undo lets it link again)',
32
36
  ' every command: [--json]',
33
37
  'This command never posts. You send the reply where the mention is.',
34
38
  ];
@@ -39,7 +43,7 @@ function parseArgs(argv) {
39
43
  const t = argv[i];
40
44
  if (!t.startsWith('--')) { out._.push(t); continue; }
41
45
  const key = t.slice(2);
42
- if (key === 'json' || key === 'help') out[key] = true;
46
+ if (key === 'json' || key === 'help' || key === 'undo') out[key] = true;
43
47
  else if ((key === 'settled' || key === 'open') && argv[i + 1] !== undefined) (out[key] = out[key] || []).push(argv[++i]);
44
48
  else if (argv[i + 1] !== undefined) out[key] = argv[++i];
45
49
  else out[key] = '';
@@ -70,6 +74,7 @@ function run(argv, { say = console.log, env = process.env, stateDir, cwd = proce
70
74
  for (const m of v.answered) say(row(m));
71
75
  return 0;
72
76
  }
77
+ if (sub === 'names' || sub === 'plain') return namesRun(sub, a, { dir, cwd, out });
73
78
  const id = a._[1];
74
79
  if (!id || !/^[0-9a-f]{12}$/.test(id)) { out({ ok: false, error: 'the conversation id is 12 hex characters (pmos mention list shows it)' }, '✗ the conversation id is 12 hex characters (pmos mention list shows it)'); return 2; }
75
80
  let text = a.text;
@@ -96,4 +101,33 @@ function run(argv, { say = console.log, env = process.env, stateDir, cwd = proce
96
101
  return 0;
97
102
  }
98
103
 
104
+ /** name-links (A536): the workspace's products (workspaces.json in the state folder), as the server lists them. */
105
+ function workspacesOf(dir) {
106
+ let reg = [];
107
+ try { reg = JSON.parse(fs.readFileSync(path.join(dir, 'workspaces.json'), 'utf8')); } catch { reg = []; }
108
+ const crypto = require('crypto');
109
+ return (Array.isArray(reg) ? reg : []).filter((w) => w && typeof w.root === 'string' && fs.existsSync(w.root)).map((w) => {
110
+ const root = path.resolve(w.root);
111
+ return { id: crypto.createHash('sha1').update(root).digest('hex').slice(0, 10), name: w.name || path.basename(root), root, ...(w.label ? { label: String(w.label) } : {}) };
112
+ });
113
+ }
114
+ function namesRun(sub, a, { dir, out }) {
115
+ const NL = require('./name-links.js');
116
+ const words = a._.slice(1).join(' ').trim();
117
+ if (!words) { out({ ok: false, error: sub === 'names' ? 'say the line: pmos mention names "<line>"' : 'say the name: pmos mention plain "<name>"' }, sub === 'names' ? '✗ say the line: pmos mention names "<line>"' : '✗ say the name: pmos mention plain "<name>"'); return 2; }
118
+ if (sub === 'plain') {
119
+ const r = NL.setPlain(dir, words, !a.undo);
120
+ if (!r.ok) { out(r, '✗ ' + r.error); return 1; }
121
+ out(r, a.undo ? `"${words}" links again where it names one record.` : `"${words}" stays plain from now on. Undo: pmos mention plain "${words}" --undo`);
122
+ return 0;
123
+ }
124
+ const r = NL.answer({ runtimeDir: dir, workspaceList: () => workspacesOf(dir) }, [words]);
125
+ const l = r.lines[0];
126
+ if (a.json) { out({ ok: true, ...l }); return 0; }
127
+ if (!l.spans.length) out(null, 'No name in this line links to one record.');
128
+ for (const s of l.spans) out(null, ` ${s.text} → ${s.kind} ${s.title}${s.meta ? ' · ' + s.meta : ''}`);
129
+ if (l.unsure.length) out(null, 'Stay plain (more than one record): ' + l.unsure.join(', '));
130
+ return 0;
131
+ }
132
+
99
133
  module.exports = { run, COMMANDS, USAGE };
@@ -0,0 +1,203 @@
1
+ 'use strict';
2
+ /* name-links.js — names in a line link to the real thing (initiative name-links, idea A536; board BatchMoreBDS panel 31, agreed 2026-11-25).
3
+ *
4
+ * link(text, records, { plain }?) PURE → { spans: [{ start, end, text, kind, id, title, meta, open, ws }], unsure: [name] }
5
+ * A name links when it resolves to exactly one record: a person's full name or first name (or a name handle), a meeting by its title or
6
+ * by "<words> meeting" (every word in one meeting's title), a document by its title. The longest name wins where two overlap, and a name
7
+ * that matches two records holds its place but stays plain (it goes to `unsure`). A one-word name links only when the line writes it
8
+ * with a capital letter, so "mark" never links to Mark. A name in `plain` never links. start and end index the original text.
9
+ * recordsOf(ctx) → [record] people (lib/people-store.js view), meeting notes (lib/notes.js list), documents
10
+ * (lib/doc-library.js library) of every product; cached 30 seconds
11
+ * record = { kind: 'person' | 'meeting' | 'document', id, title, names: [name], words?: [term], meta, open, ws }
12
+ * open what the page's opener needs: { note, ws } (Open the notes) · { doc: { ws, path } } (Open the document) · null (Ask PMOS)
13
+ * answer(ctx, texts) → { ok, lines: [{ spans, unsure }] } GET /api/name-links (lib/routes-today-log.js) and the CLI
14
+ * plainOf(rt) · setPlain(rt, name, on) the names the PM keeps plain: <runtime>/name-links/plain.json (`pmos mention plain`)
15
+ *
16
+ * The link carries the same data-ask="kind:id" stamp that "Ask about anything you press" reads (public/pm/ask-here-ctx.js idAt), so the
17
+ * one resolver names the record wherever the line is pressed.
18
+ *
19
+ * WHAT IT NEVER DOES. It calls no model, sends nothing and opens no network module. It never changes the words of a line. Every answer
20
+ * logs one [name-links] line. */
21
+ const fs = require('fs');
22
+ const path = require('path');
23
+
24
+ const TAG = '[name-links]';
25
+ const MAX_LINES = 40;
26
+ const MAX_TEXT = 400;
27
+ const TTL_MS = 30000;
28
+ const MEETING_WORDS = ['meeting', 'sync', 'call', 'standup', 'stand-up', 'catch-up', 'review'].map((w) => `[${w[0].toUpperCase()}${w[0]}]${w.slice(1)}`).join('|');
29
+ const STOP = new Set(['the', 'and', 'for', 'with', 'about', 'from', 'meeting', 'notes', 'note', 'sync', 'call', 'weekly', 'daily']);
30
+
31
+ const LETTER = /[\p{L}\p{N}]/u;
32
+ const clean = (s) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim();
33
+ const low = (s) => clean(s).toLowerCase();
34
+ const isUpper = (c) => !!c && c !== c.toLowerCase() && c === c.toUpperCase();
35
+ const wordsOf = (s) => (low(s).match(/[\p{L}\p{N}]+/gu) || []).filter((w) => w.length >= 2 && !STOP.has(w));
36
+ const keyOf = (r) => r.kind + ':' + r.id;
37
+
38
+ /** Every place `name` stands in `text` as whole words (case-insensitive). */
39
+ function placesOf(lowText, name) {
40
+ const out = [];
41
+ if (!name) return out;
42
+ let i = lowText.indexOf(name);
43
+ while (i >= 0) {
44
+ const a = lowText[i - 1], b = lowText[i + name.length];
45
+ if (!(a && LETTER.test(a)) && !(b && LETTER.test(b))) out.push(i);
46
+ i = lowText.indexOf(name, i + 1);
47
+ }
48
+ return out;
49
+ }
50
+
51
+ /** PURE. */
52
+ function link(text, records, o = {}) {
53
+ const t = String(text == null ? '' : text);
54
+ const lt = t.toLowerCase();
55
+ const plain = new Set([...(o.plain || [])].map(low));
56
+ const byName = new Map(); // a name, lower case → the records it names
57
+ for (const r of records || []) {
58
+ if (!r || !r.kind || !r.id) continue;
59
+ for (const n of new Set((r.names || []).map(low))) {
60
+ if (n.length < 3 || plain.has(n)) continue;
61
+ if (!byName.has(n)) byName.set(n, new Map());
62
+ byName.get(n).set(keyOf(r), r);
63
+ }
64
+ }
65
+ const found = [];
66
+ for (const [n, recs] of byName) {
67
+ for (const at of placesOf(lt, n)) {
68
+ const one = !/\s/.test(n);
69
+ if (one && !isUpper(t[at])) continue; // N2: a lowercase word is a word, not a name
70
+ found.push({ start: at, end: at + n.length, recs });
71
+ }
72
+ }
73
+ // "<words> meeting": the meeting whose title holds every one of the words before it ("the Roger meeting")
74
+ const meetings = (records || []).filter((r) => r && r.kind === 'meeting');
75
+ if (meetings.length) {
76
+ const re = new RegExp(`((?:\\p{Lu}[\\p{L}\\p{N}'’.-]*\\s+){1,3})(?:${MEETING_WORDS})(?![\\p{L}\\p{N}])`, 'gu');
77
+ let m;
78
+ while ((m = re.exec(t))) {
79
+ const lead = m[1].replace(/['’]s\s*$/i, ' ');
80
+ const want = wordsOf(lead);
81
+ // the words must be written as names (a capital first letter), so "Follow up on the meeting" names nothing
82
+ if (!want.length || !m[1].trim().split(/\s+/).every((w) => isUpper(w[0]))) continue;
83
+ const phrase = low(m[0]);
84
+ if (plain.has(phrase)) continue;
85
+ const recs = new Map();
86
+ for (const r of meetings) { const have = new Set(r.words || wordsOf(r.title)); if (want.every((w) => have.has(w))) recs.set(keyOf(r), r); }
87
+ if (recs.size) found.push({ start: m.index, end: m.index + m[0].length, recs });
88
+ }
89
+ }
90
+ found.sort((a, b) => (b.end - b.start) - (a.end - a.start) || a.start - b.start);
91
+ const taken = [], spans = [], unsure = [];
92
+ for (const f of found) {
93
+ if (taken.some(([s, e]) => f.start < e && s < f.end)) continue;
94
+ taken.push([f.start, f.end]); // an unsure name holds its place, so a shorter name inside it does not link instead
95
+ const words = t.slice(f.start, f.end);
96
+ if (f.recs.size !== 1) { unsure.push(words); continue; }
97
+ const r = [...f.recs.values()][0];
98
+ spans.push({ start: f.start, end: f.end, text: words, kind: r.kind, id: r.id, title: r.title, meta: r.meta || '', open: r.open || null, ws: r.ws || null });
99
+ }
100
+ spans.sort((a, b) => a.start - b.start);
101
+ return { spans, unsure: [...new Set(unsure)] };
102
+ }
103
+
104
+ /* ── the records ── */
105
+ const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
106
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
107
+ function dayWords(iso) {
108
+ const d = new Date(String(iso || ''));
109
+ return Number.isFinite(d.getTime()) ? `${DOW[d.getDay()]} ${d.getDate()} ${MON[d.getMonth()]}` : '';
110
+ }
111
+
112
+ /** People of every product: one record per full name (People is kept per repository, so one person can be in several). */
113
+ function peopleOf(list) {
114
+ const PS = require('./people-store.js');
115
+ const out = new Map();
116
+ for (const w of list) {
117
+ let v; try { v = PS.view(w.root); } catch { v = null; }
118
+ if (!v || !v.ok) continue;
119
+ for (const p of v.people || []) {
120
+ const name = clean(p.name);
121
+ if (!name || out.has(low(name))) continue;
122
+ const first = name.split(' ')[0];
123
+ const handles = (p.handles || []).filter((h) => h && h.kind === 'name').map((h) => clean(h.value));
124
+ out.set(low(name), { kind: 'person', id: String(p.id), title: name, names: [name, first !== name ? first : '', ...handles].filter(Boolean),
125
+ meta: [p.role, p.org].filter(Boolean).join(' · ') || 'in People', open: null, ws: w.id });
126
+ }
127
+ }
128
+ return [...out.values()];
129
+ }
130
+ /** Meeting notes (the PM's runtime folder; one list for every product). */
131
+ function meetingsOf(rt) {
132
+ const N = require('./notes.js');
133
+ let l; try { l = N.list(rt); } catch { return []; }
134
+ const out = [];
135
+ for (const n of (l && l.ok ? l.notes : []).slice(0, 300)) {
136
+ const title = clean(n.title);
137
+ if (!title || title === 'Untitled note') continue;
138
+ let people = 0;
139
+ try { const full = N.loadCached(rt, n.id); people = new Set(Object.values((full && full.speakers) || {}).map(low)).size; } catch { people = 0; }
140
+ const when = dayWords((n.meeting && n.meeting.start) || n.created_at);
141
+ out.push({ kind: 'meeting', id: String(n.id), title, names: title.length >= 4 ? [title] : [], words: wordsOf(title),
142
+ meta: [when, people > 1 ? people + ' people' : '', 'notes'].filter(Boolean).join(' · '), open: { note: String(n.id), ws: n.ws || '' }, ws: n.ws || null });
143
+ }
144
+ return out;
145
+ }
146
+ /** Documents of every product: a title of two words or more (a one-word title is a word, not a name). */
147
+ function documentsOf(list, rt) {
148
+ const DL = require('./doc-library.js');
149
+ const out = [];
150
+ for (const w of list) {
151
+ let lib; try { lib = DL.library(w.root, { stateDir: rt }); } catch { lib = null; }
152
+ if (!lib || !lib.ok) continue;
153
+ for (const f of lib.files || []) {
154
+ const title = clean(f.title);
155
+ if (!title || title === f.path || title.split(' ').length < 2 || title.length < 8) continue;
156
+ out.push({ kind: 'document', id: String(f.path), title, names: [title], meta: [f.type || 'Document', w.label || w.name || w.id].filter(Boolean).join(' · '),
157
+ open: { doc: { ws: w.id, path: String(f.path) } }, ws: w.id });
158
+ }
159
+ }
160
+ return out;
161
+ }
162
+
163
+ const cache = new Map(); // runtime folder → { at, records }
164
+ function recordsOf(ctx, o = {}) {
165
+ const rt = ctx.runtimeDir;
166
+ const hit = cache.get(rt);
167
+ const now = Date.now();
168
+ if (!o.fresh && hit && now - hit.at < TTL_MS) return hit.records;
169
+ const seen = new Set();
170
+ const list = ((ctx.workspaceList && ctx.workspaceList()) || []).filter((w) => w && w.root && !seen.has(w.root) && seen.add(w.root));
171
+ const records = [...peopleOf(list), ...meetingsOf(rt), ...documentsOf(list, rt)];
172
+ cache.set(rt, { at: now, records });
173
+ return records;
174
+ }
175
+
176
+ /* ── the names the PM keeps plain ── */
177
+ const plainFile = (rt) => path.join(rt, 'name-links', 'plain.json');
178
+ function plainOf(rt) {
179
+ try { const v = JSON.parse(fs.readFileSync(plainFile(rt), 'utf8')); return Array.isArray(v) ? v.map(clean).filter(Boolean) : []; } catch { return []; }
180
+ }
181
+ function setPlain(rt, name, on = true) {
182
+ const n = clean(name).slice(0, 80);
183
+ if (n.length < 3) return { ok: false, error: 'say the name, three letters or more' };
184
+ const now = plainOf(rt).filter((x) => low(x) !== low(n));
185
+ if (on) now.push(n);
186
+ fs.mkdirSync(path.dirname(plainFile(rt)), { recursive: true });
187
+ const tmp = plainFile(rt) + '.tmp';
188
+ fs.writeFileSync(tmp, JSON.stringify(now, null, 1));
189
+ fs.renameSync(tmp, plainFile(rt));
190
+ console.info(TAG + ' plain ' + (on ? 'kept' : 'taken back') + ' names=' + now.length);
191
+ return { ok: true, plain: now };
192
+ }
193
+
194
+ function answer(ctx, texts, o = {}) {
195
+ const lines = (Array.isArray(texts) ? texts : [texts]).slice(0, MAX_LINES).map((x) => String(x == null ? '' : x).slice(0, MAX_TEXT));
196
+ const records = recordsOf(ctx, o);
197
+ const plain = plainOf(ctx.runtimeDir);
198
+ const out = lines.map((x) => link(x, records, { plain }));
199
+ console.info(TAG + ' lines=' + out.length + ' links=' + out.reduce((n, l) => n + l.spans.length, 0) + ' unsure=' + out.reduce((n, l) => n + l.unsure.length, 0) + ' records=' + records.length);
200
+ return { ok: true, lines: out };
201
+ }
202
+
203
+ module.exports = { TAG, MAX_LINES, link, recordsOf, peopleOf, meetingsOf, documentsOf, answer, plainOf, setPlain, wordsOf, _cache: cache };
@@ -160,6 +160,9 @@ const VERBS = Object.freeze({
160
160
  // Not a pm-os-absorb verb (run: null): initiative next-hire-draft (job #1876, A75) added it through the same table.
161
161
  hire: Object.freeze({ module: 'hire-draft.js', run: null, guide: 'cli.md',
162
162
  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)' }),
163
+ // Not a pm-os-absorb verb (run: null): initiative connector-data (job #1920, A150) added it through the same table.
164
+ connectors: Object.freeze({ module: 'connectors-cli.js', run: null, guide: 'cli.md',
165
+ help: 'pmos connectors data [<connector>] — what PMOS reads and writes through each connector, and what leaves this computer (pmos connectors help)' }),
163
166
  // Not a pm-os-absorb verb (run: null): initiative press-release-faq (bet A362) added it through the same table.
164
167
  'press-release': Object.freeze({ module: 'press-release-cli.js', run: null, guide: 'cli.md',
165
168
  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)' }),
@@ -152,6 +152,7 @@ const MODULES = Object.freeze([
152
152
  'routes-principles', // bet A352: a product's principles drafted from its decisions, kept or dropped on the Board (records principles.jsonl; page-press POST)
153
153
  'routes-prefs', // bet A461: view preferences that follow the person to the phone and other browsers (runtime view-prefs.json; page-press POST)
154
154
  'routes-live-rows', // bet A458: chat-made task changes streamed to open pages (runtime live-events.jsonl; read-only event stream)
155
+ 'routes-connector-data', // connector-data (A150): what each connector reads and writes, from lib/connector-data.js (read only)
155
156
  ]);
156
157
  const PM_DIR = path.join(__dirname, '..', 'public', 'pm');
157
158
  const MODULE_NAME = /^[a-z0-9][a-z0-9-]*\.js$/;
@@ -17,6 +17,9 @@
17
17
  * GET /api/autonomy/kinds → { ok, kinds: [{ kind, label, made, kept, undone, auto, set, way, until }], showUntil }
18
18
  * How Claude decides (Settings › Claude, boards AwG and AwG2), over every product's state folders: lib/autonomy.js kindsOf. The PM
19
19
  * sets a kind's way with POST /api/settings { key: 'claude.ways', value: { kind: quiet | show | ask } }.
20
+ * GET /api/autonomy/alone → { ok, off, rows: [{ key, what, pmos, since, fixed, decision }], stops, line }
21
+ * What PMOS does alone (Settings › How PMOS decides › What PMOS does alone, board BatchPagesDS 2): lib/does-alone.js over the same
22
+ * state folders and ways as kinds. Read-only.
20
23
  *
21
24
  * Every POST passes pm-guard requirePagePress. An Undo is a correction (the north star) and a setback of its job (lib/autonomy.js).
22
25
  */
@@ -147,6 +150,12 @@ async function handle(req, res, url, ctx) {
147
150
  const r = require('./coming-up.js').aheadOf(w.root, ini, { title: text(url.searchParams.get('title')), schedules });
148
151
  return send({ status: 200, body: { ok: true, ws: w.id, ini, ...r } });
149
152
  }
153
+ if (sub === 'alone' && req.method === 'GET') {
154
+ const list = (ctx.workspaceList ? ctx.workspaceList() : []).filter((w) => w && w.root && !w.linked);
155
+ const dirs = [];
156
+ for (const w of list) for (const d of dirsOf(ctx, w)) if (!dirs.includes(d)) dirs.push(d);
157
+ return send({ status: 200, body: require('./does-alone.js').aloneOf(dirs, { settingsDir: ctx.runtimeDir || null }) });
158
+ }
150
159
  if (sub === 'kinds' && req.method === 'GET') {
151
160
  const list = (ctx.workspaceList ? ctx.workspaceList() : []).filter((w) => w && w.root && !w.linked);
152
161
  const dirs = [];
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+ /* routes-connector-data.js — GET /api/connector-data (initiative connector-data, idea A150): what each connector reads and writes, from the
3
+ * one list in lib/connector-data.js, with each read switch's state from Settings and the time of the last stored read. Read only: a switch
4
+ * is saved through POST /api/proactive/settings, as before. Settings › Connectors (pm/connector-data.js) and `pmos connectors data` read it. */
5
+ const CD = require('./connector-data.js');
6
+
7
+ module.exports = {
8
+ prefixes: ['/api/connector-data'],
9
+ handle: async (req, res, url, ctx) => {
10
+ if (url.pathname !== '/api/connector-data') return false;
11
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
12
+ if (!ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'no runtime folder' }, 500); return true; }
13
+ try { ctx.json(res, { ok: true, connectors: CD.viewAll(ctx.runtimeDir) }); }
14
+ catch (e) { ctx.json(res, { ok: false, error: 'the connector list could not be read: ' + String((e && e.message) || e).slice(0, 200) }, 500); }
15
+ return true;
16
+ },
17
+ };
@@ -10,6 +10,8 @@
10
10
  * POST /api/today-log/file { key, day, ws, ini } → { ok, filed } file a typed line to another initiative, or ini null: Not filed
11
11
  * An added line that clearly names one open initiative is filed there by itself (lib/capture-file.js): the answer's entry carries
12
12
  * `filed`, and a task line also becomes a task on that initiative's board. A change deletes the task the earlier filing added.
13
+ * GET /api/name-links?t=<line>&t=<line>… → { ok, lines: [{ spans, unsure }] } name-links (A536): the names in each line that resolve to
14
+ * one person, meeting or document (lib/name-links.js), at most 40 lines. Read only.
13
15
  *
14
16
  * The day is the PM's local day, sent by the page. Every POST passes pm-guard requirePagePress: the page only. A mark changes only the
15
17
  * log: done on a task or an item of the PM is sent to that record's own route by the page, and the mark is the log's line beside it.
@@ -65,11 +67,16 @@ async function fileRoute(req, res, ctx) {
65
67
  }
66
68
 
67
69
  module.exports = {
68
- prefixes: ['/api/today-log'],
70
+ prefixes: ['/api/today-log', '/api/name-links'],
69
71
  fileOf,
70
72
  handle: async (req, res, url, ctx) => {
71
73
  const p = url.pathname;
72
74
  if (!ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'PMOS has no state folder here, so Today cannot keep a log' }, 503); return true; }
75
+ if (p === '/api/name-links') {
76
+ if (req.method !== 'GET') return false;
77
+ ctx.json(res, require('./name-links.js').answer(ctx, url.searchParams.getAll('t')));
78
+ return true;
79
+ }
73
80
  if (p === '/api/today-log' && req.method === 'GET') {
74
81
  const day = url.searchParams.get('day') || localDay();
75
82
  if (!TL.DAY_RE.test(day)) { ctx.json(res, { ok: false, error: 'day is YYYY-MM-DD' }, 400); return true; }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.823.0",
3
+ "version": "0.825.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.823.0",
9
+ "version": "0.825.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.823.0",
3
+ "version": "0.825.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",
@@ -218,7 +218,7 @@ export function tableHtml(order, o = {}) {
218
218
  const table = R.length ? `<table class="pm-table wk-bkt${o.picking ? ' picking' : ''}"><thead><tr><th class="wk-rk">Rank</th><th>Item</th><th>Who</th><th>State</th><th>Source</th><th>Last change</th><th class="wk-ac" aria-label="Actions"></th></tr></thead><tbody>${body}</tbody></table>`
219
219
  : `<p class="pm-meta">${order.length ? 'Nothing here.' : 'Nothing waits outside the sprint.'}</p>`;
220
220
  const foot = R.length && drag ? '<p class="pm-meta">Drag a row to change its rank. The rank is one list across initiatives; groups only show where each item belongs.</p>' : '';
221
- return `<section class="pm-block wk-blk wk-bk" aria-label="Backlog"><div class="head"><h2 class="pm-h">Backlog</h2><span class="sp"></span>${tabs}${menu}${tune}</div>${cap}${o.said || ''}${table}${foot}${o.mode || ''}</section>`;
221
+ return `<section class="pm-block wk-blk wk-bk" aria-label="Backlog"><div class="head"><h2 class="pm-h">Backlog</h2><span class="sp"></span>${tabs}${menu}${tune}</div>${cap}${o.above || ''}${o.said || ''}${table}${foot}${o.mode || ''}</section>`;
222
222
  }
223
223
  function rowHtml(t, o, drag) {
224
224
  const u = t.ws + '|' + t.board + '|' + t.id, ck = o.sel && o.sel.has(u);
@@ -21,7 +21,8 @@ import * as WS from './work-select.js'; // the bulk move with one Undo, shared
21
21
  import * as IF from './inline-fields.js'; // a task's sprint and priority, set in the row (initiative inline-sprint-priority)
22
22
  import * as LE from './live-edit.js'; // a task's status or days show at once in the list, before it is read again; a failed save is put back
23
23
  import { noteUse } from './use-log.js'; // the sprint draft's presses, counted on this computer only (sprint-draft-capacity)
24
- import * as LV from './line-view.js'; // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
24
+ import * as LV from './line-view.js';
25
+ import * as LB from './list-balance.js'; // the balance meter under the Backlog header (bet A448, board BalanceDS) // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
25
26
  import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
26
27
 
27
28
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
@@ -219,6 +220,7 @@ function draw() {
219
220
  }
220
221
  /* ── the Backlog tab (WorkBacklogDS): Where it stands with one Suggestion, then the Backlog block ───────────────────────── */
221
222
  let ORDER = []; // the backlog in rank order, as drawn last
223
+ let BAL = ''; // the kind a legend press of the balance meter shows only ('' all)
222
224
  const backlogOf = () => DATA.tasks.filter(BD.inBacklog).filter((t) => BM.keeps(t, new Set(), PICK, partB()));
223
225
  /** The Suggestion: the sprint draft at the team's pace when PMOS knows it for one product (sprint-draft-capacity, A471), else the old
224
226
  * pull of the top 4. A draft whose sprint is already full suggests nothing (Where it stands says why). */
@@ -239,6 +241,11 @@ function drawBk() {
239
241
  const B = backlogOf(), order = BD.ranked(B, DATA.rank, DATA.inis);
240
242
  ORDER = order;
241
243
  const rank = new Map(order.map((t, i) => [t.id, i]));
244
+ // the balance meter (BalanceDS): the mix of the backlog by each task's own type; a legend press shows only that kind (the rank stays whole)
245
+ const MB = LB.balanceOf(B);
246
+ if (BAL && !MB.parts.some((p) => p.key === BAL)) BAL = '';
247
+ const meter = LB.meterHtml(MB, { on: BAL, label: 'Mix of the backlog' });
248
+ const rows = meter && BAL ? order.filter((t) => LB.kindOf(t) === BAL) : order;
242
249
  const sh = BM.showingLine(DATA.tasks, { chips: new Set(), pick: PICK, partB: partB() });
243
250
  const showing = sh ? `<p class="pm-meta">${esc(sh.text)}${sh.hidden ? ` · ${sh.hidden} hidden` : ''} · <button type="button" class="wk-sa" data-bkall>Show all</button></p>` : '';
244
251
  const said = SAID ? `<p class="pm-meta" role="status">${esc(SAID.text)}${SAID.undo ? ' <button type="button" class="wk-sa" data-bksaid>Undo</button>' : ''}</p>` : '';
@@ -250,9 +257,10 @@ function drawBk() {
250
257
  });
251
258
  host.innerHTML = (DATA.err ? `<p class="bk-err">${esc(DATA.err)}</p>` : '')
252
259
  + BD.standsHtml(B, { today: DATA.today, next: DATA.next, pull: pullFor(order), draft: draftFor(order) })
253
- + BD.tableHtml(order, { tab: BV.tab, group: BV.group, menu: BMENU, today: DATA.today, rank, sel: SEL, picking: host.classList.contains('picking'),
260
+ + BD.tableHtml(rows, { above: meter, tab: BV.tab, group: BV.group, menu: BMENU, today: DATA.today, rank, sel: SEL, picking: host.classList.contains('picking'),
254
261
  act: (t) => actHtml(t, BM.groupOf(t, partB())), stateOf: (t) => { if (!t.agent) return null; const x = BM.stateOf(t); return { text: x.text, tone: x.tone, title: x.text + (x.note ? ' · ' + x.note : '') }; },
255
262
  groupsPmos: pmosGroups, said: showing + said, mode, inline: true });
263
+ LB.sizeBars(host);
256
264
  drawBar();
257
265
  }
258
266
  const saveBv = () => put('pmos.work.backlog', BV);
@@ -260,6 +268,7 @@ const saveBv = () => put('pmos.work.backlog', BV);
260
268
  async function bkPress(e) {
261
269
  const t0 = e.target, hit = (a) => t0.closest('[' + a + ']');
262
270
  let b;
271
+ if ((b = t0.closest('.lb-m [data-balance-kind]'))) { const k = b.dataset.balanceKind; BAL = BAL === k ? '' : k; draw(); const n = host.querySelector(`.lb-m button[data-balance-kind="${k}"]`); if (n) n.focus(); return true; }
263
272
  if ((b = hit('data-bktab'))) { BV.tab = b.dataset.bktab; saveBv(); draw(); const n = host.querySelector(`[data-bktab="${BV.tab}"]`); if (n) n.focus(); return true; }
264
273
  if (hit('data-bkgroup')) { BMENU = !BMENU; draw(); const n = host.querySelector('[data-bkgrp][aria-checked="true"]'); if (BMENU && n) n.focus(); return true; }
265
274
  if ((b = hit('data-bkgrp'))) { BV.group = b.dataset.bkgrp; BMENU = false; saveBv(); draw(); const n = host.querySelector('[data-bkgroup]'); if (n) n.focus(); return true; }
@@ -200,3 +200,18 @@ body.bd-page.bk-on [id="bkBody"] { display: flex; flex-direction: column; gap: v
200
200
  .bd-pl2-l { display: flex; justify-content: space-between; font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--muted); }
201
201
  .bd-pl2.alert .bd-pl2-l span:last-child { color: var(--alert); }
202
202
  }
203
+
204
+ /* the balance meter under a list header (bet A448, board BalanceDS): the Bar and its Legend, the ✦ Said line only when over the line.
205
+ The bar's parts take the four series tokens in order, as the legend's swatches do. */
206
+ .lb-m { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
207
+ .lb-m .pm-bar { height: 6px; gap: 2px; }
208
+ .lb-m .pm-bar span { flex: var(--bd-lb-n, 1) 1 0; }
209
+ .lb-m .pm-bar .lb-blue { background: var(--blue); }
210
+ .lb-m .pm-bar .lb-leaf { background: var(--leaf); }
211
+ .lb-m .pm-bar .lb-muted { background: var(--muted); }
212
+ .lb-m .pm-bar .lb-alert { background: var(--alert); }
213
+ .lb-m .pm-leg { flex-wrap: wrap; gap: 4px 8px; }
214
+ .lb-m .lb-said { max-width: none; margin: 0; color: var(--muted); }
215
+ @media (max-width: 760px) {
216
+ .lb-m .lb-said span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
217
+ }
@@ -417,7 +417,7 @@ export function listHtml(rows, o = {}) {
417
417
  + (tl ? `<div class="pm-tabs" role="tablist" aria-label="Scale of the timeline">${scale}</div>${nav('back', 'Earlier', I.back)}${nav('today', 'Go to today', I.today)}${nav('on', 'Later', I.on)}` : '')
418
418
  + `<button type="button" class="pm-btn" data-wkmenu aria-haspopup="dialog" aria-label="Choose columns, sort and filter" title="Choose columns, sort and filter">${SV(I.tune, 16)}${filterCount() ? `<i class="wk-fc" aria-hidden="true">${filterCount()}</i>` : ''}</button></div>`;
419
419
  const ncol = 1 + keys.length + (tl ? 1 : 0);
420
- let h = `<section class="pm-block wk-blk" aria-label="Initiatives">${head}${showingHtml(every.length - rows.length)}`
420
+ let h = `<section class="pm-block wk-blk" aria-label="Initiatives">${head}${o.above || ''}${showingHtml(every.length - rows.length)}`
421
421
  + `<div class="wk-tw"><table class="pm-table wk${tl ? ' has-x' : ''}" aria-label="Initiatives"><colgroup><col class="c-title">${keys.map((k) => `<col class="c-${k}">`).join('')}${tl ? '<col class="c-x">' : ''}</colgroup>`
422
422
  + `<thead><tr>${sortHd('title', 'Initiative')}${keys.map((k) => sortHd(k, byK[k].n)).join('')}${tlHead}</tr></thead><tbody>`;
423
423
  const row = (r) => `<tr class="wk-i${o.sel === r.key ? ' sel' : ''}${CARD === r.key ? ' hov' : ''}${isClosed(r) ? ' cl' : ''}" tabindex="0" data-key="${esc(r.key)}" aria-label="${esc(r.title + (keys.length ? ', ' + words(r, keys, oo) : ''))}">`
@@ -0,0 +1,47 @@
1
+ /* pm/connector-data.js — Settings › Connectors › one connector's page: what PMOS reads, what it writes, what leaves this computer
2
+ * (initiative connector-data, idea A150; board ConnDataDS). PURE: no DOM, no fetch. The list is lib/connector-data.js, served by
3
+ * GET /api/connector-data; pm/cozy-settings.js fetches it, draws the rows and the page with these, and saves a read switch through
4
+ * POST /api/proactive/settings (data-ev-src, the switch the row had before).
5
+ *
6
+ * SUB the sub-page key prefix: T.sub = 'cd:<id>'
7
+ * findView(views, label) the view a connected connector's name backs (its match), or null
8
+ * isConnected(view, list) true when a connector the session has backs it (Atlassian backs Jira and Confluence)
9
+ * openBtn(view) the row's icon-only button that opens the page (a label for screen readers)
10
+ * ago(iso, now) "12 min ago", "3 h ago", "2 days ago"
11
+ * pageHtml(view, { now }) the page: Back, the name, the last read, then the three parts
12
+ * Zero is silence: a connector that is not connected keeps only its + (pm/cozy-settings.js), never a row line, a switch or this page. */
13
+ import { esc, svg } from './cozy-evui.js';
14
+ const icon = (d, w = 18) => svg(d, w);
15
+ const CHEV = 'M10 7l5 5-5 5', BACK = 'M19 12H5M11 6l-6 6 6 6', LOCK = 'M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6z';
16
+
17
+ export const SUB = 'cd:';
18
+ const labelOf = (name) => String(name || '').replace(/^claude\.ai\s+/i, '').trim();
19
+ const re = (v) => { try { return new RegExp(v.match, 'i'); } catch { return null; } };
20
+ export const findView = (views, label) => (Array.isArray(views) ? views : []).find((v) => { const r = re(v); return r && r.test(labelOf(label)); }) || null;
21
+ export const isConnected = (v, list) => { const r = v && re(v); return !!r && (Array.isArray(list) ? list : []).some((c) => r.test(labelOf((c && (c.label || c.name)) || c))); };
22
+
23
+ export const openBtn = (v) => `<button type="button" class="ev-ib pm-btn" data-ev-cdata="${esc(v.id)}" aria-label="${esc('What PMOS reads and writes in ' + v.name)}" title="${esc('What PMOS reads and writes')}">${icon(CHEV)}</button>`;
24
+
25
+ export function ago(iso, now = Date.now()) {
26
+ const t = Date.parse(iso || ''); if (!Number.isFinite(t)) return '';
27
+ const m = Math.max(0, Math.round((now - t) / 60000));
28
+ return m < 1 ? 'just now' : m < 60 ? `${m} min ago` : m < 48 * 60 ? `${Math.round(m / 60)} h ago` : `${Math.round(m / 1440)} days ago`;
29
+ }
30
+
31
+ const swHtml = (r, name) => `<button type="button" class="pm-switch" role="switch" aria-checked="${!!r.on}" aria-label="${esc(r.what + ' (' + name + ')')}" data-ev-src="${esc(r.switch)}"></button>`;
32
+ const readRow = (r, name) => `<div class="ev-trow ev-cd-read"><div class="ev-tx ev-grow"><b>${esc(r.what)}</b><p class="pm-meta">${esc(r.detail)}${r.switch ? '' : ' · Read while connected'}</p></div>${r.switch ? swHtml(r, name) : ''}</div>`;
33
+
34
+ export function pageHtml(v, { now = Date.now() } = {}) {
35
+ if (!v) return '';
36
+ const last = v.lastRead && ago(v.lastRead.at, now);
37
+ const meta = last ? `<span class="pm-meta">last read ${esc(last)}${v.lastRead.items ? ` · ${v.lastRead.items} ${v.lastRead.items === 1 ? 'item' : 'items'}` : ''}</span>` : '';
38
+ const hasSw = v.reads.some((r) => r.switch);
39
+ return `<div class="ev-cd" data-ev-cd="${esc(v.id)}">`
40
+ + `<div class="ev-dr-hd"><button type="button" class="ev-ib pm-btn" data-ev-sub="" aria-label="Back to Connectors" title="Back">${icon(BACK)}</button><h4 class="ev-grow">${esc(v.name)}</h4>${meta}</div>`
41
+ + `<div class="ev-cn-sec"><b class="ev-lbl">What PMOS reads</b></div>${hasSw ? '<p class="pm-meta">A switch turns a read off. Off means PMOS stops reading it and says so where it was used.</p>' : ''}`
42
+ + `<div class="ev-cn-grp">${v.reads.map((r) => readRow(r, v.name)).join('')}</div>`
43
+ + `<div class="ev-cn-sec"><b class="ev-lbl">What PMOS writes</b></div>`
44
+ + (v.writes.length ? `<ul class="ev-cd-list">${v.writes.map((w) => `<li>${esc(w)}</li>`).join('')}</ul>` : '<p class="pm-meta">Nothing. A reply PMOS drafts stays a draft you send yourself.</p>')
45
+ + `<div class="ev-cn-sec"><b class="ev-lbl">What leaves this computer</b></div><p class="pm-meta ev-cd-leaves">${icon(LOCK, 14)} ${esc(v.leaves)}</p>`
46
+ + '</div>';
47
+ }