create-pmos 0.379.0 → 0.381.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.379.0",
3
+ "version": "0.381.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.381.0",
37
+ "at": "2026-10-21T12:15:37.889Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 990,
42
+ "t": "Markdown tables draw as tables in the viewer, the Read tab and chat",
43
+ "s": "Markdown tables draw as tables in the viewer, the Read tab and chat"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "v": "0.380.0",
49
+ "at": "2026-10-21T09:18:41.886Z",
50
+ "f": 2,
51
+ "prs": [
52
+ {
53
+ "n": 989,
54
+ "t": "The /goal card opens in the viewer as a Goal tab",
55
+ "s": "The /goal card opens in the viewer as a Goal tab"
56
+ }
57
+ ]
58
+ },
35
59
  {
36
60
  "v": "0.379.0",
37
61
  "at": "2026-10-21T08:59:34.421Z",
@@ -297,30 +321,6 @@
297
321
  "s": "Premium Sprint tab folds past sprints, shows the goal from the tickets, opens every ticket"
298
322
  }
299
323
  ]
300
- },
301
- {
302
- "v": "0.361.0",
303
- "at": "2026-10-21T00:14:19.012Z",
304
- "f": 2,
305
- "prs": [
306
- {
307
- "n": 960,
308
- "t": "The morning brief runs on fresh sources; Sources says whether background work runs",
309
- "s": "PMOS reads the pane after it presses Enter."
310
- }
311
- ]
312
- },
313
- {
314
- "v": "0.360.0",
315
- "at": "2026-10-20T13:51:06.028Z",
316
- "f": 2,
317
- "prs": [
318
- {
319
- "n": 959,
320
- "t": "The Work queue has no Agents tab; agent state is a chip on the row and drafts wait in the bell",
321
- "s": "There is no Agents tab."
322
- }
323
- ]
324
324
  }
325
325
  ]
