create-pmos 0.564.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 (55) hide show
  1. package/package.json +33 -27
  2. package/payload/KIT-VERSION +2 -2
  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 +39 -11
  7. package/payload/state/discoveries.md +1 -1
  8. package/payload/state/log.md +1 -1
  9. package/workspace/changelog.json +32 -0
  10. package/workspace/fixtures/initiatives-api/list.json +2 -1
  11. package/workspace/guide/cli.md +3 -2
  12. package/workspace/guide/initiatives-and-next-steps.md +4 -4
  13. package/workspace/guide/jira.md +3 -1
  14. package/workspace/lib/agent-team.js +1 -1
  15. package/workspace/lib/board-cli.js +32 -1
  16. package/workspace/lib/description-props.js +53 -2
  17. package/workspace/lib/engine/workflow-state.js +39 -11
  18. package/workspace/lib/grill-cli.js +4 -4
  19. package/workspace/lib/impact-cli.js +3 -3
  20. package/workspace/lib/initiative-cli.js +12 -5
  21. package/workspace/lib/jira-cli.js +2 -0
  22. package/workspace/lib/jira-tickets.js +78 -5
  23. package/workspace/lib/lab-cli.js +1 -1
  24. package/workspace/lib/lead-cli.js +1 -1
  25. package/workspace/lib/measure-cli.js +13 -7
  26. package/workspace/lib/measurements.js +34 -11
  27. package/workspace/lib/metrics-cli.js +4 -4
  28. package/workspace/lib/outcomes-cli.js +2 -2
  29. package/workspace/lib/program-cli.js +2 -2
  30. package/workspace/lib/propose-cli.js +2 -2
  31. package/workspace/lib/report-draft.js +7 -6
  32. package/workspace/lib/report-engine.js +1 -1
  33. package/workspace/lib/routes-artefacts.js +3 -2
  34. package/workspace/lib/routes-board-premium.js +2 -0
  35. package/workspace/lib/routes-initiatives.js +1 -1
  36. package/workspace/lib/routes-notes.js +3 -1
  37. package/workspace/lib/routes-stage-tools.js +1 -1
  38. package/workspace/lib/stage-read.js +155 -0
  39. package/workspace/lib/task-cli.js +2 -16
  40. package/workspace/lib/team-cli.js +4 -1
  41. package/workspace/lib/today-cli.js +19 -6
  42. package/workspace/lib/vendor/scripts/workflow-state.js +39 -11
  43. package/workspace/lib/work-kind.js +16 -4
  44. package/workspace/lib/workflow-cli.js +18 -2
  45. package/workspace/package-lock.json +2 -2
  46. package/workspace/package.json +1 -1
  47. package/workspace/public/pm/bd-asks.js +1 -1
  48. package/workspace/public/pm/bd-ini-panel.js +1 -1
  49. package/workspace/public/pm/bd-next.js +9 -5
  50. package/workspace/public/pm/bd-views.js +1 -1
  51. package/workspace/public/pm/ini-agent.js +14 -7
  52. package/workspace/public/pm/premium-board.js +1 -1
  53. package/workspace/public/pm/work-kind.js +10 -6
  54. package/workspace/skills/measure.skill +6 -6
  55. package/workspace/test-lists/stage-everywhere.json +5 -0
@@ -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,
@@ -489,12 +489,13 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
489
489
  const lab = stageCache.get(id).get(sid);
490
490
  return lab || cap(String(sid || ''));
491
491
  };
492
+ const oneStage = require('./stage-read.js').labelReader(main, (id) => lifecycle.labelOf(rows.find((r) => r.id === id), main));
492
493
  const integratedAll = new Set();
493
494
  for (const r of rows) for (const w of ((factoryJoin.factoryOf(fj, r.id) || {}).items || [])) if (w && w.integrated && w.plan_item) integratedAll.add(w.plan_item);
