create-pmos 0.557.0 → 0.559.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 +27 -81
- 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/briefing-premium-adddoc-test.js +8 -6
- package/workspace/changelog.json +26 -0
- package/workspace/fixtures/board-premium-facts.js +2 -12
- package/workspace/guide/initiatives-and-next-steps.md +18 -2
- package/workspace/guide/programs.md +2 -2
- package/workspace/lib/board-premium.js +5 -23
- package/workspace/lib/core-docs-needs.js +12 -16
- package/workspace/lib/core-docs.js +27 -214
- package/workspace/lib/coredoc-cli.js +6 -6
- package/workspace/lib/custom-docs.js +3 -1
- package/workspace/lib/initiative-cli.js +4 -4
- package/workspace/lib/initiative-premium.js +1 -1
- package/workspace/lib/initiative-writer.js +28 -4
- package/workspace/lib/job-graph.js +2 -2
- package/workspace/lib/refresh.js +2 -2
- package/workspace/lib/route-modules.js +0 -1
- package/workspace/lib/routes-board-premium.js +5 -11
- package/workspace/lib/routes-boards.js +5 -4
- package/workspace/lib/routes-core-docs.js +23 -113
- package/workspace/lib/routes-custom-docs.js +8 -6
- package/workspace/lib/routes-initiatives.js +12 -0
- package/workspace/lib/routes-intake.js +6 -2
- package/workspace/lib/work-kind.js +48 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-core-doc-issue-test.js +11 -18
- package/workspace/public/pm/bd-acts.js +5 -77
- package/workspace/public/pm/bd-asks.js +16 -10
- package/workspace/public/pm/bd-ini-panel.js +11 -1
- package/workspace/public/pm/bd-next.js +14 -4
- package/workspace/public/pm/bd-prog.js +4 -5
- package/workspace/public/pm/bd-views.js +7 -58
- package/workspace/public/pm/cozy-board.css +12 -24
- package/workspace/public/pm/cozy-viewer.js +11 -5
- package/workspace/public/pm/home-app.js +2 -3
- package/workspace/public/pm/home-ini.js +10 -1
- package/workspace/public/pm/ini-agent.js +40 -8
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/premium-board.js +9 -26
- package/workspace/public/pm/premium-shell.js +3 -33
- package/workspace/public/pm/prog-page.js +1 -1
- package/workspace/public/pm/work-kind.js +82 -0
- package/workspace/ready-dash-ui-test.js +1 -1
- package/workspace/server.js +3 -12
- package/workspace/test-files.json +1 -1
- package/workspace/test-lists/uncovered-board.json +1 -1
- package/workspace/lib/routes-board-docs.js +0 -46
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* core-docs.js — the core documents of
|
|
2
|
+
/* core-docs.js — the core documents of an initiative (initiative core-documents, PRD sections 1 to 4).
|
|
3
|
+
* PORTFOLIO AND BOARD DOCUMENTS ARE RETIRED (feedback batch 29 item 8, Wawan 2026-11-10): their 21 kinds are gone from SETS, and a
|
|
4
|
+
* write, a gather or a draft on a portfolio or board scope is refused (410). The documents already written stay readable: the ledger keeps
|
|
5
|
+
* their lines, fold() and storeOf() still read them, and their files under <state>/core-docs/portfolio and board-<id> are never touched.
|
|
3
6
|
* THE ONE WRITER and THE ONE FOLD of <state>/core-docs.jsonl and of the documents under <state>/core-docs/.
|
|
4
7
|
*
|
|
5
|
-
* LEVELS · LEVEL · SETS · CATS · BY · KINDS
|
|
8
|
+
* LEVELS · RETIRED_LEVELS · RETIRED · LEVEL · SETS · CATS · BY · KINDS
|
|
6
9
|
* entryOf(level, key) · levelOfScope(scope) · parseScope(scope) · scopeDir(scope) · draftable(entry)
|
|
7
10
|
* setFor(level, { build, wfTpl, has }) the entries of one level, after the build-only and research-only filters
|
|
8
11
|
* stateOf(entry, facts) → { st, when, due, flag, staleWhy, open, draft } PURE: `facts.now` is the clock
|
|
@@ -17,15 +20,14 @@
|
|
|
17
20
|
*
|
|
18
21
|
* THE SETS are the approved mockup's (mockup-c3-doc-levels 43-doc-levels.js): every title, `for`, reader, cadence, `by` and `isNew` is its copy.
|
|
19
22
|
* `kind` says where the document lives: doc (a core document of its own, in this store), derived (read from a source PMOS already keeps),
|
|
20
|
-
*
|
|
21
|
-
* documents a rolled-up document collects.
|
|
23
|
+
* report (a recurring report on a dashboard). `days` is the cadence of a doc in days.
|
|
22
24
|
*
|
|
23
25
|
* STATE. Nothing is guessed: an entry with no source and no document is `missing`, with no date. `when` is the day of the last change, `due` the
|
|
24
26
|
* next due day, both YYYY-MM-DD. `flag` is one short warning a source gives (a tripped kill condition, an agent's check), never invented. `open`
|
|
25
|
-
* is where a press goes: { path } (document sheet), {
|
|
27
|
+
* is where a press goes: { path } (document sheet), { tool } (initiative Overview tool), { reports: true }, or null.
|
|
26
28
|
*
|
|
27
29
|
* THE LEDGER. <state>/core-docs.jsonl, <state> = report-draft.js stateRel(root). Lines { v: 1, ev: draft|issue|drop, scope, key, slot, path, by, at }.
|
|
28
|
-
* `scope` is portfolio
|
|
30
|
+
* `scope` is initiative:<id> (portfolio and board:<id> on the retired lines); `by` is the actor of the call path (lib/actor.js), never an argument. The documents are
|
|
29
31
|
* <state>/core-docs/<scope with : as ->/<key>/<slot>.md with frontmatter type, title, timestamp, core_doc, scope, state (draft | issued).
|
|
30
32
|
* A draft is never sent anywhere. Only a PM press issues or drops one (lib/routes-core-docs.js, lib/driver-decide.js Keep).
|
|
31
33
|
*/
|
|
@@ -34,45 +36,21 @@ const path = require('path');
|
|
|
34
36
|
|
|
35
37
|
const LEDGER = 'core-docs.jsonl';
|
|
36
38
|
const DIR = 'core-docs';
|
|
37
|
-
const LEVELS = Object.freeze(['
|
|
39
|
+
const LEVELS = Object.freeze(['initiative']);
|
|
40
|
+
/** The levels whose documents are retired: their scopes still parse (old ledger lines), but nothing writes or derives them. */
|
|
41
|
+
const RETIRED_LEVELS = Object.freeze(['portfolio', 'board']);
|
|
42
|
+
const RETIRED = 'PMOS no longer drafts portfolio or board documents. The product page\'s story, Intent and goals cover them, and the ones already written stay readable.';
|
|
38
43
|
const CATS = Object.freeze(['Discover', 'Plan', 'Do', 'Learn']);
|
|
39
|
-
const KINDS = Object.freeze(['doc', 'derived', '
|
|
44
|
+
const KINDS = Object.freeze(['doc', 'derived', 'report']);
|
|
40
45
|
const EVENTS = Object.freeze(['draft', 'issue', 'drop']);
|
|
41
46
|
const BY = Object.freeze({ you: 'You write it', proposes: 'PMOS proposes', drafts: 'PMOS drafts it', files: 'PMOS files it', watches: 'PMOS watches it',
|
|
42
47
|
keeps: 'PMOS keeps it current', live: 'Live view', reviews: 'PMOS reviews, you accept' });
|
|
43
48
|
const LEVEL = Object.freeze({
|
|
44
|
-
portfolio: Object.freeze({ question: 'Are we betting on the right things?', reader: 'leadership', rhythm: 'quarterly, with a monthly pulse' }),
|
|
45
|
-
board: Object.freeze({ question: 'Is this area moving, and what comes next?', reader: 'the board owner, the team and the engineering lead', rhythm: 'every sprint or two weeks' }),
|
|
46
49
|
initiative: Object.freeze({ question: 'What are we building, why, and did it work?', reader: 'the PM, the builders and the reviewers', rhythm: 'at each stage' }),
|
|
47
50
|
});
|
|
48
51
|
|
|
49
52
|
const e = (level, o) => Object.freeze({ level, reader: null, cadence: null, build: false, cat: null, isNew: false, days: null, rollup: null, tool: null, store: false, ...o });
|
|
50
53
|
const SETS = Object.freeze({
|
|
51
|
-
portfolio: Object.freeze([
|
|
52
|
-
e('portfolio', { key: 'strategy', title: 'Product strategy', ic: 'target', for: 'Vision, where we play and what we will not do. Every board and key result traces to it.', reader: 'Leadership, every PM', cadence: 'Yearly, reviewed each quarter', by: 'proposes', kind: 'doc', days: 91, isNew: true }),
|
|
53
|
-
e('portfolio', { key: 'okrs', title: 'OKRs and health budgets', ic: 'flag', for: 'The key results initiatives anchor to, and the budgets maintenance work runs on.', reader: 'Leadership, PMs', cadence: 'Quarterly', by: 'proposes', kind: 'derived', store: true, days: 91 }),
|
|
54
|
-
e('portfolio', { key: 'roadmap', title: 'Portfolio roadmap', ic: 'cal', for: 'Bets by quarter (Now, Next, Later) and the key result each serves. A sendable copy of the Roadmap.', reader: 'Leadership, stakeholders', cadence: 'Monthly', by: 'drafts', kind: 'doc', days: 30 }),
|
|
55
|
-
e('portfolio', { key: 'invest', title: 'Investment mix', ic: 'cols', for: 'Where the effort goes: by board, by key result, and feature work against upkeep.', reader: 'Leadership', cadence: 'Quarterly', by: 'drafts', kind: 'doc', days: 91, isNew: true }),
|
|
56
|
-
e('portfolio', { key: 'scan', title: 'Horizon scan reports', ic: 'search', for: 'Benchmark, competitive, insight and productivity reports, each with proposals.', reader: 'PMs, leadership', cadence: 'Weekly scan', by: 'drafts', kind: 'derived' }),
|
|
57
|
-
e('portfolio', { key: 'status', title: 'Portfolio status report', ic: 'report', for: 'One page: progress on key results, what changed, what needs a decision.', reader: 'Leadership', cadence: 'Every two weeks', by: 'drafts', kind: 'report' }),
|
|
58
|
-
e('portfolio', { key: 'decisions', title: 'Decision log', ic: 'scale', for: 'Decisions that cross boards, and why they were made.', reader: 'Everyone', cadence: 'As decided', by: 'files', kind: 'derived', store: true }),
|
|
59
|
-
e('portfolio', { key: 'kill', title: 'Kill conditions', ic: 'x', for: 'The result that would make us stop a bet.', reader: 'Leadership', cadence: 'Quarterly', by: 'watches', kind: 'derived', store: true }),
|
|
60
|
-
e('portfolio', { key: 'prisks', title: 'Cross-board risks', ic: 'alert', for: 'The few risks that span boards, rolled up from the risks each initiative records.', reader: 'Leadership, board owners', cadence: 'Monthly', by: 'drafts', kind: 'doc', days: 30, rollup: 'risks', isNew: true }),
|
|
61
|
-
e('portfolio', { key: 'quarter', title: 'Quarterly review', ic: 'up', for: 'What landed, what moved the key results, and what we learned. Built from outcome reviews.', reader: 'Leadership', cadence: 'Quarterly', by: 'drafts', kind: 'doc', days: 91, rollup: 'outcome', isNew: true }),
|
|
62
|
-
e('portfolio', { key: 'context', title: 'Market and user context', ic: 'notes', for: 'Jobs to be done, the market map and the research behind them.', reader: 'PMs', cadence: 'When research lands', by: 'keeps', kind: 'derived', store: true }),
|
|
63
|
-
]),
|
|
64
|
-
board: Object.freeze([
|
|
65
|
-
e('board', { key: 'charter', title: 'Board charter', ic: 'flag', for: 'Why this board exists: purpose, owner, the key results it serves, scope in and out, how work flows.', reader: 'Owner, team, new joiners', cadence: 'When the board changes', by: 'drafts', kind: 'doc', isNew: true }),
|
|
66
|
-
e('board', { key: 'backlog', title: 'Roadmap and backlog', ic: 'todo', for: 'Initiatives by rank, stage and owner.', reader: 'Team, stakeholders', cadence: 'Live', by: 'live', kind: 'live' }),
|
|
67
|
-
e('board', { key: 'intake', title: 'Intake log', ic: 'inbox', for: 'Asks received, accepted or declined, and why.', reader: 'Owner, requesters', cadence: 'Live', by: 'live', kind: 'live' }),
|
|
68
|
-
e('board', { key: 'bstatus', title: 'Board status report', ic: 'report', for: 'Progress, slips, asks and what needs a decision, for the owner\'s manager.', reader: 'Stakeholders', cadence: 'Every two weeks', by: 'drafts', kind: 'report' }),
|
|
69
|
-
e('board', { key: 'capacity', title: 'Capacity plan', ic: 'user', for: 'Who works on the board, their points a week, and whether the plan fits.', reader: 'Owner, eng lead', cadence: 'Each sprint', by: 'drafts', kind: 'doc', days: 14, isNew: true }),
|
|
70
|
-
e('board', { key: 'metrics', title: 'Board metrics', ic: 'up', for: 'The few numbers this board moves, with one definition each.', reader: 'Team', cadence: 'Quarterly', by: 'keeps', kind: 'doc', days: 91 }),
|
|
71
|
-
e('board', { key: 'brisks', title: 'Board risks', ic: 'alert', for: 'Risks on this board\'s initiatives and the waits on other boards. Written on each initiative, collected here.', reader: 'Owner', cadence: 'Every two weeks', by: 'drafts', kind: 'doc', days: 14, rollup: 'risks', isNew: true }),
|
|
72
|
-
e('board', { key: 'sprint', title: 'Sprint review', ic: 'clock', for: 'What the sprint committed and finished, what slipped and why.', reader: 'Team, stakeholders', cadence: 'Each sprint', by: 'drafts', kind: 'doc', days: 14, build: true, isNew: true }),
|
|
73
|
-
e('board', { key: 'release', title: 'Release notes', ic: 'out', for: 'What each release holds, every line cited.', reader: 'Team, support, customers', cadence: 'Each release', by: 'drafts', kind: 'derived', build: true }),
|
|
74
|
-
e('board', { key: 'retro', title: 'Board retro', ic: 'undo', for: 'Patterns across this board\'s initiatives, from their learnings and outcome reviews.', reader: 'Team', cadence: 'Quarterly', by: 'drafts', kind: 'doc', days: 91, rollup: 'outcome', isNew: true }),
|
|
75
|
-
]),
|
|
76
54
|
initiative: Object.freeze([
|
|
77
55
|
e('initiative', { key: 'record', title: 'Initiative record', ic: 'init', cat: 'Discover', for: 'Identity, anchor, lane and stage, with links to everything else. The gate checks it.', by: 'drafts', kind: 'derived' }),
|
|
78
56
|
e('initiative', { key: 'problem', title: 'Problem statement', ic: 'notes', cat: 'Discover', for: 'The problem, who has it and the evidence.', by: 'drafts', kind: 'derived', tool: 'problem' }),
|
|
@@ -138,9 +116,6 @@ const draftable = (entry) => !!entry && entry.kind === 'doc' && entry.by !== 'yo
|
|
|
138
116
|
/** A derived entry with `store` (the OKRs, the decision log, kill conditions, market context) is read from its own source, and PMOS may propose
|
|
139
117
|
* it as a core document while that source is absent. */
|
|
140
118
|
const storable = (entry) => !!entry && (entry.kind === 'doc' || !!entry.store);
|
|
141
|
-
/** A derived entry that fills as the work goes: with no source yet it is "none", not missing (portfolio and board only). */
|
|
142
|
-
const FILLS = Object.freeze(['files', 'watches', 'keeps']);
|
|
143
|
-
|
|
144
119
|
/** D99: an initiative's document plan. Product feature (or no library workflow): null, and the fixed set with its categories applies.
|
|
145
120
|
* A library workflow: one entry per stage whose output is a document, under that stage; the initiative record (under the first stage)
|
|
146
121
|
* and the status update (under the first In progress stage) stay for every workflow. Entries of a skipped stage are left out unless
|
|
@@ -174,7 +149,6 @@ function WF() { return WF_MOD || (WF_MOD = require(require('./repo-script.js').r
|
|
|
174
149
|
* initiative already has that document (a build-only entry it has stays). */
|
|
175
150
|
function setFor(level, { build = true, wfTpl = null, has = () => false } = {}) {
|
|
176
151
|
const list = SETS[level] || [];
|
|
177
|
-
if (level === 'board') return list.filter((x) => !x.build || build);
|
|
178
152
|
if (level === 'initiative') {
|
|
179
153
|
return list.filter((x) => (wfTpl !== 'research' || RESEARCH_KEEP.includes(x.key)) && (build || !BUILD_ONLY_INI.includes(x.key) || has(x.key)));
|
|
180
154
|
}
|
|
@@ -182,8 +156,8 @@ function setFor(level, { build = true, wfTpl = null, has = () => false } = {}) {
|
|
|
182
156
|
}
|
|
183
157
|
|
|
184
158
|
// ── the state of one entry (pure) ────────────────────────────────────────────────────────────────────
|
|
185
|
-
/* facts: { now, scope, level, store: fold(), cat (
|
|
186
|
-
* sources: { [key]: { when, open, flag, draft, next, nextDue, issued } | null },
|
|
159
|
+
/* facts: { now, scope, level, store: fold(), cat (the current category), movedAt (ms|null),
|
|
160
|
+
* sources: { [key]: { when, open, flag, draft, next, nextDue, issued } | null }, flags: { [key]: text } } */
|
|
187
161
|
function catState(entry, facts) {
|
|
188
162
|
const order = facts.order || CATS;
|
|
189
163
|
const cur = order.indexOf(facts.cat);
|
|
@@ -210,13 +184,6 @@ function docState(entry, facts) {
|
|
|
210
184
|
if (entry.level === 'initiative' && STALE_ON_MOVE.includes(entry.key) && facts.movedAt != null && facts.movedAt > issuedAt) {
|
|
211
185
|
return { ...base, st: 'stale', staleWhy: 'Stale since the stage move' };
|
|
212
186
|
}
|
|
213
|
-
if (entry.rollup) {
|
|
214
|
-
const later = ((facts.rollups && facts.rollups[entry.rollup]) || []).filter((t) => t > issuedAt);
|
|
215
|
-
if (later.length) return { ...base, st: 'stale', staleWhy: entry.rollup === 'risks' ? 'Stale since an initiative issued its risks' : 'Stale since an initiative issued its outcome review' };
|
|
216
|
-
}
|
|
217
|
-
if (entry.key === 'charter' && facts.board && facts.board.changedAt != null && facts.board.changedAt > issuedAt) {
|
|
218
|
-
return { ...base, st: 'stale', staleWhy: 'Stale since the board settings changed' };
|
|
219
|
-
}
|
|
220
187
|
const due = dueOf();
|
|
221
188
|
if (due && localDay(facts.now) >= due) return { ...base, st: 'due', due };
|
|
222
189
|
return { ...base, st: 'ok', due };
|
|
@@ -225,7 +192,6 @@ function docState(entry, facts) {
|
|
|
225
192
|
function sourceState(entry, facts) {
|
|
226
193
|
const out = blank();
|
|
227
194
|
const src = (facts.sources && facts.sources[entry.key]) || null;
|
|
228
|
-
if (entry.kind === 'live') return { ...out, st: 'ok', open: { tab: entry.key === 'backlog' ? 'initiatives' : 'triage' } };
|
|
229
195
|
if (entry.kind === 'report') {
|
|
230
196
|
const open = { reports: true };
|
|
231
197
|
if (!src) return { ...out, st: absent(entry, facts), open: entry.level === 'initiative' && catState(entry, facts) === 'later' ? null : open };
|
|
@@ -240,7 +206,6 @@ function sourceState(entry, facts) {
|
|
|
240
206
|
}
|
|
241
207
|
// derived
|
|
242
208
|
if (!src && entry.store) return docState(entry, facts);
|
|
243
|
-
if (!src && entry.level !== 'initiative' && FILLS.includes(entry.by)) return { ...out, st: 'none' };
|
|
244
209
|
if (!src) return { ...out, st: absent(entry, facts), open: entry.tool && entry.level === 'initiative' && catState(entry, facts) !== 'later' ? { tool: entry.tool } : null };
|
|
245
210
|
const res = { ...out, st: src.st || 'ok', when: src.when || null, due: src.due || null, flag: src.flag || null, open: src.open || null };
|
|
246
211
|
if (entry.level === 'initiative' && STALE_ON_MOVE.includes(entry.key) && src.atMs != null && facts.movedAt != null && facts.movedAt > src.atMs) {
|
|
@@ -303,13 +268,14 @@ const refuse = (status, error) => ({ ok: false, status, error });
|
|
|
303
268
|
/** Check a scope and key for a write: a known scope form, a key of that level, a doc entry. */
|
|
304
269
|
function checkEntry(scope, key) {
|
|
305
270
|
const p = parseScope(scope);
|
|
306
|
-
if (!p) return refuse(400, 'scope must be
|
|
271
|
+
if (!p) return refuse(400, 'scope must be initiative:<id>');
|
|
272
|
+
if (RETIRED_LEVELS.includes(p.level)) return refuse(410, RETIRED);
|
|
307
273
|
const entry = entryOf(p.level, key);
|
|
308
274
|
if (!entry) return refuse(400, `key must be one of ${SETS[p.level].map((x) => x.key).join(', ')} for the ${p.level} level`);
|
|
309
275
|
if (!storable(entry)) return refuse(400, `${entry.title} is not a document PMOS keeps here: it is read from its own source`);
|
|
310
276
|
return { ok: true, entry, level: p.level, id: p.id };
|
|
311
277
|
}
|
|
312
|
-
const scopeLabel = (scope, label) => { const p = parseScope(scope); return !p ? String(scope) :
|
|
278
|
+
const scopeLabel = (scope, label) => { const p = parseScope(scope); return !p ? String(scope) : (label || p.id); };
|
|
313
279
|
const yamlStr = (s) => JSON.stringify(String(s));
|
|
314
280
|
function frontmatterOf(text) {
|
|
315
281
|
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(String(text || ''));
|
|
@@ -383,31 +349,6 @@ function drop(root, { scope, key, slot } = {}, actor, { now } = {}) {
|
|
|
383
349
|
// ── the sources (I/O) ────────────────────────────────────────────────────────────────────────────────
|
|
384
350
|
const statOf = (abs) => { try { return fs.statSync(abs); } catch { return null; } };
|
|
385
351
|
const fileDay = (abs) => { const s = statOf(abs); return s && s.isFile() ? localDay(s.mtimeMs) : null; };
|
|
386
|
-
/** The newest markdown file under one of `dirs` (relative), or null. */
|
|
387
|
-
function newestMd(root, dirs) {
|
|
388
|
-
let best = null;
|
|
389
|
-
const walk = (rel, depth) => {
|
|
390
|
-
let list = [];
|
|
391
|
-
try { list = fs.readdirSync(path.join(root, rel), { withFileTypes: true }); } catch { return; }
|
|
392
|
-
for (const d of list) {
|
|
393
|
-
const r = `${rel}/${d.name}`;
|
|
394
|
-
if (d.isDirectory() && depth < 3) walk(r, depth + 1);
|
|
395
|
-
else if (d.isFile() && /\.md$/.test(d.name) && d.name !== 'index.md' && d.name !== 'log.md') {
|
|
396
|
-
const s = statOf(path.join(root, r));
|
|
397
|
-
if (s && (!best || s.mtimeMs > best.ms)) best = { rel: r, ms: s.mtimeMs };
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
for (const d of dirs) walk(d, 0);
|
|
402
|
-
return best;
|
|
403
|
-
}
|
|
404
|
-
function readJsonl(file) {
|
|
405
|
-
let text = '';
|
|
406
|
-
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
407
|
-
const out = [];
|
|
408
|
-
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l)) out.push(l); } catch { /* torn */ } }
|
|
409
|
-
return out;
|
|
410
|
-
}
|
|
411
352
|
|
|
412
353
|
/** The recurring report on `source` (dashboard:<key>): its newest document, its last issue and its next draft. Null when none is set up. */
|
|
413
354
|
function reportSource(root, source, now, cache) {
|
|
@@ -440,17 +381,6 @@ function flagsOf(root, store, scope) {
|
|
|
440
381
|
return out;
|
|
441
382
|
}
|
|
442
383
|
|
|
443
|
-
/** The ms of each issue of an initiative document `key` (risks, outcome), optionally only for the initiatives in `ids`. */
|
|
444
|
-
function rollupOf(store, key, ids) {
|
|
445
|
-
const out = [];
|
|
446
|
-
for (const x of store.values()) {
|
|
447
|
-
if (x.key !== key || !x.scope.startsWith('initiative:')) continue;
|
|
448
|
-
if (ids && !ids.has(x.scope.slice('initiative:'.length))) continue;
|
|
449
|
-
for (const l of x.issues) out.push(msOf(l.at));
|
|
450
|
-
}
|
|
451
|
-
return out;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
384
|
function stateDirOf(ctx, w) { try { return ctx.stateDirFor ? ctx.stateDirFor(w) : null; } catch { return null; } }
|
|
455
385
|
function stageToolsOf(ctx, w) {
|
|
456
386
|
const dir = stateDirOf(ctx, w);
|
|
@@ -458,77 +388,6 @@ function stageToolsOf(ctx, w) {
|
|
|
458
388
|
const st = require('./stage-tools.js');
|
|
459
389
|
return st.readLedger(path.join(dir, st.LEDGER));
|
|
460
390
|
}
|
|
461
|
-
function releasesOf(ctx) {
|
|
462
|
-
if (!ctx.runtimeDir) return [];
|
|
463
|
-
try {
|
|
464
|
-
const { repoScript } = require('./repo-script.js');
|
|
465
|
-
return require(repoScript('releases.js')).foldReleases(fs.readFileSync(path.join(ctx.runtimeDir, 'releases', 'releases.jsonl'), 'utf8').split('\n').filter(Boolean));
|
|
466
|
-
} catch { return []; }
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function portfolioSources(ctx, w, store, now) {
|
|
470
|
-
const root = w.root;
|
|
471
|
-
const cache = {};
|
|
472
|
-
const src = {};
|
|
473
|
-
const okr = newestMd(root, ['planning/okrs']);
|
|
474
|
-
src.okrs = okr ? { when: localDay(okr.ms), open: { path: okr.rel } } : null;
|
|
475
|
-
const ctxDoc = newestMd(root, ['planning/radar', 'planning/research']);
|
|
476
|
-
src.context = ctxDoc ? { when: localDay(ctxDoc.ms), open: { path: ctxDoc.rel } } : null;
|
|
477
|
-
src.decisions = null;
|
|
478
|
-
for (const rel of ['DECISIONS.md', 'planning/records/decisions.jsonl', 'pmos/state/records/decisions.jsonl']) {
|
|
479
|
-
const d = fileDay(path.join(root, rel));
|
|
480
|
-
if (d) { src.decisions = { when: d, open: /\.md$/.test(rel) ? { path: rel } : null }; break; }
|
|
481
|
-
}
|
|
482
|
-
try { cache.reports = require('./report-needs.js').reportsOf(root).reports; } catch { cache.reports = []; }
|
|
483
|
-
const scans = cache.reports.filter((r) => /^scan-/.test(r.cadence)).sort((a, b) => (a.slot < b.slot ? 1 : -1));
|
|
484
|
-
src.scan = scans.length ? { when: scans[0].slot.slice(0, 10), open: { reports: true } } : null;
|
|
485
|
-
const tools = stageToolsOf(ctx, w);
|
|
486
|
-
let killAt = null; let tripped = 0;
|
|
487
|
-
for (const m of tools.values()) {
|
|
488
|
-
const k = m.get('kill');
|
|
489
|
-
if (!k) continue;
|
|
490
|
-
if (k.at && (!killAt || k.at > killAt)) killAt = k.at;
|
|
491
|
-
tripped += ((k.data && k.data.items) || []).filter((i) => i.status === 'tripped').length;
|
|
492
|
-
}
|
|
493
|
-
src.kill = killAt ? { when: localDay(msOf(killAt)), flag: tripped ? `${tripped} tripped` : null } : null;
|
|
494
|
-
src.status = reportSource(root, 'dashboard:portfolio', now, cache);
|
|
495
|
-
return { sources: src, rollups: { risks: rollupOf(store, 'risks', null), outcome: rollupOf(store, 'outcome', null) } };
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
/** The ids of the initiatives on a board, or null while the rows are still being read. */
|
|
499
|
-
function boardIds(ctx, w, fr, boardId) {
|
|
500
|
-
const boards = require('./routes-boards.js');
|
|
501
|
-
let got;
|
|
502
|
-
try { got = boards.baseRows(w); } catch { return null; }
|
|
503
|
-
if (!got || !got.ok) return null;
|
|
504
|
-
return new Set(got.rows.filter((r) => boards.boardIdOf(r, fr.boards, fr.folded, w) === boardId).map((r) => r.id));
|
|
505
|
-
}
|
|
506
|
-
function boardChangedAt(ctx, w, boardId) {
|
|
507
|
-
const dir = stateDirOf(ctx, w);
|
|
508
|
-
if (!dir) return null;
|
|
509
|
-
let at = null;
|
|
510
|
-
for (const l of readJsonl(path.join(dir, 'boards.jsonl'))) {
|
|
511
|
-
if (l.board !== boardId || !['board', 'workflow'].includes(l.kind)) continue;
|
|
512
|
-
const t = msOf(l.at);
|
|
513
|
-
if (Number.isFinite(t) && (at == null || t > at)) at = t;
|
|
514
|
-
}
|
|
515
|
-
return at;
|
|
516
|
-
}
|
|
517
|
-
function boardSources(ctx, w, board, ids, store, now) {
|
|
518
|
-
const src = {};
|
|
519
|
-
src.bstatus = reportSource(w.root, `dashboard:board:${board.id}`, now, {});
|
|
520
|
-
if (board.build) {
|
|
521
|
-
const mine = ids ? releasesOf(ctx).filter((r) => (r.initiative_ids || []).some((x) => ids.has(x))) : [];
|
|
522
|
-
const today = localDay(now);
|
|
523
|
-
const dayOf = (r) => { const at = r.release_at || r.deploy_at; return at ? String(at).slice(0, 10) : null; };
|
|
524
|
-
const past = mine.filter((r) => dayOf(r) && dayOf(r) <= today).sort((a, b) => (dayOf(a) < dayOf(b) ? 1 : -1));
|
|
525
|
-
const next = mine.filter((r) => dayOf(r) && dayOf(r) > today && !(r.summary || []).length).sort((a, b) => (dayOf(a) < dayOf(b) ? -1 : 1))[0] || null;
|
|
526
|
-
// Notes are due before a release that has none yet; with no release at all there is nothing to write notes for.
|
|
527
|
-
src.release = past.length || next ? { st: next ? 'due' : 'ok', when: past.length ? dayOf(past[0]) : null, due: next ? dayOf(next) : null, open: { tab: 'releases' } } : null;
|
|
528
|
-
}
|
|
529
|
-
return { sources: src, rollups: { risks: rollupOf(store, 'risks', ids || new Set()), outcome: rollupOf(store, 'outcome', ids || new Set()) } };
|
|
530
|
-
}
|
|
531
|
-
|
|
532
391
|
/** What an initiative has, from its record, the stage tools, its artifacts and the report setups. → sources by key. */
|
|
533
392
|
function initiativeSources(ctx, w, base, extra, now) {
|
|
534
393
|
const root = w.root;
|
|
@@ -603,7 +462,7 @@ function initiativeSet(w, { row, base, board, folded, store, extra, now, ctx })
|
|
|
603
462
|
const has = (k) => !!sources[k] || !!(store.get(`${scope}|${k}`) && (store.get(`${scope}|${k}`).issued || store.get(`${scope}|${k}`).draft));
|
|
604
463
|
// D99: an initiative on a library workflow lists its own stages' documents; the record always exists, so it never counts as "had" here
|
|
605
464
|
const plan = row.wf && row.wf.id ? workflowPlan(WF().resolve(folded && folded.wfLib, row.wf.id), row, (k) => k !== 'record' && has(k)) : null;
|
|
606
|
-
const facts = { now, scope, level: 'initiative', store, cat: plan ? plan.cur : row.cat, order: plan ? plan.order : null, movedAt: lastMoveOf(folded, row.id), sources,
|
|
465
|
+
const facts = { now, scope, level: 'initiative', store, cat: plan ? plan.cur : row.cat, order: plan ? plan.order : null, movedAt: lastMoveOf(folded, row.id), sources, flags: flagsOf(w.root, store, scope) };
|
|
607
466
|
const prdRel = sources.prd && sources.prd.open ? sources.prd.open.path : null, memo = new Map();
|
|
608
467
|
const list = plan ? plan.entries : setFor('initiative', { build: !!board.build, wfTpl: row.template || null, has });
|
|
609
468
|
const out = list.map((x) => {
|
|
@@ -617,23 +476,11 @@ function initiativeSet(w, { row, base, board, folded, store, extra, now, ctx })
|
|
|
617
476
|
|
|
618
477
|
/** The facts of one level. → { ok, facts } | { pending: true } | { ok: false, status, error } */
|
|
619
478
|
function gather(ctx, w, { level, board: boardId, id, now = Date.now() } = {}) {
|
|
620
|
-
if (
|
|
479
|
+
if (RETIRED_LEVELS.includes(level)) return refuse(410, RETIRED);
|
|
480
|
+
if (!LEVELS.includes(level)) return refuse(400, 'level must be initiative');
|
|
621
481
|
const store = storeOf(w.root);
|
|
622
|
-
if (level === 'portfolio') {
|
|
623
|
-
const p = portfolioSources(ctx, w, store, now);
|
|
624
|
-
return { ok: true, facts: { level, scope: 'portfolio', now, store, ...p, flags: flagsOf(w.root, store, 'portfolio'), entries: setFor('portfolio') } };
|
|
625
|
-
}
|
|
626
482
|
const RB = require('./routes-boards.js');
|
|
627
483
|
const fr = RB.frameFor(ctx, w);
|
|
628
|
-
if (level === 'board') {
|
|
629
|
-
const board = fr.boards.find((b) => b.id === boardId);
|
|
630
|
-
if (!board) return refuse(404, `no board ${String(boardId || '').slice(0, 80)} in this workspace`);
|
|
631
|
-
const ids = boardIds(ctx, w, fr, board.id);
|
|
632
|
-
const scope = `board:${board.id}`;
|
|
633
|
-
const p = boardSources(ctx, w, board, ids, store, now);
|
|
634
|
-
return { ok: true, facts: { level, scope, now, store, ...p, board: { id: board.id, name: board.name, build: !!board.build, changedAt: boardChangedAt(ctx, w, board.id) },
|
|
635
|
-
flags: flagsOf(w.root, store, scope), entries: setFor('board', { build: !!board.build }) } };
|
|
636
|
-
}
|
|
637
484
|
if (!id || !ID_RE.test(String(id))) return refuse(400, 'id must be an initiative id');
|
|
638
485
|
const got = RB.baseRows(w);
|
|
639
486
|
if (got.pending) return { pending: true };
|
|
@@ -653,28 +500,24 @@ function actOf(entry, st) {
|
|
|
653
500
|
if ((st === 'stale' || st === 'due') && draftable(entry)) return { label: 'Draft it', do: 'draft' };
|
|
654
501
|
if (st !== 'missing' && st !== 'later') return null; // a document that does not exist yet can be drafted now, in its stage or ahead of it (testing fixes)
|
|
655
502
|
if (draftable(entry)) return { label: 'Draft it', do: 'draft' };
|
|
656
|
-
if (entry.store && entry.by !== 'you') return { label: entry.key === 'okrs' ? 'Propose them' : 'Propose it', do: 'draft' };
|
|
657
|
-
if (entry.key === 'scan') return { label: 'Run a scan', go: 'scan' };
|
|
658
|
-
if (entry.kind === 'report' && entry.level !== 'initiative') return { label: 'Set it up', go: 'reports' };
|
|
659
503
|
return null;
|
|
660
504
|
}
|
|
661
505
|
|
|
662
506
|
/** The GET body. `running(scope, key)` → true while a core-doc run drafts that entry. */
|
|
663
507
|
function answer(facts, { running = () => false } = {}) {
|
|
664
508
|
const L = LEVEL[facts.level];
|
|
665
|
-
const list = facts.
|
|
509
|
+
const list = facts.list;
|
|
666
510
|
const docs = list.map(({ entry: x, st, when, due, flag, staleWhy, open, draft, from }) => ({
|
|
667
511
|
key: x.key, title: x.title, ic: x.ic, for: x.for, reader: x.reader, cadence: x.cadence, by: x.by, kind: x.kind, cat: x.cat, isNew: !!x.isNew, ...(x.other ? { other: true } : {}),
|
|
668
512
|
st, when: when || null, due: due || null, flag: flag || null, staleWhy: staleWhy || null, open: open || null, draft: draft || null,
|
|
669
513
|
act: actOf(x, st), running: !!running(facts.scope, x.key), ...(from ? { from } : {}),
|
|
670
514
|
}));
|
|
671
|
-
const ini = facts.level === 'initiative';
|
|
672
515
|
return {
|
|
673
516
|
ok: true, level: facts.level, scope: facts.scope, question: L.question, reader: L.reader, rhythm: L.rhythm,
|
|
674
|
-
build:
|
|
675
|
-
wfTpl:
|
|
517
|
+
build: !!(facts.board && facts.board.build),
|
|
518
|
+
wfTpl: facts.row.template || null, stage: facts.row.stage || null, cat: facts.plan ? facts.plan.cur : facts.row.cat || null,
|
|
676
519
|
// D99: the stage names the documents group under, in order (null: Product feature, grouped by CATS)
|
|
677
|
-
|
|
520
|
+
phases: facts.plan ? facts.plan.order : null,
|
|
678
521
|
summary: summaryOf(docs), docs,
|
|
679
522
|
};
|
|
680
523
|
}
|
|
@@ -706,36 +549,6 @@ function driverLists(set) {
|
|
|
706
549
|
// ── the core-doc run's prompt ────────────────────────────────────────────────────────────────────────
|
|
707
550
|
const S = '<state>'; // the state folder, named in the prompt as the run sees it
|
|
708
551
|
const GUIDE = Object.freeze({
|
|
709
|
-
strategy: { sources: ['The issued product strategy, if any, under <state>/core-docs/portfolio/strategy/', 'planning/okrs/ (the key results and health budgets)', 'The board charters under <state>/core-docs/board-*/charter/', 'The boards and their initiatives with their anchors (`pmos board`, `pmos initiative list`)', 'The Horizon scan reports and the research under planning/radar/ and planning/research/, if any'],
|
|
710
|
-
sections: ['A short line: this is a proposal for the PM to change, keep or drop; the PM issues the strategy', 'Where we are going', 'Where we play (one line per pillar, with its boards)', 'What we will not do', 'How we will know (a table: Pillar, Key results, Boards)'] },
|
|
711
|
-
roadmap: { sources: ['`pmos initiative list` (every initiative with its Roadmap rank, lifecycle stage and anchor)', 'planning/okrs/ (the key results the bets serve)', 'The issued portfolio roadmap before this one, if any'],
|
|
712
|
-
sections: ['Now (each bet, its board and the key result it serves)', 'Next', 'Later', 'What changed since the last roadmap'] },
|
|
713
|
-
invest: { sources: ['`pmos initiative list` (anchors: key result or health budget)', 'The plan items and their points on every board (`pmos board`)', 'The people and their points a week (`pmos people list`)', 'The Jira snapshots under the state folder, if any (read-only)'],
|
|
714
|
-
sections: ['Headline (two sentences: where the effort goes and the one thing to look at)', 'By board (a share of the effort per board)', 'Feature work against upkeep (key results against health budgets)', 'By pillar, when a product strategy is issued', 'Worth a look (key results with no effort, effort with no key result)'] },
|
|
715
|
-
prisks: { sources: ['The issued risks of every initiative: <state>/core-docs/initiative-*/risks/', 'The issued board risks: <state>/core-docs/board-*/brisks/', 'Dependencies between plan items on different boards'],
|
|
716
|
-
sections: ['One line: how many risks reach past one board', 'A table: Risk, Boards, From (the initiative ids), Owner, Since', 'What changed since the last month'] },
|
|
717
|
-
quarter: { sources: ['The issued outcome reviews of this quarter: <state>/core-docs/initiative-*/outcome/', 'The key result readings (`pmos measure` records, planning/okrs/)', 'The learnings in the stage tools and the issued board retros: <state>/core-docs/board-*/retro/'],
|
|
718
|
-
sections: ['Headline', 'Key results (a table: Key result, Start, End of quarter, Planned, Call)', 'What landed (a table: Initiative, Outcome, Moved)', 'What we learned', 'For next quarter'] },
|
|
719
|
-
charter: { sources: ['The board settings in the boards ledger (<state>/boards.jsonl: Build and deliver, Jira projects, workflows offered)', 'The issued product strategy, if any', 'The anchors of the initiatives on this board (`pmos initiative list`)'],
|
|
720
|
-
sections: ['Purpose', 'Owner and team (a table: Role, Person; write "not known" where the sources do not say)', 'Serves (pillar, key results, health budgets)', 'Scope (a table: In, Out)', 'How work flows (workflow, Build and deliver, Jira, how asks arrive)', 'Rhythm (status report, sprint review, retro)'] },
|
|
721
|
-
capacity: { sources: ['The people and their points a week (`pmos people list`)', 'The plan items with points this sprint (`pmos board`)', 'The Jira sprint snapshot under the state folder, if any (read-only)'],
|
|
722
|
-
sections: ['One line: the points the sprint holds against the points available', 'One line per person: points planned against points available, as a percentage', 'Proposal (moves that make the plan fit; each is a proposal only)', 'A last line: changes to Jira items are proposals, and nothing moves in Jira until the PM accepts them there'] },
|
|
723
|
-
metrics: { sources: ['planning/okrs/ (the key results this board serves)', 'The KR metric records and their readings (planning/records/kr-metrics.jsonl, `pmos measure`)'],
|
|
724
|
-
sections: ['The numbers this board moves (a table: Metric, Definition, Now, Target, Source)', 'Definitions that differ from another board, if any'] },
|
|
725
|
-
brisks: { sources: ['The issued risks of the initiatives on this board: <state>/core-docs/initiative-<id>/risks/', 'Waits on other boards from the plan items'],
|
|
726
|
-
sections: ['A table: Risk, Initiative, Impact, Next step, Owner', 'Waiting on other boards'] },
|
|
727
|
-
sprint: { sources: ['The Jira sprint snapshot under the state folder (read-only)', 'The burndown of the sprint (the initiative Overview tool reads the same snapshot)', 'The plan items and PMOS tasks on this board (`pmos board`)'],
|
|
728
|
-
sections: ['Headline (points committed and finished, as a percentage)', 'Finished', 'Carried over (a table: Item, Points, Why)', 'For the next sprint'] },
|
|
729
|
-
retro: { sources: ['The learnings of the closed initiatives on this board (the stage tools)', 'Their issued outcome reviews: <state>/core-docs/initiative-<id>/outcome/', 'The issued sprint reviews: <state>/core-docs/board-<id>/sprint/'],
|
|
730
|
-
sections: ['Patterns (each with the initiatives it comes from)', 'Keep, change, try (a table)'] },
|
|
731
|
-
okrs: { sources: ['The product strategy, if one is issued: <state>/core-docs/portfolio/strategy/', 'The boards and their initiatives with their anchors (`pmos board`)', 'planning/okrs/health-budgets.md, if any', 'The KR metric records and their readings (planning/records/kr-metrics.jsonl, `pmos measure`), if any'],
|
|
732
|
-
sections: ['A short line: these are proposals for the PM to change, keep or drop', 'Objectives, each with two to four key results (a table: Key result, Metric, Now, Target, Initiatives that serve it); write "not known" where no reading exists', 'Health budgets for upkeep work (a table: Budget, What it covers, Limit)', 'Initiatives with no key result to anchor to, if any'] },
|
|
733
|
-
decisions: { sources: ['Meeting notes and their summaries in the state folder (decisions, agreed, chose, will not)', 'The initiative records and their stage moves, holds, cancels and merges (`pmos initiative list`)', 'The proposals the PM kept or dropped (the driver ledger), if any', 'The issued decision log before this one, if any: <state>/core-docs/portfolio/decisions/'],
|
|
734
|
-
sections: ['A short line: these are decisions found in the sources, for the PM to keep, correct or drop', 'A table: Date, Decision, Why, Boards, Who decided, Source', 'Open questions that look like decisions still to make'] },
|
|
735
|
-
kill: { sources: ['Every initiative with its bet, its anchor and its kill conditions, if any (`pmos initiative list`, the stage tools)', 'planning/okrs/ and the key result readings (`pmos measure` records), if any', 'The issued kill conditions before these, if any: <state>/core-docs/portfolio/kill/'],
|
|
736
|
-
sections: ['A short line: these are proposed kill conditions for the PM to change, keep or drop; the PM writes them onto each initiative', 'A table: Initiative, Bet, Key result, Kill condition (a number and a date), Reading now', 'Bets with no key result to measure, if any'] },
|
|
737
|
-
context: { sources: ['The research under planning/research/ and the Horizon scan reports under planning/radar/, if any', 'Meeting notes that name users, customers, competitors or the market', 'The problem statements and research notes of the initiatives (the stage tools)', 'The issued market and user context before this one, if any: <state>/core-docs/portfolio/context/'],
|
|
738
|
-
sections: ['A short line: this is a proposal built from what PMOS has read, for the PM to change, keep or drop', 'Jobs to be done (a table: Who, Job, Evidence)', 'The market map (a table: Player, What they offer, Where we differ)', 'What we do not know yet'] },
|
|
739
552
|
risks: { sources: ['The initiative record and every file it names (PRD, design, rubric)', 'The Jira snapshot of the initiative, if any (blocked and late tickets)', 'Meeting notes and requirement notes that name the initiative'],
|
|
740
553
|
sections: ['A table: Risk, Impact (High, Medium, Low), Likelihood, Next step, Owner, Since', 'Waits on other boards, if any'] },
|
|
741
554
|
outcome: { sources: ['The key result readings since the release (`pmos measure` records)', 'The release that shipped it (the releases ledger)', 'The initiative bet, its kill conditions and its learnings (the stage tools)', 'Support tickets and notes that name it, if any'],
|
|
@@ -827,8 +640,8 @@ function batchPrompt(entries, scope, { today, label } = {}) {
|
|
|
827
640
|
}
|
|
828
641
|
|
|
829
642
|
module.exports = {
|
|
830
|
-
LEDGER, DIR, LEVELS, LEVEL, SETS, CATS, KINDS, EVENTS, BY, RESEARCH_KEEP, BUILD_ONLY_INI, STALE_ON_MOVE, ID_RE, SLOT_RE, GUIDE,
|
|
831
|
-
entryOf, parseScope, levelOfScope, scopeDir, scopeLabel, draftable, storable, actOf,
|
|
643
|
+
LEDGER, DIR, LEVELS, RETIRED_LEVELS, RETIRED, LEVEL, SETS, CATS, KINDS, EVENTS, BY, RESEARCH_KEEP, BUILD_ONLY_INI, STALE_ON_MOVE, ID_RE, SLOT_RE, GUIDE,
|
|
644
|
+
entryOf, parseScope, levelOfScope, scopeDir, scopeLabel, draftable, storable, actOf, setFor, stateOf, summaryOf, localDay, addDays,
|
|
832
645
|
ledgerFile, readLines, append, fold, storeOf, checkEntry, writeDraft, issue, drop, frontmatterOf,
|
|
833
646
|
gather, answer, initiativeDocs, initiativeSet, workflowPlan, stageEntry, WF_KEY_RE, prdSection, driverLists, runPrompt, batchPrompt,
|
|
834
647
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* coredoc-cli.js — `pmos coredoc …`: the core documents of
|
|
2
|
+
/* coredoc-cli.js — `pmos coredoc …`: the core documents of an initiative from a terminal (initiative core-documents, PRD sections 3 and 4).
|
|
3
3
|
*
|
|
4
|
-
* pmos coredoc write --scope
|
|
4
|
+
* pmos coredoc write --scope initiative:<id> --key <key> --file <path|-> [--json] [--root <dir>]
|
|
5
5
|
* writes ONE draft of a core document under <state>/core-docs/<scope>/<key>/<slot>.md and one `draft` line. Agent-callable: it is the
|
|
6
6
|
* only write of a core-doc run (lib/headless.js kind core-doc) and the driver's way to draft a due document. It writes a draft and
|
|
7
7
|
* nothing else: only the PM issues or drops it, on the page. Nothing is sent.
|
|
8
8
|
*
|
|
9
|
-
* REFUSALS (exit 1): an unknown scope form, a key that is not a document of that level, an entry PMOS does not keep as a document (a derived,
|
|
9
|
+
* REFUSALS (exit 1): a portfolio or board scope (retired, feedback batch 29 item 8: PMOS no longer drafts those), an unknown scope form, a key that is not a document of that level, an entry PMOS does not keep as a document (a derived,
|
|
10
10
|
* live or report entry), an entry the PM writes (`by: you`) from an agent session, and a scope or key other than the one the server pinned for
|
|
11
11
|
* this run (PMOS_CORE_DOC_SCOPE, and PMOS_CORE_DOC_KEY or a batch run's PMOS_CORE_DOC_KEYS). Who wrote the draft is the call path (lib/actor.js), never an argument.
|
|
12
12
|
* Exit codes: 0 done, 1 refused, 2 usage.
|
|
@@ -19,8 +19,8 @@ const CD = require('./core-docs.js');
|
|
|
19
19
|
|
|
20
20
|
const COMMANDS = { coredoc: ['write'] };
|
|
21
21
|
const USAGE = [
|
|
22
|
-
'usage: pmos coredoc write — the core documents of
|
|
23
|
-
' pmos coredoc write --scope
|
|
22
|
+
'usage: pmos coredoc write — the core documents of an initiative',
|
|
23
|
+
' pmos coredoc write --scope initiative:<id> --key <key> --file <path|->',
|
|
24
24
|
' Write ONE draft of a core document (the markdown from the file, or standard input with -). It waits for the PM, who issues it.',
|
|
25
25
|
' Keys: ' + CD.LEVELS.map((l) => `${l}: ${CD.SETS[l].filter(CD.storable).map((x) => x.key).join(', ')}`).join(' · '),
|
|
26
26
|
' A workflow stage\'s document (the stage cards on the initiative page) is initiative key wf-<stage key>, for example wf-technical-poc; `pmos workflow of <initiative>` lists the stage keys.',
|
|
@@ -68,7 +68,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
68
68
|
if (VALUE.has(k) && flags[k] === '') { say(`--${k} needs a value`); return 2; }
|
|
69
69
|
}
|
|
70
70
|
const fail = (error, code = 1) => { if (json) say(JSON.stringify({ ok: false, error })); else say(`✗ ${error}`); return code; };
|
|
71
|
-
if (!flags.scope || !flags.key || !flags.file) { say('usage: pmos coredoc write --scope
|
|
71
|
+
if (!flags.scope || !flags.key || !flags.file) { say('usage: pmos coredoc write --scope initiative:<id> --key <key> --file <path|->'); return 2; }
|
|
72
72
|
const e = env === undefined ? process.env : env;
|
|
73
73
|
const c = CD.checkEntry(flags.scope, flags.key);
|
|
74
74
|
if (!c.ok) return fail(c.error);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* custom-docs.js — the documents the PM adds to
|
|
2
|
+
/* custom-docs.js — the documents the PM adds to an initiative, beyond the core set (initiative briefing-premium-adddoc).
|
|
3
|
+
* A board scope is retired (feedback batch 29 item 8): add() refuses it (410), and list() still reads the board documents added before.
|
|
3
4
|
* THE ONE WRITER and THE ONE FOLD of <state>/custom-docs.jsonl.
|
|
4
5
|
*
|
|
5
6
|
* KINDS · PHASES · WRITERS · TITLE_MAX · URL_MAX
|
|
@@ -146,6 +147,7 @@ function add(root, input, actor, { now } = {}) {
|
|
|
146
147
|
const c = check(input);
|
|
147
148
|
if (!c.ok) return c;
|
|
148
149
|
const v = c.value;
|
|
150
|
+
if (v.scope.startsWith('board:')) return refuse(410, require('./core-docs.js').RETIRED);
|
|
149
151
|
const file = ledgerFile(root);
|
|
150
152
|
const have = readLines(file).filter((l) => l.scope === v.scope);
|
|
151
153
|
if (have.some((l) => norm(l.title) === norm(v.title))) return refuse(409, `“${v.title}” is already on this ${v.scope.startsWith('board:') ? 'board' : 'initiative'}.`);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* initiative-cli.js — `pmos initiative …`: initiatives and their place on the Roadmap from a terminal (pm-os-absorb
|
|
3
3
|
* Run 2, PRD R16, R20 A, R23, R24, R25; D86 point 4).
|
|
4
4
|
*
|
|
5
|
-
* pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>]
|
|
5
|
+
* pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>] [--kind product|sdlc|project]
|
|
6
6
|
* pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor …] [--lane …] [--title "…"]
|
|
7
7
|
* pmos initiative top|up|down|bottom <id> reorder it on the Roadmap (one ranked list, D105)
|
|
8
8
|
* pmos initiative after <id> <other-id> rank it right after another initiative
|
|
@@ -66,7 +66,7 @@ const COMMANDS = { initiative: ['new', 'top', 'up', 'down', 'bottom', 'after', '
|
|
|
66
66
|
const RETIRED = Object.freeze(['now', 'next', 'later']);
|
|
67
67
|
const USAGE = [
|
|
68
68
|
'usage: pmos initiative new|top|up|down|bottom|after|check-by|adopt|drop|list|export|describe — initiatives on the Roadmap',
|
|
69
|
-
' pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>]',
|
|
69
|
+
' pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>] [--kind product|sdlc|project]',
|
|
70
70
|
' pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor <anchor>] [--lane <lane>] [--title "<title>"]',
|
|
71
71
|
' pmos initiative top|up|down|bottom <id> reorder it on the Roadmap',
|
|
72
72
|
' pmos initiative after <id> <other-id> rank it right after another initiative',
|
|
@@ -81,7 +81,7 @@ const USAGE = [
|
|
|
81
81
|
'Now, Next and Later are retired (D105): the rank says what comes first, the lifecycle stage says where it is.',
|
|
82
82
|
];
|
|
83
83
|
const BOOL = new Set(['json', 'top', 'help']); // --top is kept so an old script gets the retired answer, not a usage error
|
|
84
|
-
const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root']);
|
|
84
|
+
const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root', 'kind']);
|
|
85
85
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
86
86
|
|
|
87
87
|
function parse(argv) {
|
|
@@ -147,7 +147,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
147
147
|
input.title = pos[0];
|
|
148
148
|
}
|
|
149
149
|
if (flags.title) input.title = flags.title;
|
|
150
|
-
for (const k of ['lane', 'anchor', 'intent', 'id']) if (flags[k]) input[k] = flags[k];
|
|
150
|
+
for (const k of ['lane', 'anchor', 'intent', 'id', 'kind']) if (flags[k]) input[k] = flags[k];
|
|
151
151
|
const actor = actorLib.fromCli(who);
|
|
152
152
|
const r = writer.createInitiative(root, input, { actor, now });
|
|
153
153
|
if (!r.ok) return fail(r.error);
|
|
@@ -165,7 +165,7 @@ function build(f) {
|
|
|
165
165
|
pending: !!f.pending,
|
|
166
166
|
header: { text: 'Real data · as of ' + hhmm(now) + (missing.length ? ' · not read: ' + missing.join(', ') : ''), missing },
|
|
167
167
|
board: { name: board.name || '', id: board.id || null, ws: board.ws || null },
|
|
168
|
-
id, key, title: clip(row.title || id, 160), lane: row.lane || '', anchor: row.anchor || '',
|
|
168
|
+
id, key, title: clip(row.title || id, 160), lane: row.lane || '', kind: ['product', 'sdlc', 'project'].includes(row.kind) ? row.kind : 'product', anchor: row.anchor || '',
|
|
169
169
|
// the bar's presses (initiative premium-board-actions): the workflow, the lifecycle and the archive entry the row holds
|
|
170
170
|
acts: {
|
|
171
171
|
self: !!board.self, stages: moveNames, stage: (own ? names[cur] : row.stage) || null,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* createInitiative(root, input, { actor, now }) → { ok: true, id, path, written }
|
|
5
5
|
* | { ok: false, status, error, field }
|
|
6
|
-
* input = { title, lane, anchor, id?, intent?, specimen_test?, surface_check?, from? }
|
|
6
|
+
* input = { title, lane, anchor, id?, intent?, specimen_test?, surface_check?, from?, kind? }
|
|
7
7
|
* slugOf(title) → the id a title gives
|
|
8
8
|
*
|
|
9
9
|
* THREE CALLERS: the page's New initiative form (POST /api/initiatives, lib/routes-initiatives.js, behind
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* WHAT IT WRITES. One file, `<initiatives>/<id>.md` in the tree of `root` (planning/initiatives/ for PMOS-self,
|
|
16
16
|
* pmos/state/initiatives/ in a kit repository, from the engine's layout): the frontmatter the gates read (`type`,
|
|
17
17
|
* `title`, `timestamp`, `lane`, `parent_kr`, and `status` — the chore lane's intent — plus the router's
|
|
18
|
-
* `specimen_test` and `surface_check` when the caller has them)
|
|
18
|
+
* `specimen_test` and `surface_check` when the caller has them), and `kind` (batch 29 item 11: product | sdlc | project, lib/work-kind.js;
|
|
19
|
+
* Product management when the caller sends none). The kind is a hint beside the lane; no gate reads it. Then ONE `created`
|
|
19
20
|
* line in placements.jsonl (lib/placements.js): the initiative lands at the end of the Roadmap (D105), whoever made it (R16, R23).
|
|
20
21
|
* The record is not committed: a commit is the caller's (the PM's) act.
|
|
21
22
|
*
|
|
@@ -56,7 +57,8 @@ const actorLib = require('./actor.js');
|
|
|
56
57
|
const ID_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
57
58
|
const MAX_ID = 60;
|
|
58
59
|
const WRITER_SET = Object.freeze(['v', 'eid', 'by', 'via', 'at', 'override', 'pm', 'actor', 'nonce', 'timestamp', 'type']);
|
|
59
|
-
const INPUT_KEYS = Object.freeze(['id', 'title', 'lane', 'anchor', 'intent', 'specimen_test', 'surface_check', 'from']);
|
|
60
|
+
const INPUT_KEYS = Object.freeze(['id', 'title', 'lane', 'anchor', 'intent', 'specimen_test', 'surface_check', 'from', 'kind']);
|
|
61
|
+
const WK = require('./work-kind.js');
|
|
60
62
|
const ONE_LINE = (v, max) => typeof v === 'string' && v.trim().length >= 1 && v.trim().length <= max && !/[\r\n\x00-\x08\x0b-\x1f]/.test(v);
|
|
61
63
|
|
|
62
64
|
const refuse = (status, error, field) => ({ ok: false, status, error, field: field || null });
|
|
@@ -104,6 +106,8 @@ function createInitiative(root, input, { actor, now } = {}) {
|
|
|
104
106
|
for (const k of ['specimen_test', 'surface_check']) {
|
|
105
107
|
if (has(input, k) && input[k] != null && !ONE_LINE(input[k], 200)) return refuse(400, `${k} must be one line of at most 200 characters`, k);
|
|
106
108
|
}
|
|
109
|
+
if (has(input, 'kind') && input.kind != null && input.kind !== '' && !WK.valid(input.kind)) return refuse(400, `kind must be one of ${WK.KINDS.join(', ')}`, 'kind');
|
|
110
|
+
const kind = has(input, 'kind') && WK.valid(input.kind) ? input.kind : WK.DEFAULT;
|
|
107
111
|
if (has(input, 'from') && input.from != null && !(typeof input.from === 'string' && placements.CAPTURE_RE.test(input.from))) {
|
|
108
112
|
return refuse(400, 'from must name a capture note, like capture-2026-10-04-1', 'from');
|
|
109
113
|
}
|
|
@@ -127,6 +131,7 @@ function createInitiative(root, input, { actor, now } = {}) {
|
|
|
127
131
|
if (intent.trim()) fm.push(`status: ${q(intent)}`);
|
|
128
132
|
if (input.specimen_test) fm.push(`specimen_test: ${q(input.specimen_test)}`);
|
|
129
133
|
if (input.surface_check) fm.push(`surface_check: ${q(input.surface_check)}`);
|
|
134
|
+
fm.push(`kind: ${kind}`);
|
|
130
135
|
fm.push('---', '', `# ${title}`, '');
|
|
131
136
|
if (intent.trim()) fm.push(intent.trim(), '');
|
|
132
137
|
const text = fm.join('\n');
|
|
@@ -338,6 +343,25 @@ function restoreDescription(root, id, from, to, { actor } = {}) {
|
|
|
338
343
|
return { ok: true, id };
|
|
339
344
|
}
|
|
340
345
|
|
|
346
|
+
/** The kind of work (batch 29 item 11, Viewer KdV1-3): only the `kind:` line changes (added at the end of the front matter when an older
|
|
347
|
+
* record has none). → { ok: true, id, from, kind } where from is what the record read as before ('product' when it had no line). */
|
|
348
|
+
function setKind(root, id, kind, { actor } = {}) {
|
|
349
|
+
if (!actorLib.valid(actor)) return refuse(500, 'initiative-writer: the caller must pass the actor from pm-guard.js or actor.js');
|
|
350
|
+
if (!WK.valid(kind)) return refuse(400, `kind must be one of ${WK.KINDS.join(', ')}`, 'kind');
|
|
351
|
+
const f = recordFile(root, id);
|
|
352
|
+
if (!f.ok) return f;
|
|
353
|
+
const text = fs.readFileSync(f.file, 'utf8');
|
|
354
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---(\r?\n|$)/.exec(text);
|
|
355
|
+
if (!m) return refuse(409, `the record of ${id} has no front matter — nothing was saved`, 'id');
|
|
356
|
+
const lines = m[1].split(/\r?\n/);
|
|
357
|
+
const at = lines.findIndex((l) => /^kind:/.test(l));
|
|
358
|
+
const from = WK.kindOf(at >= 0 ? lines[at].slice(5) : '');
|
|
359
|
+
if (at >= 0 && from === kind && lines[at].trim() === 'kind: ' + kind) return { ok: true, id, from, kind, same: true };
|
|
360
|
+
if (at >= 0) lines[at] = 'kind: ' + kind; else lines.push('kind: ' + kind);
|
|
361
|
+
try { fs.writeFileSync(f.file, '---\n' + lines.join('\n') + '\n---' + m[2] + text.slice(m[0].length), { flag: 'w' }); } catch { return refuse(500, 'the record could not be written — nothing was saved'); }
|
|
362
|
+
return { ok: true, id, from, kind };
|
|
363
|
+
}
|
|
364
|
+
|
|
341
365
|
function withdrawSplit(root, id, want, { actor } = {}) {
|
|
342
366
|
if (!actorLib.valid(actor)) return refuse(500, 'initiative-writer: the caller must pass the actor from pm-guard.js or actor.js');
|
|
343
367
|
const f = recordFile(root, id);
|
|
@@ -349,4 +373,4 @@ function withdrawSplit(root, id, want, { actor } = {}) {
|
|
|
349
373
|
return { ok: true, removed: true };
|
|
350
374
|
}
|
|
351
375
|
|
|
352
|
-
module.exports = { setDescription, restoreDescription, DESC_MAX, setOutcome, restoreOutcome, createInitiative, renameInitiative, setAnchor, restoreAnchor, withdrawSplit, recordSha, slugOf, ID_RE, INPUT_KEYS };
|
|
376
|
+
module.exports = { setKind, setDescription, restoreDescription, DESC_MAX, setOutcome, restoreOutcome, createInitiative, renameInitiative, setAnchor, restoreAnchor, withdrawSplit, recordSha, slugOf, ID_RE, INPUT_KEYS };
|