326
326
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@6bbfa917
1
+ kernel-source: pmos@d0e6ed0e
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-21T08:59:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T12:15:35Z"}
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-21T08:59:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T12:15:35Z"}
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-21T08:59:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T12:15:35Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,28 @@
1
1
  [
2
+ {
3
+ "v": "0.381.0",
4
+ "at": "2026-10-21T12:15:37.889Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 990,
9
+ "t": "Markdown tables draw as tables in the viewer, the Read tab and chat",
10
+ "s": "Markdown tables draw as tables in the viewer, the Read tab and chat"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "v": "0.380.0",
16
+ "at": "2026-10-21T09:18:41.886Z",
17
+ "f": 2,
18
+ "prs": [
19
+ {
20
+ "n": 989,
21
+ "t": "The /goal card opens in the viewer as a Goal tab",
22
+ "s": "The /goal card opens in the viewer as a Goal tab"
23
+ }
24
+ ]
25
+ },
2
26
  {
3
27
  "v": "0.379.0",
4
28
  "at": "2026-10-21T08:59:34.421Z",
@@ -224,6 +224,8 @@ Every markdown document opens as one page in a tab: a report, a PRD, a new docum
224
224
 
225
225
  A Confluence page or Google Doc opens as a tab too. From a document's **Copies**, press **Preview** on a copy. If the last check found the same text in both, the PMOS file is shown as the page, with **Same as PMOS** and the check time. If the copy changed, the tab says so and shows the PMOS version dimmed. **Use the … version** writes the copy's text into the PMOS file after five seconds; press **Undo** to stop it. From a meeting's **Material**, press the page icon on a Google Doc or Confluence link. PMOS holds only the address of such a page, so the tab says so. **Read it now** starts one session that reads the page with your connector and keeps the text in PMOS; it changes nothing in Google Docs or Confluence. The tab then shows the text with when it was read. Press **Read again** for later edits.
226
226
 
227
+ A table in any Markdown page (a document, a copy's text, a chat answer) shows as a table. This includes a table exported from Google Docs whose first row is empty and whose header is on the next row: that row becomes the header. Each column keeps its alignment, and cells keep their bold, code and links. A wide table keeps short cells on one line and scrolls sideways, and its first column stays in view.
228
+
227
229
  A decision opens with no option chosen, because no recommendation is on record. Its card shows the evidence as label and value rows, the options, and one **Why** field. One bar at the bottom holds a quiet **Later ▾** and the only main button, named after your choice (for example **Record: Extend the date**). Choose one and the draft entry on the right changes. Nothing is written. The main button, "Not yet" and "Return this run to the agent" are off in this version, and each says why.
228
230
 
229
231
  ## The conversation
@@ -461,12 +463,14 @@ Type `/` in the box to see the commands: `/goal`, `/compact` and `/clear`. Use t
461
463
 
462
464
  - **`/goal <what you want>`** asks Claude to make the goal SMART before any work. Claude reads the records first, then asks only what it could not find out: at most 5 questions, one at a time, about how you will know it is done, by when, whether it can be done here, and what it serves.
463
465
  - **Each question** shows its answers as buttons, with the recommended one marked. Press one, or answer in your own words. **Start with defaults** stops the questions; a value you did not give is marked "assumed".
464
- - **The goal card** shows the goal, its done points, what Claude may do, what it serves, the deadline and the round limit. Nothing runs until you press **Start**. **Change something** lets you say what to change; **Cancel** drops the goal.
466
+ - **The goal card** is in the viewer, in a **Goal** tab, like Notes. The conversation shows only a small Goal chip with the goal's state; press it to open the tab. On a phone the tab covers the page, and **Back** returns to the conversation.
467
+ - **The card** shows the goal, its done points, what Claude may do, what it serves, the deadline and the round limit. Nothing runs until you press **Start** (under Claude's message or in the Goal tab). **Change something** lets you say what to change; **Cancel** drops the goal.
465
468
  - **Start** tells Claude to work on the goal until every done point is met. Merging follows your standing rule (merge once required CI is green). Claude asks before anything that is sent to other people.
466
469
 
467
- - **While it works**, a goal card under the conversation shows the round, each done point met or open, and the deadline. The points are Claude's own report, so the card says "unverified". Each time Claude would stop with a point still open, it is told to keep going.
470
+ - **While it works**, the Goal tab shows the round, each done point met or open, and the deadline. The points are Claude's own report, so the card says "unverified". Each time Claude would stop with a point still open, it is told to keep going.
468
471
  - **It stops by itself** when Claude reports every point met (Done), when it needs you (Needs you: answer it in the box and it goes on), at the deadline, after the round limit (12 unless the goal says fewer), or after 3 rounds that met no new point. The card says which.
469
- - **Stop the goal** presses Esc in the session and ends the goal.
472
+ - **When the goal changes** (it starts, a point is met, it stops, it needs you, it is done), the Goal tab opens by itself on a desktop. On a phone a bar over the box offers it, so the conversation stays in view.
473
+ - **Stop the goal** is in the Goal tab. It presses Esc in the session and ends the goal.
470
474
  - **In the bell**, a goal that is done, stopped or needs you is an item. Pressing it opens the goal's own conversation. The item goes when you write in that conversation, or after a week.
471
475
 
472
476
  Start, Cancel and Stop need the page's launch nonce too. The goal and each round are kept in `goal-runs.jsonl` in the state folder.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.379.0",
3
+ "version": "0.381.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.379.0",
9
+ "version": "0.381.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.379.0",
3
+ "version": "0.381.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,126 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-chat-goal-view-test.js — the /goal card lives in the viewer, not in the conversation (initiative premium-chat-session, goal in the viewer).
4
+ * A real server on a scratch repository (c3-scan-fixture.js); the thread and the session's conversation are routed, so the goal's state is set here.
5
+ * G1 at 1280 a stopped goal draws no card in the conversation, only a small Goal chip; the chip opens a Goal tab with the card
6
+ * G2 a goal that changes state opens the Goal tab by itself on a desktop, and the open tab follows the next change
7
+ * G3 a ready goal: the conversation shows only the chip; the plan, SMART and Start / Change / Cancel are in the Goal tab
8
+ * G4 Stop the goal is in the Goal tab and reaches the server
9
+ * G5 at 390 the chip covers the page with the Goal tab and Back; a change offers the goal in the bar over the box
10
+ * Set GOAL_VIEW_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
11
+ const { findBrowser } = require('./lib/find-browser');
12
+ require('./test-run').configure({ name: 'premium-chat-goal-view' });
13
+ const Fx = require('./c3-scan-fixture.js');
14
+
15
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
16
+ 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); } };
17
+ const results = [];
18
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
19
+ let F = null, browser = null;
20
+ const finish = async (code) => {
21
+ if (browser) await browser.close().catch(() => {});
22
+ if (F) F.stop();
23
+ const bad = results.filter((x) => !x.cond).length;
24
+ console.log(`\n${results.length - bad}/${results.length} premium-chat-goal-view assertions passed`);
25
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
26
+ };
27
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
28
+
29
+ const DRAFT = {
30
+ goal: 'Enrich the Lightbox password sign-up and login reports with drop reasons, per-step durations and segments, for yesterday',
31
+ done: ['Tables for durations, anomalies and segments exist for yesterday', 'Each drop has a reason label inferred from the events', 'Totals match GA4 Explore counts for yesterday'],
32
+ may: 'Read BigQuery and write to the reports folder', serves: 'q4:o1:kr2', by: '2026-10-22 17:00', limit: 12, assumed: ['by'],
33
+ };
34
+ const READY = 'The goal is clear. Press Start when it reads right.\n\n```pmos-goal\n' + JSON.stringify({ step: 'ready', draft: DRAFT }) + '\n```';
35
+ const goalOf = (state, extra = {}) => ({ id: 'g1', state, draft: DRAFT, met: [], rounds: 2, ...extra });
36
+
37
+ /* the page's own state */
38
+ const look = () => {
39
+ const g = document.querySelector('#dlg'), out = document.querySelector('#dOut').getBoundingClientRect(), gp = document.querySelector('#dOut .obody.vw[data-vw="goal"]');
40
+ const peek = document.querySelector('#ctxPeek');
41
+ return { shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), out: Math.round(out.width), outH: Math.round(out.height), vh: innerHeight,
42
+ cardInChat: !!document.querySelector('#dBody .gcard'), chip: (document.querySelector('#dBody [data-goal-open]') || {}).textContent || null,
43
+ smart: !!document.querySelector('#dBody .smart'), start: !!document.querySelector('#dBody [data-goal="start"]'),
44
+ tabs: [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.textContent.trim()), on: (document.querySelector('#vTabs .vtab[aria-selected="true"]') || {}).textContent || null,
45
+ pane: gp && !gp.hidden ? gp.textContent.replace(/\s+/g, ' ').trim() : null, stop: !!document.querySelector('#dOut [data-goal="stop"]'),
46
+ peek: peek && !peek.hidden ? peek.textContent.trim() : null, back: !!document.querySelector('#vBack') && getComputedStyle(document.querySelector('#vBack')).display !== 'none',
47
+ railOff: getComputedStyle(document.querySelector('.rail')).opacity === '0', wide: document.documentElement.scrollWidth > innerWidth + 1 };
48
+ };
49
+
50
+ (async () => {
51
+ const exe = findBrowser();
52
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
53
+ let chromium;
54
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
55
+ F = await Fx.start({ name: 'premium-chat-goal-view' });
56
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
57
+ const shots = process.env.GOAL_VIEW_SHOTS;
58
+ const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}`;
59
+ const open = async (width, scheme, first) => {
60
+ const st = { goal: first.goal, messages: first.messages, posts: [] };
61
+ const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 800 }, colorScheme: scheme, hasTouch: width < 1000 });
62
+ const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
63
+ await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-goal', goal: st.goal } }));
64
+ await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'pm', messages: st.messages } }));
65
+ await p.route('**/api/briefing-premium/goal**', (r) => { st.posts.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ json: { ok: true } }); });
66
+ await p.goto(chat);
67
+ await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream #thr')));
68
+ await sleep(400);
69
+ return { p, ctx, errs, st };
70
+ };
71
+ const working = [{ role: 'user', text: '[PMOS /goal start] Start the goal' }, { role: 'tool', tools: { execute_sql_readonly: 1, get_query_results: 1 }, calls: [] }, { role: 'assistant', text: 'Round two: the duration table is written; the reason labels are next.' }];
72
+
73
+ { const { p, ctx, errs, st } = await open(1280, 'light', { goal: goalOf('stopped', { reason: 'pm' }), messages: working });
74
+ const s0 = await p.evaluate(look);
75
+ ok('G1 at 1280 a stopped goal draws no card in the conversation, only a small Goal chip', !s0.cardInChat && /Stopped/.test(s0.chip || '') && /0 of 3/.test(s0.chip || ''), JSON.stringify(s0));
76
+ ok('G1 opening the chat with a goal opens nothing by itself', s0.shut && s0.tabs.length === 0, JSON.stringify(s0));
77
+ if (shots) await p.screenshot({ path: `${shots}/chip-1280-light.png` });
78
+ await p.click('#dBody [data-goal-open]');
79
+ const s1 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.pane ? v : null; }) || await p.evaluate(look);
80
+ ok('G1 the chip opens a Goal tab with the goal, its done points and why it stopped', /Goal/.test(s1.on || '') && /Stopped/.test(s1.pane || '') && /0 of 3 done points met/.test(s1.pane || '') && /Totals match GA4/.test(s1.pane || '') && /You stopped it/.test(s1.pane || ''), JSON.stringify(s1));
81
+ await p.click('#vTabs [data-vx]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('vw-shut')));
82
+ st.goal = goalOf('started', { met: [DRAFT.done[0]] });
83
+ const s2 = await until(async () => { const v = await p.evaluate(look); return v.pane && /round 3/.test(v.pane) ? v : null; }) || await p.evaluate(look);
84
+ ok('G2 a goal that changes state opens the Goal tab by itself', !s2.shut && /Goal/.test(s2.on || '') && /1 of 3 done points met/.test(s2.pane || ''), JSON.stringify(s2));
85
+ ok('G4 Stop the goal is in the Goal tab, not in the conversation', s2.stop && !(await p.evaluate(() => !!document.querySelector('#dBody [data-goal="stop"]'))), JSON.stringify(s2));
86
+ if (shots) await p.screenshot({ path: `${shots}/goal-1280-light.png` });
87
+ await p.click('#dOut [data-goal="stop"]');
88
+ const posted = await until(() => st.posts.find((x) => x.act === 'stop'));
89
+ ok('G4 Stop reaches the server for this goal', posted && posted.id === 'g1', JSON.stringify(st.posts));
90
+ st.goal = goalOf('done', { met: DRAFT.done });
91
+ const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Done, as Claude reports it/.test(v.pane) ? v : null; }) || await p.evaluate(look);
92
+ ok('G2 the open Goal tab follows the next change', /3 of 3 done points met/.test(s3.pane || '') && !s3.stop, JSON.stringify(s3));
93
+ ok('F1 no page error and no sideways scroll', !errs.length && !s3.wide, errs.join(' | '));
94
+ await ctx.close(); }
95
+
96
+ { const { p, ctx, errs, st } = await open(1280, 'dark', { goal: goalOf('grilling'), messages: [{ role: 'user', text: '[PMOS /goal] The PM set a goal: Enrich the Lightbox reports\n' }, { role: 'assistant', text: READY }] });
97
+ const s0 = await p.evaluate(look);
98
+ ok('G3 a ready goal is one chip in the conversation: no card, no SMART row, no buttons', !s0.smart && !s0.start && !s0.cardInChat && /Not started/.test(s0.chip || ''), JSON.stringify(s0));
99
+ await p.click('#dBody [data-goal-open]');
100
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane ? v : null; }) || await p.evaluate(look);
101
+ ok('G3 the Goal tab shows the plan: done when, may, serves, by', /Done when/.test(s1.pane || '') && /It may/.test(s1.pane || '') && /Serves/.test(s1.pane || '') && /Not started/.test(s1.pane || ''), JSON.stringify(s1));
102
+ await p.click('#dOut [data-goal="start"]');
103
+ const sent = await until(() => st.posts.find((x) => x.act === 'start'));
104
+ ok('G3 Start in the Goal tab sends the ready draft for this goal', sent && sent.id === 'g1' && sent.draft && sent.draft.goal === DRAFT.goal, JSON.stringify(st.posts));
105
+ if (shots) await p.screenshot({ path: `${shots}/ready-1280-dark.png` });
106
+ ok('F1 (dark) no page error and no sideways scroll', !errs.length && !s1.wide, errs.join(' | '));
107
+ await ctx.close(); }
108
+
109
+ for (const scheme of ['light', 'dark']) {
110
+ const { p, ctx, errs, st } = await open(390, scheme, { goal: goalOf('started', { met: [DRAFT.done[0]] }), messages: working });
111
+ const s0 = await p.evaluate(look);
112
+ ok(`G5 (${scheme}) at 390 the conversation shows the chip, not the card`, !s0.cardInChat && /Working/.test(s0.chip || '') && !s0.layer, JSON.stringify(s0));
113
+ if (shots) await p.screenshot({ path: `${shots}/chip-390-${scheme}.png` });
114
+ await p.click('#dBody [data-goal-open]');
115
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.layer && v.pane && v.outH >= v.vh - 2 && v.railOff ? v : null; }) || await p.evaluate(look);
116
+ ok(`G5 (${scheme}) the chip covers the page with the Goal tab and Back`, s1.layer && s1.back && /1 of 3 done points met/.test(s1.pane || '') && s1.outH >= s1.vh - 2, JSON.stringify(s1));
117
+ if (shots) await p.screenshot({ path: `${shots}/goal-390-${scheme}.png` });
118
+ await p.click('#vBack'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('vw-layer')));
119
+ st.goal = goalOf('waiting', { met: [DRAFT.done[0]] });
120
+ const s2 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }) || await p.evaluate(look);
121
+ ok(`G5 (${scheme}) a change offers the goal in the bar over the box, without covering the conversation`, /Needs you/.test(s2.peek || '') && !s2.layer, JSON.stringify(s2));
122
+ ok(`F1 (${scheme}) no page error and no sideways scroll at 390`, !errs.length && !s2.wide, errs.join(' | '));
123
+ await ctx.close();
124
+ }
125
+ return finish();
126
+ })();
@@ -2,6 +2,7 @@
2
2
  * Claude's turns are markdown: headings, **bold**, lists, `code`, fences, links, tables and quotes are drawn, not printed as their marks.
3
3
  * Everything is escaped first and the marks are read from the escaped text, so no HTML in a message reaches the page. Links open only
4
4
  * http(s). The PM's own turns lose the <pasted_content> wrapper Claude Code puts around a paste, and keep their line breaks. */
5
+ import { tableStarts, readTable, tableHtml } from './md-table.js';
5
6
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
6
7
 
7
8
  /* A file path Claude wrote (PM, 2026-10-20: "Why can't I click the file and see it on the right panel?"): a `code` span, a [name](path) link or a bare
@@ -45,8 +46,6 @@ function inline(t) {
45
46
  .replace(/~~(?=\S)([\s\S]*?\S)~~/g, '<del>$1</del>');
46
47
  return s.replace(/\u0000(\d+)\u0000/g, (_, i) => keep[+i]);
47
48
  }
48
- const cells = (l) => l.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map((c) => c.trim());
49
- const isRule = (l) => l.includes('|') && /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(l);
50
49
  const LI = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/;
51
50
 
52
51
  /** A list's items ({ ind, ord, html }) as nested <ul>/<ol>: a deeper item opens a list inside the item above it. */
@@ -85,14 +84,7 @@ function blocks(lines) {
85
84
  const h = /^\s*(#{1,6})\s+(.*?)\s*#*\s*$/.exec(l);
86
85
  if (h) { flush(); out.push(`<h${h[1].length > 3 ? 6 : h[1].length + 3}>${inline(h[2])}</h${h[1].length > 3 ? 6 : h[1].length + 3}>`); continue; }
87
86
  if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(l)) { flush(); out.push('<hr>'); continue; }
88
- if (l.includes('|') && i + 1 < lines.length && isRule(lines[i + 1])) {
89
- flush();
90
- const head = cells(l), rows = [];
91
- for (i += 2; i < lines.length && lines[i].includes('|') && lines[i].trim(); i++) rows.push(cells(lines[i]));
92
- i--;
93
- out.push(`<div class="mdtab"><table><thead><tr>${head.map((c) => `<th>${inline(c)}</th>`).join('')}</tr></thead><tbody>${rows.map((r) => `<tr>${head.map((_, c) => `<td>${inline(r[c] || '')}</td>`).join('')}</tr>`).join('')}</tbody></table></div>`);
94
- continue;
95
- }
87
+ if (tableStarts(lines, i)) { flush(); const t = readTable(lines, i); i = t.end; out.push(tableHtml(t, inline, 'mdtab')); continue; }
96
88
  if (/^\s*&gt;/.test(l)) {
97
89
  flush();
98
90
  const q = [];
@@ -62,9 +62,8 @@ export function goalBlockHtml(block, { live = false, state = 'grilling' } = {})
62
62
  return `${smartHtml(d)}<p class="tt"><b>${esc(block.question || '')}</b></p>${chips}`;
63
63
  }
64
64
  if (block.step === 'ready') {
65
- const ok = !!(d.goal && Array.isArray(d.done) && d.done.length);
66
- const btns = live && ok ? '<div class="chatopts"><button type="button" class="cta" data-goal="start">Start</button><button type="button" class="cta alt" data-goal="change">Change something</button><button type="button" class="cta alt" data-goal="cancel">Cancel</button></div>' : '';
67
- return `${smartHtml(d)}${goalCard(d, state)}${btns}`;
65
+ // the plan, SMART and Start / Change / Cancel are in the viewer's Goal tab (goalViewHtml); once started, the progress chip at the end stands for it
66
+ return !state || state === 'grilling' || state === 'cancelled' ? goalChipHtml({ draft: d, state }) : '';
68
67
  }
69
68
  if (block.step === 'progress') {
70
69
  const met = Array.isArray(block.met) ? block.met.length : 0, open = Array.isArray(block.open) ? block.open.length : 0;
@@ -75,6 +74,36 @@ export function goalBlockHtml(block, { live = false, state = 'grilling' } = {})
75
74
  }
76
75
 
77
76
  const WHY = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.' };
77
+ const GICO = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8"/></svg>';
78
+ /** What the chip under the goal says: its state, then the done points met once it has started. */
79
+ function goalLine(goal) {
80
+ const d = goal.draft || {}, all = Array.isArray(d.done) ? d.done.length : 0, met = Array.isArray(goal.met) ? goal.met.length : 0;
81
+ const word = { started: 'Working', done: 'Done', waiting: 'Needs you', stopped: 'Stopped', cancelled: 'Cancelled' }[goal.state] || 'Not started';
82
+ return ['started', 'done', 'waiting', 'stopped'].includes(goal.state) ? `${word} · ${met} of ${all} done points` : word + (all ? ` · ${all} done points` : '');
83
+ }
84
+ /** The goal in the conversation is one small chip (goal in the viewer, Wawan 2026-10-21): the plan and its progress open in the viewer's Goal tab.
85
+ * goal: { draft, state, met? }. */
86
+ export function goalChipHtml(goal) {
87
+ if (!goal || !goal.draft) return '';
88
+ return `<div class="ctxc"><button type="button" class="ctxchip lead" data-goal-open title="Open the goal in the viewer">${GICO}<span><b>${esc(goal.draft.goal || 'Goal')}</b><em>Goal · ${esc(goalLine(goal))}</em></span></button></div>`;
89
+ }
90
+ /** The viewer's Goal tab. goal: the GET /thread goal record; draft: the newest ready draft in the conversation; live: Start can be pressed.
91
+ * A goal that has started shows its progress with Stop; one still being grilled shows the plan, with Start, Change and Cancel while live. */
92
+ export function goalViewHtml(goal, draft, { live = false } = {}) {
93
+ const gp = goalProgressHtml(goal);
94
+ if (gp) return `<div class="vwdoc vwgoal">${gp}</div>`;
95
+ if (!draft) return '';
96
+ const ok = !!(draft.goal && Array.isArray(draft.done) && draft.done.length);
97
+ const btns = live && ok ? '<div class="chatopts"><button type="button" class="cta" data-goal="start">Start</button><button type="button" class="cta alt" data-goal="change">Change something</button><button type="button" class="cta alt" data-goal="cancel">Cancel</button></div>' : '';
98
+ return `<div class="vwdoc vwgoal">${smartHtml(draft)}${goalCard(draft, goal && goal.state)}${btns}</div>`;
99
+ }
100
+ /** What the chip and the peek bar say about the goal now, and a key that changes when its state or progress does. */
101
+ export function goalNow(goal, draft) {
102
+ const g = goal && goal.draft ? goal : draft ? { draft, state: goal ? goal.state : 'grilling' } : null;
103
+ if (!g) return null;
104
+ return { title: g.draft.goal || 'Goal', sub: 'Goal · ' + goalLine(g), sig: [goal && goal.id, g.state, (goal && goal.met || []).length, goal && goal.rounds, draft ? JSON.stringify(draft) : ''].join('|') };
105
+ }
106
+
78
107
  /** The working goal's card (slice 3, PRD U4, U5): its state, the round, each done point met or open, and Stop while it works.
79
108
  * goal: the GET /thread goal record. The done check is Claude's own report, so it says "unverified". */
80
109
  export function goalProgressHtml(goal) {
@@ -0,0 +1,53 @@
1
+ /* md-table.js — one GitHub-style markdown table reader for every place PMOS draws markdown (the viewer's document page, the Read tab of the document
2
+ * sheet, a tool copy such as a Google Doc read, and chat answers). Pure: no DOM, so Node tests it.
3
+ * PM, 2026-10-21 ("Bad formatting on View panel"): a Google Doc read came back with an empty first row, a `:-:` rule and the real header on the
4
+ * row after it. The old readers wanted two dashes in the rule and printed the whole table as a grey code block. This reader takes any GitHub rule
5
+ * (one dash or more, with or without colons), keeps each column's alignment, splits only on pipes that are not escaped (`\|`), and when the header
6
+ * row is empty it uses the first body row as the header, as the Google Docs export means it. */
7
+
8
+ /** True when the line is a table's rule row: `| --- | :-: | --: |`, with or without outer pipes. One column needs a pipe so a plain `---` stays a rule. */
9
+ export function isTableRule(l) {
10
+ const s = String(l || '');
11
+ return s.includes('|') && /^\s{0,3}\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(s);
12
+ }
13
+
14
+ /** The cells of one table row, trimmed. Outer pipes are optional; an escaped pipe `\|` stays in its cell as `|`. */
15
+ export function tableCells(l) {
16
+ const s = String(l || '').trim().replace(/^\|/, '').replace(/(^|[^\\])\|$/, '$1');
17
+ const out = [];
18
+ let cur = '';
19
+ for (let k = 0; k < s.length; k++) {
20
+ if (s[k] === '\\' && s[k + 1] === '|') { cur += '|'; k++; } else if (s[k] === '|') { out.push(cur.trim()); cur = ''; } else cur += s[k];
21
+ }
22
+ out.push(cur.trim());
23
+ return out;
24
+ }
25
+
26
+ /** True when line `i` starts a table: it has a pipe and the next line is a rule row. */
27
+ export function tableStarts(lines, i) {
28
+ return i + 1 < lines.length && String(lines[i]).includes('|') && !isTableRule(lines[i]) && isTableRule(lines[i + 1]);
29
+ }
30
+
31
+ /** Reads the table that starts at line `i` (see tableStarts). Returns { head, align, rows, end } where `end` is the last line the table uses.
32
+ * `align` holds 'left', 'center', 'right' or '' per column. Body rows run while a line has a pipe and is not blank. An empty header row is
33
+ * replaced by the first body row. Every row has as many cells as the widest of the header and the rule. */
34
+ export function readTable(lines, i) {
35
+ let head = tableCells(lines[i]);
36
+ const rule = tableCells(lines[i + 1]);
37
+ const align = rule.map((c) => (/^:-+:$/.test(c) ? 'center' : /-:$/.test(c) ? 'right' : /^:-/.test(c) ? 'left' : ''));
38
+ let rows = [], j = i + 2;
39
+ for (; j < lines.length && String(lines[j]).includes('|') && String(lines[j]).trim(); j++) rows.push(tableCells(lines[j]));
40
+ if (head.every((c) => !c) && rows.length) head = rows.shift();
41
+ rows = rows.filter((r) => r.some((c) => c));
42
+ const n = Math.max(head.length, rule.length);
43
+ const fit = (r) => Array.from({ length: n }, (_, k) => r[k] || '');
44
+ return { head: fit(head), align: fit(align), rows: rows.map(fit), end: j - 1 };
45
+ }
46
+
47
+ /** The table as html. `inline` turns one cell's text into html (it escapes, or the text is escaped already); `cls` is the wrapper's class,
48
+ * which scrolls the table sideways on a narrow screen. */
49
+ export function tableHtml(t, inline, cls) {
50
+ const al = (k) => (t.align[k] ? ` class="al-${t.align[k][0]}"` : ''); // al-l, al-c, al-r: the stylesheets align them
51
+ return `<div class="${cls}"><table><thead><tr>${t.head.map((c, k) => `<th${al(k)}>${inline(c)}</th>`).join('')}</tr></thead>`
52
+ + `<tbody>${t.rows.map((r) => `<tr>${r.map((c, k) => `<td${al(k)}>${inline(c)}</td>`).join('')}</tr>`).join('')}</tbody></table></div>`;
53
+ }
@@ -1,6 +1,7 @@
1
1
  /* premium-doc-edit.js — the pure half of the premium document sheet's Edit and Proposals tabs (initiative briefing-premium-doc-edit).
2
2
  * No DOM and no fetch: it turns the answers of /api/doc-sheet/* into what the tabs draw, and builds the bodies of the presses. Every figure here is a
3
3
  * field of a route's answer; a proposal's section is stale only because the route says it is. */
4
+ import { tableStarts, readTable, tableHtml } from './md-table.js';
4
5
  const esc = (s) => String(s == null ? '' : s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
5
6
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
6
7
 
@@ -85,7 +86,6 @@ export function inlineHtml(t) {
85
86
  h = h.replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2" target="_blank" rel="noopener">$1</a>');
86
87
  return h;
87
88
  }
88
- const cells = (l) => l.trim().replace(/^\||\|$/g, '').split('|').map((c) => c.trim());
89
89
 
90
90
  /** The Read tab's text as html with its outline and front matter. Pure: the page puts the html in the sheet. `outline` holds the heading texts, `levels` their depth (1 to 4). */
91
91
  export function mdHtml(text, opts) {
@@ -102,12 +102,10 @@ export function mdHtml(text, opts) {
102
102
  if (h) { flushP(); flushL(); const n = outline.length; outline.push(h[2].replace(/[*`]/g, '')); levels.push(h[1].length); out.push(`<h3 class="d2" id="ds-h${n}">${inlineHtml(h[2])}</h3>`); const at = opts && opts.attr && opts.attr[n]; if (at) out.push(`<p class="dsat"><i>${esc(at.initial)}</i>${esc(at.who)} · ${esc(at.rev)}${at.date ? ' · ' + esc(at.date) : ''}</p>`); continue; }
