create-pmos 0.270.0 → 0.272.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.270.0",
3
+ "version": "0.272.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@3edeec9
1
+ kernel-source: pmos@5c2a265
2
2
  assembled: 2026-10-18
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-18T12:29:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T13:41:52Z"}
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-18T12:29:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T13:41:52Z"}
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-18T12:29:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T13:41:52Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -200,7 +200,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
200
200
  await shut();
201
201
  await q.click('#repSetups .dmo'); await dlgOn();
202
202
  const su = await q.evaluate(() => ({ kv: document.querySelector('#oMain .kv2').textContent, acts: [...document.querySelectorAll('#oMain [data-rx]')].map((b) => b.dataset.rx).join() }));
203
- ok('R4 a set-up report shows its schedule and next draft, with Draft it now and Pause', /ScheduleEvery other Monday at 09:00/.test(su.kv) && /Next draft26 Oct/.test(su.kv) && su.acts === 'draft,pause', JSON.stringify(su));
203
+ 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));
204
204
  await q.click('#oMain [data-rx="pause"]'); await sleep(300);
205
205
  ok('R4 Pause posts that report', last()[0] === '/api/report-setups/pause' && last()[1].id === 'partner-update', JSON.stringify(last()));
206
206
  ok('R7 every press went to the dashboard save route or an existing report-setups route', R.posts.every((x) => /^POST \/api\/(premium-dashboards\/save|report-setups\/(ask|change|cancel|setup|dismiss|pause|resume|draft))$/.test(x)), R.posts.join());
@@ -203,6 +203,9 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
203
203
  - **Charts.** One chart for each KR metric that holds at least two readings. The line runs through the readings at their dates, so a month with no reading is a gap and not a zero. The dashed line is the metric's target. The chip is the record's own line status: on its line, behind it, or well behind it. Pressing a chart, or its Details link, opens the metric's record in the dialog with the read-only agent beside it.
204
204
  - **Dashboards.** The switch lists All measures first, then your saved dashboards (the main one first, marked Main), then the pillars the metrics name. 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.
205
205
  - **Make or edit a dashboard.** **New 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.
206
+ - **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.
207
+ - **Set up a report in the Studio.** **New report** on the Reports card opens the Insight Studio in **Report** mode. The brief shows the Title, What it answers, Audience, Format, Schedule, Draw from (your work, or the board's dashboard) and the Sections. A new report always has the same sections, in the same order, so they are listed, not edited. The checks (what it answers, an audience, a format that fits the audience, a new title, the answer first) say what fails, with a one-press fix. You can say it instead: "it answers: …", "for leadership", "slides", "monthly", "every two weeks on Thursday", "call it …". **Set it up** records the report and writes its first draft as a file.
208
+ - **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.
206
209
  - **What stands out.** Up to three plain sentences taken from the series: behind its line for three readings in a row, behind and still moving away from the target, closing in, slipped, reached its target, or a large one-step move. There is no forecast and no cause.
207
210
  - **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
208
211
  - **Ask PMOS to set up a report.** Type what the report is for and press **Ask**. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
@@ -210,4 +213,4 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
210
213
  - **Set up.** Your recurring reports, with their schedule and next draft. A report opens with **Draft it now** (for a report drawn from your work) and **Pause** or **Resume**.
211
214
  - **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens the console's Reports tab, where it is read, edited or issued. Nothing is sent from this page.
212
215
 
213
- Not built: the Insight Studio's Chart and Report modes, the report deck, present and print, tile sizes and free layout, the finder's settings, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
216
+ Not built: report samples and the report's look in the Studio, a second measure next to a chart, bar highlights, the report deck, present and print, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
@@ -69,6 +69,22 @@ function chartOf(o) {
69
69
  };
70
70
  }
71
71
 
