create-pmos 0.387.0 → 0.389.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.
Files changed (37) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-insights-test.js +16 -21
  7. package/workspace/changelog.json +24 -0
  8. package/workspace/guide/briefing-premium.md +19 -9
  9. package/workspace/lib/briefing-premium-agent.js +3 -0
  10. package/workspace/lib/report-chat.js +37 -0
  11. package/workspace/lib/report-setups.js +49 -7
  12. package/workspace/lib/routes-report-setups.js +38 -7
  13. package/workspace/package-lock.json +2 -2
  14. package/workspace/package.json +1 -1
  15. package/workspace/premium-chat-chart-tab-test.js +150 -0
  16. package/workspace/premium-chat-report-tab-test.js +127 -0
  17. package/workspace/public/pm/goal-chat.js +2 -1
  18. package/workspace/public/pm/premium-chart-draw.js +58 -0
  19. package/workspace/public/pm/premium-chart-tab.js +157 -0
  20. package/workspace/public/pm/premium-chat.js +8 -2
  21. package/workspace/public/pm/premium-insights.js +17 -79
  22. package/workspace/public/pm/premium-report-tab.js +233 -0
  23. package/workspace/public/pm/premium-shell.js +35 -3
  24. package/workspace/public/pm/premium-vw-report.css +60 -0
  25. package/workspace/public/pm/premium.css +1 -120
  26. package/workspace/public/pm/report-chat.js +89 -0
  27. package/workspace/test-lists/premium-chat-chart-tab.json +12 -0
  28. package/workspace/test-lists/premium-chat-report-tab.json +12 -0
  29. package/workspace/premium-studio-chart-test.js +0 -193
  30. package/workspace/premium-studio-report-test.js +0 -277
  31. package/workspace/premium-studio-test.js +0 -185
  32. package/workspace/public/pm/premium-studio-design.js +0 -298
  33. package/workspace/public/pm/premium-studio-report.js +0 -291
  34. package/workspace/public/pm/premium-studio.js +0 -453
  35. package/workspace/test-lists/premium-studio-chart.json +0 -13
  36. package/workspace/test-lists/premium-studio-report.json +0 -9
  37. package/workspace/test-lists/premium-studio.json +0 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.387.0",
3
+ "version": "0.389.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -32,6 +32,30 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.389.0",
37
+ "at": "2026-10-21T22:57:56.719Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 1001,
42
+ "t": "Reports, charts and dashboards from any chat; the Insight Studio is removed",
43
+ "s": "Reports, charts and dashboards from any chat; the Insight Studio is removed"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "v": "0.388.0",
49
+ "at": "2026-10-21T22:35:51.404Z",
50
+ "f": 2,
51
+ "prs": [
52
+ {
53
+ "n": 1000,
54
+ "t": "Report templates reschedule and delete, drafts discard, issued reports stay",
55
+ "s": "Report templates reschedule and delete, drafts discard, issued reports stay"
56
+ }
57
+ ]
58
+ },
35
59
  {
36
60
  "v": "0.387.0",
37
61
  "at": "2026-10-21T15:59:17.829Z",
@@ -277,30 +301,6 @@
277
301
  "s": "The Chat button draws cleanly on the Chat page"
278
302
  }
279
303
  ]
280
- },
281
- {
282
- "v": "0.369.0",
283
- "at": "2026-10-21T02:18:50.229Z",
284
- "f": 2,
285
- "prs": [
286
- {
287
- "n": 974,
288
- "t": "Insights' first screen shows the list, not the empty card (calmer first screen 2/5)",
289
- "s": "Insights' first screen shows the list, not the empty card (calmer first screen 2/5)"
290
- }
291
- ]
292
- },
293
- {
294
- "v": "0.368.0",
295
- "at": "2026-10-21T02:13:10.598Z",
296
- "f": 2,
297
- "prs": [
298
- {
299
- "n": 976,
300
- "t": "The phone conversation gets the screen when it scrolls",
301
- "s": "The phone conversation gets the screen when it scrolls"
302
- }
303
- ]
304
304
  }
305
305
  ]
306
306
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@3b5a77e7
1
+ kernel-source: pmos@63a88212
2
2
  assembled: 2026-10-21
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-21T15:59:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T22:57:53Z"}
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-21T15:59:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T22:57:53Z"}
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-21T15:59:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T22:57:53Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -169,21 +169,16 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
169
169
  await q.click('#repBody [data-d="pd-1"]'); await sleep(200);
170
170
  const sv = await q.evaluate(() => ({ tiles: [...document.querySelectorAll('#dashBody .mch .mlab')].map((e) => e.firstChild.textContent), gone: [...document.querySelectorAll('#dashBody .dplist .nempty')].map((e) => e.textContent.replace(/\s+/g, ' ')), bar: document.querySelector('#dashBar').textContent, purpose: document.querySelector('#dashPurpose').textContent }));
171
171
  ok('R1 a saved dashboard draws its charts in its order and says which chart is gone, in its place', sv.tiles.join() === 'Partner activation,Time to first call' && sv.gone.length === 1 && /krm-gone.*No KR metric record is called krm-gone/.test(sv.gone[0]) && /Monday partner review/.test(sv.purpose) && /Pin.*Back to All measures.*Edit/.test(sv.bar), JSON.stringify(sv));