103
103
  const ul = /^\s*[-*]\s+(.*)$/.exec(l), ol = /^\s*\d+[.)]\s+(.*)$/.exec(l);
104
104
  if (ul || ol) { flushP(); if (list.length && ord !== !!ol) flushL(); ord = !!ol; list.push((ul || ol)[1]); continue; }
105
- if (/^\|/.test(l)) {
106
- flushP(); flushL(); const buf = [l]; while (i + 1 < lines.length && /^\|/.test(lines[i + 1])) buf.push(lines[++i]);
107
- if (buf.length >= 2 && /^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(buf[1])) {
108
- const head = cells(buf[0]), rows = buf.slice(2).map(cells);
109
- out.push(`<div class="mdt"><table><thead><tr>${head.map((c) => `<th>${inlineHtml(c)}</th>`).join('')}</tr></thead><tbody>${rows.map((r) => `<tr>${head.map((_, k) => `<td>${inlineHtml(r[k] || '')}</td>`).join('')}</tr>`).join('')}</tbody></table></div>`);
110
- } else out.push(`<pre class="mdp">${esc(buf.join('\n'))}</pre>`);
105
+ if (tableStarts(lines, i)) { flushP(); flushL(); const t = readTable(lines, i); i = t.end; out.push(tableHtml(t, inlineHtml, 'mdt')); continue; }
106
+ if (/^\s{0,3}\|/.test(l)) {
107
+ flushP(); flushL(); const buf = [l]; while (i + 1 < lines.length && /^\s{0,3}\|/.test(lines[i + 1])) buf.push(lines[++i]);
108
+ out.push(`<pre class="mdp">${esc(buf.join('\n'))}</pre>`);
111
109
  continue;
112
110
  }
113
111
  if (!l.trim()) { flushP(); flushL(); continue; }
@@ -1,13 +1,13 @@
1
1
  /* pm/premium-shell.js — what the premium Briefing and My work pages share: the theme, the toast, the standard dialog and the read-only agent's conversation (initiatives briefing-premium and my-work-premium). */
2
2
  import { pmGet, pmPost } from './http.js';
3
3
  import { recChipView, STOP_LINE } from './premium-meeting.js';
4
- import { vwReset, vwOn, vwCount } from './premium-viewer.js';
4
+ import { vwReset, vwOn, vwCount, vwOpen, vwStyle } from './premium-viewer.js';
5
5
  import { openChatFile, openWebLink } from './premium-vw-file.js';
6
6
  import { turnsOf } from './chat-context.js';
7
7
  import { chipsHtml, itemOf, openCtx } from './premium-vw-ctx.js';
8
8
  import { chipActs, openLive, openFocus, mountRecord, HL_LINE } from './premium-vw-rec.js';
9
9
  import { lineItems, behindOf, whenRead } from './freshness-words.js';
10
- import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, slashMatches } from './goal-chat.js';
10
+ import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches } from './goal-chat.js';
11
11
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
12
12
  import { mountNotes, openNotes, flushNotes, syncNotes } from './premium-notes.js';
