create-pmos 0.401.0 → 0.403.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 +25 -30
- 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-programs-test.js +227 -0
- package/workspace/board-shot.js +54 -0
- package/workspace/briefing-premium-adddoc-test.js +28 -22
- package/workspace/briefing-premium-board-test.js +107 -82
- package/workspace/briefing-premium-calendar-2-test.js +23 -10
- package/workspace/briefing-premium-calendar-3-test.js +23 -19
- package/workspace/briefing-premium-calendar-test.js +20 -15
- package/workspace/briefing-premium-initiative-test.js +25 -12
- package/workspace/briefing-premium-insights-test.js +31 -18
- package/workspace/briefing-premium-metrics-test.js +8 -8
- package/workspace/briefing-premium-sources-test.js +15 -10
- package/workspace/briefing-premium-test.js +39 -16
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/board-premium-facts.js +20 -3
- package/workspace/fixtures/briefing-premium-facts.js +18 -2
- package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
- package/workspace/fixtures/program-ascent.js +101 -0
- package/workspace/guide/home.md +11 -7
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/jira.md +38 -6
- package/workspace/guide/programs.md +37 -0
- package/workspace/home-rows-test.js +184 -0
- package/workspace/lib/briefing-premium-products.js +4 -4
- package/workspace/lib/briefing-premium.js +2 -2
- package/workspace/lib/calendar-layers.js +8 -4
- package/workspace/lib/initiative-layout.js +4 -3
- package/workspace/lib/jira-cli.js +17 -12
- package/workspace/lib/jira-status.js +1 -1
- package/workspace/lib/jira-tickets.js +126 -24
- package/workspace/lib/meeting-files.js +58 -0
- package/workspace/lib/meeting-learn.js +139 -0
- package/workspace/lib/meeting-material.js +12 -5
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/programs.js +129 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-brief-page.js +8 -1
- package/workspace/lib/routes-briefing-premium.js +1 -1
- package/workspace/lib/routes-calendar-views.js +24 -3
- package/workspace/lib/routes-meeting-material.js +38 -0
- package/workspace/lib/routes-meeting-points.js +23 -3
- package/workspace/lib/routes-programs.js +122 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +31 -25
- package/workspace/premium-chat-context-test.js +1 -1
- package/workspace/premium-chat-goal-view-test.js +1 -1
- package/workspace/premium-chat-viewer-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +13 -7
- package/workspace/premium-discuss-landing-test.js +83 -0
- package/workspace/premium-link-suggest-test.js +103 -0
- package/workspace/premium-report-read-test.js +86 -82
- package/workspace/premium-vw-backlog-test.js +6 -5
- package/workspace/premium-vw-cal-test.js +45 -19
- package/workspace/premium-vw-item-test.js +8 -6
- package/workspace/premium-vw-jira-test.js +3 -2
- package/workspace/premium-vw-meet-test.js +122 -66
- package/workspace/premium-vw-notes-test.js +7 -6
- package/workspace/premium-vw-rec-test.js +14 -13
- package/workspace/premium-vw-slides-test.js +11 -5
- package/workspace/program-panel-test.js +152 -0
- package/workspace/public/pm/bd-acts.js +24 -15
- package/workspace/public/pm/bd-asks.js +111 -30
- package/workspace/public/pm/bd-ini-panel.js +229 -0
- package/workspace/public/pm/bd-pop.js +2 -2
- package/workspace/public/pm/bd-prog-panel.js +436 -0
- package/workspace/public/pm/bd-prog.js +191 -0
- package/workspace/public/pm/bd-span.js +98 -15
- package/workspace/public/pm/bd-views.js +93 -29
- package/workspace/public/pm/cozy-board.css +214 -20
- package/workspace/public/pm/cozy-evui.js +4 -2
- package/workspace/public/pm/cozy-home-rows.css +54 -0
- package/workspace/public/pm/cozy-home.css +35 -0
- package/workspace/public/pm/cozy-insights.css +1 -2
- package/workspace/public/pm/cozy-mtg-present.css +160 -0
- package/workspace/public/pm/cozy-panel.css +155 -0
- package/workspace/public/pm/cozy-rec-pill.css +12 -0
- package/workspace/public/pm/cozy-rec-pill.js +46 -0
- package/workspace/public/pm/cozy-today.css +189 -0
- package/workspace/public/pm/cozy-viewer.js +307 -43
- package/workspace/public/pm/cozy-vw-mtg.css +96 -94
- package/workspace/public/pm/cozy-vw-rp.css +40 -25
- package/workspace/public/pm/cozy-vw-shell.css +127 -0
- package/workspace/public/pm/cozy-xv.css +51 -0
- package/workspace/public/pm/cozy-xv.js +34 -0
- package/workspace/public/pm/home-app.js +192 -72
- package/workspace/public/pm/home-chat.js +17 -4
- package/workspace/public/pm/home-data.js +1 -1
- package/workspace/public/pm/home-day.js +64 -0
- package/workspace/public/pm/home-ini-model.js +1 -1
- package/workspace/public/pm/home-ini.js +197 -54
- package/workspace/public/pm/home-list.js +100 -27
- package/workspace/public/pm/home-mentions.js +187 -0
- package/workspace/public/pm/home-rec-row.js +67 -0
- package/workspace/public/pm/home-review.js +20 -10
- package/workspace/public/pm/home-task.js +19 -18
- package/workspace/public/pm/home-today.js +137 -59
- package/workspace/public/pm/premium-board.js +294 -288
- package/workspace/public/pm/premium-insights.js +118 -82
- package/workspace/public/pm/premium-mtg-present.js +408 -100
- package/workspace/public/pm/premium-mtg-replay.js +70 -10
- package/workspace/public/pm/premium-report-read.js +118 -63
- package/workspace/public/pm/premium-vw-cal.js +62 -34
- package/workspace/public/pm/premium-vw-mtg.js +348 -192
- package/workspace/public/pm/program-model.js +192 -0
- package/workspace/public/pm/rec-state.js +63 -0
- package/workspace/public/pm/rp-parts.js +33 -8
- package/workspace/public/pm/tk-draft.js +107 -0
- package/workspace/public/pm/tk-model.js +134 -0
- package/workspace/public/pm/tk-send.js +124 -0
- package/workspace/public/pm/tk-tasks.css +120 -0
- package/workspace/public/premium-board.html +4 -2
- package/workspace/server.js +4 -2
- package/workspace/skills/jira-push.skill +3 -3
- package/workspace/test-lists/board-programs.json +9 -0
- package/workspace/test-lists/prd-to-jira.json +6 -0
- package/workspace/test-lists/program-hierarchy.json +11 -0
- package/workspace/test-lists/program-panel.json +9 -0
- package/workspace/test-lists/viewer-home-rows.json +9 -0
- package/workspace/test-lists/viewer-meetings.json +9 -0
- package/workspace/test-lists/viewer-shell-a.json +15 -0
- package/workspace/tk-tasks-test.js +199 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/programs.js — programs: the level above initiatives, across products (initiative program-hierarchy, P1).
|
|
3
|
+
*
|
|
4
|
+
* fold(lines) → { [id]: program } PURE. The program records of ONE workspace's ledger
|
|
5
|
+
* merge(perWs) → [program] PURE. perWs: [{ ws, lines }]; the same program id in two workspaces is one program
|
|
6
|
+
* program: { id, title, owner, goal, why, start, target, jira, from, milestones, members, tasks, home }
|
|
7
|
+
* validProgram(b) · validMilestone(m) what a write accepts, or { error }
|
|
8
|
+
*
|
|
9
|
+
* WHERE A PROGRAM LIVES. A program spans products, and a product is a workspace with its own state folder. So there is no one folder a
|
|
10
|
+
* program "belongs" to: each workspace's <state>/programs.jsonl holds the program lines written FROM that workspace — the charter where the
|
|
11
|
+
* program was made, and a `member` line beside each initiative that joins it, in that initiative's own workspace. Reading merges every
|
|
12
|
+
* registered workspace's ledger by program id. The program is a PMOS record (PM, 2026-10-23): most teams' Jira has no Program level, so
|
|
13
|
+
* `jira` is an optional key that is only read, never written to Jira.
|
|
14
|
+
*
|
|
15
|
+
* A LINE is one of:
|
|
16
|
+
* { kind: 'program', id, title, owner?, goal?, start?, target?, jira?, from?, milestones?: [{ id, name, date?, waits: [initiative id], done? }] } the last wins
|
|
17
|
+
* `from`: the initiative a turned program came from ("Turn into a program"), in the charter's workspace
|
|
18
|
+
* { kind: 'check', program, milestone, done: true|false } the PM marks a program check done (canvas PgMilestones); the last line wins
|
|
19
|
+
* { kind: 'member', program, initiative } the initiative (of the workspace whose ledger holds the line) joins the program
|
|
20
|
+
* { kind: 'leave', program, initiative }
|
|
21
|
+
* { kind: 'task', program, key, title, owner?, due? } a task on the program itself; the last line for a key wins
|
|
22
|
+
* { kind: 'task-done', program, key, done: true|false }
|
|
23
|
+
* { kind: 'archive', program }
|
|
24
|
+
* A PROGRAM'S SPAN is `start` to `target` (canvas PgProgram, "Sep 2026 to Jun 2028"): a program can run for years, longer than any one
|
|
25
|
+
* initiative. A MILESTONE waits on initiatives (it is ready when they pass ◆ Deliver, derived on the page), or on none: then it is "a program
|
|
26
|
+
* check" (canvas PgMilestones) and its `done` is the PM's own mark, a `check` line. A milestone that waits on initiatives carries no `done`.
|
|
27
|
+
* Nothing about a program is typed that its initiatives already say: its products, its state and its stage spread are derived on the page
|
|
28
|
+
* (public/pm/program-model.js), from the initiatives' own rows. */
|
|
29
|
+
|
|
30
|
+
const ID_RE = /^[a-z0-9][a-z0-9-]{0,60}$/;
|
|
31
|
+
const INI_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/;
|
|
32
|
+
const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
33
|
+
const str = (v, n) => String(v == null ? '' : v).replace(/[\u0000-\u001f]+/g, ' ').trim().slice(0, n);
|
|
34
|
+
|
|
35
|
+
/** A program id from a title: "Project Ascent" → "project-ascent". */
|
|
36
|
+
const slug = (t) => String(t || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60);
|
|
37
|
+
|
|
38
|
+
function validMilestone(m, i) {
|
|
39
|
+
if (!m || typeof m !== 'object') return { error: 'a milestone is { name, date?, waits }' };
|
|
40
|
+
const name = str(m.name, 80);
|
|
41
|
+
if (!name) return { error: 'name the milestone' };
|
|
42
|
+
if (m.date && !DAY_RE.test(String(m.date))) return { error: 'a milestone date is YYYY-MM-DD' };
|
|
43
|
+
const waits = (Array.isArray(m.waits) ? m.waits : []).map(String).filter((x) => INI_RE.test(x)).slice(0, 20);
|
|
44
|
+
const out = { id: ID_RE.test(String(m.id || '')) ? String(m.id) : 'm' + (i + 1), name, date: m.date || '', waits };
|
|
45
|
+
if (!waits.length) out.done = m.done === true; // a program check: the PM marks it done; a milestone with initiatives is done when they are
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function validProgram(b) {
|
|
50
|
+
const title = str(b && b.title, 120);
|
|
51
|
+
if (!title) return { error: 'name the program' };
|
|
52
|
+
const id = ID_RE.test(String((b && b.id) || '')) ? String(b.id) : slug(title);
|
|
53
|
+
if (!ID_RE.test(id)) return { error: 'the program needs a name made of letters or numbers' };
|
|
54
|
+
if (b.target && !DAY_RE.test(String(b.target))) return { error: 'the target date is YYYY-MM-DD' };
|
|
55
|
+
if (b.start && !DAY_RE.test(String(b.start))) return { error: 'the start date is YYYY-MM-DD' };
|
|
56
|
+
if (b.start && b.target && String(b.start) > String(b.target)) return { error: 'the start date is after the target date' };
|
|
57
|
+
const milestones = [];
|
|
58
|
+
for (const [i, m] of (Array.isArray(b.milestones) ? b.milestones : []).slice(0, 12).entries()) {
|
|
59
|
+
const v = validMilestone(m, i);
|
|
60
|
+
if (v.error) return v;
|
|
61
|
+
if (milestones.some((x) => x.id === v.id)) return { error: 'two milestones have the id ' + v.id };
|
|
62
|
+
milestones.push(v);
|
|
63
|
+
}
|
|
64
|
+
return { kind: 'program', id, title, owner: str(b.owner, 80), goal: str(b.goal, 160), why: str(b.why, 600), start: b.start || '', target: b.target || '', jira: str(b.jira, 40), milestones };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const blank = (id) => ({ id, title: id, owner: '', goal: '', why: '', start: '', target: '', jira: '', from: '', milestones: [], members: [], tasks: [], archived: false, at: '' });
|
|
68
|
+
|
|
69
|
+
/** A program check's done mark from the `check` lines (the last line for a milestone wins) over the charter's own `done`. */
|
|
70
|
+
const withChecks = (milestones, checks) => (milestones || []).map((m) => {
|
|
71
|
+
const waits = Array.isArray(m.waits) ? m.waits : [];
|
|
72
|
+
if (waits.length) { const out = { ...m }; delete out.done; return out; }
|
|
73
|
+
return { ...m, waits, done: checks && Object.prototype.hasOwnProperty.call(checks, m.id) ? !!checks[m.id] : m.done === true };
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/** The programs one workspace's ledger says, members carrying no workspace yet (merge adds it). `checks` holds the check lines, by milestone id. */
|
|
77
|
+
function fold(lines) {
|
|
78
|
+
const out = {};
|
|
79
|
+
const get = (id) => out[id] || (out[id] = { ...blank(id), charter: false, checks: {} });
|
|
80
|
+
for (const l of lines || []) {
|
|
81
|
+
if (!l || typeof l !== 'object') continue;
|
|
82
|
+
if (l.kind === 'program' && ID_RE.test(String(l.id || ''))) {
|
|
83
|
+
const p = get(l.id);
|
|
84
|
+
Object.assign(p, { title: l.title || p.title, owner: l.owner || '', goal: l.goal || '', why: l.why || '', start: l.start || '', target: l.target || '', jira: l.jira || '',
|
|
85
|
+
from: INI_RE.test(String(l.from || '')) ? String(l.from) : p.from || '', milestones: Array.isArray(l.milestones) ? l.milestones : [], charter: true, at: p.at || l.at || '' });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const pid = String(l.program || '');
|
|
89
|
+
if (!ID_RE.test(pid)) continue;
|
|
90
|
+
const p = get(pid);
|
|
91
|
+
if (l.kind === 'member' || l.kind === 'leave') {
|
|
92
|
+
if (!INI_RE.test(String(l.initiative || ''))) continue;
|
|
93
|
+
p.members = p.members.filter((x) => x !== l.initiative);
|
|
94
|
+
if (l.kind === 'member') p.members.push(String(l.initiative));
|
|
95
|
+
} else if (l.kind === 'task' && l.key && l.title) {
|
|
96
|
+
const t = { key: String(l.key), title: String(l.title), owner: l.owner || '', due: l.due || '', done: false };
|
|
97
|
+
const i = p.tasks.findIndex((x) => x.key === t.key);
|
|
98
|
+
if (i >= 0) p.tasks[i] = { ...t, done: p.tasks[i].done }; else p.tasks.push(t);
|
|
99
|
+
} else if (l.kind === 'task-done') {
|
|
100
|
+
const t = p.tasks.find((x) => x.key === String(l.key));
|
|
101
|
+
if (t) t.done = !!l.done;
|
|
102
|
+
} else if (l.kind === 'check' && ID_RE.test(String(l.milestone || ''))) p.checks[String(l.milestone)] = !!l.done;
|
|
103
|
+
else if (l.kind === 'archive') p.archived = true;
|
|
104
|
+
}
|
|
105
|
+
for (const p of Object.values(out)) p.milestones = withChecks(p.milestones, p.checks);
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** perWs: [{ ws, lines }] → the programs, each with members [{ ws, initiative }] and the workspace its charter is in (home). */
|
|
110
|
+
function merge(perWs) {
|
|
111
|
+
const all = {};
|
|
112
|
+
for (const { ws, lines } of perWs || []) {
|
|
113
|
+
const one = fold(lines);
|
|
114
|
+
for (const p of Object.values(one)) {
|
|
115
|
+
const m = all[p.id] || (all[p.id] = { ...blank(p.id), home: '', checks: {} });
|
|
116
|
+
if (p.charter) Object.assign(m, { title: p.title, owner: p.owner, goal: p.goal, why: p.why, start: p.start, target: p.target, jira: p.jira, from: p.from, milestones: p.milestones, home: ws, at: p.at });
|
|
117
|
+
Object.assign(m.checks, p.checks);
|
|
118
|
+
for (const ini of p.members) if (!m.members.some((x) => x.ws === ws && x.initiative === ini)) m.members.push({ ws, initiative: ini });
|
|
119
|
+
for (const t of p.tasks) m.tasks.push({ ...t, ws });
|
|
120
|
+
if (p.archived) m.archived = true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// the check lines of every workspace apply to the charter's milestones (the route writes them to the charter's workspace)
|
|
124
|
+
for (const m of Object.values(all)) { m.milestones = withChecks(m.milestones, m.checks); delete m.checks; }
|
|
125
|
+
// a program with no charter anywhere is a member line whose program was never made: it is not shown
|
|
126
|
+
return Object.values(all).filter((p) => p.home && !p.archived).sort((a, b) => String(a.title).localeCompare(String(b.title)));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = { fold, merge, validProgram, validMilestone, slug, ID_RE, INI_RE };
|
|
@@ -56,6 +56,7 @@ const MODULES = Object.freeze([
|
|
|
56
56
|
'routes-home-review', // premium-uncovered-features (Home): the weekly review's four steps and the untouched work looked at (page press; file mode)
|
|
57
57
|
'routes-initiative-premium', // briefing-premium-initiative: the premium initiative page's model from the Initiatives sheet's own routes (read-only)
|
|
58
58
|
'routes-initiative-layout', // premium-uncovered-features (Initiative): Moves on by itself, held stages, task groups and saved group sets (page press; file mode)
|
|
59
|
+
'routes-programs', // program-hierarchy: programs above initiatives across products, their members, tasks and milestones (page press; file mode)
|
|
59
60
|
'routes-brief-page', // console3 Briefing as the brief: Today agenda, Needs you and Mentions (read-only; writes go through routes-pm-items)
|
|
60
61
|
'routes-mentions', // console3 Briefing Mentions: the PM's read marks (page press only)
|
|
61
62
|
'routes-inbox', // premium-agent-inbox: the bell's agent results and the PM's seen marks (page press only)
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
* Confluence or mail (initiative c3-brief-summary-mentions). Newest first: { id, source, who, where, text, at, reply, link, initiative,
|
|
22
22
|
* in_needs, need_key, read }. text is the item's quote, else its ask, else its title. at is the time of the author's last message in the item's thread.
|
|
23
23
|
* reply is the item's reply_needed. in_needs: a worth-asking item, which Needs you shows as its row need_key ("ask:<id>"). A mention whose ledger copy
|
|
24
|
-
* (brief:<id>) is done or dropped is left out.
|
|
24
|
+
* (brief:<id>) is done or dropped is left out. thread: the item's last six messages { who, at, text }; checks: the brief's own
|
|
25
|
+
* checks (strings). Both are absent when the brief has none. read: the PM marked it read (<runtime>/mentions/read.jsonl). A field the item lacks is absent.
|
|
25
26
|
* mentions is null when there is no brief for today.
|
|
26
27
|
* Item fields read defensively (a missing field is absent): kind, defer, person, evidence, workPlacement(item, today) when lib/pm-items.js
|
|
27
28
|
* has it. A deferred item ('Not yet') is left out until its defer date or time. Writes go through the existing pm-items routes; a mention's
|
|
@@ -183,6 +184,12 @@ function mentionsOf(brief, itemLines, reads, todayIso) {
|
|
|
183
184
|
row.at = mine.length ? new Date(mine[mine.length - 1].at).toISOString() : null;
|
|
184
185
|
const link = httpsUrl(x.link); if (link) row.link = link;
|
|
185
186
|
if (x.initiative_id) row.initiative = x.initiative_id;
|
|
187
|
+
// the source excerpt and what was checked, for the Mentions Viewer (Viewer kit, XvAMention*): the thread's last messages, and the
|
|
188
|
+
// checks the brief says it made. Neither is invented: a brief with no thread or no checks gives none
|
|
189
|
+
const msgs = thread.filter((m) => m && (m.text || m.who)).slice(-6).map((m) => ({ who: clip(m.who || '', 80), at: m.at && !Number.isNaN(Date.parse(m.at)) ? new Date(m.at).toISOString() : null, text: clip(m.text || '', 400) }));
|
|
190
|
+
if (msgs.length) row.thread = msgs;
|
|
191
|
+
const checks = (Array.isArray(x.checks) ? x.checks : []).map((c) => clip(typeof c === 'string' ? c : c && c.text, 240)).filter(Boolean).slice(0, 6);
|
|
192
|
+
if (checks.length) row.checks = checks;
|
|
186
193
|
if (row.in_needs) row.need_key = 'ask:' + x.id; // the Needs you row it is (briefing-real.js askNeed)
|
|
187
194
|
out.push(row);
|
|
188
195
|
}
|
|
@@ -34,7 +34,7 @@ const settings = require('./settings-store.js');
|
|
|
34
34
|
/** The workspaces the Briefing may read right now (initiative briefing-premium-products): choose()'s list, from the server's workspace list and the PM's setting. */
|
|
35
35
|
function products(ctx, only) {
|
|
36
36
|
const home = ctx.homeRoot || ctx.selfRoot || null;
|
|
37
|
-
const list = (typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : []).map((w) => ({ id: w.id, name: w.label || w.name, root: w.root, home: !!home && path.resolve(w.root) === path.resolve(home) }));
|
|
37
|
+
const list = (typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : []).map((w) => ({ id: w.id, name: w.label || w.name, root: w.root, initials: w.initials, home: !!home && path.resolve(w.root) === path.resolve(home) }));
|
|
38
38
|
return Prod.choose({ workspaces: list, include: settings.get(ctx.runtimeDir, 'ws.briefing.include', null), only });
|
|
39
39
|
}
|
|
40
40
|
/** The included product a merged row (or a returned run) belongs to: { root, ws } | { error }. null when the key is the one-workspace page's. */
|
|
@@ -185,6 +185,26 @@ function reportSchedules(RN, range) {
|
|
|
185
185
|
return out;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
/** The decisions and next steps of a note, each with confirmed: true when the PM confirmed or corrected it, else false. A corrected
|
|
189
|
+
* point carries the PM's words. A point marked not right is left out. */
|
|
190
|
+
function confirmedPoints(runtimeDir, noteId, decisions, actions) {
|
|
191
|
+
let pts = {}, eds = {};
|
|
192
|
+
try { pts = require('./meeting-points.js').pointsOf(runtimeDir, noteId); } catch { pts = {}; }
|
|
193
|
+
try { eds = require('./meeting-learn.js').editsOf(runtimeDir, noteId); } catch { eds = {}; }
|
|
194
|
+
const out = { decisions: [], actions: [] };
|
|
195
|
+
const put = (list, k) => (list || []).forEach((x, i) => {
|
|
196
|
+
const id = k[0] + (i + 1), e = eds[id];
|
|
197
|
+
if (pts[id] === 'wrong') return;
|
|
198
|
+
const kind = e && ['decision', 'action'].includes(e.kind) ? e.kind : e ? null : k;
|
|
199
|
+
if (!kind) return; // corrected into a question: not a decision or a step any more
|
|
200
|
+
const row = { text: e ? e.text : x && x.text, confirmed: !!e || pts[id] === 'confirmed' };
|
|
201
|
+
if (kind === 'action') { row.owner = x && x.owner || null; row.due = x && x.due || null; }
|
|
202
|
+
out[kind + 's'].push(row);
|
|
203
|
+
});
|
|
204
|
+
put(decisions, 'decision'); put(actions, 'action');
|
|
205
|
+
return out;
|
|
206
|
+
}
|
|
207
|
+
|
|
188
208
|
/** Notes linked to a calendar event, read straight from the notes folder (no import, no write). */
|
|
189
209
|
function linkedNotes(runtimeDir) {
|
|
190
210
|
const fs = require('fs');
|
|
@@ -203,8 +223,9 @@ function linkedNotes(runtimeDir) {
|
|
|
203
223
|
out.push({ id: n.id, title: n.title || '', private: !!n.private, initiative: n.initiative && n.initiative.id ? String(n.initiative.id) : null, board: nb, portfolio: n.portfolio === true,
|
|
204
224
|
meeting: { event_id: n.meeting.event_id || null, start: n.meeting.start, title: n.meeting.title, series: n.meeting.context && n.meeting.context.series || null },
|
|
205
225
|
overview: String(ov).replace(/\s+/g, ' ').trim().slice(0, 600),
|
|
206
|
-
|
|
207
|
-
|
|
226
|
+
// a caught point counts as a fact only once the PM confirmed or corrected it in Replay (lib/meeting-points.js, lib/meeting-learn.js);
|
|
227
|
+
// the ids are the ones lib/meeting-replay.js gives (d1, a1): the kind's first letter and the place in its list
|
|
228
|
+
...confirmedPoints(runtimeDir, n.id, pick(fin && fin.decisions, sec && sec.decisions), pick(fin && fin.actions, sec && sec.actions)) });
|
|
208
229
|
}
|
|
209
230
|
return out;
|
|
210
231
|
}
|
|
@@ -224,7 +245,7 @@ async function postLink(req, res, ctx) {
|
|
|
224
245
|
}
|
|
225
246
|
|
|
226
247
|
module.exports = {
|
|
227
|
-
readers,
|
|
248
|
+
readers, confirmedPoints,
|
|
228
249
|
prefixes: ['/api/calendar-views', '/api/calendar-links', '/api/calendar-today', '/api/calendar-events'],
|
|
229
250
|
handlePure: handle,
|
|
230
251
|
handle: async (req, res, url, ctx) => {
|
|
@@ -7,13 +7,19 @@
|
|
|
7
7
|
* series is empty). With topics=1 the answer also lists the topics Focus starts the meeting with, for the Add material sheet.
|
|
8
8
|
* POST /api/meeting-material { op?: 'add'|'remove', event: { id?, title, series? }, scope: 'meeting'|'series', item: { kind, ref|url, title?, ws? }, topic?, present? }
|
|
9
9
|
* → { ok, items } page press (lib/pm-guard.js requirePagePress). Appends one line to <runtime>/meeting-material.jsonl. The calendar is never written.
|
|
10
|
+
* POST /api/meeting-material/file?name=<file name> the raw bytes (Upload a file; page press) → { ok, name, kind, size }
|
|
11
|
+
* keeps the file in <runtime>/meeting-files (lib/meeting-files.js); the page then adds it with item { kind: 'file', ref: name }
|
|
12
|
+
* GET /api/meeting-material/file?name=<stored name> → the file: an image or PDF inline, an HTML file inline in a sandbox of its
|
|
13
|
+
* own origin, a PowerPoint file as a download
|
|
10
14
|
* GET /api/meeting-material/suggest?ws=&initiative=&board=&q=[&limit=]
|
|
11
15
|
* → { ok, suggested: [pick], found: [pick] } pick: { kind, ref, title, meta, why?, present, ws }
|
|
12
16
|
* suggested: the documents of the meeting's level (the initiative's, newest first) and the newest report cycles. found: a search over the
|
|
13
17
|
* titles and paths of PMOS documents and report cycles (two letters or more). Read-only.
|
|
14
18
|
*
|
|
15
19
|
* Handlers are pure over (req, body, ctx): ctx = { runtimeDir, getWs, stateDirFor?, initiativeIndex?, readEvents?, briefFor?, json } so a test needs no server. */
|
|
20
|
+
const fs = require('fs');
|
|
16
21
|
const store = require('./meeting-material.js');
|
|
22
|
+
const files = require('./meeting-files.js');
|
|
17
23
|
const guard = require('./pm-guard.js');
|
|
18
24
|
|
|
19
25
|
const fail = (status, error, extra) => ({ status, body: { ok: false, error, ...(extra || {}) } });
|
|
@@ -123,6 +129,37 @@ function suggest(q, ctx) {
|
|
|
123
129
|
|
|
124
130
|
const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true; };
|
|
125
131
|
|
|
132
|
+
function readRaw(req, max) {
|
|
133
|
+
return new Promise((resolve) => {
|
|
134
|
+
const parts = []; let n = 0, over = false;
|
|
135
|
+
req.on('data', (c) => { if (over) return; n += c.length; if (n > max) { over = true; parts.length = 0; return; } parts.push(c); });
|
|
136
|
+
req.on('end', () => resolve(over ? { over: true } : { buf: Buffer.concat(parts) }));
|
|
137
|
+
req.on('error', () => resolve({ over: false, buf: null }));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** Upload a file (POST, page press) and read one back (GET). */
|
|
141
|
+
async function file(req, res, url, ctx) {
|
|
142
|
+
if (req.method === 'GET' || req.method === 'HEAD') {
|
|
143
|
+
const f = files.servable(ctx.runtimeDir, url.searchParams.get('name'));
|
|
144
|
+
if (!f.ok) return respond(ctx, res, fail(f.status, f.error));
|
|
145
|
+
const shown = require('path').basename(f.file).replace(/^\d{8}T\d{6}-/, '');
|
|
146
|
+
res.writeHead(200, { 'Content-Type': f.type, 'Content-Length': f.size, 'X-Content-Type-Options': 'nosniff', 'Cache-Control': 'private, max-age=3600',
|
|
147
|
+
'Content-Disposition': (f.inline ? 'inline' : 'attachment') + '; filename="' + shown + '"', ...(f.sandbox || !f.inline ? { 'Content-Security-Policy': 'sandbox allow-scripts allow-forms allow-popups' } : {}) });
|
|
148
|
+
if (req.method === 'HEAD') { res.end(); return true; }
|
|
149
|
+
fs.createReadStream(f.file).pipe(res);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (req.method !== 'POST') return respond(ctx, res, fail(405, 'GET or POST only'));
|
|
153
|
+
if (req.headers && req.headers['x-pmos-session']) return respond(ctx, res, fail(403, 'an agent session cannot add material to a meeting'));
|
|
154
|
+
const g = guard.requirePagePress(req, {});
|
|
155
|
+
if (!g.ok) return respond(ctx, res, fail(g.status, g.error));
|
|
156
|
+
const raw = await readRaw(req, files.MAX_BYTES);
|
|
157
|
+
if (raw.over) return respond(ctx, res, fail(413, 'The file is larger than 20 MB.'));
|
|
158
|
+
let r;
|
|
159
|
+
try { r = files.save({ runtimeDir: ctx.runtimeDir, name: url.searchParams.get('name') || 'file', buf: raw.buf }); } catch (e) { r = { ok: false, status: 500, error: 'The file could not be kept: ' + String((e && e.message) || e).slice(0, 120) }; }
|
|
160
|
+
return respond(ctx, res, r.ok ? { status: 200, body: { ok: true, name: r.name, kind: r.kind, size: r.size } } : fail(r.status, r.error));
|
|
161
|
+
}
|
|
162
|
+
|
|
126
163
|
module.exports = {
|
|
127
164
|
prefixes: ['/api/meeting-material'],
|
|
128
165
|
list, post, suggest, candidates,
|
|
@@ -133,6 +170,7 @@ module.exports = {
|
|
|
133
170
|
if (req.method !== 'GET') return respond(ctx, res, fail(405, 'GET only'));
|
|
134
171
|
return respond(ctx, res, suggest(q, ctx));
|
|
135
172
|
}
|
|
173
|
+
if (p === '/api/meeting-material/file') return file(req, res, url, ctx);
|
|
136
174
|
if (p !== '/api/meeting-material') return false;
|
|
137
175
|
if (req.method === 'GET') return respond(ctx, res, await list(q, ctx));
|
|
138
176
|
if (req.method !== 'POST') return respond(ctx, res, fail(405, 'GET or POST only'));
|
|
@@ -4,15 +4,28 @@
|
|
|
4
4
|
*
|
|
5
5
|
* GET /api/meeting-points?note=<id> → { ok, points: { [pointId]: 'confirmed' | 'wrong' } }
|
|
6
6
|
* POST /api/meeting-points { note, ids: [pointId], verdict } → { ok, points } verdict confirmed | wrong | null (Undo)
|
|
7
|
-
*
|
|
7
|
+
* The GET also answers { edits, lessons }: the PM's corrections to the note's points and what PMOS learned (lib/meeting-learn.js).
|
|
8
|
+
* POST /api/meeting-points/edit { note, id, kind, text, orig: { kind, text }, learn, items: [{ id, text }] } → { ok, edits, lesson, check }
|
|
9
|
+
* a corrected point (XvAReplayEdit). learn false is "Only fix this one". check: the other points of the note that use the learned words.
|
|
10
|
+
* POST /api/meeting-points/forget { lesson } → { ok } Undo of what PMOS learned
|
|
11
|
+
* The POSTs are page presses (lib/pm-guard.js requirePagePress). Handlers are pure over (q | body, ctx) so a test needs no server. */
|
|
8
12
|
const MP = require('./meeting-points.js');
|
|
13
|
+
const ML = require('./meeting-learn.js');
|
|
9
14
|
const guard = require('./pm-guard.js');
|
|
10
15
|
|
|
11
16
|
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
12
17
|
|
|
13
18
|
function read(q, ctx) {
|
|
14
19
|
if (!/^[A-Za-z0-9_-]{1,80}$/.test(String(q.note || ''))) return fail(400, 'note is the id of a meeting note');
|
|
15
|
-
|
|
20
|
+
const note = String(q.note);
|
|
21
|
+
return { status: 200, body: { ok: true, points: MP.pointsOf(ctx.runtimeDir, note), edits: ML.editsOf(ctx.runtimeDir, note), lessons: ML.lessons(ctx.runtimeDir).filter((x) => x.phrase).slice(-30) } };
|
|
22
|
+
}
|
|
23
|
+
function learn(req, body, ctx, op) {
|
|
24
|
+
const g = guard.requirePagePress(req, body);
|
|
25
|
+
if (!g.ok) return fail(g.status, g.error);
|
|
26
|
+
const r = op === 'forget' ? ML.forget(ctx.runtimeDir, body) : ML.edit(ctx.runtimeDir, body);
|
|
27
|
+
if (!r.ok) return fail(r.status || 400, r.error);
|
|
28
|
+
return { status: 200, body: r };
|
|
16
29
|
}
|
|
17
30
|
function write(req, body, ctx) {
|
|
18
31
|
const g = guard.requirePagePress(req, body);
|
|
@@ -25,8 +38,15 @@ const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true;
|
|
|
25
38
|
|
|
26
39
|
module.exports = {
|
|
27
40
|
prefixes: ['/api/meeting-points'],
|
|
28
|
-
read, write,
|
|
41
|
+
read, write, learn,
|
|
29
42
|
handle: async (req, res, url, ctx) => {
|
|
43
|
+
const op = url.pathname === '/api/meeting-points/edit' ? 'edit' : url.pathname === '/api/meeting-points/forget' ? 'forget' : '';
|
|
44
|
+
if (op) {
|
|
45
|
+
if (req.method !== 'POST') return respond(ctx, res, fail(405, 'POST only'));
|
|
46
|
+
const got = await ctx.readJson(req);
|
|
47
|
+
if (!got.ok || !got.body || typeof got.body !== 'object' || Array.isArray(got.body)) return respond(ctx, res, fail(400, 'the body must be a JSON object'));
|
|
48
|
+
return respond(ctx, res, learn(req, got.body, ctx, op));
|
|
49
|
+
}
|
|
30
50
|
if (url.pathname !== '/api/meeting-points') return false;
|
|
31
51
|
if (req.method === 'GET') return respond(ctx, res, read(Object.fromEntries(url.searchParams), ctx));
|
|
32
52
|
if (req.method !== 'POST') return respond(ctx, res, fail(405, 'GET or POST'));
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-programs.js — programs, the level above initiatives across products (initiative program-hierarchy, P1 and P7).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/programs → { ok, programs: [program] } merged from every registered workspace (lib/programs.js merge)
|
|
5
|
+
* POST /api/programs/save { ws, program } the charter: title, owner, goal, why, start, target, jira, milestones (the last save wins)
|
|
6
|
+
* POST /api/programs/member { ws, program, initiative, leave? } an initiative of workspace `ws` joins (or leaves) the program
|
|
7
|
+
* POST /api/programs/turn { ws, initiative, title? } "Turn into a program": a charter named after the initiative, which joins it; the
|
|
8
|
+
* charter keeps `from` (the initiative), so the panel can count its tasks with no level
|
|
9
|
+
* POST /api/programs/task { ws, program, title, owner?, due?, key? } a task on the program itself
|
|
10
|
+
* POST /api/programs/task-done { ws, program, key, done }
|
|
11
|
+
* POST /api/programs/check { program, milestone, done } the PM marks a program check (a milestone that waits on no initiative) done or
|
|
12
|
+
* not; the line goes to the workspace the charter is in, whatever `ws` says
|
|
13
|
+
* POST /api/programs/archive { ws, program }
|
|
14
|
+
*
|
|
15
|
+
* FILE MODE ONLY (D64/D66): <state>/programs.jsonl of the workspace named by `ws`, append-only. Every POST is a page press (pm-guard
|
|
16
|
+
* requirePagePress): an agent session cannot make, join or archive a program. Nothing here writes to Jira. */
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const guard = require('./pm-guard.js');
|
|
19
|
+
const pmItems = require('./pm-items.js');
|
|
20
|
+
const P = require('./programs.js');
|
|
21
|
+
|
|
22
|
+
const str = (v, n) => String(v == null ? '' : v).replace(/[\u0000-\u001f]+/g, ' ').trim().slice(0, n);
|
|
23
|
+
const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
24
|
+
|
|
25
|
+
function stateDir(ctx, w) {
|
|
26
|
+
let d = null;
|
|
27
|
+
try { d = ctx.stateDirFor ? ctx.stateDirFor(w, { create: true }) : null; } catch { d = null; }
|
|
28
|
+
return d || (w && w.root ? path.join(w.root, 'pmos', 'state') : null);
|
|
29
|
+
}
|
|
30
|
+
const fileOf = (ctx, w) => { const d = stateDir(ctx, w); return d ? path.join(d, 'programs.jsonl') : null; };
|
|
31
|
+
const read = (f) => { try { return f ? pmItems.readLines(f).filter(Boolean) : []; } catch { return []; } };
|
|
32
|
+
|
|
33
|
+
/** Every registered workspace's ledger, merged. */
|
|
34
|
+
function all(ctx) {
|
|
35
|
+
const list = (ctx.workspaceList ? ctx.workspaceList() : []) || [];
|
|
36
|
+
return P.merge(list.map((w) => ({ ws: w.id, lines: read(fileOf(ctx, w)) })));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
prefixes: ['/api/programs'],
|
|
41
|
+
all,
|
|
42
|
+
handle: async (req, res, url, ctx) => {
|
|
43
|
+
const p = url.pathname;
|
|
44
|
+
const bad = (error, code) => { ctx.json(res, { ok: false, error }, code || 400); return true; };
|
|
45
|
+
if (p === '/api/programs') {
|
|
46
|
+
if (req.method !== 'GET') return bad('GET only', 405);
|
|
47
|
+
ctx.json(res, { ok: true, programs: all(ctx) });
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (req.method !== 'POST') return bad('POST only', 405);
|
|
51
|
+
const got = await ctx.readJson(req);
|
|
52
|
+
if (!got.ok) return bad('invalid JSON body');
|
|
53
|
+
const b = got.body || {};
|
|
54
|
+
const g = guard.requirePagePress(req, b);
|
|
55
|
+
if (!g.ok) return bad(g.error, g.status);
|
|
56
|
+
// a check line belongs with the charter, so every workspace's reader applies it to the same milestones
|
|
57
|
+
const home = p === '/api/programs/check' && P.ID_RE.test(String(b.program || '')) ? (all(ctx).find((x) => x.id === b.program) || {}).home : null;
|
|
58
|
+
const w = ctx.getWs ? ctx.getWs(home || b.ws || null) : null;
|
|
59
|
+
if (!w) return bad('that workspace is not registered', 404);
|
|
60
|
+
const file = fileOf(ctx, w);
|
|
61
|
+
if (!file) return bad('this workspace has no state folder', 409);
|
|
62
|
+
const now = new Date();
|
|
63
|
+
const add = (line) => pmItems.appendEvent(file, line, now);
|
|
64
|
+
const known = (id) => all(ctx).find((x) => x.id === id) || null;
|
|
65
|
+
|
|
66
|
+
if (p === '/api/programs/save' || p === '/api/programs/turn') {
|
|
67
|
+
let input = b.program || {};
|
|
68
|
+
if (p === '/api/programs/turn') {
|
|
69
|
+
if (!P.INI_RE.test(String(b.initiative || ''))) return bad('initiative must name an initiative');
|
|
70
|
+
input = { title: str(b.title, 120) || str(b.initiative, 120) };
|
|
71
|
+
}
|
|
72
|
+
const v = P.validProgram(input);
|
|
73
|
+
if (v.error) return bad(v.error);
|
|
74
|
+
if (p === '/api/programs/turn' && known(v.id)) return bad('a program with this name exists already', 409);
|
|
75
|
+
// a turned program names the initiative it came from: its tasks from before the split wait for a level (canvas PgProgram, the sort card)
|
|
76
|
+
add(p === '/api/programs/turn' ? { ...v, from: String(b.initiative) } : v);
|
|
77
|
+
if (p === '/api/programs/turn') add({ kind: 'member', program: v.id, initiative: String(b.initiative) });
|
|
78
|
+
ctx.json(res, { ok: true, program: known(v.id) });
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
const pid = String(b.program || '');
|
|
82
|
+
if (!P.ID_RE.test(pid)) return bad('program must name a program');
|
|
83
|
+
if (!known(pid)) return bad('no such program', 404);
|
|
84
|
+
if (p === '/api/programs/member') {
|
|
85
|
+
if (!P.INI_RE.test(String(b.initiative || ''))) return bad('initiative must name an initiative');
|
|
86
|
+
// an initiative is in one program at most: joining one leaves any other it is in, in this workspace
|
|
87
|
+
if (!b.leave) for (const o of all(ctx)) if (o.id !== pid && o.members.some((m) => m.ws === w.id && m.initiative === b.initiative)) add({ kind: 'leave', program: o.id, initiative: String(b.initiative) });
|
|
88
|
+
add({ kind: b.leave ? 'leave' : 'member', program: pid, initiative: String(b.initiative) });
|
|
89
|
+
ctx.json(res, { ok: true, program: known(pid) });
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (p === '/api/programs/task') {
|
|
93
|
+
const title = str(b.title, 200);
|
|
94
|
+
if (!title) return bad('the task has no text');
|
|
95
|
+
if (b.due && !DAY_RE.test(String(b.due))) return bad('due is YYYY-MM-DD');
|
|
96
|
+
const key = /^[A-Za-z0-9._-]{1,40}$/.test(String(b.key || '')) ? String(b.key) : 'pt' + now.getTime().toString(36);
|
|
97
|
+
add({ kind: 'task', program: pid, key, title, owner: str(b.owner, 80), due: b.due || '' });
|
|
98
|
+
ctx.json(res, { ok: true, key });
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (p === '/api/programs/task-done') {
|
|
102
|
+
if (!b.key) return bad('key names the task');
|
|
103
|
+
add({ kind: 'task-done', program: pid, key: String(b.key), done: !!b.done });
|
|
104
|
+
ctx.json(res, { ok: true });
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (p === '/api/programs/check') {
|
|
108
|
+
const m = (known(pid).milestones || []).find((x) => x.id === String(b.milestone || ''));
|
|
109
|
+
if (!m) return bad('no such milestone', 404);
|
|
110
|
+
if ((m.waits || []).length) return bad('this milestone waits on initiatives: it is done when they pass Deliver', 409);
|
|
111
|
+
add({ kind: 'check', program: pid, milestone: m.id, done: !!b.done });
|
|
112
|
+
ctx.json(res, { ok: true, program: known(pid) });
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (p === '/api/programs/archive') {
|
|
116
|
+
add({ kind: 'archive', program: pid });
|
|
117
|
+
ctx.json(res, { ok: true });
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return bad('no such route', 404);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.403.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.403.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED