create-pmos 0.558.0 → 0.559.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 (35) hide show
  1. package/package.json +14 -14
  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-adddoc-test.js +8 -6
  7. package/workspace/changelog.json +13 -0
  8. package/workspace/fixtures/board-premium-facts.js +2 -12
  9. package/workspace/guide/programs.md +2 -2
  10. package/workspace/lib/board-premium.js +3 -22
  11. package/workspace/lib/core-docs-needs.js +12 -16
  12. package/workspace/lib/core-docs.js +27 -214
  13. package/workspace/lib/coredoc-cli.js +6 -6
  14. package/workspace/lib/custom-docs.js +3 -1
  15. package/workspace/lib/job-graph.js +2 -2
  16. package/workspace/lib/refresh.js +2 -2
  17. package/workspace/lib/route-modules.js +0 -1
  18. package/workspace/lib/routes-board-premium.js +5 -11
  19. package/workspace/lib/routes-core-docs.js +23 -113
  20. package/workspace/lib/routes-custom-docs.js +8 -6
  21. package/workspace/package-lock.json +2 -2
  22. package/workspace/package.json +1 -1
  23. package/workspace/premium-core-doc-issue-test.js +11 -18
  24. package/workspace/public/pm/bd-acts.js +5 -77
  25. package/workspace/public/pm/bd-prog.js +4 -5
  26. package/workspace/public/pm/bd-views.js +4 -56
  27. package/workspace/public/pm/cozy-board.css +2 -24
  28. package/workspace/public/pm/home-app.js +2 -3
  29. package/workspace/public/pm/premium-board.js +6 -24
  30. package/workspace/public/pm/premium-shell.js +3 -33
  31. package/workspace/public/pm/prog-page.js +1 -1
  32. package/workspace/ready-dash-ui-test.js +1 -1
  33. package/workspace/server.js +3 -12
  34. package/workspace/test-lists/uncovered-board.json +1 -1
  35. package/workspace/lib/routes-board-docs.js +0 -46
@@ -1,12 +1,11 @@
1
- /* pm/bd-views.js — the Board's List and By stage views, the phone list and the Documents tab (initiative premium-uncovered-features, Board:
2
- * BdList, BdByStage, BdPhone, BdDocs). Markup from the page's model; the presses go back to the page (premium-board.js) through data- attributes.
1
+ /* pm/bd-views.js — the Board's List and By stage views and the phone list (initiative premium-uncovered-features, Board:
2
+ * BdList, BdByStage, BdPhone). Markup from the page's model; the presses go back to the page (premium-board.js) through data- attributes.
3
3
  * · List (BdList): one table, sorted by need (your turn, blocked, late, at risk, then by stage); a column title sorts by that column.
4
4
  * Monitor and Evaluate sit folded at the foot until "Show them". Each row has ⋯ for its actions (BdActions).
5
5
  * · By stage (BdByStage): one column per stage, a card per initiative; Monitor and Evaluate fold into strips when nothing in them needs
6
6
  * you, and a strip opens its column. A card is dragged to another column to move its stage (POST /api/boards/move, with Undo).
7
7
  * · the phone list (BdPhone): Your turn, At risk or late, On track.
8
- * · Documents (BdDocs): the board's core documents and the documents its initiatives link (PRD, rubric, evaluation, release notes), with
9
- * kind chips, health, when it changed and who changed it (GET /api/board-docs), and a row opens the document's panel.
8
+ * The Documents tab (BdDocs) is gone: batch 24 took it off the Board, and batch 29 item 8 retired the board documents it listed.
10
9
  * Nothing here invents a value: what no record holds is shown as "—" or not drawn. */
11
10
  import { nameHtml } from './split-merge.js'; // Claude suggests a split or a merge: the purple dot after the name (batch 11 item 14)
12
11
  import * as WK from './work-kind.js'; // the kind of work before each title (batch 29 item 11, KdBd)
@@ -17,14 +16,13 @@ import { nextHtml } from './bd-next.js';
17
16
  import { stageName, stageChip } from './stage-chip.js'; // W1: the one stage
18
17
  import { provenStatus, NO_SIGNAL } from './status-proof.js'; // T3: a status renders only with its source and read time
19
18
 
20
- let A = null; // the page: { M(), statusOf(r), usual(t), trail(r), docMeta(path, ws), sel(), groups(L), folded(key), laneHead(g), subTile(name), memberIcon(id), programOf(r), programs(),
19
+ let A = null; // the page: { M(), statusOf(r), usual(t), trail(r), sel(), groups(L), folded(key), laneHead(g), subTile(name), memberIcon(id), programOf(r), programs(),
21
20
  // wf() → { list, cur, ended } the workflows on the board, the picked one (null for All) and the rows that ended (pm/bd-wf.js) }
22
21
  export function init(api) { A = api; }
23
22
  const M = () => A.M();
24
23
  const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
25
24
  const MORE = 'M5 12h.01M12 12h.01M19 12h.01';
26
25
  const cap = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : '');
27
- const plural = (n, a, b) => (n === 1 ? a : b);
28
26
  /** Two letters for an avatar: "Mei" stays "Mei", "Rizky" becomes "Ri", "you" becomes "W"-style initials of the name. */
29
27
  export const initials = (name) => { const s = String(name || '').trim(); if (!s) return ''; const p = s.split(/\s+/); return p.length > 1 ? (p[0][0] + p[1][0]).toUpperCase() : s.length <= 3 ? s : s.slice(0, 2); };
30
28
  export const avatar = (name, cls = '') => (name ? `<span class="bd-av${cls ? ' ' + cls : ''}" title="${esc(name)}" aria-label="${esc(name)}">${esc(initials(name))}</span>` : '<span class="bd-amut">—</span>');
@@ -277,53 +275,3 @@ export function phoneListHtml(L) {
277
275
  if (!L.length) return '<p class="bt-empty">No initiative matches the chips or the filter.</p>';
278
276
  return `<div class="bd-plist">${grp('Your turn', you)}${grp('At risk or late', bad)}${grp('On track', rest)}${grp('No signal', none)}</div>`;
279
277
  }
