create-pmos 0.409.0 → 0.411.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 (83) hide show
  1. package/package.json +25 -30
  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/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +1 -1
  7. package/workspace/briefing-premium-initiative-test.js +9 -15
  8. package/workspace/changelog.json +24 -0
  9. package/workspace/chat-asks-test.js +146 -0
  10. package/workspace/guide/briefing-premium.md +1 -1
  11. package/workspace/guide/home.md +25 -0
  12. package/workspace/guide/programs.md +2 -1
  13. package/workspace/home-rows-test.js +149 -56
  14. package/workspace/ini-workflow-test.js +4 -4
  15. package/workspace/lib/briefing-premium-agent.js +8 -1
  16. package/workspace/lib/engine/boards.js +3 -1
  17. package/workspace/lib/goal-chat.js +94 -30
  18. package/workspace/lib/mention-cli.js +70 -0
  19. package/workspace/lib/mention-store.js +307 -0
  20. package/workspace/lib/pmos-verbs.js +3 -0
  21. package/workspace/lib/routes-boards.js +12 -0
  22. package/workspace/lib/routes-briefing-premium.js +2 -2
  23. package/workspace/lib/routes-mentions.js +62 -9
  24. package/workspace/lib/session-files.js +132 -0
  25. package/workspace/lib/session-name.js +103 -0
  26. package/workspace/lib/source-reads.js +4 -1
  27. package/workspace/package-lock.json +2 -2
  28. package/workspace/package.json +1 -1
  29. package/workspace/premium-board-actions-test.js +10 -8
  30. package/workspace/premium-chat-goal-setup-test.js +203 -0
  31. package/workspace/premium-chat-goal-view-test.js +28 -23
  32. package/workspace/premium-chat-line-test.js +189 -0
  33. package/workspace/premium-vw-backlog-test.js +1 -1
  34. package/workspace/premium-vw-item-test.js +1 -1
  35. package/workspace/premium-vw-jira-test.js +1 -1
  36. package/workspace/public/pm/bd-prog-panel.js +3 -1
  37. package/workspace/public/pm/bd-prog.js +4 -2
  38. package/workspace/public/pm/chat-ask.js +17 -9
  39. package/workspace/public/pm/cozy-home-rows.css +39 -1
  40. package/workspace/public/pm/cozy-home.css +112 -12
  41. package/workspace/public/pm/cozy-search.js +2 -1
  42. package/workspace/public/pm/cozy-steps.css +69 -0
  43. package/workspace/public/pm/cozy-steps.js +90 -0
  44. package/workspace/public/pm/goal-chat.js +141 -23
  45. package/workspace/public/pm/home-app.js +71 -35
  46. package/workspace/public/pm/home-ask.js +121 -0
  47. package/workspace/public/pm/home-chat.js +120 -68
  48. package/workspace/public/pm/home-data.js +10 -2
  49. package/workspace/public/pm/home-goal.js +159 -0
  50. package/workspace/public/pm/home-ini.css +35 -0
  51. package/workspace/public/pm/home-ini.js +50 -19
  52. package/workspace/public/pm/home-line.css +59 -0
  53. package/workspace/public/pm/home-line.js +200 -0
  54. package/workspace/public/pm/home-list.js +7 -4
  55. package/workspace/public/pm/home-mentions.js +303 -111
  56. package/workspace/public/pm/home-ses-name.js +65 -0
  57. package/workspace/public/pm/home-stage-card.js +94 -0
  58. package/workspace/public/pm/home-sweep.js +112 -0
  59. package/workspace/public/pm/home-today.js +8 -3
  60. package/workspace/public/pm/premium-initiative-head.js +8 -4
  61. package/workspace/public/pm/program-model.js +4 -1
  62. package/workspace/public/pm/rename-press.js +24 -0
  63. package/workspace/public/pm/wf-page.css +3 -0
  64. package/workspace/public/pm/wf-page.js +2 -1
  65. package/workspace/public/premium-workflows.html +1 -0
  66. package/workspace/server.js +125 -11
  67. package/workspace/session-names-test.js +144 -0
  68. package/workspace/skills/jira-push.skill +1 -0
  69. package/workspace/skills/morning-brief.skill +2 -1
  70. package/workspace/skills/report-daily.skill +1 -0
  71. package/workspace/skills/report-monthly.skill +1 -0
  72. package/workspace/skills/report-weekly.skill +1 -0
  73. package/workspace/skills/sources-read.skill +3 -2
  74. package/workspace/stage-card-test.js +203 -0
  75. package/workspace/test-lists/chat-asks.json +13 -0
  76. package/workspace/test-lists/chat-progress.json +13 -0
  77. package/workspace/test-lists/mentions-a-plus.json +9 -0
  78. package/workspace/test-lists/premium-chat-goal-setup.json +9 -0
  79. package/workspace/test-lists/session-files.json +5 -0
  80. package/workspace/test-lists/session-names.json +13 -0
  81. package/workspace/test-lists/stage-card.json +6 -0
  82. package/workspace/tk-tasks-test.js +1 -1
  83. package/workspace/workflows-setup-test.js +17 -0
@@ -1,11 +1,13 @@
1
1
  /* goal-chat — the panel's half of `/goal` (initiative premium-chat-session, slice 2; PRD G1, G4, G5, G7). Pure: no DOM, so Node tests it.
2
2
  * Claude ends each grilling message with a fenced `pmos-goal` JSON block (lib/goal-chat.js writes the rule into the prompt). This module
3
- * splits that block off the words, draws a question as chips and a ready goal as one card, and shows the PM's PMOS-typed turns as typed. */
3
+ * splits that block off the words and draws the goal before Start (XcbOptions B, row 1): the method line with Change, a row of dots (one per
4
+ * point the method needs), the question with tap answers, and the ready plan as a card in the chat with Start, Change and Cancel as icons,
5
+ * which Change turns into an editor in place. It also shows the PM's PMOS-typed turns as typed. */
4
6
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
5
7
 
6
8
  /** The `/` menu (G1): PMOS's /goal, then Claude Code's own commands. */
7
9
  export const SLASH = [
8
- { cmd: '/goal', name: 'Give Claude a goal', say: 'It asks a few questions to make the goal SMART, then works on it after you press Start.' },
10
+ { cmd: '/goal', name: 'Give Claude a goal', say: 'It picks a way to ask about the goal, asks a few questions, then works on it after you press Start.' },
9
11
  { cmd: '/compact', name: 'Compact the conversation', say: 'Claude Code summarises the conversation so far to free room.' },
10
12
  { cmd: '/clear', name: 'Clear the conversation', say: 'Claude Code starts again with an empty context in the same session.' },
11
13
  ];
@@ -27,28 +29,105 @@ export function splitGoal(text) {
27
29
  return { text: (t.slice(0, last.index) + t.slice(last.index + last[0].length)).trim(), block: block && typeof block === 'object' ? block : null };
28
30
  }
29
31
 