13
13
  import { attachMarkup, attachRowMarkup, mountAttach, attachNames, clearAttach, syncAttach, dropFiles, splitFiles, filesHtml, openAttachment } from './premium-attach.js';
@@ -414,7 +414,7 @@ export function sessionHtml(c, goal = null) {
414
414
  const live = i === last && waiting && !!goal && goal.state === 'grilling';
415
415
  return turnAgent(`<p class="agtag">Claude</p>${g.text ? mdHtml(g.text) : ''}${goalBlockHtml(g.block, { live, state: goal && goal.state })}${chipsHtml(ctx.get(i))}`);
416
416
  });
417
- const gp = goalProgressHtml(goal); if (gp) out.push(gp);
417
+ if (goalProgressHtml(goal)) out.push(goalChipHtml(goal)); // the goal itself is in the viewer's Goal tab (goalView below)
418
418
  // item-chat-history: an ended session keeps its conversation on the item; the next message picks it up
419
419
  if (c.state === 'ended') out.push(turnAgent('<p class="tt" role="status">This session has ended. Your conversation is kept here, and your next message picks it up.</p>'));
420
420
  else if (c.ask) out.push(turnAgent(`<p class="agtag">Claude asks before it goes on</p><p class="tt">${esc(c.ask.question)}</p><div class="chatopts">${(c.ask.options || []).map((o) => `<button type="button" class="cta alt" data-chat-press="${esc(o.n)}">${esc(o.label)}</button>`).join('')}</div>`));
