create-pmos 0.565.0 → 0.566.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.
Files changed (48) hide show
  1. package/package.json +20 -14
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/gate-initiative.sh +6 -3
  6. package/payload/scripts/workflow-state.js +18 -7
  7. package/payload/state/discoveries.md +1 -1
  8. package/workspace/changelog.json +19 -0
  9. package/workspace/fixtures/initiatives-api/list.json +2 -1
  10. package/workspace/guide/cli.md +2 -2
  11. package/workspace/guide/initiatives-and-next-steps.md +4 -4
  12. package/workspace/guide/jira.md +3 -1
  13. package/workspace/lib/agent-team.js +1 -1
  14. package/workspace/lib/description-props.js +53 -2
  15. package/workspace/lib/engine/workflow-state.js +18 -7
  16. package/workspace/lib/grill-cli.js +4 -4
  17. package/workspace/lib/impact-cli.js +3 -3
  18. package/workspace/lib/initiative-cli.js +7 -4
  19. package/workspace/lib/jira-cli.js +2 -0
  20. package/workspace/lib/jira-tickets.js +78 -5
  21. package/workspace/lib/lab-cli.js +1 -1
  22. package/workspace/lib/lead-cli.js +1 -1
  23. package/workspace/lib/measure-cli.js +13 -7
  24. package/workspace/lib/measurements.js +34 -11
  25. package/workspace/lib/metrics-cli.js +4 -4
  26. package/workspace/lib/outcomes-cli.js +2 -2
  27. package/workspace/lib/program-cli.js +2 -2
  28. package/workspace/lib/propose-cli.js +2 -2
  29. package/workspace/lib/report-draft.js +5 -5
  30. package/workspace/lib/report-engine.js +1 -1
  31. package/workspace/lib/routes-artefacts.js +3 -2
  32. package/workspace/lib/routes-board-premium.js +2 -0
  33. package/workspace/lib/routes-initiatives.js +1 -1
  34. package/workspace/lib/routes-stage-tools.js +1 -1
  35. package/workspace/lib/team-cli.js +4 -1
  36. package/workspace/lib/today-cli.js +1 -1
  37. package/workspace/lib/vendor/scripts/workflow-state.js +18 -7
  38. package/workspace/lib/work-kind.js +16 -4
  39. package/workspace/package-lock.json +2 -2
  40. package/workspace/package.json +1 -1
  41. package/workspace/public/pm/bd-asks.js +1 -1
  42. package/workspace/public/pm/bd-ini-panel.js +1 -1
  43. package/workspace/public/pm/bd-next.js +9 -5
  44. package/workspace/public/pm/bd-views.js +1 -1
  45. package/workspace/public/pm/ini-agent.js +14 -7
  46. package/workspace/public/pm/premium-board.js +1 -1
  47. package/workspace/public/pm/work-kind.js +10 -6
  48. package/workspace/skills/measure.skill +6 -6
@@ -2,7 +2,9 @@
2
2
  /* jira-tickets.js — Jira tickets drafted from the PRD in the PM's template, selected by the PM, then pushed (initiative
3
3
  * jira-wbs, PRD J1 to J10 and J12, proposed D88).
4
4
  *
5
- * items(root, initiative) → { items, sources, prd } J1: the ticket items of the PRD and story files
5
+ * items(root, initiative) → { items, sources, prd, from } J1: the ticket items of the PRD and story files;
6
+ * with none, the done test's checks (D107), else the initiative's open tasks
7
+ * (launch simulation W4). `from` is 'prd', 'done-test' or 'tasks'.
6
8
  * fromItem(item, prd) → a ticket J2: one item in the PM's template
7
9
  * draft(root, initiative, opts) → the merged draft, written J3: new items added, unedited ones redrafted
8
10
  * view(root, initiative) → what the tab draws J4, J5, J10, J12
@@ -213,6 +215,65 @@ function readPrd(root, prd) {
213
215
  try { return fs.readFileSync(path.join(root, prd), 'utf8'); } catch { /* the main tree */ }
214
216
  try { return fs.readFileSync(path.join(mainRoot(root), prd), 'utf8'); } catch { return null; }
215
217
  }