172
- await (async (pg, sel) => { if (await pg.locator('#dashBar').isHidden()) await pg.click('#dashMore'); await pg.click(sel); })(q, '#pdEdit'); await dlgOn();
173
- const chipv = (k) => q.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
174
- await q.click('#oMain [data-st="chip|charts"]');
175
- const ed = await q.evaluate(() => ({ eye: document.querySelector('#dEye').textContent, rows: [...document.querySelectorAll('#stTr .sul li > span:first-child')].map((b) => b.childNodes[0].textContent) }));
176
- ok('R2 Edit opens the Studio with the name, Main and the charts in order', /^Insight Studio · /.test(ed.eye) && await chipv('name') === 'Weekly partner review' && await chipv('main') === 'Yes' && ed.rows.join() === 'Partner activation,Time to first call,krm-gone', JSON.stringify(ed));
177
- await q.click('#stTr [data-st="mv|1|-1"]'); await q.click('#stTr [data-st="rm|2"]'); await q.click('#oMain [data-st="lib"]'); await q.click('#stLb [data-st="libc|krm-up"]');
178
- await q.click('#oMain [data-st="chip|name"]'); await q.fill('#stI', 'Monday review'); await q.click('#oMain [data-st="save"]'); await sleep(400);
179
- ok('R2 Save posts the dashboard with the new order, name and Main to the one save route', last()[0] === '/api/premium-dashboards/save' && JSON.stringify(last()[1]) === JSON.stringify({ ws: 'w1', board: 'w1', id: 'pd-1', name: 'Monday review', purpose: 'The measures the Monday partner review reads.', charts: ['krm-ttfc', 'krm-act', 'krm-up'], main: true }), JSON.stringify(last()));
180
- await q.click('#listNew'); await q.click('#pdNew'); await dlgOn(); await q.click('#oMain [data-st="save"]'); await sleep(200);
181
- ok('R2 a new dashboard without a name says so and posts nothing', /Give the dashboard a name/.test(await qt('#stMsg')) && last()[1].id === 'pd-1');
182
- answer = () => ({ ok: false, error: '“Weekly partner review” is already a dashboard on this board.' });
183
- await q.click('#oMain [data-st="chip|name"]'); await q.fill('#stI', 'Weekly partner review'); await q.click('#oMain [data-st="chip|use"]'); await q.fill('#stI', 'x'); await q.click('#oMain [data-st="save"]'); await sleep(300);
184
- ok('R7 the server\'s refusal is shown in words and the dialog stays open', /already a dashboard on this board/.test(await qt('#stMsg')) && await q.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !document.querySelector('#oMain [data-st="save"]').disabled));
185
- answer = (u, b) => ({ ok: true, dashboard: { id: b.id || 'pd-9' }, dashboards: [], setup: {}, drafted: { slot: '2026-10-23', path: 'planning/reports/release-readiness/2026-10-23.md' } });
186
- await shut();
172
+ await q.route('**/premium-chat.html*', (r) => r.fulfill({ status: 200, contentType: 'text/html', body: '<!doctype html><title>chat</title>' }));
173
+ await Promise.all([q.waitForURL(/premium-chat\.html/), (async (pg, sel) => { if (await pg.locator('#dashBar').isHidden()) await pg.click('#dashMore'); await pg.click(sel); })(q, '#pdEdit')]);
174
+ const u1 = new URL(q.url());
175
+ ok('R2 Edit opens the Chat page with the saved dashboard in its tab: the Insight Studio is removed', u1.searchParams.get('open') === 'dashboard:pd-1' && u1.searchParams.get('ws') === 'w1', u1.search);
176
+ await q.goBack(); await until(() => q.evaluate(() => !!document.querySelector('#repBody [data-d="pd-1"]')));
177
+ await q.click('#listNew'); await Promise.all([q.waitForURL(/premium-chat\.html/), q.click('#pdNew')]);
178
+ const u2 = new URL(q.url());
179
+ ok('R2 New, then Dashboard, opens the Chat page with a first message for the PM to send, and posts nothing', u2.searchParams.get('say') === 'Make a dashboard of ' && !u2.searchParams.get('open') && !sent.length, u2.search);
180
+ await q.goBack(); await until(() => q.evaluate(() => !!document.querySelector('#repBody [data-d="pd-1"]')));
181
+ await q.click('#repBody [data-d="pd-1"]'); await sleep(200);
187
182
  await (async (pg, sel) => { if (await pg.locator('#dashBar').isHidden()) await pg.click('#dashMore'); await pg.click(sel); })(q, '#pdBack'); await q.locator('#dashBody .lk[data-open="ins:krm-up"]').click(); await dlgOn(); await q.click('#oMain [data-pdsw="pd-1"]'); await sleep(300);
188
183
  ok('R3 the chart dialog\'s switch saves that dashboard with the chart added', last()[0] === '/api/premium-dashboards/save' && JSON.stringify(last()[1].charts) === JSON.stringify(['krm-act', 'krm-ttfc', 'krm-gone', 'krm-up']) && /Added to Weekly partner review/.test(await qt('#pdSwM')), JSON.stringify(last()));
189
184
  await shut();
@@ -214,7 +209,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
214
209
  await shut();
215
210
  await q.click('#repBody [data-setup="partner-update"]'); await dlgOn();
216
211
  const su = await q.evaluate(() => ({ kv: document.querySelector('#oMain .kv2').textContent, acts: [...document.querySelectorAll('#oMain [data-rx]')].map((b) => b.dataset.rx).join() }));
217
- ok('R4 a set-up report shows its schedule and next draft, with Draft it now, Pause and Shape it in the Studio', /ScheduleEvery other Monday at 09:00/.test(su.kv) && /Next draft26 Oct/.test(su.kv) && su.acts === 'draft,pause,studio', JSON.stringify(su));
212
+ ok('R4 a set-up report shows its schedule and next draft, with Draft it now, Pause and Shape it in a chat', /ScheduleEvery other Monday at 09:00/.test(su.kv) && /Next draft26 Oct/.test(su.kv) && su.acts === 'draft,pause,studio', JSON.stringify(su));
218
213
  await q.click('#oMain [data-rx="pause"]'); await sleep(300);
219
214
  ok('R4 Pause posts that report', last()[0] === '/api/report-setups/pause' && last()[1].id === 'partner-update', JSON.stringify(last()));
220
215
  ok('R7 every press went to the dashboard save route or an existing report-setups route; an opened popup is only recorded (seen)', R.posts.every((x) => /^POST \/api\/(premium-dashboards\/save|report-setups\/(ask|change|cancel|setup|dismiss|pause|resume|draft)|briefing-premium\/seen)$/.test(x)), R.posts.join());
@@ -297,13 +292,13 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
297
292
  await pg.goto(base2 + '/premium-insights.html');
298
293
  ok('E7 the real page draws that chart with the record\'s numbers and no script error', await until(() => pg.evaluate(() => { const t = document.querySelector('#dashBody .mch'); return !!t && t.querySelector('.mval').textContent === '30%' && /Partner activation/.test(t.textContent); }), 20000) && errs.length === 0, errs.join(' | '));
299
294
  /* briefing-premium-reports against the real server: New dashboard, Save, the switch, then the ledger answers it back */