@@ -440,6 +440,7 @@ export function drawThread(th, key, conv) {
440
440
  putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal));
441
441
  ctxAuto(key, conv);
442
442
  S.goal = th.goal || null; S.draft = readyDraft(conv); S.session = th.session || null;
443
+ goalView(key, conv);
443
444
  const go = $('#askGo'); if (go) go.disabled = !!th.working; // an earlier read-only run still answering
444
445
  const n = $('#askNote'); if (n) n.textContent = th.working ? 'The agent is answering. You can write again when it has.' : conv && conv.ask ? 'Claude is waiting for your answer above.' : CHAT_NOTE;
445
446
  if (atEnd) b.scrollTop = b.scrollHeight;
@@ -480,7 +481,7 @@ function ctxPeek(it) {
480
481
  const f = $('#askF'); if (!f) return;
481
482
  if (!b) { f.insertAdjacentHTML('beforebegin', '<button type="button" class="ctxpeek" id="ctxPeek" hidden></button>'); b = $('#ctxPeek'); }
482
483
  b.innerHTML = `<span>${esc(it.sub)} · <b>${esc(it.title)}</b></span><em>View</em>`; b.hidden = false;
483
- b.onclick = () => { ctxPeek(null); openCtx(it, ctxWhere()); };
484
+ b.onclick = () => { ctxPeek(null); if (it.kind === 'goal') openGoal(); else openCtx(it, ctxWhere()); };
484
485
  CTX.peekTimer = setTimeout(() => ctxPeek(null), 15000);
485
486
  }