30
- const MARK = { grill: '[PMOS /goal]', start: '[PMOS /goal start]', cancel: '[PMOS /goal cancel]' };
32
+ const MARK = { grill: '[PMOS /goal]', start: '[PMOS /goal start]', cancel: '[PMOS /goal cancel]', method: '[PMOS /goal method]', plan: '[PMOS /goal plan]', skip: '[PMOS /goal skip]', unskip: '[PMOS /goal unskip]' };
33
+ /** The questioning methods, as lib/goal-chat.js METHODS has them (goal-chat.test.js M1 keeps the two lists the same). */
34
+ export const METHODS = [
35
+ { id: 'done-criteria', name: 'Done criteria', fits: 'it ends in a deliverable, such as a document or a release', points: ['What it delivers', 'The done points', 'By when', 'What it may do'] },
36
+ { id: 'pre-mortem', name: 'Pre-mortem', fits: 'a risky launch or change', points: ['What ships', 'How it could fail', 'What prevents each failure', 'By when'] },
37
+ { id: 'outcome', name: 'Outcome and measure', fits: 'it moves a metric', points: ['The outcome', 'The measure and its target', 'The baseline', 'By when'] },
38
+ { id: 'problem', name: 'Problem statement', fits: 'discovery, while the problem is not clear yet', points: ['The problem', 'Who has it', 'The evidence', 'What we want to learn'] },
39
+ { id: 'smart', name: 'SMART', fits: 'any other goal', points: ['Specific', 'Measurable', 'Achievable', 'Relevant', 'Time-bound'] },
40
+ ];
41
+ const methodOf = (id) => METHODS.find((m) => m.id === id) || null;
42
+ /** The message the PM's pick in the method menu sends (lib/goal-chat.js methodMessage writes the same words). */
43
+ export const methodSay = (id) => { const m = methodOf(id); return m ? MARK.method + ' Use the ' + m.name + ' method for this goal instead. Its points: ' + m.points.join('; ') + '. Keep what is already agreed where it fits, and ask from there.' : null; };
31
44
  const OPENING = 'The PM is talking to you from the '; // the chat panel of an item, or the Chat page (lib/briefing-premium-agent.js openingFor)
45
+ /* The PM's words after the last "The PM says: ". A follow-up typed into a live session has its line breaks turned into spaces (server.js
46
+ * chatSessions.type), so the break before it may be a space (bug 2026-10-25: the New workflow chat showed its rule as the PM's turn). */
47
+ const SAYS_RE = /(?:^|\s)The PM says: /g;
48
+ function pmSays(t) { let at = -1, m; SAYS_RE.lastIndex = 0; while ((m = SAYS_RE.exec(t))) at = m.index + m[0].length; return at >= 0 ? t.slice(at) : null; }
32
49
  /** The PM's turn as the PM typed it (G7): `/goal Ship X` for the grilling prompt, a short line for Start and Cancel, and only the PM's
33
50
  * words for the opening message that carries the row's context. Anything else is shown unchanged. */
34
51
  export function shownUser(text) {
35
52
  const t = String(text == null ? '' : text);
36
53
  if (t.includes(MARK.start)) return 'Start the goal';
54
+ if (t.startsWith(MARK.method)) { const m = /Use the (.+?) method/.exec(t); return 'Ask with ' + (m ? m[1] : 'another method'); }
55
+ if (t.startsWith(MARK.plan)) return 'Changed the plan';
56
+ if (t.startsWith(MARK.skip)) { const m = /done point "([\s\S]*?)"\./.exec(t); return 'Skip: ' + (m ? m[1] : 'a point'); }
57
+ if (t.startsWith(MARK.unskip)) { const m = /done point "([\s\S]*?)" counts/.exec(t); return 'Keep: ' + (m ? m[1] : 'a point'); }
37
58
  const r = /\[PMOS \/goal round (\d+)\]/.exec(t); if (r) return 'Keep going: round ' + r[1];
38
59
  if (t.includes(MARK.cancel)) return 'Cancel the goal';
39
60
  const g = t.indexOf(MARK.grill + ' The PM set a goal: ');
40
61
  if (g >= 0) return '/goal ' + t.slice(g + (MARK.grill + ' The PM set a goal: ').length).split('\n')[0];
41
- if (t.startsWith(OPENING)) { const i = t.lastIndexOf('\nThe PM says: '); if (i >= 0) return t.slice(i + '\nThe PM says: '.length); }
42
- if (t.startsWith('[PMOS report]') || t.startsWith('[PMOS program]') || t.startsWith('[PMOS workflow]')) { const i = t.lastIndexOf('\nThe PM says: '); if (i >= 0) return t.slice(i + '\nThe PM says: '.length); } // premium-reports-from-chat: lib/report-chat.js wrap; lib/program-chat.js wrap; lib/workflow-chat.js wrap
62
+ if (t.startsWith(OPENING) || t.startsWith('[PMOS report]') || t.startsWith('[PMOS program]') || t.startsWith('[PMOS workflow]')) { const s = pmSays(t); if (s != null) return s; } // premium-reports-from-chat: lib/report-chat.js wrap; lib/program-chat.js wrap; lib/workflow-chat.js wrap
43
63
  return t;
44
64
  }
45
65
 
46
66
  const LETTERS = [['S', 'goal'], ['M', 'done'], ['A', 'may'], ['R', 'serves'], ['T', 'by']];
47
67
  const has = (d, k) => d && (k === 'done' ? Array.isArray(d.done) && d.done.length > 0 : !!d[k]);
