create-pmos 0.319.0 → 0.321.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.319.0",
3
+ "version": "0.321.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": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@ed07d2c
1
+ kernel-source: pmos@4652689
2
2
  assembled: 2026-10-19
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-19T14:43:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T15:25:02Z"}
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-19T14:43:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T15:25:02Z"}
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-19T14:43:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T15:25:02Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -166,6 +166,17 @@ When you scroll past the hero, the hero folds into a bar at the top. The bar sho
166
166
 
167
167
  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.
168
168
 
169
+ 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.
170
+
171
+ ### The document page
172
+
173
+ Every markdown document opens as one page in a tab: a report, a PRD, a new document or any other `.md` file. On a document sheet, click **Open as a page**. On a report, click **Edit**.
174
+
175
+ - **Page** shows the document as it reads. **Edit** lets you type on the page itself, with a toolbar, a **/** menu for blocks, and Ctrl+S to save. **Markdown** shows the source text. Only the sections you changed are written; the other sections and the front matter keep their exact text.
176
+ - When the agent proposes an edit, the page shows it applied and highlighted. Click a highlight to see the old text, and click **Put it back** to restore it. The bar above the page has **Keep as vN**, which keeps the changes that remain, and **Undo all**, which asks first and then rejects the whole edit.
177
+ - **Health**, **Links** and **Copies** under the toolbar show the document's checks, the documents it links to, and its linked copies. The checks only read the file.
178
+ - A report also shows **Present**, **Print** and **Download** on the same toolbar.
179
+
169
180
  A decision opens with no option chosen, because no recommendation is on record. 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.
170
181
 
171
182
  ## The conversation
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.319.0",
3
+ "version": "0.321.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.319.0",
9
+ "version": "0.321.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.319.0",
3
+ "version": "0.321.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",
@@ -88,7 +88,7 @@ fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
88
88
 
89
89
  const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 }, acceptDownloads: true }), p = await ctx.newPage(), errs = [], posts = [];
90
90
  p.on('pageerror', (e) => errs.push(String(e)));
91
- p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
91
+ p.on('request', (r) => { const u = new URL(r.url()).pathname; if (r.method() === 'POST' && u !== '/api/doc-health/check') posts.push(u); }); // the document page's health check is a read sent as a POST; it writes nothing
92
92
  const shot = async (n) => { if (process.env.READ_SHOTS) await p.screenshot({ path: path.join(process.env.READ_SHOTS, n + '.png') }); };
93
93
  const tap = (sel) => p.$eval(sel, (b) => b.click());
94
94
  const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
@@ -151,6 +151,21 @@ fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
151
151
  const pr = await p.evaluate(() => ({ h: window.__pr || '', printed: !!window.__printed }));
152
152
  ok('X1 Print opens the print page with one slide to a page', pr.printed && /pmos-print-deck/.test(pr.h) && (pr.h.match(/class="pmos-slide"/g) || []).length === 5 && pr.h.includes('premium-report-print.css'), pr.h.slice(0, 300));
153
153
 
154
+ /* E: Edit opens the report's file as the one document page (premium-viewer S2), with this report's Present, Print and Download on its bar */
155
+ await tap('#oMain [data-rr="page"]');
156
+ const VP = '.obody.vw:not([hidden]) .vwdoc';
157
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' .cf'), VP));
158
+ ok('E1 Edit opens the report as a page in a viewer tab, with Page, Edit and Markdown', await p.evaluate((v) => { const st = window.__premiumViewer.vwState(); return st.on.startsWith('doc:') && document.querySelectorAll(v + ' .vwseg').length === 3 && /Partner review, 12 Oct/.test(document.querySelector(v + ' .cft').textContent); }, VP));
159
+ ok('E2 the page bar carries Present, Print and Download', await p.evaluate((v) => ['Present', 'Print', 'Download'].every((t) => [...document.querySelectorAll(v + ' .vwdt .vwbtn')].some((b) => b.textContent.trim() === t)), VP));
160
+ await p.click(VP + ' [data-vd="xm:dl"]');
161
+ const pitems = await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwxmn [role="menuitem"]')].map((a) => a.getAttribute('href') || a.dataset.vwx), VP);
162
+ ok('E3 its Download lists the same four files through report-export, and the Markdown file', pitems.length === 5 && pitems.slice(0, 4).every((h, i) => h.includes('/api/report-export?') && h.includes('fmt=' + ['pptx', 'docx', 'xlsx', 'csv'][i])) && pitems[4] === 'md', JSON.stringify(pitems));
163
+ await p.click(VP + ' [data-vd="xm:dl"]');
164
+ await p.click(VP + ' [data-vwx="present"]');
165
+ await until(() => p.$('#rdPres'));
166
+ ok('E4 Present from the page presents the deck over the whole page', !!(await p.$('#rdPres')) && await p.evaluate(() => window.__premiumViewer.vwState().on === 'main'));
167
+ await p.keyboard.press('Escape'); await sleep(200);
168
+
154
169
  /* L: the look */
155
170
  ok('L1 with no design yet, the design row shows This cycle and no version', await p.evaluate(() => [...document.querySelectorAll('.rdv button')].map((b) => b.textContent).join()) === 'This cycle' && /No sample yet/.test(await p.textContent('.rdz')));
