create-pmos 0.824.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 (35) hide show
  1. package/package.json +78 -26
  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 +77 -12
  7. package/workspace/guide/cli.md +9 -0
  8. package/workspace/guide/home.md +1 -0
  9. package/workspace/guide/settings-and-switches.md +2 -0
  10. package/workspace/lib/autonomy-cli.js +14 -2
  11. package/workspace/lib/connector-data.js +138 -0
  12. package/workspace/lib/connectors-cli.js +6 -0
  13. package/workspace/lib/does-alone.js +67 -0
  14. package/workspace/lib/mention-cli.js +36 -2
  15. package/workspace/lib/name-links.js +203 -0
  16. package/workspace/lib/pmos-verbs.js +3 -0
  17. package/workspace/lib/route-modules.js +1 -0
  18. package/workspace/lib/routes-autonomy.js +9 -0
  19. package/workspace/lib/routes-connector-data.js +17 -0
  20. package/workspace/lib/routes-today-log.js +8 -1
  21. package/workspace/package-lock.json +2 -2
  22. package/workspace/package.json +1 -1
  23. package/workspace/public/pm/connector-data.js +47 -0
  24. package/workspace/public/pm/cozy-name-links.js +118 -0
  25. package/workspace/public/pm/cozy-settings.js +42 -7
  26. package/workspace/public/pm/cozy-today-app.js +26 -0
  27. package/workspace/public/pm/cozy-today-page.css +5 -0
  28. package/workspace/public/pm/cozy-today-view.js +8 -3
  29. package/workspace/public/pm/cozy-today.css +9 -0
  30. package/workspace/public/pm/home-chat.js +16 -1
  31. package/workspace/public/pm/home-hold.js +121 -0
  32. package/workspace/test-lists/connector-data.json +9 -0
  33. package/workspace/test-lists/does-alone.json +9 -0
  34. package/workspace/test-lists/hold-to-talk.json +9 -0
  35. package/workspace/test-lists/name-links.json +9 -0
