create-pmos 0.479.0 → 0.480.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.479.0",
3
+ "version": "0.480.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,19 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.480.0",
37
+ "at": "2026-11-01T11:08:09.778Z",
38
+ "f": 3,
39
+ "prs": [
40
+ {
41
+ "n": 1139,
42
+ "t": "Set up a custom report from chat in one press (held)",
43
+ "s": "Set up a custom report from chat in one press (held)",
44
+ "k": "fix"
45
+ }
46
+ ]
47
+ },
35
48
  {
36
49
  "v": "0.479.0",
37
50
  "at": "2026-11-01T10:19:06.142Z",
@@ -283,19 +296,6 @@
283
296
  "k": "fix"
284
297
  }
285
298
  ]
286
- },
287
- {
288
- "v": "0.460.0",
289
- "at": "2026-10-31T01:09:44.980Z",
290
- "f": 3,
291
- "prs": [
292
- {
293
- "n": 1112,
294
- "t": "Read a linked worktree's programs as its main tree's",
295
- "s": "Read a linked worktree's programs as its main tree's",
296
- "k": "fix"
297
- }
298
- ]
299
299
  }
300
300
  ]
301
301
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@06948cf0
1
+ kernel-source: pmos@a178e927
2
2
  assembled: 2026-11-01
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-11-01T10:19:03Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-01T11:08: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-11-01T10:19:03Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-01T11:08: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-11-01T10:19:03Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-01T11:08:06Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.480.0",
4
+ "at": "2026-11-01T11:08:09.778Z",
5
+ "f": 3,
6
+ "prs": [
7
+ {
8
+ "n": 1139,
9
+ "t": "Set up a custom report from chat in one press (held)",
10
+ "s": "Set up a custom report from chat in one press (held)",
11
+ "k": "fix"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.479.0",
4
17
  "at": "2026-11-01T10:19:06.142Z",
@@ -457,10 +457,11 @@ Sending and the option presses need the page's launch nonce, so an agent session
457
457
 
458
458
  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.
459
459
 
460
- - **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. If you asked for other contents, or Claude proposed them, **Structure and look** shows that change. The first draft uses the seven sections. Right after **Set it up**, Claude starts the change, and **Use this** keeps the new sections.
460
+ - **A new report** shows its name, what it answers, who reads it, its format and its sections. The chip under Claude's answer says **Set it up in the Report tab**. Press ✓ (**Set it up**) at the top of the tab: that one press records the report 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.
461
+ - **Your own sections.** Name them in the chat, for example "use these sections: Decision question; Current position; Options and recommendation; Open items; Sources". The tab shows them as the slides. ✓ saves them as the report's structure (S1), and the first draft follows them. Your first section is the report's lead, the one before Sources holds the asks to the readers, and Sources is always last. If you describe a change without a list, **Structure and look** shows the change: the first draft uses the seven standard sections, Claude starts the change right after ✓, and **Use this** keeps it.
461
462
  - **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.
462
463
  - **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.
463
- - **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.
464
+ - **Reports** lists the template's cycles. A **draft** can be discarded until it is issued, also while Claude makes a new version. An **issued** report is kept for good: it can be archived (hidden) and brought back, never deleted.
464
465
  - **Delete template** stops its schedule now. Its issued reports and its open draft stay, with its name.
465
466
 
466
467
  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.
@@ -10,7 +10,7 @@
10
10
  const MARK = '[PMOS report]';
11
11
  const SAYS = 'The PM says: ';
12
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;
13
+ const ASK_RE = /\b(reports?|charts?|graphs?|dashboards?|sections)\b/i;
14
14
 
15
15
  const isAsk = (text) => ASK_RE.test(String(text == null ? '' : text)) && !String(text).trim().startsWith('/');
16
16
 
@@ -20,9 +20,12 @@ const RULE = [
20
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
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
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 new report always starts with the standard sections: Headline, Timeline, Initiatives, New since last report, Decided this cycle, Needs your call, Sources. When the PM wants other contents (or you propose them), add "structure": "the sections it should have instead, in plain words" next to "proposal". Once the PM sets it up, the tab starts that change at once and the PM keeps it with one press.',
24
- ' In your words, say what the tab will show: the standard sections, and the change in "structure" if there is one. Never describe contents the block does not carry.',
25
- '- 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".',
23
+ ' A new report starts with the standard sections: Headline, Timeline, Initiatives, New since last report, Decided this cycle, Needs your call, Sources.',
24
+ ' When the PM names the sections (or you propose a list and the PM agrees), add "sections": ["Section title", …] next to "proposal": the titles in order, up to 10, in the PM\'s words. The tab shows them, and setting it up saves them and drafts the first report with them.',
25
+ ' When the PM wants other contents but names no list, add "structure": "the change, in plain words" instead. Once the PM sets it up, the tab starts that change and the PM keeps it with one press.',
26
+ ' The PM sets a new report up with ONE press: the check button (Set it up) at the top of the Report tab. Name it like that. Never say Create, Save or any other button.',
27
+ ' In your words, say what the tab will show: the sections it will have, then the one press. Never describe contents the block does not carry.',
28
+ '- A report that is set up already: {"kind":"report","id":"<its id>"} and, only when the PM asked for it, "schedule": {…} or "off", "sections": ["the new section titles, in order"] or "structure": "the change to its sections, in the PM\'s words", "design": "the change to its look, in the PM\'s words".',
26
29
  ' 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.',
27
30
  '- 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":""}}',
28
31
  ' 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.',
@@ -152,7 +152,7 @@ function readJsonl(file) {
152
152
  */
153
153
  function readDefinition(root, cadence) {
154
154
  const rel = definitionPath(root, cadence);
155
- const out = { path: rel, exists: false, cadence: null, audience: null, product: null, sections: FRAME.slice(), errors: [] };
155
+ const out = { path: rel, exists: false, cadence: null, audience: null, product: null, sections: FRAME.slice(), errors: [], name: null, purpose: null };
156
156
  let text;
157
157
  try { text = fs.readFileSync(path.join(path.resolve(String(root)), rel), 'utf8'); } catch { return out; }
158
158
  out.exists = true;
@@ -174,6 +174,10 @@ function readDefinition(root, cadence) {
174
174
  if (out.cadence !== cadence) out.errors.push(`its cadence is ${JSON.stringify(out.cadence)}, not ${cadence}`);
175
175
  out.audience = isStr(map.audience) && map.audience.trim() ? map.audience.trim() : null;
176
176
  out.product = isStr(map.product) && map.product.trim() ? map.product.trim() : null;
177
+ // the report's name and purpose, for the draft's title and its one-line description (report-setups.js definitionText writes both)
178
+ if (isStr(map.title) && map.title.trim()) out.name = map.title.trim().replace(/\s+definition$/i, '') || null;
179
+ const pur = /\n## Purpose\r?\n\r?\n([^\n]+)/.exec(text.slice(fm[0].length - 1));
180
+ if (pur && pur[1].trim() && !/^#/.test(pur[1])) out.purpose = pur[1].trim().slice(0, 300);
177
181
  if (!out.audience) out.errors.push('it names no audience, so Needs your call stays empty (X23)');
178
182
  if (Array.isArray(map.sections)) {
179
183
  const got = map.sections.map((s) => String(s).trim());
@@ -506,16 +510,20 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
506
510
  // ── the markdown ────────────────────────────────────────────────────────────────────────────────────
507
511
  const esc = (s) => String(s == null ? '' : s).replace(/\|/g, '\\|').replace(/\n/g, ' ');
508
512
 
509
- function render(draft, { notes } = {}) {
513
+ function render(draft, { notes, name: given, purpose } = {}) {
510
514
  if (!draft || draft.ok === false) return '';
511
515
  const n = notes && typeof notes === 'object' ? notes : {};
512
516
  const noteOf = (id, fallback) => (has(n, id) ? n[id] : (fallback == null ? '' : fallback));
513
- const name = cap(draft.cadence);
517
+ // The title is the report's own name (its definition's), never its id: "Scarlet assessment report 2026-11-02", not "Scarlet-assessment-report report …".
518
+ const named = isStr(given) && given.trim() ? given.trim().replace(/["\\]/g, "'") : '';
519
+ const name = named ? (/\breport$/i.test(named) ? named.replace(/\s*report$/i, '') : named) : cap(draft.cadence);
520
+ // The description is what readers see under the title: the report's purpose. How the file is made stays in this module's header.
521
+ const desc = isStr(purpose) && purpose.trim() ? purpose.trim().replace(/["\\]/g, "'") : `The ${named || draft.cadence} report for ${draft.slot}.`;
514
522
  const audience = draft.sources && draft.sources.definition ? draft.sources.definition.audience : null;
515
523
  const out = [];
516
524
  const push = (...l) => out.push(...l);
517
525
  push('---', 'type: Reference', `title: "${name} report ${draft.slot}"`,
518
- `description: "The ${draft.cadence} report for ${draft.slot}. pmos report draft writes every number; prose goes only between the note markers."`,
526
+ `description: "${desc}"`,
519
527
  `timestamp: ${draft.window.to}`, `cadence: ${draft.cadence}`, `slot: ${draft.slot}`,
520
528
  `window: "${draft.window.from} to ${draft.window.to} (${draft.window.since === 'last_issue' ? 'since the last issue' : 'report_cycle_days back'})"`,
521
529
  '---', '', `# ${name} report ${draft.slot}`, '');
@@ -620,7 +628,8 @@ function writeDraft(root, draft, { actor, notes, fresh, quiet } = {}) {
620
628
  if (badId !== undefined) return refuse(400, `${JSON.stringify(badId)} cannot carry a note: use lower-case letters, digits, ".", "_" or "-". Nothing was written`);
621
629
  const marked = Object.keys(kept).find((id) => kept[id] != null && MARKER_RE.test(String(kept[id])));
622
630
  if (marked !== undefined) return refuse(400, `the note for ${marked} holds a note marker (<!-- pmos:note or <!-- /pmos:note). Remove it from the note. Nothing was written`);
623
- const md = render(draft, { notes: kept });
631
+ let def = null; try { def = readDefinition(abs, draft.cadence); } catch { def = null; }
632
+ const md = render(draft, { notes: kept, name: def && def.name, purpose: def && def.purpose });
624
633
  const tmp = `${file}.tmp-${crypto.randomBytes(6).toString('hex')}`;
625
634
  try {
626
635
  fs.mkdirSync(path.dirname(file), { recursive: true });
@@ -9,6 +9,7 @@
9
9
  * validateDry(dry, plan) → { ok, dry } | refusal a dry-run result (section 4)
10
10
  * validateCheck(check, kind) → { ok, steps } | refusal the steps a check session wrote (section 5)
11
11
  * landVersion(root, id, plan, meta) → { ok, n, plan } writes versions/S<n>.json and the version line (plus any `before` lines)
12
+ * planFromSections(titles, { readers, decision, base }) → { ok, plan } | refusal the plan of the sections the PM named, in order (headline first, needs and sources last)
12
13
  * readVersion(root, id, n) → the plan of S<n> | null
13
14
  * rewriteVersion(root, id, n, plan) → the plan written back to S<n>.json (accept links chart ids)
14
15
  * writeDry · readDry · writeCheck · readCheck · pendingCheck
@@ -440,6 +441,39 @@ function landVersion(root, id, plan, { turn, answer, questions, options, from, b
440
441
  return { ok: true, n, plan: v.plan };
441
442
  }
442
443
 
444
+ /**
445
+ * The plan of the sections the PM named, in their order (report-from-chat fix, batch 21). The PM's own titles are kept; the ids follow the plan's
446
+ * rule: the first section is the fixed `headline`, a section named "Sources" (or one added) is the fixed `sources`, last, and the one before it is
447
+ * the fixed `needs`. One named section alone gets "Needs your call" after it. `base` (a saved plan) keeps its purpose, sources and charts.
448
+ * → { ok, plan } (validated) | refusal.
449
+ */
450
+ function planFromSections(titles, { readers, decision, base, charts } = {}) {
451
+ const seen = new Set();
452
+ const list = listOf(titles).map((t) => (typeof t === 'string' ? t.replace(/\s+/g, ' ').trim().slice(0, 80) : '')).filter((t) => t && !seen.has(t.toLowerCase()) && seen.add(t.toLowerCase()));
453
+ if (!list.length) return refuse(400, 'name at least one section');
454
+ const isSrc = (t) => /^sources?\b/i.test(t) || /\bsources?$/i.test(t);
455
+ const si = list.findIndex(isSrc);
456
+ const srcTitle = si >= 0 ? list.splice(si, 1)[0] : 'Sources';
457
+ if (list.length === 1) list.push('Needs your call');
458
+ if (list.length + 1 > LIMITS.sections) return refuse(400, `a report holds at most ${LIMITS.sections} sections, Sources included`);
459
+ const taken = new Set(FIXED);
460
+ const slug = (t) => {
461
+ let b = t.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 36) || 'section';
462
+ if (!/^[a-z]/.test(b)) b = 's-' + b;
463
+ let id = b, k = 2;
464
+ while (taken.has(id)) id = b + '-' + k++;
465
+ taken.add(id); return id;
466
+ };
467
+ const sec = (id, title, fixed) => ({ id, title, fixed, charts: [], notes: '', show: '' });
468
+ const outline = [sec('headline', list[0], true)]
469
+ .concat(list.slice(1, -1).map((t) => sec(slug(t), t, false)), [sec('needs', list[list.length - 1], true), sec('sources', srcTitle, true)]);
470
+ const b = isObj(base) ? base : null;
471
+ const pu = b && isObj(b.purpose) ? b.purpose : {};
472
+ const plan = { purpose: { readers: str(pu.readers) || str(readers).slice(0, LIMITS.text), decision: str(pu.decision) || str(decision).slice(0, LIMITS.text), scope: str(pu.scope), cadence: str(pu.cadence), questions: listOf(pu.questions) },
473
+ sources: b ? listOf(b.sources) : [], charts: b ? listOf(b.charts) : [], outline, options: [] };
474
+ return validatePlan(plan, { charts });
475
+ }
476
+
443
477
  // ── test pull (report-structure-gaps): ONE source read for the last complete period ──────────────────────────
444
478
  /** What a pull job wrote for one source of a plan. → { ok, pull } | refusal. `reached` false is a valid answer: the source returned nothing. */
445
479
  function validatePull(data, plan, sourceId) {
@@ -554,6 +588,6 @@ function writeBrief(root, id, setup, { now } = {}) {
554
588
  return { ok: true, path: paths(root, id).briefRel };
555
589
  }
556
590
 
557
- module.exports = { EVENTS, KINDS, PMOS_KINDS, OUTSIDE_KINDS, STATES, FIXED, LIMITS, CHECK_STEPS, CHECK_STATES, CADENCE_RE, SLUG_RE, RUN_RE,
591
+ module.exports = { planFromSections, EVENTS, KINDS, PMOS_KINDS, OUTSIDE_KINDS, STATES, FIXED, LIMITS, CHECK_STEPS, CHECK_STATES, CADENCE_RE, SLUG_RE, RUN_RE,
558
592
  paths, append, readEvents, fold, stateOf, nextN, badText, validatePlan, validateSource, validateDry, validateCheck, cleanQuestions, cleanOptions, addSourceTo, removeFrom,
559
593
  landVersion, readVersion, rewriteVersion, writeDry, readDry, validatePull, writePull, readPull, readPulls, writeCheck, readCheck, readChecks, writeBrief, structureAnswer, savedOf, overlay, defaultState, newRun };
@@ -10,7 +10,8 @@
10
10
  * POST /api/report-setups/ask { ws, text } → { ok, id } starts the report-setup run (headless)
11
11
  * POST /api/report-setups/change { ws, id, text } → { ok } a correction to a proposal; a second run revises it
12
12
  * POST /api/report-setups/cancel { ws, id } → { ok }
13
- * POST /api/report-setups/setup { ws, ask? | finding?, proposal? } → { ok, setup, first_draft, drafted } THE press that sets a report up; drafts the first cycle
13
+ * POST /api/report-setups/setup { ws, ask? | finding?, proposal?, sections? } → { ok, setup, first_draft, drafted, structure? } THE press that sets a report up; drafts the first cycle.
14
+ * sections (the titles the PM named in the chat) are saved as S1 and the first draft follows them (drafted.drafting)
14
15
  * POST /api/report-setups/draft { ws, id } → { ok, drafted: { slot, path }, id } Draft it now (the next cycle)
15
16
  * POST /api/report-setups/dismiss { ws, finding } → { ok } "Not a report"
16
17
  * POST /api/report-setups/pause | resume { ws, id } → { ok, setup }
@@ -54,6 +55,7 @@ const RC = require('./report-checks.js');
54
55
  const RX = require('./report-export.js');
55
56
  const RF = require('./report-finder.js');
56
57
  const RD = require('./report-draft.js');
58
+ const RSt = require('./report-structure.js');
57
59
  const logic = require('./schedule-logic.js');
58
60
  const docSync = require('./doc-sync.js');
59
61
  const headless = require('./headless.js');
@@ -415,14 +417,32 @@ async function handle(req, res, url, ctx) {
415
417
  else if (body.finding) { const l = RS.lookupFinding(st, text(body.finding), text(body.name)); if (!l.ok) return send({ status: l.status, body: { ok: false, error: l.error, reason: l.reason } }); from = { finding: l.finding.id }; base = l.finding.proposal; }
416
418
  const proposal = body.proposal && typeof body.proposal === 'object' && !Array.isArray(body.proposal) ? body.proposal : base;
417
419
  if (!proposal) return send(bad(400, 'say which request or finding to set up, or give the proposal'));
420
+ // The sections the PM named in the chat (report-chat `sections`), checked before anything is written: a bad list sets nothing up.
421
+ let shaped = null;
422
+ if (body.sections !== undefined) {
423
+ shaped = RSt.planFromSections(body.sections, { readers: text(proposal.audience), decision: text(proposal.purpose) });
424
+ if (!shaped.ok) return fail(shaped);
425
+ }
418
426
  const r = RS.setUp(root, { ...proposal, ...(from ? { from } : {}) }, opts);
419
427
  if (!r.ok) return fail(r);
428
+ // The PM saw those sections in the tab and pressed Set it up: that press saves them as S1, so the first draft already follows them
429
+ // (Wawan, 2026-11-01: a report set up from chat kept the standard sections and a draft written before the change landed).
430
+ let structured = null;
431
+ if (shaped && r.setup.source === 'work') {
432
+ const v = RSt.landVersion(root, r.setup.id, shaped.plan, { turn: 'The sections named in the chat.', answer: 'Made S1 from the sections you named.', from: 'chat', actor: g.actor });
433
+ if (v.ok) { RSt.append(root, r.setup.id, { ev: 'accept', n: v.n, charts: [] }, { actor: g.actor }); RSt.writeBrief(root, r.setup.id, r.setup); structured = v.n; }
434
+ }
420
435
  // The first cycle is drafted now, at the slot of its first scheduled draft, so the PM has a document to read the moment it is set up
421
436
  // (the approved mockup's "Sample draft made when you set up"). The schedule later redrafts the same slot. A failed draft leaves the set-up
422
- // in place and says why; Draft it now on the row tries again.
423
- const drafted = firstDraft(root, r, g.actor);
437
+ // in place and says why; Draft it now on the row tries again. A report with saved sections is drafted by the session that follows them.
438
+ let drafted = null;
439
+ if (structured != null && typeof ctx.structureDraft === 'function') {
440
+ let sd = null; try { sd = ctx.structureDraft(w, r.setup.id); } catch (e) { sd = { structured: true, status: 500, error: String((e && e.message) || e) }; }
441
+ if (sd && sd.structured) drafted = sd.status ? { error: sd.error } : { drafting: true, held: !!sd.held };
442
+ }
443
+ if (!drafted) drafted = firstDraft(root, r, g.actor);
424
444
  if (drafted.path) ctx.invalidateNeedsAgg && ctx.invalidateNeedsAgg();
425
- return send({ status: 200, body: { ok: true, setup: setupOut(r.setup, new Date(), documentsOf(ctx, w), copyIndex(root), root), first_draft: r.first_draft, drafted } });
445
+ return send({ status: 200, body: { ok: true, setup: setupOut(r.setup, new Date(), documentsOf(ctx, w), copyIndex(root), root), first_draft: r.first_draft, drafted, ...(structured != null ? { structure: structured } : {}) } });
426
446
  }
427
447
  if (sub === 'dismiss') {
428
448
  const r = RS.dismissFinding(file, { id: text(body.finding), name: text(body.name), by: g.actor });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.479.0",
3
+ "version": "0.480.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.479.0",
9
+ "version": "0.480.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.479.0",
3
+ "version": "0.480.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",
@@ -176,11 +176,18 @@ function slides() {
176
176
  export const longSlot = (s) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s || '')); return m ? +m[3] + ' ' + MONS[+m[2] - 1] + ' ' + m[1] : String(s || ''); };
177
177
  /** The title slide (ReportPanel.dc.html): the audience tag, the title with the audience as its accent line, a subtitle (the file's
178
178
  * subtitle or description, else its first sections) and the as-of line. Nothing is made up: a part with no source is left out. */
179
+ const AUD_MAX = 40;
180
+ /** The note older drafts carried in their description: how the file is made, for PMOS, never a subtitle. */
181
+ const INTERNAL_RE = /pmos report draft writes every number|between the note markers/i;
179
182
  function titleSlide(w) {
180
183
  const heads = (w.sections || []).map((x) => x.h).filter((h) => !/^summary$/i.test(h)).slice(0, 3);
181
184
  const list = heads.length > 1 ? heads.slice(0, -1).join(', ') + ' and ' + heads[heads.length - 1].toLowerCase() : heads.join('');
182
185
  const f = headFigure(w), t = [R.row.slot ? 'As of ' + longSlot(R.row.slot) : '', f && f.data ? 'Data: ' + f.data : ''].filter(Boolean).join(' · ');
183
- return { k: 'title', h: 'Title', title: w.title, eye: R.audience || 'Report', acc: R.audience ? R.audience.toLowerCase() : '', sub: w.sub || list, t,
186
+ // A long audience (a list of people) stays in At a glance: on the slide it would fill the eyebrow and repeat as the accent line (Wawan, 2026-11-01).
187
+ const aud = R.audience && R.audience.length <= AUD_MAX ? R.audience : '';
188
+ // an older draft is titled from the report's id ("Scarlet-assessment-report report 2026-11-02"): show the report's name instead
189
+ const idTitle = R.name && /^[A-Za-z][a-z0-9]*(?:-[a-z0-9]+)+ report \d{4}-\d{2}-\d{2}$/.test(w.title || '');
190
+ return { k: 'title', h: 'Title', title: idTitle ? R.name : w.title, eye: aud || 'Report', acc: aud ? aud.toLowerCase() : '', sub: (!INTERNAL_RE.test(w.sub || '') && w.sub) || list, t,
184
191
  fig: f ? { v: f.v, cap: f.cap } : null };
185
192
  }
186
193
  /** The title slide's headline figure (ReportPanel.dc.html: "81%" over "597 of 733 web logins"): the first bold number of the first
@@ -108,13 +108,13 @@ async function poll(t, kind) {
108
108
  await new Promise((ok) => setTimeout(ok, POLL_MS));
109
109
  if (kind === 'structure') {
110
110
  const S = await get('/api/report-structure', { id: t.block.id });
111
- if (S && S.ok && !S.structure.running) { t.S = S.structure; t.sv = t.S.current; t.busy = false; t.msg = lastSaid(t.S.log); redraw(t); return; }
111
+ if (S && S.ok && !S.structure.running) { t.S = S.structure; t.sv = t.S.current; t.msg = lastSaid(t.S.log); redraw(t); return; }
112
112
  } else {
113
113
  const r = await get('/api/report-design', { id: t.block.id });
114
- if (r && r.ok && !r.design.running) { t.Z = r.design; t.dv = t.Z.current; await renderOf(t, t.dv); t.busy = false; t.msg = lastSaid(t.Z.log); redraw(t); return; }
114
+ if (r && r.ok && !r.design.running) { t.Z = r.design; t.dv = t.Z.current; await renderOf(t, t.dv); t.msg = lastSaid(t.Z.log); redraw(t); return; }
115
115
  }
116
116
  }
117
- t.busy = false; t.msg = 'PMOS has not answered yet. The new version shows when you open this report again.'; redraw(t);
117
+ t.msg = 'PMOS has not answered yet. The new version shows when you open this report again.'; redraw(t);
118
118
  }
119
119
  const lastSaid = (log) => { const l = (log || []).filter((x) => x.who === 'pmos').pop(); return l ? l.text : ''; };
120
120
 
@@ -145,9 +145,11 @@ function draw(t, el) {
145
145
  el.querySelectorAll('iframe[data-rt-frame]').forEach((f) => { f.srcdoc = t.render.get(+f.dataset.rtFrame) || ''; });
146
146
  }
147
147
  /** The new report as slides: its title slide, then one slide per section every new report has. */
148
- export function deckOf(p) {
149
- return [{ eye: p.audience ? 'For ' + p.audience : 'New report', h: p.name, t: p.purpose || '' }].concat(FRAME.map(([h, d]) => ({ eye: p.name, h, t: d })));
148
+ export function deckOf(p, sections) {
149
+ return [{ eye: p.audience ? 'For ' + p.audience : 'New report', h: p.name, t: p.purpose || '' }].concat(frameOf(sections).map(([h, d]) => ({ eye: p.name, h, t: d })));
150
150
  }
151
+ /** The sections a new report will have: the ones the PM named in the chat (block.sections), else the standard frame. */
152
+ export const frameOf = (sections) => (Array.isArray(sections) && sections.length ? sections.map((h) => [h, '']) : FRAME);
151
153
  /**
152
154
  * A new report from the chat: the one report Viewer in its first state (canvas OvReport). The summary says it is new and not set up, what
153
155
  * it will hold, and its one primary, Set it up (a check icon); its chips are the schedule (Once until one is picked; it opens the choices)
@@ -155,20 +157,23 @@ export function deckOf(p) {
155
157
  * At a glance and Structure and look ("new"). Edit, Present, Share and Download have nothing to act on until it is set up, so they are not drawn.
156
158
  */
157
159
  function newHtml(t) {
158
- const p = t.block.proposal, L = deckOf(p), i = t.i = Math.max(0, Math.min(t.i, L.length - 1)), s = L[i];
160
+ const p = t.block.proposal, named = t.block.sections, F = frameOf(named), L = deckOf(p, named), i = t.i = Math.max(0, Math.min(t.i, L.length - 1)), s = L[i];
159
161
  const sum = rpSumHtml({ line: 'New · from your chat', tone: 'you', right: 'Not set up yet',
160
- text: t.block.structure ? 'It starts with the standard sections. When you set it up, Claude reshapes them to your change, and you keep it with one press. Nothing goes out until you set it up.'
161
- : 'One slide per section: ' + FRAME.map(([h]) => h).join(', ') + '. Nothing goes out until you set it up.',
162
+ text: named ? 'One slide per section: ' + F.map(([h]) => h).join(', ') + '. Press the check to set it up: it keeps these sections and drafts the first report with them. Nothing goes out.'
163
+ : t.block.structure ? 'It starts with the standard sections. When you set it up, Claude reshapes them to your change, and you keep it with one press. Nothing goes out until you set it up.'
164
+ : 'One slide per section: ' + FRAME.map(([h]) => h).join(', ') + '. Press the check to set it up. Nothing goes out.',
162
165
  chips: [{ icon: 'repeat', label: cadenceWords(t.sched), act: 'sched', exp: t.open }, { icon: 'file', label: OUT[p.output] || p.output || 'PDF' }],
163
166
  primary: { act: 'setup', label: t.busy ? 'Setting it up' : 'Set it up', icon: 'check', disabled: t.busy } }, 'data-rt');
164
167
  const bar = rpBarHtml({ view: t.nv, views: [['deck', 'Slides'], ['doc', 'Document']] }, 'data-rt');
165
168
  const deck = `<div class="vz-dks" role="group" aria-roledescription="slide" aria-label="Slide ${i + 1} of ${L.length}: ${esc(s.h)}"><p class="vz-dke">${esc(s.eye)}</p><h2>${esc(s.h)}</h2>${s.t ? `<p>${esc(s.t)}</p>` : ''}</div>`
166
169
  + `<div class="vz-dkn"><button type="button" class="vz-dkb vz-hv" data-rt="sl|-1" aria-label="Previous slide"${i === 0 ? ' disabled' : ''}>${SV('M15 6l-6 6 6 6')}</button><span aria-live="polite">Slide ${i + 1} of ${L.length}</span><button type="button" class="vz-dkb vz-hv" data-rt="sl|1" aria-label="Next slide"${i === L.length - 1 ? ' disabled' : ''}>${SV('M9 6l6 6-6 6')}</button></div>`
167
170
  + `<div class="vz-dkt" role="group" aria-label="Slides">${L.map((x, k) => `<button type="button" class="vz-hv" data-rt="go|${k}" aria-label="Slide ${k + 1}: ${esc(x.h)}"${k === i ? ' aria-current="true"' : ''}><span>${esc(x.h)}</span></button>`).join('')}</div>`;
168
- const page = `<article class="vz-dkp"><h2>${esc(p.name)}</h2>${p.purpose ? `<p class="vz-note">${esc(p.purpose)}</p>` : ''}${sectionsHtml(FRAME)}</article>`;
171
+ const page = `<article class="vz-dkp"><h2>${esc(p.name)}</h2>${p.purpose ? `<p class="vz-note">${esc(p.purpose)}</p>` : ''}${sectionsHtml(F)}</article>`;
169
172
  const folds = czSections([
170
173
  { id: 'glance', title: 'At a glance', count: 'For, read by, goes out', render: () => `<div class="rp-brief">${glance(p.purpose, p.audience, esc(schedWords(t.sched)), OUT[p.output] || p.output)}</div>` },
171
- { id: 'look', title: 'Structure and look', count: t.block.structure ? 'change' : 'new', render: () => (t.block.structure ? `<div class="vz-ask"><p>Your change: <b>“${esc(t.block.structure)}”</b></p><p class="vz-note">Claude makes this change as soon as the report is set up. The first draft uses the sections below.</p></div>` : '')
174
+ { id: 'look', title: 'Structure and look', count: named ? F.length + ' sections' : t.block.structure ? 'change' : 'new', render: () => named
175
+ ? `${sectionsHtml(F)}<p class="vz-note">The sections you named in the chat. It uses the standard PMOS look until you say how it should look.</p>`
176
+ : (t.block.structure ? `<div class="vz-ask"><p>Your change: <b>“${esc(t.block.structure)}”</b></p><p class="vz-note">Claude makes this change as soon as the report is set up. The first draft uses the sections below.</p></div>` : '')
172
177
  + `${sectionsHtml(FRAME)}<p class="vz-note">Every new report has these sections. ${t.block.structure ? '' : 'Once it is set up, ask in the chat to shape them. '}It uses the standard PMOS look until you say how it should look.</p>` },
173
178
  ], { key: 'report-new' });
174
179
  return sum + schedMenu(t, t.sched) + bar + (t.nv === 'doc' ? page : deck) + folds;
@@ -190,14 +195,18 @@ function stepper(kind, n, list, saved) {
190
195
  return `<div class="vz-r1 vz-g6"><button type="button" class="vz-nav vz-hv" data-rt="${kind}|${list[i - 1] ? list[i - 1].n : n}" aria-label="Earlier version"${i <= 0 ? ' disabled' : ''}>${SV('M15 6l-6 6 6 6', 14)}</button>`
191
196
  + `<span class="vz-t13">${kind === 'sv' ? 'S' : 'D'}${n}${n === saved ? ' · saved' : ' · not saved'}</span><button type="button" class="vz-nav vz-hv" data-rt="${kind}|${list[i + 1] ? list[i + 1].n : n}" aria-label="Later version"${i >= list.length - 1 ? ' disabled' : ''}>${SV('M9 6l6 6-6 6', 14)}</button></div>`;
192
197
  }
198
+ /** The change to a set-up report's sections in words: the titles the PM named, else the change Claude carried. */
199
+ const shapeOf = (b) => (b.sections && b.sections.length ? 'Use exactly these sections, in this order: ' + b.sections.join('; ') + '.' : b.structure || '');
193
200
  function structureHtml(t) {
194
201
  const S = t.S, V = (S && S.versions) || [];
195
202
  const plan = S && S.plan, shown = t.sv;
196
203
  const L = plan && plan.outline ? plan.outline.map((x) => [x.title, x.notes || '']) : FRAME;
197
- const ask = t.block.structure && !(S && S.running) ? `<div class="vz-ask"><p>Your change: <b>“${esc(t.block.structure)}”</b></p><div>${btn('s-turn', 'Make the next version', { off: t.busy })}</div></div>` : '';
204
+ const want = shapeOf(t.block);
205
+ const ask = want && !(S && S.running) ? `<div class="vz-ask"><p>Your change: <b>“${esc(want)}”</b></p><div>${btn('s-turn', 'Make the next version', { off: t.busy })}</div></div>` : '';
198
206
  const working = S && S.running ? '<p class="vz-note" role="status">PMOS is making the next version.</p>' : '';
199
- const save = shown != null && S && shown !== S.saved ? btn('s-accept', 'Use this', { off: t.busy }) : '';
200
- const undo = V.some((v) => v.n < (S ? S.current : 0)) ? btn('s-undo', 'Undo', { sec: true, off: t.busy }) : '';
207
+ const held = t.busy || !!(S && S.running); // a running job holds only these two; Discard and Delete template stay free
208
+ const save = shown != null && S && shown !== S.saved ? btn('s-accept', 'Use this', { off: held }) : '';
209
+ const undo = V.some((v) => v.n < (S ? S.current : 0)) ? btn('s-undo', 'Undo', { sec: true, off: held }) : '';
201
210
  return `${stepper('sv', shown, V, S && S.saved)}${ask}${working}${sectionsHtml(L)}${!V.length ? '<p class="vz-note">No structure version yet: each cycle uses these sections. Say in the chat how to shape them.</p>' : ''}${save || undo ? `<div class="vz-r1">${undo}${save}</div>` : ''}`;
202
211
  }
203
212
  /** The look conversation's card (RpDesign): the preview of the shown look against the saved one, Use it and Keep current. */
@@ -219,8 +228,9 @@ function designHtml(t) {
219
228
  + `<button type="button" class="rp-thumb on" data-rt="dv|${t.dv}" aria-current="true"><span class="rp-tf">${fr(t.dv, 'The new look D' + t.dv)}</span><span class="rp-tl"><b>New look</b> · D${t.dv}</span></button></div>` : '';
220
229
  const frame = t.dv != null ? (t.render.has(t.dv) ? `<div class="vz-pagefr"><iframe sandbox="" title="Design version D${t.dv}" data-rt-frame="${t.dv}"></iframe></div>` : '<p class="vz-note">This version could not be read.</p>')
221
230
  : '<p class="vz-note">No look yet. Say in the chat how it should look, or attach a sample. Each cycle uses the standard look until then.</p>';
222
- const use = preview ? btn('d-accept', 'Use it', { off: t.busy }) + btn('d-keep', 'Keep current', { sec: true, off: t.busy }) : '';
223
- const undo = !preview && V.some((v) => v.n < (Z.current || 0)) ? btn('d-undo', 'Undo', { sec: true, off: t.busy }) : '';
231
+ const held = t.busy || !!Z.running;
232
+ const use = preview ? btn('d-accept', 'Use it', { off: held }) + btn('d-keep', 'Keep current', { sec: true, off: held }) : '';
233
+ const undo = !preview && V.some((v) => v.n < (Z.current || 0)) ? btn('d-undo', 'Undo', { sec: true, off: held }) : '';
224
234
  return `${head}${stepper('dv', t.dv, V, saved)}${ask}${working}${fol}${pair}${frame}${use || undo ? `<div class="vz-r1">${use}${undo}</div>` : ''}`;
225
235
  }
226
236
  function cyclesHtml(t) {
@@ -262,8 +272,8 @@ async function press(t, e) {
262
272
  if (a === 'setup') { await setUp(t); return; }
263
273
  if (a === 'open') { const d = t.docs.find((x) => x.path === v); if (window.czViews) window.czViews.openReport(d ? { path: d.path, slot: d.slot, state: d.state, archived: !!d.archived } : v, { ws: ws(), name: t.setup ? t.setup.name : '' }); return; }
264
274
  const id = t.block.id;
265
- if (a === 's-turn') { t.busy = true; t.msg = ''; redraw(t); const r = await post('/api/report-structure/turn', { id, text: t.block.structure }); if (!r || !r.ok) { t.busy = false; t.msg = 'That did not start: ' + why(r, 'no answer') + '.'; redraw(t); return; } t.S = Object.assign({}, t.S, { running: true }); t.block = Object.assign({}, t.block, { structure: undefined }); redraw(t); poll(t, 'structure'); return; }
266
- if (a === 'd-turn') { t.busy = true; t.msg = ''; redraw(t); const r = await post('/api/report-design/turn', { id, text: t.block.design, points: [] }); if (!r || !r.ok) { t.busy = false; t.msg = 'That did not start: ' + why(r, 'no answer') + '.'; redraw(t); return; } t.Z = Object.assign({}, t.Z, { running: true }); t.block = Object.assign({}, t.block, { design: undefined }); redraw(t); poll(t, 'design'); return; }
275
+ if (a === 's-turn') { t.busy = true; t.msg = ''; redraw(t); const r = await post('/api/report-structure/turn', { id, text: shapeOf(t.block) }); if (!r || !r.ok) { t.busy = false; t.msg = 'That did not start: ' + why(r, 'no answer') + '.'; redraw(t); return; } t.busy = false; t.S = Object.assign({}, t.S, { running: true }); t.block = Object.assign({}, t.block, { structure: undefined, sections: undefined }); redraw(t); poll(t, 'structure'); return; }
276
+ if (a === 'd-turn') { t.busy = true; t.msg = ''; redraw(t); const r = await post('/api/report-design/turn', { id, text: t.block.design, points: [] }); if (!r || !r.ok) { t.busy = false; t.msg = 'That did not start: ' + why(r, 'no answer') + '.'; redraw(t); return; } t.busy = false; t.Z = Object.assign({}, t.Z, { running: true }); t.block = Object.assign({}, t.block, { design: undefined }); redraw(t); poll(t, 'design'); return; }
267
277
  if (a === 's-accept') { await act(t, async () => { const r = await post('/api/report-structure/accept', { id, n: t.sv }); if (!r || !r.ok) return why(r, 'The structure was not saved.'); t.S = r.structure; return 'S' + t.sv + ' is saved. The next cycle follows it.'; }); return; }
268
278
  if (a === 's-undo') { const V = t.S.versions.filter((x) => x.n < t.S.current); const to = V[V.length - 1].n; await act(t, async () => { const r = await post('/api/report-structure/revert', { id, n: to }); if (!r || !r.ok) return why(r, 'Undo did not go through.'); t.S = r.structure; t.sv = t.S.current; return 'Back to S' + to + '.'; }); return; }
269
279
  if (a === 'd-accept') { await act(t, async () => { const r = await post('/api/report-design/accept', { id, n: t.dv }); if (!r || !r.ok) return why(r, 'The design was not saved.'); t.Z = r.design; return 'Using the new look (D' + t.dv + '). The next cycle follows it, and every section and figure stays.'; }); return; }
@@ -295,12 +305,13 @@ async function setUp(t) {
295
305
  const p = t.block.proposal;
296
306
  const schedule = t.sched === 'off' ? { cadence: 'weekly', day: 'Mon', time: '09:00' } : t.sched;
297
307
  await act(t, async () => {
308
+ const named = t.block.sections;
298
309
  const r = await post('/api/report-setups/setup', { proposal: { name: p.name, purpose: p.purpose || p.name, audience: p.audience, source: 'work', output: p.output, schedule,
299
- sources: p.sources.length ? p.sources : ['The records of this workspace'], learned_from: 'Set up from a chat.' } });
310
+ sources: p.sources.length ? p.sources : ['The records of this workspace'], learned_from: 'Set up from a chat.' }, ...(named ? { sections: named } : {}) });
300
311
  if (!r || !r.ok) return 'It was not set up: ' + why(r, 'the page could not reach PMOS') + '.';
301
312
  if (t.sched === 'off') await post('/api/report-setups/edit', { id: r.setup.id, schedule: { cadence: 'off' } });
302
313
  // the view now shows the set-up report, under the same id, so the card stays on it
303
- const shape = t.block.structure;
314
+ const shape = r.structure ? null : named ? 'Use exactly these sections, in this order: ' + named.join('; ') + '.' : t.block.structure;
304
315
  t.block = { kind: 'report', id: r.setup.id }; t.loaded = false; show(t); await load(t);
305
316
  const d = r.drafted || {};
306
317
  // the change Claude proposed with the new report: start it now, the PM keeps it with Use this (batch 20 item 9)
@@ -310,6 +321,9 @@ async function setUp(t) {
310
321
  if (s && s.ok) { t.S = Object.assign({}, t.S, { running: true }); t.view = 'structure'; poll(t, 'structure'); shaping = ' Claude is reshaping the sections to your change now.'; }
311
322
  else { t.block = Object.assign({}, t.block, { structure: shape }); shaping = ' The change to its sections did not start: ' + why(s, 'no answer') + '. Press Make the next version to try again.'; }
312
323
  }
313
- return 'Set up. ' + (d.path ? 'The first draft is written.' : 'The first draft was not written' + (d.error ? ': ' + d.error : '') + '.') + (t.sched === 'off' ? ' Schedule is Off, so it runs once.' : '') + shaping;
324
+ if (r.structure) t.view = 'structure';
325
+ const first = d.drafting ? 'Claude is writing the first draft with your ' + named.length + ' sections. It opens under Reports when it lands.'
326
+ : d.path ? 'The first draft is written.' : 'The first draft was not written' + (d.error ? ': ' + d.error : '') + '.';
327
+ return 'Set up' + (r.structure ? ' with your sections. ' : '. ') + first + (t.sched === 'off' ? ' Schedule is Off, so it runs once.' : '') + shaping;
314
328
  });
315
329
  }
@@ -43,6 +43,14 @@ function cleanChartBlock(b) {
43
43
  return out;
44
44
  }
45
45
 
46
+ /** The sections the PM named, in order: up to 10 short titles, each once. null when there are none. */
47
+ function cleanSections(v) {
48
+ if (!Array.isArray(v)) return null;
49
+ const seen = new Set();
50
+ const out = v.filter((x) => typeof x === 'string').map((x) => clip(x, 80)).filter((x) => x && !seen.has(x.toLowerCase()) && seen.add(x.toLowerCase())).slice(0, 10);
51
+ return out.length ? out : null;
52
+ }
53
+
46
54
  /** The block as the tab uses it, or null when it is not a block. Unknown keys are dropped; text is clipped. */
47
55
  export function cleanBlock(b) {
48
56
  if (b && typeof b === 'object' && (b.kind === 'chart' || b.kind === 'dashboard')) return cleanChartBlock(b);
@@ -51,12 +59,13 @@ export function cleanBlock(b) {
51
59
  const out = { kind: 'report', id: b.id };
52
60
  if (b.schedule !== undefined) { const s = cleanSchedule(b.schedule); if (s) out.schedule = s; }
53
61
  for (const k of ['structure', 'design']) { const v = clip(b[k], 600); if (v) out[k] = v; }
62
+ const secs = cleanSections(b.sections); if (secs) out.sections = secs;
54
63
  return out;
55
64
  }
56
65
  const p = b.proposal && typeof b.proposal === 'object' ? b.proposal : null;
57
66
  if (!p || !clip(p.name, 80)) return null;
58
- const shape = clip(b.structure, 600);
59
- return { kind: 'report', ...(shape ? { structure: shape } : {}), proposal: {
67
+ const shape = clip(b.structure, 600), secs = cleanSections(b.sections);
68
+ return { kind: 'report', ...(shape ? { structure: shape } : {}), ...(secs ? { sections: secs } : {}), proposal: {
60
69
  name: clip(p.name, 80), purpose: clip(p.purpose, 400), audience: clip(p.audience, 120) || 'The team',
61
70
  output: OUTPUTS.includes(p.output) ? p.output : 'google-doc', schedule: cleanSchedule(p.schedule) === 'off' ? null : cleanSchedule(p.schedule),
62
71
  sources: (Array.isArray(p.sources) ? p.sources : []).map((x) => clip(x, 160)).filter(Boolean).slice(0, 8),
@@ -86,5 +95,7 @@ export function reportChipHtml(block, i) {
86
95
  const what = k === 'report' && !P ? (block.schedule ? 'Schedule change' : block.structure || block.design ? 'Report change' : 'Report')
87
96
  : P && !block.id ? 'New ' + noun : P ? noun[0].toUpperCase() + noun.slice(1) + ' change' : noun[0].toUpperCase() + noun.slice(1);
88
97
  const tab = k === 'report' ? 'Report' : k === 'chart' ? 'Chart' : 'Dashboard';
89
- return `<div class="ctxc"><button type="button" class="ctxchip lead" data-report-open="${i}"><span><b>${esc(name)}</b><em>${esc(what)} · View in the ${tab} tab</em></span></button></div>`;
98
+ // a new report waits for one press, so the chip names it (Wawan, 2026-11-01: "I still don't know how to set it up")
99
+ const next = k === 'report' && P && !block.id ? 'Set it up in the Report tab' : 'View in the ' + tab + ' tab';
100
+ return `<div class="ctxc"><button type="button" class="ctxchip lead" data-report-open="${i}"><span><b>${esc(name)}</b><em>${esc(what)} · ${esc(next)}</em></span></button></div>`;
90
101
  }