72
+ /** A chart the PM saved in the Insight Studio (premium-studio-chart C2): its measure's readings, the latest `range` of them, against the saved target.
73
+ * null when the measure is gone or has fewer than two readings in range. Every value is still a reading of the record. */
74
+ function mineOf(m, outcomes) {
75
+ const o = outcomes.find((x) => x.id === m.measure);
76
+ if (!o) return null;
77
+ const rs = (o.readings || []).filter((x) => x && fin(x.v) && isoDay(x.at) !== null);
78
+ const c = chartOf(Object.assign({}, o, { readings: m.range ? rs.slice(-m.range) : rs, target: m.target }));
79
+ if (!c) return null;
80
+ const dir = m.better === 'lower' ? -1 : 1, good = c.step ? c.step * dir > 0 : null;
81
+ return Object.assign(c, {
82
+ key: 'mine:' + m.id, id: m.id, measure: o.id, measureTitle: clip(o.name, 120), title: clip(m.title, 60), question: m.question || '', form: m.form, range: m.range,
83
+ better: m.better, note: m.note || '', mine: true, dir, good, all: rs.length,
84
+ sub: [clip(o.name, 120), (m.range ? 'last ' + c.pts.length : c.pts.length) + ' readings'].join(' · '),
85
+ });
86
+ }
87
+
72
88
  /** Up to three plain sentences about what stands out, from the series alone. No forecast and no cause. */