280
-
281
- /* ── Documents (BdDocs) ───────────────────────────────────────────────────────────────────────────────────────── */
282
- let docKind = 'all';
283
- export function setDocKind(k) { docKind = k || 'all'; }
284
- const DOC_IC = { PRD: 'M7 3h7l5 5v13H7zM14 3v5h5', BRD: 'M7 3h7l5 5v13H7zM14 3v5h5', Rubric: 'M5 12l5 5 9-10', Evaluation: 'M5 20V11M12 20V5M19 20v-6', 'Release notes': 'M4 5h16v14H4zM8 9h8M8 13h5', Board: 'M4 4h16v16H4zM4 9h16M9 9v11' };
285
- const ST_TONE = { ok: 'ok', draft: 'y', stale: 'w', due: 'w', missing: '', linked: '' };
286
- /** Every document the tab lists: the initiatives' own (from the trail's links) and the board's core documents. */
287
- export function docRows() {
288
- const out = [], seen = new Set(), m = M();
289
- for (const r of m.initiatives.list.rows) {
290
- const T = A.trail(r), L = (T && T.links) || {};
291
- const add = (kind, label, path, extra = {}) => { const id = (r.ws ? r.ws + ':' : '') + path; if (!path || seen.has(id)) return; seen.add(id); out.push({ src: 'ini', kind, title: label, path, ini: r, ws, ...extra }); };
292
- const drift = (T && T.drift) || [];
293
- const parts = r.track && r.track.key === 'discover' && T && Array.isArray(T.parts) ? T.parts : null;
294
- const ws = r.ws || m.board.ws || '';
295
- add('PRD', L.prdVersion ? 'PRD v' + String(L.prdVersion).replace(/^v/i, '') : 'PRD', L.prd, { drift, parts });
296
- add('Rubric', 'Rubric', L.rubric); add('Evaluation', 'Evaluation', L.evaluation); add('Release notes', 'Release notes' + (r.release ? ' ' + r.release.name : ''), L.notes, { you: !!(r.track && r.track.you && r.track.key === 'deliver') });
297
- }
298
- for (const d of (m.docs && m.docs.rows) || []) out.push({ src: 'core', kind: 'Board', title: d.title, path: d.path || null, ws: d.ws || m.board.ws || '', d });
299
- return out;
300
- }
301
- /** A row's id: a core document by its key (its path appears only once drafted), an initiative's by its path. */
302
- export const docId = (x) => (x.src === 'core' ? 'core:' + (x.d.ws ? x.d.ws + '/' : '') + x.d.key : (x.ini && x.ini.ws ? x.ini.ws + ':' : '') + x.path);
303
- export function healthOf(x) {
304
- if (x.src === 'core') return { tone: ST_TONE[x.d.st] || '', text: x.d.state || '—' };
305
- if (x.drift && x.drift.length) return { tone: 'w', text: 'Changed after the push' };
306
- if (x.parts) { const d = x.parts.filter((p) => p.done).length; return { tone: d === x.parts.length ? 'ok' : '', text: d === x.parts.length ? 'Complete' : d + ' of ' + x.parts.length + ' parts' }; }
307
- if (x.you) return { tone: 'y', text: 'Waits on your sign-off' };
308
- return { tone: '', text: 'Linked' };
309
- }
310
- export function docsHtml() {
311
- const m = M(), D = m.docs || { rows: [] }, rows = docRows();
312
- const kinds = [...new Set(rows.map((x) => x.kind))];
313
- if (docKind !== 'all' && !kinds.includes(docKind)) docKind = 'all';
314
- const chips = `<div class="bd-dchips" role="group" aria-label="Kind">${[['all', 'All', rows.length]].concat(kinds.map((k) => [k, k, rows.filter((x) => x.kind === k).length])).map(([k, n, c]) => `<button type="button" class="bd-chip${docKind === k ? ' on' : ''}" data-dkind="${esc(k)}" aria-pressed="${docKind === k}">${esc(n)} ${c}</button>`).join('')}<span class="bd-sp"></span>${D.scope ? '<button type="button" class="bd-btn" id="addDoc" data-act="adddoc">Add a document</button>' : ''}</div>`;
315
- const shown = rows.filter((x) => docKind === 'all' || x.kind === docKind);
316
- if (!rows.length) return chips + `<p class="bd-amut">${D.missing ? 'The core documents could not be read, so none is shown.' : 'No document is on this board yet.'}</p>`;
317
- const sel = A.docSel ? A.docSel() : null;
318
- const row = (x) => {
319
- const h = healthOf(x), meta = x.path ? A.docMeta(x.path, x.ws) : null, d = x.d || {};
320
- const changed = x.src === 'core' ? d.when || d.added || '—' : meta && meta.changed ? meta.changed + (x.drift && x.drift.length ? ' · after the push' : '') : '—';
321
- const by = x.src === 'core' ? `<span class="bd-amut">${esc(d.by || '—')}</span>` : meta && meta.by ? avatar(meta.by, 'b') : '<span class="bd-amut">—</span>';
322
- const act = x.src === 'core' && d.act && d.act.kind === 'draft' ? `<button type="button" class="bd-btn sm" data-act="draft" data-key="${esc(d.key)}"${d.ws ? ` data-ws="${esc(d.ws)}"` : ''}${d.running ? ' disabled' : ''}>${d.running ? 'Drafting' : esc(d.act.label || 'Draft it')}</button>` : '';
323
- const id = docId(x);
324
- return `<div class="bd-dt${sel === id ? ' sel' : ''}" role="row" data-docrow="${esc(id)}"><span class="bd-dic" aria-hidden="true">${SV(DOC_IC[x.kind] || DOC_IC.PRD)}</span>`
325
- + `<button type="button" class="bd-dlink" role="rowheader" data-opendoc="${esc(id)}">${esc(x.title)}</button><span role="cell">${esc(x.src === 'core' ? d.product || m.board.name || 'Board' : x.ini.title)}</span>`
326
- + `<span role="cell"><span class="bd-pill${h.tone ? ' ' + h.tone : ''}">${esc(h.text)}</span></span><span role="cell" class="bd-amut">${esc(changed)}</span><span role="cell" class="bd-dby">${by}${act}</span></div>`;
327
- };
328
- return chips + `<div class="bd-dtw" role="table" aria-label="Documents"><div class="bd-dt h" role="row"><span></span><span role="columnheader">Document</span><span role="columnheader">Initiative</span><span role="columnheader">Health</span><span role="columnheader">Changed</span><span role="columnheader">By</span></div>${shown.map(row).join('')}</div>`;
329
- }
@@ -694,7 +694,6 @@ span.tg-end { left: var(--tl-x); cursor: default; } /* a shared board's milest
694
694
  .bd-amut { margin: 0; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
695
695
  .bd-amsg { margin: 0; min-height: 1em; font-size: var(--fs-meta); color: var(--cz-red); line-height: var(--lh-meta); }
696
696
  .bd-amsg:empty { display: none; }
697
- .bd-albl { margin: 6px 0 4px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink3); line-height: var(--lh-label); }
698
697
  .bd-asub { margin: 0; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink2); line-height: var(--lh-label); }
699
698
  .bd-quote { margin: 0; font-size: var(--fs-body); color: var(--cz-ink); background: var(--cz-well); border-radius: 12px; padding: 10px 12px; line-height: var(--lh-body); }
700
699
  .bd-pl { display: flex; flex-direction: column; gap: 10px; }
@@ -710,8 +709,7 @@ span.tg-end { left: var(--tl-x); cursor: default; } /* a shared board's milest
710
709
  .bd-form label em { font-style: normal; font-weight: var(--fw-strong); }
711
710
  .bd-form input:not([type="radio"]):not([type="checkbox"]), .bd-form select, .bd-form textarea { font: var(--fw-regular) var(--fs-meta)/var(--lh-meta) var(--cz-sans); color: var(--cz-ink); background: var(--cz-card); border: 1px solid var(--cz-hair); border-radius: 12px; padding: 8px 10px; min-height: 36px; width: 100%; }
712
711
  .bd-form input:focus-visible, .bd-form select:focus-visible, .bd-form textarea:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
713
- .bd-rad, .bd-chks { display: flex; flex-direction: column; gap: 4px; }
714
- .bd-form .bd-rad label, .bd-chk { flex-direction: row; align-items: center; gap: 8px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink2); cursor: pointer; display: flex; min-height: 28px; line-height: var(--lh-label); }
712
+ .bd-chk { flex-direction: row; align-items: center; gap: 8px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink2); cursor: pointer; display: flex; min-height: 28px; line-height: var(--lh-label); }
715
713
  .bd-alist { display: flex; flex-direction: column; border-top: 1px solid var(--cz-hair); }
716
714
  .bd-ai { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding: 10px 4px; border-bottom: 1px solid var(--cz-hair); }
717
715
  .bd-ai:hover b { color: var(--cz-blueink); }
@@ -735,9 +733,6 @@ button.bd-lr:hover { background: var(--bd-row); }
735
733
  .bd-dlink { all: unset; cursor: pointer; font-weight: var(--fw-strong); color: var(--cz-ink); }
736
734
  .bd-dlink:hover { color: var(--cz-blueink); }
737
735
  .bd-dlink:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
738
- .bd-issue { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 12px; border-radius: 14px; background: var(--cz-bluebg); color: var(--cz-blueink); font-size: var(--fs-label); font-weight: var(--fw-strong); line-height: var(--lh-label); }
739
- .bd-issue.done { background: var(--cz-okbg); color: var(--cz-ok); }
740
- @media (max-width: 720px) { .bd-issue .bd-btn { min-height: 44px; } }
741
736
  .bd-dochd { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 10px; }
742
737
  .bd-dochd .bd-whead { margin: 0; }
743
738
  @media (max-width: 720px) { .bd-dochd .bd-btn { min-height: 44px; } }
@@ -776,7 +771,7 @@ button.bd-lr:hover { background: var(--bd-row); }
776
771
  .bd-lr, .bd-lr.doc { grid-template-columns: minmax(0, 1fr) auto; }
777
772
  .bd-dlink { min-height: 44px; display: inline-flex; align-items: center; }
778
773
  .bd-lr .st, .bd-lr .fin, .bd-lr .pth { display: none; }
779
- .bd-btn, .bd-ai, .bd-chk, .bd-form .bd-rad label { min-height: 44px; }
774
+ .bd-btn, .bd-ai, .bd-chk { min-height: 44px; }
780
775
  .bt-qt { margin-left: 0; }
781
776
  }
782
777
 
@@ -1015,17 +1010,6 @@ button.pk-jt:focus-visible { outline: 2px solid var(--cz-blue); outline-offset:
1015
1010
  .bd-strip span { writing-mode: vertical-rl; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink2); white-space: nowrap; line-height: var(--lh-label); }
1016
1011
  .bd-strip:hover { background: var(--cz-well2); }
1017
1012
  .bd-strip:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
1018
- /* Documents (BdDocs) */
1019
- .bd-dchips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
1020
- .bd-dtw { border: 1px solid var(--cz-hair); border-radius: 18px; overflow: hidden; background: var(--cz-card); }
1021
- .bd-dt { display: grid; grid-template-columns: 30px minmax(0, 1.5fr) minmax(0, 1.2fr) 170px 120px minmax(0, 160px); gap: 0 12px; align-items: center; min-height: 52px; padding: 0 14px; border-top: 1px solid var(--cz-hair); font-size: var(--fs-body); line-height: var(--lh-body); }
1022
- .bd-dt.h { border-top: 0; min-height: 40px; background: var(--cz-well); font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink3); line-height: var(--lh-label); }
1023
- .bd-dt.sel { background: var(--cz-bluebg); }
1024
- .bd-dt > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1025
- .bd-dic { width: 30px; height: 30px; border-radius: 10px; background: var(--cz-well); display: inline-flex; align-items: center; justify-content: center; color: var(--cz-ink2); }
1026
- .bd-dic svg { width: 15px; height: 15px; }
1027
- .bd-dby { display: flex; align-items: center; gap: 8px; }
1028
- .bd-read summary { cursor: pointer; font: var(--fw-strong) var(--fs-label)/var(--lh-label) var(--cz-sans); color: var(--cz-ink2); padding: 4px 0; }
1029
1013
  /* the Sprint span (BdSpans) */
