create-pmos 0.395.0 → 0.397.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 +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/nine-stages.js +49 -20
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +20 -40
- package/workspace/briefing-premium-board-test.js +145 -107
- package/workspace/briefing-premium-calendar-2-test.js +5 -2
- package/workspace/briefing-premium-calendar-3-test.js +13 -8
- package/workspace/briefing-premium-calendar-test.js +16 -5
- package/workspace/briefing-premium-initiative-test.js +50 -41
- package/workspace/briefing-premium-insights-test.js +104 -85
- package/workspace/briefing-premium-metrics-test.js +11 -32
- package/workspace/briefing-premium-sources-test.js +42 -21
- package/workspace/briefing-premium-test.js +112 -98
- package/workspace/briefing-premium-work-test.js +78 -64
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/board-premium-facts.js +2 -1
- package/workspace/fixtures/board-premium-jira.js +28 -0
- package/workspace/fixtures/initiative-premium-facts.js +2 -1
- package/workspace/fixtures/initiatives-api/list.json +30 -42
- package/workspace/fixtures/initiatives-api/roadmap.json +40 -56
- package/workspace/fixtures/initiatives-api/sheet.json +10 -14
- package/workspace/fixtures/insights-premium-facts.js +11 -2
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/lifecycle.md +51 -0
- package/workspace/home-shot.js +38 -0
- package/workspace/lib/board-premium.js +92 -1
- package/workspace/lib/engine/boards.js +15 -14
- package/workspace/lib/engine/nine-stages.js +49 -20
- package/workspace/lib/engine/signals/detectors.js +13 -11
- package/workspace/lib/insights-premium.js +78 -1
- package/workspace/lib/routes-board-premium.js +3 -2
- package/workspace/lib/routes-initiatives.js +1 -1
- package/workspace/lib/routes-insights-premium.js +8 -1
- package/workspace/lib/vendor/scripts/nine-stages.js +49 -20
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-agreed-viewer-shots.js +76 -0
- package/workspace/premium-board-actions-test.js +2 -0
- package/workspace/premium-chat-chart-tab-test.js +6 -5
- package/workspace/premium-chat-context-test.js +8 -6
- package/workspace/premium-chat-goal-view-test.js +9 -7
- package/workspace/premium-chat-notes-test.js +3 -2
- package/workspace/premium-chat-report-tab-test.js +8 -2
- package/workspace/premium-chat-term-test.js +3 -1
- package/workspace/premium-chat-viewer-test.js +23 -17
- package/workspace/premium-core-doc-issue-test.js +2 -0
- package/workspace/premium-html-viewer-test.js +4 -2
- package/workspace/premium-phone-card-test.js +1 -0
- package/workspace/premium-phone-room-test.js +16 -11
- package/workspace/premium-report-read-test.js +1 -1
- package/workspace/premium-vw-backlog-test.js +2 -0
- package/workspace/premium-vw-cal-test.js +9 -4
- package/workspace/premium-vw-doc-test.js +1 -1
- package/workspace/premium-vw-item-test.js +1 -0
- package/workspace/premium-vw-jira-test.js +4 -1
- package/workspace/premium-vw-notes-test.js +2 -1
- package/workspace/premium-vw-rec-test.js +3 -2
- package/workspace/premium-vw-slides-test.js +2 -2
- package/workspace/premium-work-depth-test.js +7 -3
- package/workspace/public/pm/bd-span.js +120 -0
- package/workspace/public/pm/bd-stages.js +33 -0
- package/workspace/public/pm/cozy-board.css +373 -0
- package/workspace/public/pm/cozy-home.css +152 -0
- package/workspace/public/pm/cozy-home.js +170 -0
- package/workspace/public/pm/cozy-initiative.css +138 -0
- package/workspace/public/pm/cozy-insights.css +292 -0
- package/workspace/public/pm/cozy-nav.js +54 -0
- package/workspace/public/pm/cozy-viewer.css +143 -0
- package/workspace/public/pm/cozy.css +172 -0
- package/workspace/public/pm/lifecycle-lens-model.js +45 -27
- package/workspace/public/pm/lifecycle-lens.js +22 -11
- package/workspace/public/pm/premium-board.js +329 -67
- package/workspace/public/pm/premium-brief.js +1 -1
- package/workspace/public/pm/premium-chat.js +17 -10
- package/workspace/public/pm/premium-initiative-head.js +138 -0
- package/workspace/public/pm/premium-initiative.js +28 -4
- package/workspace/public/pm/premium-insights.js +530 -244
- package/workspace/public/pm/premium-shell.js +40 -10
- package/workspace/public/pm/premium-viewer.js +5 -0
- package/workspace/public/pm/premium-vw-jira-model.js +22 -5
- package/workspace/public/pm/premium-vw-jira.css +11 -0
- package/workspace/public/pm/premium-vw-jira.js +11 -4
- package/workspace/public/pm/premium-vw-rec.js +5 -2
- package/workspace/public/pm/premium-wide.css +30 -0
- package/workspace/public/pm/premium-work.js +18 -8
- package/workspace/public/pm/premium.js +19 -6
- package/workspace/public/premium-board.html +83 -47
- package/workspace/public/premium-chat.html +7 -32
- package/workspace/public/premium-initiative.html +16 -8
- package/workspace/public/premium-insights.html +83 -43
- package/workspace/public/premium-work.html +6 -71
- package/workspace/public/premium.html +62 -15
- package/workspace/public/vendor/nunito-var.woff2 +0 -0
- package/workspace/server.js +7 -0
- package/workspace/test-lists/premium-agreed-viewer.json +9 -0
- package/workspace/third-party/README.md +1 -0
|
@@ -39,6 +39,87 @@ const LANES = ['feature', 'discovery', 'chore', 'incident', 'content', 'prototyp
|
|
|
39
39
|
let last = null;
|
|
40
40
|
const peekModel = () => last;
|
|
41
41
|
|
|
42
|
+
/* ── The Agreed design's stage track (initiative premium-agreed-design, B1 B2) ───────────────────────────────────────────────────────────
|
|
43
|
+
* Six stages and two milestones (◆). A board's own workflow names map onto them; the old names count for the new ones (Ideate → Discover,
|
|
44
|
+
* Strategize → Prioritize), and a name the map does not know falls back on its category. Each row gets `track`: its step, the output that
|
|
45
|
+
* finishes the step, the progress toward it from a record (Jira tickets for Build and Deliver, the record's own progress otherwise) and the
|
|
46
|
+
* Jira tickets PMOS holds a reading for. Nothing here is invented: a step with nothing counted says so. */
|
|
47
|
+
const STEPS = [
|
|
48
|
+
['triage', 'Triage', 'Triage', false, 'BRD complete'], ['discover', 'Discover', 'Disc', false, 'PRD complete'],
|
|
49
|
+
['plan', 'Plan', 'Plan', false, 'Scope, timeline, work breakdown'], ['prioritize', 'Prioritize', 'Prio', false, 'Ranked on the roadmap'],
|
|
50
|
+
['build', 'Build', 'Build', false, 'Features delivered'], ['deliver', 'Deliver', 'Deliv', true, 'Release shipped + your sign-off'],
|
|
51
|
+
['monitor', 'Monitor', 'Mon', false, 'Outcome report'], ['evaluate', 'Evaluate', 'Eval', true, 'Keep, iterate or stop'],
|
|
52
|
+
].map(([key, label, short, ms, output]) => ({ key, label, short, ms, output }));
|
|
53
|
+
const OLD_STEP = { ideate: 'discover', strategize: 'prioritize', intake: 'triage', ship: 'deliver', release: 'deliver', learn: 'monitor' };
|
|
54
|
+
const CAT_STEP = { discover: 'discover', plan: 'plan', do: 'build', learn: 'monitor' };
|
|
55
|
+
/** The index of a stage name among the eight steps, or -1. Reads old and new names alike. */
|
|
56
|
+
function stepIndex(name, cat) {
|
|
57
|
+
const n = String(name || '').trim().toLowerCase().replace(/^◆\s*/, '');
|
|
58
|
+
let k = STEPS.findIndex((s) => s.key === n);
|
|
59
|
+
if (k < 0 && OLD_STEP[n]) k = STEPS.findIndex((s) => s.key === OLD_STEP[n]);
|
|
60
|
+
if (k < 0 && n && cat && CAT_STEP[String(cat).toLowerCase()]) k = STEPS.findIndex((s) => s.key === CAT_STEP[String(cat).toLowerCase()]);
|
|
61
|
+
return k;
|
|
62
|
+
}
|
|
63
|
+
const TK_CLS = { Done: 'dn', 'In review': 'rv', 'In progress': 'ip', 'To do': '' };
|
|
64
|
+
const tkStatus = (status, category) => {
|
|
65
|
+
const s = String(status || '');
|
|
66
|
+
if (category === 'done' || /\b(done|closed|resolved|released)\b/i.test(s)) return 'Done';
|
|
67
|
+
if (/review|\bqa\b|test/i.test(s)) return 'In review';
|
|
68
|
+
if (category === 'doing' || /progress|doing|block|started/i.test(s)) return 'In progress';
|
|
69
|
+
return 'To do';
|
|
70
|
+
};
|
|
71
|
+
/** The Jira tickets of each initiative, from the sprint readings (with sprint, points and flag) and the board's work items (pushed tickets). */
|
|
72
|
+
function ticketsBy(sprints, items) {
|
|
73
|
+
const by = new Map(), seen = new Map();
|
|
74
|
+
const add = (ini, t) => {
|
|
75
|
+
if (!ini || !t.key) return;
|
|
76
|
+
const had = seen.get(t.key);
|
|
77
|
+
if (had) { for (const k of Object.keys(t)) if (had[k] == null || had[k] === '') had[k] = t[k]; return; }
|
|
78
|
+
if (!by.has(ini)) by.set(ini, []);
|
|
79
|
+
seen.set(t.key, t); by.get(ini).push(t);
|
|
80
|
+
};
|
|
81
|
+
for (const sp of sprints || []) for (const i of sp.issues || []) {
|
|
82
|
+
const status = tkStatus(i.status, i.category);
|
|
83
|
+
add(i.initiative, { key: i.key, title: clip(i.summary || i.key, 120), status, raw: i.status || '', cls: i.flagged ? 'bl' : TK_CLS[status], blocked: !!i.flagged, reason: i.flagged && i.reason ? clip(i.reason, 160) : '',
|
|
84
|
+
points: Number.isFinite(i.points) ? i.points : null, url: i.url || '', sprint: sp.name || '', sprintState: sp.state || '', sprintEnd: sp.end ? String(sp.end).slice(0, 10) : '', assignee: i.assignee || '' });
|
|
85
|
+
}
|
|
86
|
+
for (const w of items || []) {
|
|
87
|
+
if (!w || w.src !== 'jira' || w.kind === 'Epic' || !w.key) continue;
|
|
88
|
+
add(w.ini, { key: w.key, title: clip(w.title || w.key, 120), status: w.status || 'To do', raw: w.status || '', cls: w.blocked ? 'bl' : TK_CLS[w.status] || '', blocked: !!w.blocked, reason: '', points: null, url: '', sprint: '', sprintState: '', sprintEnd: '', assignee: w.owner || '' });
|
|
89
|
+
}
|
|
90
|
+
return by;
|
|
91
|
+
}
|
|
92
|
+
/** The stage track of one row: its step, the output that finishes it, progress toward it and the tickets behind that progress. */
|
|
93
|
+
function trackOf(r, tickets, today, release) {
|
|
94
|
+
const k = stepIndex(r.stage, r.cat), step = STEPS[k] || null;
|
|
95
|
+
const tk = (tickets || []).slice(0, 40);
|
|
96
|
+
const done = tk.filter((t) => t.status === 'Done').length, blocked = tk.filter((t) => t.blocked);
|
|
97
|
+
const pts = tk.filter((t) => t.points != null), ptsAll = pts.reduce((n, t) => n + t.points, 0), ptsDone = pts.filter((t) => t.status === 'Done').reduce((n, t) => n + t.points, 0);
|
|
98
|
+
const byPts = pts.length === tk.length && ptsAll > 0;
|
|
99
|
+
const jira = !!(step && (step.key === 'build' || step.key === 'deliver') && tk.length);
|
|
100
|
+
let out = step ? step.output : 'No step on record';
|
|
101
|
+
if (step && step.key === 'deliver' && release) out = release + ' shipped + your sign-off';
|
|
102
|
+
const prog = jira
|
|
103
|
+
? { done: byPts ? ptsDone : done, total: byPts ? ptsAll : tk.length, unit: byPts ? 'pts' : 'tickets', parts: tk.map((t) => t.cls || '') }
|
|
104
|
+
: r.progress != null ? { done: Math.round(r.progress), total: 100, unit: '%', parts: null } : null;
|
|
105
|
+
const review = tk.filter((t) => t.status === 'In review');
|
|
106
|
+
const next = blocked.length ? { tone: 'red', text: blocked[0].key + ' blocked' + (blocked[0].reason ? ' · ' + blocked[0].reason : '') }
|
|
107
|
+
: review.length ? { tone: '', text: review.map((t) => t.key).slice(0, 2).join(', ') + ' in review' }
|
|
108
|
+
: prog ? null : { tone: '', text: step ? 'Nothing is counted toward it yet' : 'Its stage is not one of the eight steps' };
|
|
109
|
+
const upd = r.updated ? days(String(r.updated).slice(0, 10), today) : null;
|
|
110
|
+
const fc = tk.filter((t) => t.status !== 'Done' && t.sprintEnd).map((t) => t.sprintEnd).sort().pop() || null;
|
|
111
|
+
return { k, key: step ? step.key : null, label: step ? step.label : (r.stage || 'No stage'), ms: !!(step && step.ms), output: out, prog, next, tickets: tk, blocked: blocked.length,
|
|
112
|
+
idle: upd != null && upd >= 30 && r.status !== 'done' ? upd : null, forecast: fc, forecastLabel: fc ? shortDate(fc) : '' };
|
|
113
|
+
}
|
|
114
|
+
/** The anchor's theme, for the long timeline spans: the objective a KR belongs to, or the health budgets. */
|
|
115
|
+
function themeOf(anchor) {
|
|
116
|
+
const a = String(anchor || '');
|
|
117
|
+
if (!a) return { key: 'none', label: 'No anchor' };
|
|
118
|
+
if (/^health:/.test(a)) return { key: 'health', label: 'Health budgets' };
|
|
119
|
+
const m = /^(.*?):(o\d+)/i.exec(a);
|
|
120
|
+
return m ? { key: m[1] + ':' + m[2], label: m[2].toUpperCase() + ' · ' + m[1] } : { key: a, label: a };
|
|
121
|
+
}
|
|
122
|
+
|
|
42
123
|
/** What the row's ⋯ menu and the initiative page's bar can do, from the row's own fields (initiative premium-board-actions): its workflow's stage names,
|
|
43
124
|
* its stage, its lifecycle (on hold or cancelled, with the reason and check-back day the lifecycle line holds) and its archive entry. */
|
|
44
125
|
function actsOf(r, boardNames) {
|
|
@@ -72,6 +153,7 @@ function rowOf(r, wf, today) {
|
|
|
72
153
|
stage: r.stage || null, cat: r.cat || null, stageNote: r.stageSource === 'derived' ? 'derived' : null,
|
|
73
154
|
seg: names.map((n, j) => (j < cur ? 'p' : j === cur ? 'n' : '')), progress: r.progress != null ? Math.max(0, Math.min(100, Math.round(r.progress))) : null,
|
|
74
155
|
finish: r.end ? shortDate(r.end) : 'Not planned', over: !!over, start: r.start || null, end: r.end || null,
|
|
156
|
+
owner: r.owner || null, lane: r.lane || null, anchor: r.anchor || null, updated: r.updated || null, overDays: over ? days(r.end, today) : 0,
|
|
75
157
|
acts: actsOf(r, names),
|
|
76
158
|
dialog: {
|
|
77
159
|
eye: 'Initiative', logTitle: 'Read from the board',
|
|
@@ -98,6 +180,10 @@ function build(f) {
|
|
|
98
180
|
if (rows[0] && rows[0].late) rows[0].first = true;
|
|
99
181
|
const stages = (f.columns || []).map((c) => ({ stage: c.stage, cat: c.cat, count: Number(c.count) || 0, rows: (c.rows || []).slice(0, STAGE_ROWS).map((r) => rowOf(r, wf, todayIso)), more: Math.max(0, (Number(c.count) || 0) - STAGE_ROWS) }));
|
|
100
182
|
const stageRows = [].concat(...stages.map((s) => s.rows));
|
|
183
|
+
// the Agreed design's stage track (premium-agreed-design): tickets, output and progress per row
|
|
184
|
+
const tkBy = ticketsBy((f.sprints && Array.isArray(f.sprints.sprints)) ? f.sprints.sprints : [], f.items || []);
|
|
185
|
+
const relOfIni = new Map(); if (f.nextRelease && f.nextRelease.at) for (const id of f.nextRelease.ini || []) relOfIni.set(id, f.nextRelease.name || f.nextRelease.id);
|
|
186
|
+
for (const r of rows.concat(stageRows, gone.cancelled, gone.archived)) if (!r.track) { r.track = trackOf(r, tkBy.get(r.id), todayIso, relOfIni.get(r.id)); r.theme = themeOf(r.anchor); }
|
|
101
187
|
// the timeline: only an initiative with both a start and an end date has a bar
|
|
102
188
|
const dated = rows.filter((r) => r.start && r.end && isoDay(r.start) && isoDay(r.end));
|
|
103
189
|
let timeline;
|
|
@@ -186,6 +272,11 @@ function build(f) {
|
|
|
186
272
|
stages, timeline,
|
|
187
273
|
},
|
|
188
274
|
sprint, release, docs,
|
|
275
|
+
// the Agreed design (premium-agreed-design): the eight steps with the board's own count in each, the Jira read time and the chip counts
|
|
276
|
+
steps: STEPS.map((st, i) => ({ ...st, count: stages.filter((c) => stepIndex(c.stage, c.cat) === i).reduce((n, c) => n + c.count, 0) })),
|
|
277
|
+
jira: { source: sp.source || 'none', readAt: sp.readAt || null, release: nr && nr.at ? { name: nr.name || nr.id, at: shortDate(String(nr.at).slice(0, 10)), iso: String(nr.at).slice(0, 10) } : null,
|
|
278
|
+
sprint: active ? { name: active.name, start: active.start ? String(active.start).slice(0, 10) : null, end: active.end ? String(active.end).slice(0, 10) : null } : null },
|
|
279
|
+
chips: { late, risk, blocked: rows.filter((r) => r.track && r.track.blocked).length, idle: rows.filter((r) => r.track && r.track.idle != null).length, asks: f.asks == null ? null : f.asks.filter((a) => a && a.state !== 'accepted' && a.state !== 'declined').length },
|
|
189
280
|
asks: f.asks == null ? { missing: true, rows: [] } : { rows: f.asks.filter((a) => a && a.state !== 'accepted' && a.state !== 'declined').slice(0, 50).map(askOf) },
|
|
190
281
|
dock: { needs: risk + late, label: 'need a look', release: nr && nr.at ? { at: shortDate(String(nr.at).slice(0, 10)), name: nr.name || nr.id } : null, next: (rows.find((r) => r.late) || rows.find((r) => r.bad) || {}).title || null },
|
|
191
282
|
rows: rows.concat(stageRows.filter((r) => !rows.some((x) => x.key === r.key)), gone.cancelled, gone.archived, [sprintRow, relRow].filter(Boolean)).concat([{ key: 'board:this-board', id: null, title: board.name || 'This board', sub: 'Board', dialog: { eye: 'Board', logTitle: 'Read from the board', log: ['Read the board and its initiatives', 'Counted them by status', 'Changed nothing'], say: (board.name || 'This board') + ' has ' + open + ' open ' + plural(open, 'initiative', 'initiatives') + ': ' + on + ' on track, ' + risk + ' at risk, ' + late + ' late' + (hold ? ', ' + hold + ' on hold' : '') + '.', head: 'Where it stands', facts: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== ''), hold: 'Nothing here changes a board.', pane: { label: 'Board record', file: '', note: 'The board as its records hold it.', rows: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== '') } } }]),
|
|
@@ -194,4 +285,4 @@ function build(f) {
|
|
|
194
285
|
return model;
|
|
195
286
|
}
|
|
196
287
|
|
|
197
|
-
module.exports = { build, peekModel };
|
|
288
|
+
module.exports = { build, peekModel, STEPS, stepIndex, themeOf };
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* templateWorkflow(name) → a fresh copy of a template's stages [{ name, cat, hint }]
|
|
7
7
|
* isTemplateEdited(template, workflow) → true when the stages differ from the template's (names or categories)
|
|
8
8
|
* fold(events) → { boards, moves, assigns, asks, stages, events }
|
|
9
|
-
* readingOf(nineStages, { accepted }) → the
|
|
9
|
+
* readingOf(nineStages, { accepted }) → the lifecycle key the reading names (scripts/nine-stages.js output: eight steps)
|
|
10
10
|
* deriveStage(board, reading) → the stage name a reading maps to on this board's workflow
|
|
11
11
|
* stageOf(board, id, reading, folded) → { stage, source: 'move'|'derived' }
|
|
12
12
|
* moveWarnings(board, row, from, to, facts) → ['Skipped Plan', 'No spec yet', 'No anchor']
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
* Nothing is deleted. A line that is not an object with a known kind is skipped.
|
|
41
41
|
*
|
|
42
42
|
* STAGE OF AN INITIATIVE on a team board: the last move recorded for it on that board (a workflow edit's `moved` and an
|
|
43
|
-
* ask-accept count as moves; a rename carries the move along). With none, it is derived from the
|
|
44
|
-
* discover
|
|
43
|
+
* ask-accept count as moves; a rename carries the move along). With none, it is derived from the lifecycle reading:
|
|
44
|
+
* triage|discover → first Discover stage; plan|prioritize → first Plan; build|deliver → first Do;
|
|
45
45
|
* monitor|evaluate → first Learn. A workflow with no stage in that category uses the nearest earlier category, else
|
|
46
46
|
* its first stage.
|
|
47
47
|
*/
|
|
@@ -104,16 +104,16 @@ function boardSettings(board) {
|
|
|
104
104
|
return { build, jira: projects[0] || null, jiraProjects: projects, offer, defTpl };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
/* The PMOS-self board: the
|
|
107
|
+
/* The PMOS-self board: the six stages and two milestones of scripts/nine-stages.js (premium-agreed-design L1), read-only, each in its
|
|
108
|
+
* category. The removed keys ideate and strategize keep a category so an old reading still maps (read-time only). */
|
|
109
|
+
const { STAGES: LIFE, LABELS: LIFE_LABEL, MILESTONES: LIFE_MILESTONES, stageKey } = require('./nine-stages');
|
|
108
110
|
const READING_CAT = Object.freeze({
|
|
109
|
-
discover: 'Discover', ideate: 'Discover',
|
|
110
|
-
|
|
111
|
+
triage: 'Discover', discover: 'Discover', ideate: 'Discover',
|
|
112
|
+
plan: 'Plan', prioritize: 'Plan', strategize: 'Plan',
|
|
111
113
|
build: 'Do', deliver: 'Do',
|
|
112
114
|
monitor: 'Learn', evaluate: 'Learn',
|
|
113
115
|
});
|
|
114
|
-
const
|
|
115
|
-
const NINE_LABEL = { discover: 'Discover', ideate: 'Ideate', strategize: 'Strategize', prioritize: 'Prioritize', plan: 'Plan', build: 'Build', deliver: 'Deliver', monitor: 'Monitor', evaluate: 'Evaluate' };
|
|
116
|
-
const SELF_LADDER = Object.freeze(NINE.map((k) => st(NINE_LABEL[k], READING_CAT[k], 'Derived by scripts/workflow-state.js; not moved by hand.')));
|
|
116
|
+
const SELF_LADDER = Object.freeze(LIFE.map((k) => Object.freeze({ ...st(LIFE_LABEL[k], READING_CAT[k], 'Derived by scripts/workflow-state.js; not moved by hand.'), ...(LIFE_MILESTONES.has(k) ? { milestone: true } : {}) })));
|
|
117
117
|
|
|
118
118
|
/* The stage tools of each category, per template: the initiative page shows these first and the rest behind
|
|
119
119
|
* "More tools". `id` names the page section or tool the UI opens. */
|
|
@@ -324,16 +324,17 @@ function shiftDay(iso, days) {
|
|
|
324
324
|
return d.toISOString().slice(0, 10);
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
/** The
|
|
327
|
+
/** The lifecycle key a reading names: the current stage, else (accepted) evaluate, else the last done, else the first used.
|
|
328
|
+
* A removed key (ideate, strategize) in an old reading maps to its new key. */
|
|
328
329
|
function readingOf(nine, { accepted = false } = {}) {
|
|
329
330
|
const list = Array.isArray(nine) ? nine : [];
|
|
330
331
|
const cur = list.find((s) => s && s.status === 'current');
|
|
331
|
-
if (cur) return cur.key;
|
|
332
|
+
if (cur) return stageKey(cur.key);
|
|
332
333
|
if (accepted) return 'evaluate';
|
|
333
334
|
const done = list.filter((s) => s && s.status === 'done');
|
|
334
|
-
if (done.length) return done[done.length - 1].key;
|
|
335
|
+
if (done.length) return stageKey(done[done.length - 1].key);
|
|
335
336
|
const used = list.find((s) => s && s.status !== 'skipped');
|
|
336
|
-
return used ? used.key : '
|
|
337
|
+
return used ? stageKey(used.key) : 'triage';
|
|
337
338
|
}
|
|
338
339
|
|
|
339
340
|
function deriveStage(board, reading) {
|
|
@@ -348,7 +349,7 @@ function deriveStage(board, reading) {
|
|
|
348
349
|
}
|
|
349
350
|
|
|
350
351
|
function stageOf(board, id, reading, folded) {
|
|
351
|
-
if (board && board.self) return { stage:
|
|
352
|
+
if (board && board.self) return { stage: LIFE_LABEL[stageKey(reading)] || LIFE_LABEL.triage, source: 'derived' };
|
|
352
353
|
const wf = workflowOf(board, id, folded);
|
|
353
354
|
const moved = folded && folded.stages ? folded.stages.get(key(board.id, id)) : null;
|
|
354
355
|
if (moved && wf.some((s) => s.name === moved)) return { stage: moved, source: 'move' };
|
|
@@ -1,40 +1,63 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/*
|
|
3
|
-
* The
|
|
3
|
+
* The lifecycle label layer over the workflow engine's derived stage: six stages and two milestones
|
|
4
|
+
* (premium-agreed-design L1, PM decision 2026-10-22). The file keeps its old name and export names
|
|
5
|
+
* (`nineStages`, `STAGES`, `LABELS`, `LANE_STAGES`) so that every caller keeps working; the
|
|
6
|
+
* `nine_stages` field on a row keeps its name for the same reason. It now carries eight entries.
|
|
7
|
+
*
|
|
8
|
+
* Triage (BRD) → Discover (PRD) → Plan (scope, timeline, WBS; the PM's Commit pushes tickets to Jira)
|
|
9
|
+
* → Prioritize (ranked on the roadmap) → Build (features delivered, Jira) → ◆ Deliver (milestone:
|
|
10
|
+
* release shipped, PM sign-off) → Monitor (outcome report) → ◆ Evaluate (milestone: keep, iterate or stop)
|
|
4
11
|
*
|
|
5
12
|
* The engine derives one of six rungs (intake, spec, contract, build, eval, accepted) from the steps
|
|
6
|
-
* it found. This file names the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
13
|
+
* it found. This file names the stages the PM sees and says which of them each lane uses. It never
|
|
14
|
+
* decides a stage itself: a stage is `done` only when a derived signal shows it, and a stage no record
|
|
15
|
+
* can yet show is `no-signal`, not guessed.
|
|
9
16
|
*
|
|
10
|
-
*
|
|
17
|
+
* Migration: the old nine had Ideate and Strategize. Stage is derived, never stored, so there is no
|
|
18
|
+
* stored stage to rewrite. Records that signalled Ideate (ideas, hypotheses) now count for Discover;
|
|
19
|
+
* records that signalled Strategize (decisions, bets) now count for Prioritize. `stageKey` maps an
|
|
20
|
+
* old key read from anywhere (a stored payload, a URL, a fixture) to its new key at read time.
|
|
11
21
|
*/
|
|
12
22
|
|
|
13
|
-
const STAGES = ['
|
|
23
|
+
const STAGES = ['triage', 'discover', 'plan', 'prioritize', 'build', 'deliver', 'monitor', 'evaluate'];
|
|
14
24
|
|
|
15
25
|
const LABELS = {
|
|
16
|
-
|
|
26
|
+
triage: 'Triage', discover: 'Discover', plan: 'Plan', prioritize: 'Prioritize',
|
|
17
27
|
build: 'Build', deliver: 'Deliver', monitor: 'Monitor', evaluate: 'Evaluate',
|
|
18
28
|
};
|
|
19
29
|
|
|
30
|
+
// What each stage produces (the PM's words on the Agreed design).
|
|
31
|
+
const OUTPUTS = {
|
|
32
|
+
triage: 'BRD', discover: 'PRD', plan: 'Scope, timeline and work breakdown', prioritize: 'Ranked on the roadmap',
|
|
33
|
+
build: 'Features delivered (Jira)', deliver: 'Release shipped, PM sign-off', monitor: 'Outcome report', evaluate: 'Keep, iterate or stop',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Deliver and Evaluate are milestones (drawn as a diamond), not stages with duration.
|
|
37
|
+
const MILESTONES = new Set(['deliver', 'evaluate']);
|
|
38
|
+
|
|
39
|
+
// The removed keys and where they went. Read-time only: nothing stored is rewritten.
|
|
40
|
+
const LEGACY = { ideate: 'discover', strategize: 'prioritize' };
|
|
41
|
+
const stageKey = (k) => (k == null ? k : LEGACY[k] || k);
|
|
42
|
+
|
|
20
43
|
// Which stages each product-code lane uses. Stages not listed read `skipped`.
|
|
21
44
|
const LANE_STAGES = {
|
|
22
45
|
feature: STAGES,
|
|
23
|
-
discovery: ['
|
|
24
|
-
chore: ['plan', 'build', 'evaluate'],
|
|
46
|
+
discovery: ['triage', 'discover', 'prioritize', 'evaluate'],
|
|
47
|
+
chore: ['plan', 'build', 'deliver', 'evaluate'],
|
|
25
48
|
incident: ['build', 'deliver', 'monitor', 'evaluate'],
|
|
26
|
-
content: ['
|
|
27
|
-
prototype: ['
|
|
49
|
+
content: ['discover', 'plan', 'build', 'deliver'],
|
|
50
|
+
prototype: ['triage', 'discover', 'evaluate'],
|
|
28
51
|
};
|
|
29
52
|
|
|
30
53
|
// Stages that have a derived signal today. Every other stage reads `no-signal` until its record exists.
|
|
31
|
-
const SIGNALLED = new Set(['discover', 'plan', 'build', 'evaluate']);
|
|
54
|
+
const SIGNALLED = new Set(['triage', 'discover', 'plan', 'build', 'evaluate']);
|
|
32
55
|
|
|
33
56
|
const RANK = { intake: 0, spec: 1, contract: 2, build: 3, eval: 4, accepted: 5 };
|
|
34
57
|
|
|
35
58
|
// Stages that gain a signal only when the caller passes the records (scripts/records readAll plus optional `releases`).
|
|
36
|
-
// With no records the output is exactly the
|
|
37
|
-
const RECORD_SIGNALLED = new Set(['
|
|
59
|
+
// With no records the output is exactly the records-free output, so the lifecycle-lens mirror stays equal.
|
|
60
|
+
const RECORD_SIGNALLED = new Set(['discover', 'prioritize', 'monitor', 'deliver']);
|
|
38
61
|
|
|
39
62
|
// records: { initiative?, anchor?, ideas, hypotheses, decisions, bets, 'kr-metrics', releases } (every list optional).
|
|
40
63
|
// The initiative id and anchor come from `derived` (id, anchor) or from records.initiative / records.anchor.
|
|
@@ -43,10 +66,12 @@ function recordSignals(derived, records, buildDone) {
|
|
|
43
66
|
const anchor = (derived && derived.anchor) || records.anchor || null;
|
|
44
67
|
const mine = (list) => (list || []).filter((r) => id && r.initiative === id);
|
|
45
68
|
const kr = (records['kr-metrics'] || []).filter((m) => anchor && (m.rid === anchor || m.parent_kr === anchor || 'kr:' + m.rid === anchor));
|
|
69
|
+
const ranked = mine(records.bets).some((b) => ['now', 'next', 'later'].includes(b.horizon) && Number.isInteger(b.rank));
|
|
46
70
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
// was Ideate: an idea or hypothesis on the initiative
|
|
72
|
+
discover: mine(records.ideas).length + mine(records.hypotheses).length > 0,
|
|
73
|
+
// was Strategize (a decision or bet) or the old Prioritize (a ranked bet)
|
|
74
|
+
prioritize: ranked || mine(records.decisions).length + mine(records.bets).length > 0,
|
|
50
75
|
monitor: !!buildDone && kr.some((m) => (m.readings || []).length > 0),
|
|
51
76
|
deliver: mine(records.releases).length > 0,
|
|
52
77
|
};
|
|
@@ -57,6 +82,7 @@ function nineStages(lane, derived, records) {
|
|
|
57
82
|
const rank = RANK[derived && derived.stage] ?? 0;
|
|
58
83
|
const step = (key) => (derived && derived.steps || []).find((s) => s.key === key);
|
|
59
84
|
const done = {
|
|
85
|
+
triage: rank >= 1,
|
|
60
86
|
discover: rank >= 1,
|
|
61
87
|
plan: rank >= 2,
|
|
62
88
|
build: rank >= 3 || (step('build') && step('build').status === 'done'),
|
|
@@ -64,18 +90,21 @@ function nineStages(lane, derived, records) {
|
|
|
64
90
|
};
|
|
65
91
|
const accepted = rank >= 5;
|
|
66
92
|
const fromRecords = records && typeof records === 'object' ? recordSignals(derived, records, done.build) : null;
|
|
93
|
+
const signalled = (key) => SIGNALLED.has(key) || (fromRecords && RECORD_SIGNALLED.has(key) && (key !== 'deliver' || fromRecords.deliver));
|
|
67
94
|
const out = [];
|
|
68
95
|
let currentSet = false;
|
|
69
96
|
for (const key of STAGES) {
|
|
70
97
|
let status;
|
|
71
98
|
if (!laneSet.has(key)) status = 'skipped';
|
|
72
|
-
else if (!
|
|
99
|
+
else if (!signalled(key)) status = 'no-signal';
|
|
73
100
|
else if (done[key] || (fromRecords && fromRecords[key])) status = 'done';
|
|
74
101
|
else status = 'pending';
|
|
75
102
|
if (status === 'pending' && !currentSet) { status = 'current'; currentSet = true; }
|
|
76
|
-
|
|
103
|
+
const entry = { key, label: LABELS[key], status, accepted: key === 'evaluate' ? accepted : undefined };
|
|
104
|
+
if (MILESTONES.has(key)) entry.milestone = true;
|
|
105
|
+
out.push(entry);
|
|
77
106
|
}
|
|
78
107
|
return out;
|
|
79
108
|
}
|
|
80
109
|
|
|
81
|
-
module.exports = { STAGES, LABELS, LANE_STAGES, nineStages };
|
|
110
|
+
module.exports = { STAGES, LABELS, OUTPUTS, MILESTONES, LEGACY, LANE_STAGES, stageKey, nineStages, lifecycleStages: nineStages };
|
|
@@ -202,6 +202,8 @@ reg('work', 'work.mis-lensed', (f) => f.work.filter((w) => w.lens === 'later' &&
|
|
|
202
202
|
})));
|
|
203
203
|
|
|
204
204
|
// ---------- INITIATIVES: lifecycle lenses ----------
|
|
205
|
+
// premium-agreed-design L1: Ideate folded into Discover and Strategize into Prioritize. The detector ids (ideate.*, strategize.*) are kept as
|
|
206
|
+
// stable identifiers, because kinds.js and recorded dismissals name them; only the page they belong to moved.
|
|
205
207
|
reg('discover', 'discover.untraced-evidence', (f) => f.hyps.flatMap((h) => {
|
|
206
208
|
const miss = h.evidence.filter((e) => !f.docs[e.src]);
|
|
207
209
|
const tot = sum(h.evidence.map((e) => e.w)) || 1;
|
|
@@ -217,27 +219,27 @@ reg('discover', 'discover.stale-evidence', (f) => Object.entries(f.docs).filter(
|
|
|
217
219
|
reg('discover', 'discover.open-hypothesis', (f) => f.hyps.filter((h) => { const n = sum(h.evidence.map((e) => (e.dir === 'supports' ? e.w : -e.w))); return n < 3 && n > -2; }).map((h) => s({
|
|
218
220
|
id: 'discover.open:' + h.slug, page: 'discover', key: 'hyp:' + h.slug, entity: h.slug, magnitude: 0.4, deadlineDays: 21, child: true, title: `"${h.title}" is still open`, facts: [],
|
|
219
221
|
})));
|
|
220
|
-
reg('
|
|
221
|
-
id: 'ideate.quick:' + i.slug, page: '
|
|
222
|
+
reg('discover', 'ideate.quick-win', (f) => f.ideas.filter((i) => i.effort <= 2 && i.score >= 1.5).map((i) => s({
|
|
223
|
+
id: 'ideate.quick:' + i.slug, page: 'discover', key: 'idea:' + i.slug, entity: i.slug, magnitude: Math.min(1, i.score / 3), deadlineDays: 30, shape: 'rows',
|
|
222
224
|
title: `${i.title}: score ${i.score} for effort ${i.effort}, not on the roadmap`, facts: ['impact ' + i.impact, 'confidence ' + i.confidence],
|
|
223
225
|
})));
|
|
224
|
-
reg('
|
|
225
|
-
id: 'ideate.unanchored:' + i.slug, page: '
|
|
226
|
+
reg('discover', 'ideate.unanchored', (f) => f.ideas.filter((i) => !i.parent_kr).map((i) => s({
|
|
227
|
+
id: 'ideate.unanchored:' + i.slug, page: 'discover', key: 'idea:' + i.slug, entity: i.slug, magnitude: 0.5, deadlineDays: 14, title: `${i.title} has no KR anchor`, facts: [],
|
|
226
228
|
})));
|
|
227
|
-
reg('
|
|
229
|
+
reg('discover', 'ideate.concentration', (f) => {
|
|
228
230
|
if (f.ideas.length < 4) return [];
|
|
229
231
|
const by = {}; f.ideas.forEach((i) => { by[i.parent_kr] = (by[i.parent_kr] || 0) + 1; });
|
|
230
232
|
const [k, n] = Object.entries(by).sort((a, b) => b[1] - a[1])[0];
|
|
231
|
-
return n === f.ideas.length ? [s({ id: 'ideate.concentration', page: '
|
|
233
|
+
return n === f.ideas.length ? [s({ id: 'ideate.concentration', page: 'discover', key: 'concentration', entity: k, magnitude: 0.4, deadlineDays: 30, title: `All ${n} ideas aim at one KR (${k}); nothing explores the others`, facts: [] })] : [];
|
|
232
234
|
});
|
|
233
|
-
reg('
|
|
234
|
-
reg('
|
|
235
|
-
id: 'strategize.unanchored:' + i.id, page: '
|
|
235
|
+
reg('prioritize', 'strategize.kr-deviation', (f) => REG.find((d) => d.id === 'cal.kr-deviation').fn(f).map((x) => ({ ...x, page: 'prioritize' })));
|
|
236
|
+
reg('prioritize', 'strategize.unanchored', (f) => f.inis.filter((i) => !i.done && !i.parent_kr).map((i) => s({
|
|
237
|
+
id: 'strategize.unanchored:' + i.id, page: 'prioritize', key: 'anchor:' + i.id, entity: i.id, magnitude: 0.5, deadlineDays: 14, policyCritical: true, shape: 'rows',
|
|
236
238
|
title: `${i.title} has no KR or health budget`, facts: ['horizon ' + i.horizon],
|
|
237
239
|
})));
|
|
238
|
-
reg('
|
|
240
|
+
reg('prioritize', 'strategize.single-bet', (f) => {
|
|
239
241
|
const now = f.inis.filter((i) => i.horizon === 'now');
|
|
240
|
-
return now.length === 1 && f.inis.length >= 3 ? [s({ id: 'strategize.single-bet', page: '
|
|
242
|
+
return now.length === 1 && f.inis.length >= 3 ? [s({ id: 'strategize.single-bet', page: 'prioritize', key: 'bets', entity: 'portfolio', magnitude: 0.4, deadlineDays: 30, strategic: true, title: `Everything in flight rides on one bet (${now[0].title}); ${f.inis.length - 1} others are Next or Later`, facts: [] })] : [];
|
|
241
243
|
});
|
|
242
244
|
reg('prioritize', 'prioritize.capacity-free', (f) => {
|
|
243
245
|
const inflight = f.inis.filter((i) => i.horizon === 'now').length, CAP = 4;
|
|
@@ -252,6 +252,77 @@ function leadOf(text) {
|
|
|
252
252
|
return '';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
|
|
256
|
+
/* ── premium-agreed-design (G1, G2): Goals and Outcomes ───────────────────────────────────────────────────────────────────────────────────────────
|
|
257
|
+
* A goal is one KR metric record. Its type is read from its unit, its direction from baseline to target, and its pace is the projection above said
|
|
258
|
+
* in words. What moves it is every initiative of the board whose anchor names the record (its id or its metric name, as the Calendar's synergy does).
|
|
259
|
+
* Outcomes lists the initiatives past Build (Deliver, Monitor, Evaluate) with what their anchor goal promised and where it stands. No verdict is
|
|
260
|
+
* invented: an initiative in Evaluate needs one, and a done one is listed as decided. */
|
|
261
|
+
const LIFE = ['triage', 'discover', 'plan', 'prioritize', 'build', 'deliver', 'monitor', 'evaluate'];
|
|
262
|
+
const LIFE_LABEL = ['Triage', 'Discover', 'Plan', 'Prioritize', 'Build', 'Deliver', 'Monitor', 'Evaluate'];
|
|
263
|
+
const LIFE_ALIAS = { ideate: 1, strategize: 3, intake: 0, spec: 1, contract: 2, eval: 7, accepted: 7 };
|
|
264
|
+
/** The lifecycle index (0 Triage … 7 Evaluate) of a stage name, or -1 when the name is not a lifecycle stage. PURE. */
|
|
265
|
+
function lifeIndex(stage) {
|
|
266
|
+
const k = String(stage || '').trim().toLowerCase();
|
|
267
|
+
const i = LIFE.indexOf(k);
|
|
268
|
+
return i >= 0 ? i : (k in LIFE_ALIAS ? LIFE_ALIAS[k] : -1);
|
|
269
|
+
}
|
|
270
|
+
/** The goal type the Agreed design names, read from the unit. A record holds no type field, so the unit is the only honest signal. PURE. */
|
|
271
|
+
function goalType(unit) {
|
|
272
|
+
const u = String(unit || '').trim();
|
|
273
|
+
if (u === '%' || /^(pct|percent|pts?|points?)$/i.test(u)) return 'Percentage';
|
|
274
|
+
if (/^(s|sec|secs|seconds?|mins?|minutes?|h|hrs?|hours?|d|days?|weeks?|months?|ms)$/i.test(u)) return 'Duration';
|
|
275
|
+
if (/[$€£¥]/.test(u) || /^(usd|eur|gbp|arr|mrr)$/i.test(u)) return 'Amount';
|
|
276
|
+
return 'Count';
|
|
277
|
+
}
|
|
278
|
+
const STATE_TONE = { ok: 'ok', drift: 'late', off: 'red', unscored: 'q' };
|
|
279
|
+
const anchorHits = (a, o) => !!a && (String(a) === String(o.id) || String(a) === String(o.name));
|
|
280
|
+
function initOf(r) {
|
|
281
|
+
const i = lifeIndex(r.stage);
|
|
282
|
+
return { id: String(r.id), title: clip(r.title || r.id, 120), stage: r.stage || '', idx: i, stageLabel: i >= 0 ? LIFE_LABEL[i] : (r.stage || ''), status: r.status || '', lane: r.lane || '',
|
|
283
|
+
owner: r.owner || '', end: r.end ? shortDate(r.end) : '', endAt: r.end ? String(r.end).slice(0, 10) : null, anchor: r.anchor || '' };
|
|
284
|
+
}
|
|
285
|
+
/** One goal per KR metric record, with or without a series. `today` is a day in ms (UTC midnight). */
|
|
286
|
+
function goalsOf(outcomes, charts, inits, today) {
|
|
287
|
+
return outcomes.map((o) => {
|
|
288
|
+
const c = charts.find((x) => x.id === o.id) || null;
|
|
289
|
+
const rs = (o.readings || []).filter((x) => x && fin(x.v) && isoDay(x.at) !== null);
|
|
290
|
+
const u = o.unit || '', base = fin(o.start) ? o.start : null, tgt = fin(o.target) ? o.target : null;
|
|
291
|
+
const now = rs.length ? rs[rs.length - 1].v : null;
|
|
292
|
+
const dir = tgt !== null && base !== null && tgt !== base ? Math.sign(tgt - base) : 0;
|
|
293
|
+
const fromAt = rs.length ? rs[0].at : null, byAt = isoDay(o.by) !== null ? String(o.by).slice(0, 10) : null;
|
|
294
|
+
const t0 = isoDay(fromAt), t1 = isoDay(byAt);
|
|
295
|
+
const timeGone = t0 !== null && t1 !== null && t1 > t0 ? Math.max(0, Math.min(1, (today - t0) / (t1 - t0))) : null;
|
|
296
|
+
const done = now !== null && tgt !== null && base !== null && tgt !== base ? Math.max(0, Math.min(1, (now - base) / (tgt - base))) : null;
|
|
297
|
+
const p = c ? projectionOf(c) : null;
|
|
298
|
+
const reached = now !== null && tgt !== null && dir && (dir > 0 ? now >= tgt : now <= tgt);
|
|
299
|
+
let pace;
|
|
300
|
+
if (reached) pace = { tone: 'ok', head: 'Reached', sub: 'at ' + num(now, u) + (rs.length ? ' on ' + shortDate(rs[rs.length - 1].at) : '') };
|
|
301
|
+
else if (p && !p.toward) pace = { tone: 'late', head: 'Never reaches ' + num(tgt, u), sub: p.perWeek === 0 ? 'not moving' : 'moving the wrong way' };
|
|
302
|
+
else if (p && !p.reaches) pace = { tone: 'late', head: '≈' + num(r1(p.atDue), u) + ' by ' + shortDate(byAt), sub: amount(r1(p.short), u) + ' short at this pace' };
|
|
303
|
+
else if (p) pace = { tone: 'ok', head: '≈' + num(r1(p.atDue), u) + ' by ' + shortDate(byAt), sub: done !== null && timeGone !== null ? 'on course: ' + Math.round(done * 100) + '% done, ' + Math.round(timeGone * 100) + '% of time gone' : 'on course' };
|
|
304
|
+
else pace = { tone: 'q', head: '—', sub: rs.length < 2 ? (rs.length ? 'needs a second reading' : 'no reading yet') : !byAt ? 'no target date' : t1 !== null && t1 <= isoDay(rs[rs.length - 1].at) ? 'its date has passed' : 'no pace to read' };
|
|
305
|
+
const moves = (inits || []).filter((r) => anchorHits(r.anchor, o)).map(initOf);
|
|
306
|
+
return {
|
|
307
|
+
id: o.id, key: c ? c.key : null, title: clip(o.name, 120), pillar: o.pillar || '', unit: u, type: goalType(u),
|
|
308
|
+
dirTxt: dir > 0 ? 'up is better' : dir < 0 ? 'down is better' : '', base, baseTxt: base !== null ? num(base, u) : '', from: fromAt ? shortDate(fromAt) : '',
|
|
309
|
+
now, nowTxt: now !== null ? num(now, u) : '', target: tgt, targetTxt: tgt !== null ? num(tgt, u) : '', by: byAt ? shortDate(byAt) : '', byAt, fromAt,
|
|
310
|
+
done, timeGone, tone: STATE_TONE[o.status] || 'q', state: o.status || 'unscored', chip: (CHIP[o.status] || ['No line scored'])[0], reason: o.reason || '',
|
|
311
|
+
proj: p ? { atDue: r1(p.atDue), reaches: p.reaches, toward: p.toward } : null, pace, readings: rs.length, moves,
|
|
312
|
+
};
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/** Shipped work (Deliver, Monitor, Evaluate, or done) against what its anchor goal promised. PURE. */
|
|
316
|
+
function outcomesOf(inits, goals, outcomes) {
|
|
317
|
+
const ORDER = ['verdict', 'window', 'decided'];
|
|
318
|
+
const rows = (inits || []).map(initOf).filter((r) => r.idx >= 5 || r.status === 'done');
|
|
319
|
+
return rows.map((r) => {
|
|
320
|
+
const g = goals.find((x) => anchorHits(r.anchor, { id: x.id, name: (outcomes.find((o) => o.id === x.id) || {}).name })) || null;
|
|
321
|
+
const group = r.status === 'done' || r.status === 'cancelled' ? 'decided' : r.idx === 7 ? 'verdict' : 'window';
|
|
322
|
+
return Object.assign(r, { group, goal: g ? { id: g.id, key: g.key, title: g.title, type: g.type, baseTxt: g.baseTxt, targetTxt: g.targetTxt, nowTxt: g.nowTxt, by: g.by, done: g.done, tone: g.tone, pace: g.pace } : null });
|
|
323
|
+
}).sort((a, b) => ORDER.indexOf(a.group) - ORDER.indexOf(b.group));
|
|
324
|
+
}
|
|
325
|
+
|
|
255
326
|
function build(facts) {
|
|
256
327
|
const f = facts || {};
|
|
257
328
|
const outcomes = f.outcomes || [], missing = (f.missing || []).slice();
|
|
@@ -287,8 +358,14 @@ function build(facts) {
|
|
|
287
358
|
dock: { needs: off, label: off === 1 ? 'measure off its line' : 'measures off their line', next: findings[0] && findings[0].chart ? (charts.find((c) => c.key === findings[0].chart) || {}).title || null : null },
|
|
288
359
|
counts: { charts: charts.length, noSeries: noSeries.length, off, total: outcomes.length },
|
|
289
360
|
};
|
|
361
|
+
const today = isoDay(new Date(fin(f.now) ? f.now : Date.now()).toISOString()) || 0;
|
|
362
|
+
model.today = new Date(today).toISOString().slice(0, 10);
|
|
363
|
+
model.goals = goalsOf(outcomes, charts, f.initiatives || [], today);
|
|
364
|
+
model.initiativesRead = Array.isArray(f.initiatives);
|
|
365
|
+
model.outcomes = outcomesOf(f.initiatives || [], model.goals, outcomes);
|
|
366
|
+
model.lifecycle = LIFE_LABEL.map((label, i) => ({ key: LIFE[i], label, milestone: i === 5 || i === 7 }));
|
|
290
367
|
last = model;
|
|
291
368
|
return model;
|
|
292
369
|
}
|
|
293
370
|
|
|
294
|
-
module.exports = { build, peekModel, chartOf, mineOf, findingsOf, findingsOfChart, projectionOf, leadOf, shortDate, num };
|
|
371
|
+
module.exports = { lifeIndex, goalType, goalsOf, outcomesOf, build, peekModel, chartOf, mineOf, findingsOf, findingsOfChart, projectionOf, leadOf, shortDate, num };
|
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
|
66
66
|
const missing = [];
|
|
67
67
|
// the late and at-risk initiatives first (the board's own `risk` view, late before at risk), then its `now` view, each initiative once
|
|
68
68
|
const listOf = (a, n) => { const seen = new Set(), out = []; const rank = (r) => (r.status === 'late' ? 0 : 1); for (const r of [...((a && a.rows) || [])].sort((x, y) => rank(x) - rank(y))) { if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } } for (const r of (n && n.rows) || []) if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } return out.slice(0, 100); };
|
|
69
|
-
const [risk, now, cols, spr, docs, held, can, arc, asks] = await Promise.all([
|
|
69
|
+
const [risk, now, cols, spr, docs, held, can, arc, asks, its] = await Promise.all([
|
|
70
70
|
via(boards, '/api/boards/backlog' + q + '&view=risk&limit=100', req, ctx),
|
|
71
71
|
via(boards, '/api/boards/backlog' + q + '&view=now&limit=100', req, ctx),
|
|
72
72
|
via(boards, '/api/boards/columns' + q, req, ctx),
|
|
@@ -76,6 +76,7 @@ module.exports = {
|
|
|
76
76
|
via(boards, '/api/boards/backlog' + q + '&view=all&status=cancelled&limit=100', req, ctx),
|
|
77
77
|
via(boards, '/api/boards/backlog' + q + '&archived=1&limit=100', req, ctx),
|
|
78
78
|
via(boards, '/api/boards/asks' + q, req, ctx),
|
|
79
|
+
via(boards, '/api/boards/items' + q, req, ctx), // the Jira tickets of each initiative, for the stage track (premium-agreed-design B1)
|
|
79
80
|
]);
|
|
80
81
|
const ok = (r, name) => { if (r.status === 202 || !r.body || r.body.ok === false || r.body.pending) { missing.push(name); return null; } return r.body; };
|
|
81
82
|
const rk = ok(risk, 'initiatives'), nw = ok(now, 'initiatives'), c = ok(cols, 'stages'), s = ok(spr, 'sprints'), d = ok(docs, 'core documents');
|
|
@@ -87,7 +88,7 @@ module.exports = {
|
|
|
87
88
|
now: Date.now(), pending: false, missing: missing.filter((m) => m !== 'core documents'), boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })),
|
|
88
89
|
board: head.body.board, counts: head.body.counts, nextRelease: head.body.nextRelease || null, pastReleases: head.body.pastReleases || [],
|
|
89
90
|
rows: listOf(rk, nw), columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] }, docs: d, custom,
|
|
90
|
-
held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
|
|
91
|
+
items: its && its.body && its.body.ok !== false && Array.isArray(its.body.items) ? its.body.items : [], held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
|
|
91
92
|
});
|
|
92
93
|
// a press re-derives the rows in the background; while the answer is stale the page asks again (initiative premium-board-actions)
|
|
93
94
|
let stale = false;
|
|
@@ -180,7 +180,7 @@ function rowOf(F, rec) {
|
|
|
180
180
|
progress: { done: pr.done, total: pr.total, label: pr.label },
|
|
181
181
|
next_due: nextDue(F, id),
|
|
182
182
|
last_activity: rec.last_activity || null,
|
|
183
|
-
// The
|
|
183
|
+
// The eight lifecycle steps (six stages, two milestones) over the engine's rung (scripts/nine-stages.js); on every row so Roadmap, List and sheet share one key set.
|
|
184
184
|
nine_stages: nineStages(rec.lane, { stage: rec.stage, steps: Array.isArray(rec.steps) ? rec.steps : [] }),
|
|
185
185
|
};
|
|
186
186
|
}
|
|
@@ -72,10 +72,17 @@ module.exports = {
|
|
|
72
72
|
const setupsOk = su.status === 200 && !!su.body && Array.isArray(su.body.setups);
|
|
73
73
|
if (!setupsOk) missing.push('report setups');
|
|
74
74
|
const leads = reportsOk ? leadsOf(ctx, ws, rp.body.reports || []) : {};
|
|
75
|
+
// premium-agreed-design (G1, G2): the board's initiatives, so a goal can name what moves it and Outcomes can list shipped work. Read-only.
|
|
76
|
+
let initiatives = null;
|
|
77
|
+
if (pick && pick.id) {
|
|
78
|
+
const bl = await via(boards, '/api/boards/backlog' + qs({ ws: pick.ws, board: pick.id }) + '&view=all&limit=200', req, ctx).catch(() => ({ status: 500, body: null }));
|
|
79
|
+
if (bl.status === 200 && bl.body && Array.isArray(bl.body.rows)) initiatives = bl.body.rows;
|
|
80
|
+
else if (bl.status !== 202) missing.push('initiatives');
|
|
81
|
+
}
|
|
75
82
|
const model = Insights.build({
|
|
76
83
|
now: Date.now(), board: pick ? { ws: pick.ws, id: pick.id, name: pick.name } : { ws, id: null, name: 'Insights' }, boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })),
|
|
77
84
|
outcomes, reports: reportsOk ? rp.body.reports || [] : [], reportsOk, missing, saved, mine,
|
|
78
|
-
setups: setupsOk ? su.body : null, pinned, leads, archived,
|
|
85
|
+
setups: setupsOk ? su.body : null, pinned, leads, archived, initiatives,
|
|
79
86
|
});
|
|
80
87
|
ctx.json(res, { ok: true, state: 'ready', model, as_of: Date.now() });
|
|
81
88
|
return true;
|