494
495
  const slides = slidesData({
495
496
  product: def.product || path.basename(main), cadence, slot: theSlot, nowMs, window, cycleDays: cycle,
496
497
  blocks, rows, itemsOf,
497
- stageLabel, lifecycleOf: (id) => lifecycle.labelOf(rows.find((r) => r.id === id), main), // W1: the one stage
498
+ stageLabel, lifecycleOf: oneStage, // W1: the one stage, as the Board row holds it (lib/stage-read.js)
498
499
  rankOf: (id) => (has(plc.byInit, id) && Number.isFinite(plc.byInit[id].rank) ? plc.byInit[id].rank : Infinity),
499
500
  isDone: (it) => it.state === 'done' || integratedAll.has(it.id),
500
501
  });
@@ -548,7 +549,7 @@ function render(draft, { notes, name: given, purpose } = {}) {
548
549
  push(`### ${b.title} (${b.id})`, '');
549
550
  const reason = b.health.reasons.find((r) => r.level === b.health.level);
550
551
  push(`Stage: ${b.stage} · ${LEVEL_WORD[b.health.level]}${reason ? `: ${reason.text}` : ''} · ${b.progress.label}`);
551
- 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}` : ''})`);
552
553
  push('', '**Last cycle**', '');
553
554
  const lc = b.last_cycle;
554
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
  }
