create-pmos 0.838.0 → 0.840.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 +94 -62
- 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/state/discoveries.md +1 -1
- package/workspace/changelog.json +93 -24
- package/workspace/guide/cli.md +26 -0
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/layout.md +3 -1
- package/workspace/guide/programs.md +3 -0
- package/workspace/guide/reports.md +9 -1
- package/workspace/lib/app-versions.js +169 -0
- package/workspace/lib/features.json +2 -0
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/report-translate.js +26 -1
- package/workspace/lib/report-variants.js +14 -1
- package/workspace/lib/roadmap-audiences.js +157 -0
- package/workspace/lib/roadmap-cli.js +68 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-app-versions.js +54 -0
- package/workspace/lib/routes-reports.js +20 -3
- package/workspace/lib/routes-roadmap-audiences.js +55 -0
- package/workspace/lib/routes-today.js +15 -1
- package/workspace/lib/tracker-digest.js +12 -1
- package/workspace/lib/versions-cli.js +112 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/app-versions.js +97 -0
- package/workspace/public/pm/bd-ds.css +6 -0
- package/workspace/public/pm/bd-work-ds.css +26 -0
- package/workspace/public/pm/cozy-pop-work.js +7 -3
- package/workspace/public/pm/cozy-today-app.js +19 -1
- package/workspace/public/pm/ini-detail.css +38 -0
- package/workspace/public/pm/ini-detail.js +117 -0
- package/workspace/public/pm/premium-board.js +28 -5
- package/workspace/public/pm/premium-report-read.js +61 -3
- package/workspace/public/pm/roadmap-audiences.js +72 -0
- package/workspace/public/pm/standup-line.js +37 -0
- package/workspace/public/pm/wk-sum.js +103 -0
- package/workspace/public/premium-board.html +3 -0
- package/workspace/test-lists/app-versions.json +9 -0
- package/workspace/test-lists/ini-detail.json +9 -0
- package/workspace/test-lists/roadmap-audiences.json +9 -0
- package/workspace/test-lists/surface-reports.json +9 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* app-versions.js — which versions of a product's app are still in use, the open bugs their users hit, and at most one ✦ proposal of
|
|
3
|
+
* which version to force (idea A211, initiative app-versions, board BatchReleaseDS panel 22).
|
|
4
|
+
*
|
|
5
|
+
* read(dir) → { versions: { <v>: { users, unit, source, at, gone } }, bugs: { <key>: { title, versions, crash, open, source } },
|
|
6
|
+
* decided: { <v>: 'force' | 'leave' } } the fold of <dir>/app-versions.jsonl, last line wins
|
|
7
|
+
* rows(state) → [{ version, users, unit, share, bugs: [{ key, title, crash }], crash, forced }] PURE, newest first
|
|
8
|
+
* proposal(state, rows?) → null | { version, share, bugs, crashes, text } PURE, at most one ✦
|
|
9
|
+
* setUsers(dir, { version, users, source }, now?) users: a count (710) or a share ("7%")
|
|
10
|
+
* gone(dir, version) · bug(dir, { key, title, versions, crash, source }) · fixed(dir, key)
|
|
11
|
+
* decide(dir, version, 'force' | 'leave') · undo(dir) → takes back the last force or leave
|
|
12
|
+
* releases(root, state?) → ['4.2', '4.1', …] the release names in the product's stored Jira readings (fixVersions) not recorded
|
|
13
|
+
* yet, newest first, at most 4: the block's way in when nothing is recorded (LINE.md Rule 12). Read-only.
|
|
14
|
+
* every write → { ok, … } | { ok: false, error }
|
|
15
|
+
*
|
|
16
|
+
* WHERE. `dir` is the product's records folder (lib/records-dir.js): planning/records in the PMOS repo, pmos/state/records in a kit product.
|
|
17
|
+
* The file is append-only. The counts come from the user's own sources (store console, analytics export), each write names its source;
|
|
18
|
+
* PMOS never guesses a count.
|
|
19
|
+
*
|
|
20
|
+
* THE RULES (board panel 22).
|
|
21
|
+
* · One row per version still in use: users above 0 and not marked gone. Newest first by version number (4.10 before 4.9).
|
|
22
|
+
* · A bug counts on a version only when it is open and recorded against that version. A bug with no version counts nowhere.
|
|
23
|
+
* · At most one ✦: among the versions that are not the newest, not forced or left by the PM, with at least one open bug, the one whose
|
|
24
|
+
* users hit the most crashes, then the most bugs, then the oldest. The reason says the share of users, the bugs and the crashes.
|
|
25
|
+
* · Forcing an update is an outward change. Nothing here forces one: `decide` only records the PM's own decision, and nothing in PMOS
|
|
26
|
+
* calls it except the PM's press on Work (page-press POST) or the PM's `pmos versions force`, which refuses inside a background run. */
|
|
27
|
+
const fs = require('fs');
|
|
28
|
+
const path = require('path');
|
|
29
|
+
|
|
30
|
+
const FILE = 'app-versions.jsonl';
|
|
31
|
+
const VERSION_RE = /^[0-9A-Za-z][0-9A-Za-z._+-]{0,39}$/;
|
|
32
|
+
const KEY_RE = /^[^\s]{1,60}$/;
|
|
33
|
+
const MAX_TEXT = 160;
|
|
34
|
+
|
|
35
|
+
const fileOf = (dir) => path.join(dir, FILE);
|
|
36
|
+
function lines(dir) {
|
|
37
|
+
let raw = '';
|
|
38
|
+
try { raw = fs.readFileSync(fileOf(dir), 'utf8'); } catch { return []; }
|
|
39
|
+
const out = [];
|
|
40
|
+
for (const l of raw.split('\n')) { if (!l.trim()) continue; try { out.push(JSON.parse(l)); } catch { /* a torn line is skipped */ } }
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function append(dir, line, now = Date.now()) {
|
|
44
|
+
const row = { at: new Date(now).toISOString(), ...line };
|
|
45
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
46
|
+
fs.appendFileSync(fileOf(dir), JSON.stringify(row) + '\n');
|
|
47
|
+
return row;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Compare two version names, newest first: numbers compare as numbers (4.10 > 4.9), other parts as text. */
|
|
51
|
+
function cmpDesc(a, b) {
|
|
52
|
+
const pa = String(a).split(/[.\-+_]/), pb = String(b).split(/[.\-+_]/);
|
|
53
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
54
|
+
const x = pa[i], y = pb[i];
|
|
55
|
+
if (x === undefined) return 1;
|
|
56
|
+
if (y === undefined) return -1;
|
|
57
|
+
const nx = /^\d+$/.test(x), ny = /^\d+$/.test(y);
|
|
58
|
+
if (nx && ny && Number(x) !== Number(y)) return Number(y) - Number(x);
|
|
59
|
+
if (nx !== ny) return nx ? -1 : 1;
|
|
60
|
+
if (!nx && x !== y) return x < y ? 1 : -1;
|
|
61
|
+
}
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function read(dir) {
|
|
66
|
+
const S = { versions: {}, bugs: {}, decided: {} };
|
|
67
|
+
const stack = []; // the force and leave decisions, for undo
|
|
68
|
+
for (const l of lines(dir)) {
|
|
69
|
+
const v = l.version != null ? String(l.version) : '';
|
|
70
|
+
if (l.ev === 'users' && v) S.versions[v] = { users: Number(l.users) || 0, unit: l.unit === '%' ? '%' : 'users', source: l.source || '', at: l.at, gone: false };
|
|
71
|
+
else if (l.ev === 'gone' && v && S.versions[v]) S.versions[v].gone = true;
|
|
72
|
+
else if (l.ev === 'bug' && l.key) S.bugs[l.key] = { title: l.title || '', versions: Array.isArray(l.versions) ? l.versions.map(String) : [], crash: !!l.crash, open: true, source: l.source || '' };
|
|
73
|
+
else if (l.ev === 'fixed' && l.key && S.bugs[l.key]) S.bugs[l.key].open = false;
|
|
74
|
+
else if ((l.ev === 'force' || l.ev === 'leave') && v) { stack.push({ v, was: S.decided[v] }); S.decided[v] = l.ev; }
|
|
75
|
+
else if (l.ev === 'undo') { const last = stack.pop(); if (last) { if (last.was) S.decided[last.v] = last.was; else delete S.decided[last.v]; } }
|
|
76
|
+
}
|
|
77
|
+
S.undoable = stack.length > 0;
|
|
78
|
+
return S;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function rows(state) {
|
|
82
|
+
const live = Object.entries((state && state.versions) || {}).filter(([, x]) => !x.gone && x.users > 0);
|
|
83
|
+
const counts = live.filter(([, x]) => x.unit === 'users');
|
|
84
|
+
const total = counts.reduce((n, [, x]) => n + x.users, 0);
|
|
85
|
+
const bugs = Object.entries((state && state.bugs) || {}).filter(([, b]) => b.open);
|
|
86
|
+
return live.sort(([a], [b]) => cmpDesc(a, b)).map(([version, x]) => {
|
|
87
|
+
const hit = bugs.filter(([, b]) => b.versions.includes(version)).map(([key, b]) => ({ key, title: b.title, crash: b.crash }));
|
|
88
|
+
hit.sort((a, b) => Number(b.crash) - Number(a.crash));
|
|
89
|
+
const share = x.unit === '%' ? x.users : (total && counts.length === live.length ? Math.round((x.users / total) * 100) : null);
|
|
90
|
+
return { version, users: x.users, unit: x.unit, share, source: x.source, bugs: hit, crash: hit.filter((b) => b.crash).length, forced: (state.decided || {})[version] === 'force' };
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const usersWord = (r) => (r.share != null ? r.share + ' % of users' : r.users + (r.unit === '%' ? ' %' : ' users'));
|
|
95
|
+
function proposal(state, rs) {
|
|
96
|
+
const list = rs || rows(state);
|
|
97
|
+
if (list.length < 2) return null;
|
|
98
|
+
const decided = (state && state.decided) || {};
|
|
99
|
+
const pick = list.slice(1).filter((r) => r.bugs.length && !decided[r.version])
|
|
100
|
+
.sort((a, b) => (b.crash - a.crash) || (b.bugs.length - a.bugs.length) || cmpDesc(b.version, a.version))[0];
|
|
101
|
+
if (!pick) return null;
|
|
102
|
+
const n = pick.bugs.length;
|
|
103
|
+
const text = `Force an update from ${pick.version}: ${usersWord(pick)}, ${n} bug${n === 1 ? '' : 's'}${pick.crash ? (pick.crash === 1 ? ', one a crash' : `, ${pick.crash} crashes`) : ''}.`;
|
|
104
|
+
return { version: pick.version, share: pick.share, bugs: n, crashes: pick.crash, text };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function releases(root, state, max = 4) {
|
|
108
|
+
let names = [], JT = null, JS = null;
|
|
109
|
+
try { JT = require('./jira-tickets.js'); JS = require('./jira-status.js'); names = fs.readdirSync(JT.jiraDir(root)); } catch { return []; }
|
|
110
|
+
const known = new Set(Object.keys((state && state.versions) || {}));
|
|
111
|
+
const seen = new Set();
|
|
112
|
+
for (const n of names) {
|
|
113
|
+
if (!n.endsWith('.md') || n.endsWith('-tickets.md')) continue;
|
|
114
|
+
let snap = null;
|
|
115
|
+
try { snap = JS.readSnapshot(root, n.slice(0, -3)); } catch { snap = null; }
|
|
116
|
+
for (const tk of snap ? snap.tickets.values() : []) {
|
|
117
|
+
for (const v of [].concat(tk.fixVersion || [])) { const s = String(v).trim(); if (VERSION_RE.test(s) && !known.has(s)) seen.add(s); }
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return [...seen].sort(cmpDesc).slice(0, max);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const clean = (s) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, MAX_TEXT);
|
|
124
|
+
const fail = (error) => ({ ok: false, error });
|
|
125
|
+
|
|
126
|
+
function setUsers(dir, { version, users, source } = {}, now) {
|
|
127
|
+
const v = String(version || '');
|
|
128
|
+
if (!VERSION_RE.test(v)) return fail('a version looks like 4.2 or 3.9.1');
|
|
129
|
+
const m = /^\s*(\d+(?:\.\d+)?)\s*(%?)\s*$/.exec(String(users == null ? '' : users));
|
|
130
|
+
if (!m) return fail('--users is a count (710) or a share (7%)');
|
|
131
|
+
if (m[2] && Number(m[1]) > 100) return fail('a share is 100% at most');
|
|
132
|
+
if (!clean(source)) return fail('--source "<where the count comes from>" is needed: PMOS never guesses a count');
|
|
133
|
+
return { ok: true, line: append(dir, { ev: 'users', version: v, users: Number(m[1]), unit: m[2] ? '%' : 'users', source: clean(source) }, now) };
|
|
134
|
+
}
|
|
135
|
+
function gone(dir, version, now) {
|
|
136
|
+
const v = String(version || '');
|
|
137
|
+
if (!read(dir).versions[v]) return fail(`no version ${v} is recorded`);
|
|
138
|
+
return { ok: true, line: append(dir, { ev: 'gone', version: v }, now) };
|
|
139
|
+
}
|
|
140
|
+
function bug(dir, { key, title, versions, crash, source } = {}, now) {
|
|
141
|
+
const k = String(key || '');
|
|
142
|
+
if (!KEY_RE.test(k)) return fail('--key <the bug\'s id> is needed (PAY-12)');
|
|
143
|
+
if (!clean(title)) return fail('--title "<what goes wrong>" is needed');
|
|
144
|
+
const vs = (Array.isArray(versions) ? versions : [versions]).filter((x) => x != null && x !== '').map(String);
|
|
145
|
+
if (!vs.length) return fail('--version <the version its users hit it on> is needed; a bug with no version counts nowhere');
|
|
146
|
+
const badV = vs.find((x) => !VERSION_RE.test(x));
|
|
147
|
+
if (badV) return fail(`"${badV}" is not a version`);
|
|
148
|
+
if (!clean(source)) return fail('--source "<where the bug is filed>" is needed');
|
|
149
|
+
return { ok: true, line: append(dir, { ev: 'bug', key: k, title: clean(title), versions: [...new Set(vs)], crash: !!crash, source: clean(source) }, now) };
|
|
150
|
+
}
|
|
151
|
+
function fixed(dir, key, now) {
|
|
152
|
+
const k = String(key || '');
|
|
153
|
+
if (!read(dir).bugs[k]) return fail(`no bug ${k} is recorded`);
|
|
154
|
+
return { ok: true, line: append(dir, { ev: 'fixed', key: k }, now) };
|
|
155
|
+
}
|
|
156
|
+
/** The PM's own decision on a version: 'force' (the PM will force the update where the app's updates are set) or 'leave'. Nothing is sent. */
|
|
157
|
+
function decide(dir, version, act, now) {
|
|
158
|
+
const v = String(version || '');
|
|
159
|
+
if (act !== 'force' && act !== 'leave') return fail('the decision is force or leave');
|
|
160
|
+
const S = read(dir);
|
|
161
|
+
if (!rows(S).some((r) => r.version === v)) return fail(`version ${v} is not in use`);
|
|
162
|
+
return { ok: true, line: append(dir, { ev: act, version: v, by: 'pm' }, now) };
|
|
163
|
+
}
|
|
164
|
+
function undo(dir, now) {
|
|
165
|
+
if (!read(dir).undoable) return fail('there is no force or leave to take back');
|
|
166
|
+
return { ok: true, line: append(dir, { ev: 'undo' }, now) };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = { FILE, read, rows, proposal, setUsers, gone, bug, fixed, decide, undo, releases, cmpDesc, usersWord };
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
{"id": "parked", "audience": "user", "status": "ga", "group": "Catch up", "name": "Parked work", "say": "Each initiative on hold, why it is parked and what brings it back.", "cmd": "/parked", "verb": "parked", "sub": "list", "phrases": ["parked work", "what is on hold", "what is parked", "paused initiatives"], "since": "0.700.0"},
|
|
17
17
|
{"id": "people", "audience": "user", "status": "ga", "group": "Catch up", "name": "People you work with", "say": "Each person with their role, how often you talk and their tone.", "cmd": "/people", "verb": "people", "sub": "list", "phrases": ["who do I work with", "stakeholders list", "people on this", "who is involved"], "since": "0.610.0"},
|
|
18
18
|
{"id": "strategy", "audience": "user", "status": "ga", "group": "Your product", "name": "Five-line strategy", "say": "Who it is for, the problem, the bet, how you win and what you will not do.", "cmd": "/strategy", "verb": "strategy", "sub": "show", "place": "board", "phrases": ["our strategy", "product strategy", "draft the strategy", "how we win"], "since": "0.776.0", "ask": ["product"]},
|
|
19
|
+
{"id": "versions", "audience": "user", "status": "beta", "group": "Your product", "name": "Old app versions", "say": "The app versions still in use, the open bugs their users hit, and which one to force.", "cmd": "/versions", "verb": "versions", "sub": "list", "since": "0.830.0"},
|
|
19
20
|
{"id": "segments", "audience": "user", "status": "ga", "group": "Your product", "name": "Segments", "say": "A few user groups with their size and health, and the roadmap items that serve each.", "cmd": "/segments", "verb": "segments", "sub": "list", "place": "board", "since": "0.822.0"},
|
|
20
21
|
{"id": "code", "audience": "user", "status": "ga", "group": "Your product", "name": "Code map", "say": "One line per main part of the code: what it is, how it is tested, who changed it last.", "cmd": "/code", "verb": "code", "sub": "show", "place": "board", "since": "0.826.0", "ask": ["product"]},
|
|
21
22
|
{"id": "connectors", "audience": "user", "status": "ga", "group": "Your product", "name": "What connectors read and write", "say": "What PMOS reads and writes through each connector, and what leaves this computer.", "cmd": "/connectors", "verb": "connectors", "sub": "data", "since": "0.825.0"},
|
|
@@ -83,6 +84,7 @@
|
|
|
83
84
|
{"id": "git-identity", "audience": "user", "status": "ga", "group": "Find your way", "name": "Your git identity", "say": "Which git identity and GitHub login this repository uses.", "cmd": "/git-identity", "verb": "git-identity"},
|
|
84
85
|
{"id": "voice", "audience": "user", "status": "ga", "group": "Your product", "name": "Customer voice", "say": "Survey comments and app-store reviews grouped by reason, the fastest-growing first.", "cmd": "/voice", "verb": "voice"},
|
|
85
86
|
{"id": "signal", "audience": "user", "status": "ga", "group": "Your product", "name": "Customer signals", "say": "The customer signals behind each roadmap item.", "cmd": "/signal", "verb": "signal", "hint": "<item>"},
|
|
87
|
+
{"id": "roadmap", "audience": "user", "status": "ga", "group": "Your product", "name": "Roadmap for others", "say": "The ranked roadmap written for leadership, the team or customers.", "cmd": "/roadmap", "verb": "roadmap", "hint": "for exec|team|customer"},
|
|
86
88
|
{"id": "launcher", "audience": "user", "status": "ga", "group": "Find your way", "name": "Start without a terminal", "say": "A PMOS app and a login item, so the workspace starts by itself.", "cmd": "/launcher", "verb": "launcher"},
|
|
87
89
|
{"id": "verify-work", "audience": "agent", "status": "ga", "group": "What PMOS did", "name": "Mark integrated work", "say": "A build run marks work items integrated from the default branch.", "cmd": "/verify-work", "verb": "verify-work"},
|
|
88
90
|
{"id": "build", "audience": "agent", "status": "ga", "group": "What PMOS did", "name": "The Builder", "say": "A declared work item becomes a pull request; the factory's runs use it.", "cmd": "/build", "verb": "build"},
|
|
@@ -212,6 +212,9 @@ const VERBS = Object.freeze({
|
|
|
212
212
|
// Not a pm-os-absorb verb (run: null): initiative strategy-draft (Wawan 2026-11-24) added it through the same table.
|
|
213
213
|
strategy: Object.freeze({ module: 'strategy-cli.js', run: null, guide: 'cli.md',
|
|
214
214
|
help: 'pmos strategy show|sources|draft|set|undo — the product\'s five-line strategy; PMOS drafts blank lines from the product\'s files, each citing them (pmos strategy help)' }),
|
|
215
|
+
// Not a pm-os-absorb verb (run: null): initiative app-versions (idea A211) added it through the same table.
|
|
216
|
+
versions: Object.freeze({ module: 'versions-cli.js', run: null, guide: 'cli.md',
|
|
217
|
+
help: 'pmos versions list|set|gone|bug|fixed|force|leave|undo — the app versions still in use, the open bugs their users hit, and which one to force; PMOS sends nothing (pmos versions help)' }),
|
|
215
218
|
// Not a pm-os-absorb verb (run: null): initiative declined-asks-reply (bet A326) added it through the same table.
|
|
216
219
|
declined: Object.freeze({ module: 'declined-cli.js', run: null, guide: 'cli.md',
|
|
217
220
|
help: 'pmos declined list|draft|record — asks closed without being done, each with a kind reply draft PMOS never sends; record one in the out-of-scope list (pmos declined help)' }),
|
|
@@ -274,6 +277,9 @@ const VERBS = Object.freeze({
|
|
|
274
277
|
// Not a pm-os-absorb verb (run: null): roadmap-signal-verb (bet A157) added it through the same table.
|
|
275
278
|
signal: Object.freeze({ module: 'signal-cli.js', run: null, guide: 'cli.md',
|
|
276
279
|
help: 'pmos signal add|remove|list|count — the customer signals behind each roadmap item; Work shows the count (pmos signal help)' }),
|
|
280
|
+
// Not a pm-os-absorb verb (run: null): initiative roadmap-audiences (job #2052, A88) added it through the same table.
|
|
281
|
+
roadmap: Object.freeze({ module: 'roadmap-cli.js', run: null, guide: 'cli.md',
|
|
282
|
+
help: 'pmos roadmap for exec|team|customer [--out <file>] · share|unshare <id> — the ranked roadmap written for leadership, the team or customers; Work shows the same' }),
|
|
277
283
|
launcher: Object.freeze({ module: 'launcher-cli.js', run: null, guide: 'cli.md',
|
|
278
284
|
help: 'pmos launcher on|off|status — a PMOS app and a login item, so the workspace starts without a terminal' }),
|
|
279
285
|
// Not a pm-os-absorb verb (run: null): initiative three-layouts (job #1904, A317) added it through the same table.
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* promptOf({ body, language, reader }) PURE · answerOf(answer) PURE → markdown | null
|
|
27
27
|
* copyPath(rel, code) PURE · copyText({ fm, body, rel, language, code, reader, sha }) PURE → the file
|
|
28
28
|
* alsoOf(root, rel) → [{ code, language, reader, path }] the copies on disk beside a draft (the ⋯ menu's Also in …)
|
|
29
|
+
* hintOf(audience, have) PURE · languageHint(root, cadence) → [{ language, code }] a language the readers name with no copy yet (the ✦)
|
|
29
30
|
* definitionLanguages(root, cadence) → [{ language, code, reader }] · setLanguage(root, cadence, entry, { off }) → { ok, languages, path } | { ok:false, error }
|
|
30
31
|
* translate({ root, rel, ask, runtime?, env?, guard? }) → Promise<{ written, refused, skipped, off? }>
|
|
31
32
|
* attach(ctxFactory) hook onDraftWritten once; ctx: { workspaceList, runtimeDir, spawnScheduled|spawnSession }
|
|
@@ -151,6 +152,30 @@ function definitionLanguages(root, cadence, state = null) {
|
|
|
151
152
|
return languagesOf(fmMap(bodyOf(t).fm).languages || '');
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
/** PURE. The languages a report's readers name (its definition's `audience`, for example "Leadership; Dita reads Indonesian") that are not
|
|
156
|
+
* English and not on its `languages:` line yet: the ✦ on the draft (initiative surface-reports). [{ language, code }], at most 3. */
|
|
157
|
+
function hintOf(audience, have = []) {
|
|
158
|
+
const t = String(audience == null ? '' : audience).toLowerCase();
|
|
159
|
+
if (!t.trim()) return [];
|
|
160
|
+
const had = new Set((have || []).map((x) => x && x.code).filter(Boolean));
|
|
161
|
+
const out = [];
|
|
162
|
+
const names = [...Object.entries(LANGS).map(([c, n]) => [n.toLowerCase(), c]), ...Object.entries(ALIASES).filter(([a]) => a !== 'bahasa')]; // bare "bahasa" names no one language
|
|
163
|
+
for (const [name, code] of names) {
|
|
164
|
+
if (code === 'en' || had.has(code) || out.some((x) => x.code === code)) continue;
|
|
165
|
+
if (new RegExp('(^|[^a-z])' + name.replace(/ /g, '\\s+') + '([^a-z]|$)').test(t)) out.push({ language: LANGS[code], code });
|
|
166
|
+
}
|
|
167
|
+
return out.slice(0, 3);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The ✦ hint of a report: hintOf(its definition's audience, its languages). Read-only; [] when there is no definition. */
|
|
171
|
+
function languageHint(root, cadence, state = null) {
|
|
172
|
+
let st = state;
|
|
173
|
+
if (!st) { try { st = require('./report-draft.js').stateRel(root); } catch { return []; } }
|
|
174
|
+
let t = ''; try { t = fs.readFileSync(defFile(root, st, cadence), 'utf8'); } catch { return []; }
|
|
175
|
+
const fm = fmMap(bodyOf(t).fm);
|
|
176
|
+
return hintOf(fm.audience || '', languagesOf(fm.languages || ''));
|
|
177
|
+
}
|
|
178
|
+
|
|
154
179
|
/** Add or remove one `<Language>[ for <reader>]` entry on a definition's `languages:` line. */
|
|
155
180
|
function setLanguage(root, cadence, entry, { off = false, state = null } = {}) {
|
|
156
181
|
if (!/^[a-z][a-z0-9-]{0,39}$/.test(String(cadence || ''))) return { ok: false, error: 'the cadence is a report id, for example weekly' };
|
|
@@ -235,4 +260,4 @@ function attach(ctxFactory) {
|
|
|
235
260
|
});
|
|
236
261
|
}
|
|
237
262
|
|
|
238
|
-
module.exports = { JOB, ORIGIN, LANGS, codeOf, languagesOf, bodyOf, shaOf, namesOf, keeps, promptOf, answerOf, copyPath, copyText, alsoOf, definitionLanguages, setLanguage, translate, attach };
|
|
263
|
+
module.exports = { JOB, ORIGIN, LANGS, codeOf, languagesOf, bodyOf, shaOf, namesOf, keeps, promptOf, answerOf, copyPath, copyText, alsoOf, definitionLanguages, hintOf, languageHint, setLanguage, translate, attach };
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* addsNothing(orig, version) PURE → { ok, why? } · sourcesOf(body, rel) PURE → [line]
|
|
20
20
|
* promptOf({ body, audience }) PURE · versionPath(rel, id) PURE · versionText({ fm, body, rel, audience, sha }) PURE
|
|
21
21
|
* latestDraft(root, cadence) → rel | null
|
|
22
|
+
* versionsOf(root, rel) → [{ audience, label, path }] the versions on disk beside a draft, in AUDIENCES order (GET /api/report/draft
|
|
23
|
+
* `versions`; the report view's Draft | For … tabs, pm/premium-report-read.js). A file must say `variant_of` to count.
|
|
22
24
|
* variants({ root, rel, ask, audiences?, env?, runtime?, guard? }) → Promise<{ written, refused, skipped, off? }>
|
|
23
25
|
*/
|
|
24
26
|
const fs = require('fs');
|
|
@@ -98,6 +100,17 @@ function latestDraft(root, cadence, state = null) {
|
|
|
98
100
|
return files.length ? `${st}/reports/${cadence}/${files[files.length - 1]}` : null;
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
/** The versions on disk beside a draft, in AUDIENCES order. Read-only. */
|
|
104
|
+
function versionsOf(root, rel) {
|
|
105
|
+
const out = [];
|
|
106
|
+
for (const A of AUDIENCES) {
|
|
107
|
+
const p = versionPath(rel, A.id);
|
|
108
|
+
let fm = ''; try { fm = RT.bodyOf(fs.readFileSync(path.resolve(String(root), p), 'utf8')).fm; } catch { continue; }
|
|
109
|
+
if (/^variant_of:\s*\S/m.test(fm || '')) out.push({ audience: A.id, label: 'For ' + A.label, path: p });
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
|
|
101
114
|
function guardOf() { try { return require('./ai-guard.js'); } catch { return null; } }
|
|
102
115
|
|
|
103
116
|
/** One draft → one version per audience. ask(prompt, { key }) → the answer text, or null. */
|
|
@@ -124,4 +137,4 @@ async function variants({ root, rel, ask, audiences = AUDIENCES, env = process.e
|
|
|
124
137
|
return res;
|
|
125
138
|
}
|
|
126
139
|
|
|
127
|
-
module.exports = { JOB, AUDIENCES, audiencesOf, addsNothing, sourcesOf, promptOf, versionPath, versionText, latestDraft, variants };
|
|
140
|
+
module.exports = { JOB, AUDIENCES, audiencesOf, addsNothing, sourcesOf, promptOf, versionPath, versionText, latestDraft, versionsOf, variants };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* roadmap-audiences.js — the ranked Roadmap (D105) written for one audience at a time: exec, team or customer (bet A88, initiative
|
|
3
|
+
* roadmap-audiences). Derived on every read, so it follows the plan; it prints or saves a local file and is never sent.
|
|
4
|
+
*
|
|
5
|
+
* items({ root, rows?, now?, dir? }) → [{ id, title, stage, outcome, date, owners, blockers, shared }] the live roadmap, in rank order
|
|
6
|
+
* text(list, audience, { product }) → the markdown for one audience PURE
|
|
7
|
+
* lines(list, audience) → [line] one line per item, the same words as the markdown PURE
|
|
8
|
+
* shared(dir) · share(dir, id, on, { by, now }) → Set of shared ids · { ok, line } | { ok: false, error } <records>/roadmap-share.jsonl
|
|
9
|
+
* count(root) → the items marked for customers (the health number)
|
|
10
|
+
*
|
|
11
|
+
* THE THREE AUDIENCES (rules said once, here):
|
|
12
|
+
* exec one line per item: the title, its expected outcome and the date to check it (outcome_horizon, else the Roadmap's check-by)
|
|
13
|
+
* team one line per item: the title, its stage, the task owners, and the tasks that are blocked or waiting (at most MAX_BLOCKERS)
|
|
14
|
+
* customer only the items marked shareable, the title only, with a plain word for where it is (Planned, In progress, Shipped). No ids,
|
|
15
|
+
* no owners, no anchors, no internal names: a title that starts with "Name:" loses that part.
|
|
16
|
+
* Live means ranked, not dormant, not accepted and not stopped. At most MAX items show; the rest are one line "and N more on the roadmap".
|
|
17
|
+
* A value the records do not hold is left out of the line (zero is silence), never guessed. */
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const AUDIENCES = ['exec', 'team', 'customer'];
|
|
22
|
+
const LABEL = { exec: 'Exec', team: 'Team', customer: 'Customer' };
|
|
23
|
+
const FILE = 'roadmap-share.jsonl';
|
|
24
|
+
const TAG = '[roadmap-audiences]';
|
|
25
|
+
const MAX = 20;
|
|
26
|
+
const MAX_BLOCKERS = 2;
|
|
27
|
+
const BLOCKED = /^(blocked|waiting|on hold|held)$/i;
|
|
28
|
+
const SHIPPED = new Set(['deliver', 'monitor', 'evaluate', 'closed', 'shipped', 'done']);
|
|
29
|
+
const DOING = new Set(['build', 'implementation', 'in progress', 'evaluation']);
|
|
30
|
+
|
|
31
|
+
const oneLine = (s, n = 160) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
|
|
32
|
+
const nameOf = (s) => oneLine(String(s || '').replace(/^person:/i, ''), 60);
|
|
33
|
+
|
|
34
|
+
function recordsDirOf(root) {
|
|
35
|
+
try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The frontmatter keys of a record file: { key: value } for plain `key: value` lines. */
|
|
39
|
+
function frontOf(file) {
|
|
40
|
+
let text = '';
|
|
41
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return {}; }
|
|
42
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
43
|
+
if (!m) return {};
|
|
44
|
+
const out = {};
|
|
45
|
+
for (const l of m[1].split(/\r?\n/)) {
|
|
46
|
+
const k = /^([a-z_]+):\s*(.*)$/.exec(l);
|
|
47
|
+
if (k) out[k[1]] = k[2].replace(/^["']|["']$/g, '').trim();
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function tasksOf(root) {
|
|
53
|
+
try {
|
|
54
|
+
const Facts = require('./drift-facts.js');
|
|
55
|
+
const stateDir = require('./driver.js').stateDirOf(root);
|
|
56
|
+
let storeFile = null; try { const s = require('./task-store.js').storeFor(root); storeFile = s && s.file; } catch { storeFile = null; }
|
|
57
|
+
return Facts.tasksOf(root, stateDir ? path.join(stateDir, 'boards.jsonl') : null, storeFile, []).tasks;
|
|
58
|
+
} catch { return []; }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Each initiative's task owners and blocked tasks, from the task lines. PURE. */
|
|
62
|
+
function teamOf(tasks) {
|
|
63
|
+
const by = new Map();
|
|
64
|
+
for (const t of tasks || []) {
|
|
65
|
+
let state = '', owner = '', removed = false;
|
|
66
|
+
for (const l of (t.lines || []).slice().sort((a, b) => a.at - b.at)) {
|
|
67
|
+
if (l.state) state = l.state;
|
|
68
|
+
if (l.owner !== undefined) owner = nameOf(l.owner);
|
|
69
|
+
if (l.kind === 'task-remove') removed = true;
|
|
70
|
+
if (l.kind === 'task-restore') removed = false;
|
|
71
|
+
}
|
|
72
|
+
if (removed || state === 'Done' || state === 'Archived') continue;
|
|
73
|
+
const e = by.get(t.initiative) || { owners: [], blockers: [] };
|
|
74
|
+
if (owner && !e.owners.some((o) => o.toLowerCase() === owner.toLowerCase())) e.owners.push(owner);
|
|
75
|
+
if (BLOCKED.test(state) && e.blockers.length < MAX_BLOCKERS) e.blockers.push(oneLine(t.title, 70));
|
|
76
|
+
by.set(t.initiative, e);
|
|
77
|
+
}
|
|
78
|
+
return by;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function readShare(dir) {
|
|
82
|
+
let text = '';
|
|
83
|
+
try { text = fs.readFileSync(path.join(dir, FILE), 'utf8'); } catch { return []; }
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const l of text.split('\n')) { if (!l.trim()) continue; try { const o = JSON.parse(l); if (o && typeof o.id === 'string') out.push(o); } catch { /* torn */ } }
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
function shared(dir) {
|
|
89
|
+
const s = new Set();
|
|
90
|
+
for (const o of dir ? readShare(dir) : []) { if (o.on) s.add(o.id); else s.delete(o.id); }
|
|
91
|
+
return s;
|
|
92
|
+
}
|
|
93
|
+
function share(dir, id, on, { by = 'pm', now = Date.now() } = {}) {
|
|
94
|
+
const i = String(id || '').trim();
|
|
95
|
+
if (!/^[a-z0-9][a-z0-9._-]{0,80}$/.test(i)) return { ok: false, error: 'name an initiative id from the roadmap' };
|
|
96
|
+
if (!dir) return { ok: false, error: 'this product has no records folder' };
|
|
97
|
+
const line = { at: new Date(now).toISOString(), id: i, on: !!on, by };
|
|
98
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
99
|
+
fs.appendFileSync(path.join(dir, FILE), JSON.stringify(line) + '\n');
|
|
100
|
+
return { ok: true, line };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The live roadmap in rank order. rows: initiative-rows' rows (else derived now). */
|
|
104
|
+
function items({ root, rows = null, now = Date.now(), dir = null, tasks } = {}) {
|
|
105
|
+
root = path.resolve(root);
|
|
106
|
+
if (!rows) { const d = require('./initiative-rows.js').deriveSync(root); if (!d.ok) return []; rows = d.rows; }
|
|
107
|
+
let placed;
|
|
108
|
+
try { placed = require('./placements.js').readPlacements(root, { now, rules: require('./plan-rules.js').readRules(root), records: rows }); } catch { return []; }
|
|
109
|
+
const byRow = new Map(rows.map((r) => [r.id, r]));
|
|
110
|
+
const team = teamOf(tasks === undefined ? tasksOf(root) : tasks);
|
|
111
|
+
const share = shared(dir || recordsDirOf(root));
|
|
112
|
+
const out = [];
|
|
113
|
+
for (const id of placed.ranked || []) {
|
|
114
|
+
const r = byRow.get(id), p = (placed.byInit || {})[id] || {};
|
|
115
|
+
if (!r || p.dormant || r.accepted || r.stopped) continue;
|
|
116
|
+
const fm = r.record && out.length < MAX ? frontOf(path.join(root, r.record)) : {}; // only the lines that show read their record
|
|
117
|
+
const t = team.get(id) || { owners: [], blockers: [] };
|
|
118
|
+
out.push({ id, title: oneLine(r.title || id, 120), stage: String(r.stage || '').toLowerCase(), outcome: oneLine(fm.expected_outcome || '', 200),
|
|
119
|
+
date: /^\d{4}-\d{2}-\d{2}/.test(fm.outcome_horizon || '') ? fm.outcome_horizon.slice(0, 10) : (p.check_by || ''), owners: t.owners, blockers: t.blockers, shared: share.has(id) });
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const plainStage = (s) => (SHIPPED.has(s) ? 'Shipped' : DOING.has(s) ? 'In progress' : 'Planned');
|
|
125
|
+
const outerTitle = (t) => oneLine(String(t || '').replace(/^\s*[A-Z][a-z]+(?:\s[A-Z][a-z]+)?:\s+/, ''), 120);
|
|
126
|
+
|
|
127
|
+
/** One line per item for an audience. PURE. */
|
|
128
|
+
function lines(list, audience) {
|
|
129
|
+
const L = list || [];
|
|
130
|
+
if (audience === 'exec') return L.map((x) => [x.title, x.outcome && `outcome: ${x.outcome}`, x.date && `check ${x.date}`].filter(Boolean).join(' · '));
|
|
131
|
+
if (audience === 'team') return L.map((x) => [x.title, x.stage, x.owners.length && `owners: ${x.owners.join(', ')}`, x.blockers.length && `blocked: ${x.blockers.join('; ')}`].filter(Boolean).join(' · '));
|
|
132
|
+
if (audience === 'customer') return L.filter((x) => x.shared).map((x) => `${outerTitle(x.title)} · ${plainStage(x.stage)}`);
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The markdown for one audience. PURE. */
|
|
137
|
+
function text(list, audience, { product = '' } = {}) {
|
|
138
|
+
if (!AUDIENCES.includes(audience)) return '';
|
|
139
|
+
const all = lines(list, audience);
|
|
140
|
+
const head = `# Roadmap${product && audience !== 'customer' ? ' · ' + oneLine(product, 60) : ''} · for ${audience === 'exec' ? 'leadership' : audience === 'team' ? 'the team' : 'customers'}`;
|
|
141
|
+
if (!all.length) return `${head}\n\n${audience === 'customer' ? 'Nothing is marked for customers yet.' : 'The roadmap has no live items.'}\n`;
|
|
142
|
+
const shown = all.slice(0, MAX).map((l, i) => `${i + 1}. ${l}`);
|
|
143
|
+
if (all.length > MAX) shown.push(`\nand ${all.length - MAX} more on the roadmap.`);
|
|
144
|
+
return `${head}\n\n${shown.join('\n')}\n`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function count(root) { return shared(recordsDirOf(path.resolve(root))).size; }
|
|
148
|
+
|
|
149
|
+
module.exports = { AUDIENCES, LABEL, FILE, TAG, MAX, MAX_BLOCKERS, frontOf, teamOf, shared, share, items, lines, text, count, recordsDirOf, plainStage, outerTitle };
|
|
150
|
+
|
|
151
|
+
if (require.main === module) {
|
|
152
|
+
const a = process.argv.slice(2);
|
|
153
|
+
if (a[0] !== 'count') { console.error('usage: node lib/roadmap-audiences.js count <root>'); process.exit(2); }
|
|
154
|
+
const n = count(a[1] || '.');
|
|
155
|
+
console.log(`${TAG} ${n} items marked for customers`);
|
|
156
|
+
console.log(String(n));
|
|
157
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* roadmap-cli.js — `pmos roadmap`: the ranked Roadmap written for one audience (bet A88, initiative roadmap-audiences; lib/roadmap-audiences.js).
|
|
3
|
+
*
|
|
4
|
+
* pmos roadmap for exec|team|customer [--out <file>] [--json] the live roadmap, in rank order, as markdown for that audience
|
|
5
|
+
* pmos roadmap share|unshare <initiative> mark an item for customers, or take the mark off
|
|
6
|
+
* every command: [--root <dir>] (default: the git root of this folder)
|
|
7
|
+
*
|
|
8
|
+
* The same versions show on Work (Roadmap for others). Derived on each run, so it follows the plan. Nothing is sent: it prints, or writes
|
|
9
|
+
* the one local file --out names. Exit codes: 0 done, 1 refused, 2 usage. */
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const RA = require('./roadmap-audiences.js');
|
|
13
|
+
|
|
14
|
+
const COMMANDS = { roadmap: ['for', 'share', 'unshare'] };
|
|
15
|
+
const USAGE = [
|
|
16
|
+
'usage: pmos roadmap for exec|team|customer [--out <file>] [--json] the roadmap written for leadership, the team or customers',
|
|
17
|
+
' pmos roadmap share|unshare <initiative> mark an item for customers, or take the mark off',
|
|
18
|
+
'exec: outcome and check date · team: stage, owners, blocked tasks · customer: only the items marked, no names. Nothing is sent.',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
function gitRoot(cwd = process.cwd()) {
|
|
22
|
+
for (let d = path.resolve(cwd); ; d = path.dirname(d)) {
|
|
23
|
+
if (fs.existsSync(path.join(d, '.git'))) return d;
|
|
24
|
+
if (path.dirname(d) === d) return cwd;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function parse(args) {
|
|
28
|
+
const pos = [], flags = {};
|
|
29
|
+
for (let i = 0; i < args.length; i++) {
|
|
30
|
+
const a = args[i];
|
|
31
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
32
|
+
const k = a.slice(2);
|
|
33
|
+
if (k === 'json') flags.json = true;
|
|
34
|
+
else flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
35
|
+
}
|
|
36
|
+
return { pos, flags };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function run(argv, { say = console.log, now = Date.now(), cwd = process.cwd(), rows = null } = {}) {
|
|
40
|
+
const rest = argv[0] === 'roadmap' ? argv.slice(1) : argv.slice();
|
|
41
|
+
const sub = rest[0];
|
|
42
|
+
if (!sub || sub === 'help' || rest.includes('--help') || !COMMANDS.roadmap.includes(sub)) { USAGE.forEach((l) => say(l)); return 2; }
|
|
43
|
+
const { pos, flags } = parse(rest.slice(1));
|
|
44
|
+
const root = flags.root ? path.resolve(cwd, flags.root) : gitRoot(cwd);
|
|
45
|
+
const dir = RA.recordsDirOf(root);
|
|
46
|
+
if (sub === 'share' || sub === 'unshare') {
|
|
47
|
+
const r = RA.share(dir, pos[0], sub === 'share', { by: 'cli', now });
|
|
48
|
+
if (!r.ok) { say(`✗ ${r.error}`); return 1; }
|
|
49
|
+
say(sub === 'share' ? `✓ ${r.line.id} is marked for customers (undo: pmos roadmap unshare ${r.line.id})` : `✓ ${r.line.id} is no longer marked for customers`);
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
const who = pos[0];
|
|
53
|
+
if (!RA.AUDIENCES.includes(who)) { say(`✗ the audience is one of ${RA.AUDIENCES.join(', ')}`); return 2; }
|
|
54
|
+
const list = RA.items({ root, rows, now, dir });
|
|
55
|
+
const md = RA.text(list, who, { product: path.basename(root) });
|
|
56
|
+
console.error(`${RA.TAG} for ${who} · ${RA.lines(list, who).length} items`);
|
|
57
|
+
if (flags.out) {
|
|
58
|
+
const f = path.resolve(cwd, flags.out);
|
|
59
|
+
fs.writeFileSync(f, md);
|
|
60
|
+
say(flags.json ? JSON.stringify({ ok: true, audience: who, file: f }) : `✓ wrote the ${who} roadmap to ${f}`);
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
if (flags.json) { say(JSON.stringify({ ok: true, audience: who, markdown: md, lines: RA.lines(list, who) })); return 0; }
|
|
64
|
+
say(md.trimEnd());
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -154,10 +154,12 @@ const MODULES = Object.freeze([
|
|
|
154
154
|
'routes-strategy-card', // bet A458: a product's five-line strategy above its Board, and the gentle "doesn't fit" note on new work (records strategy-card.jsonl; page-press POST)
|
|
155
155
|
'routes-segments', // idea A327: a product's user groups and the roadmap items that serve each, kept or renamed on Work (records segments.jsonl; page-press POST)
|
|
156
156
|
'routes-principles', // bet A352: a product's principles drafted from its decisions, kept or dropped on the Board (records principles.jsonl; page-press POST)
|
|
157
|
+
'routes-app-versions', // idea A211: a product's app versions in use, the open bugs their users hit, one ✦ force proposal the PM decides (records app-versions.jsonl; page-press POST)
|
|
157
158
|
'routes-switches', // idea A263: who has which switch, per customer, on Work; turning one waits for the PM's own press (records switches.jsonl; page-press POST)
|
|
158
159
|
'routes-prefs', // bet A461: view preferences that follow the person to the phone and other browsers (runtime view-prefs.json; page-press POST)
|
|
159
160
|
'routes-skill-map', // bet A208: the team skill map on Work, for the person and their lead only (records skill-map.jsonl; page-press POST)
|
|
160
161
|
'routes-first-hour', // bet A55: the first hour for a new engineer on Work (records first-hour.jsonl; page-press POST)
|
|
162
|
+
'routes-roadmap-audiences', // bet A88: the roadmap for exec, team or customer on Work (records roadmap-share.jsonl; page-press POST)
|
|
161
163
|
'routes-stakeholders', // bet A371: an initiative's stakeholder map, decides / must agree / needs to know, in the Work popup (records stakeholders.jsonl; page-press POST)
|
|
162
164
|
'routes-meeting-stance', // bet A333: before the meeting, the two questions for a contested decision and where each person stands, in the Work popup (records meeting-stance.jsonl; page-press POST)
|
|
163
165
|
'routes-code-map', // idea A176: the product's code map on Work, redrawn when the default branch moves (records code-map.json; read-only)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-app-versions.js — a product's app versions over HTTP (idea A211, initiative app-versions). The store and its rules are
|
|
3
|
+
* lib/app-versions.js (app-versions.jsonl in the product's records folder, lib/records-dir.js); `pmos versions` writes the same file.
|
|
4
|
+
*
|
|
5
|
+
* GET /api/app-versions?ws=<id> → { ok, rows, proposal, undoable, seed } rows newest first; proposal: at most one ✦
|
|
6
|
+
* or null; seed: when no version is recorded, the release names the product's Jira
|
|
7
|
+
* readings hold (the block's way in, LINE.md Rule 12), else []
|
|
8
|
+
* POST /api/app-versions { ws, act, version?, users? } → the same | 400 act: force | leave | undo | users (the PM types a count on Work)
|
|
9
|
+
*
|
|
10
|
+
* WHO WRITES. Only the PM's press on the page (pm-guard requirePagePress: the page's Origin and launch nonce). `force` records the PM's
|
|
11
|
+
* decision; forcing the update itself is an outward change PMOS never makes. A GET writes nothing. */
|
|
12
|
+
const guard = require('./pm-guard.js');
|
|
13
|
+
const AV = require('./app-versions.js');
|
|
14
|
+
const { recordsDirFor } = require('./records-dir.js');
|
|
15
|
+
|
|
16
|
+
/** The workspace's root, for its stored Jira readings. */
|
|
17
|
+
function rootFor(ctx, ws) {
|
|
18
|
+
if (ctx && ctx.repoRoot) return ctx.repoRoot;
|
|
19
|
+
try { const w = ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; return w && w.root ? w.root : null; } catch { return null; }
|
|
20
|
+
}
|
|
21
|
+
function view(dir, root) {
|
|
22
|
+
const S = AV.read(dir), rows = AV.rows(S);
|
|
23
|
+
const seed = !rows.length && root ? AV.releases(root, S) : [];
|
|
24
|
+
return { ok: true, rows, proposal: AV.proposal(S, rows), undoable: !!S.undoable, seed };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function handle(req, res, url, ctx) {
|
|
28
|
+
if (url.pathname !== '/api/app-versions') return false;
|
|
29
|
+
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
30
|
+
if (req.method === 'GET') {
|
|
31
|
+
const ws = url.searchParams.get('ws') || null;
|
|
32
|
+
const v = view(recordsDirFor(ctx, ws), rootFor(ctx, ws));
|
|
33
|
+
console.info(`[app-versions] read versions=${v.rows.length} proposal=${v.proposal ? v.proposal.version : 'none'}${v.seed.length ? ' seed=' + v.seed.length : ''}`);
|
|
34
|
+
return send(200, v);
|
|
35
|
+
}
|
|
36
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
|
|
37
|
+
const rd = await ctx.readJson(req);
|
|
38
|
+
if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
39
|
+
const body = rd.body || {};
|
|
40
|
+
const g = guard.requirePagePress(req, body);
|
|
41
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
42
|
+
const dir = recordsDirFor(ctx, body.ws || null);
|
|
43
|
+
const act = String(body.act || '');
|
|
44
|
+
let r;
|
|
45
|
+
if (act === 'undo') r = AV.undo(dir);
|
|
46
|
+
else if (act === 'force' || act === 'leave') r = AV.decide(dir, String(body.version || ''), act);
|
|
47
|
+
else if (act === 'users') r = AV.setUsers(dir, { version: String(body.version || ''), users: body.users, source: 'typed on Work by the PM' });
|
|
48
|
+
else return send(400, { ok: false, error: 'act is force, leave, undo or users' });
|
|
49
|
+
if (!r.ok) return send(400, { ok: false, error: r.error });
|
|
50
|
+
console.info(`[app-versions] ${act} ${body.version || ''}`.trim());
|
|
51
|
+
return send(200, view(dir, rootFor(ctx, body.ws || null)));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = { handle, prefixes: ['/api/app-versions'] };
|