create-pmos 0.610.0 → 0.612.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 +135 -27
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/board-columns-test.js +2 -1
- package/workspace/board-deliveries-test.js +2 -1
- package/workspace/board-programs-test.js +7 -3
- package/workspace/board-publish-ui-test.js +2 -1
- package/workspace/board-shared-ui-test.js +2 -1
- package/workspace/board-workflows-test.js +2 -1
- package/workspace/briefing-premium-board-test.js +3 -2
- package/workspace/briefing-premium-calendar-2-test.js +3 -2
- package/workspace/briefing-premium-calendar-3-test.js +1 -1
- package/workspace/briefing-premium-calendar-test.js +1 -1
- package/workspace/briefing-premium-doc-edit-test.js +2 -1
- package/workspace/briefing-premium-insights-test.js +4 -3
- package/workspace/briefing-premium-test.js +3 -2
- package/workspace/calm-timeline-test.js +2 -1
- package/workspace/changelog.json +134 -0
- package/workspace/core-docs-workflow-test.js +2 -1
- package/workspace/ev-everywhere-test.js +3 -2
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +4 -0
- package/workspace/guide/layout.md +97 -3
- package/workspace/guide/programs.md +16 -2
- package/workspace/guide/routine.md +65 -0
- package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
- package/workspace/guide/settings-and-switches.md +2 -2
- package/workspace/impact-screens-test.js +3 -1
- package/workspace/ini-workflow-test.js +2 -1
- package/workspace/lib/board-premium.js +12 -4
- package/workspace/lib/classic-board.js +15 -0
- package/workspace/lib/cos-chat.js +1 -0
- package/workspace/lib/doc-library.js +43 -12
- package/workspace/lib/doc-path.js +30 -0
- package/workspace/lib/engine/boards.js +4 -2
- package/workspace/lib/events-place.js +368 -0
- package/workspace/lib/events-stated.js +129 -0
- package/workspace/lib/initiative-chat.js +1 -0
- package/workspace/lib/insights-premium.js +13 -1
- package/workspace/lib/library-find.js +162 -0
- package/workspace/lib/library-items.js +250 -0
- package/workspace/lib/notes.js +9 -1
- package/workspace/lib/plan-items.js +17 -3
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-artefacts.js +5 -2
- package/workspace/lib/routes-boards.js +6 -2
- package/workspace/lib/routes-doc-sheet.js +1 -0
- package/workspace/lib/routes-events-place.js +203 -0
- package/workspace/lib/routes-library.js +155 -0
- package/workspace/lib/routes-pop-work.js +39 -0
- package/workspace/lib/routes-report-setups.js +32 -1
- package/workspace/lib/routes-today-log.js +48 -0
- package/workspace/lib/routine-reports.js +84 -0
- package/workspace/lib/status-when.js +36 -0
- package/workspace/lib/task-items.js +5 -3
- package/workspace/lib/today-log.js +131 -0
- package/workspace/live-pill-round-test.js +10 -7
- package/workspace/metric-drafts-ui-test.js +3 -1
- package/workspace/milestone-pins-test.js +2 -1
- package/workspace/milestone-suggest-test.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +2 -1
- package/workspace/premium-board-actions-test.js +3 -1
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-backlog-test.js +3 -1
- package/workspace/premium-vw-item-test.js +3 -1
- package/workspace/premium-vw-jira-test.js +3 -1
- package/workspace/premium-vw-meet-test.js +2 -1
- package/workspace/premium-vw-notes-test.js +3 -2
- package/workspace/product-lane-test.js +2 -1
- package/workspace/program-charter-test.js +3 -1
- package/workspace/program-leave-test.js +2 -1
- package/workspace/program-order-test.js +2 -1
- package/workspace/program-panel-test.js +3 -1
- package/workspace/public/pm/artefact-kind.js +87 -0
- package/workspace/public/pm/bd-ini-panel.js +77 -12
- package/workspace/public/pm/bd-prog-panel.js +55 -8
- package/workspace/public/pm/bd-span.js +5 -0
- package/workspace/public/pm/bd-work.css +192 -0
- package/workspace/public/pm/bd-work.js +483 -0
- package/workspace/public/pm/cozy-bar.css +11 -0
- package/workspace/public/pm/cozy-bar.js +99 -0
- package/workspace/public/pm/cozy-day-pick.css +27 -0
- package/workspace/public/pm/cozy-day-pick.js +97 -0
- package/workspace/public/pm/cozy-ev.css +2 -5
- package/workspace/public/pm/cozy-events-view.js +274 -0
- package/workspace/public/pm/cozy-events.css +179 -0
- package/workspace/public/pm/cozy-events.js +278 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-goals.css +172 -0
- package/workspace/public/pm/cozy-library.css +125 -0
- package/workspace/public/pm/cozy-live-pill.js +1 -0
- package/workspace/public/pm/cozy-nav.js +6 -7
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pop-work.css +224 -0
- package/workspace/public/pm/cozy-pop-work.js +668 -0
- package/workspace/public/pm/cozy-popup.css +11 -2
- package/workspace/public/pm/cozy-popup.js +67 -9
- package/workspace/public/pm/cozy-routine-job.js +203 -0
- package/workspace/public/pm/cozy-routine-model.js +219 -0
- package/workspace/public/pm/cozy-routine-pop.js +318 -0
- package/workspace/public/pm/cozy-routine.css +155 -0
- package/workspace/public/pm/cozy-routine.js +335 -0
- package/workspace/public/pm/cozy-schedwork.js +6 -5
- package/workspace/public/pm/cozy-settings.js +1 -5
- package/workspace/public/pm/cozy-status-when.js +48 -0
- package/workspace/public/pm/cozy-today-app.js +236 -0
- package/workspace/public/pm/cozy-today-model.js +176 -0
- package/workspace/public/pm/cozy-today-page.css +100 -0
- package/workspace/public/pm/cozy-today-view.js +76 -0
- package/workspace/public/pm/cozy-viewer.js +19 -8
- package/workspace/public/pm/cozy-vw-mtg.css +39 -0
- package/workspace/public/pm/goals-model.js +205 -0
- package/workspace/public/pm/goals-open.js +124 -0
- package/workspace/public/pm/home-app.js +18 -3
- package/workspace/public/pm/home-chat.js +4 -2
- package/workspace/public/pm/home-ini.js +43 -10
- package/workspace/public/pm/ini-edit.js +3 -1
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/library-model.js +197 -0
- package/workspace/public/pm/library-open.js +37 -0
- package/workspace/public/pm/page-chat.js +12 -2
- package/workspace/public/pm/pop-work-model.js +493 -0
- package/workspace/public/pm/premium-board.js +204 -17
- package/workspace/public/pm/premium-goals.js +213 -0
- package/workspace/public/pm/premium-library.js +436 -0
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +79 -1
- package/workspace/public/pm/scope-chip.js +204 -0
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-events.html +44 -0
- package/workspace/public/premium-goals.html +37 -0
- package/workspace/public/premium-library.html +39 -0
- package/workspace/public/premium-routine.html +33 -0
- package/workspace/public/today.html +50 -0
- package/workspace/ready-dash-ui-test.js +3 -1
- package/workspace/rename-test.js +2 -1
- package/workspace/run-tests.js +4 -1
- package/workspace/server.js +4 -2
- package/workspace/sort-order-test.js +2 -1
- package/workspace/split-merge-ui-test.js +3 -1
- package/workspace/stage-card-tasks-test.js +3 -1
- package/workspace/stage-card-test.js +2 -1
- package/workspace/task-delete-test.js +2 -1
- package/workspace/task-links-test.js +2 -1
- package/workspace/task-milestones-test.js +4 -2
- package/workspace/task-plans-test.js +3 -1
- package/workspace/task-press-test.js +3 -1
- package/workspace/task-views-test.js +3 -1
- package/workspace/test-lists/doc-path.json +9 -0
- package/workspace/test-lists/events-place.json +11 -0
- package/workspace/test-lists/goals-place.json +9 -0
- package/workspace/test-lists/library-place.json +9 -0
- package/workspace/test-lists/pop-work.json +9 -0
- package/workspace/test-lists/routine-place.json +9 -0
- package/workspace/test-lists/status-when.json +9 -0
- package/workspace/test-lists/today-log.json +9 -0
- package/workspace/test-lists/work-view.json +9 -0
- package/workspace/timeline-holds-test.js +3 -1
- package/workspace/tk-tasks-test.js +2 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/events-stated.js — the dates people state in the sources, for Events (events round 2, initiative events-place; design
|
|
3
|
+
* /mnt/project-files/nav-structure/audit/events-round2.md point 1).
|
|
4
|
+
*
|
|
5
|
+
* statedDates(reads, { today }) → [{ key, source, from, who, said, date, title, text, link, initiative }] PURE. No I/O and no clock.
|
|
6
|
+
* dateIn(text, { year, after }) → [{ date, at }] the explicit dates in one text ('30 Nov', 'Nov 30', '30 November 2026', '2026-11-30')
|
|
7
|
+
* FROM · CUE
|
|
8
|
+
*
|
|
9
|
+
* INPUT. reads = lib/source-reads.js all(runtimeDir): { <source>: { source, state, items, digests } }. An item holds what the tool says (who,
|
|
10
|
+
* where, the ask, the link) and `due` when the session that read it found a due day in the message.
|
|
11
|
+
*
|
|
12
|
+
* PROVEN ONLY. A date is kept only when the text states it: the item's own `due` (a day), or a day and a month written in the words of the
|
|
13
|
+
* item next to a word that makes it a date to keep (CUE: deadline, due, by, release, launch, decided, …). "Next week", "Friday" and "soon"
|
|
14
|
+
* are not dates here, because PMOS would have to guess the day. A date with no year takes the year of the message, or the next year when
|
|
15
|
+
* that day is more than half a year before the message. A date more than 60 days before today or more than a year after it is left out.
|
|
16
|
+
* A digest's decision line with such a date is kept too ("Decided: release on 2 Dec"): it is a date decided in the meeting notes. */
|
|
17
|
+
|
|
18
|
+
const MON = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
|
|
19
|
+
const MON_SHORT = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
20
|
+
/** The source's name in the grey line: "From Slack · Ang, 18 Nov". */
|
|
21
|
+
const FROM = Object.freeze({ mail: 'email', slack: 'Slack', wispr: 'meeting notes', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Drive', figma: 'Figma', website: 'the website', web: 'the web' });
|
|
22
|
+
/** A word that makes a stated day a date to keep. */
|
|
23
|
+
const CUE = /\b(deadline|due|by|until|before|no later than|release[ds]?|launch(es|ed)?|go[- ]?live|ships?|cut-?off|decided|agreed|accepts?|target|eta|deliver(y|s)?|freeze|submit|sign[- ]?off|demo|kick-?off)\b/i;
|
|
24
|
+
const BACK_DAYS = 60;
|
|
25
|
+
const AHEAD_DAYS = 366;
|
|
26
|
+
|
|
27
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
28
|
+
const isDay = (s) => typeof s === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(s) && !Number.isNaN(Date.parse(s + 'T00:00:00Z'));
|
|
29
|
+
const ms = (d) => Date.parse(d + 'T00:00:00Z');
|
|
30
|
+
const between = (a, b) => Math.round((ms(b) - ms(a)) / 86400000);
|
|
31
|
+
const flat = (s) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim();
|
|
32
|
+
const clip = (s, n) => { s = flat(s); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
33
|
+
/** A real day of the calendar, or null (31 Feb is not one). */
|
|
34
|
+
function mk(y, m, d) {
|
|
35
|
+
if (!(m >= 1 && m <= 12 && d >= 1 && d <= 31)) return null;
|
|
36
|
+
const t = new Date(Date.UTC(y, m - 1, d));
|
|
37
|
+
return t.getUTCMonth() === m - 1 ? `${y}-${pad(m)}-${pad(d)}` : null;
|
|
38
|
+
}
|
|
39
|
+
/** The day a message was written ('YYYY-MM-DD'), from its `at`, or null. */
|
|
40
|
+
function dayOf(at) {
|
|
41
|
+
const s = String(at || '');
|
|
42
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(s)) return s.slice(0, 10);
|
|
43
|
+
const t = Date.parse(s);
|
|
44
|
+
return Number.isNaN(t) ? null : new Date(t).toISOString().slice(0, 10);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The explicit dates in one text, with where each sits. o: { year (when the text gives none), after: 'YYYY-MM-DD' (the message day) }. */
|
|
48
|
+
function dateIn(text, o = {}) {
|
|
49
|
+
const s = String(text || '');
|
|
50
|
+
const out = [];
|
|
51
|
+
const yearOf = (m, d) => {
|
|
52
|
+
let y = Number(o.year) || new Date().getUTCFullYear();
|
|
53
|
+
const k = mk(y, m, d);
|
|
54
|
+
if (k && o.after && between(o.after, k) < -183) y += 1; // "3 Jan" said in December is next year
|
|
55
|
+
return y;
|
|
56
|
+
};
|
|
57
|
+
const push = (day, at) => { if (day && !out.some((x) => x.date === day && x.at === at)) out.push({ date: day, at }); };
|
|
58
|
+
let m;
|
|
59
|
+
const iso = /\b(20\d\d)-(\d\d)-(\d\d)\b/g;
|
|
60
|
+
while ((m = iso.exec(s))) push(mk(+m[1], +m[2], +m[3]), m.index);
|
|
61
|
+
const dm = /\b(\d{1,2})(?:st|nd|rd|th)?\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\.?(?:,?\s+(20\d\d))?\b/gi;
|
|
62
|
+
while ((m = dm.exec(s))) { const mo = MON.indexOf(m[2].slice(0, 3).toLowerCase()) + 1, d = +m[1]; push(mk(m[3] ? +m[3] : yearOf(mo, d), mo, d), m.index); }
|
|
63
|
+
const md = /\b(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\.?\s+(\d{1,2})(?:st|nd|rd|th)?\b(?:,?\s+(20\d\d))?/gi;
|
|
64
|
+
while ((m = md.exec(s))) { const mo = MON.indexOf(m[1].slice(0, 3).toLowerCase()) + 1, d = +m[2]; push(mk(m[3] ? +m[3] : yearOf(mo, d), mo, d), m.index); }
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/** The sentence of `text` around position `at`. */
|
|
68
|
+
function sentenceAt(text, at) {
|
|
69
|
+
const s = String(text);
|
|
70
|
+
const a = Math.max(s.lastIndexOf('. ', at), s.lastIndexOf('? ', at), s.lastIndexOf('! ', at), s.lastIndexOf('\n', at));
|
|
71
|
+
const ends = ['. ', '? ', '! ', '\n'].map((e) => s.indexOf(e, at)).filter((i) => i >= 0);
|
|
72
|
+
const b = ends.length ? Math.min(...ends) + 1 : s.length;
|
|
73
|
+
return s.slice(a < 0 ? 0 : a + 1, b).trim();
|
|
74
|
+
}
|
|
75
|
+
const shortDay = (d) => { const [, m, dd] = d.split('-').map(Number); return dd + ' ' + MON_SHORT[m - 1]; };
|
|
76
|
+
|
|
77
|
+
function statedDates(reads, { today } = {}) {
|
|
78
|
+
if (!isDay(today)) return [];
|
|
79
|
+
const year = Number(today.slice(0, 4));
|
|
80
|
+
const out = [], seen = new Set();
|
|
81
|
+
const keep = (x) => {
|
|
82
|
+
const d = between(today, x.date);
|
|
83
|
+
if (d < -BACK_DAYS || d > AHEAD_DAYS) return;
|
|
84
|
+
const sig = x.date + '|' + x.title.toLowerCase();
|
|
85
|
+
if (seen.has(sig)) return;
|
|
86
|
+
seen.add(sig);
|
|
87
|
+
out.push(x);
|
|
88
|
+
};
|
|
89
|
+
for (const r of Object.values(reads || {})) {
|
|
90
|
+
if (!r || r.state !== 'read' || !FROM[r.source]) continue;
|
|
91
|
+
const from = FROM[r.source];
|
|
92
|
+
for (const it of r.items || []) {
|
|
93
|
+
if (!it || !it.title || it.bot) continue;
|
|
94
|
+
const said = dayOf(it.at);
|
|
95
|
+
const base = { source: r.source, from, who: clip(it.who || '', 60), said, link: it.link || null, initiative: it.initiative_id || null, title: clip(it.ask || it.title, 140) };
|
|
96
|
+
const id = it.id || clip(it.title, 40);
|
|
97
|
+
// the item's own due day: the session that read it found it in the message
|
|
98
|
+
if (isDay(String(it.due || '').slice(0, 10))) {
|
|
99
|
+
const date = String(it.due).slice(0, 10);
|
|
100
|
+
keep({ ...base, key: 'dl:' + r.source + ':' + id + ':' + date, date, text: clip(it.ask || it.about || it.title, 240) });
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const texts = [it.ask, it.title, it.about, ...((it.thread || []).map((t) => t && t.text))].filter(Boolean);
|
|
104
|
+
let found = null;
|
|
105
|
+
for (const t of texts) {
|
|
106
|
+
for (const hit of dateIn(t, { year: said ? Number(said.slice(0, 4)) : year, after: said })) {
|
|
107
|
+
const line = sentenceAt(t, hit.at);
|
|
108
|
+
if (CUE.test(line)) { found = { date: hit.date, text: clip(line, 240) }; break; }
|
|
109
|
+
}
|
|
110
|
+
if (found) break;
|
|
111
|
+
}
|
|
112
|
+
if (found) keep({ ...base, key: 'dl:' + r.source + ':' + id + ':' + found.date, date: found.date, text: found.text });
|
|
113
|
+
}
|
|
114
|
+
for (const g of r.digests || []) {
|
|
115
|
+
if (!g || !g.name) continue;
|
|
116
|
+
for (const line of g.decisions || []) {
|
|
117
|
+
for (const hit of dateIn(line, { year })) {
|
|
118
|
+
if (!CUE.test(sentenceAt(line, hit.at))) continue;
|
|
119
|
+
keep({ source: r.source, from, who: clip(g.name, 60), said: null, link: g.link || null, initiative: null, title: clip(line, 140),
|
|
120
|
+
key: 'dl:' + r.source + ':' + clip(g.name, 40) + ':' + hit.date, date: hit.date, text: clip(line, 240) });
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return out.map((x) => ({ ...x, line: 'From ' + x.from + (x.who || x.said ? ' · ' + [x.who, x.said ? shortDay(x.said) : ''].filter(Boolean).join(', ') : '') }));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = { statedDates, dateIn, FROM, CUE };
|
|
@@ -49,6 +49,7 @@ function rule(info, id) {
|
|
|
49
49
|
(info.ended ? `It ended (${info.ended === 'wontdo' ? "Won't do" : 'Archived'}).` : stageWords(info)));
|
|
50
50
|
out.push('Its stages: ' + info.stages.map((s, i) => `${i + 1}. ${s.name} [${s.key}]${s.status === 'done' ? ' done' : s.status === 'current' ? ' current' : s.status === 'skipped' ? ' skipped' : ''}`).join('; ') + '.');
|
|
51
51
|
} else out.push(`Run \`pmos workflow of ${ini}\` to see the workflow this initiative runs and its current stage.`);
|
|
52
|
+
out.push('Speak to the PM as "you", in the first person ("I archived them"). Never write "The PM says" or speak of the PM in the third person.');
|
|
52
53
|
out.push(
|
|
53
54
|
`Read workflows only through pmos: \`pmos workflow of ${ini}\` gives this initiative's workflow and its stages, \`pmos workflow show <workflow id>\` gives any workflow's stages, and \`pmos workflow list\` names every workflow the PM can pick, the ones saved in Settings included. The workflows are not files in this repository: never search the files for one. If pmos cannot find a workflow, tell the PM so and ask. A workflow is not a lane: never use a lane (feature, discovery, chore, incident, content, prototype) in place of the initiative's workflow.`,
|
|
54
55
|
`The workflow stage is on the initiative: the stage card and the Board show it. \`pmos workflow of ${ini}\` reads it. When the PM asks to move the initiative, run \`pmos workflow move ${ini} --stage <key> --why "<reason>"\`. When the PM asks to change its workflow, run \`pmos workflow switch ${ini} --to <workflow id>\`. Both write what the page's press writes, under your name.`,
|
|
@@ -477,6 +477,16 @@ function budgetWatch(budgets, goals) {
|
|
|
477
477
|
return budgets;
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
+
/** The open initiatives whose anchor names no key result of the OKR file (by id or by name) and no health budget or domain: Goals' Unlinked row.
|
|
481
|
+
* [] with no OKR file, so a product without one never lists all its work as unlinked. PURE. */
|
|
482
|
+
function unlinkedOf(inits, okr) {
|
|
483
|
+
if (!Array.isArray(inits) || !okr || !okr.ok || !(okr.objectives || []).length) return [];
|
|
484
|
+
return inits.filter((r) => r && r.status !== 'done' && r.status !== 'cancelled' && !r.stopped).map(initOf).filter((r) => {
|
|
485
|
+
const a = String(r.anchor || '').trim();
|
|
486
|
+
if (/^(health|domain):/i.test(a)) return false;
|
|
487
|
+
return !OG.matchAnchor(a, okr.objectives) && !OG.byName(r.title, okr.objectives);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
480
490
|
function build(facts) {
|
|
481
491
|
const f = facts || {};
|
|
482
492
|
const outcomes = f.outcomes || [], missing = (f.missing || []).slice();
|
|
@@ -526,6 +536,8 @@ function build(facts) {
|
|
|
526
536
|
model.metrics = GS.metricsOf(model.goals);
|
|
527
537
|
// Intelligence redesign A: the OKR file is the goal list; a KR metric record is a key result's reader (lib/okr-goals.js)
|
|
528
538
|
model.okrFile = OG.build({ okr: f.okr, goals: model.goals, initiatives: (f.initiatives || []).map(initOf), records: f.goalMeta || {}, today: model.today });
|
|
539
|
+
// Goals (slice 9 of the six-place navigation): the open work no key result and no budget names, for the page's Unlinked row
|
|
540
|
+
model.unlinked = unlinkedOf(f.initiatives, f.okr);
|
|
529
541
|
model.lateRows = Array.isArray(f.initiatives) ? f.initiatives.filter((r) => r && r.status === 'late').map(initOf) : [];
|
|
530
542
|
model.okr = okrOf(model, (f.watch && f.watch.drafts) || 0);
|
|
531
543
|
model.lateNow = Array.isArray(f.initiatives) ? f.initiatives.filter((r) => r && r.status === 'late').length : null;
|
|
@@ -536,4 +548,4 @@ function build(facts) {
|
|
|
536
548
|
return model;
|
|
537
549
|
}
|
|
538
550
|
|
|
539
|
-
module.exports = { okrOf, watchFields, budgetWatch, lifeIndex, goalType, goalsOf, outcomesOf, budgetsOf, mdDate, build, peekModel, chartOf, mineOf, findingsOf, findingsOfChart, projectionOf, leadOf, shortDate, num };
|
|
551
|
+
module.exports = { unlinkedOf, okrOf, watchFields, budgetWatch, lifeIndex, goalType, goalsOf, outcomesOf, budgetsOf, mdDate, build, peekModel, chartOf, mineOf, findingsOf, findingsOfChart, projectionOf, leadOf, shortDate, num };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* library-find.js — the Library's search by meaning (initiative library-place, Library round 2, point 7).
|
|
3
|
+
*
|
|
4
|
+
* Two steps, so a title match stays instant and the meaning results arrive under it:
|
|
5
|
+
* shortlist({ roots, items, q }) → [{ id, passage, words }] READ ONLY. The content words of the question (no stop words, a plain stem)
|
|
6
|
+
* are found in the listed items' text: `git grep` over each product's tracked markdown files, and a meeting note's summary lines. A file
|
|
7
|
+
* scores by how many of the words it holds, then how often; its passage is the line that holds the most of them. No index is kept.
|
|
8
|
+
* rank(ctx, q, list, items) → { ok, results: [{ id, passage, idea }] } | { ok: false, why }
|
|
9
|
+
* One normal PMOS session (`claude -p`, a read-only ask run: the same path as the document chat; no new dependency, no new service)
|
|
10
|
+
* reads the question and the shortlist (name, kind, about, passage) and keeps the ones that are about the question, best first, each with
|
|
11
|
+
* the few words of its passage that carry the matching idea (the page shows them in bold). Answers are kept in memory for 10 minutes.
|
|
12
|
+
* What the session sees is what the shortlist already holds: names and one passage each, from the PM's own repositories and notes. */
|
|
13
|
+
const { execFileSync } = require('child_process');
|
|
14
|
+
const crypto = require('crypto');
|
|
15
|
+
|
|
16
|
+
const STOP = new Set(('the a an and or of to in on for with at by from is are was were be been this that these those we our us it its as about into up '
|
|
17
|
+
+ 'out what which who whom how why when where did do does done any anything something there their them they you your i me my can could should would '
|
|
18
|
+
+ 'will shall may might must have has had not no yes all some more most than then so if but also just only over under after before again new').split(' '));
|
|
19
|
+
const stem = (w) => w.replace(/(ies)$/, 'y').replace(/(ing|ed|es|s)$/, '').replace(/(.)\1$/, '$1');
|
|
20
|
+
/** The content words of a question, stemmed, at most 8. */
|
|
21
|
+
function wordsOf(q) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const w of String(q || '').toLowerCase().split(/[^a-z0-9]+/)) {
|
|
24
|
+
if (w.length < 3 || STOP.has(w)) continue;
|
|
25
|
+
const s = stem(w).length >= 3 ? stem(w) : w;
|
|
26
|
+
if (!out.includes(s)) out.push(s);
|
|
27
|
+
}
|
|
28
|
+
return out.slice(0, 8);
|
|
29
|
+
}
|
|
30
|
+
const MAX = 24;
|
|
31
|
+
const clip = (s, n) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
|
|
32
|
+
/** Strip markdown marks from a line so the passage reads as prose. */
|
|
33
|
+
const plain = (l) => String(l || '').replace(/^\s*\|\s*|\s*\|\s*$/g, '').replace(/\s*\|\s*/g, ' · ').replace(/^\s*(?:#+|[-*+>]|\d+[.)])\s*/, '').replace(/\*\*|__|`|\[([^\]]*)\]\([^)]*\)/g, (m, a) => a || '').trim();
|
|
34
|
+
|
|
35
|
+
function grep(root, words) {
|
|
36
|
+
const args = ['grep', '-I', '-i', '-n', '--no-color'];
|
|
37
|
+
for (const w of words) args.push('-e', w);
|
|
38
|
+
args.push('--', '*.md');
|
|
39
|
+
try { return execFileSync('git', args, { cwd: root, encoding: 'utf8', timeout: 8000, maxBuffer: 32 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] }); }
|
|
40
|
+
catch (e) { return (e && typeof e.stdout === 'string') ? e.stdout : ''; } // git grep exits 1 when nothing matches
|
|
41
|
+
}
|
|
42
|
+
/* a word counts at the start of a word only: "sms" is not in "mechanisms" */
|
|
43
|
+
const reOf = (w) => new RegExp('(^|[^a-z0-9])' + w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i');
|
|
44
|
+
function has(line, w) { return reOf(w).test(line); }
|
|
45
|
+
function scoreLine(line, words) {
|
|
46
|
+
let n = 0;
|
|
47
|
+
for (const w of words) if (has(line, w)) n++;
|
|
48
|
+
return n;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* roots: [{ ws, root }]; items: the Library's items (lib/library-items.js); q: the question.
|
|
52
|
+
* → [{ id, passage, words, score }] best first, at most 24. Only items in `items` are found, so a filter or a gate rule the page applies holds.
|
|
53
|
+
*/
|
|
54
|
+
function shortlist({ roots = [], items = [], q = '' } = {}) {
|
|
55
|
+
const words = wordsOf(q);
|
|
56
|
+
if (!words.length) return [];
|
|
57
|
+
const byPath = new Map();
|
|
58
|
+
for (const x of items) if (x.kind === 'doc' && x.open && x.open.doc) byPath.set(x.open.doc.ws + '|' + x.open.doc.path, x);
|
|
59
|
+
const hits = new Map(); // id → { x, have: Set, n, best, bestN }
|
|
60
|
+
const take = (x, line) => {
|
|
61
|
+
const t = plain(line); if (!t || /^[a-z_]+:\s/i.test(t) && t.length < 60) return; // a frontmatter line is not a passage
|
|
62
|
+
const n = scoreLine(t, words); if (!n) return;
|
|
63
|
+
let h = hits.get(x.id);
|
|
64
|
+
if (!h) { h = { x, have: new Set(), n: 0, best: '', bestN: 0 }; hits.set(x.id, h); }
|
|
65
|
+
for (const w of words) if (has(t, w)) h.have.add(w);
|
|
66
|
+
h.n++;
|
|
67
|
+
if (n > h.bestN || (n === h.bestN && t.length > h.best.length && h.best.length < 60)) { h.best = t; h.bestN = n; }
|
|
68
|
+
};
|
|
69
|
+
for (const { ws, root } of roots) {
|
|
70
|
+
if (!root) continue;
|
|
71
|
+
for (const raw of grep(root, words).split('\n')) {
|
|
72
|
+
const m = /^(.+?):(\d+):(.*)$/.exec(raw); if (!m) continue;
|
|
73
|
+
const x = byPath.get(ws + '|' + m[1]); if (x) take(x, m[3]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const x of items) {
|
|
77
|
+
if (x.kind === 'meeting') for (const l of x.gist || []) take(x, l);
|
|
78
|
+
// the record itself counts too (name, kind, about), so a short note with a matching name is found
|
|
79
|
+
take(x, [x.name, x.sub, x.kindText, x.about && x.about.title, x.about && x.about.programTitle].filter(Boolean).join(' · '));
|
|
80
|
+
}
|
|
81
|
+
return [...hits.values()]
|
|
82
|
+
.map((h) => ({ id: h.x.id, passage: clip(h.best, 240), words: [...h.have], score: h.have.size * 100 + Math.min(h.n, 50) }))
|
|
83
|
+
.filter((h) => h.words.length >= Math.min(2, words.length))
|
|
84
|
+
.sort((a, b) => b.score - a.score)
|
|
85
|
+
.slice(0, MAX);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* ── the ranking run ───────────────────────────────────────────────────────────────────────── */
|
|
89
|
+
const MODEL = 'claude-sonnet-5-5';
|
|
90
|
+
const LEAN = Object.freeze([{ flag: '--strict-mcp-config' }, { flag: '--disable-slash-commands' }, { flag: '--setting-sources', value: 'user' }, { flag: '--tools', value: 'Read' }]);
|
|
91
|
+
const TIMEOUT_MS = 60000;
|
|
92
|
+
const kept = new Map(); // key → { at, value }
|
|
93
|
+
const KEEP_MS = 10 * 60000;
|
|
94
|
+
|
|
95
|
+
function promptOf(q, list, byId) {
|
|
96
|
+
const lines = list.map((h, i) => {
|
|
97
|
+
const x = byId.get(h.id) || {};
|
|
98
|
+
const about = [x.about && x.about.programTitle, x.about && x.about.title].filter(Boolean).join(' › ');
|
|
99
|
+
return `${i + 1}. ${clip(x.name, 120)} [${x.kindText || ''}${about ? '; ' + clip(about, 80) : ''}]\n ${h.passage}`;
|
|
100
|
+
});
|
|
101
|
+
return [
|
|
102
|
+
'You rank search results in a product manager\'s library by meaning. Do not use any tool. Answer with JSON only.',
|
|
103
|
+
`The question: "${clip(q, 300)}"`,
|
|
104
|
+
'The candidates, each with the passage of its text that shares words with the question:',
|
|
105
|
+
lines.join('\n'),
|
|
106
|
+
'Keep only the candidates whose passage is really about the question (the same idea, not only the same words). Order them best first.',
|
|
107
|
+
'For each, copy the few words (2 to 8) of its passage that carry the idea, exactly as they are written in the passage.',
|
|
108
|
+
'Answer: {"keep":[{"n":<candidate number>,"idea":"<words copied from its passage>"}]}',
|
|
109
|
+
].join('\n\n');
|
|
110
|
+
}
|
|
111
|
+
function parse(text, list) {
|
|
112
|
+
const t = String(text || '');
|
|
113
|
+
const at = t.indexOf('{'), end = t.lastIndexOf('}');
|
|
114
|
+
if (at < 0 || end < at) return null;
|
|
115
|
+
let o; try { o = JSON.parse(t.slice(at, end + 1)); } catch { return null; }
|
|
116
|
+
if (!o || !Array.isArray(o.keep)) return null;
|
|
117
|
+
const out = [], seen = new Set();
|
|
118
|
+
for (const k of o.keep) {
|
|
119
|
+
const i = Number(k && k.n) - 1, h = list[i];
|
|
120
|
+
if (!h || seen.has(i)) continue;
|
|
121
|
+
seen.add(i);
|
|
122
|
+
const idea = String((k && k.idea) || '').trim();
|
|
123
|
+
// the idea is shown in bold inside the passage, so it must be words of the passage
|
|
124
|
+
out.push({ id: h.id, passage: h.passage, idea: idea && h.passage.toLowerCase().includes(idea.toLowerCase()) ? idea : '' });
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
function viaSession(ctx, prompt, key) {
|
|
129
|
+
if (typeof ctx.askClaude === 'function') return Promise.resolve(ctx.askClaude(prompt, { job: 'library-find', key })).catch(() => null);
|
|
130
|
+
const headless = require('./headless.js');
|
|
131
|
+
const origin = 'briefing-ask:library-find:' + key;
|
|
132
|
+
if (typeof ctx.spawnSession !== 'function' || headless.kindFor({ agent: 'claude', origin }) !== 'ask') return Promise.resolve(null);
|
|
133
|
+
return new Promise((resolve) => {
|
|
134
|
+
let settled = false; const done = (v) => { if (settled) return; settled = true; clearTimeout(t); resolve(v); };
|
|
135
|
+
const t = setTimeout(() => done(null), TIMEOUT_MS);
|
|
136
|
+
let s = null;
|
|
137
|
+
try {
|
|
138
|
+
s = ctx.spawnSession({ name: 'library: find by meaning', agent: 'claude', origin, initialInput: prompt,
|
|
139
|
+
modelAsk: { explicit: { model: MODEL, effort: 'low' } }, launchFlags: LEAN.map((f) => ({ ...f })),
|
|
140
|
+
onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null); } });
|
|
141
|
+
} catch { s = null; }
|
|
142
|
+
if (!s || s.state === 'exited') done(null);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/** Rank a shortlist by meaning. → { ok, results } or { ok: false, why } (the page then keeps the word ranking and says so). */
|
|
146
|
+
async function rank(ctx, q, list, items) {
|
|
147
|
+
if (!list.length) return { ok: true, results: [] };
|
|
148
|
+
const key = crypto.createHash('sha1').update(q + '\n' + list.map((h) => h.id + h.passage).join('\n')).digest('hex').slice(0, 12);
|
|
149
|
+
const k = kept.get(key);
|
|
150
|
+
if (k && Date.now() - k.at < KEEP_MS) return k.value;
|
|
151
|
+
const byId = new Map(items.map((x) => [x.id, x]));
|
|
152
|
+
const text = await viaSession(ctx, promptOf(q, list, byId), key);
|
|
153
|
+
if (text == null) return { ok: false, why: 'PMOS could not start a session to read for meaning' };
|
|
154
|
+
const results = parse(text, list);
|
|
155
|
+
if (!results) return { ok: false, why: 'the answer could not be read' };
|
|
156
|
+
const value = { ok: true, results };
|
|
157
|
+
kept.set(key, { at: Date.now(), value });
|
|
158
|
+
if (kept.size > 50) kept.delete(kept.keys().next().value);
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = { wordsOf, shortlist, rank, promptOf, parse };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* library-items.js — what was made, as one list (initiative library-place, slice 7 of the six-place navigation; boards StLibrary,
|
|
3
|
+
* StLibMeetings, StLibDocs on Exploring 2). PURE: no file, no clock, no network.
|
|
4
|
+
*
|
|
5
|
+
* build({ products, notes, programs }) → [item] newest first
|
|
6
|
+
* products: [{ ws, name, titles: Map|{} initiative id → title, files, links, rounds }]
|
|
7
|
+
* files lib/doc-library.js library().files that an initiative owns: [{ path, title, category, date, initiative, status, type, by }]
|
|
8
|
+
* links lib/custom-docs.js rows with a link: [{ id, scope, title, link: { kind, url }, at }]
|
|
9
|
+
* rounds prototype rounds: [{ id, ini, name, at, made, board }] (lib/idle-lab.js roundsOf, named by the round's brief)
|
|
10
|
+
* notes: lib/notes.js list().notes, with `came` (rowOf); programs: lib/routes-programs.js all()
|
|
11
|
+
* ITEM (one catalogue record, Library round 2)
|
|
12
|
+
* { id, kind, name, sub, kindText, type, family, state, v, gate, came, by, ed, product, scope, about, updated, held, open, named?, suggest?, path?, note? }
|
|
13
|
+
* kind 'doc' | 'link' | 'meeting' | 'proto'
|
|
14
|
+
* kindText the Kind column, specific: PRD, Strategic brief, Design brief, Done test, Meeting notes, Prototype, Link · Confluence …; from the
|
|
15
|
+
* frontmatter `type` first, then a title prefix ("Brief:"), then where the file lives. "Document" only when nothing says more.
|
|
16
|
+
* A title prefix that repeats the Kind leaves the name ("Brief: Scarlet lucky draw" → "Scarlet lucky draw"); `sub` keeps the title.
|
|
17
|
+
* family the Kind chip's family: plans · briefs · meetings · protos · checks · links (FAMILIES)
|
|
18
|
+
* state 'Draft' | 'Final' | 'Issued' for a document (frontmatter status, or DRAFT in the title, which leaves the name); '' otherwise
|
|
19
|
+
* v the edition a name or path says (v3), or null; ed: the key that folds editions of one document under one row
|
|
20
|
+
* gate PMOS's own gate records (done test, rubric, eval, retro …): grouped by New they fold into one "Checks · N" row per initiative
|
|
21
|
+
* by 'You' | 'PMOS' | a person's name (the last commit's author; an agent co-author is PMOS)
|
|
22
|
+
* product the product's name; about: { ws, product, ini, title, program, programTitle } (About = "Program › Initiative")
|
|
23
|
+
* scope the tokens pm/scope-chip.js filters by: 'p:<ws>', 'g:<program>', 'j:<ws>|<initiative>'
|
|
24
|
+
* named a meeting note with no title, which PMOS named ("CEM standup, 17 Nov"): ✦ until the PM accepts or renames it
|
|
25
|
+
* gist a meeting note's summary lines (none for a private note): the preview's first lines, and what search by meaning reads
|
|
26
|
+
* suggest a meeting note with no work: { ws, ini, title } the initiative its words point to, for a ✦ link (or null)
|
|
27
|
+
* came the "Came out of it" column of a meeting: '2 decisions · 3 tasks' ('' for a private note)
|
|
28
|
+
* updated ISO date or time of the last change; held: the meeting's start
|
|
29
|
+
* open what the page's opener needs: { doc: { ws, path } } | { url } | { note, ws } | { proto: { ws, board, id } }
|
|
30
|
+
* narrow(items, { ws, initiative }) → the items of one product or one initiative (slice 3's Artefacts table reads ?initiative=)
|
|
31
|
+
* Reports are not here (they repeat, so they live in Routine); Lab findings are not here (they go to Today as suggestions). */
|
|
32
|
+
|
|
33
|
+
/* ── Kind: what one thing is (round 2, point 1) ─────────────────────────────────────────────────────────────────────── */
|
|
34
|
+
/* the frontmatter `type` as a Kind; a type not here reads as itself, in sentence case ("strategic-brief" → "Strategic brief") */
|
|
35
|
+
const BY_TYPE = {
|
|
36
|
+
prd: 'PRD', spec: 'Spec', specification: 'Spec', 'strategic brief': 'Strategic brief', brief: 'Strategic brief', 'design brief': 'Design brief',
|
|
37
|
+
'prototype brief': 'Prototype brief', 'content brief': 'Content brief', 'spike brief': 'Spike brief', strategy: 'Strategy', roadmap: 'Roadmap',
|
|
38
|
+
'risk list': 'Risk list', risks: 'Risk list', 'risk register': 'Risk list', rubric: 'Rubric', eval: 'Eval', verdict: 'Eval', retro: 'Retro',
|
|
39
|
+
retrospective: 'Retro', 'done test': 'Done test', research: 'Research', design: 'Design', prototype: 'Prototype brief', story: 'Story',
|
|
40
|
+
handover: 'Handover', review: 'Review', checklist: 'Checklist', calibration: 'Calibration', decision: 'Decision', adr: 'Decision',
|
|
41
|
+
explainer: 'Explainer', guide: 'Guide', concept: 'Knowledge', reference: 'Reference', playbook: 'Playbook', template: 'Template', okr: 'OKR',
|
|
42
|
+
radar: 'Radar', principle: 'Principle', debt: 'Debt', discovery: 'Discovery', sheet: 'Sheet', spreadsheet: 'Sheet', incident: 'Incident',
|
|
43
|
+
'user stories': 'User stories', stories: 'User stories', critique: 'Grilling critique', grilling: 'Grilling critique', 'grilling critique': 'Grilling critique',
|
|
44
|
+
minutes: 'Minutes', 'pre read': 'Pre-read', preread: 'Pre-read', update: 'Update note', 'update note': 'Update note', 'api spec': 'API spec',
|
|
45
|
+
'api specification': 'API spec', guideline: 'Guideline', guidelines: 'Guideline', anchor: 'Anchor', report: 'Report', note: 'Note',
|
|
46
|
+
};
|
|
47
|
+
/* the Kind from the category doc-library gives a file, when nothing else says more */
|
|
48
|
+
const TYPE = { spec: 'PRD', eval: 'Rubric', res: 'Research', exp: 'Explainer', dec: 'Decision', know: 'Knowledge', guide: 'Guide', proto: 'Prototype brief' };
|
|
49
|
+
/* a title prefix that names the kind: "Brief: …", "Design Brief: …", "Done test — …" (the prefix leaves the name) */
|
|
50
|
+
const PREFIX = [
|
|
51
|
+
[/^design\s+brief/i, 'Design brief'], [/^prototype\s+brief/i, 'Prototype brief'], [/^content\s+brief/i, 'Content brief'], [/^spike(\s+brief)?/i, 'Spike brief'],
|
|
52
|
+
[/^(strategic\s+)?brief/i, 'Strategic brief'], [/^done[\s-]+test/i, 'Done test'], [/^prd/i, 'PRD'], [/^rubric/i, 'Rubric'], [/^retro(spective)?/i, 'Retro'],
|
|
53
|
+
[/^design(?!\s+brief)/i, 'Design'], [/^roadmap/i, 'Roadmap'], [/^strategy/i, 'Strategy'], [/^risks?(\s+(list|register))?/i, 'Risk list'], [/^spec(ification)?/i, 'Spec'],
|
|
54
|
+
];
|
|
55
|
+
const SEP = String.raw`\s*(?::|—|–|\s-\s)\s*`;
|
|
56
|
+
/** The kind a title's prefix names, and the name without it. null when the title has no such prefix. */
|
|
57
|
+
function prefixOf(title) {
|
|
58
|
+
const t = String(title || '').trim();
|
|
59
|
+
for (const [re, kind] of PREFIX) {
|
|
60
|
+
const m = new RegExp('^(?:' + re.source.slice(1) + ')' + SEP, 'i').exec(t);
|
|
61
|
+
if (m && t.length > m[0].length) return { kind, name: t.slice(m[0].length).trim() };
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const sentence = (s) => { const t = String(s || '').replace(/[-_]+/g, ' ').replace(/\s+/g, ' ').trim().toLowerCase(); return t ? t[0].toUpperCase() + t.slice(1) : ''; };
|
|
66
|
+
/** A frontmatter type as a Kind, or '' when it says nothing (Initiative, Document). */
|
|
67
|
+
function kindOfType(type) {
|
|
68
|
+
const k = String(type || '').replace(/[-_]+/g, ' ').replace(/([a-z])([A-Z])/g, '$1 $2').trim().toLowerCase();
|
|
69
|
+
if (!k || k === 'document' || k === 'doc' || k === 'initiative' || k === 'other') return '';
|
|
70
|
+
return BY_TYPE[k] || sentence(k);
|
|
71
|
+
}
|
|
72
|
+
/* PMOS's own gate records: the agent writes them for the gates; grouped by New they fold into one "Checks · N" row per initiative */
|
|
73
|
+
const GATE = new Set(['Done test', 'Rubric', 'Eval', 'Retro', 'Run log', 'Incident', 'Out of scope', 'Record', 'Prototype brief', 'Calibration']);
|
|
74
|
+
/* the Kind families of the Kind chip, in its order */
|
|
75
|
+
const FAMILIES = [['plans', 'Plans and specs'], ['briefs', 'Briefs'], ['meetings', 'Meeting notes'], ['protos', 'Prototypes and designs'], ['checks', 'Checks'], ['links', 'Links']];
|
|
76
|
+
const BROAD = new Set(['Research', 'Reference', 'Knowledge', 'Guide', 'Story', 'Concept']);
|
|
77
|
+
const BRIEFS = new Set(['Strategic brief', 'Design brief', 'Content brief', 'Spike brief', 'Brief', 'Pre-read']);
|
|
78
|
+
function familyOf(kind, gate, k) {
|
|
79
|
+
if (k === 'meeting' || kind === 'Minutes') return 'meetings';
|
|
80
|
+
if (k === 'link') return 'links';
|
|
81
|
+
if (k === 'proto' || kind === 'Design' || kind === 'Prototype') return 'protos';
|
|
82
|
+
if (gate) return 'checks';
|
|
83
|
+
return BRIEFS.has(kind) ? 'briefs' : 'plans';
|
|
84
|
+
}
|
|
85
|
+
const under = (p, dir) => new RegExp('(^|/)planning/' + dir + '/').test(p);
|
|
86
|
+
/** THE KIND RESOLVER the Library and the popup's Artefacts share: kindOf({ path, title, type, category }) → { type, gate, name }.
|
|
87
|
+
* Where a gate record lives (done tests, evals …), then a specific frontmatter type, then a title prefix that names the kind ("Brief:",
|
|
88
|
+
* "PRD:"), then the file name (user-stories.md, *-minutes.md), then the folder (briefs/, design/), then a broad frontmatter type
|
|
89
|
+
* (Research, Reference), then the doc-library category; the last fallback is "Note", never "Document". `name` is the title without a
|
|
90
|
+
* prefix that only repeats the kind. */
|
|
91
|
+
function typeOf(f) {
|
|
92
|
+
const p = String(f.path || ''), t = String(f.title || '');
|
|
93
|
+
const pre = prefixOf(t);
|
|
94
|
+
let type = '';
|
|
95
|
+
if (under(p, 'done-tests')) type = 'Done test';
|
|
96
|
+
else if (under(p, 'evals')) type = /rubric/i.test(p) ? 'Rubric' : 'Eval';
|
|
97
|
+
else if (/\bretro\b|retrospective/i.test(t) || /(^|[/-])retro([-.]|$)/i.test(p)) type = 'Retro';
|
|
98
|
+
else if (under(p, 'runs')) type = 'Run log';
|
|
99
|
+
else if (under(p, 'incidents')) type = 'Incident';
|
|
100
|
+
else if (under(p, 'out-of-scope')) type = 'Out of scope';
|
|
101
|
+
else if (under(p, 'data-export') || under(p, 'batches')) type = 'Record';
|
|
102
|
+
else if (f.category === 'proto') type = 'Prototype brief';
|
|
103
|
+
else {
|
|
104
|
+
// a specific frontmatter type wins; a broad one (Research, Reference …) gives way to a title prefix that names the kind ("Brief: …")
|
|
105
|
+
// and to the folder (planning/briefs/, planning/design/)
|
|
106
|
+
const ft = kindOfType(f.type);
|
|
107
|
+
const dir = under(p, 'briefs') ? 'Strategic brief' : under(p, 'design') ? 'Design' : '';
|
|
108
|
+
// file-name rules for kinds that live by name: user-stories.md, *-minutes.md, *-api-spec.md, *-critique.md
|
|
109
|
+
const base = p.split('/').pop().toLowerCase();
|
|
110
|
+
const byName = /user-?stories/.test(base) ? 'User stories' : /minutes/.test(base) ? 'Minutes' : /api-?spec/.test(base) ? 'API spec' : /critique|grill/.test(base) ? 'Grilling critique' : /pre-?read/.test(base) ? 'Pre-read' : '';
|
|
111
|
+
type = (ft && !BROAD.has(ft) ? ft : '') || (pre && pre.kind) || byName || dir || ft || TYPE[f.category] || 'Note';
|
|
112
|
+
}
|
|
113
|
+
// a prefix that only repeats the kind leaves the name
|
|
114
|
+
const name = pre && (pre.kind === type || (BRIEFS.has(pre.kind) && BRIEFS.has(type))) ? pre.name : t;
|
|
115
|
+
return { type, gate: GATE.has(type), name };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ── State and edition ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
119
|
+
const DRAFT_RE = /\s*(?:\(\s*DRAFT\s*\)|\[\s*DRAFT\s*\]|[,·—–-]\s*DRAFT\b)|\bDRAFT\b\s*[:—–-]?\s*/;
|
|
120
|
+
const ISSUED_RE = /^(issued|approved|accepted|published|released|ratified|shipped|signed off|signed-off|live)$/i;
|
|
121
|
+
/** The name without its DRAFT mark, and the State: Draft, Issued or Final. */
|
|
122
|
+
function stateOf(f, name) {
|
|
123
|
+
const st = String(f.status || '').trim();
|
|
124
|
+
const draft = /^(draft|wip|in progress|in-progress)$/i.test(st) || /\bDRAFT\b/.test(name);
|
|
125
|
+
const clean = name.replace(/\(([^()]*?),\s*DRAFT\s*\)/, '($1)').replace(DRAFT_RE, ' ').replace(/\s{2,}/g, ' ').replace(/\s+([)\]])/g, '$1').trim();
|
|
126
|
+
return { name: clean || name, state: draft ? 'Draft' : ISSUED_RE.test(st) ? 'Issued' : 'Final' };
|
|
127
|
+
}
|
|
128
|
+
const VER_RE = /\s*(?:[(\[]\s*)?\b(?:v|version|rev|r)\s*\.?\s*(\d{1,3})\b(?:\s*[)\]])?/i;
|
|
129
|
+
/** The version a name or a path says ("v3", "(version 2)", "-v2.md"), and the name without it. */
|
|
130
|
+
function versionOf(name, path) {
|
|
131
|
+
const m = VER_RE.exec(String(name || ''));
|
|
132
|
+
const pm = /[-_.]v(\d{1,3})(?=\.md$)/i.exec(String(path || ''));
|
|
133
|
+
const v = m ? Number(m[1]) : pm ? Number(pm[1]) : null;
|
|
134
|
+
const bare = m ? String(name).replace(m[0], ' ').replace(/\s{2,}/g, ' ').replace(/\s*[—–:-]\s*$/, '').trim() : String(name || '');
|
|
135
|
+
return { v, bare };
|
|
136
|
+
}
|
|
137
|
+
const keyOf = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
|
|
138
|
+
|
|
139
|
+
const { shortTitle: short } = require('./doc-library.js'); // a pure function of that module
|
|
140
|
+
const plural = (n, one, many) => (n === 1 ? '1 ' + one : n + ' ' + many);
|
|
141
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
142
|
+
const dayOf = (iso) => { const d = new Date(String(iso || '')); return Number.isFinite(d.getTime()) ? d.getUTCDate() + ' ' + MON[d.getUTCMonth()] : ''; };
|
|
143
|
+
|
|
144
|
+
/** "2 decisions · 3 tasks", "No decision · 2 tasks", '' when nothing came out of it (or the note is private). */
|
|
145
|
+
function cameText(c) {
|
|
146
|
+
if (!c) return '';
|
|
147
|
+
const d = Number(c.decisions) || 0, t = Number(c.tasks) || 0;
|
|
148
|
+
if (!d && !t) return '';
|
|
149
|
+
return (d ? plural(d, 'decision', 'decisions') : 'No decision') + ' · ' + (t ? plural(t, 'task', 'tasks') : 'no task');
|
|
150
|
+
}
|
|
151
|
+
const get = (m, k) => (!k ? '' : m instanceof Map ? m.get(k) || '' : (m && m[k]) || '');
|
|
152
|
+
const iniOfScope = (scope) => { const m = /^initiative:(.+)$/.exec(String(scope || '')); return m ? m[1] : null; };
|
|
153
|
+
|
|
154
|
+
/* ── a note PMOS names (round 2, point 5) ──────────────────────────────────────────────────────────────────────────────── */
|
|
155
|
+
const STOP = new Set('the a an and or of to in on for with at by from is are was were be this that we our it its as about into up out new call meeting meetings notes note sync'.split(' '));
|
|
156
|
+
const wordsOf = (s) => keyOf(s).split(' ').filter((w) => w.length > 2 && !STOP.has(w));
|
|
157
|
+
/** A name for a note with no title: the meeting's own title, else the first words of its summary, then the day ("CEM standup, 17 Nov"). */
|
|
158
|
+
function noteName(n) {
|
|
159
|
+
const day = dayOf((n.meeting && n.meeting.start) || n.created_at);
|
|
160
|
+
const m = n.meeting && n.meeting.title ? String(n.meeting.title).trim() : '';
|
|
161
|
+
let head = m;
|
|
162
|
+
if (!head) {
|
|
163
|
+
const line = String((n.summary_lines || [])[0] || '').trim();
|
|
164
|
+
head = line.split(/[.:;!?(—–]|\s-\s|,\s/)[0].trim().split(/\s+/).slice(0, 5).join(' ');
|
|
165
|
+
}
|
|
166
|
+
head = head ? head[0].toUpperCase() + head.slice(1) : 'Meeting';
|
|
167
|
+
return day ? head + ', ' + day : head;
|
|
168
|
+
}
|
|
169
|
+
/** The initiative a note talks about, by the words its title and summary share with the initiatives' titles: { ws, ini, title } or null.
|
|
170
|
+
* It asks at least two shared words that are half the initiative title's words or more, and one initiative ahead of the next; otherwise PMOS suggests nothing. */
|
|
171
|
+
function suggestFor(n, products) {
|
|
172
|
+
const words = new Set(wordsOf([n.title, ...(n.summary_lines || [])].join(' ')));
|
|
173
|
+
if (words.size < 2) return null;
|
|
174
|
+
const scored = [];
|
|
175
|
+
for (const p of products) {
|
|
176
|
+
const T = p.titles instanceof Map ? [...p.titles] : Object.entries(p.titles || {});
|
|
177
|
+
for (const [id, title] of T) {
|
|
178
|
+
const tw = wordsOf(title), hit = tw.filter((w) => words.has(w)).length;
|
|
179
|
+
// two shared words at least, and most of the initiative's own words: a common word or two is not a link
|
|
180
|
+
if (hit >= 2 && hit * 2 >= tw.length) scored.push({ ws: p.ws, ini: id, title: short(title) || id, hit });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
scored.sort((a, b) => b.hit - a.hit);
|
|
184
|
+
if (!scored.length || (scored[1] && scored[1].hit === scored[0].hit)) return null;
|
|
185
|
+
const { hit, ...s } = scored[0];
|
|
186
|
+
return s;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* build({ products, notes, programs }) → [item], newest first.
|
|
191
|
+
* programs: lib/routes-programs.js all(): [{ id, title, members: [{ ws, initiative }] }]
|
|
192
|
+
*/
|
|
193
|
+
function build({ products = [], notes = [], programs = [] } = {}) {
|
|
194
|
+
const out = [];
|
|
195
|
+
const byWs = new Map(products.map((p) => [p.ws, p]));
|
|
196
|
+
const progOf = new Map();
|
|
197
|
+
for (const g of programs || []) for (const m of g.members || []) { const k = m.ws + '|' + m.initiative; if (!progOf.has(k)) progOf.set(k, { id: g.id, title: g.title || g.id }); }
|
|
198
|
+
// About is "Program › Initiative": the initiative named short, as the Board does ("Tender new CIAM", not the PRD's full title)
|
|
199
|
+
const about = (p, ini, title) => {
|
|
200
|
+
const prog = p && ini ? progOf.get(p.ws + '|' + ini) || null : null;
|
|
201
|
+
return { ws: p ? p.ws : null, product: p ? p.name : '', ini: ini || null, title: (ini && (short(title || get(p && p.titles, ini)) || ini)) || '',
|
|
202
|
+
program: prog ? prog.id : null, programTitle: prog ? prog.title : '' };
|
|
203
|
+
};
|
|
204
|
+
const scope = (a) => [a.ws ? 'p:' + a.ws : null, a.program ? 'g:' + a.program : null, a.ws && a.ini ? 'j:' + a.ws + '|' + a.ini : null].filter(Boolean);
|
|
205
|
+
const push = (x) => { x.scope = scope(x.about); x.product = x.about.product; out.push(x); };
|
|
206
|
+
for (const p of products) {
|
|
207
|
+
for (const f of p.files || []) {
|
|
208
|
+
if (!f || !f.path || !f.initiative || f.category === 'ini') continue; // the initiative record is the work itself, not a thing made for it
|
|
209
|
+
const T = typeOf(f), title = T.name || f.title || f.path.split('/').pop(), S = stateOf(f, title), V = versionOf(S.name, f.path);
|
|
210
|
+
// the edition leaves the name and shows in State ("Final · v3")
|
|
211
|
+
const name = V.v && V.bare ? V.bare : S.name;
|
|
212
|
+
push({ id: 'doc:' + p.ws + ':' + f.path, kind: 'doc', name, sub: (f.title || '') !== name ? f.title || '' : '',
|
|
213
|
+
kindText: T.type, type: T.type, family: familyOf(T.type, T.gate, 'doc'), state: S.state, v: V.v, gate: T.gate, came: '', by: f.by || null,
|
|
214
|
+
ed: p.ws + '|' + f.initiative + '|' + T.type + '|' + keyOf(V.bare), about: about(p, f.initiative), updated: f.date || null, held: null,
|
|
215
|
+
path: f.path, open: { doc: { ws: p.ws, path: f.path } } });
|
|
216
|
+
}
|
|
217
|
+
for (const l of p.links || []) {
|
|
218
|
+
if (!l || !l.link || !l.link.url) continue;
|
|
219
|
+
const ini = iniOfScope(l.scope), src = String(l.link.kind || '').trim();
|
|
220
|
+
push({ id: 'link:' + p.ws + ':' + l.id, kind: 'link', name: l.title, sub: '', kindText: 'Link · ' + src, type: 'Link · ' + src, family: 'links', source: src,
|
|
221
|
+
state: '', v: null, gate: false, came: '', by: l.by && l.by !== 'pm' ? String(l.by) : 'You', ed: null, about: about(p, ini), updated: l.at || null, held: null, open: { url: l.link.url } });
|
|
222
|
+
}
|
|
223
|
+
for (const r of p.rounds || []) {
|
|
224
|
+
if (!r || !r.id) continue;
|
|
225
|
+
push({ id: 'proto:' + p.ws + ':' + r.id, kind: 'proto', name: r.name || 'Prototype', sub: '', kindText: 'Prototype', type: 'Prototype', family: 'protos',
|
|
226
|
+
state: '', v: r.made > 1 ? r.made : null, gate: false, came: r.made ? plural(r.made, 'version', 'versions') : '', by: 'PMOS', ed: null, about: about(p, r.ini),
|
|
227
|
+
updated: r.at || null, held: null, open: { proto: { ws: p.ws, board: r.board || '', id: r.id } } });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
for (const n of notes) {
|
|
231
|
+
if (!n || !n.id) continue;
|
|
232
|
+
const ini = n.initiative && n.initiative.id ? n.initiative : null;
|
|
233
|
+
const p = byWs.get((ini && ini.ws) || n.ws) || null;
|
|
234
|
+
const held = (n.meeting && n.meeting.start) || n.created_at || null;
|
|
235
|
+
const untitled = !String(n.title || '').trim() || n.title === 'Untitled note';
|
|
236
|
+
// a note with no title is named by PMOS and marked ✦ until the PM accepts or renames it; a note with no work gets a ✦ link to suggest
|
|
237
|
+
const sg = !ini && !n.private ? suggestFor(n, products) : null;
|
|
238
|
+
push({ id: 'meeting:' + n.id, kind: 'meeting', name: untitled ? noteName(n) : n.title, named: untitled, sub: '', kindText: 'Meeting notes', type: 'Meeting notes',
|
|
239
|
+
family: 'meetings', state: '', v: null, gate: false, came: n.private ? '' : cameText(n.came), by: n.recorded_from || n.summary ? 'PMOS' : 'You', ed: null,
|
|
240
|
+
about: ini ? about(p, ini.id, ini.title) : about(p, null), suggest: sg, gist: n.private ? [] : (n.summary_lines || []).slice(0, 3), updated: n.updated_at || held, held, note: n.id,
|
|
241
|
+
open: { note: n.id, ws: (p && p.ws) || n.ws || '' } });
|
|
242
|
+
}
|
|
243
|
+
return out.sort((a, b) => String(b.updated || '').localeCompare(String(a.updated || '')) || a.name.localeCompare(b.name));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function narrow(items, { ws, initiative } = {}) {
|
|
247
|
+
return items.filter((x) => (!ws || x.about.ws === ws) && (!initiative || x.about.ini === initiative));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
module.exports = { build, narrow, cameText, TYPE, FAMILIES, typeOf, kindOf: typeOf, prefixOf, kindOfType, stateOf, versionOf, noteName, suggestFor };
|
package/workspace/lib/notes.js
CHANGED
|
@@ -203,7 +203,15 @@ function rowOf(n, now = Date.now(), resumeMs = RESUME_MS) {
|
|
|
203
203
|
// the meeting time so far (a paused note's clock) and how many statements differ from a repository file (the Notes menu)
|
|
204
204
|
meeting_ms: n.recorded_from ? heardMs(n, now) : 0, conflicts: n.private ? 0 : conflictsOf(n).length,
|
|
205
205
|
// a private note shows its title on the calendar and the initiative, never its summary
|
|
206
|
-
summary_lines: n.private ? [] : summaryLines(n), ...stateFields(n, now, resumeMs) };
|
|
206
|
+
summary_lines: n.private ? [] : summaryLines(n), came: n.private ? null : cameOf(n), ...stateFields(n, now, resumeMs) };
|
|
207
|
+
}
|
|
208
|
+
/** What came out of a meeting (Library's "Came out of it", initiative library-place): the decisions and tasks among the agent's bullets. */
|
|
209
|
+
function cameOf(n) {
|
|
210
|
+
// the final notes after Stop, as the meeting card reads them (premium-vw-meet.js partsOf); else the bullets caught live
|
|
211
|
+
const f = n.final_notes;
|
|
212
|
+
if (f && (Array.isArray(f.decisions) || Array.isArray(f.actions))) return { decisions: (f.decisions || []).length, tasks: (f.actions || []).length };
|
|
213
|
+
const b = (n.bullets || []).filter((x) => x && !x.dropped);
|
|
214
|
+
return { decisions: b.filter((x) => x.cat === 'decision').length, tasks: b.filter((x) => x.cat === 'action').length };
|
|
207
215
|
}
|
|
208
216
|
/** The statements of a note that a repository file says otherwise: transcript lines, the agent's bullets and the PM's
|
|
209
217
|
* highlights whose check verdict is 'differs'. → [{ text, doc, line, t, from }] */
|