300
- await pg.click('#listNew'); await pg.click('#pdNew'); await until(() => pg.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
301
- await pg.click('#oMain [data-st="chip|name"]'); await pg.fill('#stI', 'Partner review'); await pg.click('#oMain [data-st="chip|use"]'); await pg.fill('#stI', 'The Monday partner review.');
302
- await pg.click('#stLb [data-st="libc|' + m.charts[0].id + '"]'); await pg.click('#oMain [data-st="chip|main"]'); await pg.click('#stTr [data-st="set|main|1"]'); await pg.click('#oMain [data-st="save"]');
303
- ok('E8 a dashboard made on the real page as the main one is saved, pinned and drawn at the top', await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && document.querySelector('#hDash').textContent === 'Partner review' && document.querySelector('#dashTag').textContent === 'Pinned' && document.querySelectorAll('#dashBody .mch').length === 1), 10000), await pg.evaluate(() => (document.querySelector('#pdM') || {}).textContent + ' / ' + document.querySelector('#hDash').textContent + ' ' + document.querySelector('#dashTag').textContent));
295
+ const H = await T.pressHeaders(base2);
296
+ const made = await fetch(base2 + '/api/premium-dashboards/save', { method: 'POST', headers: H, body: JSON.stringify({ ws: m.board.ws, board: m.board.id, name: 'Partner review', purpose: 'The Monday partner review.', charts: [m.charts[0].id], main: true }) }).then((x) => x.status);
297
+ await pg.reload();
298
+ ok('E8 a dashboard saved as the main one (a press in the Chart tab) is pinned and drawn at the top of the real page', made === 200 && await until(() => pg.evaluate(() => document.querySelector('#hDash').textContent === 'Partner review' && document.querySelector('#dashTag').textContent === 'Pinned' && document.querySelectorAll('#dashBody .mch').length === 1), 10000), await pg.evaluate(() => (document.querySelector('#pdM') || {}).textContent + ' / ' + document.querySelector('#hDash').textContent + ' ' + document.querySelector('#dashTag').textContent));
304
299
  const j2 = await (await fetch(base2 + '/api/insights-premium')).json(), d2 = j2.model.dashboards.find((d) => d.saved);
305
300
  ok('E8 the model reads it back from the ledger', !!d2 && d2.name === 'Partner review' && d2.main && d2.charts.join() === m.charts[0].id, JSON.stringify(d2));
306
- const H = await T.pressHeaders(base2), body = JSON.stringify({ ws: m.board.ws, board: m.board.id, name: 'From an agent', purpose: 'x', charts: [] });
301
+ const body = JSON.stringify({ ws: m.board.ws, board: m.board.id, name: 'From an agent', purpose: 'x', charts: [] });
307
302
  const asAgent = await fetch(base2 + '/api/premium-dashboards/save', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body }).then((x) => x.status);
308
303
  const noNonce = await fetch(base2 + '/api/premium-dashboards/save', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: base2 }, body }).then((x) => x.status);
309
304
  const unknown = await fetch(base2 + '/api/premium-dashboards/save', { method: 'POST', headers: H, body: JSON.stringify({ ws: m.board.ws, board: m.board.id, name: 'Other', purpose: 'x', charts: ['krm-none'] }) }).then((x) => x.status);