486
487
  $('#dBody').addEventListener('click', (e) => {
@@ -488,6 +489,32 @@ $('#dBody').addEventListener('click', (e) => {
488
489
  e.preventDefault(); openCtx(itemOf(b), ctxWhere());
489
490
  if (innerWidth < 1000 && !chatPage()) setTab('out');
490
491
  });
492
+ /* The /goal card lives in the viewer as a Goal tab, like Notes (Wawan 2026-10-21); the conversation keeps a small chip that opens it.
493
+ * An open tab follows every change. A change of the goal's state or progress while the chat is open opens the tab by itself on a desktop
494
+ * and offers it in the bar over the box on a phone; a goal that was already there when the chat opened opens nothing. */
495
+ const GV = { key: null, sig: null };
496
+ const goalLive = (conv) => !!S.goal && S.goal.state === 'grilling' && !!conv && !conv.ask && conv.turn !== 'agent' && conv.turn !== 'tool';
497
+ const goalPane = () => document.querySelector('#dOut .obody.vw[data-vw="goal"]');
498
+ function openGoal() {
499
+ const html = goalViewHtml(S.goal, S.draft, { live: goalLive(S.conv) }); if (!html) return null;
500
+ vwStyle('doc');
501
+ return vwOpen({ id: 'goal', title: 'Goal', icon: 'goal', render: (el) => { el.innerHTML = goalViewHtml(S.goal, S.draft, { live: goalLive(S.conv) }); } });
502
+ }
503
+ function goalView(key, conv) {
504
+ S.conv = conv;
505
+ const now = goalNow(S.goal, S.draft);
506
+ const p = goalPane();
507
+ if (p) { const h = goalViewHtml(S.goal, S.draft, { live: goalLive(conv) }); if (p.__h !== h) { p.__h = h; p.innerHTML = h; } }
508
+ const first = GV.key !== key; GV.key = key;
509
+ const sig = now ? now.sig : null, was = GV.sig; GV.sig = sig;
510
+ if (first || !now || sig === was) return;
511
+ if (desk()) openGoal(); else ctxPeek({ kind: 'goal', title: now.title, sub: now.sub });
512
+ }
513
+ $('#dBody').addEventListener('click', (e) => {
514
+ if (!e.target.closest('[data-goal-open]')) return;
515
+ e.preventDefault(); openGoal();
516
+ if (innerWidth < 1000 && !chatPage()) setTab('out');
517
+ });
491
518
  /** The draft of the newest ready goal block in the conversation, which Start sends as the confirmed goal. */
492
519
  function readyDraft(conv) {
493
520
  const ms = (conv && conv.messages) || [];
@@ -541,7 +568,7 @@ async function sendText(key, text, files) {
541
568
  loadThread(key);
542
569
  return true;
543
570
  }
544
- $('#dBody').addEventListener('click', async (e) => {
571
+ async function onGoalPress(e) {
545
572
  const say = e.target.closest('[data-chat-say]'), gb = e.target.closest('[data-goal]'), mi = e.target.closest('[data-slash]');
546
573
  if (mi) { pickSlash(mi.dataset.slash); return; }
547
574
  if (!S.key || (!say && !gb)) return;
@@ -553,7 +580,9 @@ $('#dBody').addEventListener('click', async (e) => {
553
580
  const r = await chatPost('goal', { key: S.key, id: S.goal.id, act, draft: S.draft });
554
581
  $('#askNote').textContent = r && r.ok ? ({ start: 'Claude is starting on the goal.', cancel: 'The goal is cancelled.', stop: 'The goal is stopped.' }[act]) : (r && r.error) || 'The press did not reach the session.';
555
582
  loadThread(S.key);
556
- });
583
+ }
584
+ $('#dBody').addEventListener('click', onGoalPress);
585
+ $('#dOut').addEventListener('click', (e) => { if (e.target.closest('.vwgoal [data-goal]')) onGoalPress(e); }); // Start, Change, Cancel and Stop in the Goal tab
557
586
  /* the `/` menu (G1): opens on a leading `/`, arrows move, Enter or Tab picks, Esc shuts it */
558
587
  let slashAt = 0;
559
588
  function drawSlash() {
@@ -13,6 +13,7 @@ const MAX = 4;
13
13
  const IC = {
14
14
  doc: 'M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h5', cal: 'M3.5 5h17v15h-17zM3.5 10h17M8 3v4M16 3v4', notes: 'M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h5',
15
15
  tk: 'M4 4h16v16H4zM8.5 12.5l2.5 2.5 4.5-5', list: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01', mic: 'M9 3h6v11H9zM5 11a7 7 0 0 0 14 0M12 18v3',
16
+ goal: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8',
16
17
  };
17
18
  const svg = (k) => `<svg class="i" viewBox="0 0 24 24"><path d="${IC[k] || IC.doc}"/></svg>`;
18
19
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
@@ -2,6 +2,7 @@
2
2
  * No DOM and no fetch. It draws a markdown file as a page (title, byline, properties from the front matter, panels, tables, task lists, status labels,
3
3
  * expand blocks, code blocks), lays an open proposal from GET /api/doc-sheet/proposals over the current text with each changed section marked, and
4
4
  * merges an edited page back into the file so that sections nobody touched keep their exact text. Every value comes from the file, its log or the route. */
5
+ import { tableStarts, readTable, tableHtml } from './md-table.js';
5
6
  const esc = (s) => String(s == null ? '' : s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
6
7
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
7
8
 
@@ -61,15 +62,8 @@ export function bodyHtml(src, o = {}) {
61
62
  else out.push(`<blockquote><p>${inl(buf.join(' '))}</p></blockquote>`);
62
63
  continue;
63
64
  }
64
- if (/^\s*\|/.test(l)) {
65
- const rows = []; while (i < L.length && /^\s*\|/.test(L[i])) rows.push(L[i++]);
66
- const cells = (r) => r.trim().replace(/^\||\|$/g, '').split('|').map((c) => c.trim());
67
- if (rows.length >= 2 && /^\s*\|?\s*:?-{2,}/.test(rows[1])) {
68
- const hd = cells(rows[0]);
69
- out.push(`<div class="tw"><table><thead><tr>${hd.map((c) => `<th>${inl(c)}</th>`).join('')}</tr></thead><tbody>${rows.slice(2).map((r) => { const c = cells(r); return `<tr>${hd.map((_, k) => `<td>${inl(c[k] || '')}</td>`).join('')}</tr>`; }).join('')}</tbody></table></div>`);
70
- } else out.push(`<p>${inl(rows.join(' '))}</p>`);
71
- continue;
72
- }
65
+ if (tableStarts(L, i)) { const t = readTable(L, i); i = t.end + 1; out.push(tableHtml(t, inl, 'tw')); continue; }
66
+ if (/^\s*\|/.test(l)) { const rows = []; while (i < L.length && /^\s*\|/.test(L[i])) rows.push(L[i++]); out.push(`<p>${inl(rows.join(' '))}</p>`); continue; }
73
67
  if (isList(l)) {
74
68
  const ord = /^\s*\d+[.)]/.test(l), items = [];
75
69
  while (i < L.length && (isList(L[i]) || (/^\s{2,}\S/.test(L[i]) && items.length))) { if (isList(L[i])) items.push(L[i].replace(/^\s*([-*+]|\d+[.)])\s+/, '')); else items[items.length - 1] += ' ' + L[i].trim(); i++; }
@@ -74,6 +74,11 @@
74
74
  .cfb table{border-collapse:collapse;min-width:60%;font-size:var(--fs-2)}
75
75
  .cfb th,.cfb td{border:1px solid var(--hair);padding:6px 11px;text-align:left;vertical-align:top;min-width:60px}
76
76
  .cfb thead th{background:var(--well);font-weight:500}
77
+ .cfb .tw table{width:max-content;min-width:60%}
78
+ .cfb .tw th,.cfb .tw td{max-width:32ch;overflow-wrap:break-word}
79
+ .cfb .al-l{text-align:left}
80
+ .cfb .al-c{text-align:center}
81
+ .cfb .al-r{text-align:right}
77
82
  .pnl{display:grid;grid-template-columns:18px minmax(0,1fr);gap:10px;padding:11px 14px;border-radius:6px;margin:0 0 14px;background:var(--pb,var(--well))}
78
83
  .pnl .pidot{width:14px;height:14px;margin-top:4px;border-radius:50%;border:2px solid var(--pc,var(--ink-3));box-sizing:border-box;user-select:none}
79
84
  .pnl .pc>:last-child{margin-bottom:0}
@@ -50,7 +50,7 @@ function mdOf(root) {
50
50
  if (cl.contains('pnl')) B.push(`> [!${String(c.dataset.k || 'note').toUpperCase()}]\n` + [...$('.pc', c).children].map((x) => '> ' + inlineMd(x).trim()).join('\n>\n'));
51
51
  else if (cl.contains('tw') || t === 'TABLE') {
52
52
  const rows = [...c.querySelectorAll('tr')].map((r) => '| ' + [...r.children].map((x) => inlineMd(x).trim().replace(/\|/g, '\\|')).join(' | ') + ' |');
53
- if (rows.length) { const n = c.querySelector('tr').children.length; rows.splice(1, 0, '|' + Array(n).fill('---').join('|') + '|'); B.push(rows.join('\n')); }
53
+ if (rows.length) { const rule = [...c.querySelector('tr').children].map((x) => ({ 'al-c': ':-:', 'al-r': '--:', 'al-l': ':--' }[x.className] || '---')); rows.splice(1, 0, '|' + rule.join('|') + '|'); B.push(rows.join('\n')); }
54
54
  } else if (cl.contains('cb')) B.push('```' + (c.dataset.lang || '') + '\n' + ($('pre', c) || c).textContent.replace(/\n$/, '') + '\n```');
55
55
  else if (/^H[1-6]$/.test(t)) B.push('#'.repeat(+(c.dataset.md || Math.max(2, +t[1]))) + ' ' + inlineMd(c).trim());
56
56
  else if (t === 'UL' && cl.contains('tasks')) B.push([...c.children].map((li) => `- [${li.dataset.done === 'true' ? 'x' : ' '}] ${inlineMd(li).trim()}`).join('\n'));
@@ -1981,7 +1981,15 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1981
1981
  .dso{max-height:62vh;overflow:auto}
1982
1982
  .dso .l2{padding-left:20px}
1983
1983
  .dso .l3{padding-left:30px;color:var(--ink-3)}
1984
- .dsbody .mdt{overflow-x:auto;margin:0 0 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--hair)}
1984
+ .dsbody .mdt{overflow-x:auto;margin:0 0 14px;border-radius:12px;border:1px solid var(--hair)}
1985
+ /* a wide table keeps short cells on one line and scrolls sideways; its first column stays in view (PM, 2026-10-21) */
1986
+ .dsbody .mdt table,.mdtab table{width:max-content;min-width:100%}
1987
+ .dsbody .mdt th,.dsbody .mdt td,.mdtab th,.mdtab td{max-width:32ch;overflow-wrap:break-word}
1988
+ .dsbody .mdt th:first-child,.dsbody .mdt td:first-child,.mdtab th:first-child,.mdtab td:first-child{position:sticky;left:0;z-index:1;background:var(--card-solid)}
1989
+ .dsbody .mdt th:first-child,.mdtab th:first-child{background:var(--well)}
1990
+ .mdt .al-l,.mdtab .al-l{text-align:left}
1991
+ .mdt .al-c,.mdtab .al-c{text-align:center}
1992
+ .mdt .al-r,.mdtab .al-r{text-align:right}
1985
1993
  .dsbody table{border-collapse:collapse;width:100%;font-size:var(--fs-3)}
1986
1994
  .dsbody th{font:600 var(--fs-1) var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--ink-3);text-align:left;padding:8px 12px;background:var(--well)}
1987
1995
  .dsbody td{padding:8px 12px;border-top:1px solid var(--hair);vertical-align:top;line-height:1.5}
@@ -2287,6 +2295,7 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2287
2295
  .gpts i{width:10px;height:10px;border-radius:50%;box-shadow:inset 0 0 0 1.5px var(--ink-3)}
2288
2296
  .gpts li.m i{background:var(--ok);box-shadow:none}
2289
2297
  .gpts em{font-style:normal;color:var(--ink-3);font-size:var(--t-micro)}
2298
+ .vwgoal{padding-top:6px}.vwgoal .gcard{margin-top:0}.vwgoal .cta.alt{background:var(--well)} /* the Goal tab in the viewer (goal in the viewer, 2026-10-21) */
2290
2299
  /* the chat panel's words drawn as Claude Code draws them (chat-md.js): markdown with room to read, the PM's paste without its tags, quiet tool lines */
2291
2300
  .md{font-size:var(--fs-3);line-height:1.6;color:var(--ink);max-width:64ch;overflow-wrap:anywhere}
2292
2301
  .md>:first-child{margin-top:0}.md>:last-child{margin-bottom:0}
@@ -40,6 +40,7 @@
40
40
  "briefing-premium-agent.test.js",
41
41
  "goal-chat.test.js",
42
42
  "chat-md.test.js",
43
+ "md-table.test.js",
43
44
  "chat-file-locate.test.js",
44
45
  "briefing-premium-work.test.js",
45
46
  "briefing-premium-board.test.js",
@@ -217,6 +218,7 @@
217
218
  "briefing-premium-agent.test.js": 1,
218
219
  "goal-chat.test.js": 1,
219
220
  "chat-md.test.js": 1,
221
+ "md-table.test.js": 1,
220
222
  "chat-file-locate.test.js": 1,
221
223
  "briefing-premium-work.test.js": 1,
222
224
  "briefing-premium-board.test.js": 1,
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The /goal card lives in the Chat viewer as a Goal tab: a small chip in the conversation opens it, a state change opens or updates it, Stop is in the tab, phone layer with Back. Real server, 390 and 1280 wide.",
3
+ "seconds": {
4
+ "premium-chat-goal-view-test.js": 40
5
+ },
6
+ "panels": [
7
+ "premium-chat-goal-view-test.js"
8
+ ]
9
+ }