create-pmos 0.377.0 → 0.379.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.377.0",
3
+ "version": "0.379.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,30 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.379.0",
37
+ "at": "2026-10-21T08:59:34.421Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 988,
42
+ "t": "Notes replace the Scratchpad in the premium chat",
43
+ "s": "Notes replace the Scratchpad in the premium chat"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "v": "0.378.0",
49
+ "at": "2026-10-21T07:48:19.057Z",
50
+ "f": 2,
51
+ "prs": [
52
+ {
53
+ "n": 987,
54
+ "t": "Chips for what an answer worked with, main one opens by itself",
55
+ "s": "Chips for what an answer worked with, main one opens by itself"
56
+ }
57
+ ]
58
+ },
35
59
  {
36
60
  "v": "0.377.0",
37
61
  "at": "2026-10-21T07:27:29.956Z",
@@ -297,30 +321,6 @@
297
321
  "s": "There is no Agents tab."
298
322
  }
299
323
  ]
300
- },
301
- {
302
- "v": "0.359.0",
303
- "at": "2026-10-20T13:30:13.743Z",
304
- "f": 2,
305
- "prs": [
306
- {
307
- "n": 958,
308
- "t": "The phone rail returns to the bottom after the keyboard closes",
309
- "s": "When a field loses focus or the keyboard closes, the bar goes back to the bottom of the screen and the dock back to the top."
310
- }
311
- ]
312
- },
313
- {
314
- "v": "0.358.0",
315
- "at": "2026-10-20T11:00:48.565Z",
316
- "f": 2,
317
- "prs": [
318
- {
319
- "n": 939,
320
- "t": "Chat sessions end when idle, resume, and cap at 4 live",
321
- "s": "A chat session that prints nothing for the workspace idle limit (60 minutes by default) is ended, unless its goal is started or a permission prompt is waiting."
322
- }
323
- ]
324
324
  }
325
325
  ]
326
326
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@bae3b91d
1
+ kernel-source: pmos@6bbfa917
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-21T07:27:27Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T08:59:30Z"}
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-21T07:27:27Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T08:59:30Z"}
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-21T07:27:27Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T08:59:30Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -414,7 +414,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
414
414
  ok('W3 "Tomorrow" posts the key and the time, and closes the dialog', await until(() => posts.some((x) => x.path === '/api/briefing-premium/put-off' && x.body.key === 'decision:KC5' && x.body.until === 'tomorrow')) && await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))));
415
415
  // slice 3: the read-only agent behind the reply box
416
416
  await shut(); await openIdx(3);
417
- ok('A1 the reply box has one Send to Claude button, 44 px, and no note button', await pg.evaluate(() => { const a = document.querySelector('#askGo'); const h = (e) => e.getBoundingClientRect().height; return !!a && h(a) >= 44 && /Send to Claude/.test(a.title) && !document.querySelector('#noteGo') && !/note/i.test(document.querySelector('#askF').textContent); }));
417
+ ok('A1 the reply box has one Send to Claude button, 44 px, and no note button', await pg.evaluate(() => { const a = document.querySelector('#askGo'); const h = (e) => e.getBoundingClientRect().height; return !!a && h(a) >= 44 && /Send to Claude/.test(a.title) && !document.querySelector('#noteGo') && ![...document.querySelector('#askF').childNodes].filter((n) => n.id !== 'plusM').some((n) => /note/i.test(n.textContent)); })); // the + menu's Notes item opens the notepad, not a note button
418
418
  ok('A1b a hidden question box is not drawn (the Mentions dialog has no agent thread)', await pg.evaluate(() => { const f = document.querySelector('#askF'); if (!f) return false; f.hidden = true; const d = getComputedStyle(f).display; f.hidden = false; return d === 'none'; }));
419
419
  answer = { status: 200, body: { ok: true, id: 'bq-1', state: 'working' } };
420
420
  await pg.fill('#askIn', 'Why is KC5 on my list?');