@@ -1,4 +1,28 @@
1
1
  [
2
+ {
3
+ "v": "0.389.0",
4
+ "at": "2026-10-21T22:57:56.719Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1001,
9
+ "t": "Reports, charts and dashboards from any chat; the Insight Studio is removed",
10
+ "s": "Reports, charts and dashboards from any chat; the Insight Studio is removed"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "v": "0.388.0",
16
+ "at": "2026-10-21T22:35:51.404Z",
17
+ "f": 2,
18
+ "prs": [
19
+ {
20
+ "n": 1000,
21
+ "t": "Report templates reschedule and delete, drafts discard, issued reports stay",
22
+ "s": "Report templates reschedule and delete, drafts discard, issued reports stay"
23
+ }
24
+ ]
25
+ },
2
26
  {
3
27
  "v": "0.387.0",
4
28
  "at": "2026-10-21T15:59:17.829Z",
@@ -359,15 +359,7 @@ Insights is the fifth place on the rail, at `/premium-insights.html`. It reads t
359
359
  - **The insight.** The page opens with one finding across the board's measures, in a large line, with the reason and its numbers under it, up to two more findings, **Ask PMOS why** (opens the measure's dialog on the Conversation tab) and **See the chart**. A measure that is short of its target, with a target date after its last reading, gets a projection: a straight line through its last four readings (all, when fewer), carried to the target date. When the line lands short, the finding says the measure will miss its target on that date at this pace, where it lands, how far short, and when it would get there. When the line lands on or past the target, it says the measure is on course. The page says how the projection is made, and no forecast line is drawn on a chart. With no KR metric, or none with two readings, the page says there is no insight yet and why.
360
360
  - **The pinned dashboard.** The card under the insight shows the pinned dashboard: its insight band (the next findings on it, past the one the page leads with), and its charts. Its **⋯** holds **Unpin** (or **Pin**, with Not pinned when nothing is pinned), **Back to** the pinned one, **Edit** and **New chart**, and its **ⓘ** says what the dashboard is for. When nothing can be charted yet, the card is hidden and All measures is a row of the list; the insight's explanation is then behind the **ⓘ** next to Insight. Pressing a dashboard in the list shows it in this card. One dashboard per board is pinned, All measures included; pillar groups cannot be pinned. The pin is a line in `premium-dashboards.jsonl` and shows on Insights only.
361
361
  - **Dashboards and reports.** One list holds the dashboards (All measures, your saved ones, then the pillars the metrics name) and then the reports (your set-up reports, then the report files). One chip in the card's head (**All** with its count) opens **All**, **Dashboards** and **Reports**, and shows only when the list holds both kinds; it shows six rows to a page, with page numbers. A dashboard row shows its top finding and a pin. A report row quotes the opening sentence of its latest file; a set-up report with no file says no draft is written yet. **New** offers **Dashboard** or **Report**. Your requests and what PMOS found in your work stay at the top of the list. A saved dashboard draws its charts in the order you saved them. A chart whose record is gone, or that has fewer than two readings, is listed in its place with the reason and is not drawn.
362
- - **Open the Studio.** **New**, then **Dashboard**, opens the Insight Studio on a new dashboard, and **Edit** in the dashboard's **⋯** opens it on the saved dashboard you are looking at. Chat in the rail opens the Chat page, not the Studio.
363
- - **Make or edit a dashboard.** **+** (at the left of the report input), then **Dashboard**, or **Edit** on a saved one, opens the **Insight Studio**, a wide dialog. On the right, the brief shows the Name, Purpose, Charts and Main dashboard; press a chip to change it. **Library** lists the board's measures and saved dashboards to add. The preview draws the dashboard as the page will, and lists a measure with no series as not drawn. The checks (a name, a purpose, a chart, six or fewer, no repeat, a main dashboard on the board) say what fails, with a one-press fix. On the left you can say it instead: "add Partner activation", "remove …", "move … first", "call it …", "it is for …", "make it the main dashboard", "undo" or "start a new one". A turn changes the draft only. **Undo** steps back one change. **Save the dashboard** records it; **Remove the dashboard** asks once more and then removes it. In a chart's dialog, **On your dashboards** has a switch for each saved dashboard, which adds the chart to it or takes it off.
364
- - **Make your own chart.** **New chart**, or **Edit** on one of your charts, opens the Insight Studio in **Chart** mode; the switch at the top moves between Chart and Dashboard, and each keeps its own draft. The brief shows the Question, Measure, Form (line, bars, number or meter), Range (all readings or the last few) and Target; **More** adds the Title, Better when, Note and Add to (a dashboard). The Studio suggests a form from the question and says why. The checks (a question, a target, enough readings, a form that fits the question, one scale) say what fails, with a one-press fix. You can say it instead: "show it as bars", "last 4 readings", "target 35", "lower is better", "call it …", "note: …", "add it to Weekly", or a question. A pie is declined, with the reason. **Save the chart** records it in the workspace's state folder, and adds it to the dashboard you named. Your charts are listed under **All measures**, and a dashboard can hold them beside the measures. **Remove the chart** asks once more; a dashboard that held it then says it was removed.
365
- - **Set up a report in the Studio.** **+**, then **Report**, 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.
366
- - **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.
367
- - **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.
368
- - **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.
369
- - **Choose a deck or a document, and read the design brief.** On the Design tab, the **Format** chip offers **Deck** and **Document** for the next version. Versions you already made keep their form. Once a design is saved, a **Design brief** chip shows what PMOS reads each cycle: your description, your samples, the reference version, and what stays the same, what changes and what PMOS learned. The cycles drafted to match it are checked on the report itself.
370
- - **Point, make the next version, compare.** On the Design tab, click any part of a slide to attach a request to that spot: a numbered pin appears, and you type the request under the preview (**Point and say**; the switch turns pointing off). **Make the next version** sends the typed line and every pinned request to PMOS, which makes the next version; the pins are cleared once it starts. **Compare two** shows the same slide of two versions side by side; pick the version on each side.
362
+ - **Make or change a dashboard, a chart or a report in a chat.** There is no Insight Studio. **+**, then **Dashboard** or **Report**, and **New chart** in the dashboard's **⋯**, open the Chat page with a first line in the message box ("Make a dashboard of ") for you to finish and send. **Edit** on a saved dashboard or one of your charts, and **Shape it in a chat** on a report drawn from your work, open the Chat page with it in its tab beside the conversation. See [Reports from a chat](#reports-from-a-chat).
371
363
  - **The findings.** Each finding is one sentence with its reason, taken from the series: will miss its target at this pace, on course, 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. No cause is given.
372
364
  - **Board measures.** The same four tiles as the Board's Metrics card, counted from the board's repository and drawn the same way. Choose **8 weeks**, **26 weeks** or **52 weeks**; the page keeps your choice. Press a measure to read its definition and values and to set its target: type a number and press **Save target**, or press **Clear target**. For Corrections, Blocked and Idle, lower is better, so the target is the most you accept; for Merged a week it is the least. The target goes to the workspace's state folder (`board-metric-targets.jsonl`) and the Board draws it too. An agent session cannot set one.
373
365
  - **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
@@ -445,6 +437,24 @@ Every popup has this chat, including the ones that have no row of their own: a t
445
437
 
446
438
  Sending and the option presses need the page's launch nonce, so an agent session cannot type into your chat.
447
439
 
440
+ ### Reports from a chat
441
+
442
+ Any chat can become a report. There is no button for it: say it in the chat, for example "make this a report for the growth leads" or "make it weekly on Wednesdays". Claude answers in a few lines, and the **Report** tab opens beside the conversation (on a phone, a bar over the message box offers it). The chip under Claude's answer opens the tab again.
443
+
444
+ - **A new report** shows its name, what it answers, who reads it, its format and the seven sections every new report has. **Set it up** records it and writes its first draft. If you did not say a schedule, its **Schedule** is **Off**: it runs once, and you can give it a schedule later.
445
+ - **Schedule** is a chip on the tab. Press it to pick **Off**, **Daily**, **Weekly**, **Every two weeks** or **Monthly**, and a day for a weekly one. Or say it in the chat; Claude's proposal shows with **Change the schedule**. Off pauses the template and keeps its schedule for later.
446
+ - **Structure** and **Design** show the report's versions (S1, S2, … and D1, D2, …). Say a change in the chat ("leave out the timeline", "use the theme of my sample"); the tab shows it with **Make the next version**. **Use this** or **This is it** saves the version shown, and **Undo** goes back one.
447
+ - **Reports** lists the template's cycles. A **draft** can be discarded until it is issued. An **issued** report is kept for good: it can be archived (hidden) and brought back, never deleted.
448
+ - **Delete template** stops its schedule now. Its issued reports and its open draft stay, with its name.
449
+
450
+ Charts and dashboards work the same way. Say "chart partner activation as bars" or "make a dashboard for the Monday partner review", and the **Chart** or **Dashboard** tab opens beside the conversation.
451
+
452
+ - **A chart** is drawn from the readings of one KR metric record, as Insights draws it. **Line**, **Bars**, **Number** and **Meter** redraw it; a meter needs a target. **Save chart** saves it, and it shows on Insights under Your charts. A saved chart has **Delete chart**, which asks first.
453
+ - **A dashboard** draws its charts in order and names any measure with fewer than two readings. **Save dashboard** saves it to the list on Insights, where you pin it. A saved dashboard has **Delete dashboard**, which asks first. Its charts and records stay.
454
+ - To change a saved one, ask in the chat; the tab shows the change with **Save the change**.
455
+
456
+ Claude never sets up, schedules or deletes a report, a chart or a dashboard itself. Every change is a press on the tab, and the routes refuse an agent session.
457
+
448
458
  ### Notes
449
459
 
450
460
  Notes is a notepad for each conversation. Open it from **+** › **Notes**. It opens in the viewer beside the conversation. On a phone, it opens on the viewer tab.
@@ -15,6 +15,7 @@ const path = require('path');
15
15
  const crypto = require('crypto');
16
16
  const headless = require('./headless.js');
17
17
  const Goal = require('./goal-chat.js');
18
+ const ReportChat = require('./report-chat.js');
18
19
 
19
20
  const THREADS = 'briefing-premium-threads.jsonl';
20
21
  const KEY_RE = /^(decision|blocked|waited|src|ev|work|board|init|doc|ins|chat|pop):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/; // chat: the PM's own chat on the Chat page (premium-chat-page); pop: a popup with no row of its own (premium-popup-context P1)
@@ -193,6 +194,8 @@ function chat({ runtimeDir, key, text, model, context, sessions, wsId, now = new
193
194
  let msg = q, goal = null;
194
195
  const cmd = Goal.parseCommand(q);
195
196
  if (cmd) { const b = Goal.begin({ runtimeDir, key, text: cmd.text, now }); if (b.error) return fail(400, b.error); msg = b.prompt; goal = b.id; }
197
+ // premium-reports-from-chat R1: a message about a report, a chart or a dashboard carries the pmos-report rule (lib/report-chat.js)
198
+ else if (ReportChat.isAsk(q)) msg = ReportChat.wrap(q);
196
199
  const extra = goal ? { goal } : {};
197
200
  if (alive) {
198
201
  if (!sessions.type(live, msg)) return fail(409, 'The message did not reach the session. Open it in Sessions.');
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+ /* report-chat — reports, charts and dashboards from any chat (initiative premium-reports-from-chat, slices B and C; PRD R1–R4, C1–C3).
3
+ * There is no button: the PM says "make this a report" in the chat. When a message asks for a report, a chart or a dashboard, the chat route
4
+ * types it into the session with a PMOS rule first. The rule asks Claude to end its answer with one fenced `pmos-report` JSON block. The page
5
+ * (public/pm/report-chat.js) splits that block off and shows it in the Report or Chart tab beside the conversation.
6
+ * Claude never sets up, schedules, changes or deletes a report, a chart or a dashboard itself. Every write is the PM's press in the tab, through the
7
+ * report-setups, report-structure, report-design, premium-charts and premium-dashboards routes, which refuse an agent session (D65: propose-only). */
8
+
9
+ // The first line of every message PMOS wraps. The page reads it to show the PM's turn as typed (public/pm/goal-chat.js shownUser).
10
+ const MARK = '[PMOS report]';
11
+ const SAYS = 'The PM says: ';
12
+ // A message about a report, a chart or a dashboard. Other messages go to the session as typed.
13
+ const ASK_RE = /\b(reports?|charts?|graphs?|dashboards?)\b/i;
14
+
15
+ const isAsk = (text) => ASK_RE.test(String(text == null ? '' : text)) && !String(text).trim().startsWith('/');
16
+
17
+ const RULE = [
18
+ 'If the PM asks for a report, a chart or a dashboard, or asks to change, schedule or stop one, do the reading yourself and answer in a few lines.',
19
+ 'Then end your message with ONE fenced code block with the language tag pmos-report, holding one JSON object. The page shows it in a Report or Chart tab beside this chat.',
20
+ 'You never set up, schedule, change or delete a report yourself, and you never write report-setups.jsonl: the PM presses in the tab.',
21
+ '- A new report: {"kind":"report","proposal":{"name":"short name","purpose":"what it answers, one line","audience":"who reads it","output":"google-doc|google-slides|google-sheets|confluence|pdf","schedule":null,"sources":["what it draws from"]}}',
22
+ ' schedule stays null unless the PM named one; then it is {"cadence":"daily|weekly|bi-weekly|monthly","day":"Mon","dayOfMonth":1,"time":"09:00"}. A report with no schedule runs once.',
23
+ '- A report that is set up already: {"kind":"report","id":"<its id>"} and, only when the PM asked for it, "schedule": {…} or "off", "structure": "the change to its sections, in the PM\'s words", "design": "the change to its look, in the PM\'s words".',
24
+ ' The set-up reports are the setup lines of report-setups.jsonl (planning/ or pmos/state/); a later change line wins, a remove line deletes one.',
25
+ '- A chart of one measure: {"kind":"chart","proposal":{"measure":"<KR metric id>","title":"short title","question":"what it answers","form":"line|bars|number|meter","range":null,"target":null,"better":"higher|lower","note":""}}',
26
+ ' measure is the id of a KR metric record (planning/records/kr-metrics.jsonl). range is how many of the latest readings to draw, or null for all. A meter needs a target.',
27
+ ' To change a saved chart, add its "id" (pc-…, from premium-charts.jsonl in the state folder) and put the whole changed chart in proposal; {"kind":"chart","id":"pc-…"} alone opens it.',
28
+ '- A dashboard: {"kind":"dashboard","proposal":{"name":"short name","purpose":"the routine it serves","charts":["KR metric ids or saved chart ids, in order"]}}. Six charts or fewer serve one routine.',
29
+ ' To change a saved dashboard, add its "id" (from premium-dashboards.jsonl in the state folder); {"kind":"dashboard","id":"…"} alone opens it.',
30
+ ' You never save, change or delete a chart or a dashboard yourself either: the PM presses Save in the Chart tab.',
31
+ 'If the message is not about a report, a chart or a dashboard, answer it and add no block.',
32
+ ].join('\n');
33
+
34
+ /** The message as PMOS types it into the session: the rule, then the PM's words. */
35
+ function wrap(text) { return MARK + ' ' + RULE + '\n\n' + SAYS + String(text == null ? '' : text); }
36
+
37
+ module.exports = { MARK, isAsk, wrap, RULE };
@@ -12,6 +12,8 @@
12
12
  * firstSlot(schedule, now) · initialLastRun(schedule, now) · nextDraftAt(schedule, lastRun, now) the bi-weekly parity (below)
13
13
  * definitionText(setup, { product, now }) · writeDefinition(root, setup, { now }) the definition a setup writes
14
14
  * setUp(root, input, opts) · change(root, id, patch, opts) · pause / resume / remove(root, id, opts) the PM's presses
15
+ * reschedule(root, id, schedule, opts) a template's new schedule; { cadence: 'off' } pauses it, any other resumes a paused one
16
+ * discardDraft(root, rel, opts) · archiveDoc(root, rel, archived, opts) a document's presses. AN ISSUED REPORT IS NEVER DELETED: discard refuses it
15
17
  * scheduleFor(setup) · registerSchedule(store, setup, opts) · unregisterSchedule(store, setup) the draft-only schedule
16
18
  * askStart / askChange / askCancel / askEnd / fileProposal(file, …) the Ask box
17
19
  * fileFinding / dismissFinding / setFinder / findStart / findEnd the weekly finder
@@ -23,7 +25,9 @@
23
25
  * setup { id, name, purpose, audience, source: 'work'|'dashboard:<key>', output, schedule, sources[], sections[], learned_from, fixes[],
24
26
  * product, ws, last_run, def_sha, from? } the PM pressed Set up. `from` is { ask } or { finding }
25
27
  * change { id, …the fields that changed } the PM edited a recurring report
26
- * pause · resume · remove { id }
28
+ * pause · resume · remove { id } a removed setup is a deleted TEMPLATE: its schedule stops, its documents stay
29
+ * doc-discard { doc, path } the PM discarded an unissued draft (the file is deleted; this line keeps the record)
30
+ * doc-archive { doc, archived } the PM archived (true) or brought back (false) an issued report. The file is never touched
27
31
  * drafted { id, slot, path } a dashboard-sourced setup made its document (this is its last run)
28
32
  * ask-start { ask, text, ws } the PM typed a request in the Ask box
29
33
  * proposal { ask, proposal } the report-setup run filed ONE proposal (a second one revises it)
@@ -36,8 +40,8 @@
36
40
  * finder { cadence?, sources? } the finder settings: weekly | off, and the four sources
37
41
  * migrated { keys[], count } the one-time move of the dashboard schedules
38
42
  *
39
- * FOLD. { setups: Map id → setup, asks: Map, findings: Map, dismissed: { patterns, names }, finder: { cadence, sources }, finds: [], migrated }.
40
- * A later line wins field by field; a `remove` drops the setup; a line that does not parse, or names an unknown event, is skipped.
43
+ * FOLD. { setups: Map id → setup, removed: Map id → setup (deleted templates), archived: Set of doc ids, discarded: [{ doc, path, at }], asks: Map, findings: Map, dismissed: { patterns, names }, finder: { cadence, sources }, finds: [], migrated }.
44
+ * A later line wins field by field; a `remove` moves the setup to `removed` (its name stays on its documents); a line that does not parse, or names an unknown event, is skipped.
41
45
  *
42
46
  * THE BI-WEEKLY PARITY. lib/schedule-logic.js fires a bi-weekly schedule on the first matching weekday slot that is at least 12.5 days after
43
47
  * lastRun. A schedule added on a Monday would therefore draft on the Wednesday two weeks out, whatever week the session is in. With an
@@ -56,7 +60,7 @@ const docSync = require('./doc-sync.js');
56
60
 
57
61
  const LEDGER = 'report-setups.jsonl';
58
62
  const EVENTS = Object.freeze(['setup', 'change', 'pause', 'resume', 'remove', 'drafted', 'ask-start', 'proposal', 'proposal-change', 'proposal-cancel', 'ask-end',
59
- 'find-start', 'find-end', 'finding', 'finding-dismiss', 'finder', 'migrated']);
63
+ 'find-start', 'find-end', 'finding', 'finding-dismiss', 'finder', 'migrated', 'doc-discard', 'doc-archive']);
60
64
  const OUTPUTS = Object.freeze(['google-slides', 'google-doc', 'google-sheets', 'confluence', 'pdf']);
61
65
  const CADENCES = Object.freeze(['daily', 'weekly', 'bi-weekly', 'monthly']);
62
66
  const DAYS = Object.freeze(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']);
@@ -210,7 +214,7 @@ function checkEvidence(list) {
210
214
  const SETUP_FIELDS = ['name', 'purpose', 'audience', 'output', 'schedule', 'sources', 'sections', 'learned_from', 'fixes', 'product', 'def_sha'];
211
215
 
212
216
  function fold(lines) {
213
- const st = { setups: new Map(), asks: new Map(), findings: new Map(), dismissed: { patterns: new Set(), names: new Set() },
217
+ const st = { setups: new Map(), removed: new Map(), archived: new Set(), discarded: [], asks: new Map(), findings: new Map(), dismissed: { patterns: new Set(), names: new Set() },
214
218
  finder: { cadence: 'weekly', sources: { ...FINDER_DEFAULTS } }, finds: [], migrated: null };
215
219
  for (const l of lines || []) {
216
220
  if (!isObj(l)) continue;
@@ -232,7 +236,9 @@ function fold(lines) {
232
236
  }
233
237
  case 'pause': { const s = st.setups.get(l.id); if (s) s.status = 'paused'; break; }
234
238
  case 'resume': { const s = st.setups.get(l.id); if (s) { s.status = 'active'; if (l.last_run) s.last_run = l.last_run; } break; }
235
- case 'remove': st.setups.delete(l.id); break;
239
+ case 'remove': { const s = st.setups.get(l.id); if (s) { st.removed.set(l.id, { ...s, status: 'removed', removed_at: l.at }); st.setups.delete(l.id); } break; }
240
+ case 'doc-discard': if (typeof l.doc === 'string') { st.discarded.push({ doc: l.doc, path: l.path || null, at: l.at }); st.archived.delete(l.doc); } break;
241
+ case 'doc-archive': if (typeof l.doc === 'string') { if (l.archived === false) st.archived.delete(l.doc); else st.archived.add(l.doc); } break;
236
242
  case 'drafted': { const s = st.setups.get(l.id); if (s) { s.last_run = l.at; s.drafted.push({ slot: l.slot, at: l.at, path: l.path || null }); } break; }
237
243
  case 'ask-start':
238
244
  if (ASK_RE.test(String(l.ask || ''))) st.asks.set(l.ask, { id: l.ask, text: l.text, ws: l.ws || null, state: 'running', changed: false, proposal: null, error: null, started: l.at, changes: [] });
@@ -560,6 +566,42 @@ function remove(root, id, opts = {}) {
560
566
  return { ok: true };
561
567
  }
562
568
 
569
+ /** A template's schedule, as the PM changes it. { cadence: 'off' } is Schedule Off: the template pauses and keeps its schedule for later.
570
+ * Any other schedule is checked, changed through change(), and resumes a paused template. → { ok, setup } | { ok: false, status, error } */
571
+ function reschedule(root, id, schedule, opts = {}) {
572
+ if (isObj(schedule) && schedule.cadence === 'off') return setStatus(root, id, 'pause', opts);
573
+ const c = checkSchedule(schedule);
574
+ if (!c.ok) return refuse(400, c.error);
575
+ const r = change(root, id, { schedule: c.schedule }, opts);
576
+ if (!r.ok) return r;
577
+ return r.setup && r.setup.status === 'paused' ? setStatus(root, id, 'resume', opts) : r;
578
+ }
579
+
580
+ /** The report document at `rel` (repository-relative), as report-needs lists it, else null. */
581
+ function documentAt(root, rel) {
582
+ const list = require('./report-needs.js').reportsOf(root).reports || [];
583
+ return list.find((x) => x.path === String(rel || '')) || null;
584
+ }
585
+
586
+ /** Discard an unissued draft: the file is deleted and a doc-discard line keeps the record. An issued report is refused (409) and not touched. */
587
+ function discardDraft(root, rel, opts = {}) {
588
+ const d = documentAt(root, rel);
589
+ if (!d) return refuse(404, 'no such report document');
590
+ if (d.issued) return refuse(409, 'this report was issued, so it is kept for good. You can archive it instead');
591
+ try { fs.rmSync(path.join(path.resolve(String(root)), d.path)); } catch (e) { return refuse(500, 'the draft was not deleted: ' + String((e && e.message) || e).slice(0, 160)); }
592
+ append(ledgerFile(root), { ev: 'doc-discard', doc: `${d.cadence}/${d.slot}`, path: d.path }, { now: opts.now, by: opts.by });
593
+ return { ok: true, doc: `${d.cadence}/${d.slot}` };
594
+ }
595
+
596
+ /** Archive (archived true) or bring back (false) an issued report. Only a line is written; the file is never touched. A draft is refused (409). */
597
+ function archiveDoc(root, rel, archived, opts = {}) {
598
+ const d = documentAt(root, rel);
599
+ if (!d) return refuse(404, 'no such report document');
600
+ if (!d.issued) return refuse(409, 'only an issued report is archived. Discard a draft instead');
601
+ append(ledgerFile(root), { ev: 'doc-archive', doc: `${d.cadence}/${d.slot}`, archived: archived !== false }, { now: opts.now, by: opts.by });
602
+ return { ok: true, doc: `${d.cadence}/${d.slot}`, archived: archived !== false };
603
+ }
604
+
563
605
  // ── the Ask box ──────────────────────────────────────────────────────────────────────────────────────
564
606
  function askStart(file, { text, ws, by, now }) {
565
607
  if (!oneLine(String(text || '').replace(/\s+/g, ' '), LIMITS.text)) return refuse(400, `say what report you want, in up to ${LIMITS.text} characters`);
@@ -760,6 +802,6 @@ module.exports = {
760
802
  ledgerFile, stateDir, append, readLines, fold, stateOf, openFindings, isDismissed, slugOf, patternOf, checkProposal, checkEvidence, checkSchedule,
761
803
  scheduleLabel, scheduleOf, firstSlot, initialLastRun, nextDraftAt, definitionText, writeDefinition, definitionsOf, definitionFile, shaOf,
762
804
  fileScheduleStore, scheduleFor, registerSchedule, updateSchedule, unregisterSchedule,
763
- setUp, change, pause, resume, remove, askStart, askChange, askCancel, askEnd, fileProposal, findStart, findEnd, fileFinding, dismissFinding, lookupFinding, setFinder,
805
+ setUp, change, pause, resume, remove, reschedule, discardDraft, archiveDoc, documentAt, askStart, askChange, askCancel, askEnd, fileProposal, findStart, findEnd, fileFinding, dismissFinding, lookupFinding, setFinder,
764
806
  writeDocument, frameMarkdown, migrate, migratedKeys, dashboardKeys, dashTitle, keyOfSource, longDate, localDay,
765
807
  };
@@ -14,9 +14,14 @@
14
14
  * POST /api/report-setups/draft { ws, id } → { ok, drafted: { slot, path }, id } Draft it now (the next cycle)
15
15
  * POST /api/report-setups/dismiss { ws, finding } → { ok } "Not a report"
16
16
  * POST /api/report-setups/pause | resume { ws, id } → { ok, setup }
17
+ * POST /api/report-setups/edit { ws, id, schedule?, name?, audience?, output? } → { ok, setup } change a TEMPLATE (premium-reports-from-chat L1).
18
+ * schedule { cadence: 'off' } pauses it; any other schedule changes it and resumes it
19
+ * POST /api/report-setups/remove { ws, id } → { ok } delete a TEMPLATE: its schedule stops; its drafts and issued reports stay (L2)
17
20
  * POST /api/report-setups/from-dashboard { ws, key, name, output, schedule, audience } → { ok, setup }
18
21
  * POST /api/report-setups/finder { ws, cadence?, sources? } → { ok, finder }
19
22
  * GET /api/report-documents?ws → { docs: [{ path, id, setup, name, slot, state: draft|issued, source, output, made_by: schedule|you|agent, v, copy }] }
23
+ * POST /api/report-documents/discard { ws, path } → { ok, doc } delete an UNISSUED draft; an issued report is 409 and untouched (L3)
24
+ * POST /api/report-documents/archive { ws, path, archived } → { ok, doc, archived } hide (or bring back) an ISSUED report; a draft is 409 (L4)
20
25
  * GET /api/report-export?ws&path&fmt=pptx|xlsx|docx|csv → the file, Content-Disposition: attachment. PDF is printed by the browser: there is no route.
21
26
  *
22
27
  * WHO SETS A REPORT UP. Only a PM press does. Every POST passes pm-guard requirePagePress, and a request that carries an agent session header is
@@ -25,7 +30,8 @@
25
30
  * those runs do, sends anything outward (D65: the factory is propose-only).
26
31
  *
27
32
  * A DOCUMENT is any <state>/reports/<cadence>/<slot>.md, one-offs included, joined to issues.jsonl. Its `id` is "<cadence>/<slot>"; `setup` is the
28
- * recurring report that made it (the cadence folder is the setup id), or null for a one-off. `made_by` reads the file's own `made_by` line; with
33
+ * recurring report that made it (the cadence folder is the setup id), or null for a one-off or a deleted template (then `template_deleted` is true and
34
+ * `name` is still the template's). `archived` is true for an issued report the PM archived. AN ISSUED REPORT IS NEVER DELETED: no route removes one. `made_by` reads the file's own `made_by` line; with
29
35
  * none, a setup's folder says "schedule" and a one-off says "you". `v` is 1 plus the saves the document sheet kept for the file. `copy` is the linked
30
36
  * copy's state from lib/doc-sync-store.js (kind: the output's copy kind; state: none | in-step | pmos-ahead | copy-changed | not-checked).
31
37
  *
@@ -48,7 +54,7 @@ const headless = require('./headless.js');
48
54
 
49
55
  const text = (v) => (typeof v === 'string' ? v : '');
50
56
  const bad = (status, error) => ({ status, body: { ok: false, error } });
51
- const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder'];
57
+ const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder', 'edit', 'remove', 'documents/discard', 'documents/archive'];
52
58
  const MADE_BY = ['schedule', 'you', 'agent'];
53
59
 
54
60
  const runs = new Map(); // ask id → session id, for the report-setup runs this server started
@@ -108,10 +114,11 @@ function documentsOf(ctx, w) {
108
114
  for (const x of r.reports) {
109
115
  const fm = RN.frontmatter(path.join(abs, x.path));
110
116
  const setup = st.setups.get(x.cadence) || null;
111
- const output = fm.output || (setup && setup.output) || null;
117
+ const gone = setup ? null : (st.removed.get(x.cadence) || null);
118
+ const output = fm.output || ((setup || gone) && (setup || gone).output) || null;
112
119
  docs.push({
113
- path: x.path, id: `${x.cadence}/${x.slot}`, setup: setup ? setup.id : null,
114
- name: setup ? setup.name : (fm.title || x.cadence), slot: x.slot, state: x.issued ? 'issued' : 'draft',
120
+ path: x.path, id: `${x.cadence}/${x.slot}`, setup: setup ? setup.id : null, template_deleted: !!gone,
121
+ name: setup ? setup.name : gone ? gone.name : (fm.title || x.cadence), slot: x.slot, state: x.issued ? 'issued' : 'draft', archived: !!x.issued && st.archived.has(`${x.cadence}/${x.slot}`),
115
122
  source: fm.source || (setup ? setup.source : 'work'), output,
116
123
  made_by: MADE_BY.includes(fm.made_by) ? fm.made_by : (setup ? 'schedule' : 'you'),
117
124
  v: 1 + (saves.get(x.path) || 0), copy: copyOf(linkFor(idx, x.path, output), docSync.copyKindOf(output)),
@@ -275,9 +282,10 @@ async function handle(req, res, url, ctx) {
275
282
  const send = (r) => { ctx.json(res, r.body, r.status); return true; };
276
283
  const isDocs = p === '/api/report-documents' || p.startsWith('/api/report-documents/');
277
284
  const isExport = p === '/api/report-export' || p.startsWith('/api/report-export/');
278
- const sub = isDocs ? 'documents' : isExport ? 'export' : p.replace(/^\/api\/report-setups\/?/, '');
285
+ const docPost = p === '/api/report-documents/discard' || p === '/api/report-documents/archive';
286
+ const sub = docPost ? p.replace(/^\/api\/report-/, '') : isDocs ? 'documents' : isExport ? 'export' : p.replace(/^\/api\/report-setups\/?/, '');
279
287
 
280
- if (isDocs || isExport || (sub === '' && req.method === 'GET')) {
288
+ if (!docPost && (isDocs || isExport || (sub === '' && req.method === 'GET'))) {
281
289
  if (req.method !== 'GET') return send(bad(405, 'GET only'));
282
290
  if ((isDocs && p !== '/api/report-documents') || (isExport && p !== '/api/report-export')) return send(bad(404, 'no such report route'));
283
291
  const w = wsOf(ctx, url.searchParams.get('ws'));
@@ -397,6 +405,29 @@ async function handle(req, res, url, ctx) {
397
405
  if (!r.ok) return fail(r);
398
406
  return send({ status: 200, body: { ok: true, setup: setupOut(r.setup, new Date(), { reports: [] }, new Map(), root) } });
399
407
  }
408
+ if (sub === 'edit') {
409
+ const id = text(body.id);
410
+ if (!RS.fold(RS.readLines(file)).setups.has(id)) return send(bad(404, 'no such report'));
411
+ let r = null;
412
+ const patch = {};
413
+ for (const k of ['name', 'audience', 'output']) if (typeof body[k] === 'string' && body[k].trim()) patch[k] = body[k].trim();
414
+ if (Object.keys(patch).length) { r = RS.change(root, id, patch, opts); if (!r.ok) return fail(r); }
415
+ if (body.schedule !== undefined) { r = RS.reschedule(root, id, body.schedule, opts); if (!r.ok) return fail(r); }
416
+ if (!r) return send(bad(400, 'say what to change: schedule, name, audience or output'));
417
+ const now = new Date();
418
+ return send({ status: 200, body: { ok: true, setup: setupOut(RS.fold(RS.readLines(file)).setups.get(id), now, documentsOf(ctx, w), copyIndex(root), root) } });
419
+ }
420
+ if (sub === 'remove') {
421
+ const r = RS.remove(root, text(body.id), opts);
422
+ if (!r.ok) return fail(r);
423
+ return send({ status: 200, body: { ok: true } });
424
+ }
425
+ if (sub === 'documents/discard' || sub === 'documents/archive') {
426
+ const r = sub === 'documents/discard' ? RS.discardDraft(root, text(body.path), opts) : RS.archiveDoc(root, text(body.path), body.archived !== false, opts);
427
+ if (!r.ok) return fail(r);
428
+ if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg();
429
+ return send({ status: 200, body: r });
430
+ }
400
431
  if (sub === 'finder') {
401
432
  const r = RS.setFinder(file, { cadence: body.cadence, sources: body.sources, by: g.actor });
402
433
  if (!r.ok) return fail(r);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.387.0",
3
+ "version": "0.389.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.387.0",
9
+ "version": "0.389.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.387.0",
3
+ "version": "0.389.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",