73
89
  function findingsOf(charts) {
74
90
  const out = [];
@@ -103,12 +119,14 @@ function reportRows(reports) {
103
119
 
104
120
  /** The board's saved dashboards (briefing-premium-reports D3/D5), main first as the ledger folds them. A chart id that has no record, or no series, stays
105
121
  * in `charts` and is listed in `gone` with the reason, so the page can say so in its place. `checks` are the two advisory checks, never a refusal. */
106
- function savedOf(saved, outcomes, charts) {
122
+ function savedOf(saved, outcomes, charts, mine) {
107
123
  return (saved || []).map((d) => {
108
124
  const ids = Array.isArray(d.charts) ? d.charts : [];
109
125
  const L = ids.map((id) => charts.find((c) => c.id === id)).filter(Boolean);
110
126
  const gone = ids.filter((id) => !charts.some((c) => c.id === id)).map((id) => {
111
- const o = outcomes.find((x) => x.id === id);
127
+ const o = outcomes.find((x) => x.id === id), m = (mine || []).find((x) => x.id === id);
128
+ if (m) return { id, title: clip(m.title, 60), why: 'Its measure has fewer than two readings in its range, so it has no chart.' };
129
+ if (/^pc-/.test(id)) return { id, title: id, why: 'This saved chart was removed.' };
112
130
  return { id, title: o ? clip(o.name, 120) : id, why: o ? 'This measure has fewer than two readings, so it has no chart.' : 'No KR metric record is called ' + id + ' any more.' };
113
131
  });
114
132
  const checks = [];
@@ -155,6 +173,9 @@ function build(facts) {
155
173
  const f = facts || {};
156
174
  const outcomes = f.outcomes || [], missing = (f.missing || []).slice();
157
175
  const charts = outcomes.map(chartOf).filter(Boolean);
176
+ const mineAll = f.mine || [], mine = mineAll.map((m) => mineOf(m, outcomes)).filter(Boolean);
177
+ const mineGone = mineAll.filter((m) => !mine.some((c) => c.id === m.id)).map((m) => ({ id: m.id, title: clip(m.title, 60), measure: m.measure,
178
+ why: outcomes.some((o) => o.id === m.measure) ? 'Its measure has fewer than two readings in its range, so it has no chart.' : 'No KR metric record is called ' + m.measure + ' any more.' }));
158
179
  const noSeries = outcomes.filter((o) => !chartOf(o)).map((o) => ({
159
180
  key: 'nos:' + o.id, title: clip(o.name, 120), pillar: o.pillar || '',
160
181
  why: (o.readings || []).length === 1 ? 'Only one reading is recorded.' : (o.readings || []).length === 0 ? (o.reason && /reading/i.test(o.reason) ? o.reason : 'No reading is recorded yet.') : 'Its readings do not form a series.',
@@ -162,7 +183,7 @@ function build(facts) {
162
183
  const pillars = [...new Set(charts.map((c) => c.pillar).filter(Boolean))];
163
184
  const offOf = (L) => L.filter((c) => c.off).length;
164
185
  const dash = (id, name, L) => ({ id, name, keys: L.map((c) => c.key), total: L.length, off: offOf(L), chip: !L.length ? '' : offOf(L) ? offOf(L) + ' off its line' : 'On their lines' });
165
- const dashboards = [dash('all', 'All measures', charts)].concat(savedOf(f.saved, outcomes, charts), pillars.length > 1 ? pillars.map((p) => dash('p:' + p, p, charts.filter((c) => c.pillar === p))) : []);
186
+ const dashboards = [dash('all', 'All measures', charts)].concat(savedOf(f.saved, outcomes, charts.concat(mine), mineAll), pillars.length > 1 ? pillars.map((p) => dash('p:' + p, p, charts.filter((c) => c.pillar === p))) : []);
166
187
  const findings = findingsOf(charts);
167
188
  const rep = reportRows(f.reports);
168
189
  const off = offOf(charts);
@@ -170,7 +191,7 @@ function build(facts) {
170
191
  const model = {
171
192
  header: { text: (f.pending ? 'Reading the records · ' : '') + 'Real data' + (missing.length ? ' · not read: ' + missing.join(', ') : '') },
172
193
  board: { ws: board.ws || null, id: board.id || null, name: board.name || 'Insights', switcher: (f.boards || []).map((b) => ({ ws: b.ws, id: b.id, name: b.name })) },
173
- charts, noSeries, dashboards, rows: charts,
194
+ charts, mine, mineGone, mineSaved: mineAll, noSeries, dashboards, rows: charts,
174
195
  findings: findings.length ? findings : [{ kind: 'calm', key: null, text: charts.length ? (charts.some((c) => c.target !== null) ? 'Nothing stands out. No measure moved much, and none is far behind its line.' : 'Nothing stands out. No measure here has a target, so the series can only be described.') : '' }],
175
196
  calm: !findings.length && charts.length > 0,
176
197
  reports: Object.assign({ rows: rep, ok: f.reportsOk !== false, counts: { draft: rep.filter((r) => r.state === 'draft').length, issued: rep.filter((r) => r.state === 'issued').length }, missing: f.reportsOk === false }, setupsOf(f.setups, f.now)),
@@ -183,4 +204,4 @@ function build(facts) {
183
204
  return model;
184
205
  }
185
206
 
186
- module.exports = { build, peekModel, chartOf, findingsOf, shortDate, num };
207
+ module.exports = { build, peekModel, chartOf, mineOf, findingsOf, shortDate, num };
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+ /* premium-charts.js — the charts the PM makes in the Insight Studio on the premium Insights page (initiative premium-studio-chart, PRD C1).
3
+ * THE ONE WRITER and THE ONE FOLD of <state>/premium-charts.jsonl.
4
+ *
5
+ * FORMS · TITLE_MAX · QUESTION_MAX · NOTE_MAX
6
+ * ledgerFile(root) · readLines(file)
7
+ * check(input) → { ok: true, value } | { ok: false, status, error } PURE: the shape only
8
+ * fold(lines) → { [board]: [{ id, board, measure, title, question, form, range, target, better, note, at }] } PURE
9
+ * list(root, board) → the charts of one board, in the order they were made
10
+ * save(root, input, actor, { now, known }) → { ok: true, chart, charts } | { ok: false, status, error }
11
+ *
12
+ * THE LEDGER. Lines { v: 1, ev: save | remove, id, board, measure, title, question, form, range, target, better, note, actor, at }. `measure` is a KR metric
13
+ * id of the workspace. `range` is how many of the latest readings to draw (2 or more), or null for all of them. `target` is a number, or null for none.
14
+ * The fold keeps the last save of each id and drops an id once it is removed. The file is never rewritten. A torn line, or one without an id and a board,
15
+ * is skipped. Chart ids start with `pc-`, so a dashboard can hold them beside KR metric ids (lib/premium-dashboards.js). */
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+
19
+ const LEDGER = 'premium-charts.jsonl';
20
+ const FORMS = ['line', 'bars', 'number', 'meter'];
21
+ const TITLE_MAX = 60;
22
+ const QUESTION_MAX = 100;
23
+ const NOTE_MAX = 200;
24
+ const RANGE_MAX = 500;
25
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
26
+
27
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
28
+ const refuse = (status, error) => ({ ok: false, status, error });
29
+ const tidy = (v) => (typeof v === 'string' ? v.trim().replace(/\s+/g, ' ') : '');
30
+ const norm = (t) => tidy(t).toLowerCase();
31
+
32
+ function ledgerFile(root) {
33
+ const abs = path.resolve(String(root));
34
+ return path.join(abs, require('./report-draft.js').stateRel(abs), LEDGER);
35
+ }
36
+ function readLines(file) {
37
+ let text = '';
38
+ try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
39
+ const out = [];
40
+ for (const raw of text.split('\n')) {
41
+ if (!raw.trim()) continue;
42
+ try { const l = JSON.parse(raw); if (isObj(l) && (l.ev === 'save' || l.ev === 'remove') && typeof l.id === 'string' && typeof l.board === 'string') out.push(l); } catch { /* a torn line is skipped */ }
43
+ }
44
+ return out;
45
+ }
46
+
47
+ /** Check the fields of a save or a remove. Whether the board and the measure exist is the route's check (it passes `known`). */
48
+ function check(input) {
49
+ const i = isObj(input) ? input : {};
50
+ const board = typeof i.board === 'string' ? i.board : '';
51
+ if (!ID_RE.test(board)) return refuse(400, 'Name the board the chart belongs to.');
52
+ const id = i.id == null || i.id === '' ? null : i.id;
53
+ if (id !== null && (typeof id !== 'string' || !/^pc-/.test(id) || !ID_RE.test(id))) return refuse(400, 'That chart id is not valid.');
54
+ if (i.remove === true) {
55
+ if (id === null) return refuse(400, 'Say which chart to remove.');
56
+ return { ok: true, value: { remove: true, id, board } };
57
+ }
58
+ const measure = typeof i.measure === 'string' ? i.measure : '';
59
+ if (!ID_RE.test(measure)) return refuse(400, 'Pick the measure the chart draws.');
60
+ const title = tidy(i.title);
61
+ if (!title) return refuse(400, 'Give the chart a name.');
62
+ if (title.length > TITLE_MAX) return refuse(400, `The name can be at most ${TITLE_MAX} characters.`);
63
+ const question = tidy(i.question);
64
+ if (question.length > QUESTION_MAX) return refuse(400, `The question can be at most ${QUESTION_MAX} characters.`);
65
+ const form = i.form == null || i.form === '' ? 'line' : i.form;
66
+ if (!FORMS.includes(form)) return refuse(400, 'The form must be a line, bars, a number or a meter.');
67
+ const range = i.range == null || i.range === '' ? null : i.range;
68
+ if (range !== null && (!Number.isInteger(range) || range < 2 || range > RANGE_MAX)) return refuse(400, 'The range must be two or more readings, or all of them.');
69
+ const target = i.target == null || i.target === '' ? null : i.target;
70
+ if (target !== null && (typeof target !== 'number' || !Number.isFinite(target))) return refuse(400, 'The target must be a number, or none.');
71
+ if (form === 'meter' && target === null) return refuse(400, 'A meter needs a target.');
72
+ const better = i.better == null || i.better === '' ? 'higher' : i.better;
73
+ if (better !== 'higher' && better !== 'lower') return refuse(400, 'Better when must be higher or lower.');
74
+ const note = tidy(i.note);
75
+ if (note.length > NOTE_MAX) return refuse(400, `The note can be at most ${NOTE_MAX} characters.`);
76
+ return { ok: true, value: { remove: false, id, board, measure, title, question, form, range, target, better, note } };
77
+ }
78
+
79
+ /** Every board's charts after the ledger's lines, in order. PURE. */
80
+ function fold(lines) {
81
+ const byId = new Map();
82
+ let made = 0;
83
+ for (const l of lines || []) {
84
+ const prev = byId.get(l.id);
85
+ if (prev && prev.board !== l.board) continue; // an id never moves between boards
86
+ if (l.ev === 'remove') { byId.delete(l.id); continue; }
87
+ byId.set(l.id, {
88
+ id: l.id, board: l.board, measure: typeof l.measure === 'string' ? l.measure : '', title: tidy(l.title), question: tidy(l.question),
89
+ form: FORMS.includes(l.form) ? l.form : 'line', range: Number.isInteger(l.range) && l.range >= 2 ? l.range : null,
90
+ target: typeof l.target === 'number' && Number.isFinite(l.target) ? l.target : null, better: l.better === 'lower' ? 'lower' : 'higher', note: tidy(l.note),
91
+ at: l.at || null, first: prev ? prev.first : made++,
92
+ });
93
+ }
94
+ const out = {};
95
+ for (const c of byId.values()) (out[c.board] = out[c.board] || []).push(c);
96
+ for (const b of Object.keys(out)) out[b] = out[b].sort((a, z) => a.first - z.first).map(({ first, ...c }) => c);
97
+ return out;
98
+ }
99
+
100
+ const list = (root, board) => fold(readLines(ledgerFile(root)))[board] || [];
101
+
102
+ /** THE SINGLE WRITER of premium-charts.jsonl. `v`, `id` (for a new one) and `at` are set here.
103
+ * known = { measures: Set of KR metric ids of the workspace } — a measure outside it is refused. */
104
+ function save(root, input, actor, { now, known } = {}) {
105
+ const c = check(input);
106
+ if (!c.ok) return c;
107
+ const v = c.value;
108
+ const file = ledgerFile(root);
109
+ const have = list(root, v.board);
110
+ const t = now == null ? Date.now() : now;
111
+ let line;
112
+ if (v.remove) {
113
+ if (!have.some((d) => d.id === v.id)) return refuse(404, 'That chart is not on this board.');
114
+ line = { v: 1, ev: 'remove', id: v.id, board: v.board, actor: actor || null, at: new Date(t).toISOString() };
115
+ } else {
116
+ if (v.id !== null && !have.some((d) => d.id === v.id)) return refuse(404, 'That chart is not on this board.');
117
+ if (have.some((d) => d.id !== v.id && norm(d.title) === norm(v.title))) return refuse(409, `“${v.title}” is already a chart on this board.`);
118
+ const ms = known && known.measures;
119
+ if (ms && !ms.has(v.measure)) return refuse(400, `No KR metric record is called “${v.measure}” in this workspace.`);
120
+ const id = v.id || 'pc-' + t.toString(36) + '-' + (readLines(file).length + 1);
121
+ line = { v: 1, ev: 'save', id, board: v.board, measure: v.measure, title: v.title, question: v.question, form: v.form, range: v.range, target: v.target, better: v.better, note: v.note, actor: actor || null, at: new Date(t).toISOString() };
122
+ }
123
+ fs.mkdirSync(path.dirname(file), { recursive: true });
124
+ fs.appendFileSync(file, JSON.stringify(line) + '\n');
125
+ const after = list(root, v.board);
126
+ return { ok: true, chart: v.remove ? null : after.find((d) => d.id === line.id) || null, charts: after };
127
+ }
128
+
129
+ module.exports = { FORMS, TITLE_MAX, QUESTION_MAX, NOTE_MAX, ledgerFile, readLines, check, fold, list, save };
@@ -83,6 +83,7 @@ const MODULES = Object.freeze([
83
83
  'routes-core-docs', // core-documents: the core documents of each level, Draft it (a core-doc run), Issue it and Drop (core-docs.jsonl)
84
84
  'routes-custom-docs', // briefing-premium-adddoc: the documents the PM adds beyond the core set, Add a document (custom-docs.jsonl)
85
85
  'routes-premium-dashboards', // briefing-premium-reports: the dashboards the PM makes on premium Insights (premium-dashboards.jsonl; page-press POST save)
86
+ 'routes-premium-charts', // premium-studio-chart: the charts the PM makes in the Insight Studio (premium-charts.jsonl; page-press POST save)
86
87
  'routes-report-design', // report-design-studio: the design studio (describe, samples, turns, versions, This is it), cycle renders and decisions, speaker notes and pins
87
88
  'routes-report-structure', // report-structure: the structure step (turns, versions, Use this structure, sources and their checks, dry run) and the chart store (GET /api/charts)
88
89
  'routes-refresh', // data-refresh-settings: Settings › Data refresh: what refreshes, when, the refresh log, Refresh now
@@ -5,6 +5,7 @@
5
5
  * model is lib/insights-premium.js build(), made from what the console's Reports tab reads: /api/boards (the board list), the KR metric records of the
6
6
  * workspace with the line status the Calendar's Quarter pane computes from them (routes-c3-strategy.js outcomeOf; /api/c3-strategy itself drops the dated
7
7
  * readings, so the records are read here), and /api/report (the report files). None starts a cold repository read, so this route does not answer 202.
8
+ * premium-studio-chart adds the board's saved charts (lib/premium-charts.js list).
8
9
  * briefing-premium-reports adds the board's saved dashboards (lib/premium-dashboards.js list) and the workspace's GET /api/report-setups answer
9
10
  * (setups, findings, asks). That GET is the console's own read: like the console, it may move old dashboard schedules into recurring reports once
10
11
  * per repository. This route itself writes nothing. The page's presses post to /api/report-setups/* and /api/premium-dashboards/save. */
@@ -48,14 +49,15 @@ module.exports = {
48
49
  } catch (e) { return fail('the KR metric records could not be read: ' + ((e && e.message) || e)); }
49
50
  const reportsOk = !!(rp.body && rp.body.ok !== false);
50
51
  const missing = reportsOk ? [] : ['reports'];
51
- let saved = [];
52
+ let saved = [], mine = [];
52
53
  if (pick && pick.id) { try { saved = PD.list(require('path').resolve(ctx.getWs(pick.ws).root), pick.id); } catch { missing.push('dashboards'); } }
54
+ if (pick && pick.id) { try { mine = require('./premium-charts.js').list(require('path').resolve(ctx.getWs(pick.ws).root), pick.id); } catch { missing.push('saved charts'); } }
53
55
  const su = await via(setups, '/api/report-setups' + q, req, ctx).catch(() => ({ status: 500, body: null }));
54
56
  const setupsOk = su.status === 200 && !!su.body && Array.isArray(su.body.setups);
55
57
  if (!setupsOk) missing.push('report setups');
56
58
  const model = Insights.build({
57
59
  now: Date.now(), board: pick ? { ws: pick.ws, id: pick.id, name: pick.name } : { ws, id: null, name: 'Insights' }, boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })),
58
- outcomes, reports: reportsOk ? rp.body.reports || [] : [], reportsOk, missing, saved,
60
+ outcomes, reports: reportsOk ? rp.body.reports || [] : [], reportsOk, missing, saved, mine,
59
61
  setups: setupsOk ? su.body : null,
60
62
  });
61
63
  ctx.json(res, { ok: true, state: 'ready', model, as_of: Date.now() });
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ /* routes-premium-charts.js — the charts the PM makes in the Insight Studio on the premium Insights page (initiative premium-studio-chart, PRD C1).
3
+ *
4
+ * POST /api/premium-charts/save { ws, board, id?, measure, title, question, form, range, target, better, note, remove? } → { ok, chart, charts }
5
+ * one `save` or `remove` line in <state>/premium-charts.jsonl (lib/premium-charts.js, the one writer)
6
+ *
7
+ * The page reads the charts through GET /api/insights-premium, so this module has no GET.
8
+ *
9
+ * WHO WRITES. As routes-premium-dashboards.js: the POST refuses a request that carries an agent session header (403) and passes pm-guard
10
+ * requirePagePress, the launch nonce and the page's origin. The board must be one of the workspace's boards, and the measure a KR metric record of that
11
+ * workspace. The route stores what the PM chose and nothing else. */
12
+ const guard = require('./pm-guard.js');
13
+ const PC = require('./premium-charts.js');
14
+ const { wsOf, boardIds, krIds } = require('./routes-premium-dashboards.js');
15
+
16
+ const bad = (status, error) => ({ status, body: { ok: false, error } });
17
+
18
+ async function handle(req, res, url, ctx) {
19
+ const send = (r) => { ctx.json(res, r.body, r.status); return true; };
20
+ if (url.pathname !== '/api/premium-charts/save') return send(bad(404, 'no such premium-charts route'));
21
+ if (req.method !== 'POST') return send(bad(405, 'POST only'));
22
+ const read = await ctx.readJson(req);
23
+ if (!read.ok) return send(bad(400, 'the body is not JSON'));
24
+ const body = read.body || {};
25
+ if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a chart. Only a press on the page does'));
26
+ const g = guard.requirePagePress(req, body);
27
+ if (!g.ok) return send(bad(g.status, g.error));
28
+ const w = wsOf(ctx, typeof body.ws === 'string' ? body.ws : '');
29
+ if (!w) return send(bad(404, 'no such workspace'));
30
+ const c = PC.check(body);
31
+ if (!c.ok) return send(bad(c.status, c.error));
32
+ const ids = boardIds(ctx, w);
33
+ if (!ids) return send(bad(503, 'The boards could not be read. Try again in a moment.'));
34
+ if (!ids.has(c.value.board)) return send(bad(404, 'no such board in this workspace'));
35
+ let known = null;
36
+ if (!c.value.remove) {
37
+ const ms = krIds(ctx, w.id);
38
+ if (!ms) return send(bad(503, 'The KR metric records could not be read, so the measure cannot be checked.'));
39
+ known = { measures: ms };
40
+ }
41
+ const r = PC.save(w.root, body, g.actor, { now: Date.now(), known });
42
+ if (!r.ok) return send(bad(r.status, r.error));
43
+ return send({ status: 200, body: { ok: true, chart: r.chart, charts: r.charts } });
44
+ }
45
+
46
+ module.exports = { prefixes: ['/api/premium-charts'], handle };
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * WHO WRITES. The POST refuses a request that carries an agent session header (403), as routes-custom-docs.js does, and passes pm-guard
10
10
  * requirePagePress: the launch nonce and the page's origin. The board must be one of the workspace's boards (routes-boards.js frameFor), and every chart
11
- * must be a KR metric record of that workspace (its `rid`, the id the Insights model gives a chart). The route stores what the PM chose and nothing else: no chart, report or console layout changes. */
11
+ * must be a KR metric record of that workspace (its `rid`, the id the Insights model gives a chart) or a saved chart of the board (premium-studio-chart C2). The route stores what the PM chose and nothing else: no chart, report or console layout changes. */
12
12
  const guard = require('./pm-guard.js');
13
13
  const PD = require('./premium-dashboards.js');
14
14
  const boards = require('./routes-boards.js');
@@ -52,6 +52,7 @@ async function handle(req, res, url, ctx) {
52
52
  if (!c.value.remove) {
53
53
  const ks = krIds(ctx, w.id);
54
54
  if (!ks) return send(bad(503, 'The KR metric records could not be read, so the charts cannot be checked.'));
55
+ for (const pc of require('./premium-charts.js').list(w.root, c.value.board)) ks.add(pc.id); // premium-studio-chart C2: a saved chart of the board
55
56
  known = { charts: ks };
56
57
  }
57
58
  const r = PD.save(w.root, body, g.actor, { now: Date.now(), known });
@@ -59,4 +60,4 @@ async function handle(req, res, url, ctx) {
59
60
  return send({ status: 200, body: { ok: true, dashboard: r.dashboard, dashboards: r.dashboards } });
60
61
  }
61
62
 
62
- module.exports = { prefixes: ['/api/premium-dashboards'], handle };
63
+ module.exports = { prefixes: ['/api/premium-dashboards'], handle, wsOf, boardIds, krIds };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.270.0",
3
+ "version": "0.272.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.270.0",
9
+ "version": "0.272.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.270.0",
3
+ "version": "0.272.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",