create-pmos 0.492.0 → 0.494.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 (102) hide show
  1. package/package.json +75 -27
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/mods/pmos-cockpit/README.md +1 -1
  4. package/payload/mods/pmos-cockpit/hooks/lib/guard.mjs +2 -2
  5. package/payload/planning/evals/eval-calibration.md +1 -1
  6. package/payload/planning/okrs/health-budgets.md +1 -1
  7. package/payload/state/discoveries.md +1 -1
  8. package/workspace/briefing-premium-initiative-test.js +2 -1
  9. package/workspace/changelog.json +74 -0
  10. package/workspace/fixtures/initiatives-api/list.json +0 -4
  11. package/workspace/fixtures/initiatives-api/roadmap.json +255 -275
  12. package/workspace/fixtures/initiatives-api/sheet.json +2 -3
  13. package/workspace/fixtures/report-api/draft.json +4 -4
  14. package/workspace/fixtures/reports-page/draft-biweekly-2026-10-16.md +4 -4
  15. package/workspace/guide/board.md +2 -2
  16. package/workspace/guide/briefing-premium.md +2 -0
  17. package/workspace/guide/claude-proposes.md +2 -2
  18. package/workspace/guide/data-freshness.md +3 -1
  19. package/workspace/guide/index.md +2 -2
  20. package/workspace/guide/initiative-boards.md +2 -2
  21. package/workspace/guide/initiatives-roadmap.md +38 -39
  22. package/workspace/guide/initiatives-screen.md +22 -20
  23. package/workspace/guide/initiatives-timeline.md +7 -9
  24. package/workspace/guide/integrated-work.md +7 -8
  25. package/workspace/guide/layout.md +2 -2
  26. package/workspace/guide/lifecycle.md +2 -2
  27. package/workspace/guide/notes.md +1 -1
  28. package/workspace/guide/pm-only-acts.md +5 -5
  29. package/workspace/guide/pm-only-lines.md +3 -3
  30. package/workspace/guide/report-slides.md +14 -1
  31. package/workspace/guide/reports.md +4 -2
  32. package/workspace/guide/today.md +2 -2
  33. package/workspace/guide/your-impact.md +6 -7
  34. package/workspace/lib/board-cli.js +1 -1
  35. package/workspace/lib/board-fold.js +6 -6
  36. package/workspace/lib/board-premium.js +3 -3
  37. package/workspace/lib/board-trail.js +30 -3
  38. package/workspace/lib/calendar-tidy.js +1 -1
  39. package/workspace/lib/core-docs.js +2 -2
  40. package/workspace/lib/engine/boards.js +11 -11
  41. package/workspace/lib/engine/signals/detectors.js +13 -13
  42. package/workspace/lib/engine/signals/facts.js +5 -3
  43. package/workspace/lib/git-shape.js +21 -0
  44. package/workspace/lib/grill-runs.js +21 -6
  45. package/workspace/lib/grill.js +1 -1
  46. package/workspace/lib/health-rules-factory.js +13 -14
  47. package/workspace/lib/health-rules-plan.js +8 -7
  48. package/workspace/lib/impact.js +29 -16
  49. package/workspace/lib/initiative-cli.js +59 -63
  50. package/workspace/lib/initiative-needs.js +6 -6
  51. package/workspace/lib/initiative-premium.js +2 -2
  52. package/workspace/lib/initiative-writer.js +2 -2
  53. package/workspace/lib/lifecycle-stage.js +39 -0
  54. package/workspace/lib/page-warm.js +68 -0
  55. package/workspace/lib/placements.js +117 -95
  56. package/workspace/lib/plan-rules.js +7 -5
  57. package/workspace/lib/pm-guard.js +1 -3
  58. package/workspace/lib/pm-lines-needs.js +1 -1
  59. package/workspace/lib/report-design.js +6 -1
  60. package/workspace/lib/report-draft.js +17 -16
  61. package/workspace/lib/report-export.js +148 -9
  62. package/workspace/lib/report-pyramid.js +434 -0
  63. package/workspace/lib/report-slides-data.js +11 -7
  64. package/workspace/lib/report-structure.js +5 -1
  65. package/workspace/lib/report-templates.js +81 -20
  66. package/workspace/lib/routes-boards.js +9 -8
  67. package/workspace/lib/routes-brief-page.js +20 -3
  68. package/workspace/lib/routes-grill.js +10 -4
  69. package/workspace/lib/routes-impact.js +12 -4
  70. package/workspace/lib/routes-initiatives.js +29 -43
  71. package/workspace/lib/routes-notes.js +24 -15
  72. package/workspace/lib/routes-programs.js +6 -4
  73. package/workspace/lib/routes-report-design.js +15 -0
  74. package/workspace/lib/routes-report-flow.js +106 -17
  75. package/workspace/lib/routes-report-setups.js +2 -1
  76. package/workspace/lib/routes-report-structure.js +3 -0
  77. package/workspace/lib/split-merge.js +2 -3
  78. package/workspace/lib/wf-bridge.js +5 -3
  79. package/workspace/package-lock.json +2 -2
  80. package/workspace/package.json +1 -1
  81. package/workspace/premium-chat-report-tab-test.js +5 -1
  82. package/workspace/public/pm/cozy-vw-rp.css +12 -0
  83. package/workspace/public/pm/fetch-share.js +38 -0
  84. package/workspace/public/pm/home-app.js +21 -3
  85. package/workspace/public/pm/home-chat.js +5 -4
  86. package/workspace/public/pm/home-impact.css +23 -13
  87. package/workspace/public/pm/home-impact.js +49 -32
  88. package/workspace/public/pm/home-ini.css +2 -0
  89. package/workspace/public/pm/http.js +1 -1
  90. package/workspace/public/pm/ini-view.css +55 -0
  91. package/workspace/public/pm/ini-view.js +5 -2
  92. package/workspace/public/pm/premium-board.js +1 -0
  93. package/workspace/public/pm/premium-insights.js +1 -0
  94. package/workspace/public/pm/premium-report-read.js +25 -6
  95. package/workspace/public/pm/premium-report-tab.js +69 -14
  96. package/workspace/public/pm/report-flow.js +93 -10
  97. package/workspace/public/pm/view-notes.js +8 -8
  98. package/workspace/replaced-tests.json +14 -0
  99. package/workspace/server.js +24 -3
  100. package/workspace/skills/report-template.skill +8 -0
  101. package/workspace/test-lists/page-open-speed.json +5 -0
  102. package/workspace/test-lists/report-pyramid.json +9 -0