1030
1014
  .sp-cap { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
1031
1015
  .sp { border: 1px solid var(--cz-hair); border-radius: 18px; overflow: hidden; background: var(--cz-card); }
@@ -1075,8 +1059,6 @@ button.sp-n:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: -
1075
1059
  @media (max-width: 1200px) and (min-width: 721px) {
1076
1060
  .bd-lt { grid-template-columns: minmax(160px, 1.6fr) 120px minmax(100px, .9fr) minmax(120px, 1fr) 44px minmax(140px, 1.4fr) 70px 36px; }
1077
1061
  .bd-lt > :nth-child(4) { display: none; }
1078
- .bd-dt { grid-template-columns: 30px minmax(0, 1.5fr) minmax(0, 1fr) 150px 90px; }
1079
- .bd-dt > :nth-child(6) { display: none; }
1080
1062
  }
1081
1063
  @media (max-width: 720px) {
1082
1064
  .bd-pp.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto !important; max-height: 82vh; border-radius: 28px 28px 0 0; padding: 10px 12px 24px; box-shadow: 0 -20px 50px -20px rgba(42,46,53,.35); }
@@ -1085,10 +1067,6 @@ button.sp-n:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: -
1085
1067
  .bd-scols.ph { flex-direction: column; overflow: visible; }
1086
1068
  .bd-scols.ph .bd-scol { min-height: 0; min-width: 0; }
1087
1069
  .bd-bc { min-height: 44px; }
1088
- .bd-dt { grid-template-columns: 30px minmax(0, 1fr) auto; min-height: 56px; }
1089
- .bd-dt > :nth-child(3), .bd-dt > :nth-child(5), .bd-dt > :nth-child(6) { display: none; }
1090
- .bd-dt.h { display: none; }
1091
- .bd-dchips { flex-wrap: nowrap; overflow-x: auto; }
1092
1070
  .bd-bk { grid-template-columns: 70px minmax(0, 1fr) auto; }
1093
1071
  .bd-bk > :nth-child(3), .bd-bk > :nth-child(4) { display: none; }
1094
1072
  .pk-dg { grid-template-columns: 1fr 1fr; }
@@ -1191,8 +1191,8 @@ function openProductPage() {
1191
1191
  }
1192
1192
  /** The product page (feedback batch 21 item 2, canvas RdProgL–RdProgP and rdProgAgreed): the SAME one page as a program's (pm/prog-page.js),
1193
1193
  * with no toggle. Top: the ✦ line, the goal card (short titles, KR chips, Forecast's range bar), Programs and Health budgets cards, and the
1194
- * proposals folded to one row. Tabs: Tasks · Initiatives (opens here) · Reports (the ready reports, the weekly update, the metrics review) ·
1195
- * Documents. The model is GET /api/ready-reports/dashboard scope product; until it answers (or when it cannot) the page draws the parts Home
1194
+ * proposals folded to one row. Tabs: Tasks · Initiatives (opens here) · Reports (the ready reports, the weekly update, the metrics review).
1195
+ * There is no Documents tab: board documents are retired (batch 29 item 8), and a last tab kept as Documents opens Initiatives. The model is GET /api/ready-reports/dashboard scope product; until it answers (or when it cannot) the page draws the parts Home
1196
1196
  * already has (its programs, initiatives and tasks) and the goals line of GET /api/goal-status. g: the product's group in Home's list. */
1197
1197
  const PDASH = new Map(); // ws → { d, open }
1198
1198
  const lateDays = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return null; const t = new Date(); t.setHours(0, 0, 0, 0); return Math.round((t - new Date(+m[1], +m[2] - 1, +m[3])) / 864e5); };