218
+ /** The checks of a done test (D107): its table rows `| n | check | how |`, else its top-level bullets. → [{ n, check, how }] */
219
+ function checksInDoneTest(text) {
220
+ const lines = stripFm(text).split('\n');
221
+ const out = [];
222
+ for (const l of lines) {
223
+ const m = /^\|\s*(\d+)\s*\|\s*(.+?)\s*\|\s*(.*?)\s*\|?\s*$/.exec(l);
224
+ if (m && m[2] && !/^-+$/.test(m[2])) out.push({ n: Number(m[1]), check: m[2].replace(/\\\|/g, '|'), how: m[3] || '' });
225
+ }
226
+ if (out.length) return out;
227
+ let n = 0;
228
+ for (const l of lines) {
229
+ const b = /^[-*] (?:\[[ xX]\] )?(.+)$/.exec(l);
230
+ if (b) out.push({ n: ++n, check: b[1].trim(), how: '' });
231
+ }
232
+ return out;
233
+ }
234
+ /** The done test a record names, read from the worktree or the main tree (a kit repository may name it under pmos/). */
235
+ function readDoneTest(root, rfm) {
236
+ const p = rfm && isStr(rfm.done_test_path) ? rfm.done_test_path.trim() : '';
237
+ if (!p) return null;
238
+ for (const base of [root, mainRoot(root)]) {
239
+ for (const rel of [p, path.join('pmos', p)]) {
240
+ const abs = path.resolve(base, rel);
241
+ if (abs !== path.resolve(base) && !abs.startsWith(path.resolve(base) + path.sep)) continue;
242
+ try { return { path: path.relative(mainRoot(root), abs).split(path.sep).join('/') || rel, text: fs.readFileSync(abs, 'utf8') }; } catch { /* next */ }
243
+ }
244
+ }
245
+ return null;
246
+ }
247
+ /** One ticket item per done-test check: the check is the requirement, and how to check it is the acceptance. */
248
+ function itemsFromDoneTest(dt, title) {
249
+ return checksInDoneTest(dt.text).map((c) => {
250
+ const check = oneLine(c.check);
251
+ return {
252
+ id: `DT-${String(c.n).padStart(2, '0')}`, title: clip(check.replace(/\.$/, ''), 120), epic: null, refLabel: 'Done test', source: dt.path,
253
+ body: [`### User Story`, `As the PM of ${title}, I want this check of the done test to pass: ${check}`,
254
+ `### Functional Requirements`, check,
255
+ `### Acceptance Criteria`, `- ${check}`, ...(c.how ? [`- How to check: ${oneLine(c.how)}`] : [])].join('\n'),
256
+ };
257
+ });
258
+ }
259
+ /** One ticket item per open task of the initiative (its breakdown in plan-items.jsonl), in breakdown order. */
260
+ function itemsFromTasks(root, initiative, title) {
261
+ let fold;
262
+ try { fold = planItems.readFold(root, { now: 0 }); } catch { return []; }
263
+ const rel = path.relative(mainRoot(root), planItems.ledgerPath(root)).split(path.sep).join('/');
264
+ return (fold.order || []).map((id) => fold.items[id]).filter((it) => it && it.initiative === initiative && it.state !== 'done' && !it.proposed)
265
+ .map((it) => {
266
+ const what = oneLine(it.title);
267
+ const note = oneLine(it.note || '');
268
+ return {
269
+ id: `TK-${slug(what)}`, title: clip(what, 120), epic: null, refLabel: 'Task', source: rel, task: it.id,
270
+ body: [`### User Story`, `As the PM of ${title}, I want this task done: ${what}`,
271
+ ...(note ? [`### Additional Context`, note] : []),
272
+ `### Functional Requirements`, what,
273
+ `### Acceptance Criteria`, `- ${what}${it.due ? ` by ${it.due}` : ''}`].join('\n'),
274
+ };
275
+ });
276
+ }
216
277
  function items(root, initiative) {
217
278
  const fm = recordFm(root, initiative);
218
279
  if (!fm) return { ok: false, error: `no initiative ${initiative} in this repository` };
@@ -237,6 +298,18 @@ function items(root, initiative) {
237
298
  for (const x of s) x.source = rel;
238
299
  if (s.length) { found.push(...s); sources.push(rel); }
239
300
  }
301
+ // D107: no PRD stories section. The done test says what must be true, else the breakdown says what to do (launch simulation W4).
302
+ let from = found.length ? 'prd' : null;
303
+ const title = oneLine(fm.title || initiative);
304
+ if (!found.length) {
305
+ const dt = readDoneTest(root, fm);
306
+ const s = dt ? itemsFromDoneTest(dt, title) : [];
307
+ if (s.length) { found.push(...s); sources.push(dt.path); from = 'done-test'; }
308
+ }
309
+ if (!found.length) {
310
+ const s = itemsFromTasks(root, initiative, title);
311
+ if (s.length) { found.push(...s); sources.push(s[0].source); from = 'tasks'; }
312
+ }
240
313
  // Ids: the item's own (TD-01, S3) or a slug of its title; a repeat gets -2, -3.
241
314
  const seen = new Map();
242
315
  for (const s of found) {
@@ -248,7 +321,7 @@ function items(root, initiative) {
248
321
  s.epic = s.epic || null;
249
322
  s.hash = sha(s.title + '\n' + s.body + (s.epic ? '\n' + s.epic : ''));
250
323
  }
251
- return { ok: true, initiative, items: found, sources, prd: prd || null };
324
+ return { ok: true, initiative, items: found, sources, prd: prd || null, from };
252
325
  }
253
326
 
254
327
  // ── J2 · one item in the PM's template ─────────────────────────────────────────────────────────────
@@ -307,7 +380,7 @@ function fromItem(item, prd) {
307
380
  if (k === 'refs') continue;
308
381
  for (const l of lines) for (const m of l.matchAll(LINK_RE)) if (!own.includes(m[0]) && !links.includes(m[0])) links.push(m[0]);
309
382
  }
310
- const refs = [prd ? `- PRD: \`${prd}\` · ${item.id}` : `- Item: ${item.id}`];
383
+ const refs = [prd ? `- ${item.refLabel || 'PRD'}: \`${prd}\` · ${item.task || item.id}` : `- Item: ${item.id}`];
311
384
  if (own) refs.push(own);
312
385
  for (const l of links) refs.push(`- ${l}`);
313
386
  t.sections.refs = refs.join('\n');
@@ -414,7 +487,7 @@ function anchorOf(rfm) {
414
487
  function draft(root, initiative, { dryRun = false, now } = {}) {
415
488
  const st = items(root, initiative);
416
489
  if (!st.ok) return st;
417
- if (!st.items.length) return { ok: false, error: `no ticket items found for ${initiative} — add a "User stories" or "Tickets" section to its PRD${st.prd ? ` (${st.prd})` : ''}, one subheading per ticket, such as "### TD-01 · Title"` };
490
+ if (!st.items.length) return { ok: false, error: `no ticket items found for ${initiative} — add a "User stories" or "Tickets" section to its PRD${st.prd ? ` (${st.prd})` : ''}, one subheading per ticket, such as "### TD-01 · Title"; or give it a done test (done_test_path) with its checks, or tasks (pmos item)` };
418
491
  const old = readDraft(root, initiative);
419
492
  const prev = old ? old.tickets : [];
420
493
  const byId = new Map(prev.map((t) => [t.id, t]));
@@ -447,7 +520,7 @@ function draft(root, initiative, { dryRun = false, now } = {}) {
447
520
  fm.epic_mode = anchor ? 'existing' : 'new';
448
521
  if (anchor && !fm.epic) fm.epic = anchor;
449
522
  }
450
- const result = { ok: true, initiative, draft: draftRel(root, initiative), sources: st.sources, tickets: out.length, changes, changed: !old || changes.length > 0 };
523
+ const result = { ok: true, initiative, draft: draftRel(root, initiative), sources: st.sources, from: st.from, tickets: out.length, changes, changed: !old || changes.length > 0 };
451
524
  if (dryRun || (old && !changes.length)) return result;
452
525
  writeDraft(root, initiative, { fm, tickets: out }, { now, prd: st.prd });
453
526
  return result;
@@ -17,7 +17,7 @@ const E = require('./idle-lab-engine.js');
17
17
  const COMMANDS = { lab: ['page', 'file', 'status'] };
18
18
  const GROUPS = { 'prototype-new': ['prototyped'], 'prototype-improve': ['improved'], 'scan-new': ['scanned', 'scan'], 'scan-improve': ['scanned', 'scan'] };
19
19
  const USAGE = [
20
- 'usage: pmos lab page|file|status — the idle lab: Claude prototypes and scans while you are away; each result waits under ✦ for your ✓',
20
+ 'usage: pmos lab page|file|status — the idle lab: PMOS prototypes and scans while you are away; each result waits under ✦ for your ✓',
21
21
  ' pmos lab page <url> (scan run) read one public page; it prints the page with line numbers',
22
22
  ' pmos lab page <n> [--from <line>] (scan run) print page n of this run again, from a line',
23
23
  ' pmos lab file prototyped --json - { "title", "why", "specimens": [{ "key": "A", "title", "caption", "file": "a.html" }] (2 or 3),',
@@ -12,7 +12,7 @@ const SR = require('./source-reads.js');
12
12
 
13
13
  const COMMANDS = { lead: ['put', 'show', 'due'] };
14
14
  const USAGE = [
15
- 'usage: pmos lead put|show|due — Claude\'s short lead for a popup, written ahead and shown first',
15
+ 'usage: pmos lead put|show|due — PMOS\'s short lead for a popup, written ahead and shown first',
16
16
  ' pmos lead put --key <pop:kind:id> --text "<lead>" [--cite "<what you read, when>"] …',
17
17
  ' the lead: why it matters now, what is asked or blocking, and what to do, in at most 400 characters; at most 4 cites',
18
18
  ' pmos lead show [<key>] the stored lead of one popup, or every stored lead',
@@ -2,13 +2,14 @@
2
2
  /* measure-cli.js — `pmos measure …`: record a measured value of a KR or a health budget, with its source (pm-os-absorb
3
3
  * Run 2, PRD R17, R23, R24).
4
4
  *
5
- * pmos measure add <anchor> <value> --source <path>@<sha> [--target <number>] [--unit <unit>] [--as-of YYYY-MM-DD]
5
+ * pmos measure add <anchor> <value> --source <path>@<sha>|connector:<name>|document:<path or link> [--how "<how it was read>"]
6
+ * [--target <number>] [--unit <unit>] [--as-of YYYY-MM-DD]
6
7
  * pmos measure list [<anchor>]
7
8
  * every command: [--json] [--root <dir>]
8
9
  *
9
10
  * The SAME writer the workspace page uses (lib/measurements.js). A measurement is evidence, not a PM act, so an agent
10
11
  * may write one: the line is attributed by lib/actor.js fromCli (the PM at a terminal, the bound agent session from
11
- * PMOS_SESSION, `agent:unknown` otherwise). The source is required: the workspace never computes a KR value, so a
12
+ * PMOS_SESSION, `agent:unknown` otherwise). The source is required, and a connector or document source needs --how: the workspace never computes a KR value, so a
12
13
  * group shows a value only from a line that says where it was read. `--as-of` is today (UTC) when it is not given.
13
14
  * Exit codes: 0 done, 1 refused, 2 usage.
14
15
  */
@@ -21,14 +22,18 @@ const { parseArgs } = require('./schedule-cli');
21
22
  const COMMANDS = { measure: ['add', 'list'] };
22
23
  const USAGE = [
23
24
  'usage: pmos measure add|list — measured values of KRs and health budgets',
24
- ' pmos measure add <anchor> <value> --source <path>@<sha> [--target <number>] [--unit <unit>] [--as-of YYYY-MM-DD]',
25
+ ' pmos measure add <anchor> <value> --source <source> [--how "<how it was read>"] [--target <number>] [--unit <unit>] [--as-of YYYY-MM-DD]',
25
26
  ' pmos measure list [<anchor>]',
26
27
  ' every command: [--json] [--root <dir>]',
27
28
  'The anchor is the parent_kr an initiative names: a KR such as "KR 2.1", or health:<id>. Quote an anchor with a space.',
28
- 'The source is the file the value was read from and the commit it was read at, for example planning/okrs/q4.md@1a2b3c4.',
29
+ 'The source is where the value was read:',
30
+ ' <path>@<sha> a file in this repository at a commit, for example planning/okrs/q4.md@1a2b3c4',
31
+ ' connector:<name> an analytics tool or tracker read through a connector, for example connector:amplitude',
32
+ ' document:<path or link> a shared document or sheet outside the repository',
33
+ 'A connector or document source needs --how: the query, chart or cell, so the value can be read again. --as-of is the day it was read.',
29
34
  ];
30
35
  const BOOL = new Set(['json', 'help']);
31
- const VALUE = new Set(['source', 'target', 'unit', 'as-of', 'root']);
36
+ const VALUE = new Set(['source', 'how', 'target', 'unit', 'as-of', 'root']);
32
37
 
33
38
  function parse(argv) {
34
39
  const rest = []; const bools = {};
@@ -70,7 +75,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
70
75
  if (json) { say(JSON.stringify({ ok: true, byAnchor: Object.fromEntries(anchors.map((a) => [a, (m.byAnchor[a] || []).map((x) => ({ ...x, by: actorLib.pageName(x.by) }))])), flags: m.flags })); return 0; }
71
76
  if (!anchors.length) say('No measurements yet.');
72
77
  for (const a of anchors) {
73
- for (const x of m.byAnchor[a] || []) say(`${a} · ${x.value}${x.unit || ''}${x.target === null ? '' : ` → ${x.target}${x.unit || ''}`} on ${x.as_of} · ${x.source} · ${actorLib.pageName(x.by)}`);
78
+ for (const x of m.byAnchor[a] || []) say(`${a} · ${x.value}${x.unit || ''}${x.target === null ? '' : ` → ${x.target}${x.unit || ''}`} on ${x.as_of} · ${x.source}${x.how ? ` (${x.how})` : ''} · ${actorLib.pageName(x.by)}`);
74
79
  }
75
80
  for (const f of m.flags) say(`! ${f.why}`);
76
81
  return 0;
@@ -89,11 +94,12 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
89
94
  if (flags.unit !== undefined) ev.unit = flags.unit;
90
95
  ev.as_of = flags['as-of'] || new Date(now == null ? Date.now() : now).toISOString().slice(0, 10);
91
96
  if (flags.source !== undefined) ev.source = flags.source;
97
+ if (flags.how !== undefined) ev.how = String(flags.how).trim();
92
98
  const actor = actorLib.fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env });
93
99
  const r = measurements.appendFromCli(root, [ev], { actor, now });
94
100
  if (!r.ok) return fail(r.error);
95
101
  if (json) say(JSON.stringify({ ok: true, written: r.written, eid: r.lines[0].eid }));
96
- else say(`✓ ${anchor}: ${value}${ev.unit || ''} on ${ev.as_of} recorded (source ${ev.source})`);
102
+ else say(`✓ ${anchor}: ${value}${ev.unit || ''} on ${ev.as_of} recorded (source ${ev.source}${ev.how ? `, ${ev.how}` : ''})`);
97
103
  return 0;
98
104
  }
99
105
 
@@ -4,13 +4,15 @@
4
4
  *
5
5
  * readMeasurements(root) → {
6
6
  * ok: true,
7
- * byAnchor: { [anchor]: [{ value, target, unit, as_of, source, by, at }] }, oldest first; `source` is "path@sha"
7
+ * byAnchor: { [anchor]: [{ value, target, unit, as_of, source, how, by, at }] }, oldest first; `source` is "path@sha",
8
+ * "connector:<name>" or "document:<path or link>"; `how` is null for path@sha
8
9
  * flags: [{ kind, eid, why }],
9
10
  * }
10
11
  * latest(result, anchor) → the newest measurement of `anchor` by as_of, or null
11
12
  * appendFromUi(root, events, { actor, now }) → { ok, written, lines } | { ok: false, status, error, index }
12
13
  * appendFromCli(root, events, { actor, now }) → the same
13
14
  * checkEvent(ev) → null | error text the caller-side checks, shared with `pmos measure`
15
+ * sourceKind(source) → 'repo' | 'connector' | 'document' | null
14
16
  *
15
17
  * `anchor` is the initiative's parent_kr as written (a KR id, or `health:<id>`, D59). A measurement needs a source; an
16
18
  * agent may write one (it is evidence, not a PM act), so the actor comes from actor.js, never from the caller.
@@ -18,12 +20,18 @@
18
20
  *
19
21
  * THE `measured` LINE (the shared contract):
20
22
  * { v: 1, eid, ev: 'measured', anchor, value: <number>, target: <number> | null, unit?: '%'|…, as_of: 'YYYY-MM-DD',
21
- * source: '<path>@<sha>', by, via, at }
23
+ * source: '<path>@<sha>' | 'connector:<name>' | 'document:<path or link>', how?: '<how it was read>', by, via, at }
22
24
  * pmOnly(rec) → false: a measurement is evidence, not a PM act.
23
25
  *
24
- * `source` is a repository-relative path, `@`, and a commit sha of 7 to 40 hex characters: the file the number was
25
- * read from, at the commit it was read at. The writer does not open it (no read outside the call's own checks), so a
26
- * wrong path is the writer's caller's error; scripts/check-measurements.js reports a path that is not in the tree.
26
+ * `source` is one of three kinds:
27
+ * repo a repository-relative path, `@`, and a commit sha of 7 to 40 hex characters: the file the number was read
28
+ * from, at the commit it was read at.
29
+ * connector `connector:<name>`: an analytics tool or tracker read through a connector (Amplitude, GA4, Jira, …).
30
+ * document `document:<path or link>`: a shared document or sheet outside the repository.
31
+ * A connector or document source carries `how`, one line on how the value was read (the query, the chart, the cell), so
32
+ * a reader can read it again; `as_of` is the date it was read. This matches `pmos report read` (launch simulation W4).
33
+ * The writer does not open a source (no read outside the call's own checks), so a wrong path is the writer's caller's
34
+ * error; scripts/check-measurements.js reports a path that is not in the tree.
27
35
  *
28
36
  * The fold is order-free, like lib/plan-items.js: byte-identical duplicates count once, one eid with two contents keeps
29
37
  * the first. The ledger is one per repository: lib/plan-ledgers.js ledgerPath(root, 'measurements'). Nothing is cached.
@@ -42,9 +50,12 @@ const AT_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;
42
50
  /** A KR id as the OKR files write it, or a health budget or a domain (D59, D67). One line, no control characters. */
43
51
  const ANCHOR_RE = /^(?:health:[a-z0-9][a-z0-9-]{0,59}|domain:[a-z0-9][a-z0-9-]{0,59}|[A-Za-z0-9][A-Za-z0-9 .:_-]{0,79})$/;
44
52
  const SOURCE_RE = /^([A-Za-z0-9_][A-Za-z0-9_./-]{0,239})@([0-9a-f]{7,40})$/;
53
+ const CONNECTOR_RE = /^connector:([A-Za-z0-9][A-Za-z0-9 ._-]{0,59})$/;
54
+ const DOCUMENT_RE = /^document:([^\x00-\x1f\x7f]{1,300})$/;
55
+ const HOW_RE = /^[^\x00-\x1f\x7f]{1,200}$/;
45
56
  const UNIT_RE = /^[^\s\x00-\x1f]{1,12}$/;
46
57
  const WRITER_SET = Object.freeze(['v', 'eid', 'by', 'via', 'at', 'override', 'pm', 'actor', 'nonce']);
47
- const CALLER_KEYS = Object.freeze(['anchor', 'value', 'target', 'unit', 'as_of', 'source']);
58
+ const CALLER_KEYS = Object.freeze(['anchor', 'value', 'target', 'unit', 'as_of', 'source', 'how']);
48
59
  const STORED_KEYS = Object.freeze(['v', 'eid', 'ev', 'by', 'via', 'at', ...CALLER_KEYS]);
49
60
  const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
50
61
 
@@ -73,6 +84,15 @@ function parseSource(s) {
73
84
  return { path: m[1], sha: m[2] };
74
85
  }
75
86
 
87
+ /** 'repo' (path@sha), 'connector' (connector:<name>), 'document' (document:<path or link>), or null. */
88
+ function sourceKind(s) {
89
+ if (!isStr(s) || s !== s.trim()) return null;
90
+ if (parseSource(s)) return 'repo';
91
+ if (CONNECTOR_RE.test(s)) return 'connector';
92
+ const d = DOCUMENT_RE.exec(s);
93
+ return d && d[1].trim() ? 'document' : null;
94
+ }
95
+
76
96
  /** The checks on what a caller sends (the writer runs them; `pmos measure` runs them before it writes). */
77
97
  function checkEvent(ev) {
78
98
  if (!ev || typeof ev !== 'object' || Array.isArray(ev)) return 'each line must be a JSON object';
@@ -86,8 +106,11 @@ function checkEvent(ev) {
86
106
  if (has(ev, 'target') && ev.target !== null && (typeof ev.target !== 'number' || !Number.isFinite(ev.target))) return 'target must be a number, or null';
87
107
  if (has(ev, 'unit') && !(isStr(ev.unit) && UNIT_RE.test(ev.unit))) return 'unit must be a short word with no spaces, like %';
88
108
  if (!dateOk(ev.as_of)) return 'as_of must be YYYY-MM-DD';
89
- if (!has(ev, 'source') || ev.source === '' || ev.source == null) return 'a measurement needs a source: <path>@<commit sha>';
90
- if (!parseSource(ev.source)) return 'source must be <repository-relative path>@<commit sha of 7 to 40 hex characters>';
109
+ if (!has(ev, 'source') || ev.source === '' || ev.source == null) return 'a measurement needs a source: <path>@<commit sha>, connector:<name> or document:<path or link>';
110
+ const kind = sourceKind(ev.source);
111
+ if (!kind) return 'source must be <repository-relative path>@<commit sha of 7 to 40 hex characters>, connector:<name> or document:<path or link>';
112
+ if (has(ev, 'how') && !(isStr(ev.how) && HOW_RE.test(ev.how) && ev.how.trim() === ev.how)) return 'how must be one line of at most 200 characters';
113
+ if (kind !== 'repo' && !has(ev, 'how')) return `a ${kind} source needs how the value was read (the query, chart or cell), so it can be read again`;
91
114
  return null;
92
115
  }
93
116
 
@@ -127,7 +150,7 @@ function readMeasurements(root) {
127
150
  seen.set(rec.eid, text);
128
151
  (out.byAnchor[rec.anchor] = out.byAnchor[rec.anchor] || []).push({
129
152
  value: rec.value, target: Number.isFinite(rec.target) ? rec.target : null, unit: rec.unit || null,
130
- as_of: rec.as_of, source: rec.source, by: rec.by, at: rec.at,
153
+ as_of: rec.as_of, source: rec.source, how: isStr(rec.how) ? rec.how : null, by: rec.by, at: rec.at,
131
154
  });
132
155
  }
133
156
  for (const rows of Object.values(out.byAnchor)) rows.sort((a, b) => String(a.as_of).localeCompare(String(b.as_of)) || String(a.at).localeCompare(String(b.at)));
@@ -164,7 +187,7 @@ function append(root, events, actor, { now } = {}) {
164
187
  last = Math.max(clock, last + 1);
165
188
  const rec = { v: 1, eid: newEventId(), ev: 'measured', anchor: ev.anchor, value: ev.value, target: has(ev, 'target') ? ev.target : null };
166
189
  if (has(ev, 'unit')) rec.unit = ev.unit;
167
- Object.assign(rec, { as_of: ev.as_of, source: ev.source, by: actor.by, via: actor.via, at: new Date(last).toISOString() });
190
+ Object.assign(rec, { as_of: ev.as_of, source: ev.source }, has(ev, 'how') ? { how: ev.how } : {}, { by: actor.by, via: actor.via, at: new Date(last).toISOString() });
168
191
  return rec;
169
192
  });
170
193
  let file;
@@ -186,4 +209,4 @@ function appendFromUi(root, events, { actor, now } = {}) { return append(root, e
186
209
  /** `pmos measure` (actor.fromCli's actor; an agent may write a measurement). */
187
210
  function appendFromCli(root, events, { actor, now } = {}) { return append(root, events, actor, { now }); }
188
211
 
189
- module.exports = { MAX_LINES, readMeasurements, latest, pmOnly, checkEvent, parseSource, lineErr, appendFromUi, appendFromCli };
212
+ module.exports = { MAX_LINES, readMeasurements, latest, pmOnly, checkEvent, parseSource, sourceKind, lineErr, appendFromUi, appendFromCli };
@@ -31,7 +31,7 @@ const MR = require('./metric-reads.js');
31
31
  const COMMANDS = { metrics: ['draft', 'reading'] };
32
32
  const SUBS = ['read', 'step', 'row', 'fix', 'end', 'status'];
33
33
  const USAGE = [
34
- 'usage: pmos metrics draft read|step|row|end|status — the metrics Claude drafts for the PM to keep or drop',
34
+ 'usage: pmos metrics draft read|step|row|end|status — the metrics PMOS drafts for the PM to keep or drop',
35
35
  ' pmos metrics draft read "<source>" --found "<what it says, one line>" [--state done|now|wait]',
36
36
  ' pmos metrics draft step shape|measure|target|ready',
37
37
  ' pmos metrics draft row --json <file|->',
@@ -59,7 +59,7 @@ function reading(args, { say, env, now }) {
59
59
  const file = env.PMOS_METRIC_READ_FILE, runId = env.PMOS_METRIC_READ_RUN, root = env.PMOS_METRIC_READ_RECORDS, ws = env.PMOS_METRIC_READ_WS;
60
60
  const rids = String(env.PMOS_METRIC_READ_RIDS || '').split(',').filter(Boolean), test = !!env.PMOS_METRIC_READ_TEST;
61
61
  if (!args[0] || ['help', '--help', '-h'].includes(args[0])) { for (const l of USAGE.filter((x) => /reading|Every/.test(x))) say(l); return args[0] ? 0 : 1; }
62
- if (!file || !runId || !rids.length || (!test && !root)) { say('✗ pmos metrics reading is for Claude\'s reading run. The PM adds a reading on the goal\'s page.'); return 1; }
62
+ if (!file || !runId || !rids.length || (!test && !root)) { say('✗ pmos metrics reading is for PMOS\'s reading run. The PM adds a reading on the goal\'s page.'); return 1; }
63
63
  const F = MR.fold(MR.readLines(file)), R = F.runs.get(runId);
64
64
  if (!R || R.ended) { say('✗ this run is not reading now. It ended, or the PM pressed Stop. File nothing more.'); return 1; }
65
65
  const records = () => require(require('./repo-script.js').repoScript('records/index.js'));
@@ -156,7 +156,7 @@ function reading(args, { say, env, now }) {
156
156
  const L = require(require('./repo-script.js').repoScript('trust/ledger.js'));
157
157
  const actor = L.actorFrom({ env, isTTY: !!(process.stdout && process.stdout.isTTY) }) || { by: 'claude-code/metric-read', via: 'cli' };
158
158
  const reading = { at: day, value: v, source: src, via: R.why === 'press' ? 'press' : 'run', read_at: at, ...(num !== undefined ? { num } : {}), ...(den !== undefined ? { den } : {}), ...(period ? { period } : {}) };
159
- let r; try { r = records().addReading(root, rid, reading, actor, R.why === 'press' ? 'Claude read it now, as the PM asked' : 'Claude read it with its recipe'); } catch (e) { r = { ok: false, reasons: [String((e && e.message) || e).slice(0, 160)] }; }
159
+ let r; try { r = records().addReading(root, rid, reading, actor, R.why === 'press' ? 'PMOS read it now, as the PM asked' : 'PMOS read it with its recipe'); } catch (e) { r = { ok: false, reasons: [String((e && e.message) || e).slice(0, 160)] }; }
160
160
  if (!r.ok) { say('✗ refused: ' + r.reasons.join('; ')); return 1; }
161
161
  }
162
162
  lineOut({ kind: 'read', value: v, day, source: src, ...extra });
@@ -179,7 +179,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
179
179
  if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
180
180
  if (!SUBS.includes(sub)) { say(`unknown draft command "${sub}". Use one of: ${SUBS.join(', ')}`); return 2; }
181
181
  const file = env.PMOS_METRIC_DRAFT_FILE, runId = env.PMOS_METRIC_DRAFT_RUN, scope = env.PMOS_METRIC_DRAFT_SCOPE, id = env.PMOS_METRIC_DRAFT_ID;
182
- if (!file || !runId || !MD.SCOPES.includes(scope) || !id) { say('✗ pmos metrics draft is for Claude\'s metric-draft run. The PM keeps and drops drafts on the page.'); return 1; }
182
+ if (!file || !runId || !MD.SCOPES.includes(scope) || !id) { say('✗ pmos metrics draft is for PMOS\'s metric-draft run. The PM keeps and drops drafts on the page.'); return 1; }
183
183
  const F = MD.fold(MD.readLines(file)), s = F.scopes.get(MD.keyOf(scope, id));
184
184
  const at = new Date(now).toISOString();
185
185
  const line = (ev) => { fs.appendFileSync(file, JSON.stringify({ at, by: null, scope, id, run: runId, ...ev }) + '\n'); };
@@ -24,7 +24,7 @@ const COMMANDS = { outcomes: ['list', 'propose', 'declare', 'record'] };
24
24
  const USAGE = [
25
25
  'usage: pmos outcomes list|propose|declare|record — every initiative has an expected outcome and a date to check it',
26
26
  ' pmos outcomes list [--json] checks due, outcomes with no date, initiatives with no outcome; reads only',
27
- ' pmos outcomes propose [<id>] [--max <n>] [--json] Claude\'s ✦ drafts from the PRD and the KR, each one cited',
27
+ ' pmos outcomes propose [<id>] [--max <n>] [--json] PMOS\'s ✦ drafts from the PRD and the KR, each one cited',
28
28
  ' pmos outcomes declare <id> --metric "<text>" --horizon <YYYY-MM-DD> the PM said yes: write the outcome and its check date',
29
29
  ' pmos outcomes record <id> <worked|didnt-work|cant-tell> --evidence "<text>" the PM\'s verdict on a due check',
30
30
  'Run it in the product\'s repository, or pass --root <dir>. Show each ✦ to the PM and write only after a yes.',
@@ -74,7 +74,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
74
74
  if (S.missing.length) say(`\n${S.missing.length} under way with no expected outcome${S.recent ? ` (${S.recent} edited in the last 30 days)` : ''}:\n` + S.missing.slice(0, 15).map((it) => ` ${it.id} — ${it.title}`).join('\n') + (S.missing.length > 15 ? `\n … and ${S.missing.length - 15} more (--json lists all)` : ''));
75
75
  if (S.shippedWithout) say(`\n${S.shippedWithout} accepted with no outcome: too late to declare, counted only.`);
76
76
  if (S.notRead.length) say('Not read: ' + S.notRead.join(', '));
77
- if (S.due.length || S.undated.length || S.missing.length) say('\nClaude drafts each one: pmos outcomes propose');
77
+ if (S.due.length || S.undated.length || S.missing.length) say('\nPMOS drafts each one: pmos outcomes propose');
78
78
  return 0;
79
79
  }
80
80
 
@@ -13,7 +13,7 @@ const MS = require('./milestone-suggest.js');
13
13
 
14
14
  const COMMANDS = { program: ['suggest'] };
15
15
  const USAGE = [
16
- 'usage: pmos program suggest — Claude\'s milestone suggestions for a program',
16
+ 'usage: pmos program suggest — PMOS\'s milestone suggestions for a program',
17
17
  ' pmos program suggest --json <file|->',
18
18
  ' File one suggestion (a JSON object) or a list of them, in a milestone review run only. Each one:',
19
19
  ' { "op": "add|move|rename|drop|risk", "milestone": "<id, not for add>", "name": "<add, rename>", "date": "YYYY-MM-DD (add, move)",',
@@ -30,7 +30,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
30
30
  const i = args.indexOf('--json'), src = i >= 0 ? args[i + 1] : null;
31
31
  if (!src) { say('usage: pmos program suggest --json <file|->'); return 2; }
32
32
  const file = env.PMOS_MS_REVIEW_FILE, runId = env.PMOS_MS_REVIEW_RUN, program = env.PMOS_MS_REVIEW_PROGRAM;
33
- if (!file || !runId || !program) { say('✗ pmos program suggest is for Claude\'s milestone review run. The PM changes milestones in the charter'); return 1; }
33
+ if (!file || !runId || !program) { say('✗ pmos program suggest is for PMOS\'s milestone review run. The PM changes milestones in the charter'); return 1; }
34
34
  let text;
35
35
  try { text = src === '-' ? (stdin !== undefined ? String(stdin) : fs.readFileSync(0, 'utf8')) : fs.readFileSync(src, 'utf8'); } catch (e) { say(`✗ could not read ${src}: ${String((e && e.message) || e).slice(0, 120)}`); return 1; }
36
36
  let body;
@@ -21,7 +21,7 @@ const LP = require('./loose-proposals.js');
21
21
 
22
22
  const COMMANDS = { propose: ['look', 'found', 'date', 'done', 'name', 'status', 'loose'] };
23
23
  const USAGE = [
24
- 'usage: pmos propose look|found|date|done|name|status — what Claude proposes on an initiative, under its ✦',
24
+ 'usage: pmos propose look|found|date|done|name|status — what PMOS proposes on an initiative, under its ✦',
25
25
  ' pmos propose look <source> --reading | --found <n> --what "<5 documents>" | --none',
26
26
  ' source: ' + PR.SOURCES.join(', ') + '. Say --reading when you start a source and --found or --none when you finish it.',
27
27
  ' pmos propose found <stage|docs|tasks|link|maybe|unplaced> --json <file|->',
@@ -88,7 +88,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
88
88
  if (!verb || verb === 'help' || verb === '--help' || verb === '-h') { for (const l of USAGE) say(l); return verb ? 0 : 1; }
89
89
  if (!COMMANDS.propose.includes(verb)) { say(`unknown propose command "${verb}" — one of ${COMMANDS.propose.join(', ')}`); return 2; }
90
90
  const file = env.PMOS_PROPOSE_FILE, runId = env.PMOS_PROPOSE_RUN, ini = env.PMOS_PROPOSE_INI, board = env.PMOS_PROPOSE_BOARD || '';
91
- if (!file || !runId || !ini) { say('✗ pmos propose is for Claude\'s proposal run. The PM keeps and drops proposals on the page, under the initiative\'s ✦'); return 1; }
91
+ if (!file || !runId || !ini) { say('✗ pmos propose is for PMOS\'s proposal run. The PM keeps and drops proposals on the page, under the initiative\'s ✦'); return 1; }
92
92
  if ((verb === 'loose') !== (ini === '~loose')) { say(verb === 'loose' ? '✗ pmos propose loose is for Home\'s clean-up run' : '✗ this is Home\'s clean-up run: file with pmos propose loose'); return 1; }
93
93
  if (verb === 'loose') return loose(args, { say, stdin, file, runId });
94
94
  const F = PR.fold(PR.readLines(file));
@@ -39,7 +39,8 @@
39
39
  * health from `health` (a function of the health ctx, or a map by id; tests inject it) else lib/health.js healthOf. An off-track or at-risk block with no reason
40
40
  * at its level refuses the whole draft (422);
41
41
  * - progress from plan-items (proposed items never count; an item the factory join marks integrated counts done);
42
- * a measured value only from a measurements line whose source is `<path>@<sha>` (no KR is computed here);
42
+ * a measured value only from a measurements line with a source the writer accepts (`<path>@<sha>`, or a connector or
43
+ * document with how it was read; no KR is computed here);
43
44
  * - the Timeline strip from item-spans.js, the PM's own acts under Decided this cycle (a pending proposal never),
44
45
  * Needs your call from the asks note, for the definition's audience only (X23), and the sources.
45
46
  * The definition `<state>/reports/definitions/<cadence>.md` gives `audience` and `sections` (readDefinition). Besides
@@ -100,7 +101,6 @@ const SLIDES_CLOSE = '-->';
100
101
  const FRAME = Object.freeze(['headline', 'timeline', 'initiatives', 'new', 'decided', 'needs', 'sources']);
101
102
  const CADENCE_RE = /^[a-z][a-z0-9-]{0,39}$/;
102
103
  const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
103
- const SOURCE_RE = /^[^@\s]+@[0-9a-f]{7,40}$/;
104
104
  const DAY = 86400000;
105
105
  const SEVERITY = { off: 3, 'at-risk': 2, unknown: 1, on: 0 };
106
106
  const LEVEL_WORD = { off: 'Off track', 'at-risk': 'At risk', unknown: 'Unknown', on: 'On track' };
@@ -336,7 +336,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
336
336
  || byText(String(a.createdAt), String(b.createdAt)) || byText(a.id, b.id));
337
337
  const dated = ordered.filter((it) => [it.start, it.due].some((d) => d && d >= today && d <= cycleEnd));
338
338
  const coming = dated.length ? { basis: 'dates', list: dated } : { basis: 'order', list: ordered.slice(0, 3) };
339
- const m = measurement && SOURCE_RE.test(String(measurement.source)) ? measurement : null;
339
+ const m = measurement && measurements.sourceKind(measurement.source) ? measurement : null;
340
340
 
341
341
  blocks.push({
342
342
  id, title: titleOf.get(id),
@@ -344,7 +344,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
344
344
  health: { level: h.level, reasons: h.reasons },
345
345
  progress: { done, total: real.length, delta: doneNow.length,
346
346
  label: real.length ? `${done} of ${real.length} (+${doneNow.length})` : planTree.progressLabel(0, 0, its.length - real.length) },
347
- measure: m ? { anchor: String(row.anchor).split(' ')[0], value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source } : null,
347
+ measure: m ? { anchor: String(row.anchor).split(' ')[0], value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source, how: m.how || null } : null,
348
348
  last_cycle: {
349
349
  done: doneNow.map((it) => ({ id: it.id, title: it.title })),
350
350
  gates,
@@ -549,7 +549,7 @@ function render(draft, { notes, name: given, purpose } = {}) {
549
549
  push(`### ${b.title} (${b.id})`, '');
550
550
  const reason = b.health.reasons.find((r) => r.level === b.health.level);
551
551
  push(`Stage: ${b.stage} · ${LEVEL_WORD[b.health.level]}${reason ? `: ${reason.text}` : ''} · ${b.progress.label}`);
552
- if (b.measure) push('', `Measured: ${b.measure.anchor} ${b.measure.value}${b.measure.unit || ''}${b.measure.target == null ? '' : ` of ${b.measure.target}${b.measure.unit || ''}`}, as of ${b.measure.as_of} (${b.measure.source})`);
552
+ if (b.measure) push('', `Measured: ${b.measure.anchor} ${b.measure.value}${b.measure.unit || ''}${b.measure.target == null ? '' : ` of ${b.measure.target}${b.measure.unit || ''}`}, as of ${b.measure.as_of} (${b.measure.source}${b.measure.how ? `, ${b.measure.how}` : ''})`);
553
553
  push('', '**Last cycle**', '');
554
554
  const lc = b.last_cycle;
555
555
  push(`- Done: ${lc.done.length ? lc.done.map((x) => `${x.title} (${x.id})`).join('; ') : 'none'}`);
@@ -341,7 +341,7 @@ function ledgerReadings(root, brief, now) {
341
341
  const base = `${b.id}`.toLowerCase().replace(/[^a-z0-9._-]/g, '-');
342
342
  if (b.progress && b.progress.total) out.push({ id: `${base}.done`, value: b.progress.done, of: b.progress.total, unit: 'items', at, source: 'pmos', how: 'plan items done of total', label: `${b.title}: items done` });
343
343
  if (b.health && b.health.level) out.push({ id: `${base}.health`, value: { off: 'off track', 'at-risk': 'at risk', unknown: 'unknown', on: 'on track' }[b.health.level] || b.health.level, at, source: 'pmos', how: 'lib/health.js', label: `${b.title}: health`, ...(b.health.level === 'off' || b.health.level === 'at-risk' ? { flag: (b.health.reasons || []).map((x) => x.text).join('; ') || b.health.level } : {}) });
344
- if (b.measure && typeof b.measure.value === 'number') out.push({ id: `${base}.${String(b.measure.anchor || 'kr').toLowerCase()}`, value: b.measure.value, unit: b.measure.unit || null, ...(typeof b.measure.target === 'number' ? { target: b.measure.target } : {}), at: b.measure.as_of || at, source: 'pmos', how: `measurement ${b.measure.source}`, label: `${b.title}: ${b.measure.anchor}` });
344
+ if (b.measure && typeof b.measure.value === 'number') out.push({ id: `${base}.${String(b.measure.anchor || 'kr').toLowerCase()}`, value: b.measure.value, unit: b.measure.unit || null, ...(typeof b.measure.target === 'number' ? { target: b.measure.target } : {}), at: b.measure.as_of || at, source: 'pmos', how: `measurement ${b.measure.source}${b.measure.how ? `, ${b.measure.how}` : ''}`, label: `${b.title}: ${b.measure.anchor}` });
345
345
  const carried = (b.last_cycle && b.last_cycle.carried) || [];
346
346
  const overdue = carried.filter((c) => c.due && c.due < brief.slot);
347
347
  if (overdue.length) out.push({ id: `${base}.overdue`, value: overdue.length, unit: 'items', at, source: 'pmos', how: 'carried plan items past their due date', label: `${b.title}: items overdue`, flag: overdue.map((c) => `${c.title}, due ${full(c.due)}`).join('; ') });
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
  /* routes-artefacts.js — the seven artefacts (R18, D107, lib/artefacts.js).
3
3
  *
4
- * GET /api/artefacts?ws&scope → { ok, ws, scope, kind, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
4
+ * GET /api/artefacts?ws&scope → { ok, ws, scope, kind, factory, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
5
+ * factory: a D65 factory runs in this repository (lib/work-kind.js factoryRuns), so "PMOS builds it" is true
5
6
  * scope: portfolio (default), board:<id>, goal:<id>, experiment:<id> (initiative:<id> is an alias)
6
7
  * GET /api/artefacts/story?ws → { ok, ws, story: { scope, at, lines: [{ text, sources }] } | null, seeding? } "The story so far" on the
7
8
  * product page (board AwE): the Narrative of board:<ws>, else of the portfolio (lib/artefacts.js storyOf). A
@@ -122,7 +123,7 @@ async function handle(req, res, url, ctx) {
122
123
  const v = A.viewOf(A.fold(A.readLines(A.file(dir))), scope);
123
124
  const artefacts = v.artefacts.map((a) => ({ ...a,
124
125
  fields: Object.fromEntries(Object.entries(a.fields).map(([k, val]) => [k, Array.isArray(val) ? val.map(pageBy) : pageBy(val)])) }));
125
- return send(200, { ok: true, ws: w.id, scope: v.scope, kind: v.kind, artefacts });
126
+ return send(200, { ok: true, ws: w.id, scope: v.scope, kind: v.kind, factory: require('./work-kind.js').factoryRuns(w.root), artefacts });
126
127
  }
127
128
 
128
129
  module.exports = { prefixes: ['/api/artefacts'], handle, _migrated: migrated };
@@ -113,6 +113,8 @@ module.exports = {
113
113
  rows: rowsNow, members, columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] },
114
114
  items: its && its.body && its.body.ok !== false && Array.isArray(its.body.items) ? its.body.items : [], held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
115
115
  });
116
+ // W3: Full SDLC says "PMOS builds" only where a factory runs (lib/work-kind.js factoryRuns); elsewhere the team's agents build
117
+ try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; if (model.board) model.board.factory = !!(w && w.id === pick.ws && require('./work-kind.js').factoryRuns(w.root)); } catch { /* no factory said */ }
116
118
  // workspace grill W2: a row nothing read for says No signal (grey), with where its status came from (r.signal: from, why, source,
117
119
  // readAt); the header and the Needs a look menu count them apart from on track, from the board's own count (scripts/boards.js counts)
118
120
  try {
@@ -266,7 +266,7 @@ function listOf(w, F) {
266
266
  if (!g.anchors.has(a.key)) {
267
267
  const raw = String(F.byId.get(r.id).anchor || '').trim();
268
268
  const m = (a.token && measurements.latest(F.meas, a.token)) || (a.anchor && measurements.latest(F.meas, a.anchor)) || (raw && measurements.latest(F.meas, raw)) || null;
269
- g.anchors.set(a.key, { anchor: a.anchor, kind: a.kind, title: a.title, measurement: m ? { value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source } : null, rows: [] });
269
+ g.anchors.set(a.key, { anchor: a.anchor, kind: a.kind, title: a.title, measurement: m ? { value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source, how: m.how || null } : null, rows: [] });
270
270
  }
271
271
  g.anchors.get(a.key).rows.push(r);
272
272
  }
@@ -116,7 +116,7 @@ function measurementsOf(root, anchor) {
116
116
  try {
117
117
  const M = require('./measurements.js');
118
118
  const r = M.readMeasurements(root);
119
- const series = ((r.byAnchor || {})[anchor] || []).map((m) => ({ value: m.value, target: m.target == null ? null : m.target, unit: m.unit || null, as_of: m.as_of, source: m.source }));
119
+ const series = ((r.byAnchor || {})[anchor] || []).map((m) => ({ value: m.value, target: m.target == null ? null : m.target, unit: m.unit || null, as_of: m.as_of, source: m.source, how: m.how || null }));
120
120
  return { anchor, latest: M.latest(r, anchor), series };
121
121
  } catch { return { anchor, latest: null, series: [] }; }
122
122
  }
@@ -69,12 +69,15 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
69
69
 
70
70
  if (verb === 'roles') {
71
71
  const t = T.tableForPage();
72
- if (json) return ok({ roles: t });
72
+ // launch simulation W3: say whether the Builder can run here, from the files on disk (lib/work-kind.js factoryRuns)
73
+ const factory = require('./work-kind.js').factoryRuns(root);
74
+ if (json) return ok({ roles: t, factory });
73
75
  for (const r of t) {
74
76
  say(`${r.initial.padEnd(2)} ${r.name} · class ${r.cls}${r.runs ? ` · up to ${r.budget} runs a day` : ' · runs no model here'}`);
75
77
  say(` owns: ${r.what}`);
76
78
  if (r.owns.paths.length || r.owns.verbs.length) say(` writes only: ${[...r.owns.paths, ...r.owns.verbs].join(', ')}`);
77
79
  say(` wakes on: ${r.triggers.map((x) => (x.on === 'stage' ? `stage ${x.stage}${x.unless ? ' without ' + x.unless : ''}` : x.on === 'written' ? 'a write by another role' : 'a dispatch')).join(', ')}`);
80
+ if (r.key === 'build') say(` here: ${factory ? 'the factory runs in this repository. It opens pull requests and never merges them; you merge.' : 'no factory runs in this repository, so the Builder does not run. The team\'s agents build from the done test and the pull request plan PMOS writes.'}`);
78
81
  }
79
82
  return 0;
80
83
  }
@@ -21,7 +21,7 @@ const USAGE = [
21
21
  ' pmos today --root <dir> [--json] [--wait]',
22
22
  'With a workspace server running, prints Your move: the list Home shows, in the same order (public/pm/move-rank.js rankMove):',
23
23
  'an overdue outcome verdict, a grill finding on shipped work, a meeting change, a finding on work ahead, a key result with no',
24
- 'reading, then the rest Claude proposes, one row per initiative. Rows older than 14 days fold under "Older".',
24
+ 'reading, then the rest PMOS proposes, one row per initiative. Rows older than 14 days fold under "Older".',
25
25
  'Without a server it reads the repository and prints the Today cards, ranked by kind (1 a gate is owed, 2 a session is',
26
26
  'waiting, 3 a step was returned to you, 4 work to check, 5 a breakdown to keep, 6 a capture, 7 a cycle review, 8 needs',
27
27
  'repair). It does not read sessions then.',