48
- /** S M A R T, filled for the points the draft holds. */
49
- export const smartHtml = (d) => `<div class="smart" aria-label="SMART points filled">${LETTERS.map(([l, k]) => `<b class="${has(d, k) ? 'y' : ''}" title="${esc(k)}">${l}</b>`).join('')}</div>`;
68
+ /** The points the method needs, each agreed or not: the block's own list, else SMART's five read from the draft. */
69
+ export function pointsOf(block) {
70
+ const ps = block && Array.isArray(block.points) ? block.points.filter((p) => p && (p.name || typeof p === 'string')).slice(0, 8) : [];
71
+ if (ps.length) return ps.map((p) => (typeof p === 'string' ? { name: p, agreed: block.step === 'ready' } : { name: String(p.name), agreed: block.step === 'ready' || !!p.agreed }));
72
+ const d = (block && block.draft) || {};
73
+ return LETTERS.map(([, k]) => ({ name: k, agreed: (block && block.step === 'ready') || has(d, k) }));
74
+ }
75
+ /** The row of dots that replaces the S M A R T letters: one per point, filled as points are agreed. */
76
+ export function dotsHtml(points) {
77
+ const n = points.length, y = points.filter((p) => p.agreed).length;
78
+ return `<div class="gdots" role="img" aria-label="${y} of ${n} points agreed">${points.map((p) => `<i class="${p.agreed ? 'y' : ''}" title="${esc(p.name)}"></i>`).join('')}</div>`;
79
+ }
80
+ /** The old letters, kept for a draft with no block (the Viewer of an older goal). */
81
+ export const smartHtml = (d) => dotsHtml(LETTERS.map(([, k]) => ({ name: k, agreed: has(d, k) })));
82
+
83
+ const P = (d, n = 18, w = 2) => `<svg width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
84
+ export const ICON = { go: 'M5 12h14M13 6l6 6-6 6', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4', x: 'M6 6l12 12M18 6 6 18', ok: 'M5 12.5l4.5 4.5L19 7', plus: 'M12 5v14M5 12h14',
85
+ grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M6 9l6 6 6-6', undo: 'M9 14 4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11' };
86
+ const icb = (attr, label, icon, pri) => `<button type="button" class="icb${pri ? ' pri' : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${P(icon, 18, icon === ICON.ok ? 2.4 : 2)}</button>`;
87
+
88
+ /** The method line over a question: "Method: Done criteria ⌄ it ends in a document". live: Change opens the menu of the other methods. */
89
+ export function methodHtml(block, { live = false, open = false } = {}) {
90
+ const m = methodOf(block && block.method), name = m ? m.name : block && block.method ? String(block.method) : '';
91
+ if (!name) return '';
92
+ const why = block.why ? String(block.why) : m ? m.fits : '';
93
+ const inner = `Method: <b>${esc(name)}</b>${live ? P(ICON.down, 14) : ''}${why ? `<em>${esc(why)}</em>` : ''}`;
94
+ if (!live) return `<p class="gmeth">${inner}</p>`;
95
+ const menu = `<span class="gmenu" role="menu" aria-label="Ask with another method"${open ? '' : ' hidden'}>${METHODS.filter((x) => !m || x.id !== m.id).map((x) => `<button type="button" role="menuitem" data-goal-method="${esc(x.id)}"><b>${esc(x.name)}</b><em>${esc(x.fits)}</em></button>`).join('')}</span>`;
96
+ return `<span class="gmw"><button type="button" class="gmeth" data-goal-meth aria-haspopup="menu" aria-expanded="${open}" title="Change the method">${inner}</button>${menu}</span>`;
97
+ }
98
+
99
+ /** The ready plan as a card in the chat: the dots, the goal, Done when, By and It may (assumed marked), then Start, Change and Cancel as icons
100
+ * while live. A plan with no goal or no done point cannot start. state: the goal record's state (cancelled shows it, quietly). */
101
+ export function planHtml(d, { live = false, state = 'grilling', points = null } = {}) {
102
+ if (!d || typeof d !== 'object') return '';
103
+ const a = new Set(Array.isArray(d.assumed) ? d.assumed : []);
104
+ const done = Array.isArray(d.done) ? d.done : [];
105
+ const ok = !!(d.goal && done.length);
106
+ const tag = (k) => (a.has(k) ? ' <em>assumed</em>' : '');
107
+ const kv = [d.by ? `By <span>${esc(d.by)}</span>${tag('by')}` : '', d.may ? `It may <span>${esc(d.may)}</span>${tag('may')}` : ''].filter(Boolean).join(' · ');
108
+ const acts = live && (!state || state === 'grilling')
109
+ ? `<div class="acts">${ok ? icb('data-goal="start"', 'Start', ICON.go, true) : ''}${icb('data-goal="change"', 'Change the plan', ICON.pen)}${icb('data-goal="cancel"', 'Cancel the goal', ICON.x)}</div>` : '';
110
+ return `<div class="gplan">${dotsHtml(points || pointsOf({ step: 'ready', draft: d }))}<button type="button" class="gpt" data-goal-open title="Open the whole plan in the Viewer">${esc(d.goal || 'Goal')}</button>`
111
+ + (done.length ? `<p class="pk2">Done when</p><ul>${done.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` : '')
112
+ + (kv ? `<p class="pk2">${kv}</p>` : '') + (state === 'cancelled' ? '<p class="pk2">Cancelled</p>' : '') + acts + '</div>';
113
+ }
114
+ /** The same card as an editor in place: each point a field with a drag handle and ×, + adds one, By and It may are fields, ✓ saves and
115
+ * × discards. d: the plan as it was when the editor opened; the page keeps what is typed and puts it back after a redraw (home-chat.js). */
116
+ export function planEditHtml(d) {
117
+ const done = Array.isArray(d.done) && d.done.length ? d.done : [''];
118
+ const row = (x, i) => `<li data-gi="${i}"><button type="button" class="grip" data-goal-grip aria-label="Move this point (arrow keys)" title="Drag to move">${P(ICON.grip, 16, 3)}</button>`
119
+ + `<textarea class="fld" rows="1" data-goal-fld="done" aria-label="Done point ${i + 1}">${esc(x)}</textarea>`
120
+ + `<button type="button" class="rx" data-goal-rm aria-label="Remove this point" title="Remove this point">${P(ICON.x, 14, 2.2)}</button></li>`;
121
+ return `<div class="gplan ed" data-goal-ed><b class="gpt">${esc(d.goal || 'Goal')}</b>`
122
+ + `<p class="pk2">Done when</p><ol class="edl">${done.map(row).join('')}</ol>`
123
+ + `<button type="button" class="addp" data-goal-add aria-label="Add a point" title="Add a point">${P(ICON.plus, 16, 2.2)}</button>`
124
+ + `<p class="pk2 kv"><label>By <input class="fld s" data-goal-fld="by" value="${esc(d.by || '')}" placeholder="a date"></label><label>It may <input class="fld s" data-goal-fld="may" value="${esc(d.may || '')}" placeholder="what it may do"></label></p>`
125
+ + `<div class="acts">${icb('data-goal-save', 'Save the plan', ICON.ok, true)}${icb('data-goal-discard', 'Discard the changes', ICON.x)}</div></div>`;
126
+ }
127
+ /** One new point row for the editor (the + press). */
128
+ export const planRowHtml = (i) => planEditHtml({ done: [''] }).match(/<li[\s\S]*?<\/li>/)[0].replace('data-gi="0"', `data-gi="${i}"`).replace('Done point 1', 'Done point ' + (i + 1));
50
129
 
