create-pmos 0.383.0 → 0.384.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.383.0",
3
+ "version": "0.384.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": {
@@ -32,6 +32,23 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.384.0",
37
+ "at": "2026-10-21T13:39:28.616Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 993,
42
+ "t": "A Work item from the brief opens on its source",
43
+ "s": "A Work item from the brief opens on its source"
44
+ },
45
+ {
46
+ "n": 995,
47
+ "t": "Claude's stored lead shows first in a popup, with Refresh",
48
+ "s": "Claude's stored lead shows first in a popup, with Refresh"
49
+ }
50
+ ]
51
+ },
35
52
  {
36
53
  "v": "0.383.0",
37
54
  "at": "2026-10-21T13:13:17.082Z",
@@ -294,23 +311,6 @@
294
311
  "s": "The brief is derived content, following the rule Wawan set on 2026-10-21."
295
312
  }
296
313
  ]
297
- },
298
- {
299
- "v": "0.364.0",
300
- "at": "2026-10-21T00:58:08.077Z",
301
- "f": 2,
302
- "prs": [
303
- {
304
- "n": 967,
305
- "t": "Chat is its own page, with the sessions on it",
306
- "s": "Chat is its own page, with the sessions on it"
307
- },
308
- {
309
- "n": 970,
310
- "t": "Each tool the Briefing uses gets a stored read (briefing-source-flow, slice 1)",
311
- "s": "Each tool the Briefing uses gets a stored read (briefing-source-flow, slice 1)"
312
- }
313
- ]
314
314
  }
315
315
  ]
316
316
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@36fe68a0
1
+ kernel-source: pmos@cb5f50a7
2
2
  assembled: 2026-10-21
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-10-21T13:13:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T13:39:25Z"}
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-10-21T13:13:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T13:39:25Z"}
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-10-21T13:13:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T13:39:25Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -127,6 +127,15 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
127
127
  await p.locator('#cIniTk .tkq').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
128
128
  const td = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, grid: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), ask: document.querySelector('#askF').hidden, seg: !!document.querySelector('#oMain .tkst') }));
129
129
  ok('I6 a Jira task opens its record as a grid, read-only: no status control, and its own conversation (premium-popup-context P1)', td.title === 'Sandbox key step' && /Reference\|ONB-12\|Source\|Jira \(read-only\)/.test(td.grid) && td.ask === false && td.seg === false, JSON.stringify(td));
130
+ // popup context slice 3 (L2, L3): the stored lead comes first, with its time and reads, and Refresh asks the popup's own session
131
+ A.setThread({ ok: true, working: false, turns: [], lead: { text: 'ONB-12 waits on the sandbox key. Ask Sam for a date.', cites: ['Jira read 07:02'], at: new Date().toISOString() } });
132
+ await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
133
+ await p.locator('#cIniTk .tkq').first().click(); await until(() => p.evaluate(() => !!document.querySelector('#dlg.on #leadT .plead')), 6000);
134
+ const ld = await p.evaluate(() => { const s = document.querySelector('#dBody .stream'); return { first: s.firstElementChild && s.firstElementChild.id, text: document.querySelector('#leadT').textContent }; });
135
+ ok('I6 a task popup shows Claude\'s stored lead first, with when it was written and what it read (popup context L2)', ld.first === 'leadT' && /waits on the sandbox key/.test(ld.text) && /Lead · written \d\d:\d\d · from Jira read 07:02/.test(ld.text), JSON.stringify(ld));
136
+ { const nA = A.posts.length; await p.click('#leadT [data-lead="refresh"]');
137
+ ok('I6 Refresh asks the popup\'s own session to write the lead again and save it with pmos lead put (popup context L3)', await until(() => A.posts.slice(nA).some((x) => x.path === '/api/briefing-premium/ask' && /^pop:task:/.test(x.body.key) && x.body.text.includes('pmos lead put --key ' + x.body.key))), JSON.stringify(A.posts.slice(nA))); }
138
+ A.setThread({ ok: true, working: false, turns: [] });
130
139
  await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
131
140
  /* a PMOS task: its status can be changed */
132
141
  A.set({ status: 200, body: { ok: true, item: {} } });
@@ -306,7 +306,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
306
306
  ok('R11 the page behind the dialog is inert and the dialog is modal', d.inert && d.role === 'true');
307
307
  ok('R4 the dialog offers Pin to the top for a list row (premium-calmer-first-screen)', await p.evaluate(() => { const b = document.querySelector('#card .dpin'); return !!b && /Pin to the top/.test(b.textContent) && b.getAttribute('aria-pressed') === 'false'; }));
308
308
  ok('R4 the dialog names the row, with an activity log of what was read', d.title === MODEL.list.rows[0].title && /Readfromtherepository3steps/.test(d.log.replace(/\s+/g, '')), d.log);
309
- ok('R4 the detail pane opens with the record\'s path and heading, as the mockup draws it', await p.evaluate(() => { const o = document.querySelector('#oMain'); return !!o.querySelector('.dpath') && !!o.querySelector('.d1') && o.querySelector('.dpath').compareDocumentPosition(o.querySelector('.d1')) & Node.DOCUMENT_POSITION_FOLLOWING; }));
309
+ ok('R4 the detail pane opens with the record\'s path and does not repeat the title the dialog head shows (popup context slice 2)', await p.evaluate(() => { const o = document.querySelector('#oMain'), t = document.querySelector('#dTitle').textContent.trim(); return !!o.querySelector('.dpath') && ![...o.querySelectorAll('.d1, h1, h2, h3')].some((h) => h.textContent.trim() === t); }));
310
310
  ok('R4 the card holds the evidence and the next step, and the right pane the record', /The way through/.test(d.card) && /Blocked at/.test(d.card) && /Initiative record/.test(d.label) && /planning\/initiatives|console-3-boards/.test(d.pane), d.card.slice(0, 120));