156
171
  await p.setInputFiles('#rdFile', path.join(base, 'q3-deck.png'));
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-viewer-test.js — the premium dialog's right pane as a viewer with tabs (initiative premium-viewer, S1; planning/prd/premium-viewer-prd.md R1, R7).
4
+ * Serves the real Briefing page from the real server with the Briefing model answered by a stand-in, opens a row's dialog, then drives window.__premiumViewer.
5
+ * R1 tabs: open, switch, close, at most 4 extra, #oMain kept with its handlers, reset on the next dialog · R7 floors: 390px, 44px targets, dark theme
6
+ * Every wait polls the page; no fixed sleep stands in for a state. */
7
+ const path = require('path');
8
+ const { spawn } = require('child_process');
9
+ const { findBrowser } = require('./lib/find-browser');
10
+ const T = require('./test-run').configure({ name: 'premium-viewer' });
11
+ const B = require('./lib/briefing-premium.js');
12
+ const F = require('./fixtures/briefing-premium-facts.js');
13
+
14
+ const BASE = T.BASE;
15
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
16
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); 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 !== '' ? ' — ' + extra : ''}`); };
19
+ let srv = null; let browser = null;
20
+ const finish = async (code) => {
21
+ if (browser) await browser.close().catch(() => {});
22
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
23
+ T.killTmux();
24
+ const bad = results.filter((x) => !x.cond).length;
25
+ console.log(`\n${results.length - bad}/${results.length} premium-viewer assertions passed`);
26
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
27
+ };
28
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
29
+
30
+ (async () => {
31
+ const exe = findBrowser();
32
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
33
+ let chromium;
34
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
35
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
36
+ await T.waitForServer(BASE);
37
+ browser = await chromium.launch({ executablePath: exe });
38
+
39
+ const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
40
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
41
+ const page = await ctx.newPage();
42
+ const S = { errors: [] };
43
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
44
+ await page.route('**/api/briefing-premium*', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }) }));
45
+ await page.goto(BASE + '/premium.html?theme=' + theme);
46
+ S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr .rhd').length > 0 && !!window.__premiumViewer), 20000);
47
+ return { page, ctx, S };
48
+ };
49
+ /* opens the first row that opens a dialog on this page (a row with its own page would navigate away) */
50
+ const openDialog = async (page) => {
51
+ const n = await page.evaluate(() => document.querySelectorAll('#rank .rr .rhd').length);
52
+ for (let i = 0; i < n; i++) {
53
+ const url = page.url();
54
+ await page.evaluate((k) => document.querySelectorAll('#rank .rr .rhd')[k].click(), i);
55
+ if (await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on')), 3000)) return true;
56
+ if (page.url() !== url) { await page.goBack(); await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr .rhd').length > 0 && !!window.__premiumViewer), 20000); }
57
+ }
58
+ return false;
59
+ };
60
+ const st = (page) => page.evaluate(() => {
61
+ const t = document.querySelector('#vTabs'), m = document.querySelector('#oMain'), lab = document.querySelector('#oLab');
62
+ const vis = (e) => !!e && !e.hidden && getComputedStyle(e).display !== 'none';
63
+ return { ...window.__premiumViewer.vwState(), strip: vis(t), lab: vis(lab), main: vis(m), tabs: t ? [...t.querySelectorAll('.vtab')].map((x) => x.dataset.vw) : [],
64
+ sel: t ? [...t.querySelectorAll('.vtab[aria-selected="true"]')].map((x) => x.dataset.vw) : [], panes: [...document.querySelectorAll('#dOut .obody.vw')].map((p) => [p.dataset.vw, vis(p)]) };
65
+ });
66
+
67
+ /* R1 desktop */
68
+ {
69
+ const { page, ctx, S } = await open();
70
+ ok('R1 the Briefing loads with the viewer module', S.up);
71
+ ok('R1 a row opens the dialog', await openDialog(page));
72
+ let s = await st(page);
73
+ ok('R1 with no extra tab the strip is hidden, #oLab shows, #oMain shows', !s.strip && s.lab && s.main && s.ids.length === 0, JSON.stringify(s));
74
+ /* a page's handler on #oMain, and a node inside it, must survive the tabs */
75
+ await page.evaluate(() => { const m = document.querySelector('#oMain'); window.__hits = 0; m.addEventListener('click', () => { window.__hits++; }); const p = document.createElement('p'); p.id = 'vwMark'; p.textContent = 'mark'; m.append(p); });
76
+ await page.evaluate(() => window.__premiumViewer.vwOpen({ id: 'a', title: 'Alpha doc', icon: 'doc', html: '<p id="paneA">Alpha</p>', wire: (el) => { el.querySelector('#paneA').dataset.wired = '1'; } }));
77
+ s = await st(page);
78
+ ok('R1 opening an item shows the strip with the main tab and the item, the item selected', s.strip && !s.lab && JSON.stringify(s.tabs) === '["main","a"]' && JSON.stringify(s.sel) === '["a"]' && !s.main, JSON.stringify(s));
79
+ ok('R1 the item fills its own pane and wire runs on it', await page.evaluate(() => document.querySelector('#paneA') && document.querySelector('#paneA').dataset.wired === '1'));
80
+ ok('R1 the main tab is labelled with the dialog\'s label and has no close button', await page.evaluate(() => { const t = document.querySelector('#vTabs .vtab[data-vw="main"]'); return t.textContent.trim() === document.querySelector('#oLab').textContent.trim() && !t.querySelector('.vx'); }));
81
+ await page.click('#vTabs .vtab[data-vw="main"]');
82
+ s = await st(page);
83
+ ok('R1 a click on the main tab shows #oMain and hides the item', s.main && s.on === 'main' && s.panes.every((p) => !p[1]), JSON.stringify(s));
84
+ ok('R1 #oMain was not re-rendered: the node inside it and its handler are still there', await page.evaluate(() => { document.querySelector('#vwMark').click(); return !!document.querySelector('#oMain #vwMark') && window.__hits === 1; }));
85
+ await page.evaluate(() => window.__premiumViewer.vwOpen({ id: 'a', title: 'Alpha doc', html: '<p id="paneA">Alpha 2</p>' }));
86
+ s = await st(page);
87
+ ok('R1 opening the same id again refills that tab and shows it, with no second tab', s.ids.length === 1 && s.on === 'a' && (await page.textContent('#paneA')) === 'Alpha 2', JSON.stringify(s));
88
+ for (const id of ['b', 'c', 'd', 'e']) await page.evaluate((x) => window.__premiumViewer.vwOpen({ id: x, title: 'Item ' + x, html: `<p>${x}</p>` }), id);
89
+ s = await st(page);
90
+ ok('R1 at most 4 extra tabs: the fifth closes the oldest', JSON.stringify(s.ids) === '["b","c","d","e"]' && s.on === 'e' && s.panes.length === 4, JSON.stringify(s));
91
+ await page.click('#vTabs .vtab[data-vw="e"] .vx');
92
+ s = await st(page);
93
+ ok('R1 closing the shown tab shows the one before it', JSON.stringify(s.ids) === '["b","c","d"]' && s.on === 'd', JSON.stringify(s));
94
+ await page.focus('#vTabs .vtab[data-vw="d"]');
95
+ await page.keyboard.press('ArrowLeft');
96
+ s = await st(page);
97
+ ok('R1 the arrow keys move between tabs', s.on === 'c' && (await page.evaluate(() => document.activeElement.dataset.vw)) === 'c', JSON.stringify(s));
98
+ await page.keyboard.press('Delete');
99
+ s = await st(page);
100
+ ok('R1 Delete closes the focused tab', JSON.stringify(s.ids) === '["b","d"]', JSON.stringify(s));
101
+ const yes = page.evaluate(() => window.__premiumViewer.vwConfirm(document.querySelector('#dOut .obody.vw:not([hidden])'), { text: 'Undo all 3 edits?', yes: 'Undo all' }));
102
+ await until(() => page.evaluate(() => !!document.querySelector('.vcf')));
103
+ ok('R1 vwConfirm draws a card with the question in the shown pane', (await page.textContent('.vcf p')) === 'Undo all 3 edits?');
104
+ await page.click('.vcf [data-a="1"]');
105
+ ok('R1 vwConfirm resolves true on the yes button and removes the card', (await yes) === true && !(await page.$('.vcf')));
106
+ await page.evaluate(() => window.__premiumViewer.vwStyle('none-such'));
107
+ ok('R1 vwStyle adds the view\'s stylesheet link once', await page.evaluate(() => { window.__premiumViewer.vwStyle('none-such'); window.__premiumViewer.vwStyle('../x'); return document.querySelectorAll('link[data-vw-css]').length === 1 && document.querySelector('link[data-vw-css]').getAttribute('href') === '/pm/premium-vw-none-such.css'; }));
108
+ await page.keyboard.press('Escape');
109
+ await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')), 3000);
110
+ await openDialog(page);
111
+ s = await st(page);
112
+ ok('R1 the next dialog starts with no extra tab', s.ids.length === 0 && !s.strip && s.main && s.panes.length === 0, JSON.stringify(s));
113
+ ok('R1 no page error', S.errors.length === 0, S.errors.join(' | '));
114
+ await ctx.close();
115
+ }
116
+
117
+ /* R7 phone and dark theme */
118
+ {
119
+ const { page, ctx, S } = await open({ w: 390, h: 844, theme: 'dark' });
120
+ ok('R7 a row opens the dialog at 390px', await openDialog(page));
121
+ for (const id of ['a', 'b']) await page.evaluate((x) => window.__premiumViewer.vwOpen({ id: x, title: 'A long item title ' + x, html: `<p>${x}</p>` }), id);
122
+ const m = await page.evaluate(() => {
123
+ const r = (e) => e.getBoundingClientRect();
124
+ const tabs = [...document.querySelectorAll('#vTabs .vtab')], xs = [...document.querySelectorAll('#vTabs .vx')];
125
+ return { tabH: Math.min(...tabs.map((t) => r(t).height)), xH: Math.min(...xs.map((t) => r(t).height)), xW: Math.min(...xs.map((t) => r(t).width)),
126
+ over: document.documentElement.scrollWidth > window.innerWidth, stripW: r(document.querySelector('#vTabs')).right <= window.innerWidth + 1,
127
+ bg: getComputedStyle(document.querySelector('#vTabs .vtab[aria-selected="true"]')).backgroundColor };
128
+ });
129
+ ok('R7 tabs and close buttons are at least 44px at 390px', m.tabH >= 44 && m.xH >= 44 && m.xW >= 44, JSON.stringify(m));
130
+ ok('R7 the strip fits the width and the page does not scroll sideways', m.stripW && !m.over, JSON.stringify(m));
131
+ ok('R7 in the dark theme the selected tab is not a light card', (() => { const c = (m.bg.match(/\d+/g) || []).slice(0, 3).map(Number); return c.length === 3 && c[0] + c[1] + c[2] < 3 * 160; })(), m.bg);
132
+ ok('R7 no page error', S.errors.length === 0, S.errors.join(' | '));
133
+ await ctx.close();
134
+ }
135
+ finish();
136
+ })();
@@ -0,0 +1,218 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-vw-doc-test.js — a markdown document as a page in the premium viewer (initiative premium-viewer S2; planning/prd/premium-viewer-prd.md R2, R6, R7).
4
+ * Serves the real initiative page from the real server and opens its PRD sheet, then the page in the viewer. The /api/doc-sheet routes are answered by a
5
+ * small stateful stand-in, so each press can be read off the request the page sent. The routes' own behaviour is in briefing-premium-doc-edit.test.js.
6
+ * D1 the page · D2 edit in place · D3 Markdown · D4 an agent's edit · D5 Undo all · D6 ask · D7 the sheet reads again · D8 floors */
7
+ const path = require('path');
8
+ const { spawn } = require('child_process');
9
+ const { findBrowser } = require('./lib/find-browser');
10
+ const T = require('./test-run').configure({ name: 'premium-vw-doc' });
11
+ const IP = require('./lib/initiative-premium.js');
12
+ const F = require('./fixtures/initiative-premium-facts.js');
13
+
14
+ const BASE = T.BASE;
15
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
16
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); 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 !== '' ? ' — ' + extra : ''}`); };
19
+ let srv = null; let browser = null;
20
+ const finish = async (code) => {
21
+ if (browser) await browser.close().catch(() => {});
22
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
23
+ T.killTmux();
24
+ const bad = results.filter((x) => !x.cond).length;
25
+ console.log(`\n${results.length - bad}/${results.length} premium-vw-doc assertions passed`);
26
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
27
+ };
28
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
29
+
30
+ const PATH = 'planning/prd/self-serve-v2-prd.md';
31
+ const TEXT = '---\ntype: PRD\ntitle: "Self-serve onboarding v2"\nstatus: Draft\ntimestamp: 2026-10-16\ntags: [onboarding, q4]\n---\n\n# PRD: Self-serve onboarding v2\n\n'
32
+ + '> [!NOTE]\n> Owned by the onboarding squad.\n\n## Problem\n\nA partner waits for a person.\nIt takes two days.\n\n## Goal\n\n- a first call without help\n\n'
33
+ + '## Requirements\n\n| Id | What | State |\n|---|---|---|\n| R1 | a first call | :status[In progress] |\n\n- [x] draft the flow\n- [ ] test it\n';
34
+ const AFTER = TEXT.replace('## Goal', '## Summary\n\nPartners reach a first call without help.\n\n## Goal').replace('- a first call without help', '- a first call in under ten minutes');
35
+ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'add a summary and tighten the goal', at: '2026-10-18T01:00:00Z', hash: 'ha', by: 'agent', why: null, after: AFTER, sections: [
36
+ { name: 'Summary', kind: 'added', before: '', after: 'Partners reach a first call without help.', current: null, stale: false },
37
+ { name: 'Goal', kind: 'changed', before: '- a first call without help', after: '- a first call in under ten minutes', current: '- a first call without help', stale: false },
38
+ { name: 'Requirements', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }, o || {});
39
+
40
+ (async () => {
41
+ const exe = findBrowser();
42
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
43
+ let chromium;
44
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
45
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
46
+ await T.waitForServer(BASE);
47
+ browser = await chromium.launch({ executablePath: exe });
48
+
49
+ const open = async ({ w = 1280, h = 900, theme = 'light', props = [], post = null } = {}) => {
50
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
51
+ const page = await ctx.newPage();
52
+ const S = { text: TEXT, revs: [{ rev: 1, why: '', by: 'baseline', at: '2026-10-16T08:00:00Z' }], props, ask: null, errors: [], posts: [], gets: [], links: [] };
53
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
54
+ await page.route('**/api/initiative-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IP.build(F.facts()), as_of: F.NOW }) }));
55
+ await page.route('**/api/doc-health/check', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, health: { passed: 1, total: 1, checks: [{ id: 'fresh', pass: true, reason: 'ok' }] } }) }));
56
+ await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
57
+ await page.route('**/api/docs/library*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, kinds: ['cites'], files: [{ path: PATH, title: 'Self-serve PRD' }, { path: 'planning/research/interviews.md', title: 'Onboarding interviews' }, { path: 'planning/evals/self-serve-v2-rubric.md', title: 'Self-serve rubric' }], edges: [[1, 0, 0], [0, 2, 0]] }) }));
58
+ await page.route('**/api/docs?*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, docs: [{ path: PATH, links: S.links }] }) }));
59
+ await page.route('**/api/docs/link', (r) => { const b = JSON.parse(r.request().postData() || '{}'); S.posts.push({ route: 'docs/link', body: b }); S.links.push({ kind: b.kind, target: b.target, signal: 'unchecked', title: 'Onboarding PRD' }); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
60
+ await page.route('**/api/doc-sheet/**', (r) => {
61
+ const rq = r.request(), u = new URL(rq.url()), route = u.pathname.replace('/api/doc-sheet/', ''), send = (b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
62
+ if (rq.method() === 'GET') {
63
+ S.gets.push({ route, query: u.search });
64
+ if (route === 'log') return send({ ok: true, path: PATH, revisions: S.revs, events: [] });
65
+ if (route === 'at') return send({ ok: true, path: PATH, rev: S.revs.length, text: S.text });
66
+ if (route === 'proposals') return send({ ok: true, path: PATH, proposals: S.props });
67
+ if (route === 'ask') return send(S.ask || { ok: true, id: 'ask-1', state: 'working' });
68
+ return send({ ok: false, error: 'not in this test' }, 404);
69
+ }
70
+ const body = JSON.parse(rq.postData() || '{}'); S.posts.push({ route, query: u.search, body });
71
+ if (post) { const a = post(route, body, S); if (a) return send(a.body, a.status || 200); }
72
+ if (route === 'edit') { S.text = body.text; S.revs.push({ rev: S.revs.length + 1, why: body.why, by: 'pm', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
73
+ if (route === 'accept') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'accepted' }) : p)); S.text = AFTER.replace('- a first call in under ten minutes', '- a first call without help'); S.revs.push({ rev: S.revs.length + 1, why: 'add a summary', by: 'pm', text_by: 'agent', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
74
+ if (route === 'reject') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'rejected', why: body.why }) : p)); return send({ ok: true }); }
75
+ if (route === 'ask') { S.ask = { ok: true, id: 'ask-1', state: 'working' }; return send({ ok: true, id: 'ask-1', state: 'working' }); }
76
+ return send({ ok: false, error: 'not in this test' }, 404);
77
+ });
78
+ await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
79
+ await until(() => page.evaluate(() => document.querySelector('#cIniDoc')));
80
+ await page.locator('#dmList .dmo[data-doc="prd"]').click();
81
+ await until(() => page.evaluate(() => document.querySelector('#oMain [data-ds="page"]')));
82
+ await page.click('#oMain [data-ds="page"]');
83
+ await until(() => page.evaluate(() => document.querySelector('.vwdoc .cf, .vwdoc .vwempty:not(:empty)') && !/Reading the file/.test(document.querySelector('.vwdoc').textContent)));
84
+ return { ctx, page, S };
85
+ };
86
+ const V = '.obody.vw:not([hidden]) .vwdoc';
87
+ const txt = (p, q) => p.evaluate((s) => ((document.querySelector(s) || {}).textContent || '').replace(/\s+/g, ' '), q);
88
+
89
+ /* D1 the page */
90
+ const A = await open(); const p = A.page;
91
+ ok('D1 Open as a page opens the document in a viewer tab, beside the sheet', await p.evaluate(() => { const st = window.__premiumViewer && window.__premiumViewer.vwState(); return !!st && st.ids.includes('doc:planning/prd/self-serve-v2-prd.md') && st.on === 'doc:planning/prd/self-serve-v2-prd.md'; }));
92
+ const head = await p.evaluate((v) => { const r = document.querySelector(v); return { t: r.querySelector('.cft').textContent, by: r.querySelector('.cfby').textContent, props: [...r.querySelectorAll('.cfpr tr')].map((x) => [...x.children].map((c) => c.textContent.trim()).join(' ')), labels: [...r.querySelectorAll('.cflb span')].map((x) => x.textContent), h1: r.querySelectorAll('.cfb h1, .cfb h2').length && r.querySelector('.cfb').textContent.includes('PRD: Self-serve'), foot: r.querySelector('.cff').textContent }; }, V);
93
+ ok('D1 the title comes from the front matter and the first heading is not drawn twice', head.t === 'Self-serve onboarding v2' && !head.h1, JSON.stringify(head));
94
+ ok('D1 the byline says who changed it last, the version and the read time, from the log', /Last change by Before the sheet · 16 Oct 2026 · v1 · 1 min read/.test(head.by), head.by);
95
+ ok('D1 the properties table and labels come from the front matter', head.props.join('|') === 'type PRD|status Draft|timestamp 16 Oct 2026' && head.labels.join() === 'onboarding,q4', JSON.stringify(head));
96
+ ok('D1 the body has the panel, the table with its status label, and the task list', await p.evaluate((v) => { const b = document.querySelector(v + ' .cfb'); return !!b.querySelector('.pnl.note') && !!b.querySelector('.tw table .lz.b') && b.querySelectorAll('.tasks li').length === 2 && b.querySelector('.tasks li[data-done="true"]') !== null; }, V));
97
+ ok('D1 the footer names the file', /planning\/prd\/self-serve-v2-prd\.md/.test(head.foot));
98
+ ok('D1 Page, Edit and Markdown are one control, with Page on', await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwseg')].map((b) => b.textContent.trim() + ':' + b.getAttribute('aria-pressed')).join() === 'Page:true,Edit:false,Markdown:false', V));
99
+
100
+ /* D9 Health, Links and Copies */
101
+ ok('D9 the page shows Health with the checks that passed, Links and Copies', await until(() => p.evaluate((v) => [...document.querySelectorAll(v + ' .vwchip')].map((b) => b.textContent.replace(/\s+/g, ' ').trim()).join('|') === 'Health 1 of 1|Links|Copies 0', V)), await txt(p, V + ' .vwmore'));
102
+ await p.click(V + ' [data-vd="more:health"]');
103
+ ok('D9 Health lists each check from the health route', /fresh\s*Passed/.test(await txt(p, V + ' .vwmp')) && /1 of 1 checks/.test(await txt(p, V + ' .vwmp')));
104
+ await p.click(V + ' [data-vd="more:links"]');
105
+ await until(() => p.evaluate((v) => /Built from/.test((document.querySelector(v + ' .vwmp') || {}).textContent || ''), V));
106
+ ok('D9 Links show what it is built from and what uses it, from the document library', /Built from · 1.*Onboarding interviews/.test(await txt(p, V + ' .vwmp')) && /Used by · 1.*Self-serve rubric/.test(await txt(p, V + ' .vwmp')) && /Links 2/.test(await txt(p, V + ' .vwmore')));
107
+ await p.click(V + ' [data-vd="open:planning/evals/self-serve-v2-rubric.md"]');
108
+ ok('D9 a linked document opens as a page in its own tab', await until(() => p.evaluate(() => window.__premiumViewer.vwState().on === 'doc:planning/evals/self-serve-v2-rubric.md')));
109
+ await p.evaluate(() => window.__premiumViewer.vwShow('doc:planning/prd/self-serve-v2-prd.md'));
110
+ await p.click(V + ' [data-vd="more:copies"]');
111
+ ok('D9 Copies says there is none yet and offers to link one', /no copy in Confluence or Google Docs yet/.test(await txt(p, V + ' .vwmp')));
112
+ await p.fill(V + ' #vwCpUrl', 'https://acme.atlassian.net/wiki/spaces/PM/pages/1'); await p.click(V + ' [data-vd="cplink"]');
113
+ await until(() => p.evaluate((v) => /Onboarding PRD/.test((document.querySelector(v + ' .vwmp') || {}).textContent || ''), V));
114
+ ok('D9 Link posts the copy to /api/docs/link and the copy is listed as not checked', A.S.posts.some((x) => x.route === 'docs/link' && x.body.kind === 'confluence' && x.body.path === PATH) && /Confluence.*Not checked/.test(await txt(p, V + ' .vwmp')));
115
+ await p.click(V + ' [data-vd="more:copies"]');
116
+ const nPosts = A.S.posts.length; A.S.posts.length = 0;
117
+ ok('D9 (setup) the copy link was the only post so far', nPosts === 1);
118
+
119
+ /* D3 Markdown */
120
+ await p.click(V + ' [data-vd="mode:md"]');
121
+ ok('D3 Markdown shows the file exactly as it is on disk', (await p.inputValue(V + ' #vwMd')) === TEXT);
122
+ await p.click(V + ' [data-vd="mode:read"]');
123
+
124
+ /* D2 edit in place */
125
+ await p.click(V + ' [data-vd="mode:edit"]');
126
+ ok('D2 Edit makes the page itself editable and shows the toolbar and a save row', await p.evaluate((v) => document.querySelector(v + ' .cfb').isContentEditable && !!document.querySelector(v + ' .vwetb') && /Save as v2/.test(document.querySelector(v + ' .vwsave').textContent), V));
127
+ await p.evaluate((v) => { const para = [...document.querySelectorAll(v + ' .cfb p')].find((x) => /A partner waits/.test(x.textContent)); const r = document.createRange(); r.setStart(para.firstChild, 'A partner'.length); r.collapse(true); const s = getSelection(); s.removeAllRanges(); s.addRange(r); para.focus(); }, V);
128
+ await p.keyboard.type(' still');
129
+ await p.click(V + ' [data-vd="save"]');
130
+ ok('D2 Save with no reason posts nothing and says why', /Say why the document changes/.test(await txt(p, V + ' #vwErr')) && A.S.posts.length === 0);
131
+ ok('D2 the typing is still there after the refusal', /A partner still waits/.test(await txt(p, V + ' .cfb')));
132
+ await p.fill(V + ' #vwWhy', 'say the partner still waits'); await p.click(V + ' [data-vd="save"]');
133
+ await until(() => A.S.posts.length);
134
+ const e1 = A.S.posts[0];
135
+ const want = TEXT.replace('A partner waits for a person.\nIt takes two days.', 'A partner still waits for a person. It takes two days.');
136
+ ok('D2 Save posts path, text and why to /api/doc-sheet/edit for the workspace', e1 && e1.route === 'edit' && Object.keys(e1.body).sort().join() === 'path,text,why' && e1.body.path === PATH && e1.body.why === 'say the partner still waits' && /ws=w1/.test(e1.query), JSON.stringify(e1));
137
+ ok('D2 only the section that was typed in changes; the front matter, the panel, the table and the tasks keep their exact text', e1 && e1.body.text === want, JSON.stringify(e1 && e1.body.text));
138
+ await until(() => p.evaluate((v) => document.querySelector(v + ' .vwseg[aria-pressed="true"]') && /Page/.test(document.querySelector(v + ' .vwseg[aria-pressed="true"]').textContent) && /v2/.test(document.querySelector(v + ' .cfby').textContent), V));
139
+ ok('D2 after Save the page reads the file again and says v2', /Last change by You · 18 Oct 2026 · v2/.test(await txt(p, V + ' .cfby')));
140
+ ok('D7 a write in the page reads the sheet beside it again', A.S.gets.filter((g) => g.route === 'log').length >= 3);
141
+
142
+ /* D2 the editor's blocks: a / menu and a markdown shortcut */
143
+ await p.click(V + ' [data-vd="mode:edit"]');
144
+ await p.evaluate((v) => { const b = document.querySelector(v + ' .cfb'), last = b.lastElementChild; const pp = document.createElement('p'); pp.innerHTML = '<br>'; last.after(pp); const r = document.createRange(); r.setStart(pp, 0); r.collapse(true); const s = getSelection(); s.removeAllRanges(); s.addRange(r); b.focus(); }, V);
145
+ await p.keyboard.type('/'); await sleep(100);
146
+ ok('D2 / opens the block menu with headings, lists, panels, a table and more', await p.evaluate((v) => { const m = document.querySelector(v.replace(' .vwdoc', '') + ' .vwpop'); return !!m && /Heading 1/.test(m.textContent) && /Info panel/.test(m.textContent) && /Table/.test(m.textContent); }, V));
147
+ await p.keyboard.type('info'); await p.keyboard.press('Enter'); await sleep(100);
148
+ await p.keyboard.type('Ship to new workspaces first.');
149
+ ok('D2 picking Info panel puts a panel in the page where the caret was', await p.evaluate((v) => [...document.querySelectorAll(v + ' .cfb .pnl.info')].some((x) => /Ship to new workspaces first/.test(x.textContent)), V));
150
+ await p.fill(V + ' #vwWhy', 'add a note'); await p.click(V + ' [data-vd="save"]');
151
+ await until(() => A.S.posts.length > 1);
152
+ ok('D2 the panel is saved as a GitHub note block in plain markdown', /> \[!INFO\]\n> Ship to new workspaces first\./.test(A.S.posts[1].body.text) && A.S.posts[1].body.text.startsWith(want.split('## Requirements')[0]), JSON.stringify(A.S.posts[1].body.text));
153
+ ok('0 no page error', A.S.errors.length === 0, A.S.errors.join(' | '));
154
+ await A.ctx.close();
155
+
156
+ /* D4 an agent's edit, applied and highlighted, with one Keep */
157
+ {
158
+ const B = await open({ props: [prop()] }); const q = B.page;
159
+ await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
160
+ ok('D4 the bar says what was asked and how many places changed, with Undo all and Keep as v2', /Asked: add a summary and tighten the goal/.test(await txt(q, V + ' .vwag')) && /The agent changed 2 places/.test(await txt(q, V + ' .vwag')) && /Keep as v2/.test(await txt(q, V + ' [data-vd="keep"]')) && !!(await q.$(V + ' [data-vd="undoall"]')));
161
+ ok('D4 a stale section is not applied, and the bar says so', /1 more change does not apply/.test(await txt(q, V + ' .vwag')) && !(await q.$(V + ' .vwchg[data-sec="Requirements"]')));
162
+ ok('D4 the changes are in the page, highlighted: the new Summary and the new Goal text', await q.evaluate((v) => { const s = document.querySelector(v + ' .vwchg.added[data-sec="Summary"]'), g = document.querySelector(v + ' .vwchg.changed[data-sec="Goal"]'); return !!s && /Partners reach a first call without help/.test(s.textContent) && !!g && /under ten minutes/.test(g.textContent); }, V));
163
+ ok('D4 Edit and Markdown wait until the edit is kept or undone', await q.evaluate((v) => document.querySelector(v + ' [data-vd="mode:edit"]').disabled && document.querySelector(v + ' [data-vd="mode:md"]').disabled, V));
164
+ await q.click(V + ' .vwchg[data-sec="Goal"] .vwcl');
165
+ ok('D4 clicking a highlight shows what it said before', /What it said before.*a first call without help/.test(await txt(q, V + ' .vwchg[data-sec="Goal"] .vwbefore')));
166
+ await q.click(V + ' .vwchg[data-sec="Goal"] [data-vd="back:Goal"]');
167
+ ok('D4 Put it back shows the old text and the bar counts one place', /a first call without help/.test(await txt(q, V + ' .vwchg[data-sec="Goal"] .vwcb')) && /The agent changed 1 place\./.test(await txt(q, V + ' .vwag')) && await q.evaluate((v) => document.querySelector(v + ' .vwchg[data-sec="Goal"]').classList.contains('off'), V));
168
+ await q.click(V + ' [data-vd="keep"]');
169
+ await until(() => B.S.posts.length);
170
+ const ac = B.S.posts[0];
171
+ ok('D4 Keep accepts only the sections still applied, with the proposal id and hash', ac.route === 'accept' && Object.keys(ac.body).sort().join() === 'hash,id,path,sections' && ac.body.sections.join() === 'Summary' && ac.body.hash === 'ha' && /ws=w1/.test(ac.query), JSON.stringify(ac));
172
+ await until(() => q.evaluate((v) => !document.querySelector(v + ' .vwag') && /v2/.test((document.querySelector(v + ' .cfby') || {}).textContent || ''), V));
173
+ ok('D4 after Keep the page is the file as v2, with no highlight left', await q.evaluate((v) => !document.querySelector(v + ' .vwchg') && /Partners reach a first call/.test(document.querySelector(v + ' .cfb').textContent), V));
174
+ ok('0 no page error', B.S.errors.length === 0, B.S.errors.join(' | '));
175
+ await B.ctx.close();
176
+ }
177
+ /* D5 Undo all, D6 ask */
178
+ {
179
+ const C = await open({ props: [prop()] }); const q = C.page;
180
+ await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
181
+ await q.click(V + ' [data-vd="undoall"]');
182
+ await sleep(150);
183
+ const cf = await q.evaluate(() => { const b = [...document.querySelectorAll('.obody.vw button')].find((x) => x.textContent.trim() === 'Undo all' && !x.dataset.vd); return !!b; });
184
+ ok('D5 Undo all asks first, and nothing is posted yet', cf && C.S.posts.length === 0);
185
+ await q.evaluate(() => { const b = [...document.querySelectorAll('.obody.vw button')].find((x) => x.textContent.trim() === 'Undo all' && !x.dataset.vd); b.click(); });
186
+ await until(() => C.S.posts.length);
187
+ ok('D5 Undo all rejects the proposal with a reason for the Edit log, and the file is left as it is', C.S.posts[0].route === 'reject' && C.S.posts[0].body.id === 'prop-a' && /Undo all/.test(C.S.posts[0].body.why) && !C.S.posts.some((x) => x.route === 'edit' || x.route === 'accept'));
188
+ await until(() => q.evaluate((v) => !document.querySelector(v + ' .vwag'), V));
189
+ ok('D5 after Undo all the page shows the file with no highlight', await q.evaluate((v) => !document.querySelector(v + ' .vwchg') && /a first call without help/.test(document.querySelector(v + ' .cfb').textContent), V));
190
+ await q.click(V + ' [data-vd="askt"]');
191
+ await q.fill(V + ' #vwAsk', 'tighten the goal'); await q.click(V + ' [data-vd="ask"]');
192
+ await until(() => C.S.posts.length > 1);
193
+ ok('D6 Ask posts path and prompt to /api/doc-sheet/ask', C.S.posts[1].route === 'ask' && C.S.posts[1].body.prompt === 'tighten the goal' && C.S.posts[1].body.path === PATH);
194
+ ok('D6 while the agent works the page says so', await until(() => q.evaluate((v) => /The agent is reading the document/.test(document.querySelector(v).textContent), V)));
195
+ C.S.props = [prop({ id: 'prop-c', hash: 'hc', prompt: 'tighten the goal', sections: [prop().sections[1]], after: TEXT.replace('- a first call without help', '- a first call in under ten minutes') })];
196
+ C.S.ask = { ok: true, id: 'ask-1', state: 'proposed' };
197
+ ok('D6 when the agent answers, its edit shows applied and highlighted', await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwchg[data-sec="Goal"]') && /The agent changed 1 place/.test(document.querySelector(v + ' .vwag').textContent), V), 9000));
198
+ ok('0 no page error', C.S.errors.length === 0, C.S.errors.join(' | '));
199
+ await C.ctx.close();
200
+ }
201
+ /* D8 floors */
202
+ for (const [w, h, theme] of [[1280, 900, 'light'], [1280, 900, 'dark'], [390, 844, 'light'], [390, 844, 'dark']]) {
203
+ const R = await open({ w, h, theme, props: [prop()] });
204
+ await until(() => R.page.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
205
+ const f = await R.page.evaluate(([v, small]) => {
206
+ const bad = [], root = document.querySelector(v);
207
+ for (const e of root.querySelectorAll('button,input,textarea')) { const r = e.getBoundingClientRect(); if (r.width && r.height && r.height < (small ? 44 : 30)) bad.push(e.textContent.trim().slice(0, 20) + ':' + Math.round(r.height)); }
208
+ const out = [...root.querySelectorAll('*')].filter((e) => { const r = e.getBoundingClientRect(); return r.width && r.right > innerWidth + 1 && !e.closest('.tw,.vwetb,pre'); }).length;
209
+ const fs = [...root.querySelectorAll('*')].map((e) => getComputedStyle(e).fontSize).filter((x, i, a) => a.indexOf(x) === i);
210
+ return { sx: document.documentElement.scrollWidth - innerWidth, bad, out, fs };
211
+ }, [V, w < 600]);
212
+ ok(`D8 at ${w} px ${theme}: no sideways scroll, no small target, nothing past the edge, console sizes only`, f.sx <= 0 && f.bad.length === 0 && f.out === 0 && f.fs.every((x) => ['11px', '12px', '14px', '16px', '20px', '28px'].includes(x)), JSON.stringify(f));
213
+ const c = await R.page.evaluate((v) => { const e = document.querySelector(v + ' .cf'); return [getComputedStyle(e).backgroundColor, getComputedStyle(e).color]; }, V);
214
+ ok(`D8 at ${w} px ${theme}: the page follows the theme`, theme === 'dark' ? c[0] === 'rgb(23, 26, 35)' : c[0] === 'rgb(253, 253, 252)', JSON.stringify(c));
215
+ await R.ctx.close();
216
+ }
217
+ finish();
218
+ })();
@@ -5,6 +5,7 @@
5
5
  import { pmPost } from './http.js';
6
6
  import { proposalsModel, relationsOf, copyKindOf, copyView, editBody, acceptBody, rejectBody, askBody, askLine, issueBody, mdHtml, sectionAttribution, revDiffHtml } from './premium-doc-edit.js';
7
7
  import { $, $$, esc, openDlg, closeDlg, toast, loadThread, logHtml, turnA, ptx, kv, CHECK, CHEV, AI } from './premium-shell.js';
8
+ import { openDocPage } from './premium-vw-doc.js';
8
9
 
9
10
  const when = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return ''; return +m[3] + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+m[2] - 1]; };
