create-pmos 0.691.0 → 0.692.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 +14 -14
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +13 -0
- package/workspace/guide/cli.md +3 -1
- package/workspace/lib/board-premium.js +10 -2
- package/workspace/lib/initiative-cli.js +31 -4
- package/workspace/lib/initiative-origin.js +131 -0
- package/workspace/lib/initiative-writer.js +35 -2
- package/workspace/lib/routes-boards.js +4 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-work.js +24 -5
- package/workspace/test-lists/who-raised-each-idea.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.692.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,19 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.692.0",
|
|
38
|
+
"at": "2026-11-22T09:33:00.888Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1515,
|
|
43
|
+
"t": "Show who raised each initiative (Raised by column, group, sort and filter on Work)",
|
|
44
|
+
"s": "Show who raised each initiative (Raised by column, group, sort and filter on Work)",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
36
49
|
{
|
|
37
50
|
"v": "0.691.0",
|
|
38
51
|
"at": "2026-11-22T09:21:12.074Z",
|
|
@@ -405,19 +418,6 @@
|
|
|
405
418
|
"k": "fix"
|
|
406
419
|
}
|
|
407
420
|
]
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
"v": "0.651.0",
|
|
411
|
-
"at": "2026-11-20T07:19:20.677Z",
|
|
412
|
-
"f": 4,
|
|
413
|
-
"prs": [
|
|
414
|
-
{
|
|
415
|
-
"n": 1433,
|
|
416
|
-
"t": "Quick edit in a row and full popups for a task and a milestone",
|
|
417
|
-
"s": "Quick edit in a row and full popups for a task and a milestone",
|
|
418
|
-
"k": "new"
|
|
419
|
-
}
|
|
420
|
-
]
|
|
421
421
|
}
|
|
422
422
|
]
|
|
423
423
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T09:32:57Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T09:32:57Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T09:32:57Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.692.0",
|
|
4
|
+
"at": "2026-11-22T09:33:00.888Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1515,
|
|
9
|
+
"t": "Show who raised each initiative (Raised by column, group, sort and filter on Work)",
|
|
10
|
+
"s": "Show who raised each initiative (Raised by column, group, sort and filter on Work)",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
2
15
|
{
|
|
3
16
|
"v": "0.691.0",
|
|
4
17
|
"at": "2026-11-22T09:21:12.074Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -367,7 +367,7 @@ A page that keeps breaking should get fixed before it gets a new feature. This c
|
|
|
367
367
|
|
|
368
368
|
| Command | What it does |
|
|
369
369
|
|---|---|
|
|
370
|
-
| `pmos initiative new "<title>" --lane <lane> --anchor <anchor> [--intent "<text>"] [--id <id>]` | Makes the record and puts it at the end of the Roadmap. |
|
|
370
|
+
| `pmos initiative new "<title>" --lane <lane> --anchor <anchor> [--intent "<text>"] [--id <id>] [--raised-by "<who>"]` | Makes the record and puts it at the end of the Roadmap. |
|
|
371
371
|
| `pmos initiative new --from <capture> [--anchor <anchor>]` | Adds the initiative a capture proposes. |
|
|
372
372
|
| `pmos initiative top <id>` | Ranks it first. |
|
|
373
373
|
| `pmos initiative up <id>` | Moves it one place up. |
|
|
@@ -381,6 +381,8 @@ A page that keeps breaking should get fixed before it gets a new feature. This c
|
|
|
381
381
|
| `pmos initiative export <id>` | Writes the breakdown as markdown to the terminal. |
|
|
382
382
|
| `pmos initiative describe <id>` | Shows the description, and the lines PMOS can draft it from. |
|
|
383
383
|
| `pmos initiative describe <id> "<text>"` | Saves the description. PMOS runs this only after your yes. |
|
|
384
|
+
| `pmos initiative raised-by <id>` | Shows who raised it: you, a teammate, a customer, PMOS or the tracker. |
|
|
385
|
+
| `pmos initiative raised-by <id> "<who>"` | Saves who raised it: `you`, `pmos`, `tracker`, `"teammate: <name>"` or `"customer: <name>"`. `none` removes it. |
|
|
384
386
|
|
|
385
387
|
Every command takes `--json` and `--root <dir>`. The command does not accept `--by` or `--via`. `pmos initiative now`, `next` and `later` are retired: they write nothing, say what to use instead and exit 2.
|
|
386
388
|
|
|
@@ -275,6 +275,14 @@ const gapsOf = (r) => (Array.isArray(r.gaps) ? r.gaps : []).filter((g) => g && d
|
|
|
275
275
|
/** Where the dated work of each stage runs (batch 11 item 13): the » of a skipped stage sits between two of them. */
|
|
276
276
|
const stageSpansOf = (r) => (Array.isArray(r.stageSpans) ? r.stageSpans : []).filter((x) => x && stageKey(x.stage) && dayOr(x.start) && dayOr(x.due)).slice(0, 40)
|
|
277
277
|
.map((x) => ({ stage: stageKey(x.stage), start: x.start, due: x.due }));
|
|
278
|
+
/** Who raised the row (lib/initiative-origin.js, built by the route): kept only in its known shape, else null (a row with none shows nothing). */
|
|
279
|
+
const ORIGIN_KINDS = ['you', 'teammate', 'customer', 'pmos', 'tracker'];
|
|
280
|
+
function originOf(r) {
|
|
281
|
+
const o = r && r.origin;
|
|
282
|
+
if (!o || !ORIGIN_KINDS.includes(o.kind) || typeof o.label !== 'string' || typeof o.group !== 'string') return null;
|
|
283
|
+
return { kind: o.kind, name: typeof o.name === 'string' ? clip(o.name, 60) : null, label: clip(o.label, 80), group: o.group, source: o.source === 'record' ? 'record' : 'roadmap' };
|
|
284
|
+
}
|
|
285
|
+
|
|
278
286
|
function rowOf(r0, wf, today) {
|
|
279
287
|
// T3 (lib/status-proof.js): a status word the row cannot prove (no source, no read time) says No signal, on every surface that reads it
|
|
280
288
|
const r = r0 && r0.status ? { ...r0, status: SP.provenStatus(r0) } : r0;
|
|
@@ -282,7 +290,7 @@ function rowOf(r0, wf, today) {
|
|
|
282
290
|
const bad = r.status === 'late' || r.status === 'at risk';
|
|
283
291
|
const facts = [
|
|
284
292
|
['Lane', r.lane], ['Stage', r.stage ? r.stage + (r.stageSource ? ' (' + r.stageSource + ')' : '') : ''], ['Anchor', r.anchor], ['Rank', Number.isInteger(r.rank) ? '#' + (r.rank + 1) + ' on the Roadmap' : ''],
|
|
285
|
-
['Status', STATUS_LABEL[r.status] || (r.status ? r.status.charAt(0).toUpperCase() + r.status.slice(1) : '')], ['Owner', r.owner],
|
|
293
|
+
['Status', STATUS_LABEL[r.status] || (r.status ? r.status.charAt(0).toUpperCase() + r.status.slice(1) : '')], ['Owner', r.owner], ['Raised by', originOf(r) ? originOf(r).label : ''],
|
|
286
294
|
['Progress', pctOf(r.progress) != null ? pctOf(r.progress) + '%' : ''], ['Starts', r.start ? shortDate(r.start) : ''], ['Ends', r.end ? shortDate(r.end) : ''],
|
|
287
295
|
['Last changed', r.updated ? shortDate(String(r.updated).slice(0, 10)) : ''], ['Possible duplicate of', r.dupOf], ['Warnings', (r.warnings || []).map((w) => (typeof w === 'string' ? w : w && (w.text || w.message || w.id)) || '').filter(Boolean).join('; ')],
|
|
288
296
|
].filter((x) => x[1]);
|
|
@@ -294,7 +302,7 @@ function rowOf(r0, wf, today) {
|
|
|
294
302
|
stage: r.stage || null, cat: r.cat || null, stageNote: r.stageSource === 'derived' ? 'derived' : null,
|
|
295
303
|
seg: names.map((n, j) => (j < cur ? 'p' : j === cur ? 'n' : '')), progress: pctOf(r.progress),
|
|
296
304
|
finish: r.end ? shortDate(r.end) : 'Not planned', over: !!over, start: r.start || null, end: r.end || null,
|
|
297
|
-
owner: r.owner || null, lane: r.lane || null, kind: KINDS.includes(r.kind) ? r.kind : 'product', anchor: r.anchor || null, kr: krShort(r.anchor), rank: Number.isInteger(r.rank) ? r.rank : null, warnings: (r.warnings || []).filter((w) => typeof w === 'string').slice(0, 12), epics: Array.isArray(r.epics) ? r.epics.filter((e) => typeof e === 'string').slice(0, 6) : [], updated: r.updated || null, reading: r.reading || null, overDays: over ? days(r.end, today) : 0,
|
|
305
|
+
owner: r.owner || null, origin: originOf(r), lane: r.lane || null, kind: KINDS.includes(r.kind) ? r.kind : 'product', anchor: r.anchor || null, kr: krShort(r.anchor), rank: Number.isInteger(r.rank) ? r.rank : null, warnings: (r.warnings || []).filter((w) => typeof w === 'string').slice(0, 12), epics: Array.isArray(r.epics) ? r.epics.filter((e) => typeof e === 'string').slice(0, 6) : [], updated: r.updated || null, reading: r.reading || null, overDays: over ? days(r.end, today) : 0,
|
|
298
306
|
acts: actsOf(r, names),
|
|
299
307
|
// the PM's standing verdict on the outcome (launch simulation W2): the Next cell stops asking "did it work?" once it is answered
|
|
300
308
|
outcome: r.outcome && r.outcome.verdict ? { verdict: r.outcome.verdict, current: !!r.outcome.current, ...(r.outcome.next ? { next: r.outcome.next } : {}) } : null,
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* pmos initiative export <id> the breakdown as markdown on stdout; nothing is written
|
|
14
14
|
* pmos initiative describe <id> ["<text>"] no text: its description and the cited lines PMOS can draft it from; with text: write
|
|
15
15
|
* its `description:` line (initiative-description-field). An agent writes only after the PM's yes
|
|
16
|
+
* pmos initiative raised-by <id> ["<who>"|none] no value: who raised it and where that is read from; with a value: write its `raised_by:`
|
|
17
|
+
* line (who-raised-each-idea): you, pmos, tracker, "teammate: <name>" or "customer: <name>"
|
|
16
18
|
* every command: [--json] [--root <dir>]
|
|
17
19
|
*
|
|
18
20
|
* The SAME writers the workspace page uses (lib/initiative-writer.js, lib/placements.js) — no server is needed. Who
|
|
@@ -61,12 +63,12 @@ function docNote(docs) {
|
|
|
61
63
|
return `Not on the Roadmap · ${docs.length} on a document lane: ${names}. A document lane does not show on Home or the Board. If it is work, set lane: in its record to ${WORK_LANES}.`;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
const COMMANDS = { initiative: ['new', 'top', 'up', 'down', 'bottom', 'after', 'check-by', 'adopt', 'drop', 'list', 'export', 'describe'] };
|
|
66
|
+
const COMMANDS = { initiative: ['new', 'top', 'up', 'down', 'bottom', 'after', 'check-by', 'adopt', 'drop', 'list', 'export', 'describe', 'raised-by'] };
|
|
65
67
|
/** The horizon verbs D105 retired: they answer with what to use instead. */
|
|
66
68
|
const RETIRED = Object.freeze(['now', 'next', 'later']);
|
|
67
69
|
const USAGE = [
|
|
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>] [--kind product|sdlc|project]',
|
|
70
|
+
'usage: pmos initiative new|top|up|down|bottom|after|check-by|adopt|drop|list|export|describe|raised-by — initiatives on the Roadmap',
|
|
71
|
+
' pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>] [--kind product|sdlc|project] [--raised-by "<who>"]',
|
|
70
72
|
' pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor <anchor>] [--lane <lane>] [--title "<title>"]',
|
|
71
73
|
' pmos initiative top|up|down|bottom <id> reorder it on the Roadmap',
|
|
72
74
|
' pmos initiative after <id> <other-id> rank it right after another initiative',
|
|
@@ -76,6 +78,7 @@ const USAGE = [
|
|
|
76
78
|
' pmos initiative list the Roadmap, ranked, with each lifecycle stage',
|
|
77
79
|
' pmos initiative export <id> the breakdown as markdown on stdout',
|
|
78
80
|
' pmos initiative describe <id> ["<text>"] read its description and what to draft it from; with text, save it (after the PM\'s yes)',
|
|
81
|
+
' pmos initiative raised-by <id> ["<who>"|none] who raised it; with a value, save it: you, pmos, tracker, "teammate: <name>", "customer: <name>"',
|
|
79
82
|
' --lane is a work lane of this repository: new-feature, improvement, bug-fix, discovery or chore in a product repository',
|
|
80
83
|
' (scripts/lane-defs.js; the PMOS repository itself uses feature, discovery, chore, incident, content and prototype)',
|
|
81
84
|
' every command: [--json] [--root <dir>]',
|
|
@@ -83,7 +86,7 @@ const USAGE = [
|
|
|
83
86
|
'Now, Next and Later are retired (D105): the rank says what comes first, the lifecycle stage says where it is.',
|
|
84
87
|
];
|
|
85
88
|
const BOOL = new Set(['json', 'top', 'help']); // --top is kept so an old script gets the retired answer, not a usage error
|
|
86
|
-
const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root', 'kind']);
|
|
89
|
+
const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root', 'kind', 'raised-by']);
|
|
87
90
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
88
91
|
|
|
89
92
|
function parse(argv) {
|
|
@@ -150,6 +153,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
150
153
|
}
|
|
151
154
|
if (flags.title) input.title = flags.title;
|
|
152
155
|
for (const k of ['lane', 'anchor', 'intent', 'id', 'kind']) if (flags[k]) input[k] = flags[k];
|
|
156
|
+
if (flags['raised-by']) input.raised_by = flags['raised-by'];
|
|
153
157
|
const actor = actorLib.fromCli(who);
|
|
154
158
|
const r = writer.createInitiative(root, input, { actor, now });
|
|
155
159
|
if (!r.ok) return fail(r.error);
|
|
@@ -214,6 +218,29 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
214
218
|
return done({ written: r.written }, `✓ proposal ${eid} ${verb === 'adopt' ? 'kept' : 'dropped'}`);
|
|
215
219
|
}
|
|
216
220
|
|
|
221
|
+
if (verb === 'raised-by') {
|
|
222
|
+
// who-raised-each-idea (bet A445): read who raised an initiative, or write its raised_by line
|
|
223
|
+
const rid = pos[0];
|
|
224
|
+
if (!rid || pos.length > 2) { say('usage: pmos initiative raised-by <id> ["<who>"|none]'); return 2; }
|
|
225
|
+
const ORIGIN = require('./initiative-origin.js');
|
|
226
|
+
if (pos.length === 2) {
|
|
227
|
+
const r = writer.setRaisedBy(root, rid, pos[1], { actor: actorLib.fromCli(who) });
|
|
228
|
+
if (!r.ok) return fail(r.error, r.status === 400 ? 2 : 1);
|
|
229
|
+
const o = ORIGIN.originOf({ raised_by: r.to, created: ORIGIN.createdBy(root).get(rid) });
|
|
230
|
+
return done({ id: rid, from: r.from || null, raised_by: r.to || null, origin: o, same: !!r.same },
|
|
231
|
+
r.same ? `${rid} says that already.` : `✓ ${rid}: raised by ${o ? o.label : 'not recorded'}. Commit the record to keep it.`);
|
|
232
|
+
}
|
|
233
|
+
const fs = require('fs');
|
|
234
|
+
let text = null;
|
|
235
|
+
for (const rel of ['planning/initiatives', 'pmos/state/initiatives']) { try { text = fs.readFileSync(path.join(root, rel, rid + '.md'), 'utf8'); break; } catch { /* the other layout */ } }
|
|
236
|
+
if (text == null) return fail(`no initiative ${rid} here`);
|
|
237
|
+
const o = ORIGIN.originOf({ raised_by: ORIGIN.raisedByOfText(text), created: ORIGIN.createdBy(root).get(rid) });
|
|
238
|
+
if (json) { say(JSON.stringify({ ok: true, id: rid, origin: o })); return 0; }
|
|
239
|
+
say(o ? `${rid}: raised by ${o.label} (${o.source === 'record' ? 'its raised_by line' : 'the Roadmap line that added it'}).` : `${rid}: who raised it is not recorded.`);
|
|
240
|
+
if (!o || o.source !== 'record') say(`Ask the PM who raised it; after the answer: pmos initiative raised-by ${rid} "<you|pmos|tracker|teammate: name|customer: name>"`);
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
217
244
|
if (verb === 'describe') {
|
|
218
245
|
// initiative-description-field: the record's own description. Read with no text; write with text, only after the PM said yes.
|
|
219
246
|
const did = pos[0];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/initiative-origin.js — who raised an initiative (bet A445, initiative who-raised-each-idea). The one place the rule lives.
|
|
3
|
+
*
|
|
4
|
+
* parse(text) → { ok: true, kind, name } | { ok: false, error } a `raised_by:` value
|
|
5
|
+
* originOf({ raised_by, created }) → origin | null
|
|
6
|
+
* createdBy(root) → Map(initiative → { by, from }) the Roadmap's `created` lines (lib/placements.js), read once
|
|
7
|
+
* coverage(root) → { total, known, pct, byKind }
|
|
8
|
+
* node lib/initiative-origin.js coverage <root> prints the coverage; its last line is the percent (the build's health number)
|
|
9
|
+
*
|
|
10
|
+
* WHERE AN ORIGIN COMES FROM, in this order, for any product:
|
|
11
|
+
* 1. the record's own `raised_by:` line, which the PM or an agent writes (lib/initiative-writer.js, `pmos initiative raised-by`):
|
|
12
|
+
* `you`, `pmos` (or `agent`), `tracker`, `teammate: <name>`, `customer: <name>`;
|
|
13
|
+
* 2. the Roadmap's `created` line, which the one writer of a record appends: `by: pm:*` is You, `by: agent:*` is PMOS;
|
|
14
|
+
* 3. nothing: the row shows nothing (zero is silence) and falls in "Not recorded" in a group or a filter.
|
|
15
|
+
* PMOS never guesses a person from a ticket or a document: an origin is read, never invented.
|
|
16
|
+
*
|
|
17
|
+
* AN ORIGIN: { kind, name, label, group, source }
|
|
18
|
+
* kind 'you' | 'teammate' | 'customer' | 'pmos' | 'tracker'
|
|
19
|
+
* name the person or company for a teammate or a customer, else null
|
|
20
|
+
* label what a cell says: "You", "Dana · teammate", "Acme · customer", "PMOS", "From the tracker"
|
|
21
|
+
* group what a group or a filter value says: "You", "Teammates", "Customers", "PMOS", "From the tracker"
|
|
22
|
+
* source 'record' (the raised_by line) | 'roadmap' (the created line)
|
|
23
|
+
* The page never sees a session token: the created line's `by` is reduced to its kind here.
|
|
24
|
+
*/
|
|
25
|
+
const fs = require('fs');
|
|
26
|
+
const path = require('path');
|
|
27
|
+
|
|
28
|
+
const KINDS = Object.freeze(['you', 'teammate', 'customer', 'pmos', 'tracker']);
|
|
29
|
+
const NAMED = new Set(['teammate', 'customer']);
|
|
30
|
+
const ALIAS = Object.freeze({ pm: 'you', me: 'you', agent: 'pmos' });
|
|
31
|
+
const GROUP = Object.freeze({ you: 'You', teammate: 'Teammates', customer: 'Customers', pmos: 'PMOS', tracker: 'From the tracker' });
|
|
32
|
+
const NONE = 'Not recorded';
|
|
33
|
+
const MAX_NAME = 60;
|
|
34
|
+
|
|
35
|
+
/** A `raised_by:` value → { ok, kind, name } or { ok: false, error }. Quotes around the whole value are dropped. */
|
|
36
|
+
function parse(text) {
|
|
37
|
+
const raw = String(text == null ? '' : text).trim().replace(/^["']|["']$/g, '').trim();
|
|
38
|
+
if (!raw) return { ok: false, error: 'say who raised it: you, pmos, tracker, "teammate: <name>" or "customer: <name>"' };
|
|
39
|
+
if (/[\r\n\x00-\x08\x0b-\x1f]/.test(raw)) return { ok: false, error: 'who raised it must be one line' };
|
|
40
|
+
const m = /^([A-Za-z]+)\s*(?::\s*(.*))?$/.exec(raw);
|
|
41
|
+
const k0 = m ? m[1].toLowerCase() : '';
|
|
42
|
+
const kind = ALIAS[k0] || k0;
|
|
43
|
+
if (!m || !KINDS.includes(kind)) return { ok: false, error: `"${raw.slice(0, 40)}" is not one of: you, pmos, tracker, teammate: <name>, customer: <name>` };
|
|
44
|
+
const name = m[2] != null ? m[2].trim() : '';
|
|
45
|
+
if (NAMED.has(kind)) {
|
|
46
|
+
if (!name) return { ok: false, error: `name the ${kind}: "${kind}: <name>"` };
|
|
47
|
+
if (name.length > MAX_NAME) return { ok: false, error: `the name is at most ${MAX_NAME} characters` };
|
|
48
|
+
return { ok: true, kind, name };
|
|
49
|
+
}
|
|
50
|
+
if (m[2] != null) return { ok: false, error: `${kind} takes no name` };
|
|
51
|
+
return { ok: true, kind, name: null };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The value a record line holds for a parsed origin: `you`, `teammate: Dana`. */
|
|
55
|
+
const lineValue = (p) => (p.name ? `${p.kind}: ${p.name}` : p.kind);
|
|
56
|
+
|
|
57
|
+
function shape(kind, name, source) {
|
|
58
|
+
const label = name ? `${name} · ${kind}` : kind === 'you' ? 'You' : kind === 'pmos' ? 'PMOS' : kind === 'tracker' ? 'From the tracker' : GROUP[kind];
|
|
59
|
+
return { kind, name: name || null, label, group: GROUP[kind], source };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The origin of one initiative: its record line first, else the Roadmap's created line, else null. */
|
|
63
|
+
function originOf({ raised_by: rb, created } = {}) {
|
|
64
|
+
if (rb != null && String(rb).trim()) {
|
|
65
|
+
const p = parse(rb);
|
|
66
|
+
if (p.ok) return shape(p.kind, p.name, 'record');
|
|
67
|
+
}
|
|
68
|
+
const by = created && typeof created.by === 'string' ? created.by : '';
|
|
69
|
+
if (by.startsWith('pm:')) return shape('you', null, 'roadmap');
|
|
70
|
+
if (by.startsWith('agent:')) return shape('pmos', null, 'roadmap');
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The first `created` line of each initiative in the placements ledger: Map(id → { by, from }). An unreadable ledger is an empty map. */
|
|
75
|
+
function createdBy(root) {
|
|
76
|
+
const out = new Map();
|
|
77
|
+
let lines = [];
|
|
78
|
+
try { lines = require('./plan-ledgers.js').readLines(root, 'placements').lines || []; } catch { return out; }
|
|
79
|
+
for (const { rec } of lines) {
|
|
80
|
+
if (!rec || rec.ev !== 'created' || typeof rec.initiative !== 'string' || out.has(rec.initiative)) continue;
|
|
81
|
+
out.set(rec.initiative, { by: typeof rec.by === 'string' ? rec.by : '', from: rec.from || null });
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The `raised_by:` line of a record's front matter, or ''. */
|
|
87
|
+
function raisedByOfText(text) {
|
|
88
|
+
const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(String(text || ''));
|
|
89
|
+
if (!fm) return '';
|
|
90
|
+
const m = /^raised_by:[ \t]*(.*?)[ \t]*$/m.exec(fm[1]);
|
|
91
|
+
return m ? m[1].replace(/^["']|["']$/g, '').replace(/\\"/g, '"') : '';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The initiative records of a checkout, either layout: planning/initiatives/ (PMOS itself) and pmos/state/initiatives/ (a kit repository). */
|
|
95
|
+
function recordFiles(root) {
|
|
96
|
+
const out = [];
|
|
97
|
+
for (const rel of ['planning/initiatives', 'pmos/state/initiatives']) {
|
|
98
|
+
let names = [];
|
|
99
|
+
try { names = fs.readdirSync(path.join(root, rel)); } catch { continue; }
|
|
100
|
+
for (const n of names) if (n.endsWith('.md') && !/^(readme|index|log)\.md$/i.test(n)) out.push({ id: n.slice(0, -3), file: path.join(root, rel, n) });
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** How many of a checkout's initiatives show who raised them. → { total, known, pct, byKind: { you, teammate, … , none } } */
|
|
106
|
+
function coverage(root) {
|
|
107
|
+
const created = createdBy(root);
|
|
108
|
+
const byKind = Object.fromEntries([...KINDS, 'none'].map((k) => [k, 0]));
|
|
109
|
+
let total = 0, known = 0;
|
|
110
|
+
for (const { id, file } of recordFiles(root)) {
|
|
111
|
+
let text = '';
|
|
112
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { continue; }
|
|
113
|
+
if (!/^---\r?\n[\s\S]*?^type:\s*["']?Initiative/m.test(text)) continue;
|
|
114
|
+
total++;
|
|
115
|
+
const o = originOf({ raised_by: raisedByOfText(text), created: created.get(id) });
|
|
116
|
+
if (o) { known++; byKind[o.kind]++; } else byKind.none++;
|
|
117
|
+
}
|
|
118
|
+
return { total, known, pct: total ? Math.round((known / total) * 1000) / 10 : 0, byKind };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (require.main === module) {
|
|
122
|
+
const [cmd, root0] = process.argv.slice(2);
|
|
123
|
+
if (cmd !== 'coverage') { console.log('usage: node lib/initiative-origin.js coverage <checkout>'); process.exit(2); }
|
|
124
|
+
const root = path.resolve(root0 || '.');
|
|
125
|
+
const c = coverage(root);
|
|
126
|
+
const kinds = Object.entries(c.byKind).filter(([, n]) => n).map(([k, n]) => `${k === 'none' ? NONE.toLowerCase() : k} ${n}`).join(', ');
|
|
127
|
+
console.log(`[origin] ${c.known} of ${c.total} initiatives show who raised them${kinds ? ` (${kinds})` : ''}`);
|
|
128
|
+
console.log(String(c.pct));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = { KINDS, GROUP, NONE, parse, lineValue, originOf, createdBy, raisedByOfText, coverage };
|
|
@@ -57,8 +57,9 @@ const actorLib = require('./actor.js');
|
|
|
57
57
|
const ID_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
58
58
|
const MAX_ID = 60;
|
|
59
59
|
const WRITER_SET = Object.freeze(['v', 'eid', 'by', 'via', 'at', 'override', 'pm', 'actor', 'nonce', 'timestamp', 'type']);
|
|
60
|
-
const INPUT_KEYS = Object.freeze(['id', 'title', 'lane', 'anchor', 'intent', 'specimen_test', 'surface_check', 'from', 'kind']);
|
|
60
|
+
const INPUT_KEYS = Object.freeze(['id', 'title', 'lane', 'anchor', 'intent', 'specimen_test', 'surface_check', 'from', 'kind', 'raised_by']);
|
|
61
61
|
const WK = require('./work-kind.js');
|
|
62
|
+
const ORIGIN = require('./initiative-origin.js'); // who raised it (who-raised-each-idea): the one parser of a raised_by value
|
|
62
63
|
const ONE_LINE = (v, max) => typeof v === 'string' && v.trim().length >= 1 && v.trim().length <= max && !/[\r\n\x00-\x08\x0b-\x1f]/.test(v);
|
|
63
64
|
|
|
64
65
|
const refuse = (status, error, field) => ({ ok: false, status, error, field: field || null });
|
|
@@ -108,6 +109,11 @@ function createInitiative(root, input, { actor, now } = {}) {
|
|
|
108
109
|
}
|
|
109
110
|
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
111
|
const kind = has(input, 'kind') && WK.valid(input.kind) ? input.kind : WK.DEFAULT;
|
|
112
|
+
let raised = null;
|
|
113
|
+
if (has(input, 'raised_by') && input.raised_by != null && input.raised_by !== '') {
|
|
114
|
+
raised = ORIGIN.parse(input.raised_by);
|
|
115
|
+
if (!raised.ok) return refuse(400, raised.error, 'raised_by');
|
|
116
|
+
}
|
|
111
117
|
if (has(input, 'from') && input.from != null && !(typeof input.from === 'string' && placements.CAPTURE_RE.test(input.from))) {
|
|
112
118
|
return refuse(400, 'from must name a capture note, like capture-2026-10-04-1', 'from');
|
|
113
119
|
}
|
|
@@ -132,6 +138,7 @@ function createInitiative(root, input, { actor, now } = {}) {
|
|
|
132
138
|
if (input.specimen_test) fm.push(`specimen_test: ${q(input.specimen_test)}`);
|
|
133
139
|
if (input.surface_check) fm.push(`surface_check: ${q(input.surface_check)}`);
|
|
134
140
|
fm.push(`kind: ${kind}`);
|
|
141
|
+
if (raised) fm.push(`raised_by: ${q(ORIGIN.lineValue(raised))}`);
|
|
135
142
|
fm.push('---', '', `# ${title}`, '');
|
|
136
143
|
if (intent.trim()) fm.push(intent.trim(), '');
|
|
137
144
|
const text = fm.join('\n');
|
|
@@ -343,6 +350,32 @@ function restoreDescription(root, id, from, to, { actor } = {}) {
|
|
|
343
350
|
return { ok: true, id };
|
|
344
351
|
}
|
|
345
352
|
|
|
353
|
+
/** Who raised it (who-raised-each-idea, bet A445): only the `raised_by:` line changes, added at the end of the front matter when there is
|
|
354
|
+
* none; `none` (or '') removes it, and the row then reads its origin from the Roadmap's created line again (lib/initiative-origin.js).
|
|
355
|
+
* → { ok: true, id, from, to } where from and to are the line's values ('' for no line), or a refusal (400 for a value parse refuses). */
|
|
356
|
+
function setRaisedBy(root, id, value, { actor } = {}) {
|
|
357
|
+
if (!actorLib.valid(actor)) return refuse(500, 'initiative-writer: the caller must pass the actor from pm-guard.js or actor.js');
|
|
358
|
+
const v = typeof value === 'string' ? value.trim() : '';
|
|
359
|
+
let to = '';
|
|
360
|
+
if (v && v.toLowerCase() !== 'none') {
|
|
361
|
+
const p = ORIGIN.parse(v);
|
|
362
|
+
if (!p.ok) return refuse(400, p.error, 'raised_by');
|
|
363
|
+
to = ORIGIN.lineValue(p);
|
|
364
|
+
}
|
|
365
|
+
const f = recordFile(root, id);
|
|
366
|
+
if (!f.ok) return f;
|
|
367
|
+
const text = fs.readFileSync(f.file, 'utf8');
|
|
368
|
+
const fm = frontOfText(text);
|
|
369
|
+
if (!fm) return refuse(409, `the record of ${id} has no front matter — nothing was saved`, 'id');
|
|
370
|
+
const lines = fm[1].split(/\r?\n/);
|
|
371
|
+
const at = lines.findIndex((l) => /^raised_by:/.test(l));
|
|
372
|
+
const from = at >= 0 ? ORIGIN.raisedByOfText('---\n' + lines[at] + '\n---') : '';
|
|
373
|
+
if (from === to) return { ok: true, id, from, to, same: true };
|
|
374
|
+
if (to) { const line = 'raised_by: ' + q(to); if (at >= 0) lines[at] = line; else lines.push(line); } else lines.splice(at, 1);
|
|
375
|
+
try { fs.writeFileSync(f.file, '---\n' + lines.join('\n') + '\n---' + fm[2] + text.slice(fm[0].length), { flag: 'w' }); } catch { return refuse(500, 'the record could not be written — nothing was saved'); }
|
|
376
|
+
return { ok: true, id, from, to };
|
|
377
|
+
}
|
|
378
|
+
|
|
346
379
|
/** 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
380
|
* record has none). → { ok: true, id, from, kind } where from is what the record read as before ('product' when it had no line). */
|
|
348
381
|
function setKind(root, id, kind, { actor } = {}) {
|
|
@@ -373,4 +406,4 @@ function withdrawSplit(root, id, want, { actor } = {}) {
|
|
|
373
406
|
return { ok: true, removed: true };
|
|
374
407
|
}
|
|
375
408
|
|
|
376
|
-
module.exports = { setKind, setDescription, restoreDescription, DESC_MAX, setOutcome, restoreOutcome, createInitiative, renameInitiative, setAnchor, restoreAnchor, withdrawSplit, recordSha, slugOf, ID_RE, INPUT_KEYS };
|
|
409
|
+
module.exports = { setKind, setRaisedBy, setDescription, restoreDescription, DESC_MAX, setOutcome, restoreOutcome, createInitiative, renameInitiative, setAnchor, restoreAnchor, withdrawSplit, recordSha, slugOf, ID_RE, INPUT_KEYS };
|
|
@@ -112,6 +112,7 @@ const holdSpans = require('./hold-spans.js');
|
|
|
112
112
|
const ledgers = require('./plan-ledgers.js');
|
|
113
113
|
const intake = require(repoScript('intake.js'));
|
|
114
114
|
const WK = require('./work-kind.js');
|
|
115
|
+
const ORIGIN = require('./initiative-origin.js'); // who raised each initiative (who-raised-each-idea)
|
|
115
116
|
const OS = require('./one-stage.js');
|
|
116
117
|
|
|
117
118
|
const LEDGER = 'boards.jsonl';
|
|
@@ -421,6 +422,7 @@ function baseRowsRead(w) {
|
|
|
421
422
|
const verdicts = require('./outcomes.js').rowOutcomes(w.root, { today: day });
|
|
422
423
|
const rows = [];
|
|
423
424
|
const seen = new Set();
|
|
425
|
+
const created = ORIGIN.createdBy(w.root); // the Roadmap's created lines, read once: who added each record
|
|
424
426
|
for (const id of F.placed.ranked) {
|
|
425
427
|
if (seen.has(id)) continue;
|
|
426
428
|
seen.add(id);
|
|
@@ -439,6 +441,7 @@ function baseRowsRead(w) {
|
|
|
439
441
|
rows.push({
|
|
440
442
|
id, title: r.title, lane: r.lane || null, kind: WK.kindOf(fm.kind), // batch 29 item 11: no line reads as Product management
|
|
441
443
|
owner: fm.owner ? String(fm.owner) : null,
|
|
444
|
+
origin: ORIGIN.originOf({ raised_by: fm.raised_by, created: created.get(id) }),
|
|
442
445
|
anchor: r.anchor || null, rank: Number.isInteger(r.rank) ? r.rank : null, dormant: !!r.dormant,
|
|
443
446
|
status: statusOf(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
|
|
444
447
|
statusIn: statusIn(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
|
|
@@ -609,7 +612,7 @@ function boardRow(board, base, folded, lib) {
|
|
|
609
612
|
const wf = B.workflowOf(board, base.id, folded);
|
|
610
613
|
const cat = B.catOf({ workflow: wf }, s.stage);
|
|
611
614
|
const row = {
|
|
612
|
-
id: base.id, title: base.title, lane: base.lane, kind: WK.kindOf(base.kind), stage: s.stage, cat, owner: base.owner, anchor: base.anchor,
|
|
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,
|
|
613
616
|
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: [],
|
|
614
617
|
rank: base.rank, health: B.isActive(base) ? base.health : null, updated: base.updated, reading: base.reading, stageSource: s.source, lifecycle: base.lifecycle,
|
|
615
618
|
stopped: base.stopped || null, archived: archivedOf(folded, base.id), outcome: base.outcome || null,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.692.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.692.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -34,9 +34,10 @@ export const COLS = [
|
|
|
34
34
|
{ k: 'program', n: 'Program', w: 150, on: false },
|
|
35
35
|
{ k: 'goal', n: 'Goal', w: 170, on: false },
|
|
36
36
|
{ k: 'wf', n: 'Workflow', w: 140, on: false },
|
|
37
|
+
{ k: 'origin', n: 'Raised by', w: 150, on: false }, // who raised it (who-raised-each-idea, bet A445): lib/initiative-origin.js on the row
|
|
37
38
|
];
|
|
38
39
|
const byK = Object.fromEntries(COLS.map((c) => [c.k, c]));
|
|
39
|
-
export const GROUPS = [['goal', 'Goal'], ['product', 'Product'], ['stage', 'Stage'], ['status', 'Status'], ['program', 'Program'], ['none', 'No groups']];
|
|
40
|
+
export const GROUPS = [['goal', 'Goal'], ['product', 'Product'], ['stage', 'Stage'], ['status', 'Status'], ['program', 'Program'], ['origin', 'Raised by'], ['none', 'No groups']];
|
|
40
41
|
// the scale tabs (WorkDS, 2026-11-20): Week, Month, Quarter, Year and Full; the number is the window's length in days (Full fits the rows)
|
|
41
42
|
export const SPANS = [['week', 'Week', 42], ['month', 'Month', 152], ['quarter', 'Quarter', 456], ['year', 'Year', 1096], ['full', 'Full', 0]];
|
|
42
43
|
const OLD_SPAN = { half: 'quarter', y2: 'year', y5: 'year' }; // a view kept before the scale tabs
|
|
@@ -94,6 +95,16 @@ export function moveCol(k, before) {
|
|
|
94
95
|
/** The columns to draw beside Initiative: the ones switched on, in their order; Product leaves by itself with one product. */
|
|
95
96
|
export const colsShown = (v, o = {}) => v.cols.filter((c) => c.on && !(c.k === 'product' && !o.many)).map((c) => c.k);
|
|
96
97
|
|
|
98
|
+
/* ── who raised it (who-raised-each-idea) ── the server reads it (lib/initiative-origin.js) and the row carries { kind, name, label, group }:
|
|
99
|
+
* "You", "Dana · teammate", "Acme · customer", "PMOS", "From the tracker". A row with none shows nothing and falls in "Not recorded". A copy
|
|
100
|
+
* never says "You" to a reader: it says "The PM". */
|
|
101
|
+
export const NO_ORIGIN = 'Not recorded';
|
|
102
|
+
const ORIGIN_ORDER = ['You', 'Teammates', 'Customers', 'PMOS', 'From the tracker'];
|
|
103
|
+
const roYou = (s) => (RO && s === 'You' ? 'The PM' : s);
|
|
104
|
+
export const originText = (r) => (r && r.origin && r.origin.label ? roYou(r.origin.label) : '');
|
|
105
|
+
export const originGroup = (r) => (r && r.origin && r.origin.group ? roYou(r.origin.group) : '');
|
|
106
|
+
const originPos = (g) => { const i = ORIGIN_ORDER.indexOf(g === 'The PM' ? 'You' : g); return i < 0 ? ORIGIN_ORDER.length : i; };
|
|
107
|
+
|
|
97
108
|
/* ── dates ───────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
98
109
|
export const day = (v) => { if (v instanceof Date) return new Date(v.getFullYear(), v.getMonth(), v.getDate()); const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
99
110
|
const today = (now) => day(now || new Date());
|
|
@@ -149,14 +160,16 @@ export function groupsOf(rows, by, o = {}) {
|
|
|
149
160
|
stage: (r) => stageText(r),
|
|
150
161
|
status: (r) => statusText(r),
|
|
151
162
|
program: (r) => (o.programOf && o.programOf(r)) || '',
|
|
163
|
+
origin: (r) => originGroup(r),
|
|
152
164
|
}[by];
|
|
153
165
|
if (!keyOf) return null;
|
|
154
|
-
const none = { goal: 'No goal yet', product: 'No product', stage: 'No stage', status: 'No status', program: 'No program' }[by];
|
|
166
|
+
const none = { goal: 'No goal yet', product: 'No product', stage: 'No stage', status: 'No status', program: 'No program', origin: NO_ORIGIN }[by];
|
|
155
167
|
const m = new Map();
|
|
156
168
|
for (const r of rows) { const k = keyOf(r) || ''; if (!m.has(k)) m.set(k, []); m.get(k).push(r); }
|
|
157
169
|
let G = [...m.entries()].map(([k, rs]) => ({ key: by + ':' + (k || '-'), name: k || none, rows: rs, empty: !k }));
|
|
158
170
|
if (by === 'stage') G.sort((a, b) => (a.empty - b.empty) || (Math.min(...a.rows.map(posOf)) - Math.min(...b.rows.map(posOf))));
|
|
159
171
|
else if (by === 'status') { const O = { 'To do': 0, 'In progress': 1, Done: 2 }; G.sort((a, b) => (O[a.name] ?? 9) - (O[b.name] ?? 9)); }
|
|
172
|
+
else if (by === 'origin') G.sort((a, b) => (a.empty - b.empty) || originPos(a.name) - originPos(b.name));
|
|
160
173
|
else G.sort((a, b) => a.empty - b.empty);
|
|
161
174
|
// one group that holds every row and names nothing (no goal yet anywhere) says nothing: the list is flat (zero is silence)
|
|
162
175
|
return G.length === 1 && G[0].empty ? null : G;
|
|
@@ -182,7 +195,7 @@ export function addSort(k) {
|
|
|
182
195
|
return write({ ...read(), sorts: S });
|
|
183
196
|
}
|
|
184
197
|
export const dropSort = (k) => write({ ...read(), sorts: read().sorts.filter((x) => x.k !== k) });
|
|
185
|
-
export const SORT_KEYS = [['title', 'Initiative'], ['stage', 'Stage'], ['date', 'Date'], ['ms', 'Next milestone'], ['status', 'Status'], ['product', 'Product'], ['program', 'Program']];
|
|
198
|
+
export const SORT_KEYS = [['title', 'Initiative'], ['stage', 'Stage'], ['date', 'Date'], ['ms', 'Next milestone'], ['status', 'Status'], ['product', 'Product'], ['program', 'Program'], ['origin', 'Raised by']];
|
|
186
199
|
const str = (v) => String(v || '~');
|
|
187
200
|
/** Stage order: the row's own workflow's place, else (no workflow on record) the lifecycle's order by name, so Discover comes before Build. */
|
|
188
201
|
const LIFE = ['triage', 'discover', 'discovery', 'plan', 'prioritize', 'build', 'deliver', 'monitor', 'evaluate', 'completed', 'closed'];
|
|
@@ -198,6 +211,7 @@ const SORTS = {
|
|
|
198
211
|
program: (a, b, o) => str(o.programOf && o.programOf(a)).localeCompare(str(o.programOf && o.programOf(b))),
|
|
199
212
|
goal: (a, b, o) => str(o.goalOf && o.goalOf(a)).localeCompare(str(o.goalOf && o.goalOf(b))),
|
|
200
213
|
wf: (a, b) => String(wfOf(a).name).localeCompare(String(wfOf(b).name)),
|
|
214
|
+
origin: (a, b) => originPos(originGroup(a) || '~') - originPos(originGroup(b) || '~') || str(originText(a)).localeCompare(str(originText(b))),
|
|
201
215
|
};
|
|
202
216
|
const sortRows = (rows, o) => {
|
|
203
217
|
const S = read().sorts.filter((x) => SORTS[x.k]); if (!S.length) return rows;
|
|
@@ -206,7 +220,7 @@ const sortRows = (rows, o) => {
|
|
|
206
220
|
|
|
207
221
|
/* ── filter (round 3): every facet takes several values; each value says how many rows it holds, and one that holds none is not shown.
|
|
208
222
|
* The filter lives for this page (the view is what PMOS remembers). ── */
|
|
209
|
-
const FACETS = [['need', 'Needs'], ['stage', 'Stage'], ['status', 'Status'], ['product', 'Product'], ['program', 'Program'], ['owner', 'Owner'], ['sprint', 'Sprint']];
|
|
223
|
+
const FACETS = [['need', 'Needs'], ['stage', 'Stage'], ['status', 'Status'], ['product', 'Product'], ['program', 'Program'], ['owner', 'Owner'], ['origin', 'Raised by'], ['sprint', 'Sprint']];
|
|
210
224
|
const NEEDS = [['you', 'Waits on you'], ['late', 'Late'], ['risk', 'At risk'], ['blocked', 'Blocked']];
|
|
211
225
|
const FL = Object.fromEntries(FACETS.map(([k]) => [k, new Set()]));
|
|
212
226
|
const RO_FACETS = new Set(['need', 'stage', 'status', 'product', 'program']); // a copy filters on what its table draws; never owner, sprint or "waits on you"
|
|
@@ -223,6 +237,7 @@ function valuesOf(r, k, o) {
|
|
|
223
237
|
if (k === 'product') { const v = o.product ? o.product(r) : r.product; return v ? [v] : []; }
|
|
224
238
|
if (k === 'program') return [(o.programOf && o.programOf(r)) || 'No program'];
|
|
225
239
|
if (k === 'owner') return [r.owner || 'No owner'];
|
|
240
|
+
if (k === 'origin') return [originGroup(r) || NO_ORIGIN];
|
|
226
241
|
if (k === 'sprint') return [...new Set((t.tickets || []).map((x) => x.sprint).filter(Boolean))];
|
|
227
242
|
return [];
|
|
228
243
|
}
|
|
@@ -238,6 +253,7 @@ export function facetsOf(rows, o = {}) {
|
|
|
238
253
|
if (k === 'need') vals = NEEDS.map(([x]) => vals.find((y) => y.v === x)).filter(Boolean);
|
|
239
254
|
else if (k === 'stage') { const rep = (v) => rows.find((r) => stageText(r) === v); vals.sort((a, b) => stageCmp(rep(a.v), rep(b.v))); }
|
|
240
255
|
else if (k === 'sprint') vals.sort((a, b) => String(b.v).localeCompare(String(a.v), undefined, { numeric: true }));
|
|
256
|
+
else if (k === 'origin') vals.sort((a, b) => originPos(a.v) - originPos(b.v));
|
|
241
257
|
else vals.sort((a, b) => b.n - a.n || String(a.v).localeCompare(String(b.v)));
|
|
242
258
|
// a value that is on but holds no row now stays, so it can be taken off
|
|
243
259
|
for (const v of FL[k]) if (!vals.some((y) => y.v === v)) vals.push({ v, word: k === 'need' ? needWord(v) : v, n: 0, on: true });
|
|
@@ -260,7 +276,8 @@ export function showingHtml(hidden) {
|
|
|
260
276
|
const and = (k) => [...FL[k]].map((v) => (k === 'need' ? needWord(v) : v)).join(k === 'need' ? ' or ' : ' and ');
|
|
261
277
|
const what = ['need', 'stage', 'status', 'sprint'].filter((k) => FL[k].size).map(and).join(' · ') || (Q ? 'the initiatives named “' + Q + '”' : 'the initiatives');
|
|
262
278
|
const of = ['product', 'program'].filter((k) => FL[k].size).map(and).join(' · '), by = FL.owner.size ? and('owner') : '';
|
|
263
|
-
|
|
279
|
+
const from = FL.origin.size ? [...FL.origin].map((v) => (v === NO_ORIGIN ? 'nobody on record' : v === 'You' ? 'you' : v)).join(' or ') : '';
|
|
280
|
+
return `<div class="wk-showing" role="status"><span>Showing ${esc(what)}${of ? ' of ' + esc(of) : ''}${by ? ' owned by ' + esc(by) : ''}${from ? ' raised by ' + esc(from) : ''}</span>${hidden ? `<span class="q">· ${hidden} hidden</span>` : ''}<span class="q">·</span><button type="button" class="wk-sa" data-wkclear>Show all</button></div>`;
|
|
264
281
|
}
|
|
265
282
|
|
|
266
283
|
/* ── the timeline's window ───────────────────────────────────────────────────────────────────────────────────── */
|
|
@@ -323,6 +340,7 @@ function cellHtml(r, k, o) {
|
|
|
323
340
|
if (k === 'program') return `<td>${esc((o.programOf && o.programOf(r)) || '')}</td>`;
|
|
324
341
|
if (k === 'goal') return `<td>${esc((o.goalOf && o.goalOf(r)) || '')}</td>`;
|
|
325
342
|
if (k === 'wf') return `<td>${esc(wfOf(r).name)}</td>`;
|
|
343
|
+
if (k === 'origin') return `<td>${esc(originText(r))}</td>`; // none: an empty cell (zero is silence)
|
|
326
344
|
return '<td></td>';
|
|
327
345
|
}
|
|
328
346
|
const words = (r, keys, o) => keys.map((k) => {
|
|
@@ -334,6 +352,7 @@ const words = (r, keys, o) => keys.map((k) => {
|
|
|
334
352
|
if (k === 'program') return (o.programOf && o.programOf(r)) || '';
|
|
335
353
|
if (k === 'goal') return (o.goalOf && o.goalOf(r)) || '';
|
|
336
354
|
if (k === 'wf') return wfOf(r).name;
|
|
355
|
+
if (k === 'origin') return originText(r) ? 'raised by ' + originText(r) : '';
|
|
337
356
|
return '';
|
|
338
357
|
}).filter(Boolean).join(', ');
|
|
339
358
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "who-raised-each-idea (bet A445): who raised each initiative. The parser and rule (lib/initiative-origin.js), the writer's raised_by line, pmos initiative raised-by, the coverage number, the Board row and the Work list's Raised by column, group, sort and filter (public/pm/bd-work.js). No browser.",
|
|
3
|
+
"modules": ["initiative-origin.test.js"],
|
|
4
|
+
"seconds": { "initiative-origin.test.js": 4 }
|
|
5
|
+
}
|