311
311
  await until(() => p.evaluate(() => getComputedStyle(document.querySelector('#dlg')).transform === 'none' || /matrix\(1, 0, 0, 1, 0, 0\)/.test(getComputedStyle(document.querySelector('#dlg')).transform)), 3000);
312
312
  const pane0 = await p.evaluate(() => { const b = document.querySelector('#dPane'); const r = b.getBoundingClientRect(); return { on: b.getAttribute('aria-pressed'), t: b.title, w: r.width, h: r.height, convo: getComputedStyle(document.querySelector('#dBody')).display }; });
@@ -1,4 +1,21 @@
1
1
  [
2
+ {
3
+ "v": "0.384.0",
4
+ "at": "2026-10-21T13:39:28.616Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 993,
9
+ "t": "A Work item from the brief opens on its source",
10
+ "s": "A Work item from the brief opens on its source"
11
+ },
12
+ {
13
+ "n": 995,
14
+ "t": "Claude's stored lead shows first in a popup, with Refresh",
15
+ "s": "Claude's stored lead shows first in a popup, with Refresh"
16
+ }
17
+ ]
18
+ },
2
19
  {
3
20
  "v": "0.383.0",
4
21
  "at": "2026-10-21T13:13:17.082Z",
@@ -205,7 +205,7 @@ When you scroll past the hero, the hero folds into a bar at the top. The bar sho
205
205
 
206
206
  ## What a dialog holds
207
207
 
208
- A row or a Today item opens a dialog with the same parts every time. At the top is a short log of what PMOS read, for example the kill-condition file and `pm-decisions.md`. Under it is one plain sentence. Then one card holds the evidence and, for a decision, the options. The record sits on the right: a draft `pm-decisions.md` entry for a decision, the initiative record for blocked work, the commit for a merge.
208
+ A row or a Today item opens a dialog with the same parts every time. At the top is a short log of what PMOS read, for example the kill-condition file and `pm-decisions.md`. Under it is one plain sentence. Then one card holds the evidence and, for a decision, the options. The record sits on the right, without the title again, because the top of the dialog already shows it: a draft `pm-decisions.md` entry for a decision, the initiative record for blocked work, the commit for a merge.
209
209
 
210
210
  The right side can hold more than one item. When the dialog opens a related item there, such as a document, a meeting or a ticket, the item opens as a tab beside the dialog's own detail. The first tab is always the dialog's own detail. You can have up to four more tabs; a fifth closes the oldest. Click a tab or use the arrow keys to move between them. Use the **×** on a tab, or press Delete, to close it. The tabs close when the dialog closes. With no extra item, there are no tabs.
211
211
 
@@ -277,6 +277,10 @@ My work is the second place on the rail, at `/premium-work.html`. It reads the l
277
277
 
278
278
  **The item dialog.** The conversation gets the whole body. Two controls sit beside the Detail / Conversation switch, on both tabs: **Edit ▾** and **Done**. On a wide screen the row also shows where the item is. **Edit ▾** opens a sheet with one labelled field for each choice. Each field shows its value from the record and opens when you press it: **When** (Today, Later today, Tomorrow, Next week, Not before a date, Someday), **Waiting on**, **Who does it** (the steps) and **Priority · Due** (the edit panel). **Keep it** and **Drop it** are at the bottom of the sheet. The sheet closes when you press Edit again, press outside it, or press Escape. **Waiting on** is not shown when the item cannot wait and waits on nobody. An agent that only can draft is a field in the sheet. An agent that is working, has a draft, or stopped stays in the conversation, because it needs you. Every action stays reachable.
279
279
 
280
+ **Where an item came from.** An item from the morning brief opens on its source. Claude's first line says why it is here now and what was asked, for example "Claudia Loo asks: Can the form text hold images?". The right side shows who asked and where, their messages or words, the sources the brief read, and **Open in Slack** (or Jira, mail, and so on) when the brief kept a link. The title is not drawn there again. The item's own fields (place, due date, who asked) are behind **Details**. All of this is what the brief stored when it was written: opening the item reads nothing new. An item you added yourself still shows its fields.
281
+
282
+ **Claude's lead in a popup.** A popup such as a task, a document, a report or a measure opens on Claude's short lead, written ahead of time: why the thing matters now, what is asked or blocking, and what to do. Under it is when the lead was written and what Claude read for it. Opening a popup starts nothing: the lead is read from what is stored. **Refresh** asks the popup's own Claude Code session to write the lead again from the stored reads, and the new lead replaces the old one. A popup with no lead yet says so and offers **Write the lead**. An agent session saves a lead with `pmos lead put --key <popup key> --text "<lead>" --cite "<what it read, when>"`, and `pmos lead show [<key>]` prints what is stored. `pmos lead` calls no tool.
283
+
280
284
  **The agent's draft.** The draft shows as formatted text in the detail panel on the right, labelled as the agent's and not checked, with **Open** and **Copy**. Its heading names the item ("Draft for IDPF-2989", or "Draft for you"), the round and the time of the latest round, and an approved step shows as "Step when you approve". A long draft is cut short, with **Show all**. It appears there as soon as the agent finishes, even while the dialog is open. The left column keeps the conversation (with **View round**) and the decision cards, in the console's words: **Post it to Jira** (marked outward, with exactly the text that goes), **Edit the draft**, **Keep it as a draft** and **Mark it done**. Post asks you to confirm the exact text first, and nothing is posted before that.
281
285
 
282
286
  **An agent's offer.** When an agent has offered to draft an item, the dialog shows three choices: let the agent draft it (suggested), do it today, or not before next Monday. You pick one and press its button. A row with steps says how many it has and how many an agent can do. PMOS does not record that a step is done, so it shows no "done" count.
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+ /* lead-cli.js — `pmos lead …`: Claude's short lead for a popup (popup context slice 3).
3
+ * pmos lead put --key <pop:kind:id> --text "<lead>" [--cite "<what you read, when>"] … save the lead the popup shows first
4
+ * pmos lead show [<key>] [--json] what is stored, for one popup or all
5
+ * The leads are kept in the per-user runtime folder (lib/popup-leads.js). This command calls no tool: write the lead from stored
6
+ * reads (`pmos source show`, the repository files) and name them in --cite.
7
+ */
8
+ const stateRoot = require('./state-root');
9
+ const PL = require('./popup-leads.js');
10
+
11
+ const COMMANDS = { lead: ['put', 'show'] };
12
+ const USAGE = [
13
+ 'usage: pmos lead put|show — Claude\'s short lead for a popup, written ahead and shown first',
14
+ ' pmos lead put --key <pop:kind:id> --text "<lead>" [--cite "<what you read, when>"] …',
15
+ ' the lead: why it matters now, what is asked or blocking, and what to do, in at most 400 characters; at most 4 cites',
16
+ ' pmos lead show [<key>] the stored lead of one popup, or every stored lead',
17
+ ' every command: [--json]',
18
+ 'This command never calls a tool. Write the lead from stored reads and name them.',
19
+ ];
20
+
21
+ function parseArgs(argv) {
22
+ const out = { _: [], cite: [] };
23
+ for (let i = 0; i < argv.length; i++) {
24
+ const t = argv[i];
25
+ if (!t.startsWith('--')) { out._.push(t); continue; }
26
+ const eq = t.indexOf('=');
27
+ const key = eq > 0 ? t.slice(2, eq) : t.slice(2);
28
+ const val = eq > 0 ? t.slice(eq + 1) : key === 'json' || key === 'help' ? true : argv[i + 1] !== undefined ? argv[++i] : '';
29
+ if (key === 'cite') out.cite.push(String(val)); else out[key] = val;
30
+ }
31
+ return out;
32
+ }
33
+
34
+ function run(argv, { say = console.log, env = process.env, stateDir, now = () => new Date() } = {}) {
35
+ const a = parseArgs(argv.slice(1));
36
+ const sub = a._[0];
37
+ const out = (o, line) => { if (a.json) say(JSON.stringify(o)); else say(line); };
38
+ if (!sub || a.help || sub === 'help') { USAGE.forEach((l) => say(l)); return sub || a.help ? 0 : 2; }
39
+ if (!COMMANDS.lead.includes(sub)) { say(`✗ pmos lead ${sub} is not a command`); USAGE.forEach((l) => say(l)); return 2; }
40
+ const dir = stateDir || stateRoot.defaultRoot({ env });
41
+ if (sub === 'put') {
42
+ const v = PL.validate({ key: a.key, text: a.text, cites: a.cite });
43
+ if (!v.ok) { out({ ok: false, error: v.error }, `✗ refused: ${v.error}. Nothing was saved.`); return a.key && a.text ? 1 : 2; }
44
+ const rec = PL.put(dir, v.lead, now());
45
+ out({ ok: true, lead: rec }, `saved the lead of ${rec.key} at ${rec.at}`);
46
+ return 0;
47
+ }
48
+ const key = a._[1];
49
+ if (key) {
50
+ const r = PL.get(dir, key);
51
+ if (a.json) { say(JSON.stringify({ ok: true, lead: r })); return 0; }
52
+ say(r ? `${key} · ${r.at}\n ${r.text}${r.cites.length ? '\n from: ' + r.cites.join('; ') : ''}` : `${key} has no lead yet`);
53
+ return 0;
54
+ }
55
+ const m = PL.all(dir);
56
+ if (a.json) { say(JSON.stringify({ ok: true, leads: m })); return 0; }
57
+ const ks = Object.keys(m);
58
+ if (!ks.length) { say('no lead is stored yet'); return 0; }
59
+ for (const k of ks) say(`${k} · ${m[k].at} · ${m[k].text}`);
60
+ return 0;
61
+ }
62
+
63
+ module.exports = { run, COMMANDS, USAGE };
@@ -109,6 +109,25 @@ function fridayOf({ today, work, tray, ready, review }) {
109
109
  note: 'One step for each place a thing waits for you. A step opens its first item. PMOS keeps no review schedule or timing, so none is shown.' };
110
110
  }
