create-pmos 0.492.0 → 0.494.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 +75 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/mods/pmos-cockpit/README.md +1 -1
- package/payload/mods/pmos-cockpit/hooks/lib/guard.mjs +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/workspace/briefing-premium-initiative-test.js +2 -1
- package/workspace/changelog.json +74 -0
- package/workspace/fixtures/initiatives-api/list.json +0 -4
- package/workspace/fixtures/initiatives-api/roadmap.json +255 -275
- package/workspace/fixtures/initiatives-api/sheet.json +2 -3
- package/workspace/fixtures/report-api/draft.json +4 -4
- package/workspace/fixtures/reports-page/draft-biweekly-2026-10-16.md +4 -4
- package/workspace/guide/board.md +2 -2
- package/workspace/guide/briefing-premium.md +2 -0
- package/workspace/guide/claude-proposes.md +2 -2
- package/workspace/guide/data-freshness.md +3 -1
- package/workspace/guide/index.md +2 -2
- package/workspace/guide/initiative-boards.md +2 -2
- package/workspace/guide/initiatives-roadmap.md +38 -39
- package/workspace/guide/initiatives-screen.md +22 -20
- package/workspace/guide/initiatives-timeline.md +7 -9
- package/workspace/guide/integrated-work.md +7 -8
- package/workspace/guide/layout.md +2 -2
- package/workspace/guide/lifecycle.md +2 -2
- package/workspace/guide/notes.md +1 -1
- package/workspace/guide/pm-only-acts.md +5 -5
- package/workspace/guide/pm-only-lines.md +3 -3
- package/workspace/guide/report-slides.md +14 -1
- package/workspace/guide/reports.md +4 -2
- package/workspace/guide/today.md +2 -2
- package/workspace/guide/your-impact.md +6 -7
- package/workspace/lib/board-cli.js +1 -1
- package/workspace/lib/board-fold.js +6 -6
- package/workspace/lib/board-premium.js +3 -3
- package/workspace/lib/board-trail.js +30 -3
- package/workspace/lib/calendar-tidy.js +1 -1
- package/workspace/lib/core-docs.js +2 -2
- package/workspace/lib/engine/boards.js +11 -11
- package/workspace/lib/engine/signals/detectors.js +13 -13
- package/workspace/lib/engine/signals/facts.js +5 -3
- package/workspace/lib/git-shape.js +21 -0
- package/workspace/lib/grill-runs.js +21 -6
- package/workspace/lib/grill.js +1 -1
- package/workspace/lib/health-rules-factory.js +13 -14
- package/workspace/lib/health-rules-plan.js +8 -7
- package/workspace/lib/impact.js +29 -16
- package/workspace/lib/initiative-cli.js +59 -63
- package/workspace/lib/initiative-needs.js +6 -6
- package/workspace/lib/initiative-premium.js +2 -2
- package/workspace/lib/initiative-writer.js +2 -2
- package/workspace/lib/lifecycle-stage.js +39 -0
- package/workspace/lib/page-warm.js +68 -0
- package/workspace/lib/placements.js +117 -95
- package/workspace/lib/plan-rules.js +7 -5
- package/workspace/lib/pm-guard.js +1 -3
- package/workspace/lib/pm-lines-needs.js +1 -1
- package/workspace/lib/report-design.js +6 -1
- package/workspace/lib/report-draft.js +17 -16
- package/workspace/lib/report-export.js +148 -9
- package/workspace/lib/report-pyramid.js +434 -0
- package/workspace/lib/report-slides-data.js +11 -7
- package/workspace/lib/report-structure.js +5 -1
- package/workspace/lib/report-templates.js +81 -20
- package/workspace/lib/routes-boards.js +9 -8
- package/workspace/lib/routes-brief-page.js +20 -3
- package/workspace/lib/routes-grill.js +10 -4
- package/workspace/lib/routes-impact.js +12 -4
- package/workspace/lib/routes-initiatives.js +29 -43
- package/workspace/lib/routes-notes.js +24 -15
- package/workspace/lib/routes-programs.js +6 -4
- package/workspace/lib/routes-report-design.js +15 -0
- package/workspace/lib/routes-report-flow.js +106 -17
- package/workspace/lib/routes-report-setups.js +2 -1
- package/workspace/lib/routes-report-structure.js +3 -0
- package/workspace/lib/split-merge.js +2 -3
- package/workspace/lib/wf-bridge.js +5 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-report-tab-test.js +5 -1
- package/workspace/public/pm/cozy-vw-rp.css +12 -0
- package/workspace/public/pm/fetch-share.js +38 -0
- package/workspace/public/pm/home-app.js +21 -3
- package/workspace/public/pm/home-chat.js +5 -4
- package/workspace/public/pm/home-impact.css +23 -13
- package/workspace/public/pm/home-impact.js +49 -32
- package/workspace/public/pm/home-ini.css +2 -0
- package/workspace/public/pm/http.js +1 -1
- package/workspace/public/pm/ini-view.css +55 -0
- package/workspace/public/pm/ini-view.js +5 -2
- package/workspace/public/pm/premium-board.js +1 -0
- package/workspace/public/pm/premium-insights.js +1 -0
- package/workspace/public/pm/premium-report-read.js +25 -6
- package/workspace/public/pm/premium-report-tab.js +69 -14
- package/workspace/public/pm/report-flow.js +93 -10
- package/workspace/public/pm/view-notes.js +8 -8
- package/workspace/replaced-tests.json +14 -0
- package/workspace/server.js +24 -3
- package/workspace/skills/report-template.skill +8 -0
- package/workspace/test-lists/page-open-speed.json +5 -0
- package/workspace/test-lists/report-pyramid.json +9 -0
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ledgerOf(root, id) <state>/reports/<id>/template.jsonl
|
|
5
5
|
* readLines(root, id) · fold(lines) → { current, versions: [{ n, settings, at, why, current }], chat, log }
|
|
6
|
-
* settingsOf(setup)
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* settingsOf(setup, refs?) → { output, audience, schedule, structure?, design? } what a template is
|
|
7
|
+
* liveRefs(root, id) → { structure: S<n> | null, design: D<n> | null } the saved sections and look now
|
|
8
|
+
* namesOf(root, id) → { sections(n) → [title] | null, look(n) → words } for the words below
|
|
9
|
+
* sameSettings(a, b) · diffWords(a, b, names) "Format: Slides → Document", "Sections: + Customers", "Look: Standard PMOS look → D3 · warmer"
|
|
10
|
+
* sectionsDiff(was, now) → "+ Customers, − Risk watch" | "new order" | ''
|
|
11
|
+
* ensureFirst(root, id, setup, { chat, refs, now }) → T1 from the setup, once. `chat` is the conversation key the report was proposed in
|
|
9
12
|
* addVersion(root, id, settings, { why, now }) → { ok, n } the PM's ✓ on a changed template: T<n+1> becomes the current one
|
|
10
13
|
* restore(root, id, n, { now }) → { ok, n } Go back to T<n>: that version is the current one again. Nothing is deleted
|
|
11
14
|
* cyclesOf(folded, issued) → Map n → issued cycles while that version was the current one
|
|
@@ -15,7 +18,10 @@
|
|
|
15
18
|
* THE LINES. { v: 1, ev, …, at }:
|
|
16
19
|
* version { n, settings, why, chat? } T<n>; the newest version line is the current template until a restore line
|
|
17
20
|
* restore { n } Go back to T<n>
|
|
18
|
-
* A template is its settings: the format (output), who reads it (audience)
|
|
21
|
+
* A template is its settings: the format (output), who reads it (audience), when it goes out (schedule), its sections (structure: the saved
|
|
22
|
+
* structure version S<n> of lib/report-structure.js, or null = the standard sections) and its look (design: the saved design version D<n> of
|
|
23
|
+
* lib/report-design.js, or null = the standard look) (canvas TplA, brief 3). A T line written before TplA has no structure or design key: it is
|
|
24
|
+
* read as "not recorded", never as a change, and Go back to it leaves the sections and look as they are. A change to any of them is a new
|
|
19
25
|
* version (the agreed note: "Changing any setting makes a different template"); the drafts and issued cycles stay with the version they were made
|
|
20
26
|
* under. The setup line in report-setups.jsonl keeps the live values: the route applies a version there with report-setups change and reschedule.
|
|
21
27
|
*
|
|
@@ -50,13 +56,33 @@ function append(root, id, line, now) {
|
|
|
50
56
|
return rec;
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
/**
|
|
54
|
-
function settingsOf(s) {
|
|
59
|
+
/** A template's settings: the three report-setups keeps, and the saved sections and look when `refs` names them. */
|
|
60
|
+
function settingsOf(s, refs) {
|
|
55
61
|
const x = isObj(s) ? s : {};
|
|
56
62
|
const sc = isObj(x.schedule) ? x.schedule : null;
|
|
57
63
|
const paused = x.status === 'paused';
|
|
58
|
-
|
|
64
|
+
const out = { output: String(x.output || ''), audience: String(x.audience || ''), schedule: !sc || paused || sc.cadence === 'off' ? 'off' : { cadence: sc.cadence, ...(sc.day ? { day: sc.day } : {}), ...(sc.dayOfMonth ? { dayOfMonth: sc.dayOfMonth } : {}), time: sc.time || '09:00' } };
|
|
65
|
+
if (isObj(refs)) { if (refs.structure !== undefined) out.structure = refN(refs.structure); if (refs.design !== undefined) out.design = refN(refs.design); }
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** A saved version number, or null (the standard sections or look). */
|
|
69
|
+
const refN = (v) => (Number.isInteger(v) && v >= 1 ? v : null);
|
|
70
|
+
/** The sections and look saved now: the structure's and the design's accept lines. */
|
|
71
|
+
function liveRefs(root, id) {
|
|
72
|
+
let structure = null, design = null;
|
|
73
|
+
try { const st = require('./report-structure.js').stateOf(root, id); structure = st.saved ? refN(st.saved.n) : null; } catch { structure = null; }
|
|
74
|
+
try { const st = require('./report-design.js').stateOf(root, id); design = st.saved ? refN(st.saved.version) : null; } catch { design = null; }
|
|
75
|
+
return { structure, design };
|
|
59
76
|
}
|
|
77
|
+
/** The words of a version's sections and look, read from their stores. */
|
|
78
|
+
function namesOf(root, id) {
|
|
79
|
+
const S = require('./report-structure.js'), D = require('./report-design.js');
|
|
80
|
+
return {
|
|
81
|
+
sections: (n) => { if (n == null) return null; try { const p = S.readVersion(root, id, n); return p && Array.isArray(p.outline) ? p.outline.map((o) => String(o.title || o.id)) : null; } catch { return null; } },
|
|
82
|
+
look: (n) => { if (n == null) return STANDARD_LOOK; let m = null; try { m = D.versionMeta(root, id, n); } catch { m = null; } const t = m && String(m.turn || '').replace(/\s+/g, ' ').trim(); return 'D' + n + (t ? ' · ' + (t.length > 40 ? t.slice(0, 39) + '…' : t) : ''); },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const STANDARD_LOOK = 'Standard PMOS look';
|
|
60
86
|
function cleanSettings(s) {
|
|
61
87
|
if (!isObj(s)) return null;
|
|
62
88
|
const out = {};
|
|
@@ -64,10 +90,22 @@ function cleanSettings(s) {
|
|
|
64
90
|
if (typeof s.audience === 'string' && s.audience.trim()) out.audience = s.audience.replace(/\s+/g, ' ').trim().slice(0, 120);
|
|
65
91
|
if (s.schedule === 'off' || (isObj(s.schedule) && s.schedule.cadence === 'off')) out.schedule = 'off';
|
|
66
92
|
else if (isObj(s.schedule) && typeof s.schedule.cadence === 'string') out.schedule = { cadence: s.schedule.cadence, ...(s.schedule.day ? { day: String(s.schedule.day) } : {}), ...(s.schedule.dayOfMonth ? { dayOfMonth: +s.schedule.dayOfMonth } : {}), time: /^\d{1,2}:\d{2}$/.test(String(s.schedule.time || '')) ? String(s.schedule.time) : '09:00' };
|
|
93
|
+
for (const k of ['structure', 'design']) if (s[k] === null || (Number.isInteger(s[k]) && s[k] >= 1)) out[k] = s[k];
|
|
67
94
|
return Object.keys(out).length ? out : null;
|
|
68
95
|
}
|
|
69
96
|
const key = (sc) => JSON.stringify(sc === 'off' || !sc ? 'off' : { c: sc.cadence, d: sc.day || null, m: sc.dayOfMonth || null, t: sc.time || '09:00' });
|
|
70
|
-
|
|
97
|
+
/** A sections or look ref differs only when both sides recorded one: an old T line (no key) is "not recorded", never a change. */
|
|
98
|
+
const refDiffers = (a, b, k) => a[k] !== undefined && b[k] !== undefined && a[k] !== b[k];
|
|
99
|
+
function sameSettings(a, b) { return !!a && !!b && a.output === b.output && a.audience === b.audience && key(a.schedule) === key(b.schedule) && !refDiffers(a, b, 'structure') && !refDiffers(a, b, 'design'); }
|
|
100
|
+
/** What changed between two section lists, in words: "+ Customers, − Risk watch", or "new order" when only the order moved. */
|
|
101
|
+
function sectionsDiff(was, now) {
|
|
102
|
+
const A = Array.isArray(was) ? was : [], B = Array.isArray(now) ? now : [];
|
|
103
|
+
const low = (L) => L.map((t) => String(t).toLowerCase());
|
|
104
|
+
const a = low(A), b = low(B);
|
|
105
|
+
const out = B.filter((t, i) => !a.includes(b[i])).map((t) => '+ ' + t).concat(A.filter((t, i) => !b.includes(a[i])).map((t) => '− ' + t));
|
|
106
|
+
if (out.length) return out.join(', ');
|
|
107
|
+
return a.join('\n') !== b.join('\n') ? 'new order' : '';
|
|
108
|
+
}
|
|
71
109
|
|
|
72
110
|
const FORMAT = { 'google-slides': 'Slides', 'google-doc': 'Document', pdf: 'PDF', 'google-sheets': 'Sheets', confluence: 'Confluence page' };
|
|
73
111
|
const DAYS = { Mon: 'Monday', Tue: 'Tuesday', Wed: 'Wednesday', Thu: 'Thursday', Fri: 'Friday', Sat: 'Saturday', Sun: 'Sunday' };
|
|
@@ -78,19 +116,31 @@ function goesWords(sc) {
|
|
|
78
116
|
if (sc.cadence === 'monthly') return 'every month on day ' + (sc.dayOfMonth || 1) + ' ' + t;
|
|
79
117
|
return (sc.cadence === 'bi-weekly' ? 'every two weeks, ' : 'every week, ') + (DAYS[sc.day] || 'Monday') + ' ' + t;
|
|
80
118
|
}
|
|
81
|
-
|
|
82
|
-
|
|
119
|
+
const lookOf = (names, n) => (n == null ? STANDARD_LOOK : names && typeof names.look === 'function' ? names.look(n) : 'D' + n);
|
|
120
|
+
const titlesOf = (names, n) => (n == null ? null : names && typeof names.sections === 'function' ? names.sections(n) : null);
|
|
121
|
+
/** What changed between two templates, in words: ["Format: Slides → Document", "Sections: + Customers", "Look: D2 → D3 · warmer"]. `names`
|
|
122
|
+
* (namesOf) reads the section titles and look words; without it a sections change is said by its version ("Sections: S2 → S3"). */
|
|
123
|
+
function diffWords(a, b, names) {
|
|
83
124
|
const out = [];
|
|
84
125
|
if (!a || !b) return out;
|
|
85
126
|
if (a.output !== b.output) out.push('Format: ' + (FORMAT[a.output] || a.output || 'none') + ' → ' + (FORMAT[b.output] || b.output || 'none'));
|
|
86
127
|
if (a.audience !== b.audience) out.push('Readers: ' + (a.audience || 'none') + ' → ' + (b.audience || 'none'));
|
|
87
128
|
if (key(a.schedule) !== key(b.schedule)) out.push('Goes out: ' + goesWords(a.schedule) + ' → ' + goesWords(b.schedule));
|
|
129
|
+
if (refDiffers(a, b, 'structure')) {
|
|
130
|
+
const A = titlesOf(names, a.structure), B = titlesOf(names, b.structure);
|
|
131
|
+
const d = A && B ? sectionsDiff(A, B) : '';
|
|
132
|
+
out.push('Sections: ' + (d || (a.structure == null ? 'standard' : 'S' + a.structure) + ' → ' + (b.structure == null ? 'standard' : 'S' + b.structure)));
|
|
133
|
+
}
|
|
134
|
+
if (refDiffers(a, b, 'design')) out.push('Look: ' + lookOf(names, a.design) + ' → ' + lookOf(names, b.design));
|
|
88
135
|
return out;
|
|
89
136
|
}
|
|
90
|
-
/** One line naming a template's settings: "Format: Slides · readers: The team · goes out once". */
|
|
91
|
-
function settingsWords(s) {
|
|
137
|
+
/** One line naming a template's settings: "Format: Slides · readers: The team · goes out once · 6 sections · Standard PMOS look". */
|
|
138
|
+
function settingsWords(s, names) {
|
|
92
139
|
if (!s) return '';
|
|
93
|
-
|
|
140
|
+
const T = s.structure !== undefined ? titlesOf(names, s.structure) : null;
|
|
141
|
+
const sec = s.structure === undefined ? '' : s.structure == null ? ' · standard sections' : ' · ' + (T ? T.length + (T.length === 1 ? ' section' : ' sections') : 'sections S' + s.structure);
|
|
142
|
+
const look = s.design === undefined ? '' : ' · ' + lookOf(names, s.design) + (s.design == null ? '' : ' look');
|
|
143
|
+
return 'Format: ' + (FORMAT[s.output] || s.output || 'none') + ' · readers: ' + (s.audience || 'none') + ' · goes out ' + goesWords(s.schedule) + sec + look;
|
|
94
144
|
}
|
|
95
145
|
|
|
96
146
|
function fold(lines) {
|
|
@@ -107,24 +157,26 @@ function fold(lines) {
|
|
|
107
157
|
}
|
|
108
158
|
|
|
109
159
|
/** T1, from the setup as it is now. Once: a report with a version already keeps it. `chat` names the conversation it came from. */
|
|
110
|
-
function ensureFirst(root, id, setup, { chat, now } = {}) {
|
|
160
|
+
function ensureFirst(root, id, setup, { chat, refs, now } = {}) {
|
|
111
161
|
if (!ID_RE.test(String(id || ''))) return refuse(400, 'id must be a report id');
|
|
112
162
|
const f = fold(readLines(root, id));
|
|
113
163
|
if (f.current != null) return { ok: true, n: f.current, existing: true };
|
|
114
|
-
const line = { ev: 'version', n: 1, settings: settingsOf(setup), why: 'First shape, from your chat.' };
|
|
164
|
+
const line = { ev: 'version', n: 1, settings: settingsOf(setup, refs || liveRefs(root, id)), why: 'First shape, from your chat.' };
|
|
115
165
|
if (typeof chat === 'string' && CHAT_RE.test(chat)) line.chat = chat;
|
|
116
166
|
append(root, id, line, now);
|
|
117
167
|
return { ok: true, n: 1 };
|
|
118
168
|
}
|
|
119
169
|
/** The PM's ✓ on a changed template: T<n+1> with these settings is the current one. Unchanged settings write nothing. */
|
|
120
|
-
function addVersion(root, id, settings, { why, now } = {}) {
|
|
170
|
+
function addVersion(root, id, settings, { why, names, fill, now } = {}) {
|
|
121
171
|
if (!ID_RE.test(String(id || ''))) return refuse(400, 'id must be a report id');
|
|
122
172
|
const f = fold(readLines(root, id));
|
|
123
173
|
const cur = f.versions.find((v) => v.current);
|
|
124
|
-
|
|
125
|
-
|
|
174
|
+
// `fill`: the sections and look saved before this change, for a current T line that did not record them (written before TplA)
|
|
175
|
+
const was = cur ? { ...(isObj(fill) ? fill : {}), ...cur.settings } : null;
|
|
176
|
+
const next = { ...(was || {}), ...(cleanSettings(settings) || {}) };
|
|
177
|
+
if (cur && sameSettings(was, next)) return { ok: true, n: cur.n, unchanged: true };
|
|
126
178
|
const n = f.versions.reduce((m, v) => Math.max(m, v.n), 0) + 1;
|
|
127
|
-
append(root, id, { ev: 'version', n, settings: next, why: typeof why === 'string' && why.trim() ? why.trim().slice(0, 200) : diffWords(
|
|
179
|
+
append(root, id, { ev: 'version', n, settings: next, why: typeof why === 'string' && why.trim() ? why.trim().slice(0, 200) : diffWords(was, next, names).join('; ').slice(0, 200) }, now);
|
|
128
180
|
return { ok: true, n, settings: next };
|
|
129
181
|
}
|
|
130
182
|
/** Go back to T<n>: that version is the current one again. Nothing is deleted. */
|
|
@@ -169,4 +221,13 @@ function review(markdown, { slot = '', now = Date.now(), listed = [] } = {}) {
|
|
|
169
221
|
return { fix, passed };
|
|
170
222
|
}
|
|
171
223
|
|
|
172
|
-
|
|
224
|
+
/**
|
|
225
|
+
* A sections or look change saved in its own studio (Structure "Use this", Design "Use it") is the PM's ✓ too: the template follows it as
|
|
226
|
+
* T<n+1>. Call `followBefore(root, id, setup)` BEFORE the studio's accept line (T1 then records the sections and look as they were; it answers
|
|
227
|
+
* them), and `followAfter(root, id, { structure | design }, was)` after it, with that answer.
|
|
228
|
+
*/
|
|
229
|
+
function followBefore(root, id, setup) { try { const was = liveRefs(root, id); ensureFirst(root, id, setup, { refs: was }); return was; } catch { return null; } }
|
|
230
|
+
function followAfter(root, id, patch, was) { try { return addVersion(root, id, patch, { names: namesOf(root, id), fill: was }); } catch { return null; } }
|
|
231
|
+
|
|
232
|
+
module.exports = { ID_RE, CHAT_RE, FORMAT, STANDARD_LOOK, ledgerOf, readLines, fold, settingsOf, cleanSettings, sameSettings, sectionsDiff, diffWords, settingsWords, goesWords,
|
|
233
|
+
liveRefs, namesOf, refN, ensureFirst, addVersion, restore, cyclesOf, chatOf, review, followBefore, followAfter };
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* GET /api/boards → { ok, boards: [portfolio row] } every workspace; `ws` is ignored
|
|
6
6
|
* GET /api/boards?names=1 → the same rows without health, counts and next release (no row is derived)
|
|
7
7
|
* GET /api/boards/board?ws&board → { ok, board, counts: { total, byStage, byStatus }, asks, nextRelease, recent }
|
|
8
|
-
* GET /api/boards/backlog?ws&board&q&stage&status&owner&
|
|
9
|
-
* → { ok, total, offset, limit, rows, facets: { stage, status, owner,
|
|
8
|
+
* GET /api/boards/backlog?ws&board&q&stage&status&owner&anchor&view&sort&offset&limit
|
|
9
|
+
* → { ok, total, offset, limit, rows, facets: { stage, status, owner, anchor, cat } }
|
|
10
|
+
* (D105: no horizon filter, facet or field; a row carries its Roadmap rank)
|
|
10
11
|
* GET /api/boards/columns?ws&board&q&owner&cap → { ok, columns: [{ stage, cat, hint, count, rows }] }
|
|
11
12
|
* GET /api/boards/initiative?ws&board&id → { ok, row, board, history, tools }
|
|
12
13
|
* GET /api/boards/asks?ws&board&state → { ok, asks } state: open (default) | accepted | declined | all
|
|
@@ -224,7 +225,7 @@ function domainsOf(root) {
|
|
|
224
225
|
|
|
225
226
|
function boardsOf(ctx, w, folded) {
|
|
226
227
|
const self = isSelf(ctx, w);
|
|
227
|
-
const base = [{ id: w.id, name: w.name || path.basename(w.root), domain: null, kind: 'default' }];
|
|
228
|
+
const base = [{ id: w.id, name: w.label || w.name || path.basename(w.root), domain: null, kind: 'default' }];
|
|
228
229
|
for (const d of domainsOf(w.root)) if (d !== w.id) base.push({ id: d, name: d, domain: d, kind: 'domain' });
|
|
229
230
|
const known = new Set(base.map((b) => b.id));
|
|
230
231
|
for (const [id, b] of folded.boards) if (!known.has(id) && b.created) { base.push({ id, name: b.name || id, domain: b.domain || null, kind: 'created' }); known.add(id); }
|
|
@@ -311,7 +312,7 @@ function baseRowsRead(w) {
|
|
|
311
312
|
const holds = lcFile ? holdSpans.readHolds(lcFile) : new Map();
|
|
312
313
|
const rows = [];
|
|
313
314
|
const seen = new Set();
|
|
314
|
-
for (const id of
|
|
315
|
+
for (const id of F.placed.ranked) {
|
|
315
316
|
if (seen.has(id)) continue;
|
|
316
317
|
seen.add(id);
|
|
317
318
|
const rec = F.byId.get(id);
|
|
@@ -329,7 +330,7 @@ function baseRowsRead(w) {
|
|
|
329
330
|
rows.push({
|
|
330
331
|
id, title: r.title, lane: r.lane || null,
|
|
331
332
|
owner: fm.owner ? String(fm.owner) : null,
|
|
332
|
-
anchor: r.anchor || null,
|
|
333
|
+
anchor: r.anchor || null, rank: Number.isInteger(r.rank) ? r.rank : null, dormant: !!r.dormant,
|
|
333
334
|
status: statusOf(rec, r.health && r.health.level, end, day),
|
|
334
335
|
health: r.health ? r.health.level : null,
|
|
335
336
|
start: span ? span.start || null : null, end,
|
|
@@ -449,7 +450,7 @@ function boardRow(board, base, folded, lib) {
|
|
|
449
450
|
const cat = B.catOf({ workflow: wf }, s.stage);
|
|
450
451
|
const row = {
|
|
451
452
|
id: base.id, title: base.title, lane: base.lane, stage: s.stage, cat, owner: base.owner, anchor: base.anchor,
|
|
452
|
-
|
|
453
|
+
status: base.status, start: ts ? minDay(base.start, ts.start) : base.start, end: ts ? maxDay(base.end, ts.end) : base.end, progress: base.progress, warnings: [],
|
|
453
454
|
rank: base.rank, health: B.isActive(base) ? base.health : null, updated: base.updated, reading: base.reading, stageSource: s.source, lifecycle: base.lifecycle,
|
|
454
455
|
stopped: base.stopped || null, archived: archivedOf(folded, base.id),
|
|
455
456
|
// feedback batch 9 item 8: every hold of the initiative, and the stretches of 2 weeks or more that no dated work-item or task covers (batch 11
|
|
@@ -746,7 +747,7 @@ const READS = {
|
|
|
746
747
|
'/api/boards/backlog': (ctx, res, url) => {
|
|
747
748
|
const r = boardRead(ctx, res, url);
|
|
748
749
|
if (!r) return;
|
|
749
|
-
const q = Object.fromEntries(['q', 'stage', 'status', 'owner', '
|
|
750
|
+
const q = Object.fromEntries(['q', 'stage', 'status', 'owner', 'anchor', 'cat', 'view', 'sort', 'offset', 'limit', 'me', 'archived'].map((k) => [k, url.searchParams.get(k)]));
|
|
750
751
|
if (!q.me) q.me = actorLib.PM_SLUG;
|
|
751
752
|
const out = B.filterRows(r.rows, { ...q, stages: r.board.workflow.map((s) => s.name) });
|
|
752
753
|
ctx.json(res, { ok: true, ws: r.w.id, board: r.board.id, ...out });
|
|
@@ -821,7 +822,7 @@ const READS = {
|
|
|
821
822
|
const live = r.rows.filter((x) => !x.archived); // an archived initiative leaves every list and timeline (c3-initiative-lifecycle)
|
|
822
823
|
seedRows(ctx, r.w, r.fr, r.board, live);
|
|
823
824
|
ctx.json(res, { ok: true, ws: r.w.id, board: r.board.id, build: r.board.build, jira: r.board.jira, jiraProjects: r.board.jiraProjects, items: itemsOf(r.w, r.fr, r.board, live),
|
|
824
|
-
initiatives: live.map((x) => ({ id: x.id, title: x.title, stage: x.stage, cat: x.cat, status: x.status, owner: x.owner, anchor: x.anchor || '',
|
|
825
|
+
initiatives: live.map((x) => ({ id: x.id, title: x.title, stage: x.stage, cat: x.cat, status: x.status, owner: x.owner, anchor: x.anchor || '', rank: x.rank, start: x.start, end: x.end, progress: x.progress, template: x.template, epics: x.epics,
|
|
825
826
|
stages: (x.wfStages || []).map((st) => ({ key: st.key, name: st.name, milestone: !!st.milestone })), ...(x.wfMap ? { map: x.wfMap } : {}) })) }); // the sections a task can sit in (the task Viewer's move icon)
|
|
826
827
|
},
|
|
827
828
|
'/api/boards/sprints': (ctx, res, url) => {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
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
|
|
29
29
|
* read mark goes through POST /api/mentions/read (routes-mentions.js). */
|
|
30
30
|
const path = require('path');
|
|
31
|
+
const fs = require('fs');
|
|
31
32
|
const pmItems = require('./pm-items.js');
|
|
32
33
|
const { repoScript } = require('./repo-script.js');
|
|
33
34
|
|
|
@@ -233,12 +234,28 @@ function notesAdapter(runtimeDir) {
|
|
|
233
234
|
};
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
/** The PM's first name for the greeting: the first word of `git config user.name` where PMOS runs. null when git holds none (the page then greets without a name).
|
|
237
|
+
/** The PM's first name for the greeting: the first word of `git config user.name` where PMOS runs. null when git holds none (the page then greets without a name).
|
|
238
|
+
* Kept until one of git's config files changes (page-open-speed): Home asked `git` twice per open, about 35 ms each, on the thread every
|
|
239
|
+
* other answer waits for. The key is the size and time of the files `git config` reads, so an edited name shows on the next open. */
|
|
240
|
+
const nameCache = new Map(); // cwd -> { key, name }
|
|
241
|
+
function gitConfigKey(cwd) {
|
|
242
|
+
const os = require('os');
|
|
243
|
+
const home = os.homedir();
|
|
244
|
+
const files = [path.join(home, '.gitconfig'), path.join(process.env.XDG_CONFIG_HOME || path.join(home, '.config'), 'git', 'config'), path.join(cwd, '.git', 'config')];
|
|
245
|
+
if (process.env.GIT_CONFIG_GLOBAL) files.push(process.env.GIT_CONFIG_GLOBAL);
|
|
246
|
+
return files.map((f) => { try { const st = fs.statSync(f); return st.size + ':' + st.mtimeMs; } catch { return '-'; } }).join('|');
|
|
247
|
+
}
|
|
237
248
|
function firstName(cwd) {
|
|
249
|
+
const key = gitConfigKey(cwd);
|
|
250
|
+
const hit = nameCache.get(cwd);
|
|
251
|
+
if (hit && hit.key === key) return hit.name;
|
|
252
|
+
let name = null;
|
|
238
253
|
try {
|
|
239
254
|
const n = String(require('child_process').execFileSync('git', ['config', 'user.name'], { cwd, encoding: 'utf8', timeout: 2000, stdio: ['ignore', 'pipe', 'ignore'] })).trim().split(/\s+/)[0];
|
|
240
|
-
|
|
241
|
-
} catch {
|
|
255
|
+
name = n && n.length <= 40 ? n : null;
|
|
256
|
+
} catch { name = null; }
|
|
257
|
+
nameCache.set(cwd, { key, name });
|
|
258
|
+
return name;
|
|
242
259
|
}
|
|
243
260
|
|
|
244
261
|
module.exports = {
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* spent, left this month, in US dollars (lib/grill.js spentIn: an open run counts its whole budget)
|
|
8
8
|
* paused the cap held a run back this month
|
|
9
9
|
* runs for each initiative asked for: its last ended run { ini, why, at, cost, n, turn? }; n = its open grill findings
|
|
10
|
-
* news the newest ended run of this workspace in the last 7 days that left open findings (Home's one line); null is silence
|
|
10
|
+
* news the newest ended run of this workspace in the last 7 days that left open findings (Home's one line); null is silence.
|
|
11
|
+
* news.more: how many other initiatives were grilled this week with open findings; news.total: all their open findings
|
|
11
12
|
* run.turn: { scope, id, to } when the run started on a forecast turn (lib/forecast.js `turned` line, its key)
|
|
12
13
|
*
|
|
13
14
|
* Read-only: no run starts from a page (Claude grills by itself, lib/grill-runs.js), and the settings are written by /api/settings. */
|
|
@@ -44,13 +45,18 @@ function model(ctx, w, inis, now = Date.now()) {
|
|
|
44
45
|
const shape = (r) => ({ ini: r.ini, why: r.why, at: r.endAt || r.at, cost: r.cost, n: P ? openFindings(P, r.ini) : 0, ...(r.why === 'forecast' ? { turn: turnOf(r, turned) } : {}) });
|
|
45
46
|
const runs = {};
|
|
46
47
|
for (const id of inis) { const r = ended.filter((x) => x.ini === id).pop(); if (r) runs[id] = shape(r); }
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
// news: the newest; more and total: the other initiatives grilled this week that left open findings, so Home says how many, not just one
|
|
49
|
+
let news = null; const others = new Set(); let total = 0;
|
|
50
|
+
for (let i = ended.length - 1; i >= 0; i--) {
|
|
49
51
|
const r = ended[i];
|
|
50
52
|
if (now - (Date.parse(r.endAt || r.at) || 0) > WEEK) break;
|
|
53
|
+
if ((news && r.ini === news.ini) || others.has(r.ini)) continue;
|
|
51
54
|
const s = shape(r);
|
|
52
|
-
if (s.n > 0)
|
|
55
|
+
if (!(s.n > 0)) continue;
|
|
56
|
+
if (!news) news = s; else others.add(r.ini);
|
|
57
|
+
total += s.n;
|
|
53
58
|
}
|
|
59
|
+
if (news) Object.assign(news, { more: others.size, total });
|
|
54
60
|
return { ok: true, mode: G.modeOf(get, ctx.env || process.env), envOff: G.off(ctx.env || process.env), cap: Number.isFinite(cap) ? cap : null,
|
|
55
61
|
spent, left: Number.isFinite(cap) ? Math.max(0, Math.round((cap - spent) * 100) / 100) : null, month, paused: F.paused.has(month), runs, news };
|
|
56
62
|
}
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
* GET /api/impact/week?week=YYYY-MM-DD → { ok, on, live, first, week, from, to, label, grow, celebrate, quiet, items } Home's Adler, the Viewer
|
|
7
7
|
* GET /api/impact/weeks → { ok, on, live, weeks: [{ week, from, to, label, quiet, items }] } the log, newest first
|
|
8
|
-
* GET /api/impact/check → { ok, on, due, week, label, items, gate }
|
|
8
|
+
* GET /api/impact/check → { ok, on, due, week, label, items, gate, looked } the weekly check in Home's chat
|
|
9
9
|
* POST /api/impact/verdict { id, real } → { ok } ✓ (true) or ✕ (false) one row
|
|
10
10
|
* POST /api/impact/verdict-all { week } → { ok } ✓✓ every row of that week not checked yet
|
|
11
|
-
* POST /api/impact/undo { id } → { ok } the row back to not checked
|
|
11
|
+
* POST /api/impact/undo { id } → { ok } the row back to not checked (a dropped row counts again)
|
|
12
|
+
* POST /api/impact/looked { week } → { ok } the check card was shown for last week (a closed week then counts for the gate)
|
|
12
13
|
* POST /api/impact/seen { ids } → { ok } read on a Phase 2 surface; ends its one celebration
|
|
13
14
|
* `ws` is accepted on every route and ignored: the ledger is per person, across products.
|
|
14
15
|
*
|
|
@@ -50,7 +51,7 @@ async function handle(req, res, url, ctx) {
|
|
|
50
51
|
: what === 'weeks' ? IM.weeksView(F, optsOf(ctx)) : IM.checkView(F, optsOf(ctx));
|
|
51
52
|
return send({ status: 200, body: { ok: true, on: true, ...body } });
|
|
52
53
|
}
|
|
53
|
-
if (!['verdict', 'verdict-all', 'undo', 'seen'].includes(what)) return send(bad(404, 'no such impact route'));
|
|
54
|
+
if (!['verdict', 'verdict-all', 'undo', 'seen', 'looked'].includes(what)) return send(bad(404, 'no such impact route'));
|
|
54
55
|
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
55
56
|
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'Only you check your impact, from the page. Claude\'s run files items with pmos impact.'));
|
|
56
57
|
const rd = await ctx.readJson(req);
|
|
@@ -63,10 +64,17 @@ async function handle(req, res, url, ctx) {
|
|
|
63
64
|
const F = IM.read(dir), at = new Date(nowMs(ctx)).toISOString(), by = { by: 'pm' };
|
|
64
65
|
|
|
65
66
|
if (what === 'seen') {
|
|
66
|
-
const ids = (Array.isArray(body.ids) ? body.ids : []).map(String).filter((id) => { const it = F.items.get(id); return it && it.real
|
|
67
|
+
const ids = (Array.isArray(body.ids) ? body.ids : []).map(String).filter((id) => { const it = F.items.get(id); return it && it.real !== false && !it.read; }).slice(0, 100);
|
|
67
68
|
if (ids.length) IM.append(dir, by, { kind: 'seen', ids }, at);
|
|
68
69
|
return send({ status: 200, body: { ok: true } });
|
|
69
70
|
}
|
|
71
|
+
if (what === 'looked') {
|
|
72
|
+
const week = text(body.week), o = optsOf(ctx);
|
|
73
|
+
if (week !== IM.addDays(IM.weekOf(o.today, o.start), -7)) return send(bad(400, 'week is the first day of last week, YYYY-MM-DD: the week the check is open for'));
|
|
74
|
+
if (!F.looked.has(week)) IM.append(dir, by, { kind: 'looked', week }, at);
|
|
75
|
+
noteGate(ctx, dir);
|
|
76
|
+
return send({ status: 200, body: { ok: true } });
|
|
77
|
+
}
|
|
70
78
|
if (what === 'verdict-all') {
|
|
71
79
|
const week = text(body.week), o = optsOf(ctx);
|
|
72
80
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(week)) return send(bad(400, 'week is the first day of the week, YYYY-MM-DD'));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-initiatives.js — the Initiatives API: the Roadmap, the List, the initiative sheet, the export, and the three
|
|
3
|
-
* writes behind them (pm-os-absorb Run 2, slice 2C; PRD R13, R16, R17, R20 A, R23, R25, R26; D86 point 4
|
|
3
|
+
* writes behind them (pm-os-absorb Run 2, slice 2C; PRD R13, R16, R17, R20 A, R23, R25, R26; D86 point 4; D105: the
|
|
4
|
+
* Roadmap is one ranked list, with no Now / Next / Later).
|
|
4
5
|
*
|
|
5
6
|
* GET /api/initiatives?ws=&view=roadmap|list → fixtures/initiatives-api/roadmap.json | list.json
|
|
6
7
|
* GET /api/initiatives/<id>?ws= → fixtures/initiatives-api/sheet.json
|
|
@@ -17,14 +18,14 @@
|
|
|
17
18
|
* move every other document of each named group to the archive
|
|
18
19
|
* POST /api/initiatives/jev-check { ws, confirm?, expect_requests?, expect_fingerprint? } → { ok, gates, plan } without
|
|
19
20
|
* confirm; { ok, corrections, groups, sent, … } with it (lib/jev-documents.js)
|
|
20
|
-
* POST /api/placements { ws, events: [
|
|
21
|
+
* POST /api/placements { ws, events: [ranked | created | adopted | dropped] }
|
|
21
22
|
* → { ok, written, sig } fixtures/initiatives-api/post-ok.json
|
|
22
23
|
* POST /api/measurements { ws, events: [measured] } → { ok, written, sig }
|
|
23
24
|
*
|
|
24
|
-
* GUARDS (seams §3, §5.1).
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* a body never names it. Refusals answer { ok: false, status, error } with that status (post-403.json).
|
|
25
|
+
* GUARDS (seams §3, §5.1). `adopted` is a PM-only act: requirePmPress with act `adopt`, and one proposal per body
|
|
26
|
+
* (R17). Every other write — a ranked line, a new initiative, a measurement — passes requirePagePress. Move to Now is
|
|
27
|
+
* retired with the horizons (D105); an old `placed` line is refused by the writer with what to send instead. The actor
|
|
28
|
+
* goes from the guard to the writer; a body never names it. Refusals answer { ok: false, status, error } with that status (post-403.json).
|
|
28
29
|
*
|
|
29
30
|
* READS. The signature is taken BEFORE any ledger or record is read (the F2 rule of lib/plan-items.js), so a write that
|
|
30
31
|
* lands during a read changes the next poll's answer. `sig` = { placements, items, measurements, records }: the
|
|
@@ -61,7 +62,6 @@ const docCatCorrections = require('./doc-category-corrections');
|
|
|
61
62
|
const { repoScript } = require('./repo-script.js');
|
|
62
63
|
const { nineStages } = require(repoScript('nine-stages.js')); // pure label layer; never workflow-state.js (it runs its CLI on require)
|
|
63
64
|
|
|
64
|
-
const HORIZON_RANK = { now: 0, next: 1, later: 2 };
|
|
65
65
|
const FILE_KEYS = [['brief_path', 'brief', 'Brief'], ['prd_path', 'prd', 'PRD'], ['rubric_path', 'rubric', 'Rubric'], ['doc_path', 'doc', 'Document']];
|
|
66
66
|
const cap = (s) => (s ? s[0].toUpperCase() + s.slice(1) : s);
|
|
67
67
|
const GIT_GROUP_LABEL = { code: 'Code', tests: 'Test', documents: 'Document', other: 'File' };
|
|
@@ -174,7 +174,7 @@ function rowOf(F, rec) {
|
|
|
174
174
|
if (!pr.total && !pr.proposed) { const d = derivedBreakdown(F.root, rec, { progress: pr }); if (d) pr = d.progress; }
|
|
175
175
|
return {
|
|
176
176
|
id, title: rec.title || id, lane: rec.lane, anchor: a.anchor, anchor_kind: a.kind,
|
|
177
|
-
|
|
177
|
+
rank: p.rank, confirmed: p.confirmed, dormant: p.dormant, check_by: p.check_by,
|
|
178
178
|
stage: stageOf(F.root, rec),
|
|
179
179
|
display: { word: d.word, stage: d.stage, waitingOn: d.waitingOn, act: d.act, idleDays: d.idleDays, line2: d.line2 },
|
|
180
180
|
health: { level: h.level, reasons: h.reasons },
|
|
@@ -189,22 +189,19 @@ function rowOf(F, rec) {
|
|
|
189
189
|
const flagsOf = (F) => F.placed.flags.map((f) => ({ kind: f.kind, init: f.init, why: actorLib.pageName(f.why) }));
|
|
190
190
|
|
|
191
191
|
function roadmapOf(w, F) {
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const later = laterAll.filter((r) => !r.dormant);
|
|
197
|
-
const dormant = laterAll.filter((r) => r.dormant);
|
|
192
|
+
// D105: one ranked list. A dormant row (untouched for dormant_days) folds out of it, behind the header's count.
|
|
193
|
+
const all = F.placed.ranked.filter((id) => F.byId.has(id)).map((id) => rowOf(F, F.byId.get(id)));
|
|
194
|
+
const rows = all.filter((r) => !r.dormant);
|
|
195
|
+
const dormant = all.filter((r) => r.dormant);
|
|
198
196
|
const title = (id) => (F.byId.get(id) || {}).title || id;
|
|
199
197
|
return {
|
|
200
198
|
header: {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
later: { count: later.length, dormant: dormant.length },
|
|
199
|
+
count: rows.length, dormant: dormant.length,
|
|
200
|
+
kr: rows.filter((r) => r.anchor_kind === 'kr' || r.anchor_kind === 'objective').length, health: rows.filter((r) => r.anchor_kind === 'health').length,
|
|
204
201
|
},
|
|
205
|
-
|
|
202
|
+
rows,
|
|
206
203
|
dormant,
|
|
207
|
-
proposals: F.placed.proposals.map((p) => ({ eid: p.eid, initiative: p.init, title: title(p.init),
|
|
204
|
+
proposals: F.placed.proposals.map((p) => ({ eid: p.eid, initiative: p.init, title: title(p.init), after: p.after, by: actorLib.pageName(p.by), at: p.at })),
|
|
208
205
|
flags: flagsOf(F),
|
|
209
206
|
scan: scanSummary(F),
|
|
210
207
|
};
|
|
@@ -257,7 +254,7 @@ function claimedPaths(root, rows) {
|
|
|
257
254
|
}
|
|
258
255
|
|
|
259
256
|
function listOf(w, F) {
|
|
260
|
-
const all =
|
|
257
|
+
const all = F.placed.ranked.filter((id) => F.byId.has(id)).map((id) => rowOf(F, F.byId.get(id)));
|
|
261
258
|
const groups = new Map(); // objective key -> { objective, anchors: Map(anchorKey -> group) }
|
|
262
259
|
const objOrder = [];
|
|
263
260
|
for (const r of all) {
|
|
@@ -272,7 +269,7 @@ function listOf(w, F) {
|
|
|
272
269
|
}
|
|
273
270
|
g.anchors.get(a.key).rows.push(r);
|
|
274
271
|
}
|
|
275
|
-
const byDue = (x, y) => (
|
|
272
|
+
const byDue = (x, y) => ((x.dormant ? 1 : 0) - (y.dormant ? 1 : 0))
|
|
276
273
|
|| ((x.next_due || '9999') < (y.next_due || '9999') ? -1 : (x.next_due || '9999') > (y.next_due || '9999') ? 1 : 0) || (x.rank - y.rank);
|
|
277
274
|
// Objectives first, in the order their rows first appear; the anchors with no objective (health, domain, none) last.
|
|
278
275
|
const ordered = [...objOrder.filter((k) => k !== 'none'), ...objOrder.filter((k) => k === 'none')];
|
|
@@ -312,11 +309,11 @@ function sheetOf(w, F, rec, opts = {}) {
|
|
|
312
309
|
const recF = lad && lad.ok && lad.found ? { ...rec, found: lad.found } : rec;
|
|
313
310
|
const files = filesOf(root, recF, fm, opts);
|
|
314
311
|
const derived = derivedBreakdown(root, recF, lay);
|
|
315
|
-
|
|
312
|
+
// D105: a move is a rank (1 = top) at the time of the line, not a horizon
|
|
316
313
|
const history = F.placed.moves.filter((m) => m.init === rec.id)
|
|
317
|
-
.map((m) => ({ at: m.at, by: actorLib.pageName(m.by), text: m.from === null
|
|
314
|
+
.map((m) => ({ at: m.at, by: actorLib.pageName(m.by), text: m.from === null ? `Added to the Roadmap at #${m.to}` : `Ranked #${m.to} on the Roadmap (was #${m.from})` }))
|
|
318
315
|
.reverse();
|
|
319
|
-
return { initiative: row, stepper, waiting, files, derived, history, cli: {
|
|
316
|
+
return { initiative: row, stepper, waiting, files, derived, history, cli: { rank: `pmos initiative top ${rec.id}`, export: `pmos initiative export ${rec.id}` } };
|
|
320
317
|
}
|
|
321
318
|
|
|
322
319
|
/**
|
|
@@ -525,27 +522,16 @@ async function readBody(ctx, req, res) {
|
|
|
525
522
|
return r.body;
|
|
526
523
|
}
|
|
527
524
|
|
|
528
|
-
/** POST /api/placements: which guard, and the one-
|
|
529
|
-
function placementGuard(req, body
|
|
525
|
+
/** POST /api/placements: which guard, and the one-proposal rule for adopt (the one PM-only act left here, R17). */
|
|
526
|
+
function placementGuard(req, body) {
|
|
530
527
|
const events = Array.isArray(body.events) ? body.events : null;
|
|
531
528
|
if (!events) return { ok: false, status: 400, error: 'send { ws, events: [ … ] }' };
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
if (!nowLines.length && !adoptLines.length) return guard.requirePagePress(req, body);
|
|
537
|
-
if (nowLines.length && adoptLines.length) return { ok: false, status: 400, error: 'send Move to Now and adopt as two presses' };
|
|
538
|
-
const g = guard.requirePmPress(req, body, { act: adoptLines.length ? 'adopt' : 'now' });
|
|
529
|
+
const adoptLines = events.filter((e) => e && e.ev === 'adopted');
|
|
530
|
+
if (!adoptLines.length) return guard.requirePagePress(req, body);
|
|
531
|
+
if (adoptLines.length !== events.length) return { ok: false, status: 400, error: 'send adopt as a press of its own' };
|
|
532
|
+
const g = guard.requirePmPress(req, body, { act: 'adopt' });
|
|
539
533
|
if (!g.ok) return g;
|
|
540
|
-
|
|
541
|
-
const inits = new Set();
|
|
542
|
-
for (const e of events) {
|
|
543
|
-
if (isAdopt(e)) {
|
|
544
|
-
const p = placements.readPlacements(root).proposals.find((x) => x.eid === e.proposal);
|
|
545
|
-
inits.add(p ? p.init : `proposal:${e.proposal}`);
|
|
546
|
-
} else inits.add(e && e.initiative);
|
|
547
|
-
}
|
|
548
|
-
if (inits.size > 1 || adoptLines.length > 1) return { ok: false, status: 400, error: `${adoptLines.length ? 'adopt' : 'Move to Now'} takes one initiative per press; this body names ${Math.max(inits.size, adoptLines.length)}` };
|
|
534
|
+
if (adoptLines.length > 1) return { ok: false, status: 400, error: `adopt takes one proposal per press; this body names ${adoptLines.length}` };
|
|
549
535
|
return g;
|
|
550
536
|
}
|
|
551
537
|
|
|
@@ -686,7 +672,7 @@ async function handle(req, res, url, ctx) {
|
|
|
686
672
|
return true;
|
|
687
673
|
}
|
|
688
674
|
if (p === '/api/placements' || p === '/api/measurements') {
|
|
689
|
-
const g = p === '/api/placements' ? placementGuard(req, body
|
|
675
|
+
const g = p === '/api/placements' ? placementGuard(req, body) : guard.requirePagePress(req, body);
|
|
690
676
|
if (!g.ok) return answer(ctx, res, g), true;
|
|
691
677
|
if (!Array.isArray(body.events)) { ctx.json(res, { ok: false, status: 400, error: 'send { ws, events: [ … ] }' }, 400); return true; }
|
|
692
678
|
const lib = p === '/api/placements' ? placements : measurements;
|
|
@@ -348,31 +348,40 @@ function glossaryOf(root) {
|
|
|
348
348
|
glossaryCache.set(root, { at: Date.now(), terms: out });
|
|
349
349
|
return out;
|
|
350
350
|
}
|
|
351
|
-
/**
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
*
|
|
351
|
+
/** How many of the top of the Roadmap the note picker offers as one-tap choices; the rest are in its list. */
|
|
352
|
+
const PICKER_TOP = 6;
|
|
353
|
+
/** The open initiatives of one repository, in Roadmap order (D105). The Initiatives view reads the repository's documents
|
|
354
|
+
* (lib/initiative-rows.js) and ranks them on one list; a repository kept as documents has no planning/initiatives records,
|
|
355
|
+
* so those alone left the picker empty. Ranked rows come first, in rank; dormant rows follow; records the view does not
|
|
356
|
+
* rank come last. Each item carries its lifecycle stage (`stage`, '' when none shows) and `top`: true for the first
|
|
357
|
+
* PICKER_TOP rows that are not dormant. `pending` is true while the first read of the documents is still running. */
|
|
355
358
|
function openInitiativesOf(w) {
|
|
356
359
|
const legacy = notesLinks.initiativesOf(w.root);
|
|
357
|
-
let
|
|
360
|
+
let ranked = []; let pending = false;
|
|
358
361
|
try {
|
|
359
362
|
const rowsLib = require('./initiative-rows.js');
|
|
360
363
|
const ri = require('./routes-initiatives.js');
|
|
364
|
+
const lifecycle = require('./lifecycle-stage.js');
|
|
361
365
|
const got = rowsLib.rowsFor(w.root);
|
|
362
366
|
if (got.pending) pending = true;
|
|
363
367
|
else if (got.ok) {
|
|
364
368
|
const rm = ri.roadmapOf(w, ri.frameOf(w, got.rows, { now: Date.now() }));
|
|
365
369
|
const byId = new Map(got.rows.map((r) => [r.id, r]));
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
370
|
+
let top = 0;
|
|
371
|
+
const add = (r, dormant) => {
|
|
372
|
+
const rec = byId.get(r.id);
|
|
373
|
+
if (rec && (rec.stopped || rec.accepted)) return;
|
|
374
|
+
const isTop = !dormant && top < PICKER_TOP;
|
|
375
|
+
if (isTop) top++;
|
|
376
|
+
ranked.push({ id: r.id, title: r.title, anchor: r.anchor, intent: '', stage: lifecycle.labelOf(rec), dormant, top: isTop });
|
|
377
|
+
};
|
|
378
|
+
for (const r of rm.rows) add(r, false);
|
|
379
|
+
for (const r of rm.dormant) add(r, true);
|
|
369
380
|
}
|
|
370
|
-
} catch {
|
|
371
|
-
const seen = new Set(
|
|
372
|
-
const rest = legacy.filter((i) => !seen.has(i.id)).map((i) => ({ ...i,
|
|
373
|
-
|
|
374
|
-
const open = [...placed, ...rest].sort((a, b) => order[a.horizon] - order[b.horizon]);
|
|
375
|
-
return { open, pending };
|
|
381
|
+
} catch { ranked = []; }
|
|
382
|
+
const seen = new Set(ranked.map((i) => i.id));
|
|
383
|
+
const rest = legacy.filter((i) => !seen.has(i.id)).map((i) => ({ ...i, stage: '', dormant: false, top: false }));
|
|
384
|
+
return { open: [...ranked, ...rest], pending };
|
|
376
385
|
}
|
|
377
386
|
/** The repository's terms for a note: its initiative's title, the glossary, and the product terms in the open initiatives' titles. */
|
|
378
387
|
function repoTermsFor(ctx, note) {
|
|
@@ -838,7 +847,7 @@ async function handle(req, res, url, ctx) {
|
|
|
838
847
|
const r = nid ? notes.read(dir, nid) : null;
|
|
839
848
|
if (r && !r.ok) { send(ctx, res, r); return true; }
|
|
840
849
|
const s = r ? notesLinks.suggest(r.note, open) : { pick: null, ranked: [] };
|
|
841
|
-
ctx.json(res, { ok: true, open: open.map((i) => ({ id: i.id, title: i.title,
|
|
850
|
+
ctx.json(res, { ok: true, open: open.map((i) => ({ id: i.id, title: i.title, stage: i.stage, dormant: i.dormant, top: i.top })), pick: s.pick, pending });
|
|
842
851
|
return true;
|
|
843
852
|
}
|
|
844
853
|
if (p === '/api/notes/engine') {
|