51
- /** The goal as a card (G5): every value, "assumed" on the defaulted ones. */
130
+ /** The goal as a card in the Viewer (G5): every value, "assumed" on the defaulted ones. */
52
131
  export function goalCard(d, state) {
53
132
  const a = new Set(Array.isArray(d.assumed) ? d.assumed : []);
54
133
  const row = (k, label, v) => (v ? `<dt>${label}</dt><dd${a.has(k) ? ' class="assumed"' : ''}>${v}</dd>` : '');
@@ -57,18 +136,20 @@ export function goalCard(d, state) {
57
136
  return `<div class="gcard"><div class="grow"><b>${esc(d.goal || 'Goal')}</b><span class="gpill">${pill}</span></div><dl class="gkv">${row('done', 'Done when', done)}${row('may', 'It may', esc(d.may))}${row('serves', 'Serves', esc(d.serves))}${row('by', 'By', esc(d.by))}${row('limit', 'Limit', esc((Number.isInteger(d.limit) ? d.limit : 12) + ' rounds of work at most'))}</dl></div>`;
58
137
  }
59
138
 
60
- /** The block under Claude's words. live: this is the newest message, Claude is waiting and the goal is still being grilled, so it can be pressed. */
61
- export function goalBlockHtml(block, { live = false, state = 'grilling' } = {}) {
139
+ /** The block under Claude's words. live: this is the newest message, Claude is waiting and the goal is still being grilled, so it can be
140
+ * pressed. menu: the method menu is open. edit: the plan as it was when the PM pressed Change (the editor shows in place of the card). */
141
+ export function goalBlockHtml(block, { live = false, state = 'grilling', menu = false, edit = null } = {}) {
62
142
  if (!block) return '';
63
143
  const d = block.draft && typeof block.draft === 'object' ? block.draft : {};
64
144
  if (block.step === 'question') {
65
145
  const opts = (Array.isArray(block.options) ? block.options : []).filter((o) => o && o.label).slice(0, 4);
66
- const chips = live ? `<div class="chips">${opts.map((o) => `<button type="button" class="chip${o.recommended ? ' rec' : ''}" data-chat-say="${esc(o.label)}">${esc(o.label)}${o.recommended ? '<small>recommended</small>' : ''}</button>`).join('')}<button type="button" class="chip" data-chat-say="Start with defaults">Start with defaults</button></div>` : '';
67
- return `${smartHtml(d)}<p class="tt"><b>${esc(block.question || '')}</b></p>${chips}`;
146
+ const chips = live ? `<div class="gchips">${opts.map((o) => `<button type="button" class="gchip${o.recommended ? ' rec' : ''}" data-chat-say="${esc(o.label)}">${esc(o.label)}${o.recommended ? '<small>recommended</small>' : ''}</button>`).join('')}</div>` : '';
147
+ return `<div class="gq">${methodHtml(block, { live: live && state === 'grilling', open: menu })}${dotsHtml(pointsOf(block))}<p class="tt"><b>${esc(block.question || '')}</b></p>${chips}</div>`;
68
148
  }
69
149
  if (block.step === 'ready') {
70
- // the plan, SMART and Start / Change / Cancel are in the viewer's Goal tab (goalViewHtml); once started, the progress chip at the end stands for it
71
- return !state || state === 'grilling' || state === 'cancelled' ? goalChipHtml({ draft: d, state }) : '';
150
+ // the plan is Claude's newest message, in the chat (XcbOptions B); once started, the progress line stands for it and the card stays as it was
151
+ if (live && edit) return planEditHtml(edit);
152
+ return planHtml(d, { live, state, points: pointsOf(block) });
72
153
  }
73
154
  if (block.step === 'progress') {
74
155
  const met = Array.isArray(block.met) ? block.met.length : 0, open = Array.isArray(block.open) ? block.open.length : 0;
@@ -78,11 +159,36 @@ export function goalBlockHtml(block, { live = false, state = 'grilling' } = {})
78
159
  return '';
79
160
  }
80
161
 
81
- const WHY = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.' };
162
+ /** The plan the editor wrote, as one pmos-goal draft: empty points dropped, the rest of the draft kept. fields: { goal, done[], by, may }. */
163
+ export function editedDraft(base, fields) {
164
+ const t = (x) => String(x == null ? '' : x).replace(/\s+/g, ' ').trim();
165
+ const out = { ...(base || {}) };
166
+ out.goal = t(fields.goal) || t(out.goal);
167
+ out.done = (fields.done || []).map(t).filter(Boolean);
168
+ for (const k of ['by', 'may']) { const v = t(fields[k]); if (v) out[k] = v; else delete out[k]; }
169
+ // a value the PM typed is no longer assumed
170
+ if (Array.isArray(out.assumed)) out.assumed = out.assumed.filter((k) => !['goal', 'done', 'by', 'may'].includes(k) || t(fields[k] == null ? '' : [].concat(fields[k]).join()) === t([].concat((base || {})[k] == null ? '' : base[k]).join()));
171
+ return out;
172
+ }
173
+
174
+ /** The choice when /goal is typed while a goal works here: one goal runs in a chat at a time. here: the working goal's sentence.
175
+ * newChat: false where this page cannot open a new chat (then only "Here" is offered). Esc or another message closes it (home-chat.js). */
176
+ export function goalChoiceHtml(here, { newChat = true } = {}) {
177
+ return `<div class="hm-a gchoice"><div class="hm-ab"><div class="askc" role="group" aria-label="Where should the new goal go?"><p class="k">One goal runs in a chat at a time</p><b>Where should the new goal go?</b><div class="gchips">`
178
+ + (newChat ? `<button type="button" class="gchip rec" data-goal-where="new">In a new chat<small>recommended · this goal keeps going</small></button>` : '')
179
+ + `<button type="button" class="gchip" data-goal-where="here">Here, instead of this goal<small class="warn">stops “${esc(here || 'the goal')}”</small></button>`
180
+ + '</div></div></div></div>';
181
+ }
182
+
183
+ const WHY = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.', replaced: 'You replaced it with a new goal.' };
82
184
  const GICO = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8"/></svg>';
185
+ /** The done points that still count: the draft's, less the ones the PM skipped (lib/goal-chat.js requiredOf). */
186
+ const requiredOf = (goal) => ((goal && goal.draft && Array.isArray(goal.draft.done)) ? goal.draft.done : []).filter((x) => !((goal && goal.skipped) || []).includes(x));
187
+ /** May the PM still take a skip back? Until Claude's next round after the skip (lib/goal-chat.js decide unskip). */
188
+ export const undoable = (goal, p) => !!(goal && goal.skipAt && goal.skipAt[p]) && !(Date.parse(goal.skipAt[p]) <= Date.parse(goal.roundAt || ''));
83
189
  /** What the chip under the goal says: its state, then the done points met once it has started. */
84
190
  function goalLine(goal) {
85
- const d = goal.draft || {}, all = Array.isArray(d.done) ? d.done.length : 0, met = Array.isArray(goal.met) ? goal.met.length : 0;
191
+ const req = requiredOf(goal), all = req.length, met = (goal.met || []).filter((x) => req.includes(x)).length;
86
192
  const word = { started: 'Working', done: 'Done', waiting: 'Needs you', stopped: 'Stopped', cancelled: 'Cancelled' }[goal.state] || 'Not started';
87
193
  return ['started', 'done', 'waiting', 'stopped'].includes(goal.state) ? `${word} · ${met} of ${all} done points` : word + (all ? ` · ${all} done points` : '');
88
194
  }
@@ -92,14 +198,16 @@ export function goalChipHtml(goal) {
92
198
  if (!goal || !goal.draft) return '';
93
199
  return `<div class="ctxc"><button type="button" class="ctxchip lead" data-goal-open title="Open the goal in the viewer">${GICO}<span><b>${esc(goal.draft.goal || 'Goal')}</b><em>Goal · ${esc(goalLine(goal))}</em></span></button></div>`;
94
200
  }
95
- /** The viewer's Goal tab. goal: the GET /thread goal record; draft: the newest ready draft in the conversation; live: Start can be pressed.
96
- * A goal that has started shows its progress with Stop; one still being grilled shows the plan, with Start, Change and Cancel while live. */
97
- export function goalViewHtml(goal, draft, { live = false } = {}) {
201
+ /** The viewer's Goal tab. goal: the GET /thread goal record; draft: the newest ready plan in the conversation; live: Start can be pressed;
202
+ * edit: the plan as it was when the PM pressed Change, drawn as the editor. A goal that has started shows its progress; one still being
203
+ * grilled shows the whole plan, with Start, Change and Cancel as icons while live. */
204
+ export function goalViewHtml(goal, draft, { live = false, edit = null } = {}) {
205
+ if (edit && (live || (goal && (goal.state === 'started' || goal.state === 'waiting')))) return `<div class="vwdoc vwgoal">${planEditHtml(edit)}</div>`;
98
206
  const gp = goalProgressHtml(goal);
99
207
  if (gp) return `<div class="vwdoc vwgoal">${gp}</div>`;
100
208
  if (!draft) return '';
101
209
  const ok = !!(draft.goal && Array.isArray(draft.done) && draft.done.length);
102
- const btns = live && ok ? '<div class="chatopts"><button type="button" class="cta" data-goal="start">Start</button><button type="button" class="cta alt" data-goal="change">Change something</button><button type="button" class="cta alt" data-goal="cancel">Cancel</button></div>' : '';
210
+ const btns = live ? `<div class="acts">${ok ? icb('data-goal="start"', 'Start', ICON.go, true) : ''}${icb('data-goal="change"', 'Change the plan', ICON.pen)}${icb('data-goal="cancel"', 'Cancel the goal', ICON.x)}</div>` : '';
103
211
  return `<div class="vwdoc vwgoal">${smartHtml(draft)}${goalCard(draft, goal && goal.state)}${btns}</div>`;
104
212
  }
105
213
  /** What the chip and the peek bar say about the goal now, and a key that changes when its state or progress does. */
@@ -113,14 +221,24 @@ export function goalNow(goal, draft) {
113
221
  * goal: the GET /thread goal record. The done check is Claude's own report, so it says "unverified". */
114
222
  export function goalProgressHtml(goal) {
115
223
  if (!goal || !goal.draft || !['started', 'done', 'stopped', 'waiting'].includes(goal.state)) return '';
116
- const d = goal.draft, all = Array.isArray(d.done) ? d.done : [], met = new Set(goal.met || []);
224
+ const d = goal.draft, all = Array.isArray(d.done) ? d.done : [], met = new Set(goal.met || []), req = requiredOf(goal), skipped = new Set(goal.skipped || []);
225
+ const working = goal.state === 'started' || goal.state === 'waiting';
226
+ const now = req.find((x) => !met.has(x)); // the point Claude is on: it cannot be skipped with ×
117
227
  const limit = Number.isInteger(d.limit) ? d.limit : 12;
118
228
  const pill = goal.state === 'started' ? 'Working · round ' + Math.max(1, (goal.rounds || 0) + 1) + ' of ' + limit
119
229
  : goal.state === 'done' ? 'Done, as Claude reports it' : goal.state === 'waiting' ? 'Needs you' : 'Stopped';
120
230
  const note = goal.state === 'stopped' ? (WHY[goal.reason] || 'It stopped.') + ' Send a message to go on, or /goal to set a new goal.'
121
231
  : goal.state === 'waiting' ? 'Claude needs your answer above. Your reply lets it go on.'
122
232
  : goal.state === 'done' ? 'Check the work before you rely on it. Claude checked its own points.' : 'Claude keeps working until every point is met, the deadline, or ' + limit + ' rounds.';
123
- const pts = all.map((x) => `<li class="${met.has(x) ? 'm' : ''}"><i aria-hidden="true"></i><span>${esc(x)}</span><em>${met.has(x) ? 'met' : 'open'}</em></li>`).join('');
233
+ // skip a point (XcbOptions B row 2): × on a point that has not started; struck through with Undo until Claude's next round
234
+ const act = (x) => {
235
+ if (!working || met.has(x)) return '';
236
+ if (skipped.has(x)) return undoable(goal, x) ? `<button type="button" class="rx" data-goal-unskip="${esc(x)}" aria-label="Undo the skip" title="Undo the skip">${P(ICON.undo, 15, 2.2)}</button>` : '';
237
+ return x !== now && req.length > 1 ? `<button type="button" class="rx" data-goal-skip="${esc(x)}" aria-label="Skip this point" title="Skip this point">${P(ICON.x, 14, 2.2)}</button>` : '';
238
+ };
239
+ const word = (x) => (skipped.has(x) ? (undoable(goal, x) ? 'Skipped by you · Claude drops it after this step' : 'Skipped by you') : met.has(x) ? 'met' : working && x === now ? 'now · Stop or tell Claude to skip it' : 'open');
240
+ const pts = all.map((x) => `<li class="${met.has(x) ? 'm' : skipped.has(x) ? 'sk' : ''}"><i aria-hidden="true"></i><span>${skipped.has(x) ? `<s>${esc(x)}</s>` : esc(x)}</span><em>${esc(word(x))}</em>${act(x)}</li>`).join('');
124
241
  const stop = goal.state === 'started' ? '<div class="chatopts"><button type="button" class="cta alt" data-goal="stop">Stop the goal</button></div>' : '';
125
- return `<div class="gcard gprog2" role="status"><div class="grow"><b>${esc(d.goal)}</b><span class="gpill">${esc(pill)}</span></div><p class="gprog">${met.size} of ${all.length} done points met · unverified${d.by ? ' · due ' + esc(d.by) : ''}</p><ul class="gpts">${pts}</ul><p class="gprog">${esc(note)}</p>${stop}</div>`;
242
+ const pen = working ? icb('data-goal="change"', 'Change the plan', ICON.pen) : '';
243
+ return `<div class="gcard gprog2" role="status"><div class="grow"><b>${esc(d.goal)}</b><span class="gpill">${esc(pill)}</span>${pen}</div><p class="gprog">${req.filter((x) => met.has(x)).length} of ${req.length} done points met · unverified${d.by ? ' · due ' + esc(d.by) : ''}</p><ul class="gpts">${pts}</ul><p class="gprog">${esc(note)}</p>${stop}</div>`;
126
244
  }
@@ -21,6 +21,7 @@ import * as H from './home-data.js';
21
21
  import { mountChat, avHtml } from './home-chat.js';
22
22
  import * as MORE from './home-more.js';
23
23
  import { headModel, STEPS } from './premium-initiative-head.js';
24
+ import * as SC from './home-stage-card.js'; // the initiative's stage card D
24
25
  import * as WFM from './ini-wf-model.js'; // D99: the workflow an initiative runs (kind line, usual days)
25
26
  import { wfIcon, wfOf } from './wf-model.js';
26
27
  import { startAgent } from './page-agent.js';
@@ -33,7 +34,8 @@ import * as YD from './home-day.js'; // Your day in the Viewer (XvAPhDay)
33
34
  import { canDictate, dictate } from './home-dictate.js';
34
35
  import { mountIni, iniList, iniOverview, iniPage } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
35
36
  import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
36
- import { mountRecRow } from './home-rec-row.js';
37
+ import { mountRecRow, clockOf as recClock } from './home-rec-row.js';
38
+ import { mountSesName } from './home-ses-name.js'; // session names A: tap the session's name to rename it (canvas XmsNames)
37
39
  import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
38
40
 
39
41
  const $ = (s, r = document) => r.querySelector(s);
@@ -81,7 +83,7 @@ const S = {
81
83
  sel: null, // the selected row's id
82
84
  allNeeds: false, kids: new Set(), shut: new Set(JSON.parse(store.get('pmos.home.shut') || '[]')), folded: store.get('pmos.home.fold') === '1',
83
85
  IM: null, IMid: null, // the selected initiative's model (GET /api/initiative-premium)
84
- doneOpen: false, sheet: false, rec: {}, pin: new Set(JSON.parse(store.get('pmos.home.pin') || '[]')),
86
+ doneOpen: false, stepsMore: false, sheet: false, rec: {}, pin: new Set(JSON.parse(store.get('pmos.home.pin') || '[]')),
85
87
  cardFold: store.get('pmos.home.cardfold') === '1', // the card's checklist folded to one line (AgInitSpec), kept in this browser
86
88
  // the one list (premium-uncovered-features): the filter, the picked product, which groups and initiatives are open, kept in this browser
87
89
  filter: 'today', product: store.get('pmos.home.product') || null, kidsOff: new Set(), rest: new Set(), tasks: new Set(), cap: false, day: false,
@@ -135,7 +137,7 @@ async function load() {
135
137
  const [brief, board, ses, desk, today, sch, work, day, rev, progs] = await Promise.all([
136
138
  getRetry('/api/briefing-premium' + wsQ()), getRetry('/api/board-premium' + wsQ() + boardQ(WS ? '&' : '?')), pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ()),
137
139
  pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()), pmGet('/api/my-work-premium' + wsQ()), pmGet('/api/phone-day'), pmGet('/api/home-review' + wsQ()),
138
- pmGet('/api/programs'),
140
+ pmGet('/api/programs'), MEN.load(menCtx()),
139
141
  ]);
140
142
  const D = S.D;
141
143
  D.brief = brief && brief.ok && brief.model ? brief.model : null;
@@ -202,6 +204,9 @@ function poll() {
202
204
  }, 8000);
203
205
  }
204
206
  setInterval(() => { if (!document.hidden) load(); }, 300000);
207
+ // back on this tab (a program or an initiative made on the Board in another tab): read again at once, at most every 15 seconds
208
+ let shownAt = Date.now();
209
+ document.addEventListener('visibilitychange', () => { if (document.hidden || Date.now() - shownAt < 15000) return; shownAt = Date.now(); load(); });
205
210
  window.addEventListener('hm:reload', () => load());
206
211
 
207
212
  /* ── the list ── */
@@ -327,8 +332,17 @@ const ckTitle = (t, ms) => { const m = ms && /^(To reach |To finish )(.+)$/.exec
327
332
  const wfPill = (id) => { const w = wfOf(iniRowOf(id) || {}); return `<button type="button" class="hm-wf" data-hm-wf aria-haspopup="listbox" aria-expanded="false" aria-label="Workflow: ${esc(w.name)}. Change" title="${esc(w.name)} · Change">${wfIcon(w, 18)}</button>`; };
328
333
  /** "Tender · KR 2.1": the workflow an initiative runs and its anchor, the kind line over its name (D99: Kind becomes Workflow). */
329
334
  function kindOf(id) { return WFM.kindLine(iniRowOf(id) || {}); }
330
- function cardHtml(id) {
335
+ function cardHtml(id, o = {}) {
331
336
  const prod = id === 'product';
337
+ // the initiative's page: the stage card as a live step list (agreed stage card D); o.tail(h) draws its last node (home-ini.js)
338
+ if (!prod) {
339
+ const r = iniRowOf(id) || { title: (S.IM && S.IM.title) || id };
340
+ const h = headOf(id); S.H = h;
341
+ if (r.kr && h.anchor && r.kr !== h.anchor) { h.payoff = String(h.payoff || '').split(h.anchor).join(r.kr); h.anchor = r.kr; } // "Moves KR 2.1", the board's own name
342
+ const at = S.D.sessions.find((s) => H.iniOfSession(s) === id && s.shown === 'working');
343
+ const run = at ? { title: (at.hx && at.hx.title) || '', created: at.created || '' } : null;
344
+ return SC.stageCardHtml(h, { title: r.title, wf: wfPill(id), doneOpen: S.doneOpen, moreOpen: S.stepsMore, run, now: Date.now(), tail: o.tail ? o.tail(h) : '' });
345
+ }
332
346
  let kind, title, turn, turnLabel, stage, lad = '', bars = '', ckh, items, then, time, cta, primary, over = false, foldSum = '', msNext = false;
333
347
  if (prod) {
334
348
  const C = H.productCard(S.D, S.D.now);
@@ -338,21 +352,6 @@ function cardHtml(id) {
338
352
  then = C.payoff; time = C.time; cta = C.cta; primary = !C.sent;
339
353
  const risk = C.items.filter((x) => x.kind === 'risk').length;
340
354
  foldSum = C.of + (risk ? ' · ' + risk + ' at risk' : '');
341
- } else {
342
- const r = iniRowOf(id) || { title: (S.IM && S.IM.title) || id };
343
- const h = headOf(id); S.H = h;
344
- kind = kindOf(id);
345
- title = r.title; turn = h.turn; turnLabel = h.turnLabel; stage = h.stage;
346
- lad = `<p class="hm-lad" role="img" aria-label="${esc(h.ladderAria)}">${h.prev ? `<span class="pv">${SVG(I.check, 11, 2.6)}${esc(h.prev)}</span>${SVG(I.chev, 11, 2.2)}` : ''}<b>${esc(h.cur)}</b>${h.toReach && h.toReach !== 'Done' ? SVG(I.chev, 11, 2.2) + `<span class="nx">${msStep(h.toReach) ? MS : ''}${esc(h.toReach)}</span>` : ''}</p>`;
347
- bars = `<div class="hm-bars" aria-hidden="true">${h.steps.map((s) => `<i class="${s.cls}"></i>`).join('')}</div>`;
348
- ckh = [h.checkTitle, h.doneOf];
349
- const doneRow = h.done.length ? `<button type="button" class="hm-it donerow" data-hm-done aria-expanded="${S.doneOpen}">${markHtml('done')}<span class="l">${h.done.length} done${S.doneOpen ? '' : ': ' + esc(h.done.map((x) => x.label).join(' · '))}</span>${SVG(S.doneOpen ? 'M6 15l6-6 6 6' : I.down, 12, 2.2)}</button>` : '';
350
- // the agent at work on this initiative: its avatar marks an agent step (AgInitAgents); with none at work the step is next
351
- const at = S.D.sessions.find((s) => H.iniOfSession(s) === id && s.shown === 'working');
352
- const io = { role: at ? H.roleOf(at, S.D.desk && S.D.desk.roles) : null, stalled: h.turn === 'stalled' };
353
- items = doneRow + (S.doneOpen ? h.done.map((x) => itemHtml(x, io)).join('') : '') + h.rest.map((x) => itemHtml(x, io)).join('');
354
- then = h.payoff; time = h.time; over = h.over; cta = h.cta; primary = h.primary;
355
- foldSum = h.foldSum; msNext = msStep(h.toReach);
356
355
  }
357
356
  // on the initiative's page the Viewer's header names it (kind, title, New session): the card is its stage box alone (HbCDesk)
358
357
  return `<section class="hm-card hm-pcard" aria-label="${esc(title)}">`
@@ -389,6 +388,22 @@ function drawList() {
389
388
  if (PHC && PHC.el.parentNode === sc) PHC.el.remove();
390
389
  document.body.classList.toggle('hm-folded', S.folded && !isPhone());
391
390
  document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
391
+ drawRecTop();
392
+ }
393
+ /* A phone chat has no floating menu, so while a meeting records its pill sits in the top bar (XcbOptions B, case 7): a red dot and the
394
+ * clock (home-rec-row.js ticks every [data-hr-clock]); a press opens the live meeting in place. No recording: no pill. */
395
+ function drawRecTop() {
396
+ let st; try { st = RECROW.state(); } catch { return; } // the recording row is mounted after the first draw
397
+ const t = $('#hmTop'); if (!t) return;
398
+ let a = $('#hmRecTop');
399
+ if (!a) { t.querySelector('.hm-top-t').insertAdjacentHTML('afterend', '<button type="button" class="hm-recp" id="hmRecTop" hidden></button>'); a = $('#hmRecTop'); a.onclick = () => { if (a.dataset.id) openMeeting({ note: a.dataset.id }); }; }
400
+ if (!st || !st.on) { a.hidden = true; return; }
401
+ const ms = st.elapsedMs + (st.paused ? 0 : Math.max(0, Date.now() - (st.readAt || Date.now())));
402
+ a.dataset.id = st.id; a.classList.toggle('paused', !!st.paused);
403
+ a.setAttribute('aria-label', 'Back to the recording: ' + st.title + (st.paused ? ', paused' : ''));
404
+ const h = `<span class="pill"><i aria-hidden="true"></i><span data-hr-clock>${esc(recClock(ms))}</span></span>`;
405
+ if (a.__h !== h) { a.__h = h; a.innerHTML = h; }
406
+ a.hidden = false;
392
407
  }
393
408
 
394
409
  function draw() { drawList(); drawTop(); chat.refresh(); }
@@ -402,7 +417,7 @@ function allRows() {
402
417
  for (const g of M.groups) { (g.flat || []).forEach(add); (g.inis || []).forEach(add); (g.rest || []).forEach(add); (g.rows || []).forEach(add); (g.tasks || []).forEach(add); }
403
418
  if (M.list) M.list.rows.forEach(add);
404
419
  if (S.filter !== 'today') { const T = L.homeList(S.D, { now: NOW() }); T.groups.forEach((g) => { (g.rows || []).forEach(add); (g.inis || []).concat(g.rest || []).forEach(add); }); }
405
- for (const s of S.D.sessions) { const r = { id: 's:' + s.id, kind: 'session', sid: s.id, key: H.keyOfSession(s), ini: H.iniOfSession(s), name: (s.hx && s.hx.title) || s.name, role: H.roleOf(s, S.D.desk && S.D.desk.roles), state: s.shown }; out.push(r); }
420
+ for (const s of S.D.sessions) { const r = { id: 's:' + s.id, kind: 'session', sid: s.id, key: H.keyOfSession(s), ini: H.iniOfSession(s), name: H.nameOf(s), role: H.roleOf(s, S.D.desk && S.D.desk.roles), state: s.shown }; out.push(r); }
406
421
  return out;
407
422
  }
408
423
  const rowById = (id) => allRows().find((r) => r.id === id) || null;
@@ -411,11 +426,19 @@ const rowById = (id) => allRows().find((r) => r.id === id) || null;
411
426
  function drawTop() {
412
427
  const n = H.needsOf(S.D).length;
413
428
  const cur = S.cur || { title: 'Home', sub: '' };
414
- $('#hmTopTitle').textContent = cur.title; $('#hmTopSub').textContent = cur.sub || '';
429
+ // session names A: an open session shows its current name (Claude's or the PM's) and the name is the rename press; the phone's top bar
430
+ // is back + that name only, no second line (XmsNames, XcbOptions)
431
+ const ses = cur.ses ? S.D.sessions.find((x) => x.id === cur.ses) : null;
432
+ const title = ses ? H.nameOf(ses) : cur.title;
433
+ const th = ses && isPhone() ? SN.titleHtml(ses.id, title) : esc(title || '');
434
+ const tb = $('#hmTopTitle'); if (tb.__h !== th) { tb.__h = th; tb.innerHTML = th; }
435
+ $('#hmTopSub').textContent = '';
415
436
  $('#hmNeedsN').textContent = !S.ready ? 'Reading' : n ? n + (n === 1 ? ' next step' : ' next steps') : 'Today';
416
437
  $('#hmNeeds').classList.toggle('loud', n > 0);
417
- document.title = 'PMOS · ' + (cur.title || 'Home');
438
+ document.title = 'PMOS · ' + (title || 'Home');
418
439
  }
440
+ const SN = mountSesName({ esc, pmPost, toast, toastUndo: (m, u) => toastUndo(m, u), session: (sid) => S.D.sessions.find((x) => x.id === sid) || null, shown: (x) => H.nameOf(x),
441
+ changed: () => { drawTop(); chat.refresh(); drawList(); } });
419
442
 
420
443
  /* ── the chat ── */
421
444
  const chat = mountChat($('#hmChat'), {
@@ -432,7 +455,9 @@ const chat = mountChat($('#hmChat'), {
432
455
  linkTo: (sid, ini) => link(sid, ini),
433
456
  dismissLink: (sid) => { try { localStorage.setItem('cz-linksug-x:' + sid, '1'); } catch { /* a private window: it shows again next time */ } },
434
457
  onLink: (b, t) => menu(b, H.boardRows(S.D).map((r) => ({ label: r.title, sub: r.stage, go: () => link(t.sid, r.id) })), 'Link it to an initiative'),
435
- onTo: (b, t) => menu(b, toItems(t), 'Send your messages to'), // @ and the To: chip: which conversation of this initiative you are writing in
458
+ onTo: (b, t) => menu(b, toItems(t), 'Send your messages to'),
459
+ // /goal while a goal works: "In a new chat" opens a fresh session of the same initiative (a loose chat elsewhere) and sends the goal there
460
+ newGoalChat: (text, t) => { const m = /^init:([^:]+)/.exec((t && t.key) || ''); if (m) newIn(m[1]); else newLoose(); chat.send(text); }, // @ and the To: chip: which conversation of this initiative you are writing in
436
461
  workItem: (text, t) => workItem(text, t),
437
462
  openTerminal: (sid) => openTerminal(sid),
438
463
  viewerClosed: () => !VW.isOpen() && !isPhone(),
@@ -448,6 +473,11 @@ function chatHead(t) {
448
473
  const r = S.sel ? rowById(S.sel) : null;
449
474
  if (t.prog) return { row: r, title: t.title, scope: t.prog.title, prog: true };
450
475
  const title = r && r.kind !== 'ini' ? r.name : t.title;
476
+ // session names A: an open session's name is the rename press (or the field while it is renamed)
477
+ if (t.ses) { const s = S.D.sessions.find((x) => x.id === t.ses); if (s) return { ...chatHeadOf(t, r, H.nameOf(s)), titleHtml: SN.titleHtml(s.id, H.nameOf(s), 'hm-chb') }; }
478
+ return chatHeadOf(t, r, title);
479
+ }
480
+ function chatHeadOf(t, r, title) {
451
481
  // the weekly update and the product's own chat sit in the product: its name, no stage track
452
482
  if (t.ini === 'product' || (r && r.ini === 'product')) return { row: r, title, scope: H.productName(S.D) };
453
483
  const ini = t.ini || (r && r.ini) || null;
@@ -464,7 +494,7 @@ function toItems(cur) {
464
494
  const ses = S.D.sessions.filter((s) => H.iniOfSession(s) === id && s.shown !== 'exited');
465
495
  const main = iniTarget(id);
466
496
  return [{ label: 'The initiative’s chat', sub: 'Claude, with ' + iniTitle(id) + ' as its context', checked: at === main.key, go: () => openTarget(main) }]
467
- .concat(ses.map((s) => { const r = H.roleOf(s, S.D.desk && S.D.desk.roles), st = sessionTarget(s); return { label: (s.hx && s.hx.title) || s.name, sub: r.name + ' · another session of this initiative', checked: at === st.key, go: () => openTarget(st) }; }))
497
+ .concat(ses.map((s) => { const r = H.roleOf(s, S.D.desk && S.D.desk.roles), st = sessionTarget(s); return { label: H.nameOf(s), sub: r.name + ' · another session of this initiative', checked: at === st.key, go: () => openTarget(st) }; }))
468
498
  .concat([{ label: 'A new session', sub: 'A fresh conversation in ' + iniTitle(id), go: () => newIn(id) }]);
469
499
  }
470
500
  /* A loose chat's best guess at its initiative, by the words its title and first message share with an initiative's title (XvALinkSuggest).
@@ -511,9 +541,10 @@ function sessionTarget(s) {
511
541
  const key = H.keyOfSession(s);
512
542
  const ini = H.iniOfSession(s);
513
543
  const role = H.roleOf(s, S.D.desk && S.D.desk.roles);
514
- const t = { title: (s.hx && s.hx.title) || s.name, sub: [role.name, ini ? iniTitle(ini) : 'Loose'].join(' · '), ini, role, scope: ini ? scopeOf(ini) : { text: 'Loose', icon: I.chat, loose: true }, rich: rich(), to: rich() ? role : null, also: alsoOf(ini) };
544
+ const t = { title: H.nameOf(s), ses: s.id, sub: [role.name, ini ? iniTitle(ini) : 'Loose'].join(' · '), ini, role, scope: ini ? scopeOf(ini) : { text: 'Loose', icon: I.chat, loose: true }, rich: rich(), to: rich() ? role : null, also: alsoOf(ini) };
515
545
  if (key && /^(decision|blocked|waited|src|ev|work|board|init|doc|ins|chat|pop):/.test(key)) { t.key = key; t.sid = undefined; } else t.sid = s.id;
516
546
  if (!t.key) t.sid = s.id;
547
+ if (/^schedule:/.test(s.origin || '')) t.routine = true; // a scheduled run: a stop reads "Run stopped at 3 of 5" with Run again (home-sweep.js)
517
548
  return t;
518
549
  }
519
550
  function alsoOf(ini) {
@@ -641,7 +672,7 @@ function homeTarget() {
641
672
  empty: 'Ask anything about your work. Claude reads your repositories and works in a real Claude Code session.', also: alsoOf(null) };
642
673
  }
643
674
  function openTarget(t) {
644
- S.cur = { title: t.title, sub: t.sub != null && t.sub !== '' ? t.sub : t.scope && t.scope.text !== t.title ? t.scope.text : '' };
675
+ S.cur = { title: t.title, ses: t.ses || null, sub: t.sub != null && t.sub !== '' ? t.sub : t.scope && t.scope.text !== t.title ? t.scope.text : '' };
645
676
  chat.open(t); drawTop();
646
677
  }
647
678
 
@@ -674,7 +705,7 @@ function select(id, o = {}) {
674
705
  * stays as it is. o.page false: the chat alone, the Viewer as it is. */
675
706
  async function goIni(id, o = {}) {
676
707
  const was = S.ini;
677
- S.ini = id; S.sel = null; S.head = id === 'product' ? productKey() : null; S.doneOpen = false;
708
+ S.ini = id; S.sel = null; S.head = id === 'product' ? productKey() : null; S.doneOpen = false; S.stepsMore = false;
678
709
  if (was !== id) { S.IM = null; S.IMid = null; }
679
710
  if (isPhone()) sheet(false);
680
711
  syncUrl();
@@ -1044,7 +1075,7 @@ function addPerson() {
1044
1075
  const STRAT = { key: 'strategy', name: 'Strategist', initial: 'St' };
1045
1076
  const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
1046
1077
  const isMetrics = (s) => /metric/i.test(String((s && [s.task, s.skill, s.name, s.label].filter(Boolean).join(' ')) || ''));
1047
- const isMetricsSession = (s) => /^chat:metrics-review/.test(H.keyOfSession(s) || '') || (H.roleOf(s, S.D.desk && S.D.desk.roles).key === 'strategy' && /metric/i.test((s.hx && s.hx.title) || s.name || ''));
1078
+ const isMetricsSession = (s) => /^chat:metrics-review/.test(H.keyOfSession(s) || '') || (H.roleOf(s, S.D.desk && S.D.desk.roles).key === 'strategy' && /metric/i.test(H.nameOf(s) || ''));
1048
1079
  let MET = null;
1049
1080
  async function metricsModel() {
1050
1081
  if (MET && MET.model && Date.now() - MET.at < 60000) return MET.model;
@@ -1119,7 +1150,7 @@ function openRoutine(s) {
1119
1150
  /* the agent's terminal, read only, in the Viewer (term-view.js) */
1120
1151
  function openTerminal(sid) {
1121
1152
  const s = S.D.sessions.find((x) => x.id === sid);
1122
- import('./term-view.js').then((M) => M.openTermView(sid, { title: s ? (s.hx && s.hx.title) || s.name : sid }));
1153
+ import('./term-view.js').then((M) => M.openTermView(sid, { title: s ? H.nameOf(s) : sid }));
1123
1154
  }
1124
1155
 
1125
1156
  /* ── meetings and the calendar (the Viewer's own modules, through window.czViews) ── */
@@ -1143,13 +1174,18 @@ addEventListener('premium-rec', () => drawList());
1143
1174
  const RECROW = mountRecRow({ notes: () => (REC && REC.notes ? REC.notes() : []), refresh: () => REC && REC.refresh(), redraw: () => drawList() });
1144
1175
  /* what the Mentions Viewer needs from Home (home-mentions.js) */
1145
1176
  function menCtx() {
1146
- return { D: () => S.D, pmPost, toast, reload: () => load(), iniTitle, goIni: (id) => goIni(id), stageOf: (id) => (iniRowOf(id) || {}).stage || '',
1147
- draft: (m) => { // Draft a reply: Home's chat writes it with the PM; PMOS sends nothing, the PM answers where the mention is
1177
+ return { D: () => S.D, pmGet, pmPost, toast, toastUndo, reload: () => load(), redrawList: () => { if (S.ready) drawList(); }, iniTitle, goIni: (id) => goIni(id),
1178
+ stageOf: (id) => (iniRowOf(id) || {}).stage || '', onBoard: (id) => H.boardRows(S.D).some((r) => r.id === id), board: () => ({ ws: boardWs(), board: boardId() }),
1179
+ draft: (m) => { // the pencil: Home's chat changes the reply with the PM; Claude saves it with `pmos mention draft`, the Viewer shows it. PMOS sends nothing
1148
1180
  const who = String(m.who || 'them').split(/\s+/)[0];
1149
1181
  S.phoneChat = isPhone(); if (isPhone()) VW.close();
1150
- openTarget({ ...homeTarget(), key: 'chat:mention-' + m.id, title: 'Reply to ' + who, scope: { text: MEN.placeOf(m), icon: I.chat },
1151
- intro: { role: CLAUDE, text: (m.who || 'Someone') + (m.reply ? ' asks: “' : ' wrote: “') + (m.text || '') + '” Tell me what to answer and I will draft it. You send it in ' + MEN.placeOf(m) + '.' },
1152
- placeholder: 'What should the reply say?', context: 'A mention of the PM to answer. ' + (m.who || 'Someone') + ' in ' + MEN.placeOf(m) + ': ' + (m.text || '') + (m.initiative ? ' (initiative ' + m.initiative + ')' : '') });
1182
+ const place = MEN.placeOf(m);
1183
+ openTarget({ ...homeTarget(), key: 'chat:mention-' + m.id, title: 'Reply to ' + who, scope: { text: (m.who || who) + ' · ' + (m.where || place), icon: I.chat },
1184
+ intro: { role: CLAUDE, text: m.draft ? 'This is the reply I proposed to ' + who + ': “' + m.draft + '” Tell me what to change. The reply in the Viewer updates; you send it in ' + place + '.'
1185
+ : who + (m.fyi ? ' wrote: “' : ' asks: “') + (m.text || '') + '” Tell me what to answer and I will draft it. You send it in ' + place + '.' },
1186
+ placeholder: m.draft ? 'Change the reply' : 'What should the reply say?',
1187
+ context: 'A mention of the PM to answer (mention id ' + m.id + '). ' + (m.who || 'Someone') + ' in ' + place + ': ' + (m.text || '') + (m.initiative ? ' (initiative ' + m.initiative + ')' : '')
1188
+ + (m.draft ? '. The proposed reply now: ' + m.draft : '') + '. When the reply reads right, save it with: pmos mention draft ' + m.id + ' --text "<the reply>". The Mentions Viewer shows it. Never post it: the PM sends it.' });
1153
1189
  drawList(); chat.focus();
1154
1190
  } };
1155
1191
  }
@@ -1378,7 +1414,7 @@ function cta() {
1378
1414
  /* ── start ── */
1379
1415
  mountIni({ S, VW, pmGet, pmPost, toast, rowOf: (id) => iniRowOf(id), renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
1380
1416
  // the initiative's page (HbCDesk): its card, its header and its ⋯
1381
- cardHtml: (id) => cardHtml(id), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), talk: () => talk(),
1417
+ cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), talk: () => talk(),
1382
1418
  foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1383
1419
  /* The program panel in Home's Viewer (HbCProg): Home's board model and programs; an initiative of it opens here, with ← back to the program.
1384
1420
  * Read on the first program press, never at start: the panel's modules load premium-shell.js, whose start reads ?session= for the old dialog. */