@@ -384,13 +384,15 @@ function openInitiativesOf(w) {
384
384
  else if (got.ok) {
385
385
  const rm = ri.roadmapOf(w, ri.frameOf(w, got.rows, { now: Date.now() }));
386
386
  const byId = new Map(got.rows.map((r) => [r.id, r]));
387
+ // the one stage the Board row holds (lib/stage-read.js): a workflow move counts, as on every page
388
+ const stageLabel = require('./stage-read.js').labelReader(w.root, (id) => lifecycle.labelOf(byId.get(id), w.root));
387
389
  let top = 0;
388
390
  const add = (r, dormant) => {
389
391
  const rec = byId.get(r.id);
390
392
  if (rec && (rec.stopped || rec.accepted)) return;
391
393
  const isTop = !dormant && top < PICKER_TOP;
392
394
  if (isTop) top++;
393
- ranked.push({ id: r.id, title: r.title, anchor: r.anchor, intent: '', stage: lifecycle.labelOf(rec, w.root), dormant, top: isTop });
395
+ ranked.push({ id: r.id, title: r.title, anchor: r.anchor, intent: '', stage: stageLabel(r.id), dormant, top: isTop });
394
396
  };
395
397
  for (const r of rm.rows) add(r, false);
396
398
  for (const r of rm.dormant) add(r, true);
@@ -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
  }
@@ -0,0 +1,155 @@
1
+ 'use strict';
2
+ /* stage-read.js — the ONE stage and the tasks of an initiative outside HTTP, read the way the Board reads them (launch simulation W1,
3
+ * 2026-11-12).
4
+ *
5
+ * The launch simulation found four answers for one record: `pmos workflow of` and the Board said Evaluate, `pmos initiative list` said
6
+ * Triage, and the Viewer's gate line and the ladder said something else again. The Board row (lib/routes-boards.js boardRow) already
7
+ * holds the one stage (row.oneStage, lib/one-stage.js stageOf): the PM's word, a Board or workflow move, Jira, dated plan items, then
8
+ * the spec files. Every terminal reader now takes it from there, so a terminal line and a page cannot disagree.
9
+ *
10
+ * cliCtx(root, stateDir?) → { w, ctx } the Board's routes outside HTTP: this repository as the one workspace
11
+ * rowOf(ctx, w, id) → initiativeWorkflow's answer, deriving the rows first when they are still being read
12
+ * stageOf(ctx, w, id) → { label, stage, step, setBy, source, readAt, wf: { stage, n, of } | null } | null
13
+ * label is what every surface prints (row.oneStage.label); wf is the workflow's own stage beside it
14
+ * stagesOf(ctx, w, ids) → Map id → stageOf answer
15
+ * labelReader(root, fallback) → (id) → label for a server surface: never starts a read, falls back while the records are read
16
+ * tasksOf(ctx, w, id) → every task of an initiative: its Board tasks and its breakdown items (what `pmos task list` lists)
17
+ * disagreements(answers) → [{ id, surfaces: { name: label } }] the initiatives two surfaces name different stages for
18
+ * check(root, { ids }) → { ok, checked, disagree, stages } every surface's stage, compared (`pmos workflow check`)
19
+ *
20
+ * The CI Initiative Gate is not a stage: scripts/workflow-state.js reports the gate rung (spec, contract, build …), and the engine
21
+ * never requires this file (X29).
22
+ */
23
+ const path = require('path');
24
+
25
+ function cliCtx(root, stateDir) {
26
+ const driver = require('./driver.js');
27
+ const dir = stateDir === undefined ? driver.stateDirOf(root) : stateDir;
28
+ const w = { id: driver.wsIdOf(root), name: path.basename(root), root };
29
+ return { w, ctx: { getWs: () => w, workspaceList: () => [w], stateDirFor: () => dir, selfRoot: path.resolve(__dirname, '..', '..') } };
30
+ }
31
+
32
+ function rowOf(ctx, w, id) {
33
+ const boards = require('./routes-boards.js');
34
+ const rowsLib = require('./initiative-rows.js');
35
+ const was = rowsLib.setBackground(false);
36
+ try {
37
+ let r = boards.initiativeWorkflow(ctx, w, id);
38
+ if (r.pending) { try { rowsLib.deriveNow(w.root); } catch { /* answered below */ } r = boards.initiativeWorkflow(ctx, w, id); }
39
+ return r;
40
+ } finally { rowsLib.setBackground(was); }
41
+ }
42
+
43
+ /** The stage a Board row shows → the stageOf answer. The same rule the stage card and the chip draw. */
44
+ function fromRow(row) {
45
+ if (!row) return null;
46
+ const one = row.oneStage || null;
47
+ const st = row.wfStage || null;
48
+ const wf = st && st.name ? { stage: st.name, key: st.key, n: st.n, of: st.of } : null;
49
+ if (row.ended) return { label: row.ended.as === 'wontdo' ? "Won't do" : 'Archived', stage: 'ended', step: one ? one.step : null, setBy: 'pm', source: 'the workflow', readAt: null, wf };
50
+ // the chip, the stage card and the Viewer's stage words all print row.oneStage.label (public/pm/stage-chip.js, lib/initiative-premium.js)
51
+ if (one && one.label) return { label: one.label, stage: one.stage, step: one.step, setBy: one.setBy, source: one.source, readAt: one.readAt, wf };
52
+ if (wf) return { label: wf.stage, stage: null, step: null, setBy: 'pm', source: 'the workflow', readAt: null, wf };
53
+ return null;
54
+ }
55
+
56
+ function stageOf(ctx, w, id) {
57
+ const r = rowOf(ctx, w, id);
58
+ return r && r.ok ? fromRow(r.row) : null;
59
+ }
60
+ function stagesOf(ctx, w, ids) {
61
+ const out = new Map();
62
+ const pass = { ...ctx, boardsPass: new Map() }; // one fold of the Board ledger for the whole list
63
+ for (const id of ids || []) { try { out.set(id, stageOf(pass, w, id)); } catch { out.set(id, null); } }
64
+ return out;
65
+ }
66
+
67
+ /** A reader for a surface that holds only a repository root and its workflow rows (the notes picker, a report's slides): id → the
68
+ * one stage's label. It never starts a read of the records: while they are still being read it answers with `fallback(id)`. */
69
+ function labelReader(root, fallback) {
70
+ let pass = null, w = null;
71
+ try { const c = cliCtx(root); w = c.w; pass = { ...c.ctx, boardsPass: new Map() }; } catch { pass = null; }
72
+ const boards = require('./routes-boards.js');
73
+ return (id) => {
74
+ if (pass && pass.stateDirFor()) {
75
+ try { const r = boards.initiativeWorkflow(pass, w, id); const a = r && r.ok ? fromRow(r.row) : null; if (a) return a.label; } catch { /* the fallback answers */ }
76
+ }
77
+ return fallback ? fallback(id) : '';
78
+ };
79
+ }
80
+
81
+ /** Every task of an initiative: its Board tasks (on any board of this workspace) and its breakdown items. */
82
+ function tasksOf(ctx, w, id) {
83
+ const boards = require('./routes-boards.js');
84
+ const TI = require('./task-items.js');
85
+ const r = rowOf(ctx, w, id);
86
+ const board = r.ok ? r.board.id : null;
87
+ const F = boards.foldOf(ctx, w), S = F.sections || new Map(), MS = F.milestones || new Map(), PN = F.pins || new Map();
88
+ const pinOf = (tid) => (PN.has(tid) ? { pinned: PN.get(tid) } : {}); // the PM's pin on the Board timeline (batch 13 item 4); unset = the rule
89
+ const msOf = (tid, own) => (MS.has(tid) ? MS.get(tid) : !!own); // the PM's ◇ flag (feedback batch 11 item 3)
90
+ // the group the Tasks section shows it under: a stage of the workflow it ran before a switch reads as the stage that switch put it in
91
+ // (row.wfMap, batch 24 item 5), as on the page
92
+ const keys = r.ok ? (r.row.wfStages || []).map((s) => s.key) : [], M = (r.ok && r.row.wfMap) || {};
93
+ const placed = (k) => (k && !keys.includes(k) && keys.includes(M[k]) ? M[k] : k);
94
+ const sec = (tid, from) => placed(S.has(tid) ? S.get(tid) : (from && from.stage) || '');
95
+ const own = [...(F.tasks || new Map()).values()].filter((t) => t.initiative === id).map((t) => ({ ...t, stage: sec(t.id, t.from), milestone: msOf(t.id), ...pinOf(t.id) }));
96
+ const items = TI.rowsOf(w.root, new Set([id]), board).map((x) => ({ id: x.uid, board, kind: 'Task', title: x.title, state: x.status, owner: x.owner, start: x.start || null, due: x.end, store: 'item', stage: sec(x.uid), milestone: msOf(x.uid, x.milestone), ...pinOf(x.uid) }));
97
+ return own.concat(items);
98
+ }
99
+
100
+ /** answers: { <surface name>: Map id → label } → the initiatives whose surfaces name different stages. A surface with no answer for
101
+ * an id is left out of that id's comparison (it has not read it), never counted as a disagreement. */
102
+ function disagreements(answers) {
103
+ const ids = new Set();
104
+ for (const m of Object.values(answers || {})) for (const id of m.keys()) ids.add(id);
105
+ const out = [];
106
+ for (const id of ids) {
107
+ const surfaces = {};
108
+ for (const [name, m] of Object.entries(answers)) { const v = m.get(id); if (v) surfaces[name] = v; }
109
+ if (new Set(Object.values(surfaces)).size > 1) out.push({ id, surfaces });
110
+ }
111
+ return out;
112
+ }
113
+
114
+ /** Every surface's stage for the initiatives of a repository, compared (`pmos workflow check`). → { ok, checked, disagree: [{ id, surfaces }] }
115
+ * Surfaces: the Board's list of rows (the Board page and its chip), the one-initiative read (the Viewer, the stage card, `pmos workflow of`),
116
+ * `pmos initiative list`, and the notes picker and report slides. The Board's column name joins when it is one of the eight lifecycle
117
+ * words (a workflow of its own names its columns as it likes). The CI gate rung (scripts/workflow-state.js) is not a stage and is not read. */
118
+ function check(root, { ids: only } = {}) {
119
+ const boards = require('./routes-boards.js');
120
+ const OS = require('./one-stage.js');
121
+ const rowsLib = require('./initiative-rows.js');
122
+ const { w, ctx } = cliCtx(root);
123
+ if (!ctx.stateDirFor()) return { ok: false, error: 'this repository has no PMOS state folder (pmos/state, state or .pmos)' };
124
+ const was = rowsLib.setBackground(false);
125
+ try {
126
+ try { rowsLib.deriveNow(root); } catch { /* baseRows says what could not be read */ }
127
+ const pass = { ...ctx, boardsPass: new Map() };
128
+ const base = boards.baseRows(w, pass);
129
+ if (!base.ok) return { ok: false, error: base.error || 'the initiative records could not be read' };
130
+ const fr = boards.frameFor(pass, w);
131
+ const ids = base.rows.map((r) => r.id).filter((id) => !only || only.includes(id));
132
+ if (only) for (const id of only) if (!ids.includes(id)) return { ok: false, error: `no initiative ${id} on a board of this workspace` };
133
+ const board = new Map(), column = new Map();
134
+ for (const b of fr.boards) {
135
+ for (const r of boards.rowsOfBoard(fr, b, base.rows)) {
136
+ if (!ids.includes(r.id)) continue;
137
+ const a = fromRow(r);
138
+ if (a) board.set(r.id, a.label);
139
+ // a column joins when it names one of the eight steps and no PM word (Shipped, On hold, Cancelled) stands over it: a shipped
140
+ // initiative sits in its last column by design
141
+ const word = a && ['shipped', 'on-hold', 'cancelled', 'ended'].includes(a.stage);
142
+ if (!word && r.stage && OS.STEPS.some((k) => OS.LABELS[k] === r.stage) && !r.ended) column.set(r.id, r.stage);
143
+ }
144
+ }
145
+ const one = new Map();
146
+ for (const id of ids) { const r = boards.initiativeWorkflow(pass, w, id); const a = r && r.ok ? fromRow(r.row) : null; if (a) one.set(id, a.label); }
147
+ const list = new Map([...stagesOf(ctx, w, ids)].filter(([, a]) => a).map(([id, a]) => [id, a.label]));
148
+ const reader = labelReader(root, () => '');
149
+ const notes = new Map(ids.map((id) => [id, reader(id)]).filter(([, v]) => v));
150
+ const disagree = disagreements({ Board: board, 'Board column': column, 'Viewer and pmos workflow of': one, 'pmos initiative list': list, 'notes and reports': notes });
151
+ return { ok: true, checked: ids.length, disagree, stages: Object.fromEntries(ids.map((id) => [id, one.get(id) || board.get(id) || null])) };
152
+ } finally { rowsLib.setBackground(was); }
153
+ }
154
+
155
+ module.exports = { cliCtx, rowOf, fromRow, stageOf, stagesOf, labelReader, tasksOf, disagreements, check };
@@ -143,22 +143,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
143
143
 
144
144
  const cli = { isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env };
145
145
  const g = { ok: true, actor: actorLib.fromCli(cli), cli };
146
- /** Every task of an initiative: its Board tasks (on any board of this workspace) and its breakdown items. */
147
- const tasksOf = (id) => {
148
- const r = rowOf(boards, ctx, w, id);
149
- const board = r.ok ? r.board.id : null;
150
- const F = boards.foldOf(ctx, w), S = F.sections || new Map(), MS = F.milestones || new Map(), PN = F.pins || new Map();
151
- const pinOf = (tid) => (PN.has(tid) ? { pinned: PN.get(tid) } : {}); // the PM's pin on the Board timeline (batch 13 item 4); unset = the rule
152
- const msOf = (tid, own) => (MS.has(tid) ? MS.get(tid) : !!own); // the PM's ◇ flag (feedback batch 11 item 3)
153
- // the group the Tasks section shows it under: a stage of the workflow it ran before a switch reads as the stage that switch put it in
154
- // (row.wfMap, batch 24 item 5), as on the page
155
- const keys = r.ok ? (r.row.wfStages || []).map((s) => s.key) : [], M = (r.ok && r.row.wfMap) || {};
156
- const placed = (k) => (k && !keys.includes(k) && keys.includes(M[k]) ? M[k] : k);
157
- const stageOf = (tid, from) => placed(S.has(tid) ? S.get(tid) : (from && from.stage) || '');
158
- const own = [...(F.tasks || new Map()).values()].filter((t) => t.initiative === id).map((t) => ({ ...t, stage: stageOf(t.id, t.from), milestone: msOf(t.id), ...pinOf(t.id) }));
159
- const items = TI.rowsOf(root, new Set([id]), board).map((x) => ({ id: x.uid, board, kind: 'Task', title: x.title, state: x.status, owner: x.owner, start: x.start || null, due: x.end, store: 'item', stage: stageOf(x.uid), milestone: msOf(x.uid, x.milestone), ...pinOf(x.uid) }));
160
- return own.concat(items);
161
- };
146
+ /** Every task of an initiative: its Board tasks and its breakdown items (lib/stage-read.js, which `pmos board` reads too). */
147
+ const tasksOf = (id) => require('./stage-read.js').tasksOf(ctx, w, id);
162
148
 
163
149
  if (verb === 'add') {
164
150
  const [id, title] = pos;
@@ -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,16 +21,26 @@ 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.',
28
- 'Without a server the Cycle review and missing-anchor cards need the initiative records read, which takes time: they show',
29
- 'as pending. Add --wait to read them now (about a quarter of a second per record).',
28
+ 'Without a server it reads the initiative records first when there are up to 100. With more, the Cycle review and',
29
+ 'missing-anchor cards show as pending: add --wait to read them now (about 5 s for 500 records).',
30
30
  ];
31
31
  const BOOL = new Set(['json', 'help', 'wait']);
32
32
  const VALUE = new Set(['ws', 'root']);
33
33
 
34
+ const AUTO_READ = 100;
35
+ /** How many initiative records the repository holds (the engine's layout), or Infinity when it cannot say. */
36
+ function recordCount(root) {
37
+ try {
38
+ const loaded = require('./console-state').loadEngine();
39
+ if (!loaded.ok) return Infinity;
40
+ return fs.readdirSync(loaded.engine.layout(root).initiatives).filter((n) => n.endsWith('.md') && n !== 'README.md').length;
41
+ } catch { return Infinity; }
42
+ }
43
+
34
44
  function isDir(d) { try { return fs.statSync(d).isDirectory(); } catch { return false; } }
35
45
 
36
46
  function repoRoot(cwd) {
@@ -85,7 +95,8 @@ function print(say, out, { sessions }) {
85
95
  say(` ${c.act.label}${c.act.cli ? ' · ' + c.act.cli : ''}${c.initiative_id ? ' · ' + c.initiative_id : ''}`);
86
96
  }
87
97
  for (const b of out.banner || []) say(`! ${b.source}: ${b.error}`);
88
- if (!out.count) say(out.next ? `Nothing needs you. Next: ${out.next.label}.` : 'Nothing needs you.');
98
+ const unread = (out.banner || []).length > 0;
99
+ if (!out.count) say(unread ? 'Nothing needs you in what was read. The lines marked ! were not read.' : out.next ? `Nothing needs you. Next: ${out.next.label}.` : 'Nothing needs you.');
89
100
  if (!sessions) say('No server is running, so waiting sessions were not read.');
90
101
  }
91
102
 
@@ -125,11 +136,13 @@ async function run(argv, { say, call }) {
125
136
  }
126
137
  }
127
138
  if (!out || !out.ok) {
128
- // a local read: nothing in this process would read a background derivation, so none starts; --wait derives now
139
+ // a local read: nothing in this process would read a background derivation, so none starts. A repository of up to AUTO_READ
140
+ // records is read now (a product repository, a fresh kit): without that it stopped at "still reading the initiative records"
141
+ // (launch simulation W1, 2026-11-12). A larger one answers at once with the pending line; --wait reads it (574 records, ~5 s).
129
142
  const rowsLib = require('./initiative-rows.js');
130
143
  const was = rowsLib.setBackground(false);
131
144
  try {
132
- if (f.wait) rowsLib.deriveNow(root);
145
+ if (f.wait || recordCount(root) <= AUTO_READ) { try { rowsLib.deriveNow(root); } catch { /* the banner says what could not be read */ } }
133
146
  out = today.todayFor({ id: 'local', root }, {});
134
147
  } finally { rowsLib.setBackground(was); }
135
148
  }