@@ -1237,7 +1237,6 @@ function productPageHtml(x, ws, vid, name, g) {
1237
1237
  + `<section class="pv-card" aria-label="Open tasks"><div class="pv-ch"><h4>Open tasks</h4><small>${T.length}</small></div>${T.filter((t) => !late.slice(0, 3).includes(t)).map(tRow).join('')}</section>` : '<p class="pv-none">No open task on its initiatives.</p>') },
1238
1238
  { id: 'initiatives', label: 'Initiatives', n: inis.length, html: () => (inis.length ? iniCards : '<p class="pv-none">Nothing is open. A new initiative shows here.</p>') },
1239
1239
  { id: 'reports', label: 'Reports', n: reps.length, sig: reps.some((r) => r.state === 'drafted') ? 'ready' : '', html: () => `<div class="db" data-level="product">${d ? DB.trustHtml(d) : ''}${R}</div><section class="pv-card" aria-label="More reports">${extra}</section>` },
1240
- { id: 'documents', label: 'Documents', html: () => '<p class="pv-none">Each initiative keeps its PRD, rubric and release notes on its own page. Open one from Initiatives.</p>' },
1241
1240
  ];
1242
1241
  // "The story so far" (board AwE): the product's Narrative under the top line, a source on every line; the top line says it is the weekly update
1243
1242
  const story = x.story ? ST.storyHtml(x.story, { sources: true }) : '';
@@ -1,15 +1,15 @@
1
1
  /* pm/premium-board.js — the premium Board in the Agreed design (initiative premium-agreed-design: the AgBoard* frames; built on briefing-premium-board).
2
2
  * Reads GET /api/board-premium and draws the model lib/board-premium.js builds from the routes the production Initiatives page reads.
3
3
  * · one toolbar: the product picker, the view toggle, Find, Filter, the shell's bell, New initiative and the shell's ⋯ menu; under it the
4
- * Initiatives and Documents tabs and the chips (Jira read time, sprint and release, new asks, late, at risk, blocked, idle, This sprint).
4
+ * Initiatives and Shared with me tabs and the chips (Jira read time, sprint and release, new asks, late, at risk, blocked, idle, This sprint).
5
5
  * · the stage track (default): each initiative is a row across the six stages and two milestones (◆), with the parts or tickets counted
6
6
  * toward the output that finishes its current step. Monitor and Evaluate rows fold under the table after the first of each.
7
7
  * · List and By stage (pm/bd-views.js; BdList, BdByStage) and the timeline (pm/bd-span.js, scrolled by pm/bd-scroll.js): Sprint, Quarter, Half,
8
8
  * Year, 2 yr and 5 yr, the same rows on every span from Quarter on (feedback batch 7, timeline spans C).
9
9
  * · a row opens the initiative panel and a ticket opens the Jira ticket panel, in the side panel (a bottom sheet on a phone).
10
10
  * · the Board has no chat: "Ask about this" sends the question to Home (/premium.html?ask=<initiative>&q=<question>).
11
- * The uncovered features (initiative premium-uncovered-features: BdList, BdByStage, BdDocs, BdSpans, BdAsks, BdNew, BdGrill, BdActions, BdFilter,
12
- * BdSprint, BdPanel, BdPhone, BdHead) are drawn by pm/bd-views.js (the views and Documents), pm/bd-asks.js (new asks, New initiative and its first
11
+ * The uncovered features (initiative premium-uncovered-features: BdList, BdByStage, BdSpans, BdAsks, BdNew, BdGrill, BdActions, BdFilter,
12
+ * BdSprint, BdPanel, BdPhone, BdHead) are drawn by pm/bd-views.js (the views), pm/bd-asks.js (new asks, New initiative and its first
13
13
  * questions), pm/bd-acts.js (the row actions, Find, Filter, the sprint and release, the trends, the document panel) and pm/bd-pop.js (popovers).
14
14
  * A phone has List, By stage, the stage track and the timeline (BdPhone, TsCPhone), with one span picker beside the product picker.
15
15
  * After the model, GET /api/board-trail (lib/board-trail.js) adds what the model does not carry: days in the step and the usual days, the
@@ -93,7 +93,6 @@ let PKP = null, picked = false; // the saved pick (GET /api/briefing-premium/p
93
93
  let grouping = ['program', 'product', 'goal'].includes(store.get(GROUPING_KEY)) ? store.get(GROUPING_KEY) : 'goal';
94
94
  let byProduct = grouping === 'product';
95
95
  let GOALS = null, goalsFor = ''; // GET /api/artefacts/goals for the rows on screen ({ goals, of }), and the rows it was read for
96
- let DM = {}; // the documents' history (GET /api/board-docs): { [path]: { changed, by, log } }
97
96
  let peek = null; // what the Viewer shows for the Board: { kind: 'ini', key } an initiative or its ticket, { kind: 'acts' } an acts panel
98
97
  mountNav('board', document, { scope: () => Acts.findScope() }); // ⌘K and Find open Search scoped to this Board first (UI grill U2)
99
98
  quietPlace('board', document.getElementById('stage'));
@@ -928,7 +927,7 @@ $('#bdFilter').addEventListener('click', (e) => Acts.open.filter(e.currentTarget
928
927
  // and that press opens New initiative at once.
929
928
  $('#newIni').addEventListener('click', (e) => { if (e.isTrusted) Asks.openNewMenu(e.currentTarget); else Acts.open.new(e.currentTarget); });
930
929
 
931
- /* ── tabs: Initiatives and Documents (Documents has no frame yet: a plain list) ──────────────────────────────────────────────────────── */
930
+ /* ── tabs: Initiatives and Shared with me ──────────────────────────────────────────────────────── */
932
931
  let SH_PASTE = ''; // ?shared=<link>: Open in my PMOS on a shared board (batch 27 item 3) lands on Shared with the link in the paste field
