create-pmos 0.730.0 → 0.732.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 +45 -45
- package/payload/KIT-VERSION +1 -1
- package/payload/design-system/brand/icons.json +59 -0
- 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 +44 -0
- package/workspace/design-system/brand/icons.json +59 -0
- package/workspace/guide/agent-capabilities.md +1 -0
- package/workspace/guide/cli.md +10 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/initiatives-and-next-steps.md +23 -1
- package/workspace/guide/layout.md +3 -1
- package/workspace/guide/positioning.md +33 -0
- package/workspace/lib/board-premium.js +10 -0
- package/workspace/lib/customer-signals.js +207 -0
- package/workspace/lib/headless.js +1 -0
- package/workspace/lib/icon-check.js +280 -0
- package/workspace/lib/job-graph.js +1 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/positioning-draft.js +225 -0
- package/workspace/lib/principles-cli.js +109 -0
- package/workspace/lib/principles.js +165 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +5 -1
- package/workspace/lib/routes-principles.js +109 -0
- package/workspace/lib/routes-strategy-card.js +33 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/agenda-live.js +1 -1
- package/workspace/public/pm/bd-positioning.js +91 -0
- package/workspace/public/pm/bd-principles.js +64 -0
- package/workspace/public/pm/bd-span.js +1 -1
- package/workspace/public/pm/bd-sprint-ds.js +1 -1
- package/workspace/public/pm/bd-sprint.js +1 -1
- package/workspace/public/pm/bd-strategy.js +10 -3
- package/workspace/public/pm/bd-views.js +36 -3
- package/workspace/public/pm/bd-work.js +1 -1
- package/workspace/public/pm/cozy-board.css +14 -0
- package/workspace/public/pm/cozy-day-pick.js +1 -1
- package/workspace/public/pm/cozy-events-view.js +1 -1
- package/workspace/public/pm/cozy-popup.js +8 -22
- package/workspace/public/pm/cozy-rec-present.js +1 -1
- package/workspace/public/pm/cozy-viewer.js +4 -3
- package/workspace/public/pm/goal-chat.js +1 -1
- package/workspace/public/pm/home-chat.js +1 -1
- package/workspace/public/pm/home-rec-row.js +1 -1
- package/workspace/public/pm/home-today.js +3 -3
- package/workspace/public/pm/ini-agent.js +1 -1
- package/workspace/public/pm/ini-edit.js +2 -2
- package/workspace/public/pm/ini-groups.js +1 -1
- package/workspace/public/pm/ini-versions.js +1 -1
- package/workspace/public/pm/ini-view.js +2 -2
- package/workspace/public/pm/intent.js +2 -2
- package/workspace/public/pm/okr-list.js +2 -2
- package/workspace/public/pm/pinned-views.js +1 -1
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/premium-insights.js +3 -3
- package/workspace/public/pm/premium-mtg-present.js +2 -2
- package/workspace/public/pm/premium-mtg-replay.js +1 -1
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +1 -1
- package/workspace/public/pm/premium-vw-slides.js +3 -3
- package/workspace/public/pm/task-card.js +1 -1
- package/workspace/public/pm/wf-page.js +1 -1
- package/workspace/public/premium-board.html +2 -0
- package/workspace/public/premium-events.html +2 -2
- package/workspace/skills/principles-draft.skill +23 -0
- package/workspace/test-lists/icon-check.json +9 -0
- package/workspace/test-lists/positioning-draft.json +9 -0
- package/workspace/test-lists/principles.json +9 -0
- package/workspace/test-lists/roadmap-signal-count.json +9 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* positioning-draft.js — the product's positioning statement and key messages, drafted from its five-line strategy (idea A328,
|
|
3
|
+
* initiative positioning-draft; done test planning/done-tests/positioning-draft.md).
|
|
4
|
+
*
|
|
5
|
+
* draft(ctx, card, opts) → { state: 'ready', key, by, lines } | { state: 'pending', key } | { state: 'missing', missing: [field] }
|
|
6
|
+
* opts.again: the PM pressed draft again, so a new run starts even when a draft is kept for this strategy
|
|
7
|
+
* peek(ctx, card) → the kept draft for this strategy, or null (never starts a run)
|
|
8
|
+
* normalize(answer, card) → [line] | null the model's answer made honest
|
|
9
|
+
* template(card) → [line] the lines put together from the strategy word for word (no AI)
|
|
10
|
+
* keep(dir, line, card, now?) → { ok, line } | { ok: false, error } appends { at, ev: 'keep', … } to <dir>/positioning.jsonl
|
|
11
|
+
* drop(dir, id, now?) → { ok } | { ok: false, error } appends { at, ev: 'drop', id }
|
|
12
|
+
* read(dir, card?) → [kept line] folded; a line whose cited strategy line changed since is `stale`
|
|
13
|
+
* count(dirs) → how many of the folders hold one or more kept lines
|
|
14
|
+
*
|
|
15
|
+
* A LINE is { id, kind: 'positioning' | 'message', text, cites: [field], quotes: { field: text } }. `cites` names the strategy lines
|
|
16
|
+
* (lib/strategy-card.js FIELDS) it comes from; `quotes` is the text of each cited line taken from the saved card, never from the model.
|
|
17
|
+
*
|
|
18
|
+
* THE RUN. One short PMOS session of the existing read-only `ask` kind (lib/headless.js, origin briefing-ask:positioning-draft:<key>): it
|
|
19
|
+
* reads only the five lines, uses no tool, writes nothing and sends nothing. Its answer is kept in <runtime>/strategy/positioning-drafts.json
|
|
20
|
+
* by the key of the five lines, so the same strategy is drafted once. When no session can start or the answer cannot be read, the
|
|
21
|
+
* template draft stands in and says so (by: 'template'): the PM always gets a draft, and never one made up.
|
|
22
|
+
*
|
|
23
|
+
* WHERE. `dir` is the product's records folder (lib/records-dir.js): planning/records in the PMOS repo, pmos/state/records in a kit
|
|
24
|
+
* product. positioning.jsonl is append-only; nothing rewrites it. */
|
|
25
|
+
const fs = require('fs');
|
|
26
|
+
const path = require('path');
|
|
27
|
+
const crypto = require('crypto');
|
|
28
|
+
const SC = require('./strategy-card.js');
|
|
29
|
+
|
|
30
|
+
const FILE = 'positioning.jsonl';
|
|
31
|
+
const KINDS = ['positioning', 'message'];
|
|
32
|
+
const MAX_LEN = 200;
|
|
33
|
+
const MAX_MESSAGES = 5;
|
|
34
|
+
const MODEL = 'claude-sonnet-5-5';
|
|
35
|
+
const LEAN = Object.freeze([{ flag: '--strict-mcp-config' }, { flag: '--disable-slash-commands' }, { flag: '--setting-sources', value: 'user' }, { flag: '--tools', value: 'Read' }]);
|
|
36
|
+
const TIMEOUT_MS = 180000;
|
|
37
|
+
const say = (s) => { try { console.log('[positioning-draft] ' + s); } catch { /* no console */ } };
|
|
38
|
+
const clip = (v, n = MAX_LEN) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
39
|
+
const lower1 = (s) => (s && !/^[A-Z]{2}/.test(s) ? s[0].toLowerCase() + s.slice(1) : s);
|
|
40
|
+
const noDot = (s) => String(s || '').replace(/[.\s]+$/, '');
|
|
41
|
+
|
|
42
|
+
/** The strategy lines a draft needs that are not written yet. */
|
|
43
|
+
const missingOf = (card) => SC.FIELDS.filter((k) => !String((card && card[k]) || '').trim());
|
|
44
|
+
const keyOf = (card) => crypto.createHash('sha1').update(SC.FIELDS.map((k) => SC.clean({ [k]: card && card[k] })[k] || '').join('\n')).digest('hex').slice(0, 16);
|
|
45
|
+
const idOf = (kind, text) => crypto.createHash('sha1').update(kind + '\n' + text).digest('hex').slice(0, 10);
|
|
46
|
+
|
|
47
|
+
/** One line made honest: a known kind, one line of text, cites that name written strategy lines, the card's own quotes. */
|
|
48
|
+
function lineOf(raw, card) {
|
|
49
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
50
|
+
const kind = KINDS.includes(raw.kind) ? raw.kind : 'message';
|
|
51
|
+
const text = clip(raw.text);
|
|
52
|
+
if (!text) return null;
|
|
53
|
+
const cites = [...new Set((Array.isArray(raw.cites) ? raw.cites : [raw.cites]).map((c) => String(c || '').trim().toLowerCase()))]
|
|
54
|
+
.filter((c) => SC.FIELDS.includes(c) && String((card && card[c]) || '').trim());
|
|
55
|
+
if (!cites.length) return null;
|
|
56
|
+
const quotes = Object.fromEntries(cites.map((c) => [c, String(card[c]).trim()]));
|
|
57
|
+
return { id: idOf(kind, text), kind, text, cites, quotes };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Order and limit: one positioning statement first, then at most MAX_MESSAGES messages; repeated text once. */
|
|
61
|
+
function shape(lines) {
|
|
62
|
+
const seen = new Set(), pos = [], msg = [];
|
|
63
|
+
for (const l of lines) { if (!l || seen.has(l.text.toLowerCase())) continue; seen.add(l.text.toLowerCase()); (l.kind === 'positioning' ? pos : msg).push(l); }
|
|
64
|
+
if (!pos.length && msg.length) { const first = msg.shift(); pos.push({ ...first, kind: 'positioning', id: idOf('positioning', first.text) }); }
|
|
65
|
+
return [...pos.slice(0, 1), ...msg.slice(0, MAX_MESSAGES)];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function promptOf(card) {
|
|
69
|
+
return [
|
|
70
|
+
'You draft positioning for a product manager. Do not use any tool. Answer with JSON only.',
|
|
71
|
+
"The product's strategy, one line each, with its key:",
|
|
72
|
+
SC.FIELDS.map((k) => `${k} (${SC.LABELS[k]}): ${clip(card[k], 200)}`).join('\n'),
|
|
73
|
+
'Write in plain, short English, in the words of the strategy. Never invent customers, numbers, prices, dates, competitors or features that the strategy does not name.',
|
|
74
|
+
'1. One positioning statement of at most 35 words: who it is for, the problem, what the product does about it, and why it wins.',
|
|
75
|
+
"2. Three to five key messages, each one sentence of at most 20 words, that a team can say outside. None may promise what \"wont\" rules out.",
|
|
76
|
+
'Every line lists in "cites" the keys of the strategy lines it comes from (one or more of: for, problem, bet, win, wont).',
|
|
77
|
+
'Answer: {"lines":[{"kind":"positioning","text":"…","cites":["for","problem","bet"]},{"kind":"message","text":"…","cites":["win"]}]}',
|
|
78
|
+
].join('\n\n');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The model's answer → [line] | null (unreadable, or no line cites a written strategy line). */
|
|
82
|
+
function normalize(text, card) {
|
|
83
|
+
const t = String(text || ''), at = t.indexOf('{'), end = t.lastIndexOf('}');
|
|
84
|
+
if (at < 0 || end < at) return null;
|
|
85
|
+
let o; try { o = JSON.parse(t.slice(at, end + 1)); } catch { return null; }
|
|
86
|
+
if (!o || !Array.isArray(o.lines)) return null;
|
|
87
|
+
const lines = shape(o.lines.slice(0, 20).map((l) => lineOf(l, card)));
|
|
88
|
+
return lines.length ? lines : null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The lines put together from the strategy word for word: honest when no session can run. */
|
|
92
|
+
function template(card) {
|
|
93
|
+
const c = Object.fromEntries(SC.FIELDS.map((k) => [k, noDot(String(card[k] || '').trim())]));
|
|
94
|
+
return shape([
|
|
95
|
+
lineOf({ kind: 'positioning', text: `For ${lower1(c.for)}, who face this: ${lower1(c.problem)}. Our answer: ${lower1(c.bet)}. Why us: ${lower1(c.win)}.`, cites: ['for', 'problem', 'bet', 'win'] }, card),
|
|
96
|
+
lineOf({ kind: 'message', text: c.bet + '.', cites: ['bet'] }, card),
|
|
97
|
+
lineOf({ kind: 'message', text: `Made for ${lower1(c.for)}.`, cites: ['for'] }, card),
|
|
98
|
+
lineOf({ kind: 'message', text: c.win + '.', cites: ['win'] }, card),
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* ── drafts: one run per strategy, kept in the runtime folder ─────────────────────────────────────────────────── */
|
|
103
|
+
const draftsFile = (ctx) => path.join((ctx && ctx.runtimeDir) || require('os').tmpdir(), 'strategy', 'positioning-drafts.json');
|
|
104
|
+
function readDrafts(ctx) { try { const o = JSON.parse(fs.readFileSync(draftsFile(ctx), 'utf8')); return o && typeof o === 'object' ? o : {}; } catch { return {}; } }
|
|
105
|
+
function keepDraft(ctx, key, value) {
|
|
106
|
+
const all = readDrafts(ctx); all[key] = { at: new Date().toISOString(), ...value };
|
|
107
|
+
const keys = Object.keys(all).sort((a, b) => String(all[b].at).localeCompare(String(all[a].at)));
|
|
108
|
+
for (const k of keys.slice(20)) delete all[k]; // the newest 20 strategies' drafts
|
|
109
|
+
fs.mkdirSync(path.dirname(draftsFile(ctx)), { recursive: true });
|
|
110
|
+
fs.writeFileSync(draftsFile(ctx), JSON.stringify(all));
|
|
111
|
+
}
|
|
112
|
+
const running = new Map(); // key → started at (ms)
|
|
113
|
+
|
|
114
|
+
function viaSession(ctx, prompt, key) {
|
|
115
|
+
if (ctx && typeof ctx.askClaude === 'function') return Promise.resolve(ctx.askClaude(prompt, { job: 'positioning-draft', key })).catch(() => null);
|
|
116
|
+
const headless = require('./headless.js');
|
|
117
|
+
const origin = 'briefing-ask:positioning-draft:' + key;
|
|
118
|
+
if (!ctx || typeof ctx.spawnSession !== 'function' || headless.kindFor({ agent: 'claude', origin }) !== 'ask') return Promise.resolve(null);
|
|
119
|
+
return new Promise((resolve) => {
|
|
120
|
+
let settled = false; const done = (v) => { if (settled) return; settled = true; clearTimeout(tm); resolve(v); };
|
|
121
|
+
const tm = setTimeout(() => done(null), TIMEOUT_MS);
|
|
122
|
+
let s = null;
|
|
123
|
+
try {
|
|
124
|
+
s = ctx.spawnSession({ name: 'positioning: draft from strategy', agent: 'claude', origin, initialInput: prompt,
|
|
125
|
+
modelAsk: { explicit: { model: MODEL, effort: 'low' } }, launchFlags: LEAN.map((f) => ({ ...f })),
|
|
126
|
+
onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null); } });
|
|
127
|
+
} catch { s = null; }
|
|
128
|
+
if (!s || s.state === 'exited') done(null);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function peek(ctx, card) {
|
|
133
|
+
if (missingOf(card).length) return null;
|
|
134
|
+
const key = keyOf(card), have = readDrafts(ctx)[key];
|
|
135
|
+
return have && Array.isArray(have.lines) ? { state: 'ready', key, by: have.by, lines: have.lines, at: have.at } : running.has(key) ? { state: 'pending', key } : null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function draft(ctx, card, opts = {}) {
|
|
139
|
+
const missing = missingOf(card);
|
|
140
|
+
if (missing.length) return { state: 'missing', missing };
|
|
141
|
+
const key = keyOf(card);
|
|
142
|
+
if (running.has(key)) return { state: 'pending', key };
|
|
143
|
+
const have = readDrafts(ctx)[key];
|
|
144
|
+
if (have && Array.isArray(have.lines) && !opts.again) return { state: 'ready', key, by: have.by, lines: have.lines, at: have.at };
|
|
145
|
+
running.set(key, Date.now());
|
|
146
|
+
const p = Promise.resolve(viaSession(ctx, promptOf(card), key)).then((text) => {
|
|
147
|
+
const lines = text == null ? null : normalize(text, card);
|
|
148
|
+
const value = lines ? { by: 'ai', lines } : { by: 'template', lines: template(card), why: text == null ? 'PMOS could not start a session' : 'the answer could not be read' };
|
|
149
|
+
try { keepDraft(ctx, key, value); } catch { /* the next press tries again */ }
|
|
150
|
+
say(`drafted ${value.lines.length} lines (${value.by})`);
|
|
151
|
+
}).catch(() => {}).finally(() => running.delete(key));
|
|
152
|
+
if (opts.wait) return p.then(() => draft(ctx, card));
|
|
153
|
+
return { state: 'pending', key };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* ── the kept lines ───────────────────────────────────────────────────────────────────────────────────────────── */
|
|
157
|
+
const fileOf = (dir) => (dir ? path.join(dir, FILE) : null);
|
|
158
|
+
function readLines(dir) {
|
|
159
|
+
let text = ''; try { text = fs.readFileSync(fileOf(dir), 'utf8'); } catch { return []; }
|
|
160
|
+
const out = [];
|
|
161
|
+
for (const l of text.split('\n')) { if (!l.trim()) continue; try { const o = JSON.parse(l); if (o && (o.ev === 'keep' || o.ev === 'drop') && o.id) out.push(o); } catch { /* a torn line is skipped */ } }
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function read(dir, card = null) {
|
|
166
|
+
const by = new Map();
|
|
167
|
+
for (const l of readLines(dir)) {
|
|
168
|
+
if (l.ev === 'drop') { by.delete(l.id); continue; }
|
|
169
|
+
by.delete(l.id); by.set(l.id, { id: l.id, kind: l.kind, text: l.text, cites: l.cites || [], quotes: l.quotes || {}, edited: !!l.edited, at: l.at });
|
|
170
|
+
}
|
|
171
|
+
const out = [...by.values()];
|
|
172
|
+
if (card) for (const l of out) l.stale = l.cites.some((c) => String(card[c] || '').trim() !== String(l.quotes[c] || '').trim());
|
|
173
|
+
return out.sort((a, b) => (a.kind === b.kind ? 0 : a.kind === 'positioning' ? -1 : 1));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function append(dir, obj) { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(fileOf(dir), JSON.stringify(obj) + '\n'); }
|
|
177
|
+
|
|
178
|
+
/** Keep one line, as drafted or edited. `line.from` is the drafted text it started as: a different text marks it edited. */
|
|
179
|
+
function keep(dir, line, card, now = Date.now()) {
|
|
180
|
+
if (!dir) return { ok: false, error: 'This product has no records folder.' };
|
|
181
|
+
const l = lineOf(line, card || {});
|
|
182
|
+
if (!l) return { ok: false, error: 'A kept line needs text and one or more written strategy lines it cites: ' + SC.FIELDS.join(', ') + '.' };
|
|
183
|
+
const edited = line.from != null ? clip(line.from) !== l.text : !!line.edited;
|
|
184
|
+
try { append(dir, { at: new Date(now).toISOString(), ev: 'keep', ...l, edited }); } catch (e) { return { ok: false, error: 'could not keep the line: ' + ((e && e.message) || e) }; }
|
|
185
|
+
say(`kept a ${l.kind} line${edited ? ' (edited)' : ''} citing ${l.cites.join(', ')}`);
|
|
186
|
+
return { ok: true, line: { ...l, edited } };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function drop(dir, id, now = Date.now()) {
|
|
190
|
+
if (!dir) return { ok: false, error: 'This product has no records folder.' };
|
|
191
|
+
if (!read(dir).some((l) => l.id === id)) return { ok: false, error: 'No kept line has that id.' };
|
|
192
|
+
try { append(dir, { at: new Date(now).toISOString(), ev: 'drop', id }); } catch (e) { return { ok: false, error: 'could not drop the line: ' + ((e && e.message) || e) }; }
|
|
193
|
+
say('dropped a kept line');
|
|
194
|
+
return { ok: true };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const count = (dirs) => (dirs || []).filter((d) => read(d).length > 0).length;
|
|
198
|
+
|
|
199
|
+
module.exports = { FILE, KINDS, MAX_LEN, MAX_MESSAGES, missingOf, keyOf, promptOf, normalize, template, draft, peek, keep, drop, read, readLines, count };
|
|
200
|
+
|
|
201
|
+
if (require.main === module) {
|
|
202
|
+
const args = process.argv.slice(2), cmd = args[0];
|
|
203
|
+
const flag = (k) => { const i = args.indexOf('--' + k); return i >= 0 ? args[i + 1] : undefined; };
|
|
204
|
+
const pos = args.slice(1).filter((a, i, A) => !a.startsWith('--') && !(i > 0 && A[i - 1].startsWith('--')));
|
|
205
|
+
const root = pos[0] || process.cwd();
|
|
206
|
+
let dir;
|
|
207
|
+
try { const { repoScript } = require('./repo-script.js'); dir = require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { dir = path.join(root, 'planning', 'records'); }
|
|
208
|
+
const card = SC.read(dir);
|
|
209
|
+
if (cmd === 'count') { console.log(String(count([dir]))); process.exit(0); }
|
|
210
|
+
if (cmd === 'show') {
|
|
211
|
+
const kept = read(dir, card);
|
|
212
|
+
if (!kept.length) console.log('No positioning line kept yet.');
|
|
213
|
+
for (const l of kept) console.log(`${l.kind === 'positioning' ? 'Positioning' : 'Message'}: ${l.text} (from ${l.cites.map((c) => SC.LABELS[c]).join(', ')}${l.stale ? '; the strategy changed since' : ''}) [${l.id}]`);
|
|
214
|
+
process.exit(0);
|
|
215
|
+
}
|
|
216
|
+
if (cmd === 'keep') {
|
|
217
|
+
const r = keep(dir, { kind: flag('kind') || 'message', text: flag('text'), cites: String(flag('cites') || '').split(',') }, card);
|
|
218
|
+
console.log(r.ok ? `kept: ${r.line.text}` : '✗ ' + r.error); process.exit(r.ok ? 0 : 1);
|
|
219
|
+
}
|
|
220
|
+
if (cmd === 'drop') { const r = drop(dir, flag('id')); console.log(r.ok ? 'dropped' : '✗ ' + r.error); process.exit(r.ok ? 0 : 1); }
|
|
221
|
+
console.error('usage: node workspace/lib/positioning-draft.js count|show|keep|drop [<product checkout>]\n'
|
|
222
|
+
+ ' keep --text "<line>" --cites bet,for [--kind positioning|message] keep a positioning line (it must cite written strategy lines)\n'
|
|
223
|
+
+ ' drop --id <id> drop a kept line (ids from show)');
|
|
224
|
+
process.exit(2);
|
|
225
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* principles-cli.js — `pmos principles`: a product's principles, drafted from its past decisions, each citing the decisions it came from, kept or
|
|
3
|
+
* dropped by the PM (bet A352, initiative product-principles-draft; the store is lib/principles.js).
|
|
4
|
+
*
|
|
5
|
+
* pmos principles list [--all] [--json] the kept principles, then the drafts that wait; --all adds the dropped ones
|
|
6
|
+
* pmos principles sources [--json] the decisions a draft may cite (DECISIONS.md and its ADRs, and the decision journal)
|
|
7
|
+
* pmos principles draft --text "<principle>" --why "<the pattern in the decisions>" --source <id> [--source <id> …]
|
|
8
|
+
* one draft; refused when a source is not a decision of this product (the drafting run's write)
|
|
9
|
+
* pmos principles keep|drop|undo <id> the PM's answer to a draft (the chat writes it for the PM; the Board shows it)
|
|
10
|
+
* pmos principles add --text "<principle>" [--why "<text>"] [--source <id> …] the PM's own principle, kept at once
|
|
11
|
+
* every command: [--root <dir>] (default: this repository)
|
|
12
|
+
*
|
|
13
|
+
* The principles live in principles.jsonl in the product's records folder, so what the chat writes shows on the Board.
|
|
14
|
+
* Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { execFileSync } = require('child_process');
|
|
17
|
+
const P = require('./principles.js');
|
|
18
|
+
|
|
19
|
+
const COMMANDS = { principles: ['list', 'sources', 'draft', 'keep', 'drop', 'undo', 'add'] };
|
|
20
|
+
const USAGE = [
|
|
21
|
+
'usage: pmos principles list|sources|draft|keep|drop|undo|add — the product\'s principles, drafted from its decisions, each citing them',
|
|
22
|
+
' pmos principles list [--all] [--json] the kept principles, then the drafts that wait for you',
|
|
23
|
+
' pmos principles sources [--json] the decisions a principle may cite',
|
|
24
|
+
' pmos principles draft --text "<principle>" --why "<the pattern>" --source <id> [--source <id> …] one draft, 1 to ' + P.MAX_SOURCES + ' sources',
|
|
25
|
+
' pmos principles keep|drop|undo <id> keep or drop a draft, or put it back to open',
|
|
26
|
+
' pmos principles add --text "<principle>" [--why "<text>"] [--source <id> …] your own principle, kept at once',
|
|
27
|
+
'Run it in the product\'s repository, or pass --root <dir>.',
|
|
28
|
+
];
|
|
29
|
+
const ALLOWED = { list: ['json', 'root', 'all'], sources: ['json', 'root'], draft: ['json', 'root', 'text', 'why', 'source'], keep: ['json', 'root'], drop: ['json', 'root'],
|
|
30
|
+
undo: ['json', 'root'], add: ['json', 'root', 'text', 'why', 'source'] };
|
|
31
|
+
const BOOL = new Set(['json', 'all']);
|
|
32
|
+
|
|
33
|
+
function parse(args) {
|
|
34
|
+
const pos = [], flags = {};
|
|
35
|
+
for (let i = 0; i < args.length; i++) {
|
|
36
|
+
const a = args[i];
|
|
37
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
38
|
+
const k = a.slice(2);
|
|
39
|
+
if (BOOL.has(k)) { flags[k] = true; continue; }
|
|
40
|
+
const v = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
41
|
+
if (k === 'source') (flags.source = flags.source || []).push(...String(v).split(/[\s,]+/).filter(Boolean));
|
|
42
|
+
else flags[k] = v;
|
|
43
|
+
}
|
|
44
|
+
return { pos, flags };
|
|
45
|
+
}
|
|
46
|
+
function repoRoot(cwd) {
|
|
47
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
|
|
48
|
+
}
|
|
49
|
+
function recordsDirOf(root) {
|
|
50
|
+
try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
|
|
51
|
+
}
|
|
52
|
+
const pub = (x) => ({ id: x.id, state: x.state, own: !!x.own, text: x.text, why: x.why || null, sources: x.sources });
|
|
53
|
+
const lineOf = (x) => ` ${x.id} — ${x.text}${x.why ? `\n why: ${x.why}` : ''}${x.sources.length ? `\n from: ${x.sources.join(', ')}` : ''}`;
|
|
54
|
+
|
|
55
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now(), isTTY } = {}) {
|
|
56
|
+
const args = argv[0] === 'principles' ? argv.slice(1) : argv.slice();
|
|
57
|
+
const sub = args[0];
|
|
58
|
+
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
59
|
+
if (!COMMANDS.principles.includes(sub)) { say(`unknown principles command "${sub}". Use one of: ${COMMANDS.principles.join(', ')}`); return 2; }
|
|
60
|
+
const { pos, flags } = parse(args.slice(1));
|
|
61
|
+
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos principles ${sub}`); return 2; }
|
|
62
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
63
|
+
const dir = recordsDirOf(root);
|
|
64
|
+
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
65
|
+
const by = () => { try { return require('./actor.js').fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env }).by; } catch { return 'unknown'; } };
|
|
66
|
+
|
|
67
|
+
if (sub === 'list') {
|
|
68
|
+
if (pos.length) return fail('pmos principles list takes no argument', 2);
|
|
69
|
+
const all = P.read(dir);
|
|
70
|
+
const kept = all.filter((x) => x.state === 'kept'), open = all.filter((x) => x.state === 'open'), dropped = all.filter((x) => x.state === 'dropped');
|
|
71
|
+
if (flags.json) { say(JSON.stringify({ ok: true, principles: [...kept, ...open, ...(flags.all ? dropped : [])].map(pub) })); return 0; }
|
|
72
|
+
if (!all.length) { say('No principles yet. PMOS drafts them from the decisions once the product has ' + P.MIN_DECISIONS + ' or more (pmos principles sources).'); return 0; }
|
|
73
|
+
say(`${kept.length} kept · ${open.length} waiting for you · ${dropped.length} dropped`);
|
|
74
|
+
if (kept.length) say('\nKept:\n' + kept.map(lineOf).join('\n'));
|
|
75
|
+
if (open.length) say('\nDrafts:\n' + open.map(lineOf).join('\n') + '\n\nKeep or drop one: pmos principles keep|drop <id>');
|
|
76
|
+
if (flags.all && dropped.length) say('\nDropped:\n' + dropped.map(lineOf).join('\n'));
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (sub === 'sources') {
|
|
81
|
+
if (pos.length) return fail('pmos principles sources takes no argument', 2);
|
|
82
|
+
const D = P.decisionsOf(root, { now });
|
|
83
|
+
if (flags.json) { say(JSON.stringify({ ok: true, decisions: D })); return 0; }
|
|
84
|
+
if (!D.length) { say('No decisions in this repository yet (DECISIONS.md or pmos decisions).'); return 0; }
|
|
85
|
+
say(D.map((d) => ` ${d.id} — ${d.title} (${d.from})`).join('\n'));
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (sub === 'draft' || sub === 'add') {
|
|
90
|
+
if (pos.length) return fail(`usage: pmos principles ${sub} --text "<principle>" ${sub === 'draft' ? '--why "<the pattern>" --source <id>' : '[--why "<text>"]'}`, 2);
|
|
91
|
+
const input = { text: flags.text, why: flags.why, sources: flags.source || [] };
|
|
92
|
+
const D = P.decisionsOf(root, { now });
|
|
93
|
+
const r = sub === 'draft' ? P.draft(dir, input, D, { by: by(), now }) : P.add(dir, input, D, { by: by(), now });
|
|
94
|
+
if (!r.ok) return r.code === 'dropped' && !flags.json ? (say('dropped: ' + r.error), 1) : fail(r.error);
|
|
95
|
+
if (flags.json) { say(JSON.stringify({ ok: true, principle: pub(r.item) })); return 0; }
|
|
96
|
+
say(`✓ ${r.item.id}: ${sub === 'draft' ? 'drafted; it waits on the Board for a keep or a drop' : 'kept'}.`);
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// keep · drop · undo
|
|
101
|
+
if (pos.length !== 1) return fail(`usage: pmos principles ${sub} <id>`, 2);
|
|
102
|
+
const r = P.act(dir, sub, pos[0], { by: by(), now });
|
|
103
|
+
if (!r.ok) return fail(r.error);
|
|
104
|
+
if (flags.json) { say(JSON.stringify({ ok: true, principle: pub(r.item) })); return 0; }
|
|
105
|
+
say(`✓ ${r.item.id}: ${r.item.state === 'open' ? 'back to a draft' : r.item.state}. The Board shows it.`);
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* principles.js — a product's principles, drafted by PMOS from its past decisions, each citing the decisions it came from, kept or dropped by
|
|
3
|
+
* the PM (bet A352, initiative product-principles-draft). THE ONE WRITER and THE ONE FOLD of principles.jsonl. lib/principles-cli.js is the
|
|
4
|
+
* verb (`pmos principles`), lib/routes-principles.js the routes and the once-a-day drafting run, public/pm/bd-principles.js the Board's block.
|
|
5
|
+
*
|
|
6
|
+
* decisionsOf(root, { now }) → [{ id, title, from }] the decisions a draft may cite: the ones that still stand in DECISIONS.md and its
|
|
7
|
+
* ADRs (lib/decision-ledger.js; at the root, or under pmos/ in a kit product) and the entries of the decision
|
|
8
|
+
* journal (`pmos decisions`, lib/decision-journal.js) that no later decision replaced
|
|
9
|
+
* readLines(dir) · fold(lines) → [item] item: { id, text, why, sources, state: open | kept | dropped, own, at }
|
|
10
|
+
* read(dir) → fold(readLines(dir))
|
|
11
|
+
* draft(dir, input, decisions, { by, now }) → { ok, item } | { ok: false, error, code? } code 'dropped': the PM dropped this text before
|
|
12
|
+
* act(dir, kind, id, { by, now }) → { ok, item } | { ok: false, error } kind ∈ keep · drop · undo
|
|
13
|
+
* add(dir, input, decisions, { by, now }) → { ok, item } | { ok: false, error } the PM's own principle, kept at once
|
|
14
|
+
* idOf(text) → 'p-<8 hex>' the same text gives the same id, so a new run cannot bring back a dropped draft
|
|
15
|
+
* count(dir) → the number of kept principles (the health number)
|
|
16
|
+
*
|
|
17
|
+
* 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.
|
|
18
|
+
* Append-only: one line per event { at, by, kind, id, ... }; nothing rewrites it.
|
|
19
|
+
* draft { text, why, sources } PMOS's draft: one line of text, one line of why, 1 to 5 decision ids it came from
|
|
20
|
+
* add { text, why?, sources? } the PM's own principle (sources optional), kept at once
|
|
21
|
+
* keep · drop · undo the PM's press, or the chat for the PM; undo puts a kept or dropped principle back to open
|
|
22
|
+
* A draft is refused when a source is not a decision the product has, so every draft cites real decisions. Nothing here sends anything. */
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
const crypto = require('crypto');
|
|
26
|
+
|
|
27
|
+
const FILE = 'principles.jsonl';
|
|
28
|
+
const KINDS = ['draft', 'add', 'keep', 'drop', 'undo'];
|
|
29
|
+
const MAX_TEXT = 140;
|
|
30
|
+
const MAX_WHY = 240;
|
|
31
|
+
const MAX_SOURCES = 5;
|
|
32
|
+
const MAX_OPEN = 6;
|
|
33
|
+
const MIN_DECISIONS = 3; // fewer decisions than this: nothing to draw principles from, so no run starts
|
|
34
|
+
const say = (s) => { try { console.log('[principles] ' + s); } catch { /* no console */ } };
|
|
35
|
+
|
|
36
|
+
const one = (v, max) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > max ? s.slice(0, max - 1).trimEnd() + '…' : s; };
|
|
37
|
+
const idOf = (text) => 'p-' + crypto.createHash('sha256').update(one(text, MAX_TEXT).toLowerCase()).digest('hex').slice(0, 8);
|
|
38
|
+
const fileOf = (dir) => (dir ? path.join(dir, FILE) : null);
|
|
39
|
+
|
|
40
|
+
/** The decisions a draft may cite, for the product checked out at `root`. */
|
|
41
|
+
function decisionsOf(root, { now = Date.now() } = {}) {
|
|
42
|
+
const out = [];
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
const push = (id, title, from) => { if (id && !seen.has(id)) { seen.add(id); out.push({ id, title: one(title, 160), from }); } };
|
|
45
|
+
if (!root) return out;
|
|
46
|
+
const DL = require('./decision-ledger.js');
|
|
47
|
+
for (const [r, rel] of [[root, 'DECISIONS.md'], [path.join(root, 'pmos'), 'pmos/DECISIONS.md']]) {
|
|
48
|
+
let L = null;
|
|
49
|
+
try { L = DL.load(r); } catch { L = null; }
|
|
50
|
+
if (!L) continue;
|
|
51
|
+
for (const d of L.decisions.values()) if (d.status !== 'reverted' && (d.status !== 'superseded' || d.partial)) push(d.id, d.title, rel);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const J = require('./decision-journal.js');
|
|
56
|
+
const { rows } = J.read(root);
|
|
57
|
+
for (const e of J.fold(rows, { today: new Date(now).toISOString().slice(0, 10) })) if (e.state !== 'replaced') push(e.id, e.decided, 'journal');
|
|
58
|
+
} catch { /* no journal */ }
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function readLines(dir) {
|
|
63
|
+
const f = fileOf(dir);
|
|
64
|
+
if (!f) return [];
|
|
65
|
+
let text = '';
|
|
66
|
+
try { text = fs.readFileSync(f, 'utf8'); } catch { return []; }
|
|
67
|
+
const out = [];
|
|
68
|
+
for (const l of text.split('\n')) {
|
|
69
|
+
if (!l.trim()) continue;
|
|
70
|
+
try { const o = JSON.parse(l); if (o && KINDS.includes(o.kind) && typeof o.id === 'string') out.push(o); } catch { /* a torn line is skipped */ }
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** One item per principle, in the order first filed. The last line for an id wins. */
|
|
76
|
+
function fold(lines) {
|
|
77
|
+
const by = new Map();
|
|
78
|
+
for (const l of lines || []) {
|
|
79
|
+
const cur = by.get(l.id);
|
|
80
|
+
if (l.kind === 'draft' || l.kind === 'add') {
|
|
81
|
+
const own = l.kind === 'add';
|
|
82
|
+
const base = cur || { id: l.id, state: own ? 'kept' : 'open', own, at: l.at || null };
|
|
83
|
+
// A draft filed again keeps the PM's answer; the newer wording and sources replace the old ones.
|
|
84
|
+
by.set(l.id, Object.assign(base, { text: one(l.text, MAX_TEXT), why: one(l.why, MAX_WHY), sources: Array.isArray(l.sources) ? l.sources.map(String) : [] }, own ? { state: 'kept', own: true } : {}));
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (!cur) continue;
|
|
88
|
+
cur.state = l.kind === 'keep' ? 'kept' : l.kind === 'drop' ? 'dropped' : 'open';
|
|
89
|
+
cur.at = l.at || cur.at;
|
|
90
|
+
}
|
|
91
|
+
return [...by.values()];
|
|
92
|
+
}
|
|
93
|
+
const read = (dir) => fold(readLines(dir));
|
|
94
|
+
|
|
95
|
+
function append(dir, line) {
|
|
96
|
+
const f = fileOf(dir);
|
|
97
|
+
if (!f) return { ok: false, error: 'This product has no records folder.' };
|
|
98
|
+
try { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(f, JSON.stringify(line) + '\n'); } catch (e) { return { ok: false, error: 'could not save: ' + ((e && e.message) || e) }; }
|
|
99
|
+
return { ok: true };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Check text, why and sources against the product's decisions. needSources: a draft must cite 1 to 5; the PM's own may cite none. */
|
|
103
|
+
function clean(input, decisions, { needSources }) {
|
|
104
|
+
const i = input && typeof input === 'object' ? input : {};
|
|
105
|
+
const text = one(i.text, MAX_TEXT);
|
|
106
|
+
if (!text) return { error: 'Say the principle in one line (--text).' };
|
|
107
|
+
const why = one(i.why, MAX_WHY);
|
|
108
|
+
if (needSources && !why) return { error: 'Say in one line which pattern in the decisions it comes from (--why).' };
|
|
109
|
+
const raw = Array.isArray(i.sources) ? i.sources : i.sources ? String(i.sources).split(/[\s,]+/) : [];
|
|
110
|
+
const sources = [...new Set(raw.map((s) => String(s).trim()).filter(Boolean))];
|
|
111
|
+
if (needSources && !sources.length) return { error: 'Cite the decisions it came from (--source <id>, 1 to ' + MAX_SOURCES + ').' };
|
|
112
|
+
if (sources.length > MAX_SOURCES) return { error: 'Cite at most ' + MAX_SOURCES + ' decisions.' };
|
|
113
|
+
const known = new Set((decisions || []).map((d) => d.id));
|
|
114
|
+
const unknown = sources.filter((s) => !known.has(s));
|
|
115
|
+
if (unknown.length) return { error: 'Not a decision of this product: ' + unknown.join(', ') + '. `pmos principles sources` lists the ones you may cite.' };
|
|
116
|
+
return { text, why, sources };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function draft(dir, input, decisions, { by = 'agent', now = Date.now() } = {}) {
|
|
120
|
+
const c = clean(input, decisions, { needSources: true });
|
|
121
|
+
if (c.error) return { ok: false, error: c.error };
|
|
122
|
+
const id = idOf(c.text);
|
|
123
|
+
const items = read(dir);
|
|
124
|
+
const cur = items.find((x) => x.id === id);
|
|
125
|
+
if (cur && cur.state === 'dropped') return { ok: false, code: 'dropped', error: 'The PM dropped this principle before; it is not filed again.' };
|
|
126
|
+
if (cur && cur.state === 'kept') return { ok: false, code: 'kept', error: 'This principle is already kept.' };
|
|
127
|
+
if (!cur && items.filter((x) => x.state === 'open').length >= MAX_OPEN) return { ok: false, error: MAX_OPEN + ' drafts already wait for the PM. File no more.' };
|
|
128
|
+
const r = append(dir, { at: new Date(now).toISOString(), by, kind: 'draft', id, text: c.text, why: c.why, sources: c.sources });
|
|
129
|
+
if (!r.ok) return r;
|
|
130
|
+
say('drafted ' + id + ' from ' + c.sources.join(', '));
|
|
131
|
+
return { ok: true, item: read(dir).find((x) => x.id === id) };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function add(dir, input, decisions, { by = 'pm', now = Date.now() } = {}) {
|
|
135
|
+
const c = clean(input, decisions, { needSources: false });
|
|
136
|
+
if (c.error) return { ok: false, error: c.error };
|
|
137
|
+
const id = idOf(c.text);
|
|
138
|
+
const r = append(dir, { at: new Date(now).toISOString(), by, kind: 'add', id, text: c.text, why: c.why, sources: c.sources });
|
|
139
|
+
if (!r.ok) return r;
|
|
140
|
+
say('added ' + id);
|
|
141
|
+
return { ok: true, item: read(dir).find((x) => x.id === id) };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function act(dir, kind, id, { by = 'pm', now = Date.now() } = {}) {
|
|
145
|
+
if (!['keep', 'drop', 'undo'].includes(kind)) return { ok: false, error: 'keep, drop or undo' };
|
|
146
|
+
const cur = read(dir).find((x) => x.id === String(id || ''));
|
|
147
|
+
if (!cur) return { ok: false, error: 'No principle ' + JSON.stringify(String(id || '')) + '. `pmos principles list` shows the ids.' };
|
|
148
|
+
const r = append(dir, { at: new Date(now).toISOString(), by, kind, id: cur.id });
|
|
149
|
+
if (!r.ok) return r;
|
|
150
|
+
say(kind + ' ' + cur.id);
|
|
151
|
+
return { ok: true, item: read(dir).find((x) => x.id === cur.id) };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const count = (dir) => read(dir).filter((x) => x.state === 'kept').length;
|
|
155
|
+
|
|
156
|
+
module.exports = { FILE, KINDS, MAX_TEXT, MAX_WHY, MAX_SOURCES, MAX_OPEN, MIN_DECISIONS, idOf, decisionsOf, readLines, fold, read, draft, add, act, count };
|
|
157
|
+
|
|
158
|
+
if (require.main === module) {
|
|
159
|
+
const cmd = process.argv[2];
|
|
160
|
+
if (cmd !== 'count') { console.error('usage: node workspace/lib/principles.js count [<product checkout>] (principles kept)'); process.exit(2); }
|
|
161
|
+
const root = process.argv[3] || process.cwd();
|
|
162
|
+
let dir = null;
|
|
163
|
+
try { const { repoScript } = require('./repo-script.js'); dir = require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { dir = path.join(root, 'planning', 'records'); }
|
|
164
|
+
console.log(String(count(dir)));
|
|
165
|
+
}
|
|
@@ -140,6 +140,7 @@ const MODULES = Object.freeze([
|
|
|
140
140
|
'routes-jira-epics', // work-subtasks: the epic check's fix, direct on tickets assigned to the PM, the day's draft for the rest (tracker/jira/epics.jsonl; page-press POST)
|
|
141
141
|
'routes-use-log', // bet A466: the local use log, page opens and controls pressed, on this computer only (runtime use-log.jsonl; page-press POST)
|
|
142
142
|
'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)
|
|
143
|
+
'routes-principles', // bet A352: a product's principles drafted from its decisions, kept or dropped on the Board (records principles.jsonl; page-press POST)
|
|
143
144
|
'routes-prefs', // bet A461: view preferences that follow the person to the phone and other browsers (runtime view-prefs.json; page-press POST)
|
|
144
145
|
]);
|
|
145
146
|
const PM_DIR = path.join(__dirname, '..', 'public', 'pm');
|
|
@@ -113,6 +113,7 @@ const ledgers = require('./plan-ledgers.js');
|
|
|
113
113
|
const intake = require(repoScript('intake.js'));
|
|
114
114
|
const WK = require('./work-kind.js');
|
|
115
115
|
const ORIGIN = require('./initiative-origin.js'); // who raised each initiative (who-raised-each-idea)
|
|
116
|
+
const CS = require('./customer-signals.js'); // the customer signals behind each roadmap item (roadmap-signal-count, A157)
|
|
116
117
|
const OS = require('./one-stage.js');
|
|
117
118
|
|
|
118
119
|
const LEDGER = 'boards.jsonl';
|
|
@@ -406,6 +407,7 @@ function baseRowsRead(w) {
|
|
|
406
407
|
let lcFile = null;
|
|
407
408
|
try { lcFile = path.join(ledgers.runsDir(w.root), 'lifecycle.jsonl'); const st = fs.statSync(lcFile); sig.lifecycle = st.size + ':' + st.mtimeMs; } catch { sig.lifecycle = 'none'; }
|
|
408
409
|
try { const st = fs.statSync(path.join(ledgers.runsDir(w.root), 'outcome_checks.jsonl')); sig.outcomes = st.size + ':' + st.mtimeMs; } catch { sig.outcomes = 'none'; }
|
|
410
|
+
sig.signals = CS.sigOf(w.root); // roadmap-signal-count: a customer signal added in chat shows on the next read
|
|
409
411
|
try { const jd = jiraTickets.jiraDir(w.root); sig.jira = fs.readdirSync(jd).filter((n) => n.endsWith('.md')).map((n) => { const st = fs.statSync(path.join(jd, n)); return n + ':' + st.mtimeMs; }).join(','); } catch { sig.jira = 'none'; }
|
|
410
412
|
const cacheKey = JSON.stringify(sig) + day;
|
|
411
413
|
const hit = rowCache.get(w.root);
|
|
@@ -423,6 +425,7 @@ function baseRowsRead(w) {
|
|
|
423
425
|
const rows = [];
|
|
424
426
|
const seen = new Set();
|
|
425
427
|
const created = ORIGIN.createdBy(w.root); // the Roadmap's created lines, read once: who added each record
|
|
428
|
+
let signalsBy = new Map(); try { signalsBy = CS.byInitiative(w.root); } catch { signalsBy = new Map(); } // the customer signals behind each item (A157)
|
|
426
429
|
for (const id of F.placed.ranked) {
|
|
427
430
|
if (seen.has(id)) continue;
|
|
428
431
|
seen.add(id);
|
|
@@ -442,6 +445,7 @@ function baseRowsRead(w) {
|
|
|
442
445
|
id, title: r.title, lane: r.lane || null, kind: WK.kindOf(fm.kind), // batch 29 item 11: no line reads as Product management
|
|
443
446
|
owner: fm.owner ? String(fm.owner) : null,
|
|
444
447
|
origin: ORIGIN.originOf({ raised_by: fm.raised_by, created: created.get(id) }),
|
|
448
|
+
signals: CS.rowSignals(signalsBy.get(id), ORIGIN.originOf({ raised_by: fm.raised_by })), // { n, items } | null: zero is silence
|
|
445
449
|
anchor: r.anchor || null, rank: Number.isInteger(r.rank) ? r.rank : null, dormant: !!r.dormant,
|
|
446
450
|
status: statusOf(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
|
|
447
451
|
statusIn: statusIn(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
|
|
@@ -612,7 +616,7 @@ function boardRow(board, base, folded, lib) {
|
|
|
612
616
|
const wf = B.workflowOf(board, base.id, folded);
|
|
613
617
|
const cat = B.catOf({ workflow: wf }, s.stage);
|
|
614
618
|
const row = {
|
|
615
|
-
id: base.id, title: base.title, lane: base.lane, kind: WK.kindOf(base.kind), stage: s.stage, cat, owner: base.owner, origin: base.origin || null, anchor: base.anchor,
|
|
619
|
+
id: base.id, title: base.title, lane: base.lane, kind: WK.kindOf(base.kind), stage: s.stage, cat, owner: base.owner, origin: base.origin || null, signals: base.signals || null, anchor: base.anchor,
|
|
616
620
|
status: base.status, start: ts ? minDay(base.start, ts.start) : base.start, end: ts ? maxDay(base.end, ts.end) : base.end, progress: base.progress, warnings: [],
|
|
617
621
|
rank: base.rank, health: B.isActive(base) ? base.health : null, updated: base.updated, reading: base.reading, stageSource: s.source, lifecycle: base.lifecycle,
|
|
618
622
|
stopped: base.stopped || null, archived: archivedOf(folded, base.id), outcome: base.outcome || null,
|