@@ -1,4 +1,28 @@
1
1
  [
2
+ {
3
+ "v": "0.379.0",
4
+ "at": "2026-10-21T08:59:34.421Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 988,
9
+ "t": "Notes replace the Scratchpad in the premium chat",
10
+ "s": "Notes replace the Scratchpad in the premium chat"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "v": "0.378.0",
16
+ "at": "2026-10-21T07:48:19.057Z",
17
+ "f": 2,
18
+ "prs": [
19
+ {
20
+ "n": 987,
21
+ "t": "Chips for what an answer worked with, main one opens by itself",
22
+ "s": "Chips for what an answer worked with, main one opens by itself"
23
+ }
24
+ ]
25
+ },
2
26
  {
3
27
  "v": "0.377.0",
4
28
  "at": "2026-10-21T07:27:29.956Z",
@@ -419,6 +419,7 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
419
419
  - **The conversation** is Claude Code's own record, word for word. Claude's answers are formatted as Claude Code formats them: headings, bold, lists, code, tables, quotes and links (links open in a new tab). Your messages keep their line breaks, and a paste shows without the tags Claude Code wraps around it. A run of tool calls shows as one small grey line, for example "Used Read ×2, slack_read_thread". A connector tool shows its short name.
420
420
  - **While a session runs**, the panel reads it again every 2 seconds and changes only when there is something new. The messages already on screen stay still, so nothing blinks beside the viewer.
421
421
  - **A file Claude names** (a path such as `briefs/drafts/plan.md`, or a link to one) is underlined. Press it to read the file beside the conversation, as a tab in the viewer; on a phone, the Detail side shows it (on the Chat page, the viewer opens over the conversation). Markdown shows as a page, an HTML file shows as the page it draws (press **Source** for its code), and other text files show as code. An HTML page runs its own scripts, so its toggles and charts work, but it cannot reach PMOS or the internet: a web font falls back to the system font. It is read-only. While the tab is open it shows the newest version, so a file Claude is still writing stays current. A file outside the workspaces PMOS serves says "Not in a workspace" and is not read.
422
+ - **What an answer worked with** shows as buttons under it: the files Claude wrote, changed or read, the Jira tickets and Slack channels it used, and the links it named. The first one is the main one: a file Claude wrote comes first, then what it named in its words, then what it only read. When an answer finishes while the chat is open, its main one opens in the viewer by itself, once; answers that were there when you opened the chat open nothing. On a phone a bar over the message box offers it instead (**View**), so the conversation stays in view. A Jira ticket shows what PMOS last read from Jira for a board or initiative it syncs, with **Open in Jira**; a ticket PMOS has not read says so. A Slack channel or message opens with **Open in Slack**, as PMOS keeps no copy of Slack messages.
422
423
  - **A link to a Google Doc or a Confluence page** opens beside the conversation too, as the viewer shows a copy: the text PMOS has read, or **Read it now**. **A Claude artifact link** opens a tab with **Open in Claude**: claude.ai does not let another site show an artifact inside it. Other links open in a new browser tab.
423
424
  - **The session** is also listed in **Sessions** and in the console, where you can open its terminal.
424
425
  - **Ending a session ends only its process.** Whether you press End in the session list, or PMOS ends an idle chat, the conversation stays with the row: the panel and the session's own view still show every turn, read from Claude Code's record (in whichever Claude login ran it, such as `~/.claude-personal`). PMOS also keeps a copy in its own state folder (`chat-history/`), so the conversation stays after Claude Code removes old records. Files the session wrote are never touched. Your next message picks up the same conversation.
@@ -426,19 +427,24 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
426
427
 
427
428
  Sending and the option presses need the page's launch nonce, so an agent session cannot type into your chat.
428
429
 
429
- ### The Scratchpad
430
+ ### Notes
430
431
 
431
- Under the message box, **Scratchpad** opens a pad above the box. It keeps notes for this conversation only. Claude does not see them until you add them to a message.
432
+ Notes is a notepad for each conversation. Open it from **+** › **Notes**. It opens in the viewer beside the conversation. On a phone, it opens on the viewer tab.
432
433
 
433
- - The text is saved on this machine as you type. It is there when you open the same row again, also after a reload.
434
- - **Add to message** puts the pad text into the message box. Nothing is sent: read it, change it and press send yourself. If you select part of the pad first, the button reads **Add selection to message** and adds only that part. The pad keeps its text.
435
- - To hide the pad, press **Scratchpad** again. The text is kept, and the chip shows how many lines it holds. The page remembers if the pad was open.
436
- - To make the pad taller or shorter, drag the grip on its top edge, or select the grip and press the up arrow or the down arrow. Double-click the grip for the default height.
437
- - A dialog with no conversation has no pad.
434
+ - A conversation can have more than one note. The head shows the title of the note (its first line) and how many notes there are. Press the title to see the list and pick a note. **Delete this note** is at the end of the list. It asks first.
435
+ - The **+** button in the head makes a new note.
436
+ - Each note is saved as you type, as a Markdown file on this machine (`chat-files/<conversation>/notes/`). It never goes into a repository. The head says **Saved**.
437
+ - To format, type a start at the beginning of a line and then a space: `#`, `##` or `###` for a heading, `-` for a bullet, `1.` for a numbered list and `[]` for a checkbox. Ctrl+B (Cmd+B on a Mac) makes text bold and Ctrl+I makes it italic. Press a checkbox to tick it.
438
+ - In a checkbox list, Enter makes the next checkbox. Enter on an empty checkbox ends the list.
439
+ - The two buttons at the bottom have icons only. Hold the pointer on a button to see its name.
440
+ - **Add selection to message** (the arrow into a line) puts the words you selected into the message box. With nothing selected, it puts the whole note there. Nothing is sent.
441
+ - **Share with Claude** (the arrow up out of a box) puts the note on your message as a file, like an attachment. Claude reads the note when you send. Your message shows it as a **Note** chip. Press the chip to open the note.
442
+ - The old Scratchpad text of a conversation becomes its first note when you open Notes. Nothing is lost.
443
+ - A dialog with no conversation has no Notes.
438
444
 
439
445
  ### Attach files and photos
440
446
 
441
- Press **+** at the left of the message box. The menu has three items: **Add files or photos**, **Slash commands** and **Scratchpad**.
447
+ Press **+** at the left of the message box. The menu has three items: **Add files or photos**, **Slash commands** and **Notes**.
442
448
 
443
449
  - **Add files or photos** opens the file chooser. You can pick more than one file. On a phone, the phone shows its own choices, such as Take Photo and Photo Library.
444
450
  - On a computer, you can also drag a file onto the conversation, or paste a screenshot into the message box.
@@ -8,6 +8,8 @@
8
8
  * withFiles(text, paths) → the message with the closing line that names each file for Claude
9
9
  * splitFiles(text) → { text, files: [path] } the same line read back, for the PM's bubble
10
10
  * servable(runtimeDir, p) → { ok, file, size, type, inline } | { ok: false, … } GET /api/chat-file?path=
11
+ * listNotes / saveNote / removeNote Notes (premium-chat-notes): Markdown files in the same folder,
12
+ * under notes/, so Share with Claude names one like an attachment
11
13
  *
12
14
  * The files live in the workspace state folder, never in a repository, so nothing reaches git. The chat sessions start with
13
15
  * the chat-files folder as an added directory, so Claude reads an attachment without a permission question. Nothing here
@@ -39,6 +41,10 @@ function cleanName(name) {
39
41
  /** The stored name: a time prefix keeps two files of the same name apart and orders the folder. */
40
42
  const storedName = (name, now = new Date()) => now.toISOString().replace(/[-:]/g, '').replace(/\..*$/, '') + '-' + cleanName(name);
41
43
  const NAME_RE = /^\d{8}T\d{6}-[\w.-]{1,96}$/;
44
+ const NOTES = 'notes', NOTE_RE = /^n[0-9a-z]{6,16}$/, NOTE_MAX = 200000;
45
+ const notesDir = (runtimeDir, key) => path.join(dirOf(runtimeDir, key), NOTES);
46
+ /** A message may name a saved file, or a note as notes/<id>.md. */
47
+ const nameOk = (n) => NAME_RE.test(n) || (n.startsWith(NOTES + '/') && NOTE_RE.test(n.slice(NOTES.length + 1).replace(/\.md$/, '')) && n.endsWith('.md'));
42
48
 
43
49
  function save({ runtimeDir, key, name, buf, now = new Date() }) {
44
50
  if (!runtimeDir) return fail(409, 'this workspace has no state folder to keep the file in');
@@ -66,7 +72,7 @@ function pathsOf({ runtimeDir, key, names }) {
66
72
  const dir = runtimeDir && key ? dirOf(runtimeDir, key) : null;
67
73
  const paths = [];
68
74
  for (const n of names) {
69
- const f = dir && NAME_RE.test(String(n || '')) ? path.join(dir, String(n)) : null;
75
+ const f = dir && nameOk(String(n || '')) ? path.join(dir, String(n)) : null;
70
76
  if (!f || !fs.existsSync(f)) return fail(400, 'A file on this message was not saved: ' + String(n || '').slice(0, 80));
71
77
  paths.push(f);
72
78
  }
@@ -89,11 +95,52 @@ function splitFiles(text) {
89
95
  function servable(runtimeDir, p) {
90
96
  if (!runtimeDir) return fail(404, 'no such file');
91
97
  const root = path.resolve(rootOf(runtimeDir)), f = path.resolve(String(p || ''));
92
- if (path.dirname(path.dirname(f)) !== root || !NAME_RE.test(path.basename(f))) return fail(404, 'no such file');
98
+ const att = path.dirname(path.dirname(f)) === root && NAME_RE.test(path.basename(f));
99
+ const note = path.basename(path.dirname(f)) === NOTES && path.dirname(path.dirname(path.dirname(f))) === root && NOTE_RE.test(path.basename(f, '.md')) && f.endsWith('.md');
100
+ if (!att && !note) return fail(404, 'no such file');
93
101
  let st; try { st = fs.lstatSync(f); } catch { return fail(404, 'no such file'); }
94
102
  if (!st.isFile()) return fail(404, 'no such file');
95
103
  const type = KINDS[path.extname(f).toLowerCase()] || 'application/octet-stream';
96
104
  return { ok: true, file: f, size: st.size, type, inline: INLINE.has(type) };
97
105
  }
98
106
 
99
- module.exports = { MAX_BYTES, MAX_FILES, DIR, LEAD, rootOf, dirOf, cleanName, storedName, save, remove, pathsOf, withFiles, splitFiles, servable };
107
+ /** A note's title: its first line that has words, without the heading marks. Pure. */
108
+ function noteTitle(text) {
109
+ const l = String(text || '').split('\n').map((x) => x.replace(/^\s*(#{1,6}\s+|[-*+]\s+(\[[ xX]\]\s+)?|\d+[.)]\s+|>\s*)/, '').replace(/[*_`]/g, '').trim()).find(Boolean);
110
+ return (l || 'Untitled note').slice(0, 80);
111
+ }
112
+ /** The notes of a conversation, oldest first: { id, title, text, path, mtime }. */
113
+ function listNotes({ runtimeDir, key }) {
114
+ if (!runtimeDir || !key) return fail(400, 'key must name a conversation');
115
+ const dir = notesDir(runtimeDir, key);
116
+ let names = []; try { names = fs.readdirSync(dir); } catch { return { ok: true, notes: [] }; }
117
+ const notes = names.filter((n) => n.endsWith('.md') && NOTE_RE.test(n.slice(0, -3))).map((n) => {
118
+ const f = path.join(dir, n); let text = '', mtime = 0;
119
+ try { text = fs.readFileSync(f, 'utf8'); mtime = fs.statSync(f).mtimeMs; } catch { /* gone between the read and the list */ }
120
+ return { id: n.slice(0, -3), title: noteTitle(text), text, path: f, mtime };
121
+ });
122
+ notes.sort((a, b) => (a.id < b.id ? -1 : 1));
123
+ return { ok: true, notes };
124
+ }
125
+ /** Save a note. No id: a new note, named by the time so the list keeps the order they were made in. */
126
+ function saveNote({ runtimeDir, key, id, text, now = Date.now() }) {
127
+ if (!runtimeDir || !key) return fail(400, 'key must name a conversation');
128
+ const t = String(text == null ? '' : text);
129
+ if (t.length > NOTE_MAX) return fail(413, 'A note holds 200,000 characters at most.');
130
+ const dir = notesDir(runtimeDir, key);
131
+ let n = id == null || id === '' ? null : String(id);
132
+ if (n !== null && !NOTE_RE.test(n)) return fail(400, 'no such note');
133
+ fs.mkdirSync(dir, { recursive: true });
134
+ if (n === null) { let k = now; do { n = 'n' + (k++).toString(36); } while (fs.existsSync(path.join(dir, n + '.md'))); }
135
+ const f = path.join(dir, n + '.md');
136
+ fs.writeFileSync(f, t);
137
+ return { ok: true, id: n, title: noteTitle(t), path: f, name: NOTES + '/' + n + '.md' };
138
+ }
139
+ function removeNote({ runtimeDir, key, id }) {
140
+ if (!runtimeDir || !key) return fail(400, 'key must name a conversation');
141
+ if (!NOTE_RE.test(String(id || ''))) return fail(400, 'no such note');
142
+ try { fs.unlinkSync(path.join(notesDir(runtimeDir, key), String(id) + '.md')); } catch { return fail(404, 'no such note'); }
143
+ return { ok: true };
144
+ }
145
+
146
+ module.exports = { MAX_BYTES, MAX_FILES, DIR, LEAD, rootOf, dirOf, cleanName, storedName, save, remove, pathsOf, withFiles, splitFiles, servable, noteTitle, listNotes, saveNote, removeNote };
@@ -244,6 +244,25 @@ function readSnapshot(root, initiative) {
244
244
  return { fetchedAt: isStr(data.fetched_at) ? data.fetched_at : null, query: isStr(data.query) ? data.query : null, tickets };
245
245
  }
246
246
 
247
+ /**
248
+ * One ticket by its key from every stored Jira reading (the initiatives' and the boards' snapshots), newest reading first, or null.
249
+ * The Chat page's viewer shows a ticket Claude worked with from this; it never reads Jira itself (premium-chat-viewer slice 2).
250
+ */
251
+ function findTicket(root, key) {
252
+ const k = String(key || '').toUpperCase();
253
+ if (!KEY_RE.test(k)) return null;
254
+ let names;
255
+ try { names = fs.readdirSync(jiraTickets.jiraDir(root)); } catch { return null; }
256
+ let best = null;
257
+ for (const n of names) {
258
+ if (!n.endsWith('.md') || n.endsWith('-tickets.md')) continue;
259
+ const snap = readSnapshot(root, n.slice(0, -3));
260
+ const r = snap && snap.tickets.get(k);
261
+ if (r && (!best || String(snap.fetchedAt || '') > String(best.fetchedAt || ''))) best = { ...r, fetchedAt: snap.fetchedAt, from: n.slice(0, -3) };
262
+ }
263
+ return best;
264
+ }
265
+
247
266
  /**
248
267
  * Write the snapshot from a saved search result. Only the tickets this initiative pushed are kept; any other issue in
249
268
  * the result is counted and ignored. A pushed ticket missing from the result keeps its last reading, marked stale.
@@ -509,5 +528,5 @@ function which(root, key) {
509
528
  return { ok: true, key: k, initiatives: hits };
510
529
  }
511
530
 
512
- module.exports = { queryFor, linkedInitiatives, normalize, sync, readSnapshot, which, sprintLabel, snapshotPath, snapshotRel, sprintQuery, syncSprints, readSprints, SPRINTS_FILE,
531
+ module.exports = { queryFor, linkedInitiatives, normalize, sync, readSnapshot, findTicket, which, sprintLabel, snapshotPath, snapshotRel, sprintQuery, syncSprints, readSprints, SPRINTS_FILE,
513
532
  sprintsToSummarise, saveSprintNotes, readSprintNotes, sameSprint, noteOne, NOTES_FILE };
@@ -122,6 +122,13 @@ function readRaw(req, max) {
122
122
  });
123
123
  }
124
124
  async function chatFile(req, res, url, ctx) {
125
+ if (url.pathname === '/api/chat-file/notes' && req.method === 'GET') { // premium-chat-notes: the conversation's notes, oldest first
126
+ const key = url.searchParams.get('key') || '';
127
+ if (!Ag.KEY_RE.test(key)) { ctx.json(res, { ok: false, error: 'key must name a row' }, 400); return true; }
128
+ const r = Files.listNotes({ runtimeDir: ctx.runtimeDir, key });
129
+ ctx.json(res, r.ok ? { ok: true, notes: r.notes.map((n) => ({ id: n.id, title: n.title, text: n.text, path: n.path, name: 'notes/' + n.id + '.md' })) } : { ok: false, error: r.error }, r.ok ? 200 : r.status);
130
+ return true;
131
+ }
125
132
  if (url.pathname === '/api/chat-file' && req.method === 'GET') {
126
133
  const f = Files.servable(ctx.runtimeDir, url.searchParams.get('path'));
127
134
  if (!f.ok) { ctx.json(res, { ok: false, error: f.error }, f.status); return true; }
@@ -135,6 +142,17 @@ async function chatFile(req, res, url, ctx) {
135
142
  if (req.headers && req.headers['x-pmos-session']) { ctx.json(res, { ok: false, error: 'an agent session cannot attach a file to the PM\'s message' }, 403); return true; }
136
143
  const g = guard.requirePagePress(req, {});
137
144
  if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
145
+ if (url.pathname === '/api/chat-file/notes' || url.pathname === '/api/chat-file/notes/remove') { // premium-chat-notes: save or delete one note
146
+ const got = await ctx.readJson(req);
147
+ if (!got.ok) { ctx.json(res, { ok: false, error: 'body must be JSON' }, 400); return true; }
148
+ const b = got.body || {}, key = String(b.key || '');
149
+ if (!Ag.KEY_RE.test(key)) { ctx.json(res, { ok: false, error: 'key must name a row' }, 400); return true; }
150
+ let r;
151
+ try { r = url.pathname.endsWith('/remove') ? Files.removeNote({ runtimeDir: ctx.runtimeDir, key, id: b.id }) : Files.saveNote({ runtimeDir: ctx.runtimeDir, key, id: b.id, text: b.text }); }
152
+ catch (e) { r = { ok: false, status: 500, error: 'The note could not be saved: ' + String((e && e.message) || e).slice(0, 120) }; }
153
+ ctx.json(res, r.ok ? { ok: true, ...(r.id ? { id: r.id, title: r.title, path: r.path, name: r.name } : {}) } : { ok: false, error: r.error }, r.ok ? 200 : r.status);
154
+ return true;
155
+ }
138
156
  if (url.pathname === '/api/chat-file/remove') {
139
157
  const got = await ctx.readJson(req);
140
158
  if (!got.ok) { ctx.json(res, { ok: false, error: 'body must be JSON' }, 400); return true; }
@@ -429,6 +429,8 @@ function callTarget(input, root) {
429
429
  else if (str(input.command)) t = str(input.command).split('\n')[0];
430
430
  else if (str(input.pattern)) t = str(input.pattern) + (str(input.path) ? ' in ' + rel(str(input.path)) : '');
431
431
  else if (str(input.url)) t = str(input.url);
432
+ else if (str(input.issueIdOrKey) || str(input.issueKey) || str(input.issue_key)) t = str(input.issueIdOrKey) || str(input.issueKey) || str(input.issue_key); // a Jira call: the ticket (premium-chat-viewer slice 2)
433
+ else if (str(input.channel_id) || str(input.channel)) t = (str(input.channel_id) || str(input.channel)) + (str(input.message_ts) || str(input.thread_ts) ? ' ' + (str(input.message_ts) || str(input.thread_ts)) : ''); // a Slack call: the channel and the message
432
434
  else if (str(input.query)) t = str(input.query);
433
435
  else if (str(input.description)) t = str(input.description);
434
436
  else if (str(input.path)) t = rel(str(input.path));
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.377.0",
3
+ "version": "0.379.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.377.0",
9
+ "version": "0.379.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.377.0",
3
+ "version": "0.379.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",
@@ -66,7 +66,7 @@ const filesIn = () => { const d = path.join(T.STATE_DIR, 'chat-files'); const ou
66
66
  ok('B1 the menu starts closed and no chip row shows', await page.isHidden('#plusM') && await page.isHidden('#attRow'));
67
67
  await page.click('#askPlus');
68
68
  ok('B1 the + opens a menu of three above the box', await page.isVisible('#plusM') && (await page.$$('#plusM [data-plus]')).length === 3 && await page.evaluate(() => document.querySelector('#plusM').getBoundingClientRect().bottom <= document.querySelector('#askIn').getBoundingClientRect().top + 8));
69
- ok('B1 the menu names Add files or photos, Slash commands and Scratchpad', /Add files or photos[\s\S]*Slash commands[\s\S]*Scratchpad/.test(await page.textContent('#plusM')));
69
+ ok('B1 the menu names Add files or photos, Slash commands and Notes', /Add files or photos[\s\S]*Slash commands[\s\S]*Notes/.test(await page.textContent('#plusM')));
70
70
  await shot(page, 'menu-1280-light');
71
71
  await page.keyboard.press('Escape');
72
72
  ok('B1 Escape closes the menu and leaves the dialog open', await page.isHidden('#plusM') && await page.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
@@ -75,8 +75,7 @@ const filesIn = () => { const d = path.join(T.STATE_DIR, 'chat-files'); const ou
75
75
  ok('B2 Slash commands puts / in the box and shows the commands', (await page.inputValue('#askIn')) === '/' && await page.isVisible('#slashM'));
76
76
  await page.fill('#askIn', ''); await page.evaluate(() => document.querySelector('#askIn').dispatchEvent(new Event('input', { bubbles: true })));
77
77
  await page.click('#askPlus'); await page.click('[data-plus="pad"]');
78
- ok('B2 Scratchpad opens the pad', await page.isVisible('#sPad'));
79
- await page.click('#sPadT');
78
+ ok('B2 Notes opens the notepad in the viewer', !!(await until(async () => page.isVisible('#ntEd'))));
80
79
  /* B3 */
81
80
  await page.setInputFiles('#askFile', [{ name: 'Screenshot 1.41.39 PM.png', mimeType: 'image/png', buffer: PNG }, { name: 'Q4 roadmap.pdf', mimeType: 'application/pdf', buffer: Buffer.from('%PDF-1.4 test') }]);
82
81
  ok('B3 two picked files show as two chips with their sizes once saved', !!(await until(async () => { const c = await chips(page); return c.length === 2 && c.every((x) => /KB/.test(x.meta)); })), JSON.stringify(await chips(page)));
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-chat-context-test.js — what one of Claude's answers worked with shows as chips under it, and the main one opens by itself
4
+ * (initiative premium-chat-viewer, slice 2). A real server on a scratch repository (c3-scan-fixture.js); the chat's thread and conversation
5
+ * and the file reads are routed, and the test changes the conversation the way a running session does.
6
+ * C1 an answer that was there when the chat opened has its chips, the main one first, and opens nothing
7
+ * C2 a new answer opens its main item in the viewer once, when Claude has finished, and not while it still works
8
+ * C3 a Jira chip opens the ticket from the stored Jira reading, with Open in Jira; a key with no reading says so
9
+ * C4 a Slack chip opens a tab with Open in Slack
10
+ * C5 at 390 a new answer shows a bar over the message box instead of covering the conversation; its press opens the viewer layer
11
+ * C6 every chip is at least 44 px; no sideways scroll; no page error
12
+ * Set CHAT_CONTEXT_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
13
+ const { findBrowser } = require('./lib/find-browser');
14
+ require('./test-run').configure({ name: 'premium-chat-context' });
15
+ const Fx = require('./c3-scan-fixture.js');
16
+
17
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
18
+ const until = async (fn, ms = 8000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
19
+ const results = [];
20
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
21
+ let F = null, browser = null;
22
+ const finish = async (code) => {
23
+ if (browser) await browser.close().catch(() => {});
24
+ if (F) F.stop();
25
+ const bad = results.filter((x) => !x.cond).length;
26
+ console.log(`\n${results.length - bad}/${results.length} premium-chat-context assertions passed`);
27
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
28
+ };
29
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
30
+
31
+ const MD = '# Sign-up drop\n\nThe **sign-up** rate fell from 41% to 38%.\n';
32
+ const first = () => [
33
+ { role: 'user', text: 'Why did sign-ups drop?', at: '2026-10-21T08:00:00Z' },
34
+ { role: 'tool', tools: { Read: 1, Write: 1 }, calls: [{ tool: 'Read', target: 'planning/prd/signup-fix.md' }, { tool: 'Write', target: 'planning/research/signup-drop.md' }], at: '2026-10-21T08:00:10Z' },
35
+ { role: 'assistant', text: 'I wrote it up in planning/research/signup-drop.md. The rate fell from 41% to 38% (UTF-8 export).', at: '2026-10-21T08:00:20Z' },
36
+ ];
37
+ const second = (k) => [
38
+ { role: 'user', text: 'Check the ticket and tell the channel', at: '2026-10-21T08:01:00Z' },
39
+ { role: 'tool', tools: { getJiraIssue: 2, slack_send_message: 1, Edit: 1 }, calls: [{ tool: 'mcp__Atlassian__getJiraIssue', target: 'SGN-42' }, { tool: 'mcp__Atlassian__getJiraIssue', target: 'SGN-7' }, { tool: 'mcp__Slack__slack_send_message', target: 'C0123ABCD' }, { tool: 'Edit', target: 'planning/research/signup-plan' + k + '.md' }], at: '2026-10-21T08:01:10Z' },
40
+ { role: 'assistant', text: 'SGN-42 is in review. I told the team in Slack and updated the plan.', at: '2026-10-21T08:01:2' + k + 'Z' },
41
+ ];
42
+
43
+ (async () => {
44
+ const exe = findBrowser();
45
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
46
+ let chromium;
47
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
48
+ F = await Fx.start({ name: 'premium-chat-context' });
49
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
50
+ const shots = process.env.CHAT_CONTEXT_SHOTS;
51
+ const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}`;
52
+ const open = async (width, scheme = 'light') => {
53
+ const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 800 }, colorScheme: scheme, hasTouch: width < 1000 });
54
+ const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
55
+ const conv = { ok: true, state: 'conv', turn: 'user', messages: first() };
56
+ await p.route('**/api/briefing-premium/thread**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-ctx' } }));
57
+ await p.route('**/api/sessions/conversation**', (r) => r.fulfill({ json: conv }));
58
+ await p.route('**/api/jira/ticket**', (r) => r.fulfill({ json: { ok: true, ticket: /SGN-42/.test(r.request().url()) ? { key: 'SGN-42', summary: 'Fix the sign-up form', status: 'In Review', category: 'indeterminate', sprint: { name: 'Sprint 14', state: 'active' }, url: 'https://acme.atlassian.net/browse/SGN-42', fetchedAt: '2026-10-21T07:00:00Z' } : null } }));
59
+ await p.route('**/api/doc/locate**', (r) => { const u = decodeURIComponent(r.request().url()); const rel = (u.match(/path=([^&]+)/) || [])[1] || 'x.md'; r.fulfill({ json: { ok: true, ws: F.ws, rel, name: rel.split('/').pop(), abs: '/x/' + rel, mtime: 1, size: MD.length } }); });
60
+ await p.route('**/api/doc?**', (r) => r.fulfill({ contentType: 'text/plain', headers: { 'X-Doc-Kind': 'markdown' }, body: MD }));
61
+ await p.goto(chat);
62
+ await until(() => p.evaluate(() => document.querySelectorAll('#dBody .ctxchip').length > 0), 10000);
63
+ return { p, ctx, errs, conv };
64
+ };
65
+ const look = () => {
66
+ const g = document.querySelector('#dlg'), peek = document.querySelector('#ctxPeek');
67
+ return { shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width),
68
+ tabs: [...document.querySelectorAll('#vTabs .vtab')].filter((t) => !t.hidden).map((t) => t.textContent.trim()),
69
+ chips: [...document.querySelectorAll('#dBody .ctxc')].map((c) => [...c.querySelectorAll('.ctxchip')].map((b) => b.dataset.ctx + ':' + b.querySelector('b').textContent + (b.classList.contains('lead') ? '*' : ''))),
70
+ peek: peek && !peek.hidden ? peek.textContent.trim() : null, minH: Math.min(...[...document.querySelectorAll('#dBody .ctxchip')].map((b) => b.getBoundingClientRect().height)), wide: document.documentElement.scrollWidth > innerWidth + 1 };
71
+ };
72
+ const answer = async (p, conv, k, working) => { conv.messages = [...first(), ...second(k)]; conv.turn = working ? 'agent' : 'user'; };
73
+
74
+ { const { p, ctx, errs, conv } = await open(1280);
75
+ await sleep(2500); // a read after the first: an answer already there opens nothing
76
+ const s0 = await p.evaluate(look);
77
+ ok('C1 the answer that was there has its chips, the file Claude wrote first and the file it read after', JSON.stringify(s0.chips) === JSON.stringify([['file:signup-drop.md*', 'file:signup-fix.md']]), JSON.stringify(s0.chips));
78
+ ok('C1 it opens nothing by itself: the viewer stays closed', s0.shut && s0.out === 0 && s0.tabs.length === 0, JSON.stringify(s0));
79
+ await answer(p, conv, 1, true);
80
+ await sleep(2600);
81
+ const s1 = await p.evaluate(look);
82
+ ok('C2 while Claude still works, the new answer has no chips and nothing opens', s1.shut && s1.chips.length === 1, JSON.stringify(s1));
83
+ conv.turn = 'user';
84
+ const s2 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.tabs.length ? v : null; }, 6000) || await p.evaluate(look);
85
+ ok('C2 when it has finished, its main item (the file it changed) opens in the viewer', !s2.shut && s2.out > 300 && JSON.stringify(s2.tabs) === JSON.stringify(['signup-plan1.md']), JSON.stringify(s2));
86
+ ok('C2 its chips: the file it changed, then the ticket and the Slack channel it worked with; a ticket only read and not named comes after', JSON.stringify(s2.chips[1]) === JSON.stringify(['file:signup-plan1.md*', 'slack:Slack channel', 'jira:SGN-42', 'jira:SGN-7']), JSON.stringify(s2.chips));
87
+ await sleep(2500);
88
+ ok('C2 it opens once: later reads open nothing more', JSON.stringify((await p.evaluate(look)).tabs) === JSON.stringify(['signup-plan1.md']));
89
+ await p.click('#dBody .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-42"]');
90
+ const tk = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw="jira:SGN-42"]'); return e && /Fix the sign-up form/.test(e.textContent) ? { text: e.textContent, href: (e.querySelector('a') || {}).href } : null; }));
91
+ ok('C3 a Jira chip opens the ticket from the stored reading: key, summary, status, sprint, and Open in Jira', !!tk && /In Review/.test(tk.text) && /Active sprint: Sprint 14/.test(tk.text) && tk.href === 'https://acme.atlassian.net/browse/SGN-42', JSON.stringify(tk));
92
+ await p.click('#dBody .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-7"]');
93
+ const none = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw="jira:SGN-7"]'); return e && /no reading/.test(e.textContent) ? e.textContent : null; }));
94
+ ok('C3 a key with no stored reading says so and claims nothing', !!none, String(none));
95
+ await p.click('#dBody .ctxchip[data-ctx="slack"]');
96
+ const sl = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw^="slack:"]'); const a = e && e.querySelector('a'); return a ? a.href : null; }));
97
+ ok('C4 a Slack chip opens a tab with Open in Slack', sl === 'slack://channel?id=C0123ABCD', String(sl));
98
+ const s3 = await p.evaluate(look);
99
+ ok('C6 at 1280 every chip is at least 44 px and nothing scrolls sideways', s3.minH >= 44 && !s3.wide, JSON.stringify(s3));
100
+ if (shots) await p.screenshot({ path: `${shots}/chat-context-1280-light.png` });
101
+ ok('C6 no page error at 1280', errs.length === 0, errs.join(' | '));
102
+ await ctx.close(); }
103
+
104
+ for (const scheme of ['light', 'dark']) {
105
+ const { p, ctx, errs, conv } = await open(390, scheme);
106
+ await sleep(2500);
107
+ await answer(p, conv, 2, false);
108
+ const s0 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }, 6000) || await p.evaluate(look);
109
+ ok(`C5 at 390 (${scheme}) a new answer shows a bar over the message box and leaves the conversation uncovered`, /Claude wrote this · signup-plan2\.md\s*View/.test(s0.peek || '') && !s0.layer, JSON.stringify(s0));
110
+ if (shots) await p.screenshot({ path: `${shots}/chat-context-390-${scheme}.png` });
111
+ await p.click('#ctxPeek');
112
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.layer ? v : null; }) || await p.evaluate(look);
113
+ ok(`C5 at 390 (${scheme}) the bar's press opens the file in the viewer layer and the bar goes`, s1.layer && JSON.stringify(s1.tabs) === JSON.stringify(['signup-plan2.md']) && !s1.peek, JSON.stringify(s1));
114
+ await p.click('#vBack');
115
+ const s2 = await p.evaluate(look);
116
+ ok(`C6 at 390 (${scheme}) every chip is at least 44 px and nothing scrolls sideways`, s2.minH >= 44 && !s2.wide, JSON.stringify(s2));
117
+ ok(`C6 no page error at 390 (${scheme})`, errs.length === 0, errs.join(' | '));
118
+ await ctx.close();
119
+ }
120
+ return finish();
121
+ })();