create-pmos 0.297.0 → 0.299.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 +1 -1
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/guide/briefing-premium.md +2 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-studio-report-test.js +37 -1
- package/workspace/public/pm/premium-insights.js +5 -1
- package/workspace/public/pm/premium-report-read.js +3 -3
- package/workspace/public/pm/premium-studio-design.js +203 -0
- package/workspace/public/pm/premium-studio-report.js +34 -7
- package/workspace/public/pm/premium-studio.js +6 -0
- package/workspace/public/pm/premium.css +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.299.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": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T06:45:06Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T06:45:06Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T06:45:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "The premium Briefing (/premium.html)"
|
|
4
4
|
description: "The Briefing page at /premium.html: the hero sentence, What you need to do, Today, the dock, and what each one reads from the repository."
|
|
5
|
-
timestamp: 2026-10-
|
|
5
|
+
timestamp: 2026-10-19
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# The premium Briefing
|
|
@@ -263,6 +263,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
263
263
|
- **Set up a report in the Studio.** **New report** on the Reports card opens the Insight Studio in **Report** mode. The brief shows the Title, What it answers, Audience, Format, Schedule, Draw from (your work, or the board's dashboard) and the Sections. A new report always has the same sections, in the same order, so they are listed, not edited. The checks (what it answers, an audience, a format that fits the audience, a new title, the answer first) say what fails, with a one-press fix. You can say it instead: "it answers: …", "for leadership", "slides", "monthly", "every two weeks on Thursday", "call it …". **Set it up** records the report and writes its first draft as a file.
|
|
264
264
|
- **Change the size of the Studio.** On a wide window, **Normal**, **Half**, **3/4** and **Whole** sit beside **Library**. Whole is the full screen. At Half, the conversation and the Studio are two tabs. The Studio opens on Whole, and PMOS remembers your choice on this browser.
|
|
265
265
|
- **Shape a report's sections.** On a report drawn from your work, **Shape it in the Studio** opens Report mode on it. Tell PMOS how to shape the sections in your own words; PMOS proposes the next version and says what it changed. **Leave out** on a section makes the next version without it; the headline, Needs your call and Sources are always in. **Undo** goes back one version. **Use this structure** saves the version shown, and the next cycle follows it.
|
|
266
|
+
- **Design how a report looks.** A set-up report in the Studio has two tabs: **1 Structure** (what it says) and **2 Design** (how it looks). The Design tab shows the versions D1 to Dn, the slides of the one shown (a large preview, previous and next, and thumbnails), and the samples the look follows. **Add a file** (PDF, PowerPoint, Word or an image) or **Add the link** (Google or Confluence) adds a sample, and PMOS says what it took from it. Say how it should look, for example "use the theme of my picture", and PMOS makes the next version. Pick a version to look at it. **Undo** goes back one version. **This is it** saves the version shown as the design, and each new cycle is drawn to it. When you open a report again, both tabs show what was said before.
|
|
266
267
|
- **What stands out.** Up to three plain sentences taken from the series: behind its line for three readings in a row, behind and still moving away from the target, closing in, slipped, reached its target, or a large one-step move. There is no forecast and no cause.
|
|
267
268
|
- **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
|
|
268
269
|
- **Ask PMOS to set up a report.** Type what the report is for and press **Ask**. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.299.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.299.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -51,6 +51,11 @@ let input = ''; process.stdin.on('data', (d) => { input += d; }); process.stdin.
|
|
|
51
51
|
const line = (k) => { const m = new RegExp('^- ' + k + ': (.*)$', 'm').exec(input); return m ? m[1].trim() : null; };
|
|
52
52
|
const mode = line('Mode'); const out = line('Output path');
|
|
53
53
|
const done = (o) => { process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', is_error: false, result: typeof o === 'string' ? o : JSON.stringify(o), num_turns: 2, duration_ms: 500, permission_denials: [] })); process.exit(0); };
|
|
54
|
+
if (out && /\\.html$/.test(out) && /HTML contract/.test(input)) { // a report-design turn: two slides
|
|
55
|
+
const sec = (id, title) => '<section class="pmos-slide" data-slide-id="' + id + '" data-kind="title" data-title="' + title + '"><h2>' + title + '</h2></section>';
|
|
56
|
+
fs.writeFileSync(out, '<style>.pmos-slide{width:1280px;height:720px}</style>' + sec('title', 'Report') + sec('headline', 'Headline'));
|
|
57
|
+
return setTimeout(() => done({ answer: 'Built the first look.', took: [], rules: { same: ['The order'], changes: [], learned: [] } }), 400);
|
|
58
|
+
}
|
|
54
59
|
if (!mode || !out || mode === 'dry') return done('Done.');
|
|
55
60
|
const prev = line('Previous version');
|
|
56
61
|
const plan = prev && prev.startsWith('/') ? JSON.parse(fs.readFileSync(prev, 'utf8')) : {
|
|
@@ -180,6 +185,33 @@ const model = async () => (await (await fetch(BASE + '/api/insights-premium')).j
|
|
|
180
185
|
const sv = S.stateOf(dir, su.id).saved;
|
|
181
186
|
ok('H7 Use this structure saves the version shown, and is then not offered', sv && sv.n === 1 && await cta() === 'Use this structure:off' && await checksTxt() === '5 of 5 checks pass', JSON.stringify(sv) + ' ' + await cta());
|
|
182
187
|
|
|
188
|
+
/* R: the conversation is kept; opening the report again shows it */
|
|
189
|
+
await p.click('#dlg [aria-label="Close"], #dlg .dx, #dClose').catch(() => {});
|
|
190
|
+
await tap('#oMain [data-st="cancel"]'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
|
|
191
|
+
await until(() => p.evaluate((id) => !!document.querySelector(`#repBody [data-setup="${id}"]`), su.id));
|
|
192
|
+
await p.click(`#repBody [data-setup="${su.id}"]`);
|
|
193
|
+
await until(() => p.evaluate(() => !!document.querySelector('#oMain [data-rx="studio"]')));
|
|
194
|
+
await tap('#oMain [data-rx="studio"]');
|
|
195
|
+
ok('R1 opening the report again shows what was said before', await until(() => p.evaluate(() => document.body.textContent.includes('Shape it for the partner review') && document.body.textContent.includes('Built the first version')), 5000));
|
|
196
|
+
/* D: the Design tab of a set-up report */
|
|
197
|
+
const dver = () => p.evaluate(() => [...document.querySelectorAll('#stPv [data-st^="dzver|"]')].map((b) => b.textContent.trim() + (b.getAttribute('aria-pressed') === 'true' ? '*' : '')).join());
|
|
198
|
+
await p.click('#oMain [data-st="rtab|design"]');
|
|
199
|
+
await until(() => chipv('dsv').then((v) => v === 'None yet'));
|
|
200
|
+
ok('D1 the Design tab opens with no version yet, and the tab is pressed', await chipv('dsv') === 'None yet' && await p.evaluate(() => (document.querySelector('#oMain .stsub [aria-pressed="true"]') || {}).textContent) === '2 Design' && await cta() === 'This is it:off', await chipv('dsv'));
|
|
201
|
+
await tap('#oMain [data-st="chip|dsmp"]'); await sleep(100);
|
|
202
|
+
await p.setInputFiles('#dzFile', { name: 'sample.png', mimeType: 'image/png', buffer: Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', 'base64') });
|
|
203
|
+
ok('D2 a sample file is added and listed', await until(() => p.evaluate(() => /sample\.png/.test((document.querySelector('#stTr') || {}).textContent || '') || /Added "sample\.png"/.test(document.body.textContent)), 8000) && posts.includes('/api/report-design/sample'), posts.join());
|
|
204
|
+
await p.fill('#stIn', 'make it clean and light'); await p.press('#stIn', 'Enter');
|
|
205
|
+
await until(() => dver().then((v) => /^D1/.test(v)), 60000);
|
|
206
|
+
ok('D3 a turn makes D1 and shows it with two slides', /^D1\*/.test(await dver()) && await p.evaluate(() => document.querySelectorAll('#stPv .dzth button').length) === 2 && /Built the first look/.test(await lastA()), await dver() + ' ' + await lastA());
|
|
207
|
+
ok('D4 This is it is offered for the version shown', await cta() === 'This is it:on', await cta());
|
|
208
|
+
await tap('#oMain [data-st="save"]');
|
|
209
|
+
await until(() => chipv('dsv').then((v) => v === 'D1, saved'));
|
|
210
|
+
ok('D5 This is it saves D1 as the design, and is then not offered', await chipv('dsv') === 'D1, saved' && await cta() === 'This is it:off' && posts.includes('/api/report-design/accept'), await chipv('dsv'));
|
|
211
|
+
await shot('report-design-1280');
|
|
212
|
+
await p.click('#oMain [data-st="rtab|structure"]');
|
|
213
|
+
await until(() => chipv('ver').then((v) => /^S/.test(v)));
|
|
214
|
+
ok('D6 back to Structure keeps its version', /^S1/.test(await chipv('ver')), await chipv('ver'));
|
|
183
215
|
await tap('#oMain [data-st="chip|secs"]'); await sleep(150); await shot('report-shape-1280'); await tap('#oMain [data-st="chip|secs"]');
|
|
184
216
|
/* L: the library */
|
|
185
217
|
await tap('#oMain [data-st="lib"]'); await sleep(100);
|
|
@@ -188,7 +220,7 @@ const model = async () => (await (await fetch(BASE + '/api/insights-premium')).j
|
|
|
188
220
|
await tap('#oMain [data-st="lib"]');
|
|
189
221
|
|
|
190
222
|
/* P: the writes */
|
|
191
|
-
const allowed = new Set(['/api/report-setups/setup', '/api/report-setups/from-dashboard', '/api/report-structure/turn', '/api/report-structure/remove', '/api/report-structure/revert', '/api/report-structure/accept']);
|
|
223
|
+
const allowed = new Set(['/api/report-setups/setup', '/api/report-setups/from-dashboard', '/api/report-structure/turn', '/api/report-structure/remove', '/api/report-structure/revert', '/api/report-structure/accept', '/api/report-design/describe', '/api/report-design/sample', '/api/report-design/turn', '/api/report-design/accept', '/api/report-design/revert']);
|
|
192
224
|
ok('P1 every POST is one of the existing report routes', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
|
|
193
225
|
|
|
194
226
|
/* F: floors */
|
|
@@ -198,6 +230,10 @@ const model = async () => (await (await fetch(BASE + '/api/insights-premium')).j
|
|
|
198
230
|
ok('F1 at 390 wide, Report mode does not scroll sideways', wide[0] <= 0 && wide[1] <= 1, wide.join());
|
|
199
231
|
const small = await p.evaluate(() => [...document.querySelectorAll('#oMain .stmd button, #oMain .suc, #stFt button')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent));
|
|
200
232
|
ok('F2 the mode switch, the chips and the footer are 44 px tall', small.length === 0, small.join());
|
|
233
|
+
await p.click('#oMain [data-st="rtab|design"]'); await sleep(600); await shot('report-design-390');
|
|
234
|
+
const wide2 = await p.evaluate(() => { const d = document.querySelector('#oMain'); return [document.documentElement.scrollWidth - innerWidth, d ? d.scrollWidth - d.clientWidth : 0]; });
|
|
235
|
+
const small2 = await p.evaluate(() => [...document.querySelectorAll('#oMain .stmd button, #oMain .suc, #stFt button, #stPv .rdv button, #stPv .rdnv button')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent));
|
|
236
|
+
ok('F4 at 390 wide, the Design tab does not scroll sideways and its presses are 44 px tall', wide2[0] <= 0 && wide2[1] <= 1 && small2.length === 0, wide2.join() + ' ' + small2.join());
|
|
201
237
|
ok('F3 no script error', errs.length === 0, errs.join(' | '));
|
|
202
238
|
return finish();
|
|
203
239
|
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -170,7 +170,11 @@ const structure = {
|
|
|
170
170
|
get: (id) => pmGet('/api/report-structure?ws=' + encodeURIComponent(M.board.ws || '') + '&id=' + encodeURIComponent(id)),
|
|
171
171
|
post: (sub, id, body) => pmPost('/api/report-structure/' + sub, Object.assign({ ws: M.board.ws, id }, body)),
|
|
172
172
|
};
|
|
173
|
-
const
|
|
173
|
+
const design = {
|
|
174
|
+
get: (id) => pmGet('/api/report-design?ws=' + encodeURIComponent(M.board.ws || '') + '&id=' + encodeURIComponent(id)),
|
|
175
|
+
post: (sub, id, body) => pmPost('/api/report-design/' + sub, Object.assign({ ws: M.board.ws, id }, body)),
|
|
176
|
+
};
|
|
177
|
+
const studioOf = (o) => openStudio(Object.assign({ M, tile: tileHtml, derive: deriveChart, save: saveDash, saveChart, setup: (sub, body) => repPost(sub, body), structure, design, reportsChanged: () => load(),
|
|
174
178
|
done: async (id) => { dash = id || dash; if (!M.dashboards.some((d) => d.id === dash)) dash = 'all'; await load(); } }, o));
|
|
175
179
|
function openDashEdit(D) { studioOf({ mode: 'dash', D, done: async (id) => { dash = id || 'all'; await load(); } }); }
|
|
176
180
|
/* A chart is made and edited in the Studio's Chart mode (initiative premium-studio-chart). Save posts POST /api/premium-charts/save. */
|
|
@@ -65,7 +65,7 @@ export function slideHtml(lines) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/* ── a sanitized render: its style, its slides and its body (DOMParser; nothing of it runs) ── */
|
|
68
|
-
function splitRender(html) {
|
|
68
|
+
export function splitRender(html) {
|
|
69
69
|
const d = new DOMParser().parseFromString(String(html || ''), 'text/html');
|
|
70
70
|
d.querySelectorAll('script,iframe,object,embed,link,meta,base').forEach((n) => n.remove());
|
|
71
71
|
d.querySelectorAll('*').forEach((n) => { for (const a of [...n.attributes]) if (/^on/i.test(a.name) || /^\s*javascript:/i.test(a.value)) n.removeAttribute(a.name); });
|
|
@@ -103,7 +103,7 @@ function sourceLine() {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/* ── drawing ── */
|
|
106
|
-
function slideCard(s, mini) {
|
|
106
|
+
export function slideCard(s, mini) {
|
|
107
107
|
if (s.k === 'frame') return `<div class="rdfc${mini ? ' mini' : ''}">${frame(s.css, s.html, 'pmos-one', s.h)}</div>`;
|
|
108
108
|
if (s.k === 'title') return `<div class="rds title${mini ? ' mini' : ''}"><h3>${esc(s.h)}</h3>${mini ? '' : `<p>${esc(s.t)}</p>`}</div>`;
|
|
109
109
|
return `<div class="rds${mini ? ' mini' : ''}"><h3>${esc(s.h)}</h3>${mini ? '' : s.html}</div>`;
|
|
@@ -160,7 +160,7 @@ function draw() {
|
|
|
160
160
|
/* a 1280 x 720 frame scales to its card's width */
|
|
161
161
|
const RO = typeof ResizeObserver === 'function' ? new ResizeObserver((es) => { for (const e of es) scaleOf(e.target, e.contentRect.width); }) : null;
|
|
162
162
|
function scaleOf(card, w) { if (w) card.style.setProperty('--rp-scale', String(Math.round((w / W) * 10000) / 10000)); }
|
|
163
|
-
function fit(root) { root.querySelectorAll('.rdfc').forEach((c) => { if (RO) RO.observe(c); scaleOf(c, c.getBoundingClientRect().width); }); }
|
|
163
|
+
export function fit(root) { root.querySelectorAll('.rdfc').forEach((c) => { if (RO) RO.observe(c); scaleOf(c, c.getBoundingClientRect().width); }); }
|
|
164
164
|
|
|
165
165
|
/* ── the conversation ── */
|
|
166
166
|
const stream = () => $('#dBody .stream');
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/* pm/premium-studio-design.js — the Design step of a set-up report in the Insight Studio (initiative premium-studio-design). The console's Design studio
|
|
2
|
+
* (c3-design-studio.js) on the premium page: the versions D1 to Dn of the report's look, the slides of the one shown, the samples the look follows, and
|
|
3
|
+
* This is it. premium-studio-report.js hands a set-up report's Design tab to this module: the brief, its tray, the preview, the checks, the footer and
|
|
4
|
+
* the conversation. A report's Structure (what it says) and its Design (how it looks) are two tabs of the same report.
|
|
5
|
+
*
|
|
6
|
+
* READS: GET /api/report-design (versions, samples, log, saved) and GET /api/report-design/version (one sanitized render).
|
|
7
|
+
* WRITES: the report-design describe, sample, turn, accept and revert routes only, each a press on the page behind the launch nonce.
|
|
8
|
+
* A render is HTML the server sanitized; it is shown in a frame with an empty sandbox, so nothing in it runs. Nothing is sent outward. */
|
|
9
|
+
import { $, esc } from './premium-shell.js';
|
|
10
|
+
import { splitRender, slideCard, fit } from './premium-report-read.js';
|
|
11
|
+
|
|
12
|
+
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
13
|
+
const PREV = ICO('<path d="m15 6-6 6 6 6"/>'), NEXT = ICO('<path d="m9 6 6 6-6 6"/>'), PLUS = ICO('<path d="M12 5v14M5 12h14"/>'), CHK = ICO('<path d="M5 12.5l4.5 4.5L19 7.5"/>');
|
|
14
|
+
const KINDS = { pdf: 'pdf', pptx: 'pptx', docx: 'docx', png: 'image', jpg: 'image', jpeg: 'image' };
|
|
15
|
+
const SWORD = { pdf: 'PDF', pptx: 'PowerPoint', docx: 'Word', image: 'Image', pictures: 'Page pictures', link: 'Link', 'pmos-doc': 'Past PMOS document' };
|
|
16
|
+
const POLL_MS = 800, POLL_MAX = 240000;
|
|
17
|
+
const HELPD = 'Tell me how it should look, for example: use the theme of my picture, denser, like slide 3 of my sample. Add a sample first if you have one. PMOS makes the next version; nothing is kept until you press This is it.';
|
|
18
|
+
const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
|
|
19
|
+
|
|
20
|
+
let X = null; // the Studio's hand, as premium-studio-report.js gets it
|
|
21
|
+
export function useStudio(x) { X = x; }
|
|
22
|
+
const hand = () => X.P.design;
|
|
23
|
+
|
|
24
|
+
/* ── the state of one report's design, kept on its draft: d.D = { design, err, loading, shown, ver: Map, i } ── */
|
|
25
|
+
export function fresh() { return { design: null, err: '', loading: false, shown: null, ver: new Map(), i: 0, working: false, link: '' }; }
|
|
26
|
+
const saved = (z) => (z.design && z.design.saved ? z.design.saved.version : null);
|
|
27
|
+
const versions = (z) => (z.design && z.design.versions) || [];
|
|
28
|
+
const slidesOf = (z) => { const r = z.ver.get(z.shown); return r ? r.slides.map((s) => ({ k: 'frame', h: s.h, html: s.html, css: r.style })) : []; };
|
|
29
|
+
|
|
30
|
+
export async function load(d) {
|
|
31
|
+
const z = d.Z; z.loading = true;
|
|
32
|
+
const res = await hand().get(d.id);
|
|
33
|
+
if (X.r() !== d) return;
|
|
34
|
+
z.loading = false;
|
|
35
|
+
if (!res || res.ok !== true) { z.err = (res && res.error) || 'The design of this report could not be read.'; X.draw(); return; }
|
|
36
|
+
z.design = res.design; z.err = '';
|
|
37
|
+
const cur = z.design.current != null ? z.design.current : saved(z);
|
|
38
|
+
if (z.shown == null) z.shown = cur;
|
|
39
|
+
if (z.shown != null) await read(z, z.shown);
|
|
40
|
+
X.restream(chat(d));
|
|
41
|
+
if (z.design.running) { z.working = true; X.draw(); wait(d, z.design.log.length).then((a) => { if (X.r() === d && d.tab === 'design') X.say(a); }); return; }
|
|
42
|
+
X.draw();
|
|
43
|
+
}
|
|
44
|
+
async function read(z, n) {
|
|
45
|
+
if (z.ver.has(n)) return;
|
|
46
|
+
try { const r = await fetch('/api/report-design/version?' + q({ ws: X.P.M.board.ws, id: X.r().id, n }), { credentials: 'same-origin' }); if (r.ok) z.ver.set(n, splitRender(await r.text())); } catch { /* shown as unread */ }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* ── the conversation: what the design log says, as the console shows it ── */
|
|
50
|
+
const GREET = (d) => 'This is the design of "' + d.name + '": how each cycle looks. Add a sample, or say what you want, and I make a version. Press This is it on the one you want. Nothing is sent.';
|
|
51
|
+
export function chat(d) {
|
|
52
|
+
const L = ((d.Z.design && d.Z.design.log) || []).map((l) => ({ who: l.who === 'pmos' ? 'a' : 'u', text: l.kind === 'sample' ? 'Added the sample "' + l.text + '".' : l.text }));
|
|
53
|
+
return [{ who: 'a', text: GREET(d) }].concat(L);
|
|
54
|
+
}
|
|
55
|
+
export const help = () => HELPD;
|
|
56
|
+
export const guide = (d) => 'Shape how ' + esc(d.name) + ' looks. <button type="button" class="lk" data-st="rtab|structure">Back to the structure</button>';
|
|
57
|
+
|
|
58
|
+
/* ── the tabs of a set-up report ── */
|
|
59
|
+
export const tabs = (d) => `<div class="stmd stsub" role="group" aria-label="Step of this report"><button type="button" data-st="rtab|structure" aria-pressed="${d.tab !== 'design'}">1 Structure</button><button type="button" data-st="rtab|design" aria-pressed="${d.tab === 'design'}">2 Design</button></div>`;
|
|
60
|
+
export async function openTab(d, tab) {
|
|
61
|
+
if (d.tab === tab) return;
|
|
62
|
+
d.tab = tab;
|
|
63
|
+
if (tab === 'design') {
|
|
64
|
+
X.restream([{ who: 'a', text: 'Reading the design.' }]);
|
|
65
|
+
X.draw(); await load(d);
|
|
66
|
+
} else {
|
|
67
|
+
X.restream([{ who: 'a', text: 'This is "' + d.name + '". ' }].concat(d.S ? d.S.log.map((l) => ({ who: l.who === 'pmos' ? 'a' : 'u', text: l.text })) : []));
|
|
68
|
+
X.draw();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ── the brief, tray, preview, checks, footer ── */
|
|
73
|
+
export function brief(d) {
|
|
74
|
+
const z = d.Z, c = X.chip, n = saved(z), v = versions(z);
|
|
75
|
+
return `<div class="stbr" role="group" aria-label="Brief">${tabs(d)}${c('dfmt', 'Format', z.loading ? 'Reading' : ({ deck: 'Deck', doc: 'Document' }[(z.design || {}).format] || 'Deck'))}${c('dsmp', 'Samples', z.loading ? 'Reading' : String(((z.design || {}).samples || []).length))}${c('dsv', 'Design', z.loading ? 'Reading' : n == null ? (v.length ? 'D' + (z.shown || v[v.length - 1].n) + ', not saved' : 'None yet') : 'D' + n + ', saved')}</div>`;
|
|
76
|
+
}
|
|
77
|
+
export function tray(d, p) {
|
|
78
|
+
const z = d.Z, S = (z.design || {}).samples || [];
|
|
79
|
+
if (p === 'dfmt') return '<p class="note">A version is a deck or a document: PMOS chooses it from what you say and your samples. Say "make it a document" to change it.</p>';
|
|
80
|
+
if (p === 'dsmp') {
|
|
81
|
+
return (S.length ? `<ul class="sul">${S.map((s) => `<li><span>${esc(s.name)}<small>${esc(s.line || SWORD[s.kind] || s.kind)}${s.hint ? '. ' + esc(s.hint) : ''}</small>${s.took ? `<small>PMOS took: ${esc(s.took)}</small>` : s.readable === false ? '<small>PMOS could not read it with your tools. It is kept, but it does not shape the design.</small>' : '<small>PMOS reads it on the next version.</small>'}</span></li>`).join('')}</ul>` : '<p class="note">No sample yet. A sample is a deck, a document or a picture of how you want it to look.</p>')
|
|
82
|
+
+ `<div class="sor"><button type="button" class="dmcta alt" data-st="dzpick"${z.working ? ' disabled' : ''}>${PLUS}Add a file</button><input type="file" id="dzFile" hidden accept=".pdf,.pptx,.docx,.png,.jpg,.jpeg"></div>`
|
|
83
|
+
+ `<div class="stlk"><input class="sti" id="dzLink" placeholder="A Google Slides, Docs or Confluence link" maxlength="600" aria-label="A link to a sample" autocomplete="off" value="${esc(z.link)}"><button type="button" class="dmcta alt" data-st="dzlink"${z.working ? ' disabled' : ''}>Add the link</button></div><p class="note">PDF, PowerPoint, Word, PNG or JPG, up to 20 MB. A link is read with your own connectors.</p>`;
|
|
84
|
+
}
|
|
85
|
+
if (p === 'dsv') {
|
|
86
|
+
const v = versions(z);
|
|
87
|
+
return v.length ? `<ul class="sul">${v.slice().reverse().map((x) => `<li><span>D${x.n}${x.n === saved(z) ? ' · saved' : ''}${x.n === z.shown ? ' · shown' : ''}<small>${esc(x.turn || '')}</small></span></li>`).join('')}</ul><p class="note">Pick a version in the preview. This is it keeps the one shown. Undo goes back one version.</p>` : '<p class="note">No version yet. Say how it should look.</p>';
|
|
88
|
+
}
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
export function preview(d) {
|
|
92
|
+
const z = d.Z;
|
|
93
|
+
if (z.loading) return '<div class="stpvw"><p class="note">Reading the design of this report.</p></div>';
|
|
94
|
+
if (z.err) return `<div class="stpvw"><p class="note">${esc(z.err)}</p></div>`;
|
|
95
|
+
const v = versions(z), n = saved(z);
|
|
96
|
+
if (!v.length) return `<div class="stpvw"><p class="note">${z.working ? 'PMOS is making the first version.' : 'No version yet. Add a sample, or say how the report should look. PMOS makes D1.'}</p></div>`;
|
|
97
|
+
const L = slidesOf(z), i = z.i = Math.max(0, Math.min(z.i, L.length - 1));
|
|
98
|
+
const strip = `<span class="rdv" role="group" aria-label="Design versions">${v.map((x) => `<button type="button" data-st="dzver|${x.n}" aria-pressed="${x.n === z.shown}"${z.working ? ' disabled' : ''} title="${esc((x.n === n ? 'Saved. ' : '') + (x.turn || ''))}" aria-label="D${x.n}${x.n === n ? ', saved' : ''}">D${x.n}${x.n === n ? CHK : ''}</button>`).join('')}</span>`;
|
|
99
|
+
const big = L.length ? `<div class="rdk"><div class="rdbig" id="dzSlide" tabindex="0" role="group" aria-roledescription="slide" aria-label="Slide ${i + 1} of ${L.length}: ${esc(L[i].h)}">${slideCard(L[i])}</div>`
|
|
100
|
+
+ `<div class="rdnv"><button type="button" data-st="dzgo|${i - 1}" aria-label="Previous slide"${i === 0 ? ' disabled' : ''}>${PREV}</button><span>${i + 1} / ${L.length}</span><button type="button" data-st="dzgo|${i + 1}" aria-label="Next slide"${i === L.length - 1 ? ' disabled' : ''}>${NEXT}</button></div>`
|
|
101
|
+
+ `<div class="rdt dzth" role="group" aria-label="Slides">${L.map((x, j) => `<button type="button" data-st="dzgo|${j}"${j === i ? ' aria-current="true"' : ''} aria-label="Slide ${j + 1}: ${esc(x.h)}">${slideCard(x, true)}<i>${j + 1}</i></button>`).join('')}</div></div>`
|
|
102
|
+
: '<p class="note">This version is not drawn as slides. It is a page.</p>';
|
|
103
|
+
return `<div class="stpvw dzpv"><div class="dzbar">${strip}<span class="note">${z.working ? 'PMOS is working on the next version.' : z.shown === n ? 'The saved design.' : 'Not saved. Press This is it to keep it.'}</span></div>${big}</div>`;
|
|
104
|
+
}
|
|
105
|
+
export function afterDraw() { const m = $('#stPv'); if (m) fit(m); }
|
|
106
|
+
export function checks(d) {
|
|
107
|
+
const z = d.Z, S = (z.design || {}).samples || [], n = saved(z), v = versions(z);
|
|
108
|
+
return [
|
|
109
|
+
{ ok: v.length > 0, l: 'A version exists', d: v.length ? v.length + ' version' + (v.length === 1 ? '' : 's') + ': D' + v[0].n + ' to D' + v[v.length - 1].n + '.' : 'There is no version yet. Say how it should look.' },
|
|
110
|
+
{ ok: S.length > 0 || !!(z.design && z.design.description), l: 'The look has something to follow', d: S.length ? 'It follows ' + S.map((s) => s.name).join(', ') + '.' : z.design && z.design.description ? 'It follows your description.' : 'There is no sample and no description.', fix: ['Add a sample', 'chip|dsmp'] },
|
|
111
|
+
{ ok: n != null, l: 'A design is saved', d: n != null ? 'D' + n + ' is the saved design. Each new cycle is drawn to it.' : 'No design is saved, so each cycle uses the standard look.', fix: z.shown != null ? ['This is it', 'dzkeep'] : null },
|
|
112
|
+
{ ok: n != null && n === z.shown, l: 'The version shown is the saved one', d: n == null ? 'Nothing is saved yet.' : n === z.shown ? 'D' + n + ' is shown and saved.' : 'D' + z.shown + ' is shown. The saved design is D' + n + '.', fix: z.shown != null && z.shown !== n ? ['This is it', 'dzkeep'] : null },
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
export function footer(d) {
|
|
116
|
+
const z = d.Z, n = z.shown;
|
|
117
|
+
return { undo: !z.working && n != null && versions(z).some((x) => x.n < n), cta: 'This is it', off: z.working || n == null || n === saved(z) };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* ── presses ── */
|
|
121
|
+
async function refresh(d) { const res = await hand().get(d.id); if (res && res.ok === true) d.Z.design = res.design; return d.Z.design; }
|
|
122
|
+
export async function press(d, a) {
|
|
123
|
+
const [k, v] = a, z = d.Z;
|
|
124
|
+
if (k === 'dzgo') { z.i = +v; X.draw(['pv']); afterDraw(); const s = $('#dzSlide'); if (s) s.focus(); return; }
|
|
125
|
+
if (k === 'dzver') { await show(d, +v, true); return; }
|
|
126
|
+
if (k === 'dzkeep') { await keep(d); return; }
|
|
127
|
+
if (k === 'dzpick') { const f = $('#dzFile'); if (f) f.click(); return; }
|
|
128
|
+
if (k === 'dzlink') { const i = $('#dzLink'); const link = i ? i.value.trim() : ''; if (!link) { X.st.msg = 'Paste a link first.'; X.draw(['ft']); return; } await sample(d, { link }); }
|
|
129
|
+
}
|
|
130
|
+
async function show(d, n, pick) {
|
|
131
|
+
const z = d.Z;
|
|
132
|
+
if (pick && z.design && z.design.current !== n) {
|
|
133
|
+
const r = await hand().post('revert', d.id, { n });
|
|
134
|
+
if (!r || r.ok !== true) { X.st.msg = (r && r.error) || 'D' + n + ' could not be picked.'; X.draw(['ft']); return; }
|
|
135
|
+
z.design = r.design; X.say('Back to D' + n + '. The next version builds on it.');
|
|
136
|
+
}
|
|
137
|
+
z.shown = n; z.i = 0; await read(z, n); X.draw(); afterDraw();
|
|
138
|
+
}
|
|
139
|
+
export async function undo(d) {
|
|
140
|
+
const z = d.Z, V = versions(z).filter((x) => x.n < z.shown);
|
|
141
|
+
if (!V.length || z.working) return null;
|
|
142
|
+
const to = V[V.length - 1].n;
|
|
143
|
+
await show(d, to, true);
|
|
144
|
+
return 'Done: back to D' + to + '. The next version builds on it.';
|
|
145
|
+
}
|
|
146
|
+
export async function keep(d) {
|
|
147
|
+
const z = d.Z, n = z.shown, s = X.st; if (n == null || n === saved(z) || z.working) return;
|
|
148
|
+
s.busy = true; s.msg = 'Saving the design.'; X.draw(['ft']);
|
|
149
|
+
const r = await hand().post('accept', d.id, { n });
|
|
150
|
+
s.busy = false;
|
|
151
|
+
if (!r || r.ok !== true) { s.msg = (r && r.error) || 'The design could not be saved.'; X.draw(); return; }
|
|
152
|
+
z.design = r.design; s.msg = 'D' + n + ' is saved as the design. ' + (r.redraw && r.redraw.started ? 'PMOS is drawing the current cycle to match it.' : 'Each new cycle is drawn to match it.');
|
|
153
|
+
X.draw(); afterDraw(); X.P.reportsChanged();
|
|
154
|
+
}
|
|
155
|
+
async function sample(d, body) {
|
|
156
|
+
const z = d.Z, s = X.st; s.msg = 'Adding the sample.'; X.draw(['ft']);
|
|
157
|
+
const r = await hand().post('sample', d.id, body);
|
|
158
|
+
if (!r || r.ok !== true) { s.msg = 'The sample was not added: ' + ((r && r.error) || 'the press did not go through.'); X.draw(['ft']); return; }
|
|
159
|
+
z.link = ''; await refresh(d); s.msg = '';
|
|
160
|
+
X.say('Added "' + ((r.sample && r.sample.name) || 'the sample') + '". Tell me what to take from it, and I make the next version follow it.');
|
|
161
|
+
}
|
|
162
|
+
export async function addFile(d, file) {
|
|
163
|
+
const ext = (/\.([a-z0-9]+)$/i.exec(file.name) || [])[1], kind = KINDS[String(ext || '').toLowerCase()];
|
|
164
|
+
if (!kind) { X.st.msg = 'A sample is a PDF, PowerPoint, Word, PNG or JPG file.'; X.draw(['ft']); return; }
|
|
165
|
+
if (file.size > 20 * 1024 * 1024) { X.st.msg = 'A sample is 20 MB or less.'; X.draw(['ft']); return; }
|
|
166
|
+
const data = await new Promise((ok) => { const r = new FileReader(); r.onload = () => ok(String(r.result || '')); r.onerror = () => ok(''); r.readAsDataURL(file); });
|
|
167
|
+
if (!data) { X.st.msg = 'The file could not be read.'; X.draw(['ft']); return; }
|
|
168
|
+
await sample(d, { name: file.name, kind, data });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* ── a turn: one design job. Its answer is PMOS's own line from the design log. ── */
|
|
172
|
+
export async function turn(d, t, low) {
|
|
173
|
+
const z = d.Z;
|
|
174
|
+
if (/^(this is it|use this|save (it|this)|keep (it|this))\b/.test(low)) { await keep(d); return X.st.msg; }
|
|
175
|
+
if (/^undo\b/.test(low)) return (await undo(d)) || 'I changed nothing. There is no earlier version to go back to.';
|
|
176
|
+
if (z.working) return 'PMOS is still working on the last version. Wait for its answer.';
|
|
177
|
+
if (z.loading) return 'Reading the design. Try again in a moment.';
|
|
178
|
+
z.working = true; X.draw();
|
|
179
|
+
if (z.design && !z.design.description && !(z.design.versions || []).length) {
|
|
180
|
+
const r0 = await hand().post('describe', d.id, { text: t });
|
|
181
|
+
if (!r0 || r0.ok !== true) { z.working = false; X.draw(); return 'The description was not saved: ' + ((r0 && r0.error) || 'the press did not go through.'); }
|
|
182
|
+
}
|
|
183
|
+
const before = ((z.design && z.design.log) || []).length;
|
|
184
|
+
const r = await hand().post('turn', d.id, { text: t });
|
|
185
|
+
if (!r || r.ok !== true) { z.working = false; X.draw(); return 'Nothing changed: ' + ((r && r.error) || 'the change could not start.'); }
|
|
186
|
+
return wait(d, before);
|
|
187
|
+
}
|
|
188
|
+
async function wait(d, before) {
|
|
189
|
+
const z = d.Z, t0 = Date.now();
|
|
190
|
+
for (;;) {
|
|
191
|
+
await new Promise((ok) => setTimeout(ok, POLL_MS));
|
|
192
|
+
if (X.r() !== d || d.tab !== 'design') return 'The Studio moved on. The answer is in the report\'s design.';
|
|
193
|
+
const g = await refresh(d);
|
|
194
|
+
if (g && !g.running) {
|
|
195
|
+
z.working = false;
|
|
196
|
+
const L = (g.log || []).slice(before).filter((x) => x.kind === 'version' || x.kind === 'error'), last = L[L.length - 1];
|
|
197
|
+
if (last && last.kind === 'version' && last.version) { await show(d, last.version, false); return last.text + ' This is D' + last.version + '. Press This is it to keep it as the design.'; }
|
|
198
|
+
X.draw();
|
|
199
|
+
return last ? 'The change did not work: ' + last.text : 'PMOS ended without a new version. Say it again, or in other words.';
|
|
200
|
+
}
|
|
201
|
+
if (Date.now() - t0 > POLL_MAX) { z.working = false; X.draw(); return 'PMOS has not answered yet. The version shows when you open this report again.'; }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* Use this structure posts .../accept. Every POST goes through the page's hand (P.setup, P.structure), behind the launch nonce. The frame of a new report
|
|
9
9
|
* is frozen (D78 as amended by D86), so its sections are shown, not edited. Nothing is sent outward. */
|
|
10
10
|
import { $, esc } from './premium-shell.js';
|
|
11
|
+
import * as DES from './premium-studio-design.js';
|
|
11
12
|
|
|
12
13
|
const OUT = { 'google-slides': ['Google Slides', 'A deck. Leadership usually reads one.'], 'google-doc': ['Google Doc', 'A document to read through.'], 'google-sheets': ['Google Sheets', 'A spreadsheet of the numbers.'], confluence: ['Confluence page', 'A page in your wiki.'], pdf: ['PDF', 'A file to keep or attach.'] };
|
|
13
14
|
const CAD = { daily: 'Daily', weekly: 'Weekly', 'bi-weekly': 'Every two weeks', monthly: 'Monthly' };
|
|
@@ -25,7 +26,8 @@ const HELP = 'I understand: call it something, it answers something (or a questi
|
|
|
25
26
|
const HELPS = 'Tell me how to shape the sections in your own words, for example: leave out the timeline, or put the decisions first. PMOS proposes the next version; nothing is saved until you press Use this structure. Undo goes back one version.';
|
|
26
27
|
|
|
27
28
|
let X = null; // the Studio's hand: { st, P, chip, opt, field, draw, plural }
|
|
28
|
-
export function useStudio(x) { X = x; }
|
|
29
|
+
export function useStudio(x) { X = x; DES.useStudio({ get st() { return x.st; }, get P() { return x.P; }, chip: x.chip, draw: x.draw, say: x.say, restream: x.restream, r: () => x.st.r }); }
|
|
30
|
+
const design = (d) => d.kind === 'setup' && d.tab === 'design';
|
|
29
31
|
const st = () => X.st;
|
|
30
32
|
const r = () => X.st.r;
|
|
31
33
|
const board = () => X.P.M.board || {};
|
|
@@ -44,7 +46,7 @@ export function blankReport() {
|
|
|
44
46
|
return { kind: 'new', title: ((board().name || 'Board') + ' weekly report').slice(0, 80), purpose: '', audience: 'The team', output: 'google-doc', cadence: 'weekly', day: 'Mon', from: 'work' };
|
|
45
47
|
}
|
|
46
48
|
export function setupReport(s) {
|
|
47
|
-
const d = { kind: 'setup', id: s.id, name: s.name, audience: s.audience, output: s.output, label: s.label, S: null, loading: true, working: false, err: '' };
|
|
49
|
+
const d = { kind: 'setup', id: s.id, name: s.name, audience: s.audience, output: s.output, label: s.label, S: null, loading: true, working: false, err: '', tab: 'structure', Z: DES.fresh() };
|
|
48
50
|
load(d);
|
|
49
51
|
return d;
|
|
50
52
|
}
|
|
@@ -53,7 +55,11 @@ async function load(d) {
|
|
|
53
55
|
if (r() !== d) return;
|
|
54
56
|
d.loading = false;
|
|
55
57
|
if (!res || res.ok !== true) { d.err = (res && res.error) || 'The structure of this report could not be read.'; X.draw(); return; }
|
|
56
|
-
d.S = res.structure; d.err = '';
|
|
58
|
+
d.S = res.structure; d.err = '';
|
|
59
|
+
// The conversation is kept in the structure log: show what was said before, failed runs included, and pick up a run that is still going.
|
|
60
|
+
X.replay((d.S.log || []).map((l) => ({ who: l.who === 'pmos' ? 'a' : 'u', text: l.text })));
|
|
61
|
+
if (d.S.running) { d.working = true; X.draw(); waitFor(d, (d.S.log || []).length).then((a) => { if (r() === d) X.say(a); }); return; }
|
|
62
|
+
X.draw();
|
|
57
63
|
}
|
|
58
64
|
const plan = (d) => (d.S && d.S.plan) || null;
|
|
59
65
|
const shownN = (d) => (d.S ? d.S.current : null);
|
|
@@ -63,14 +69,16 @@ const outline = (d) => (plan(d) ? plan(d).outline : FRAME.map(([id, title]) => (
|
|
|
63
69
|
/* ── the brief ── */
|
|
64
70
|
export function brief() {
|
|
65
71
|
const d = r(), c = X.chip;
|
|
72
|
+
if (design(d)) return DES.brief(d);
|
|
66
73
|
if (d.kind === 'new') {
|
|
67
74
|
return `<div class="stbr" role="group" aria-label="Brief">${c('title', 'Title', d.title || 'Not set')}${c('purpose', 'What it answers', d.purpose || 'Not set')}${c('aud', 'Audience', d.audience || 'Not set')}${c('out', 'Format', outName(d.output))}${c('sched', 'Schedule', schedLabel(d))}${c('from', 'Draw from', d.from === 'dash' ? 'The board\'s dashboard' : 'Your work')}${d.from === 'work' ? c('secs', 'Sections', String(FRAME.length)) : ''}</div>`;
|
|
68
75
|
}
|
|
69
76
|
const n = shownN(d), s = savedN(d);
|
|
70
|
-
return `<div class="stbr" role="group" aria-label="Brief">${c('facts', 'Report', d.name)}${c('secs', 'Sections', d.loading ? 'Reading' : String(outline(d).length))}${c('ver', 'Version', d.loading ? 'Reading' : n == null ? 'None yet' : 'S' + n + (s === n ? ', saved' : s != null ? ', saved is S' + s : ', not saved'))}</div>`;
|
|
77
|
+
return `<div class="stbr" role="group" aria-label="Brief">${DES.tabs(d)}${c('facts', 'Report', d.name)}${c('secs', 'Sections', d.loading ? 'Reading' : String(outline(d).length))}${c('ver', 'Version', d.loading ? 'Reading' : n == null ? 'None yet' : 'S' + n + (s === n ? ', saved' : s != null ? ', saved is S' + s : ', not saved'))}</div>`;
|
|
71
78
|
}
|
|
72
79
|
export function tray(p) {
|
|
73
80
|
const d = r(), o = X.opt, f = X.field;
|
|
81
|
+
if (design(d)) return DES.tray(d, p);
|
|
74
82
|
if (d.kind === 'new') {
|
|
75
83
|
if (p === 'title') return f('title', d.title, 'The name of the report', 80);
|
|
76
84
|
if (p === 'purpose') return f('purpose', d.purpose, 'For example: Are partners activating, and what do we decide?', 400) + '<p class="note">One line: what the report answers for its readers. The headline leads with it.</p>';
|
|
@@ -108,6 +116,7 @@ export function libRows() {
|
|
|
108
116
|
/* ── the preview ── */
|
|
109
117
|
export function preview() {
|
|
110
118
|
const d = r();
|
|
119
|
+
if (design(d)) return DES.preview(d);
|
|
111
120
|
if (d.kind === 'new') {
|
|
112
121
|
const secs = d.from === 'work' ? FRAME.map(([, t, w]) => `<section class="stsec"><h4>${esc(t)}</h4><p class="mut">${esc(w)}</p></section>`).join('')
|
|
113
122
|
: `<p class="note">Drawn from ${esc(board().name || 'the board')}'s dashboard: each of its charts, in its order, as the dashboard reads them on the report's day.</p>`;
|
|
@@ -124,6 +133,7 @@ export function preview() {
|
|
|
124
133
|
/* ── the checks ── */
|
|
125
134
|
export function checks() {
|
|
126
135
|
const d = r();
|
|
136
|
+
if (design(d)) return DES.checks(d);
|
|
127
137
|
if (d.kind === 'new') {
|
|
128
138
|
const dup = setups().some((s) => s.name.toLowerCase() === d.title.trim().toLowerCase());
|
|
129
139
|
return [
|
|
@@ -145,11 +155,13 @@ export function checks() {
|
|
|
145
155
|
}
|
|
146
156
|
export function guide() {
|
|
147
157
|
const d = r();
|
|
158
|
+
if (design(d)) return DES.guide(d);
|
|
148
159
|
return d.kind === 'new' ? 'A report leads with the answer, then the evidence, then what it needs from the reader.'
|
|
149
160
|
: 'Shape the sections of ' + esc(d.name) + ' in words. PMOS proposes each version. <button type="button" class="lk" data-st="new">Start a new report instead</button>';
|
|
150
161
|
}
|
|
151
162
|
export function footer() {
|
|
152
163
|
const d = r(), s = st();
|
|
164
|
+
if (design(d)) { const f = DES.footer(d); return { undo: f.undo, cta: f.cta, off: f.off || s.busy }; }
|
|
153
165
|
if (d.kind === 'new') return { undo: s.h.rep.length > 0, cta: 'Set it up', off: s.busy };
|
|
154
166
|
const n = shownN(d);
|
|
155
167
|
return { undo: !d.working && !!(d.S && d.S.versions.some((v) => v.n < n)), cta: 'Use this structure', off: s.busy || d.working || n == null || n === savedN(d) };
|
|
@@ -166,6 +178,7 @@ export function set(f, v) {
|
|
|
166
178
|
}
|
|
167
179
|
/* Undo on a set-up report goes back to the version before the one shown (POST .../revert). → a promise of the answer, or null when there is none. */
|
|
168
180
|
export function undoSetup() {
|
|
181
|
+
if (design(r())) return DES.undo(r()).then((a) => a || 'I changed nothing. There is no earlier version to go back to.');
|
|
169
182
|
const d = r(), n = shownN(d), V = ((d.S && d.S.versions) || []).filter((v) => v.n < n);
|
|
170
183
|
if (!V.length || d.working) return null;
|
|
171
184
|
const to = V[V.length - 1].n;
|
|
@@ -184,6 +197,7 @@ export async function leaveOut(id) {
|
|
|
184
197
|
}
|
|
185
198
|
export async function save() {
|
|
186
199
|
const d = r(), s = st();
|
|
200
|
+
if (design(d)) return DES.keep(d);
|
|
187
201
|
if (d.kind === 'setup') {
|
|
188
202
|
const n = shownN(d); if (n == null || n === savedN(d)) return;
|
|
189
203
|
s.busy = true; s.msg = 'Saving the structure.'; X.draw(['ft']);
|
|
@@ -209,9 +223,10 @@ export async function save() {
|
|
|
209
223
|
}
|
|
210
224
|
|
|
211
225
|
/* ── the conversation ── */
|
|
212
|
-
export const help = () => (r().kind === 'new' ? HELP : HELPS);
|
|
226
|
+
export const help = () => (r().kind === 'new' ? HELP : design(r()) ? DES.help() : HELPS);
|
|
213
227
|
export function command(t, low) {
|
|
214
228
|
const d = r();
|
|
229
|
+
if (design(d)) return DES.turn(d, t, low);
|
|
215
230
|
if (d.kind === 'setup') return turn(t, low);
|
|
216
231
|
if (/\b(start (a )?new|new report|start over)\b/.test(low)) { X.snap(); st().r = blankReport(); return 'Done: a new report. Say what it answers and who reads it.'; }
|
|
217
232
|
const before = JSON.stringify(d), said = []; X.snap();
|
|
@@ -248,6 +263,10 @@ async function turn(t, low) {
|
|
|
248
263
|
const before = d.S ? d.S.log.length : 0;
|
|
249
264
|
const res = await X.P.structure.post('turn', d.id, { text: t });
|
|
250
265
|
if (!res || res.ok !== true) { d.working = false; X.draw(); return 'That did not go through: ' + ((res && res.error) || 'the turn could not start') + '.'; }
|
|
266
|
+
return waitFor(d, before);
|
|
267
|
+
}
|
|
268
|
+
/* Wait for the one structure job of this report, then give PMOS's own words from the log. A run that ended without a version says so. */
|
|
269
|
+
async function waitFor(d, before) {
|
|
251
270
|
const end = Date.now() + 240000;
|
|
252
271
|
for (;;) {
|
|
253
272
|
await new Promise((ok) => setTimeout(ok, 800));
|
|
@@ -256,9 +275,17 @@ async function turn(t, low) {
|
|
|
256
275
|
if (g && g.ok === true && !g.structure.running) {
|
|
257
276
|
d.working = false; d.S = g.structure; X.draw();
|
|
258
277
|
const said = g.structure.log.slice(before).filter((l) => l.who === 'pmos').pop();
|
|
259
|
-
return said ? said.text + (said.n ? ' Shown: S' + said.n + ', not saved yet.' : '') : 'PMOS ended without an answer.';
|
|
278
|
+
return said ? said.text + (said.n ? ' Shown: S' + said.n + ', not saved yet.' : '') : 'PMOS ended without an answer. Say it again, or in other words.';
|
|
260
279
|
}
|
|
261
|
-
if (Date.now() > end) { d.working = false; X.draw(); return 'PMOS has not answered yet. The answer will show
|
|
280
|
+
if (Date.now() > end) { d.working = false; X.draw(); return 'PMOS has not answered yet. The answer will show when you open this report again.'; }
|
|
262
281
|
}
|
|
263
282
|
}
|
|
283
|
+
/* The presses of a set-up report's tabs: the tab switch and the Design step (premium-studio-design.js). */
|
|
284
|
+
export function press(a) {
|
|
285
|
+
const d = r(); if (d.kind !== 'setup') return;
|
|
286
|
+
if (a[0] === 'rtab') { if (a[1] === 'design' || a[1] === 'structure') DES.openTab(d, a[1]); return; }
|
|
287
|
+
if (design(d)) DES.press(d, a);
|
|
288
|
+
}
|
|
289
|
+
export const afterDraw = () => { if (design(r())) DES.afterDraw(); };
|
|
290
|
+
export const addFile = (f) => { const d = r(); if (design(d)) DES.addFile(d, f); };
|
|
264
291
|
export const focusInput = (v) => { const i = $('#stIn'); if (i) { i.value = v; i.focus(); } };
|
|
@@ -211,6 +211,7 @@ function draw(parts) {
|
|
|
211
211
|
if (all || parts.includes('ck')) set('stCk', checksHtml());
|
|
212
212
|
if (all || parts.includes('ft')) set('stFt', footHtml());
|
|
213
213
|
const m = $('#stMsg'); if (m) m.textContent = st.msg;
|
|
214
|
+
if (st.mode === 'rep') REP.afterDraw();
|
|
214
215
|
const l = $('.stu [data-st="lib"]'); if (l) l.setAttribute('aria-expanded', st.lib);
|
|
215
216
|
if (all) { const i = $('#stIn'); if (i) { i.placeholder = 'Say what to change'; i.setAttribute('aria-label', 'Say what to change in the ' + ({ chart: 'chart', rep: 'report' }[st.mode] || 'dashboard')); } const h = $('#stHelp'); if (h) h.textContent = help() + (st.mode === 'rep' ? '' : ' Nothing is saved until you press Save.'); }
|
|
216
217
|
}
|
|
@@ -241,6 +242,7 @@ function act(a) {
|
|
|
241
242
|
if (k === 'del') { if (st.mode === 'chart') removeChart(); else remove(); return; }
|
|
242
243
|
if (k === 'new') { snap(); if (st.mode === 'chart') st.c = chartFrom(st.c && st.c.measure); else if (st.mode === 'rep') { st.r = REP.blankReport(); st.h.rep = []; } else st.d = blank(); st.pop = null; draw(); return; }
|
|
243
244
|
if (st.mode === 'rep') {
|
|
245
|
+
if (k === 'rtab' || /^dz/.test(k)) { REP.press(a); return; }
|
|
244
246
|
if (k === 'set') { if (st.r.kind !== 'new') return; snap(); REP.set(x, y || ''); st.pop = null; draw(); return; }
|
|
245
247
|
if (k === 'rsec') { REP.leaveOut(x); return; }
|
|
246
248
|
if (k === 'say') { REP.focusInput(a.slice(1).join('|')); return; }
|
|
@@ -434,11 +436,15 @@ export function openStudio(p) {
|
|
|
434
436
|
draw();
|
|
435
437
|
}
|
|
436
438
|
REP.useStudio({ get st() { return st; }, get P() { return P; }, chip: (k, l, v) => chip(k, l, v), opt: (...a) => opt(...a), field: (...a) => field(...a), draw: (x) => draw(x), snap: () => snap(),
|
|
439
|
+
replay: (L) => { const el = $('#dBody .stream'); if (!el || !L.length) return; el.insertAdjacentHTML('beforeend', L.map((x) => (x.who === 'u' ? turnU(x.text) : turnA(ptx(x.text)))).join('')); el.scrollTop = el.scrollHeight; },
|
|
440
|
+
say: (text) => { const el = $('#dBody .stream'); if (!el) return; el.insertAdjacentHTML('beforeend', turnA(ptx(text))); el.scrollTop = el.scrollHeight; draw(); },
|
|
441
|
+
restream: (L) => { const el = $('#dBody .stream'); if (!el) return; el.innerHTML = L.map((x) => (x.who === 'u' ? turnU(x.text) : turnA(ptx(x.text)))).join(''); el.scrollTop = el.scrollHeight; },
|
|
437
442
|
done: (msg) => { closeDlg(); toast(msg); P.reportsChanged(); } });
|
|
438
443
|
/* The Studio's presses. The dialog is shared, so each listener first asks whether the Studio is what it holds. */
|
|
439
444
|
const inStudio = (e) => $('#dlg').classList.contains('stud') && $('#dlg').classList.contains('on') && e.target.closest('#oMain');
|
|
440
445
|
document.addEventListener('click', (e) => { if (!inStudio(e)) return; const t = e.target.closest('[data-st]'); if (t && !t.disabled) act(t.dataset.st.split('|')); });
|
|
441
446
|
document.addEventListener('input', (e) => { if (inStudio(e)) onInput(e); });
|
|
447
|
+
document.addEventListener('change', (e) => { if (inStudio(e) && e.target.id === 'dzFile' && e.target.files && e.target.files[0]) REP.addFile(e.target.files[0]); });
|
|
442
448
|
document.addEventListener('focusout', (e) => { if (e.target && e.target.id === 'stI') typed = false; });
|
|
443
449
|
document.addEventListener('keydown', (e) => { if (e.key === 'Enter' && e.target.id === 'stI' && inStudio(e)) { e.preventDefault(); st.pop = null; typed = false; draw(['br', 'tr']); } });
|
|
444
450
|
/* Another dialog of the page opens without the Studio's class. */
|
|
@@ -1796,6 +1796,13 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
1796
1796
|
.phstats b{font-size:var(--t-lead,20px);font-weight:700;color:var(--ink)}
|
|
1797
1797
|
.phstats span{font-size:var(--t-small);color:var(--ink-3)}
|
|
1798
1798
|
}
|
|
1799
|
+
.stsub{grid-column:1/-1;flex:0 0 100%;justify-self:start;margin-bottom:4px}
|
|
1800
|
+
.dzbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin-bottom:10px}
|
|
1801
|
+
.dzth{align-items:flex-start}
|
|
1802
|
+
.dzth button{position:relative;flex:0 0 132px;padding:6px}
|
|
1803
|
+
.dzth .rdfc{border-radius:10px}
|
|
1804
|
+
.dzth i{position:absolute;right:10px;bottom:8px;font:650 10.5px var(--mono);font-style:normal;color:var(--ink-3)}
|
|
1805
|
+
.stlk{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}.stlk .sti{flex:1 1 200px}
|
|
1799
1806
|
/* initiative page: Tasks paging and the about-popup of a document with no file */
|
|
1800
1807
|
.tkpg{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:12px}.tkpg>span{display:flex;align-items:center;gap:10px}.tkpg small{color:var(--ink-2)}
|
|
1801
1808
|
.tkpg .dmcta:disabled{opacity:.45;cursor:default}
|