933
932
  function setTab(t) {
934
933
  tab = t;
@@ -940,23 +939,6 @@ function setTab(t) {
940
939
  function setSharedCount(n) { SH_N = n; if (menuOpen('bdViewMenu')) drawViewMenu(); }
941
940
  document.addEventListener('bd:links', (e) => { if (!SH_FULL && e.detail) setSharedCount(e.detail.n); });
942
941
 
943
- /** The history of the documents (GET /api/board-docs) for the document panel of pm/bd-acts.js. Batch 24 item 7 took the Documents tab off the Board,
944
- * so nothing on the Board opens that panel now; it is kept for a later way in (see the PR).: when each last changed, by whom, its last commits. Read-only. */
945
- async function loadDocMeta(list) {
946
- if (!M) return;
947
- // each document is read from its own product's workspace (All products lists every product's documents)
948
- const here = M.board.ws || '', want = (list || V.docRows()).map((x) => ({ path: x.path, ws: x.ws || here })).filter((x) => x.path && !DM[x.ws + ':' + x.path]).slice(0, 40);
949
- if (!want.length) return;
950
- const by = new Map(); for (const x of want) { if (!by.has(x.ws)) by.set(x.ws, []); by.get(x.ws).push(x.path); }
951
- let got = false;
952
- for (const [ws, P] of by) {
953
- let r = null; try { r = await (await fetch('/api/board-docs?ws=' + encodeURIComponent(ws) + '&paths=' + P.map(encodeURIComponent).join(','), { credentials: 'same-origin' })).json(); } catch { r = null; }
954
- if (!r || !r.ok) continue;
955
- for (const p of P) DM[ws + ':' + p] = r.docs[p] || { none: true };
956
- got = true;
957
- }
958
- }
959
- const docMeta = (p, ws) => { const d = DM[(ws || (M && M.board.ws) || '') + ':' + p]; return d && !d.none ? d : null; };
960
942
 
961
943
  /* ── the shell's bell sits before New initiative, as the design orders the tools; Escape closes a popover, then the panel ──────── */
962
944
  /* the ⋯ menu (UI grill U2): Publish a read-only copy and Cancelled and archived, nothing else. The shell's Sources, Theme and Settings rows
@@ -1221,12 +1203,12 @@ function openFindings(r, from) {
1221
1203
  }
1222
1204
  FCC.init({ rowOf: (k) => rowOf(k), openFindings });
1223
1205
  const openIniAny = (r) => { if (r && curView() === 'time') TL.reveal(r.key); openIni(r, $('#chNeed') || $('#bdFind'), 'track'); };
1224
- V.init({ M: () => M, wf: wfState, statusOf, usual: usualOf, trail: TI, docMeta, sel: () => (peek && peek.kind !== 'acts' ? peek.key : null), docSel: () => Acts.docSel(),
1206
+ V.init({ M: () => M, wf: wfState, statusOf, usual: usualOf, trail: TI, sel: () => (peek && peek.kind !== 'acts' ? peek.key : null),
1225
1207
  groups: (L) => groups(L), folded: PG.folded, laneHead: (g) => (g.kind === 'goal' ? GL.laneHtml(g, !PG.folded(g.key)) : PG.laneHtml(g, g.kind === 'program' ? progState(g.program) : null)), progGroups: (L) => progGroups(L), subTile: (n) => PG.tileHtml(n, 'bd-ti s'),
1226
1208
  memberIcon: (id) => PG.memberIcon(PGS, id), product: () => (M.board.product || M.board.name || ''), programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), tileHtml: PG.tileHtml, progTile: PG.progTile });
1227
1209
  Asks.init({ M: () => M, load, say, panel: actsPanel, close: closePanel, rowOf, openIni: openIniAny, openDoc: viewDoc, anchors, programs: () => PGS, reloadPrograms: loadPrograms });
1228
1210
  Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePanel, redraw: () => { drawChips(); drawInit(); }, F, rowOf, statusOf, openIni: openIniAny,
1229
- openTicket: (ini, tk) => openTicket(ini, tk, $('#bdFind')), askHref, pageHref, trail: TI, docMeta, loadDocMeta, viewDoc,
1211
+ openTicket: (ini, tk) => openTicket(ini, tk, $('#bdFind')), askHref, pageHref, trail: TI, viewDoc,
1230
1212
  grouping: () => ({ on: groupingOn(), byProduct, by: grouping === 'goal' && !goalsHere() ? (groupingOn() ? 'program' : 'product') : grouping, goal: goalsHere() }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time',
1231
1213
  tune: tuneParts, sprintOnly, toggleSprintOnly: () => { if (F.chips.has('sprint')) F.chips.delete('sprint'); else F.chips.add('sprint'); }, sortPick, refreshJira: () => refreshJira() });
1232
1214
  BI.mount({ M: () => M, statusOf, dayTitle, usual: usualOf, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
@@ -932,35 +932,6 @@ export function wireCrumb(o) {
932
932
  });
933
933
  }
934
934
 
935
- /* ── Add a document: the dialog the Board and the initiative page share (initiative briefing-premium-adddoc) ──────────────────────────────────
936
- * o = { ws, scope: 'board:<id>' | 'initiative:<id>', sub, onAdded }. The one press posts to POST /api/custom-docs/add and nothing else. */
937
- export function openAddDoc(o) {
938
- const ini = String(o.scope).startsWith('initiative:'), phases = ['Discover', 'Plan', 'Build', 'Evaluate'];
939
- const form = `<div class="addf"><p class="note" style="margin:0">Add a document the core set does not cover, for example a research plan, a UAT plan or a contract. It is saved on the ${ini ? 'initiative' : 'board'}'s record with the address of a copy that lives in Confluence or Google Docs. PMOS does not read or sync that page.</p>
940
- <label>Title<input id="adT" maxlength="80" placeholder="For example: UAT plan"></label>
941
- ${ini ? `<label>Phase<select id="adC">${phases.map((k) => `<option>${k}</option>`).join('')}</select></label>` : ''}
942
- <div><span class="label">Who writes it</span><div class="seg" id="adW" role="group" aria-label="Who writes it"><i class="pill"></i><button type="button" data-w="drafts" aria-pressed="true">PMOS drafts it</button><button type="button" data-w="you" aria-pressed="false">I write it</button></div></div>
943
- <div><span class="label">Where it lives</span><div class="two"><label><select id="adK" aria-label="Where it lives"><option value="">In PMOS</option><option>Confluence</option><option>Google Docs</option><option>Google Slides</option></select></label><label><input id="adU" maxlength="300" placeholder="Paste the page address" aria-label="Page address" disabled></label></div></div>
944
- <p class="note" id="adM" role="status" style="margin:0;min-height:1.2em"></p><div class="cact"><button class="cta" id="adGo">Add document</button><button class="cta alt" id="adNo">Cancel</button></div></div>`;
945
- openDlg({ eye: 'New document · real data', title: 'Add a document', sub: o.sub, say: 'Name the document and say who writes it. It is saved on the record.', stream: turnA(ptx('Name the document and say who writes it. I save it on the record and change nothing else. A linked page is kept as an address only.')), noteKey: popKey('new-doc', o.scope), pane: `<article class="paper doc">${form}</article>`, label: 'Document' });
946
- pillOf($('#adW'));
947
- let who = 'drafts';
948
- $('#oMain').onchange = (e) => { if (e.target.id === 'adK') { $('#adU').disabled = !e.target.value; if (e.target.value) $('#adU').focus(); } };
949
- $('#oMain').onclick = async (e) => {
950
- const w = e.target.closest('[data-w]');
951
- if (w) { who = w.dataset.w; $$('#adW button').forEach((x) => x.setAttribute('aria-pressed', x === w)); pillOf($('#adW')); return; }
952
- if (e.target.closest('#adNo')) { closeDlg(); return; }
953
- if (!e.target.closest('#adGo')) return;
954
- const title = $('#adT').value.trim(), m = $('#adM'), kind = $('#adK').value, url = ($('#adU').value || '').trim();
955
- if (!title) { m.textContent = 'Give the document a title.'; $('#adT').focus(); return; }
956
- if (kind && !url) { m.textContent = 'Paste the address of the ' + kind + ' page, or choose In PMOS.'; $('#adU').focus(); return; }
957
- const go = $('#adGo'); go.disabled = true;
958
- const res = await pmPost('/api/custom-docs/add', { ws: o.ws, scope: o.scope, title, writer: who, phase: ini ? document.getElementById('adC').value : undefined, kind: kind || undefined, url: kind ? url : undefined });
959
- if (!res || res.ok !== true) { go.disabled = false; m.textContent = (res && res.error) || 'The document could not be added.'; return; }
960
- toast('Document added. It is saved on the record.'); closeDlg(); if (o.onAdded) await o.onAdded();
961
- };
962
- }
963
-
964
935
  /* ── Search (Ctrl K or "/") and the agent inbox (initiative premium-search-bell). Reads only; a press goes to a page.
965
936
  * The Agreed design draws no bell, so none is drawn: the inbox is still read (its count, its toast and the panel premium.js opens). ── */
966
937
  const SRCH = '<svg class="i" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>';
@@ -1002,7 +973,7 @@ function pvOpen(kind) {
1002
973
  $$('main.stage').forEach((x) => { x.inert = true; }); document.documentElement.style.overflow = 'hidden';
1003
974
  if (homeDock()) $('#dlg').inert = true;
1004
975
  const o = $('#pvOv'); o.className = 'pv-ov ' + kind; o.setAttribute('aria-label', kind === 'pal' ? 'Search' : 'Needs you'); o.hidden = false; o.inert = false; $('#pvScrim').classList.add('on');
1005
- if (kind === 'pal') { o.innerHTML = '<div class="pv-pin">' + SRCH + '<input id="pvQ" type="text" placeholder="Search places, initiatives, documents and sessions" aria-label="Search" autocomplete="off" role="combobox" aria-expanded="true" aria-controls="pvList"><kbd>Esc</kbd></div><div id="pvList" role="listbox" aria-label="Results"></div><p class="pv-note">Ctrl K or / opens this from any page. Arrow keys move, Enter opens.</p>'; $('#pvQ').focus(); pvPal(); }
976
+ if (kind === 'pal') { o.innerHTML = '<div class="pv-pin">' + SRCH + '<input id="pvQ" type="text" placeholder="Search places, initiatives and sessions" aria-label="Search" autocomplete="off" role="combobox" aria-expanded="true" aria-controls="pvList"><kbd>Esc</kbd></div><div id="pvList" role="listbox" aria-label="Results"></div><p class="pv-note">Ctrl K or / opens this from any page. Arrow keys move, Enter opens.</p>'; $('#pvQ').focus(); pvPal(); }
1006
977
  else { o.innerHTML = '<div class="pv-hd"><h2>Needs you</h2><small id="pvN"></small><button type="button" class="ib-all" id="ibAll" hidden>Mark all seen</button></div><div id="pvList" class="pv-lst"></div>'; pvBellDraw(); pvNeeds(); ibRead(); }
1007
978
  }
1008
979
  /* A session opens in Home's chat: in place on Home, or Home opens on it (?session=<id>, read at the end of this file). Never the console. */
@@ -1010,12 +981,11 @@ const pvGo = (it) => { pvClose(); if (it.sid && pvOnBriefing()) { openSessionAt(
1010
981
  const pvRow = (it, i, sel) => `<button type="button" class="pv-row" role="option" id="pvo${i}" data-i="${i}" aria-selected="${sel}"><span class="gl">${GL[it.gl]}</span><span><b>${esc(it.t)}</b>${it.s ? `<small>${esc(it.s)}</small>` : ''}</span></button>`;
1011
982
  async function pvPal() {
1012
983
  if (!pvOv.pal) {
1013
- const [b, d, s] = await Promise.all([pvGet('/api/boards/backlog?limit=200' + pvQ('&')), pvGet('/api/core-docs?level=board' + pvQ('&')), pvGet('/api/sessions')]);
984
+ const [b, s] = await Promise.all([pvGet('/api/boards/backlog?limit=200' + pvQ('&')), pvGet('/api/sessions')]); // board documents are retired (batch 29 item 8): nothing to search
1014
985
  const miss = [];
1015
986
  const ini = b.j && b.j.ok && Array.isArray(b.j.rows) ? b.j.rows.map((r) => ({ g: 'Initiatives', gl: 'ini', t: r.title || r.id, s: [r.lane, r.stage].filter(Boolean).join(' · '), go: '/premium-initiative.html?id=' + encodeURIComponent(r.id) + (b.j.ws ? '&ws=' + encodeURIComponent(b.j.ws) + '&board=' + encodeURIComponent(b.j.board) : '') })) : (miss.push('initiatives'), []);
1016
- const docs = d.j && d.j.ok && Array.isArray(d.j.docs) ? d.j.docs.map((x) => ({ g: 'Documents', gl: 'doc', t: x.title || x.key, s: d.j.scope && d.j.scope.name ? d.j.scope.name : 'Board', go: '/premium-board.html' + pvQ('?') })) : (miss.push('documents'), []);
1017
987
  const ses = s.j && Array.isArray(s.j.sessions) ? s.j.sessions.filter((x) => !x.automatic).map((x) => ({ g: 'Sessions', gl: 'ses', t: x.name || x.id, s: [x.cwd && x.cwd !== '.' ? x.cwd : '', x.state].filter(Boolean).join(' · '), sid: x.id, go: '/premium.html?' + ['session=' + encodeURIComponent(x.id), PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&') })) : (miss.push('sessions'), []);
1018
- pvOv.pal = { items: [...PLACES.map(([t, go]) => ({ g: 'Places', gl: 'place', t, s: 'Place', go })), ...ini, ...docs, ...ses], miss };
988
+ pvOv.pal = { items: [...PLACES.map(([t, go]) => ({ g: 'Places', gl: 'place', t, s: 'Place', go })), ...ini, ...ses], miss };
1019
989
  }
1020
990
  if (pvOv.kind === 'pal') pvPalDraw();
1021
991
  }
@@ -9,7 +9,7 @@
9
9
  * goal html of the goal card: the goal's short title with its KR chip, its range bar, and the milestones inside it
10
10
  * cards html of more cards in the top area (a product: Programs, Health budgets)
11
11
  * props { n, sub, html } the proposals that wait on the owner, folded to one row; never on a shared board (RdProgO)
12
- * tabs [{ id: 'tasks'|'initiatives'|'reports'|'documents', label, n?, sig?: 'late'|'ready', html() }]
12
+ * tabs [{ id: 'tasks'|'initiatives'|'reports'|'documents' (a program only), label, n?, sig?: 'late'|'ready', html() }]
13
13
  * shared true on a teammate's read-only copy
14
14
  * }
15
15
  * tabOf(page) the tab that opens: the viewer's last one on this page, else Initiatives (Wawan 2026-11-01: "initiative as default")
@@ -194,7 +194,7 @@ const SPONSORS = '# Inline login slips to early December unless passkeys move to
194
194
  await pg.goto(BASE + '/premium.html?ini=product');
195
195
  // batch 21 item 2: the product page is the same ONE page as a program's (prog-page.js): no toggle, Initiatives open first
196
196
  const pd = await until(() => pg.evaluate(() => { const v = document.querySelector('#czViewer .pv'); if (!v) return null; return { goal: !!v.querySelector('.pv-gc'), tabs: [...v.querySelectorAll('[data-pv="tab"]')].map((t) => t.dataset.k + (t.getAttribute('aria-selected') === 'true' ? '*' : '')), over: v.scrollWidth > v.clientWidth + 1, toggle: !!document.querySelector('#czViewer [data-cz-vw-p="dash"]') }; }), 15000);
197
- ok('P (' + nm + ') the product page is the one page: the goal card, Tasks, Initiatives (open first), Reports, Documents; no toggle', !!pd && pd.goal && pd.tabs.join() === 'tasks,initiatives*,reports,documents' && !pd.toggle && !pd.over, JSON.stringify(pd));
197
+ ok('P (' + nm + ') the product page is the one page: the goal card, Tasks, Initiatives (open first), Reports (batch 29 item 8 took Documents off); no toggle', !!pd && pd.goal && pd.tabs.join() === 'tasks,initiatives*,reports' && !pd.toggle && !pd.over, JSON.stringify(pd));
198
198
  await pg.click('#czViewer [data-pv="tab"][data-k="reports"]');
199
199
  ok('P (' + nm + ') the Reports tab has no Metrics review row: it is Intelligence › Delivery trends now', await pg.evaluate(() => !document.querySelector('#czViewer [data-hp="metrics"]')));
200
200
  ok('P (' + nm + ') read as a page to read (scope product)', gets.some((g) => g.scope === 'product' && g.from === 'read'), JSON.stringify(gets));
@@ -3208,18 +3208,9 @@ const metricReadTick = () => { try { metricReadRuns.tick({}); } catch (e) { warn
3208
3208
  // Grill that listens for it) needs no page open (lib/forecast-tick.js). PMOS_FORECAST=off stops it.
3209
3209
  const forecastTicker = require('./lib/forecast-tick.js').create({ ctx: { getWs, stateDirFor, workspaceList: () => [...workspaces.values()], runtimeDir: STATE, invalidateNeedsAgg, metricReadHours, proSettings, selfRoot: EMBEDDED_SELF ? SELF_ROOT : null } });
3210
3210
  const forecastTick = () => { forecastTicker.tick().catch((e) => warnWriteFail('forecast tick', e)); };
3211
- // core-documents: every 30 minutes inside the working hours, ONE headless run per due core document of the portfolio and of each board
3212
- // (at most 3 at once, once per document per day, never one the PM writes). The run writes a draft with `pmos coredoc write`; nothing is sent.
3213
- // PMOS_CORE_DOCS_NOW (a local date-time) fixes its clock for the suites.
3214
- const coreDocsTick = () => {
3215
- let m; try { m = require('./lib/routes-core-docs.js'); } catch { return; }
3216
- const t = process.env.PMOS_CORE_DOCS_NOW ? Date.parse(process.env.PMOS_CORE_DOCS_NOW) : NaN;
3217
- try {
3218
- m.tick({ getWs, stateDirFor, workspaceList: () => [...workspaces.values()], runtimeDir: STATE, selfRoot: EMBEDDED_SELF ? SELF_ROOT : null, initiativeIndex,
3219
- spawnSession: orchSpawn.spawn, stopSession: (id) => { const x = sessions.get(String(id || '')); if (x && x.child) stopHeadless(x); }, invalidateNeedsAgg,
3220
- proSettings, inQuiet: (now, quiet) => proactiveLib.inQuietHours(now, quiet), deepOpen: (st, now) => deepOpenNow(now), isLead: (w) => isPlanNeedsTree(w) }, Number.isFinite(t) ? { now: t } : {});
3221
- } catch (e) { warnWriteFail('core documents tick', e); }
3222
- };
3211
+ // core-documents: the tick drafted the due portfolio and board documents. Those are retired (feedback batch 29 item 8), so it drafts
3212
+ // nothing; the step stays so the queue and the Sources row keep their shape. An initiative document is drafted by Draft it or the driver.
3213
+ const coreDocsTick = () => {};
3223
3214
  /** One needs-you item, so it shows in the bell. */
3224
3215
  function tellNeed(ws, runId, label, question) {
3225
3216
  const w = getWs(ws || '') || homeWorkspace(); const nf = w ? needsFileFor(w) : null; if (!nf) return;
@@ -1,5 +1,5 @@
1
1
  {
2
- "_comment": "premium-uncovered-features, Board: a new initiative's Why, material and first questions (lib/board-grill.js, POST/GET /api/board-grill) and the Documents tab's edit history (GET /api/board-docs). Node, scratch state folder.",
2
+ "_comment": "premium-uncovered-features, Board: a new initiative's Why, material and first questions (lib/board-grill.js, POST/GET /api/board-grill) (GET /api/board-docs is retired with the board documents, batch 29 item 8). Node, scratch state folder.",
3
3
  "modules": [
4
4
  "board-grill.test.js"
5
5
  ],
@@ -1,46 +0,0 @@
1
- 'use strict';
2
- /* routes-board-docs.js — GET /api/board-docs?ws=<id>&paths=<path,path,…> (initiative premium-uncovered-features, Board: BdDocs).
3
- *
4
- * 200 { ok, docs: { [path]: { changed, at, by, log: [{ at, by, subject }] } } } when each document last changed, by whom, and its last five commits
5
- * 400 { ok: false, error } — no path, or a path outside the repository · 404 — the workspace is not registered
6
- * Read-only: `git log` on the workspace's repository. A path git has no history for (a new file, no repository) is left out, so the
7
- * Documents tab shows "—" for it rather than a guess. At most 40 paths per call. */
8
- const path = require('path');
9
- const { execFileSync } = require('child_process');
10
-
11
- const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
12
- const day = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Number(m[3]) + ' ' + MON[Number(m[2]) - 1] : ''; };
13
- const PATH_RE = /^[\w@][\w@ .()/-]{0,300}$/;
14
-
15
- /** The last commits of one file, newest first. → [{ at, by, subject }] (empty when git knows none). */
16
- function logOf(root, rel) {
17
- let out = '';
18
- try { out = execFileSync('git', ['log', '-n', '5', '--format=%cI%x09%an%x09%s', '--', rel], { cwd: root, encoding: 'utf8', timeout: 4000, stdio: ['ignore', 'pipe', 'ignore'] }); } catch { return []; }
19
- return out.split('\n').filter(Boolean).map((l) => { const [at, by, ...s] = l.split('\t'); return { at, by, subject: s.join('\t').slice(0, 160) }; });
20
- }
21
- /** The answer for a list of paths. Pure over `log` (a stand-in in the unit test). */
22
- function docsOf(root, paths, log = logOf) {
23
- const docs = {};
24
- for (const p of paths) {
25
- const L = log(root, p);
26
- if (!L.length) continue;
27
- docs[p] = { changed: day(L[0].at), at: L[0].at, by: L[0].by, log: L.map((x) => ({ at: day(x.at), by: x.by, subject: x.subject })) };
28
- }
29
- return docs;
30
- }
31
-
32
- module.exports = {
33
- prefixes: ['/api/board-docs'],
34
- docsOf,
35
- handle: async (req, res, url, ctx) => {
36
- if (url.pathname !== '/api/board-docs') return false;
37
- if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
38
- const paths = String(url.searchParams.get('paths') || '').split(',').map((s) => s.trim()).filter(Boolean).slice(0, 40);
39
- if (!paths.length) { ctx.json(res, { ok: false, error: 'name the documents: paths=<path,path,…>' }, 400); return true; }
40
- if (!paths.every((p) => PATH_RE.test(p) && !p.split('/').includes('..') && !path.isAbsolute(p))) { ctx.json(res, { ok: false, error: 'a path must stay inside the repository' }, 400); return true; }
41
- const w = ctx.getWs ? ctx.getWs(url.searchParams.get('ws') || null) : null;
42
- if (!w || !w.root) { ctx.json(res, { ok: false, error: 'that workspace is not registered' }, 404); return true; }
43
- ctx.json(res, { ok: true, docs: docsOf(w.root, paths) });
44
- return true;
45
- },
46
- };