@@ -15,7 +15,7 @@
15
15
  * exit the initiative is about to leave its stage (most of the stage's tasks are closed), once per stage
16
16
  * forecast its forecast, or the forecast of a goal it moves, turned at-risk or will-miss (lib/forecast.js `turned` lines), once per turn
17
17
  * move its scope or dates moved a lot since the last look (tasks ±30% and 3 or more, or the end ±14 days)
18
- * monthly a running initiative with late work, at most once in 30 days
18
+ * monthly every running initiative with open work, at most once in 30 days each: late work first, then the ones grilled longest ago
19
19
  * `exits` runs only the first. Every run counts against the monthly credit cap (grill.cap, US dollars): before a run the cap must hold
20
20
  * the run's whole budget, which goes to the run as --max-budget-usd, so the month never goes beyond the cap. At the cap Claude pauses and
21
21
  * says so once per month (a `paused` line).
@@ -7,10 +7,11 @@
7
7
  * item whose folded state is `failed` is unresolved. UNKNOWN (code factory-unreadable) when the
8
8
  * factory ledger exists but cannot be read or folded (the join's `unreadable`, R8): a failure
9
9
  * the rule cannot see must not read as on track.
10
- * factory-outside-now AT RISK — building outside Now: a factory item is claimed (a live claim) while the initiative
11
- * is in Next or Later, or the trunk holds commits that scripts/delivery-index.js attributes to
12
- * it while it is in Next or Later and it is not accepted. An initiative with no placement is in
13
- * Later (lib/placements.js horizonOf).
10
+ * factory-unranked AT RISK — building before Prioritize: a factory item is claimed (a live claim), or the trunk
11
+ * holds commits that scripts/delivery-index.js attributes to it while it is not accepted, and no
12
+ * line ranked the initiative on the Roadmap (lib/placements.js byInit[id].source is not
13
+ * 'ledger': day one's guess and a new initiative's landing line are not a rank). D105 replaced
14
+ * "building outside Now" (code factory-outside-now) with this rule when Now / Next / Later went.
14
15
  *
15
16
  * What a rule reads (lib/health.js ctx): `factory` = lib/factory-join.js factoryOf(joinFactory(root), id), `placement`
16
17
  * = lib/placements.js byInit[id], `row` = the workflow row (scripts/workflow-state.js). A rule whose input is missing
@@ -27,7 +28,6 @@ const fs = require('fs');
27
28
  const path = require('path');
28
29
 
29
30
  const SOURCE = 'planning/work-items.jsonl';
30
- const HORIZON_WORD = { next: 'Next', later: 'Later' };
31
31
  const DELIVERY_PATHS = [
32
32
  path.join(__dirname, '..', '..', 'scripts', 'delivery-index.js'),
33
33
  path.join(__dirname, 'engine', 'delivery-index.js'),
@@ -42,7 +42,8 @@ function attributionSentences(id) {
42
42
  return ['branch', 'mention'].map((s) => delivery.attributionEvidence(s, id));
43
43
  }
44
44
 
45
- const horizonOf = (ctx) => (ctx && ctx.placement && ctx.placement.horizon) || 'later';
45
+ /** A line put the initiative on the Roadmap (a ranked line, an adopted proposal, or an old placed line). */
46
+ const rankedOf = (ctx) => !!(ctx && ctx.placement && ctx.placement.source === 'ledger');
46
47
  const list = (ids) => (ids.length > 3 ? `${ids.slice(0, 3).join(', ')} and ${ids.length - 3} more` : ids.join(', '));
47
48
 
48
49
  module.exports = [
@@ -65,17 +66,15 @@ module.exports = [
65
66
  },
66
67
  },
67
68
  {
68
- id: 'factory-outside-now',
69
+ id: 'factory-unranked',
69
70
  check(ctx) {
70
- const horizon = horizonOf(ctx);
71
- if (horizon === 'now' || !HORIZON_WORD[horizon]) return null;
72
- const where = HORIZON_WORD[horizon];
71
+ if (rankedOf(ctx)) return null;
73
72
  const items = (ctx && ctx.factory && Array.isArray(ctx.factory.items)) ? ctx.factory.items : [];
74
73
  const claimed = items.filter((it) => it && it.state === 'claimed').map((it) => it.id);
75
74
  if (claimed.length) {
76
75
  return {
77
- level: 'at-risk', code: 'factory-outside-now', source: SOURCE,
78
- text: `Factory work is claimed (${list(claimed)}), but the initiative is in ${where}. Factory work starts only from Now.`,
76
+ level: 'at-risk', code: 'factory-unranked', source: SOURCE,
77
+ text: `Factory work is claimed (${list(claimed)}), but the initiative is not ranked on the Roadmap. Rank it first (Prioritize).`,
79
78
  };
80
79
  }
81
80
  const row = ctx && ctx.row;
@@ -84,8 +83,8 @@ module.exports = [
84
83
  const said = build && build.status === 'done' ? String(build.evidence || '') : '';
85
84
  if (!said || !attributionSentences(ctx.id || row.id).some((s) => said.includes(s))) return null;
86
85
  return {
87
- level: 'at-risk', code: 'factory-outside-now', source: 'git (scripts/delivery-index.js)',
88
- text: `Commits on the trunk are attributed to this initiative, but it is in ${where}. Building starts only from Now.`,
86
+ level: 'at-risk', code: 'factory-unranked', source: 'git (scripts/delivery-index.js)',
87
+ text: 'Commits on the trunk are attributed to this initiative, but it is not ranked on the Roadmap. Rank it first (Prioritize).',
89
88
  };
90
89
  },
91
90
  },
@@ -7,19 +7,20 @@
7
7
  * (seams §5.4). A field a rule needs and ctx does not carry makes that rule say nothing.
8
8
  *
9
9
  * off track an overdue milestone; a predecessor from another initiative that was withdrawn
10
- * at risk a Now initiative idle for stall_days; a PM step owed longer than that; a passed check-by date; an
10
+ * at risk an initiative under way (past its spec, not accepted) idle for stall_days (was: a Now initiative; D105); a PM step owed longer than that; a passed check-by date; an
11
11
  * overdue item; an item that starts before an open predecessor ends
12
12
  * unknown a source could not be read (the workflow row, or lines of plan-items.jsonl)
13
13
  *
14
- * Not here: an unresolved failed factory item and building outside Now (Run 4, health-rules-factory.js). A finished
14
+ * Not here: an unresolved failed factory item and building before it is ranked (Run 4, health-rules-factory.js). A finished
15
15
  * initiative (Accepted, Handed off) has no health: every rule here says nothing for it. A PM step's age is the age of the
16
16
  * initiative's last evidence, because the ladder does not record when a step became owed. A stopped initiative (On hold, Closed,
17
- * Cancelled) has none either: it is off the board. A check-by date belongs to Now, so one that a card keeps in Next or Later is
18
- * not read.
17
+ * Cancelled) has none either: it is off the board. A check-by date is read wherever the initiative ranks (D105: it belonged to
18
+ * Now while there was a Now).
19
19
  *
20
20
  * Pure: no I/O, no clock beyond ctx.now, no cache.
21
21
  */
22
22
  const display = require('./initiative-display.js');
23
+ const lifecycle = require('./lifecycle-stage.js');
23
24
 
24
25
  const DAY = 86400000;
25
26
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -86,9 +87,9 @@ const RULES = [
86
87
  },
87
88
  },
88
89
  {
89
- id: 'idle-in-now',
90
+ id: 'idle-underway', // was idle-in-now (D105): the lifecycle stage, not a horizon, says the work is under way
90
91
  check(ctx) {
91
- if (!ctx.row || !ctx.placement || ctx.placement.horizon !== 'now' || finishedWord(ctx)) return null;
92
+ if (!ctx.row || !lifecycle.underway(ctx.row) || finishedWord(ctx)) return null;
92
93
  const label = display.idleLabel(ctx.row, displayCtx(ctx));
93
94
  if (!label) return null;
94
95
  return { level: 'at-risk', code: 'idle', text: label, source: recordOf(ctx) };
@@ -110,7 +111,7 @@ const RULES = [
110
111
  {
111
112
  id: 'check-by-passed',
112
113
  check(ctx) {
113
- const by = ctx.placement && ctx.placement.horizon === 'now' && ctx.placement.check_by;
114
+ const by = ctx.placement && ctx.placement.check_by;
114
115
  if (!by || by >= todayOf(ctx) || finishedWord(ctx)) return null;
115
116
  return { level: 'at-risk', code: 'check-by-passed', text: `check-by ${shortDate(by)} passed`, source: PLACEMENTS };
116
117
  },
@@ -9,6 +9,10 @@
9
9
  * ticket that moved after your decision, a spec used, a KR that moved after your initiative delivered), with the source to open it. Never
10
10
  * logins, ticks, time, messages sent, or Claude's own work.
11
11
  *
12
+ * COUNTED BY DEFAULT (batch 23 item 4, canvas IcA). An item counts unless the PM drops it (✕, "Not right, drop it"). The check of week W is open
13
+ * during the week after W; when that week ends, every row of W nobody dropped is real. A closed week is judged for the gate only when the
14
+ * check card was shown to the PM (a `looked` line), so the gate never opens on weeks nobody saw. An explicit ✓ (older ledgers) still counts.
15
+ *
12
16
  * NO NUMBERS LEAVE THIS FILE. The views carry words: grow is rest · bud · leaf · full; the gate is measuring · open · short. The gate's rate
13
17
  * is written to the ledger (the brief's "record the rate") and never shown.
14
18
  *
@@ -18,6 +22,7 @@
18
22
  * end { run, ok, error? } the run ended
19
23
  * verdict { id, real: true | false } the PM's ✓ or ✕ in the weekly check
20
24
  * undo { id } a row back to unchecked
25
+ * looked { week } the weekly check card was shown to the PM for that week
21
26
  * seen { ids } read on a Phase 2 surface; ends its celebration
22
27
  * gate { state, real, judged, weeks } the gate changed: measuring → open (and stays), or → short
23
28
  *
@@ -34,7 +39,7 @@ const path = require('path');
34
39
  const crypto = require('crypto');
35
40
 
36
41
  const LEDGER = 'impact.jsonl';
37
- const LINES = new Set(['run', 'item', 'end', 'verdict', 'undo', 'seen', 'gate']);
42
+ const LINES = new Set(['run', 'item', 'end', 'verdict', 'undo', 'seen', 'gate', 'looked']);
38
43
  const KINDS = ['thanks', 'unblock', 'used', 'kr'];
39
44
  const SOURCE_TYPES = ['slack', 'mail', 'jira', 'doc', 'meeting', 'kr', 'board', 'initiative'];
40
45
  const GROW = ['rest', 'bud', 'leaf', 'full'];
@@ -115,7 +120,7 @@ function clean(input) {
115
120
 
116
121
  /* ── the fold ── */
117
122
  function fold(lines) {
118
- const items = new Map(), runs = [];
123
+ const items = new Map(), runs = [], looked = new Set();
119
124
  let gate = { state: 'measuring' };
120
125
  const runOf = (id) => runs.find((r) => r.run === id);
121
126
  for (const l of lines || []) {
@@ -129,10 +134,11 @@ function fold(lines) {
129
134
  items.set(c.item.id, { ...c.item, real: null, read: false, filed: str(l.at), run: str(l.run) });
130
135
  } else if (l.kind === 'verdict' && str(l.id)) { const it = items.get(l.id); if (it && typeof l.real === 'boolean') { it.real = l.real; it.checkedAt = str(l.at); } }
131
136
  else if (l.kind === 'undo' && str(l.id)) { const it = items.get(l.id); if (it) { it.real = null; it.read = false; } }
132
- else if (l.kind === 'seen' && Array.isArray(l.ids)) { for (const id of l.ids) { const it = items.get(String(id)); if (it && it.real === true) it.read = true; } }
137
+ else if (l.kind === 'seen' && Array.isArray(l.ids)) { for (const id of l.ids) { const it = items.get(String(id)); if (it && it.real !== false) it.read = true; } }
133
138
  else if (l.kind === 'gate' && ['measuring', 'open', 'short'].includes(l.state)) { if (gate.state !== 'open') gate = { state: l.state, at: str(l.at) }; }
139
+ else if (l.kind === 'looked' && DAY_RE.test(str(l.week))) looked.add(l.week);
134
140
  }
135
- return { items, runs, gate };
141
+ return { items, runs, gate, looked };
136
142
  }
137
143
 
138
144
  const weekIs = (it, start) => weekOf(dayOf(Date.parse(it.at)), start);
@@ -144,14 +150,21 @@ function itemsByWeek(F, start) {
144
150
  return m;
145
151
  }
146
152
 
147
- /** PURE. The gate before Phase 2: a checked week is a finished week whose every item has ✓ or ✕. Across the checked weeks, at least 9 of 10
148
- * judged items real, over at least two weeks and ten items: open (and it stays open once written). Ten or more judged and under 9 of 10: short. */
153
+ /** The check of week `w` is closed once the week after it has ended: rows nobody dropped are real from then on. */
154
+ const closed = (w, thisWeek) => w < addDays(thisWeek, -7);
155
+ /** Counts in your impact: not dropped. A row still in its open check counts too (the card says so: "counted them in your impact"). */
156
+ const counts = (x) => x.real !== false;
157
+
158
+ /** PURE. The gate before Phase 2: a judged week is a finished week whose every item has ✓ or ✕, or a closed week whose check card the PM saw
159
+ * (rows nobody dropped are real). Across the judged weeks, at least 9 of 10 items real, over at least two weeks and ten items: open (and it
160
+ * stays open once written). Ten or more judged and under 9 of 10: short. */
149
161
  function gateOf(F, thisWeek, start = 'mon') {
150
- const W = itemsByWeek(F, start);
162
+ const W = itemsByWeek(F, start), saw = F.looked || new Set();
151
163
  let real = 0, judged = 0, weeks = 0;
152
164
  for (const [w, list] of W) {
153
- if (w >= thisWeek || !list.length || list.some((x) => x.real === null)) continue;
154
- weeks++; judged += list.length; real += list.filter((x) => x.real === true).length;
165
+ if (w >= thisWeek || !list.length) continue;
166
+ if (list.some((x) => x.real === null) && !(closed(w, thisWeek) && saw.has(w))) continue;
167
+ weeks++; judged += list.length; real += list.filter(counts).length;
155
168
  }
156
169
  if (F.gate && F.gate.state === 'open') return { state: 'open', real, judged, weeks };
157
170
  const state = weeks < GATE_WEEKS || judged < GATE_ITEMS ? 'measuring' : real * 10 >= judged * 9 ? 'open' : 'short';
@@ -163,7 +176,7 @@ const growOf = (n) => GROW[n <= 0 ? 0 : n === 1 ? 1 : n <= 3 ? 2 : 3];
163
176
  function weekView(F, o) {
164
177
  const thisWeek = weekOf(o.today, o.start), week = o.week && DAY_RE.test(o.week) ? weekOf(o.week, o.start) : thisWeek;
165
178
  const live = gateOf(F, thisWeek, o.start).state === 'open';
166
- const real = live ? (itemsByWeek(F, o.start).get(week) || []).filter((x) => x.real === true).sort(byNewest) : [];
179
+ const real = live ? (itemsByWeek(F, o.start).get(week) || []).filter(counts).sort(byNewest) : [];
167
180
  const cel = real.find((x) => !x.read);
168
181
  return { live, first: F.items.size === 0, week, from: week, to: addDays(week, 6), label: labelOf(week, thisWeek), grow: growOf(real.length),
169
182
  celebrate: cel ? cel.id : null, quiet: real.length === 0, items: real.map(shown) };
@@ -176,19 +189,19 @@ function weeksView(F, o) {
176
189
  const W = itemsByWeek(F, o.start), all = [...W.keys()].filter((w) => w <= thisWeek).sort();
177
190
  const weeks = [];
178
191
  if (all.length) for (let w = thisWeek; w >= all[0]; w = addDays(w, -7)) {
179
- const real = (W.get(w) || []).filter((x) => x.real === true).sort(byNewest);
192
+ const real = (W.get(w) || []).filter(counts).sort(byNewest);
180
193
  weeks.push({ week: w, from: w, to: addDays(w, 6), label: labelOf(w, thisWeek), quiet: real.length === 0, items: real.map(shown) });
181
194
  }
182
195
  return { live, weeks };
183
196
  }
184
- /** PURE. GET /api/impact/check: the oldest finished week with a row not checked yet, all its rows (checked ones keep their mark). */
197
+ /** PURE. GET /api/impact/check: last week's rows while its check is open (the whole of this week); dropped rows keep their mark for Undo.
198
+ * looked: the card was shown already this week, so the row under Mentions goes; the card stays Home's chat intro until the week ends. */
185
199
  function checkView(F, o) {
186
200
  const thisWeek = weekOf(o.today, o.start), W = itemsByWeek(F, o.start);
187
201
  const gate = gateOf(F, thisWeek, o.start).state;
188
- const open = [...W.keys()].filter((w) => w < thisWeek && W.get(w).some((x) => x.real === null)).sort();
189
- if (!open.length) return { due: false, week: null, label: '', items: [], gate };
190
- const week = open[0];
191
- return { due: true, week, label: labelOf(week, thisWeek), items: W.get(week).sort(byNewest).map(shown), gate };
202
+ const week = addDays(thisWeek, -7), list = W.get(week) || [];
203
+ if (!list.length) return { due: false, week: null, label: '', items: [], gate, looked: false };
204
+ return { due: true, week, label: labelOf(week, thisWeek), items: list.sort(byNewest).map(shown), gate, looked: (F.looked || new Set()).has(week) };
192
205
  }
193
206
 
194
207
  module.exports = { LEDGER, KINDS, SOURCE_TYPES, GROW, GATE_ITEMS, GATE_WEEKS, COUNT_RE, dirOf, ledgerFile, readLines, read, append, clean, fold,
@@ -4,9 +4,8 @@
4
4
  *
5
5
  * pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>]
6
6
  * pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor …] [--lane …] [--title "…"]
7
- * pmos initiative now <id> PM only: type the id to confirm
8
- * pmos initiative next|later <id> [--top] to the end of that horizon, or its top
9
- * pmos initiative top|up|down <id> reorder inside its horizon
7
+ * pmos initiative top|up|down|bottom <id> reorder it on the Roadmap (one ranked list, D105)
8
+ * pmos initiative after <id> <other-id> rank it right after another initiative
10
9
  * pmos initiative check-by <id> <YYYY-MM-DD|none>
11
10
  * pmos initiative adopt <proposal-eid> the PM types the eid to confirm; an agent passes (D98)
12
11
  * pmos initiative drop <proposal-eid>
@@ -15,11 +14,12 @@
15
14
  * every command: [--json] [--root <dir>]
16
15
  *
17
16
  * The SAME writers the workspace page uses (lib/initiative-writer.js, lib/placements.js) — no server is needed. Who
18
- * wrote a line comes from the call path, never from an argument: Move to Now, adopt, and any line into Now go through
19
- * lib/pm-guard.js requirePmCli — the PM types the confirmation at a terminal, and an agent session passes with its own
20
- * actor (D98); every other command takes lib/actor.js fromCli: the PM at a terminal, the bound agent session from
17
+ * wrote a line comes from the call path, never from an argument: adopt goes through lib/pm-guard.js requirePmCli — the
18
+ * PM types the confirmation at a terminal, and an agent session passes with its own actor (D98); every other command
19
+ * takes lib/actor.js fromCli: the PM at a terminal, the bound agent session from
21
20
  * PMOS_SESSION, `agent:unknown` otherwise. An agent's placement applies at once and its line names the agent (D98).
22
21
  * Work lanes only (D86 point 4): `list` and `export` leave document-lane initiatives out.
22
+ * D105 retired Now / Next / Later: `now`, `next` and `later` answer with what to use instead and change nothing.
23
23
  * Exit codes: 0 done, 1 refused, 2 usage.
24
24
  */
25
25
  const path = require('path');
@@ -32,25 +32,28 @@ const rowsLib = require('./initiative-rows.js');
32
32
  const planRules = require('./plan-rules.js');
33
33
  const breakdownExport = require('./breakdown-export.js');
34
34
  const triage = require('./triage.js');
35
+ const lifecycle = require('./lifecycle-stage.js');
35
36
  const { parseArgs } = require('./schedule-cli');
36
37
 
37
- const COMMANDS = { initiative: ['new', 'now', 'next', 'later', 'top', 'up', 'down', 'check-by', 'adopt', 'drop', 'list', 'export'] };
38
+ const COMMANDS = { initiative: ['new', 'top', 'up', 'down', 'bottom', 'after', 'check-by', 'adopt', 'drop', 'list', 'export'] };
39
+ /** The horizon verbs D105 retired: they answer with what to use instead. */
40
+ const RETIRED = Object.freeze(['now', 'next', 'later']);
38
41
  const USAGE = [
39
- 'usage: pmos initiative new|now|next|later|top|up|down|check-by|adopt|drop|list|export — initiatives on the Roadmap',
42
+ 'usage: pmos initiative new|top|up|down|bottom|after|check-by|adopt|drop|list|export — initiatives on the Roadmap',
40
43
  ' pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>]',
41
44
  ' pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor <anchor>] [--lane <lane>] [--title "<title>"]',
42
- ' pmos initiative now <id> move it into Now (you only; type the id to confirm)',
43
- ' pmos initiative next|later <id> [--top] move it to the end of Next or Later, or to its top',
44
- ' pmos initiative top|up|down <id> reorder it inside its horizon',
45
+ ' pmos initiative top|up|down|bottom <id> reorder it on the Roadmap',
46
+ ' pmos initiative after <id> <other-id> rank it right after another initiative',
45
47
  ' pmos initiative check-by <id> <YYYY-MM-DD|none>',
46
48
  ' pmos initiative adopt <proposal> keep an open proposal (you type the proposal to confirm)',
47
49
  ' pmos initiative drop <proposal> close an open proposal',
48
- ' pmos initiative list Now, Next and Later, in order',
50
+ ' pmos initiative list the Roadmap, ranked, with each lifecycle stage',
49
51
  ' pmos initiative export <id> the breakdown as markdown on stdout',
50
52
  ' every command: [--json] [--root <dir>]',
51
- 'An agent session\'s placement applies at once and names the agent. A new initiative lands in Later.',
53
+ 'An agent session\'s move applies at once and names the agent. A new initiative lands at the end of the Roadmap.',
54
+ 'Now, Next and Later are retired (D105): the rank says what comes first, the lifecycle stage says where it is.',
52
55
  ];
53
- const BOOL = new Set(['json', 'top', 'help']);
56
+ const BOOL = new Set(['json', 'top', 'help']); // --top is kept so an old script gets the retired answer, not a usage error
54
57
  const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root']);
55
58
  const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
56
59
 
@@ -78,6 +81,11 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
78
81
  for (const l of USAGE) say(l);
79
82
  return verb ? 0 : 1;
80
83
  }
84
+ if (RETIRED.includes(verb)) {
85
+ const msg = `Now, Next and Later are retired (D105); nothing was moved. Rank the initiative instead: pmos initiative top|up|down|bottom <id>, or pmos initiative after <id> <other-id>. Its lifecycle stage (Triage to Evaluate) says where it is.`;
86
+ if (json) say(JSON.stringify({ ok: false, error: msg })); else say(`✗ ${msg}`);
87
+ return 2;
88
+ }
81
89
  if (!COMMANDS.initiative.includes(verb)) { say(`unknown initiative command "${verb}" — one of ${COMMANDS.initiative.join(', ')}`); return 2; }
82
90
  if ('by' in flags || 'via' in flags) { say(`attribution is set from the call path; --${'by' in flags ? 'by' : 'via'} is not accepted`); return 2; }
83
91
  for (const k of Object.keys(flags)) {
@@ -115,28 +123,32 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
115
123
  for (const k of ['lane', 'anchor', 'intent', 'id']) if (flags[k]) input[k] = flags[k];
116
124
  const r = writer.createInitiative(root, input, { actor: actorLib.fromCli(who), now });
117
125
  if (!r.ok) return fail(r.error);
118
- return done({ id: r.id, path: r.path }, `✓ ${r.id} added to Later (${r.path}). Commit the record to keep it.`);
126
+ return done({ id: r.id, path: r.path }, `✓ ${r.id} added at the end of the Roadmap (${r.path}). Commit the record to keep it.`);
119
127
  }
120
128
 
121
129
  if (verb === 'list') {
122
130
  const o = order();
123
131
  if (o.error) return fail(o.error);
124
- const titles = new Map(o.rows.map((r) => [r.id, r.title || r.id]));
125
- if (json) { say(JSON.stringify({ ok: true, order: o.placed.order, byInit: o.placed.byInit, proposals: o.placed.proposals.map((p) => ({ ...p, by: actorLib.pageName(p.by) })) })); return 0; }
126
- for (const h of placements.HORIZONS) {
127
- const ids = o.placed.order[h];
128
- const dormant = h === 'later' ? ids.filter((id) => o.placed.byInit[id].dormant).length : 0;
129
- say(`${h[0].toUpperCase()}${h.slice(1)} · ${ids.length}${dormant ? ` (${dormant} dormant)` : ''}`);
130
- for (const id of ids) {
131
- const p = o.placed.byInit[id];
132
- const bits = [];
133
- if (h === 'now' && !p.confirmed) bits.push('unconfirmed');
134
- if (p.check_by) bits.push(`check by ${p.check_by}`);
135
- if (p.dormant) bits.push('dormant');
136
- say(` ${p.rank + 1}. ${id} — ${titles.get(id)}${bits.length ? ' · ' + bits.join(' · ') : ''}`);
137
- }
132
+ const byRow = new Map(o.rows.map((r) => [r.id, r]));
133
+ const stage = (id) => lifecycle.labelOf(byRow.get(id));
134
+ if (json) {
135
+ say(JSON.stringify({ ok: true, ranked: o.placed.ranked, byInit: o.placed.byInit, stages: Object.fromEntries(o.placed.ranked.map((id) => [id, stage(id)])),
136
+ proposals: o.placed.proposals.map((p) => ({ ...p, by: actorLib.pageName(p.by) })) }));
137
+ return 0;
138
+ }
139
+ const ids = o.placed.ranked;
140
+ const dormant = ids.filter((id) => o.placed.byInit[id].dormant).length;
141
+ say(`Roadmap · ${ids.length}${dormant ? ` (${dormant} dormant)` : ''}`);
142
+ for (const id of ids) {
143
+ const p = o.placed.byInit[id];
144
+ const bits = [];
145
+ if (stage(id)) bits.push(stage(id));
146
+ if (!p.confirmed) bits.push('not ranked yet');
147
+ if (p.check_by) bits.push(`check by ${p.check_by}`);
148
+ if (p.dormant) bits.push('dormant');
149
+ say(` ${p.rank + 1}. ${id} — ${(byRow.get(id) || {}).title || id}${bits.length ? ' · ' + bits.join(' · ') : ''}`);
138
150
  }
139
- for (const p of o.placed.proposals) say(`proposal ${p.eid}: ${p.init} to ${p.horizon} · ${actorLib.pageName(p.by)}`);
151
+ for (const p of o.placed.proposals) say(`proposal ${p.eid}: ${p.init} ${p.after ? `after ${p.after}` : 'to the top'} · ${actorLib.pageName(p.by)}`);
140
152
  return 0;
141
153
  }
142
154
 
@@ -166,32 +178,14 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
166
178
  const id = pos[0];
167
179
  if (!id) { say(`usage: pmos initiative ${verb} <id>${verb === 'check-by' ? ' <YYYY-MM-DD|none>' : ''}`); return 2; }
168
180
 
169
- if (verb === 'now' || verb === 'next' || verb === 'later') {
170
- // After the last line of that horizon in the LEDGER's order, so no workflow derivation is needed (fast). Day one's
171
- // rows are seeded before the lines (placements.js), so the ones no line was placed after sort below it. --top puts
172
- // it first.
173
- const ledgerOnly = placements.readPlacements(root);
174
- const list = ledgerOnly.order[verb].filter((x) => x !== id);
175
- const after = flags.top ? null : (list.length ? list[list.length - 1] : null);
176
- let actor;
177
- if (verb === 'now') {
178
- const g = await pmPress('now', id);
179
- if (!g.ok) return fail(g.error);
180
- actor = g.actor;
181
- } else actor = actorLib.fromCli(who);
182
- const r = write([{ ev: 'placed', initiative: id, horizon: verb, after }], actor);
183
- if (!r.ok) return fail(r.error);
184
- return done({ written: r.written, proposed: r.lines[0].proposed }, said(r, `✓ ${id} moved to ${verb[0].toUpperCase()}${verb.slice(1)}${flags.top ? ', at the top' : ''}`));
185
- }
186
-
187
- // top | up | down | check-by: the whole order, day one included.
181
+ // top | up | down | bottom | after | check-by: the whole order, day one included.
188
182
  const o = order();
189
183
  if (o.error) return fail(o.error);
190
184
  const cur = o.placed.byInit[id];
191
185
  if (!cur) return fail(`no work-lane initiative ${id} in this repository`);
192
- const list = o.placed.order[cur.horizon];
186
+ const list = o.placed.ranked;
193
187
  const i = list.indexOf(id);
194
- const ev = { ev: 'placed', initiative: id, horizon: cur.horizon };
188
+ const ev = { ev: 'ranked', initiative: id };
195
189
  let what;
196
190
  if (verb === 'check-by') {
197
191
  const v = pos[1];
@@ -199,24 +193,26 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
199
193
  ev.after = i > 0 ? list[i - 1] : null;
200
194
  ev.check_by = v === 'none' ? null : v;
201
195
  what = v === 'none' ? `✓ ${id}: check-by cleared` : `✓ ${id}: check by ${v}`;
196
+ } else if (verb === 'after') {
197
+ const other = pos[1];
198
+ if (!other) { say('usage: pmos initiative after <id> <other-id>'); return 2; }
199
+ if (other === id) return fail('an initiative cannot come after itself');
200
+ if (!o.placed.byInit[other]) return fail(`no work-lane initiative ${other} on the Roadmap`);
201
+ if (i > 0 && list[i - 1] === other) return done({ written: 0 }, `${id} comes right after ${other} already`);
202
+ ev.after = other;
203
+ what = `✓ ${id} ranked right after ${other}`;
202
204
  } else if (verb === 'top' || verb === 'up') {
203
- if (i === 0) return done({ written: 0 }, `${id} is at the top of ${cur.horizon} already`);
205
+ if (i === 0) return done({ written: 0 }, `${id} is at the top of the Roadmap already`);
204
206
  ev.after = verb === 'top' || i === 1 ? null : list[i - 2];
205
207
  what = `✓ ${id} moved ${verb === 'top' ? 'to the top' : 'up'}`;
206
208
  } else {
207
- if (i === list.length - 1) return done({ written: 0 }, `${id} is at the end of ${cur.horizon} already`);
208
- ev.after = list[i + 1];
209
- what = `✓ ${id} moved down`;
209
+ if (i === list.length - 1) return done({ written: 0 }, `${id} is at the end of the Roadmap already`);
210
+ ev.after = verb === 'bottom' ? list[list.length - 1] : list[i + 1];
211
+ what = `✓ ${id} moved ${verb === 'bottom' ? 'to the end' : 'down'}`;
210
212
  }
211
- let actor;
212
- if (cur.horizon === 'now') {
213
- const g = await pmPress('now', id);
214
- if (!g.ok) return fail(g.error);
215
- actor = g.actor;
216
- } else actor = actorLib.fromCli(who);
217
- const r = write([ev], actor);
213
+ const r = write([ev], actorLib.fromCli(who));
218
214
  if (!r.ok) return fail(r.error);
219
215
  return done({ written: r.written, proposed: r.lines[0].proposed }, said(r, what));
220
216
  }
221
217
 
222
- module.exports = { run, COMMANDS, USAGE };
218
+ module.exports = { run, COMMANDS, RETIRED, USAGE };
@@ -9,8 +9,9 @@
9
9
  * triage one row per capture note not yet added (lib/triage.js): "Proposed: <title> · <lane> · <anchor>".
10
10
  * A capture whose words match a file under planning/out-of-scope/ says "matches an earlier rejection"
11
11
  * in today.cause and names that file in today.evidence. Act: Add (`pmos initiative new --from …`).
12
- * cycle-review ONE row (R12 kind 7) while the cycle holds something to confirm: day one's unconfirmed Now
13
- * initiatives (R26), agent proposals not kept or dropped (R23), and passed check-by dates. 2D draws it.
12
+ * cycle-review ONE row (R12 kind 7) while the cycle holds something to confirm: agent proposals not kept or
13
+ * dropped (R23) and passed check-by dates. 2D draws it. (Day one's "unconfirmed Now" went with the
14
+ * horizons, D105.)
14
15
  * no-anchor one row per work-lane initiative record with no parent_kr (R12 kind 8, "old records have no anchor").
15
16
  *
16
17
  * Every row is repository-wide, so a tree that is not the lead returns []. A row never carries a session token: no
@@ -60,17 +61,16 @@ function cycleRow(root, records, now) {
60
61
  const rules = planRules.readRules(root);
61
62
  const placed = placements.readPlacements(root, { now, rules, records });
62
63
  const today = new Date(now).toISOString().slice(0, 10);
63
- const unconfirmed = placed.order.now.filter((id) => placed.byInit[id].source === 'day-one');
64
+ // D105: there is no Now to confirm. Day one's guess is the activity order, and the PM ranks when it matters.
64
65
  const passed = Object.entries(placed.byInit).filter(([, p]) => p.check_by && p.check_by < today).map(([id]) => id);
65
66
  const proposals = placed.proposals.length;
66
- if (!unconfirmed.length && !passed.length && !proposals) return [];
67
+ if (!passed.length && !proposals) return [];
67
68
  const parts = [];
68
- if (unconfirmed.length) parts.push(`Day one: ${plural(unconfirmed.length, 'initiative reads', 'initiatives read')} Now, unconfirmed`);
69
69
  if (proposals) parts.push(`${plural(proposals, 'agent proposal', 'agent proposals')} to keep or drop`);
70
70
  if (passed.length) parts.push(`${plural(passed.length, 'check-by date', 'check-by dates')} passed`);
71
71
  return [{
72
72
  run_id: `${NAME}:cycle:${today}`, kind: 'cycle-review', initiative_id: null,
73
- question: unconfirmed.length ? 'Confirm what is in Now' : 'Review the cycle', doc: null,
73
+ question: 'Review the cycle', doc: null,
74
74
  today: { kind: 7, source: NAME, cause: parts.join('; '), evidence: ledgerRel(root, 'placements'), act: { label: 'Review', cli: null } },
75
75
  }];
76
76
  }
@@ -5,7 +5,7 @@
5
5
  * peekModel() → the last model built, for the agent to find the initiative in (null before the first)
6
6
  *
7
7
  * facts come from the routes of lib/routes-boards.js, lib/routes-initiatives.js and lib/routes-core-docs.js:
8
- * row GET /api/boards/initiative → .row { id, title, lane, stage, cat, owner, anchor, horizon, status, start, end, progress, warnings, updated, stageSource, workflow }
8
+ * row GET /api/boards/initiative → .row { id, title, lane, stage, cat, owner, anchor, rank, status, start, end, progress, warnings, updated, stageSource, workflow }
9
9
  * sheet GET /api/initiatives/<id> → { initiative: { health, progress, display }, stepper: [{ id, label, state, owed }], waiting, files, derived }
10
10
  * docs GET /api/core-docs?level=initiative → { summary, docs: [{ key, title, for, by, kind, st, when, open: { path }, act, running }] }
11
11
  * ladder the workflow engine's ladder for this initiative (console-state.ladder → row): { steps: [{ key, status, evidence, rule }], next: { step, why, action } }
@@ -149,7 +149,7 @@ function build(f) {
149
149
  const files = ((sheet && sheet.files) || []).filter((x) => x && x.path).slice(0, 12).map((x) => ({ label: x.label || x.kind, path: x.path }));
150
150
  const say = (row.title || id) + ' is ' + (status ? STATUS_LABEL[status] ? STATUS_LABEL[status].toLowerCase() : status : 'without a status') + (row.stage ? ', in the ' + row.stage + ' stage' : '') + '.'
151
151
  + (row.stageSource === 'derived' ? ' The stage comes from the workflow engine, not from a person.' : '');
152
- const facts = [['Lane', row.lane], ['Stage', row.stage], ['Anchor', row.anchor], ['Horizon', row.horizon], ['Status', head.statusLabel], ['Owner', row.owner], ['Planned finish', row.end ? shortDate(row.end) : ''], ['Progress', prog && prog.total ? prog.done + ' of ' + prog.total : '']].filter((x) => x[1]);
152
+ const facts = [['Lane', row.lane], ['Stage', row.stage], ['Anchor', row.anchor], ['Rank', Number.isInteger(row.rank) ? '#' + (row.rank + 1) + ' on the Roadmap' : ''], ['Status', head.statusLabel], ['Owner', row.owner], ['Planned finish', row.end ? shortDate(row.end) : ''], ['Progress', prog && prog.total ? prog.done + ' of ' + prog.total : '']].filter((x) => x[1]);
153
153
 
154
154
  const model = {
155
155
  pending: !!f.pending,
@@ -16,7 +16,7 @@
16
16
  * pmos/state/initiatives/ in a kit repository, from the engine's layout): the frontmatter the gates read (`type`,
17
17
  * `title`, `timestamp`, `lane`, `parent_kr`, and `status` — the chore lane's intent — plus the router's
18
18
  * `specimen_test` and `surface_check` when the caller has them). No new frontmatter field (R24). Then ONE `created`
19
- * line in placements.jsonl (lib/placements.js): the initiative lands at the top of Later, whoever made it (R16, R23).
19
+ * line in placements.jsonl (lib/placements.js): the initiative lands at the end of the Roadmap (D105), whoever made it (R16, R23).
20
20
  * The record is not committed: a commit is the caller's (the PM's) act.
21
21
  *
22
22
  * WHAT IT REFUSES, whoever calls:
@@ -29,7 +29,7 @@
29
29
  * - a writer field (`by`, `via`, `at`, …) in the input (400), and a call without an actor (500).
30
30
  * The file is opened O_CREAT|O_EXCL|O_NOFOLLOW inside the resolved initiatives folder, so an existing file or a
31
31
  * symlink is never written through. When the placement line cannot be written, the new record is removed again and
32
- * the refusal is returned: a record never lands without its place in Later.
32
+ * the refusal is returned: a record never lands without its place on the Roadmap.
33
33
  *
34
34
  * renameInitiative(root, id, title, { actor }) → { ok: true, id, path, from, title } | { ok: false, status, error, field }
35
35
  *
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+ /* lifecycle-stage.js — the lifecycle stage an initiative is in (Triage, Discover, Plan, Prioritize, Build, Deliver,
3
+ * Monitor, Evaluate), read from a workflow row (D105: the stage replaces Now / Next / Later as "where it is").
4
+ *
5
+ * keyOf(row) → 'build' | … | null the current stage of scripts/nine-stages.js, or null when no stage shows
6
+ * labelOf(row) → 'Build' | … | ''
7
+ * underway(row) → true when the work is under way: past its spec and not yet accepted (the engine's contract, build
8
+ * and eval rungs; the lifecycle reads Build to Evaluate there). An idle initiative is at risk only then.
9
+ *
10
+ * `row` is a workflow row ({ lane, stage, steps, accepted? }, lib/initiative-rows.js). The stage is derived, never stored:
11
+ * this file only names it. A finished row (accepted) reads Evaluate's milestone as done and has no current stage; it
12
+ * answers null. Nothing here is guessed: a row whose stages show no signal answers null.
13
+ */
14
+ const { repoScript } = require('./repo-script.js');
15
+ // The label layer is read on first use, not at load: a copy of the workspace with no scripts/ tree (state-isolation's
16
+ // scratch install) still starts, and keyOf answers null there. `underway` never needs it.
17
+ let NS = null;
18
+ function labels() {
19
+ if (NS === null) { try { NS = require(repoScript('nine-stages.js')); } catch { NS = false; } } // pure label layer; never workflow-state.js
20
+ return NS || null;
21
+ }
22
+
23
+ /** The engine's rungs (scripts/workflow-state.js) between an agreed spec and acceptance. */
24
+ const UNDERWAY = new Set(['contract', 'build', 'eval']);
25
+
26
+ function keyOf(row) {
27
+ if (!row || typeof row !== 'object') return null;
28
+ const ns = labels();
29
+ if (!ns) return null;
30
+ try {
31
+ const steps = ns.nineStages(row.lane, { stage: row.stage, steps: Array.isArray(row.steps) ? row.steps : [] });
32
+ const cur = steps.find((s) => s.status === 'current');
33
+ return cur ? cur.key : null;
34
+ } catch { return null; }
35
+ }
36
+ const labelOf = (row) => { const k = keyOf(row); return k ? labels().LABELS[k] : ''; };
37
+ const underway = (row) => !!row && !row.accepted && UNDERWAY.has(String(row.stage || ''));
38
+
39
+ module.exports = { keyOf, labelOf, underway, UNDERWAY };