@@ -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.824.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.824.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.824.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",
@@ -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
+ }
@@ -0,0 +1,118 @@
1
+ /* pm/cozy-name-links.js — names in a line link to the real thing (initiative name-links, idea A536; board BatchMoreBDS panel 31, agreed by Wawan
2
+ * 2026-11-25). The server finds the names (lib/name-links.js, GET /api/name-links); this module draws them and their card.
3
+ *
4
+ * linkedHtml(text, spans, esc) → html PURE. The line's own words, escaped, with each span (start, end on the text) as one link. Nothing
5
+ * else on the line changes: the text of the html is the text of the line.
6
+ * linkAttrs(span) → the link's attributes: data-ask="kind:id" (the stamp "Ask about anything you press" reads, pm/ask-here-ctx.js idAt),
7
+ * and what the card shows (data-nl-title, data-nl-meta, data-nl-open)
8
+ * PRESS[kind] → [label, icon path] the card's one press: Open the notes · Open the document · Ask PMOS about the person
9
+ * wire(root, { openItem?, askAt? }) a pointer resting on a link (a desk), or a tap or Enter on it, opens the small card; Esc, a press
10
+ * elsewhere or leaving the link and the card closes it. Each card open notes `nameLinkOpen`.
11
+ * An unsure name (two records) comes back from the server as plain text, so it is never drawn here. */
12
+ import { noteUse } from './use-log.js';
13
+
14
+ const ESC = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
15
+ export const PRESS = {
16
+ meeting: ['Open the notes', 'M4 5h16v11H9l-5 4z'],
17
+ document: ['Open the document', 'M6 3h9l4 4v14H6zM14 3v5h5'],
18
+ person: ['Ask PMOS about them', 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z'],
19
+ };
20
+ const KIND_ASK = { meeting: 'meeting', document: 'document', person: 'person' };
21
+
22
+ export function linkAttrs(s, esc = ESC) {
23
+ return `class="nl-a" role="button" tabindex="0" aria-haspopup="dialog" data-ask="${esc((KIND_ASK[s.kind] || s.kind) + ':' + s.id)}"`
24
+ + ` data-nl-kind="${esc(s.kind)}" data-nl-title="${esc(s.title || s.text)}" data-nl-meta="${esc(s.meta || '')}"`
25
+ + (s.open ? ` data-nl-open="${esc(JSON.stringify(s.open))}"` : '') + (s.ws ? ` data-ws="${esc(s.ws)}"` : '');
26
+ }
27
+
28
+ /** PURE. */
29
+ export function linkedHtml(text, spans, esc = ESC) {
30
+ const t = String(text == null ? '' : text);
31
+ let h = '', at = 0;
32
+ for (const s of (spans || []).slice().sort((a, b) => a.start - b.start)) {
33
+ // a span that no longer fits the words (the line changed since it was read) is left out, never forced
34
+ if (!(s.start >= at && s.end > s.start && s.end <= t.length) || (s.text && t.slice(s.start, s.end) !== s.text)) continue;
35
+ h += esc(t.slice(at, s.start)) + `<span ${linkAttrs(s, esc)}>${esc(t.slice(s.start, s.end))}</span>`;
36
+ at = s.end;
37
+ }
38
+ return h + esc(t.slice(at));
39
+ }
40
+
41
+ const S = { card: null, link: null, timer: 0, off: null };
42
+ function close() {
43
+ clearTimeout(S.timer);
44
+ if (S.card) S.card.remove();
45
+ if (S.link) S.link.setAttribute('aria-expanded', 'false');
46
+ S.card = null; S.link = null;
47
+ if (S.off) { S.off(); S.off = null; }
48
+ }
49
+ function show(a, o, focus) {
50
+ if (S.link === a && S.card) return;
51
+ close();
52
+ const kind = a.getAttribute('data-nl-kind') || '';
53
+ const [label, icon] = PRESS[kind] || PRESS.person;
54
+ const title = a.getAttribute('data-nl-title') || a.textContent;
55
+ const card = document.createElement('div');
56
+ card.className = 'pm-menu nl-card';
57
+ card.setAttribute('role', 'dialog');
58
+ card.setAttribute('aria-label', title);
59
+ card.innerHTML = `<div class="nl-h"><b>${ESC(title)}</b><span class="pm-meta">${ESC(a.getAttribute('data-nl-meta') || '')}</span></div>`
60
+ + `<button type="button" role="menuitem"><svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${icon}"/></svg>${ESC(kind === 'person' ? 'Ask PMOS about ' + title.split(' ')[0] : label)}</button>`;
61
+ document.body.appendChild(card);
62
+ const b = a.getBoundingClientRect();
63
+ card.style.top = Math.max(8, Math.min(innerHeight - card.offsetHeight - 8, b.bottom + 6)) + 'px';
64
+ card.style.left = Math.max(8, Math.min(innerWidth - card.offsetWidth - 8, b.left)) + 'px';
65
+ S.card = card; S.link = a;
66
+ a.setAttribute('aria-expanded', 'true');
67
+ noteUse('nameLinkOpen');
68
+ card.querySelector('button').addEventListener('click', () => { close(); press(a, kind, title, o); });
69
+ card.addEventListener('pointerleave', (e) => { if (e.pointerType === 'mouse' && !a.contains(e.relatedTarget)) later(); });
70
+ card.addEventListener('pointerenter', () => clearTimeout(S.timer));
71
+ const out = (e) => { if (S.card && !S.card.contains(e.target) && !a.contains(e.target)) close(); };
72
+ const key = (e) => { if (e.key === 'Escape' && S.card) { e.stopPropagation(); const l = S.link; close(); if (l) l.focus(); } };
73
+ addEventListener('pointerdown', out, true); addEventListener('keydown', key, true);
74
+ S.off = () => { removeEventListener('pointerdown', out, true); removeEventListener('keydown', key, true); };
75
+ if (focus) card.querySelector('button').focus();
76
+ }
77
+ function later() { clearTimeout(S.timer); S.timer = setTimeout(close, 300); }
78
+ async function press(a, kind, title, o) {
79
+ let open = null;
80
+ try { open = JSON.parse(a.getAttribute('data-nl-open') || 'null'); } catch { open = null; }
81
+ if (kind === 'person' || !open) { // a person has no page of their own: the same Ask card a right-click opens, about them
82
+ const M = o.askAt ? { open: o.askAt } : await import('./ask-here.js');
83
+ M.open(a, {});
84
+ return;
85
+ }
86
+ const item = { id: a.getAttribute('data-ask') || '', kind: kind === 'meeting' ? 'meeting' : 'doc', name: title, open };
87
+ const L = o.openItem ? { openItem: o.openItem } : await import('./library-open.js');
88
+ L.openItem(item, {});
89
+ }
90
+
91
+ /** One wiring per page root; a redraw keeps it (the listeners sit on the root, not on the links). */
92
+ export function wire(root, o = {}) {
93
+ if (!root || root.__nlWired) return;
94
+ root.__nlWired = true;
95
+ root.addEventListener('pointerover', (e) => {
96
+ const a = e.target.closest && e.target.closest('.nl-a');
97
+ if (!a || e.pointerType !== 'mouse') return;
98
+ clearTimeout(S.timer);
99
+ S.timer = setTimeout(() => show(a, o, false), 250);
100
+ });
101
+ root.addEventListener('pointerout', (e) => {
102
+ const a = e.target.closest && e.target.closest('.nl-a');
103
+ if (!a || e.pointerType !== 'mouse' || a.contains(e.relatedTarget) || (S.card && S.card.contains(e.relatedTarget))) return;
104
+ if (S.link === a) later(); else clearTimeout(S.timer);
105
+ });
106
+ root.addEventListener('click', (e) => {
107
+ const a = e.target.closest && e.target.closest('.nl-a');
108
+ if (!a) return;
109
+ e.preventDefault(); e.stopPropagation();
110
+ if (S.link === a && S.card) close(); else show(a, o, e.detail === 0);
111
+ });
112
+ root.addEventListener('keydown', (e) => {
113
+ const a = e.target.closest && e.target.closest('.nl-a');
114
+ if (!a || (e.key !== 'Enter' && e.key !== ' ')) return;
115
+ e.preventDefault(); e.stopPropagation();
116
+ show(a, o, true);
117
+ });
118
+ }