111
111
 
112
+ const SRC_NAME = { calendar: 'Calendar', wispr: 'Wispr', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Drive', figma: 'Figma', website: 'the website', derived: 'PMOS' };
113
+ /* Where a brief item came from, as the popup shows it first: who, where, their words, the conversation and the link (popup context slice 2). */
114
+ function sourceOf(b) {
115
+ if (!b) return null;
116
+ const name = SRC_NAME[b.source] || (b.source ? String(b.source) : '');
117
+ const thread = (b.thread || []).map((m) => ({ who: m.who ? clip(m.who, 80) : null, at: m.at ? clip(m.at, 20) : null, text: clip(m.text, 280) })).filter((m) => m.text);
118
+ const refs = (b.refs || []).map((r) => ({ label: clip(r.label, 120), link: r.link || null, lines: (r.lines || []).map((l) => clip(l, 200)) }));
119
+ const o = { name, who: b.who ? clip(b.who, 120) : '', where: b.where ? clip(b.where, 120) : '', ask: b.ask ? clip(b.ask, 240) : '', quote: b.quote ? clip(b.quote, 280) : '',
120
+ about: b.about ? clip(b.about, 480) : '', evidence: b.evidence ? clip(b.evidence, 240) : '', link: /^https?:\/\//.test(b.link || '') ? b.link : '', thread, refs };
121
+ return o.who || o.where || o.ask || o.quote || o.about || o.evidence || o.link || thread.length || refs.length ? o : null;
122
+ }
123
+ /* Claude's first line for a brief item: why it is here now, and what is asked. */
124
+ function leadOf(b) {
125
+ if (!b) return '';
126
+ const why = b.why_now ? clip(b.why_now, 240).replace(/\s*$/, '') : '';
127
+ const ask = b.ask ? (b.who ? clip(b.who, 80) + ' asks: ' : 'The ask: ') + clip(b.ask, 240) : '';
128
+ return [why && !/[.!?]$/.test(why) ? why + '.' : why, ask && !/[.!?]$/.test(ask) ? ask + '.' : ask].filter(Boolean).join(' ');
129
+ }
130
+
112
131
  function rowOf(it, list, v, inReview, focusIds) {
113
132
  const today = v.today, { chip, overdue } = dueChip(it, today);
114
133
  const sub = [srcLabel(it) + (it.key && it.source !== 'local' ? ' ' + it.key : ''), it.priority, it.waiting_on ? 'waiting on ' + it.waiting_on : null, (it.steps || []).length ? (it.steps || []).length + ' ' + plural((it.steps || []).length, 'step', 'steps') + ((it.steps || []).some((x) => x.who === 'agent-does' || x.who === 'agent-drafts') ? ' · agent can do ' + (it.steps || []).filter((x) => x.who !== 'you').length : '') : null].filter(Boolean).join(' · ');
@@ -125,7 +144,13 @@ function rowOf(it, list, v, inReview, focusIds) {
125
144
  if (list !== 'waiting') actions.push('waiting');
126
145
  actions.push('remove');
127
146
  if (inReview) actions.push('keep');
128
- const say = overdue ? 'This was due ' + shortDate(it.due) + ' and is still open.' : list === 'tray' ? 'You added this. It has no date or place yet. Place it, or drop it.' : list === 'inbox' ? 'This is new and has no date or place yet.' : list === 'waiting' ? 'You are waiting on ' + (it.waiting_on || 'someone') + (days != null ? ' for ' + days + ' ' + plural(days, 'day', 'days') : '') + '.' : 'This is on your list.';
147
+ const src = sourceOf(it.brief), lead = leadOf(it.brief);
148
+ if (src) {
149
+ if (src.who) facts.splice(1, 0, ['Asked by', src.who]);
150
+ if (src.where) facts.splice(src.who ? 2 : 1, 0, ['Where', src.where]);
151
+ }
152
+ const state = overdue ? 'This was due ' + shortDate(it.due) + ' and is still open.' : list === 'tray' ? 'You added this. It has no date or place yet. Place it, or drop it.' : list === 'inbox' ? 'This is new and has no date or place yet.' : list === 'waiting' ? 'You are waiting on ' + (it.waiting_on || 'someone') + (days != null ? ' for ' + days + ' ' + plural(days, 'day', 'days') : '') + '.' : 'This is on your list.';
153
+ const say = lead ? (overdue || list === 'waiting' ? state + ' ' : '') + lead : state;
129
154
  const { sug, cta } = suggestOf(it, list, today, overdue);
130
155
  return {
131
156
  key: 'work:' + it.id, id: it.id, list, title: clip(it.title, 140), sub: sub + (added && (list === 'inbox' || list === 'tray') ? ' · added ' + added : ''), chip, overdue, src: srcLabel(it), sug, cta,
@@ -133,7 +158,7 @@ function rowOf(it, list, v, inReview, focusIds) {
133
158
  focus: list === 'today' && focusIds.has(it.id),
134
159
  dialog: {
135
160
  eye: 'Your item', logTitle: 'Read from your list',
136
- log: ['Read the item (' + srcLabel(it) + ')', 'Placed it from its date, its flag and who it waits on: ' + list, inReview ? 'Found it untouched for ' + v.review_days + ' days' : 'Checked it against the seven-day review'],
161
+ log: ['Read the item (' + srcLabel(it) + ')', 'Placed it from its date, its flag and who it waits on: ' + list, ...(it.brief ? ['Read the brief item it came from' + (it.brief.source ? ' (' + (SRC_NAME[it.brief.source] || it.brief.source) + ')' : '')] : []), inReview ? 'Found it untouched for ' + v.review_days + ' days' : 'Checked it against the seven-day review'],
137
162
  say, head: 'Where it stands', facts,
138
163
  write: { kind: 'work', id: it.id, actions },
139
164
  hold: HOLD.agent,
@@ -142,7 +167,8 @@ function rowOf(it, list, v, inReview, focusIds) {
142
167
  steps: (it.steps || []).map((x) => ({ id: x.id, text: clip(x.text, 200), who: x.who })),
143
168
  defer: it.defer || null,
144
169
  someday: list === 'someday',
145
- pane: { label: 'Item record', file: 'pm-items · ' + it.id, h: clip(it.title, 120), intro: sub, rows: facts, paras: draft ? [clip(draft, 1500)] : [], parasTitle: draft ? 'Agent draft, not checked' : '' },
170
+ source: src,
171
+ pane: { label: src ? 'Source' : 'Item record', file: 'pm-items · ' + it.id, h: clip(it.title, 120), intro: sub, rows: facts, paras: draft ? [clip(draft, 1500)] : [], parasTitle: draft ? 'Agent draft, not checked' : '' },
146
172
  },
147
173
  };
148
174
  }
@@ -56,6 +56,9 @@ const VERBS = Object.freeze({
56
56
  // Not a pm-os-absorb verb (run: null): briefing-source-flow added it through the same table.
57
57
  source: Object.freeze({ module: 'source-cli.js', run: null, guide: 'data-freshness.md',
58
58
  help: 'pmos source save|status|show — the stored read of each tool the Briefing uses: Mail, Slack, Confluence and the rest (pmos source help)' }),
59
+ // Not a pm-os-absorb verb (run: null): the popup context work (premium-chat-session slice 7) added it through the same table.
60
+ lead: Object.freeze({ module: 'lead-cli.js', run: null, guide: 'briefing-premium.md',
61
+ help: 'pmos lead put|show — Claude\'s short lead for a popup, written ahead from stored reads (pmos lead help)' }),
59
62
  // Not a pm-os-absorb verb (run: null): c3-meet-extension added it through the same table.
60
63
  extension: Object.freeze({ module: 'extension-cli.js', run: null, guide: 'console-calendar.md',
61
64
  help: 'pmos extension — the folder of the Chrome extension for Google Meet, and the three steps to load it' }),
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+ /* popup-leads.js — Claude's short lead for a popup, written ahead and stored (popup context slice 3, PRD premium-chat-session L1–L4).
3
+ *
4
+ * validate({ key, text, cites }) → { ok, lead } | { ok: false, error }
5
+ * put(runtimeDir, lead, now) → the stored record · get(runtimeDir, key) → record | null · all(runtimeDir) → { key: record }
6
+ *
7
+ * A lead says why the thing in the popup matters now, what is asked or blocking, and what to do, in at most 400 characters, with
8
+ * the reads it came from (at most 4 cites). It is keyed by the popup's conversation key (`pop:<kind>:<id>`, premium-shell popKey).
9
+ * The records live in the per-user runtime folder, one file, newest 500 keys kept. Writing a lead calls no tool: an agent session
10
+ * writes it with `pmos lead put` from stored reads, and the popup only reads the file.
11
+ */
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+
15
+ const KEY_RE = /^pop:[a-z][a-z-]{0,30}(?::[A-Za-z0-9._-]{1,100}){0,4}$/;
16
+ const MAX_TEXT = 400;
17
+ const MAX_CITES = 4;
18
+ const MAX_CITE = 120;
19
+ const KEEP = 500;
20
+
21
+ const fileOf = (runtimeDir) => path.join(runtimeDir, 'popup-leads.json');
22
+ const clean = (s) => String(s).replace(/\s+/g, ' ').trim();
23
+
24
+ function validate(raw) {
25
+ const r = raw && typeof raw === 'object' ? raw : {};
26
+ const key = typeof r.key === 'string' ? r.key : '';
27
+ if (!KEY_RE.test(key) || key.length > 140) return { ok: false, error: 'key must be a popup key, pop:<kind>:<id>' };
28
+ if (typeof r.text !== 'string' || !clean(r.text)) return { ok: false, error: 'text is required: why it matters now, what is asked, what to do' };
29
+ const text = clean(r.text);
30
+ if (text.length > MAX_TEXT) return { ok: false, error: `text is over ${MAX_TEXT} characters` };
31
+ const cites = r.cites === undefined || r.cites === null ? [] : r.cites;
32
+ if (!Array.isArray(cites) || cites.length > MAX_CITES) return { ok: false, error: `cites must be a list of at most ${MAX_CITES} reads` };
33
+ const out = [];
34
+ for (const c of cites) {
35
+ if (typeof c !== 'string' || !clean(c)) return { ok: false, error: 'each cite names what was read, and when' };
36
+ if (clean(c).length > MAX_CITE) return { ok: false, error: `a cite is over ${MAX_CITE} characters` };
37
+ out.push(clean(c));
38
+ }
39
+ return { ok: true, lead: { key, text, cites: out } };
40
+ }
41
+
42
+ function all(runtimeDir) {
43
+ if (!runtimeDir) return {};
44
+ try { const m = JSON.parse(fs.readFileSync(fileOf(runtimeDir), 'utf8')); return m && typeof m === 'object' && !Array.isArray(m) ? m : {}; } catch { return {}; }
45
+ }
46
+
47
+ function get(runtimeDir, key) {
48
+ if (typeof key !== 'string' || !KEY_RE.test(key)) return null;
49
+ const r = all(runtimeDir)[key];
50
+ return r && typeof r.text === 'string' && r.at ? r : null;
51
+ }
52
+
53
+ function put(runtimeDir, lead, now = new Date()) {
54
+ const m = all(runtimeDir);
55
+ const rec = { text: lead.text, cites: lead.cites || [], at: now.toISOString() };
56
+ delete m[lead.key];
57
+ m[lead.key] = rec;
58
+ const keys = Object.keys(m).sort((a, b) => String(m[a].at).localeCompare(String(m[b].at)));
59
+ for (const k of keys.slice(0, Math.max(0, keys.length - KEEP))) delete m[k];
60
+ const f = fileOf(runtimeDir);
61
+ fs.mkdirSync(path.dirname(f), { recursive: true });
62
+ const tmp = `${f}.${process.pid}.tmp`;
63
+ fs.writeFileSync(tmp, JSON.stringify(m) + '\n');
64
+ fs.renameSync(tmp, f);
65
+ return { key: lead.key, ...rec };
66
+ }
67
+
68
+ module.exports = { KEY_RE, MAX_TEXT, validate, put, get, all, fileOf };
@@ -14,6 +14,7 @@ const guard = require('./pm-guard.js');
14
14
  const Wr = require('./briefing-premium-writes.js');
15
15
  const Ag = require('./briefing-premium-agent.js');
16
16
  const Goal = require('./goal-chat.js');
17
+ const Leads = require('./popup-leads.js');
17
18
  const Files = require('./chat-files.js');
18
19
  const Inbox = require('./agent-inbox.js');
19
20
  const actor = require('./actor.js');
@@ -207,7 +208,9 @@ module.exports = {
207
208
  const live = !!(sid && ctx.chatSessions && ctx.chatSessions.alive(sid));
208
209
  // item-chat-history: with no live session, the conversation the key had is read from its saved Claude Code file, so ending a session never empties the panel
209
210
  const history = !live && ctx.runtimeDir ? Ag.chatHistory({ runtimeDir: ctx.runtimeDir, key, sessions: ctx.chatSessions }) : null;
210
- ctx.json(res, { ok: true, ...Ag.threadOf(ctx.runtimeDir, key), session: live ? sid : null, history, goal: ctx.runtimeDir ? Goal.goalOf(ctx.runtimeDir, key) : null });
211
+ // popup context slice 3: a popup's stored lead comes with its thread, so the popup shows it first and starts nothing
212
+ const lead = key.startsWith('pop:') && ctx.runtimeDir ? Leads.get(ctx.runtimeDir, key) : undefined;
213
+ ctx.json(res, { ok: true, ...Ag.threadOf(ctx.runtimeDir, key), session: live ? sid : null, history, goal: ctx.runtimeDir ? Goal.goalOf(ctx.runtimeDir, key) : null, ...(lead !== undefined ? { lead } : {}) });
211
214
  return true;
212
215
  }
213
216
  if (url.pathname !== '/api/briefing-premium') return false;
@@ -354,9 +354,12 @@ module.exports = {
354
354
  const readBriefOf = (d) => { try { return JSON.parse(fs.readFileSync(path.join(ctx.runtimeDir, 'briefs', d + '.json'), 'utf8')); } catch { return null; } };
355
355
  for (const it of v.items) {
356
356
  const m = /^brief:([0-9a-f]{12})$/.exec(String(it.id || ''));
357
- if (!m || it.agent || it.done || !ctx.runtimeDir) continue;
357
+ if (!m || it.done || !ctx.runtimeDir) continue;
358
358
  const x = assigned.findBriefItem(readBriefOf, m[1], c.now.getTime());
359
- if (x) { it.agent = assigned.briefAgent(x, assigned.runWith(runs, 't-' + x.id)); if (!it.place) it.place = x.source || null; }
359
+ if (!x) continue;
360
+ // the brief item's own context goes with it, so the popup shows who asked, where, their words and the link (popup context slice 2)
361
+ it.brief = assigned.briefContext(x);
362
+ if (!it.agent) { it.agent = assigned.briefAgent(x, assigned.runWith(runs, 't-' + x.id)); if (!it.place) it.place = x.source || null; }
360
363
  }
361
364
  ctx.json(res, v);
362
365
  return true;
@@ -125,6 +125,17 @@ function findBriefItem(readBrief, id, nowMs, days = 7) {
125
125
  return null;
126
126
  }
127
127
 
128
+ /** The context a brief item carries, for the popup of the Work item made from it: why now, the source, who asked, where,
129
+ * their words, the conversation and the link. Only the fields the brief gave. */
130
+ function briefContext(x) {
131
+ if (!x) return null;
132
+ const o = {};
133
+ for (const k of ['why_now', 'evidence', 'source', 'who', 'where', 'about', 'ask', 'quote', 'link', 'todo']) if (typeof x[k] === 'string' && x[k].trim()) o[k] = x[k];
134
+ if (Array.isArray(x.thread) && x.thread.length) o.thread = x.thread.slice(0, 4).map((m) => ({ who: m.who || null, at: m.at || null, text: String(m.text || '') }));
135
+ if (Array.isArray(x.refs) && x.refs.length) o.refs = x.refs.slice(0, 3).map((r) => ({ label: r.label, source: r.source || null, link: r.link || null, lines: (r.lines || []).slice(0, 5) }));
136
+ return Object.keys(o).length ? o : null;
137
+ }
138
+
128
139
  function fromBrief(brief, todayIso, run = null) {
129
140
  if (!brief || brief.date !== todayIso) return [];
130
141
  const list = [...(Array.isArray(brief.priorities) ? brief.priorities : []), ...(Array.isArray(brief.items) ? brief.items : [])];
@@ -160,4 +171,4 @@ function overlay(item, byId) {
160
171
  return out;
161
172
  }
162
173
 
163
- module.exports = { fromMyWork, fromBrief, addable, createdEvent, overlay, agentOf, briefAgent, briefSuggest, briefDraftSpec, taskAgent, localTaskId, localOffer, localSuggest, localDraftSpec, localAgent, runWith, recentRuns, recentDates, findBriefItem, AGENT };
174
+ module.exports = { fromMyWork, fromBrief, addable, createdEvent, overlay, agentOf, briefAgent, briefSuggest, briefDraftSpec, taskAgent, localTaskId, localOffer, localSuggest, localDraftSpec, localAgent, runWith, recentRuns, recentDates, findBriefItem, briefContext, AGENT };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.383.0",
3
+ "version": "0.384.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.383.0",
9
+ "version": "0.384.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.383.0",
3
+ "version": "0.384.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",
@@ -440,9 +440,28 @@ function putHtml(el, html) {
440
440
  return true;
441
441
  }
442
442
  function clearHtml(el) { el.__h = undefined; el.classList.remove('still'); el.innerHTML = ''; }
443
+ /* popup context slice 3: Claude's lead for a popup, written ahead from stored reads, comes first. Refresh asks the popup's own
444
+ * session to write it again; nothing runs when the popup opens. */
445
+ const leadAsk = (key) => 'Refresh the short lead for this popup. In 1 to 3 sentences say why it matters now, what is asked or blocking, and what you would do. '
446
+ + 'Use only stored reads (pmos source show, the repository files) and say which. Save it with: pmos lead put --key ' + key + ' --text "<the lead>" --cite "<what you read, when>". Then give the lead here.';
447
+ const leadTime = (iso) => { const d = new Date(iso); if (Number.isNaN(d.getTime())) return ''; const p = (n) => String(n).padStart(2, '0'); return (d.toDateString() === new Date().toDateString() ? '' : d.getDate() + ' ' + d.toLocaleString('en-GB', { month: 'short' }) + ' ') + p(d.getHours()) + ':' + p(d.getMinutes()); };
448
+ function leadHtml(lead) {
449
+ if (!lead) return `<div class="plead none"><p class="fine2">No lead is written for this yet.</p><button type="button" class="xtb" data-lead="refresh">Write the lead</button></div>`;
450
+ return `<div class="plead"><p>${esc(lead.text)}</p><p class="fine2">Lead · written ${esc(leadTime(lead.at))}${lead.cites && lead.cites.length ? ' · from ' + esc(lead.cites.join('; ')) : ''}</p><button type="button" class="xtb" data-lead="refresh">Refresh</button></div>`;
451
+ }
452
+ function drawLead(box, th) {
453
+ if (!('lead' in th)) return;
454
+ let l = $('#leadT', box); if (!l) { box.insertAdjacentHTML('afterbegin', '<div id="leadT"></div>'); l = $('#leadT', box); }
455
+ putHtml(l, leadHtml(th.lead));
456
+ }
457
+ $('#dBody').addEventListener('click', async (e) => {
458
+ const b = e.target.closest('[data-lead="refresh"]'); if (!b || !S.key || !S.key.startsWith('pop:')) return;
459
+ b.disabled = true; await sendText(S.key, leadAsk(S.key));
460
+ });
443
461
  export function drawThread(th, key, conv) {
444
462
  if (S.key !== key) return;
445
463
  const box = $('#dBody .stream'); if (!box) return;
464
+ drawLead(box, th);
446
465
  let t = $('#thr', box); if (!t) { box.insertAdjacentHTML('beforeend', '<div id="thr"></div>'); t = $('#thr', box); }
447
466
  const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
448
467
  putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal));
@@ -295,9 +295,24 @@ function paneHtml(r) {
295
295
  + (dr.step ? `<p class="agstep">Step when you approve: ${esc(dr.step)}</p>` : '')
296
296
  + `<div class="mdr${clip ? ' clipd' : ''}">${mdHtml(dr.body || dr.summary)}</div>${long ? `<button class="xtb" data-pp="all" type="button" aria-expanded="${!clip}">${clip ? 'Show all' : 'Show less'}</button>` : ''}</article>`;
297
297
  }
298
- let g = `<p class="dpath">${esc(p.file)}</p>${p.h ? `<h3 class="d1">${esc(p.h)}</h3>` : ''}${p.intro ? `<p>${esc(p.intro)}</p>` : ''}`; // the heading and lead line, as the mockup draws them
299
- if (p.rows && p.rows.length) g += `<div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>`;
300
- return h + `<article class="paper doc">${g}<p class="xn">The item as your list holds it.</p></article>`;
298
+ // the dialog head already shows the title and its line, so the pane opens the source and keeps the record behind Details
299
+ const kv = p.rows && p.rows.length ? `<div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>` : '';
300
+ const sc = r.dialog.source;
301
+ if (sc) return h + srcHtml(sc) + `<details class="paper doc wkdet"><summary>Details</summary>${kv}<p class="xn">${esc(p.file)}</p></details>`;
302
+ return h + `<article class="paper doc">${kv}<p class="xn">The item as your list holds it · ${esc(p.file)}</p></article>`;
303
+ }
304
+ /* the message, ticket or thread the item came from, as the brief stored it: nothing is read live on open */
305
+ function srcHtml(sc) {
306
+ const by = [sc.who, sc.where ? 'in ' + sc.where : ''].filter(Boolean).join(' ');
307
+ let g = `<p class="agtag"><span class="agst">${esc(sc.name || 'Source')}</span>${by ? ' ' + esc(by) : ''}</p>`;
308
+ if (sc.thread && sc.thread.length) g += `<div class="wksrc">${sc.thread.map((m) => `<p class="wkmsg"><b>${esc(m.who || 'Someone')}</b>${m.at ? ` <span class="xn">${esc(m.at)}</span>` : ''}<br>${esc(m.text)}</p>`).join('')}</div>`;
309
+ else if (sc.quote) g += `<blockquote class="wkq">${esc(sc.quote)}</blockquote>`;
310
+ if (sc.ask && !(sc.thread && sc.thread.length) && !sc.quote) g += `<p><b>Asked:</b> ${esc(sc.ask)}</p>`;
311
+ if (sc.about) g += `<p>${esc(sc.about)}</p>`;
312
+ for (const rf of sc.refs || []) g += `<p class="wkref"><b>${rf.link ? `<a href="${esc(rf.link)}" target="_blank" rel="noopener">${esc(rf.label)}</a>` : esc(rf.label)}</b></p>${rf.lines.length ? `<ul>${rf.lines.map((l) => `<li>${esc(l)}</li>`).join('')}</ul>` : ''}`;
313
+ if (sc.evidence) g += `<p class="xn">Evidence: ${esc(sc.evidence)}</p>`;
314
+ if (sc.link) g += `<p><a class="xtb" href="${esc(sc.link)}" target="_blank" rel="noopener">Open in ${esc(sc.name || 'its source')}</a></p>`;
315
+ return `<article class="paper doc wksrcp">${g}</article>`;
301
316
  }
302
317
  const paneLabel = (r) => (r.dialog.agent && r.dialog.agent.draft && (r.dialog.agent.draft.body || r.dialog.agent.draft.summary) ? 'Draft and item record' : r.dialog.pane.label);
303
318
  const paneSig = (r) => JSON.stringify([r.dialog.agent && r.dialog.agent.draft, r.dialog.agent && r.dialog.agent.round, r.dialog.agent && r.dialog.agent.state, r.dialog.pane]);
@@ -2707,3 +2707,14 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2707
2707
  .ctxpeek b{color:var(--ink);font-weight:600}
2708
2708
  .ctxpeek em{font-style:normal;font-weight:600;color:var(--ink)}
2709
2709
  .vwtk b{display:block}
2710
+ /* popup context slice 2: a Work item from the brief opens its source; the record folds behind Details */
2711
+ .wksrcp .wkmsg{margin:0 0 10px;font-size:var(--fs-3);line-height:1.5;overflow-wrap:anywhere}
2712
+ .wksrcp .wkq{margin:0 0 10px;padding:6px 12px;border-left:3px solid var(--hair);color:var(--ink-2);font-size:var(--fs-3);line-height:1.5}
2713
+ .wksrcp .wkref{margin:10px 0 2px}.wksrcp ul{margin:0 0 8px;padding-left:18px;font-size:var(--fs-3)}
2714
+ .wkdet summary{cursor:pointer;font:600 var(--t-micro) var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3)}
2715
+ .wkdet[open] summary{margin-bottom:10px}
2716
+ /* popup context slice 3: Claude's stored lead opens the conversation of a popup */
2717
+ .plead{margin:0 0 14px;padding:12px 14px;border-radius:12px;background:var(--well)}
2718
+ .plead p{margin:0 0 6px;font-size:var(--fs-3);line-height:1.5;overflow-wrap:anywhere}
2719
+ .plead .fine2{color:var(--ink-3)}
2720
+ .plead.none{display:flex;align-items:center;gap:10px;justify-content:space-between}.plead.none p{margin:0}
@@ -240,7 +240,9 @@ function cardHtml(r) {
240
240
  function paneHtml(r) {
241
241
  // as the mockup draws it: the record's path, its heading and one lead line, then its grid or sections
242
242
  const p = r.dialog.pane, sel = SEL[r.key] || r.dialog.sel, o = (r.dialog.opts || []).find((x) => x.k === sel);
243
- let h = `<p class="dpath">${esc(p.file || '')}</p>${p.h ? H1(p.h) : ''}${p.intro ? P1(p.intro) : ''}`;
243
+ // the dialog head already shows the title and its line: the pane does not draw them a second time
244
+ const same = (a, b) => String(a || '').trim() === String(b || '').trim();
245
+ let h = `<p class="dpath">${esc(p.file || '')}</p>${p.h && !same(p.h, r.dialog.title || r.title) ? H1(p.h) : ''}${p.intro && !same(p.intro, r.dialog.sub || r.subject) ? P1(p.intro) : ''}`;
244
246
  if (p.list) h = `<p class="dpath">planning/runs/evals.jsonl</p><ol class="stp">${r.dialog.items.map((x, k) => `<li><i>${k + 1}</i><span><b>${esc(x.t)}</b><small>${esc(x.m + ' · ' + x.s)}${x.lead ? '. ' + esc(x.lead) : ''}</small></span></li>`).join('')}</ol>`;
245
247
  else if (p.optsDraft) h += H2('Evidence') + UL(p.evidence.filter((x) => x && x[1]).map(([k, v]) => k + ': ' + v)) + H2('Decision') + P1(o ? o.t + '. ' + o.draft : 'Choose an option to draft the entry.') + `<p class="xn">A draft. Nothing is written to the journal until you press Record.</p>`;
246
248
  else h += (p.rows && p.rows.length ? kv(p.rows) : '') + (p.paras && p.paras.length ? (p.parasTitle ? H2(p.parasTitle) : '') + p.paras.map(P1).join('') : '') + `<p class="xn">The record as it stands. Nothing is drafted here.</p>`;
@@ -0,0 +1,5 @@
1
+ {
2
+ "_comment": "popup context (premium-chat-session slice 7): Claude's short lead for a popup, stored with pmos lead and shown first.",
3
+ "modules": ["popup-leads.test.js"],
4
+ "seconds": { "popup-leads.test.js": 1 }
5
+ }