10
11
 
@@ -52,7 +53,7 @@ export function mountDocSheet(ctx) {
52
53
  const cps = (s.copies || []).map(copyView);
53
54
  const cpc = s.copies == null ? '' : cps.length ? cps.map((c) => `<button type="button" class="chp lk ${c.tone}" data-ds="cp" aria-expanded="${!!s.cp}" title="${esc(c.words)}"><i></i>${esc(c.tool)}: ${esc(c.state.toLowerCase())}</button>`).join('') : `<button type="button" class="chp lk" data-ds="cp" aria-expanded="${!!s.cp}"><i></i>Link a copy</button>`;
54
55
  const file = String(d.path).split('/').pop();
55
- const head = `<div class="dsm2"><span class="chp ${d.st === 'ok' ? 'ok' : d.st === 'draft' ? 'warn' : ''}"><i></i>${esc(d.state)}</span>${revs.length ? `<span class="chp mono">v${revs.length}</span>` : ''}${chk}${cpc}<button type="button" class="chp lk" data-ds="meta" aria-expanded="${!!s.meta}" title="${esc(d.path)}">${esc(file)}</button>${last ? `<span class="chp"><span>Last change: <b>${esc(whoOf(last))}</b>${last.at ? ', ' + esc(when(last.at)) : ''}</span></span>` : ''}${d.when && !last ? `<span class="chp">updated ${esc(d.when)}</span>` : ''}</div>${s.cp ? copiesHtml(s, cps) : ''}${s.meta ? `<div class="dsmeta"><p class="dpath">${esc(d.path)}</p>${m0 && m0.fm.length ? kv(m0.fm) : '<p class="note">The file has no front matter.</p>'}</div>` : ''}`;
56
+ const head = `<div class="dsm2"><span class="chp ${d.st === 'ok' ? 'ok' : d.st === 'draft' ? 'warn' : ''}"><i></i>${esc(d.state)}</span>${revs.length ? `<span class="chp mono">v${revs.length}</span>` : ''}${chk}${cpc}<button type="button" class="chp lk" data-ds="meta" aria-expanded="${!!s.meta}" title="${esc(d.path)}">${esc(file)}</button><button type="button" class="chp lk" data-ds="page" title="Read and edit it as a page in the viewer">Open as a page</button>${last ? `<span class="chp"><span>Last change: <b>${esc(whoOf(last))}</b>${last.at ? ', ' + esc(when(last.at)) : ''}</span></span>` : ''}${d.when && !last ? `<span class="chp">updated ${esc(d.when)}</span>` : ''}</div>${s.cp ? copiesHtml(s, cps) : ''}${s.meta ? `<div class="dsmeta"><p class="dpath">${esc(d.path)}</p>${m0 && m0.fm.length ? kv(m0.fm) : '<p class="note">The file has no front matter.</p>'}</div>` : ''}`;
56
57
  let body = '';
57
58
  if (s.err) body = `<p class="empty3 plain">${esc(s.err)}</p>`;
58
59
  else if (s.tab === 'read') {
@@ -193,7 +194,7 @@ export function mountDocSheet(ctx) {
193
194
  const lg = e.target.closest('[data-lgd]');
194
195
  if (lg && sheet) { toggleCmp(lg.dataset.lgd); return; }
195
196
  const rl = e.target.closest('[data-rel]');
196
- if (rl && sheet) { openSheet({ path: rl.dataset.rel, title: rl.dataset.rt, st: 'ok', state: 'Current', key: 'rel:' + rl.dataset.rel }); return; }
197
+ if (rl && sheet) { openPage({ path: rl.dataset.rel, title: rl.dataset.rt }); return; } // a related file opens as a page beside this one (premium-viewer R1, R2)
197
198
  const t = e.target.closest('[data-sh]');
198
199
  if (t && sheet) { keepDraft(); sheet.vm = false; sheet.tab = t.dataset.sh; sheet.err = null; sheet.msg = ''; drawSheet(); loadTab(sheet.tab); return; }
199
200
  const b = e.target.closest('[data-ds]'); if (b && sheet) { sheetPress(b.dataset.ds); return; }
@@ -221,6 +222,7 @@ export function mountDocSheet(ctx) {
221
222
  const s = sheet; keepDraft();
222
223
  const fail = (m) => { s.busy = false; s.msg = m; drawSheet(); };
223
224
  if (act === 'meta') { s.meta = !s.meta; drawSheet(); return; }
225
+ if (act === 'page') { openPage({ path: s.d.path, title: s.d.title, iniName: s.d.iniName }); return; }
224
226
  if (act === 'cp') { s.cp = !s.cp; s.cpMsg = ''; drawSheet(); return; }
225
227
  if (act === 'cplink') {
226
228
  const t = String(s.cpUrl || '').trim(), kind = copyKindOf(t);
@@ -289,6 +291,11 @@ export function mountDocSheet(ctx) {
289
291
  toast('Rejected. The file is as it was.'); return reloadSheet(s);
290
292
  }
291
293
  }
294
+ /** The document as a page in the viewer (premium-vw-doc.js). A write there reads this sheet again, so its views stay in step. */
295
+ function openPage(doc) {
296
+ const s = sheet;
297
+ openDocPage(doc, { ws: ctx.ws, onWrite: () => { if (sheet === s && s) reloadSheet(s); } });
298
+ }
292
299
  async function pollAsk(s, id) {
293
300
  for (let i = 0; i < 400 && sheet === s; i++) {
294
301
  await new Promise((r) => setTimeout(r, 2000));