create-pmos 0.410.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.
- package/package.json +13 -18
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +1 -1
- package/workspace/briefing-premium-initiative-test.js +9 -15
- package/workspace/changelog.json +12 -0
- package/workspace/chat-asks-test.js +146 -0
- package/workspace/guide/briefing-premium.md +1 -1
- package/workspace/guide/home.md +24 -0
- package/workspace/home-rows-test.js +149 -56
- package/workspace/ini-workflow-test.js +4 -4
- package/workspace/lib/briefing-premium-agent.js +8 -1
- package/workspace/lib/engine/boards.js +3 -1
- package/workspace/lib/goal-chat.js +94 -30
- package/workspace/lib/mention-cli.js +70 -0
- package/workspace/lib/mention-store.js +307 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/routes-boards.js +12 -0
- package/workspace/lib/routes-briefing-premium.js +2 -2
- package/workspace/lib/routes-mentions.js +62 -9
- package/workspace/lib/session-files.js +132 -0
- package/workspace/lib/session-name.js +103 -0
- package/workspace/lib/source-reads.js +4 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +10 -8
- package/workspace/premium-chat-goal-setup-test.js +203 -0
- package/workspace/premium-chat-goal-view-test.js +28 -23
- package/workspace/premium-chat-line-test.js +189 -0
- package/workspace/premium-vw-backlog-test.js +1 -1
- package/workspace/premium-vw-item-test.js +1 -1
- package/workspace/premium-vw-jira-test.js +1 -1
- package/workspace/public/pm/chat-ask.js +17 -9
- package/workspace/public/pm/cozy-home-rows.css +39 -1
- package/workspace/public/pm/cozy-home.css +112 -12
- package/workspace/public/pm/cozy-search.js +2 -1
- package/workspace/public/pm/cozy-steps.css +69 -0
- package/workspace/public/pm/cozy-steps.js +90 -0
- package/workspace/public/pm/goal-chat.js +141 -23
- package/workspace/public/pm/home-app.js +68 -35
- package/workspace/public/pm/home-ask.js +121 -0
- package/workspace/public/pm/home-chat.js +120 -68
- package/workspace/public/pm/home-data.js +10 -2
- package/workspace/public/pm/home-goal.js +159 -0
- package/workspace/public/pm/home-ini.css +35 -0
- package/workspace/public/pm/home-ini.js +50 -19
- package/workspace/public/pm/home-line.css +59 -0
- package/workspace/public/pm/home-line.js +200 -0
- package/workspace/public/pm/home-list.js +2 -2
- package/workspace/public/pm/home-mentions.js +303 -111
- package/workspace/public/pm/home-ses-name.js +65 -0
- package/workspace/public/pm/home-stage-card.js +94 -0
- package/workspace/public/pm/home-sweep.js +112 -0
- package/workspace/public/pm/home-today.js +7 -2
- package/workspace/public/pm/premium-initiative-head.js +8 -4
- package/workspace/public/pm/rename-press.js +24 -0
- package/workspace/public/pm/wf-page.css +3 -0
- package/workspace/public/pm/wf-page.js +2 -1
- package/workspace/public/premium-workflows.html +1 -0
- package/workspace/server.js +125 -11
- package/workspace/session-names-test.js +144 -0
- package/workspace/skills/jira-push.skill +1 -0
- package/workspace/skills/morning-brief.skill +2 -1
- package/workspace/skills/report-daily.skill +1 -0
- package/workspace/skills/report-monthly.skill +1 -0
- package/workspace/skills/report-weekly.skill +1 -0
- package/workspace/skills/sources-read.skill +3 -2
- package/workspace/stage-card-test.js +203 -0
- package/workspace/test-lists/chat-asks.json +13 -0
- package/workspace/test-lists/chat-progress.json +13 -0
- package/workspace/test-lists/mentions-a-plus.json +9 -0
- package/workspace/test-lists/premium-chat-goal-setup.json +9 -0
- package/workspace/test-lists/session-files.json +5 -0
- package/workspace/test-lists/session-names.json +13 -0
- package/workspace/test-lists/stage-card.json +6 -0
- package/workspace/tk-tasks-test.js +1 -1
- 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
|
|
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) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[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
|
|
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)
|
|
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
|
-
/**
|
|
49
|
-
export
|
|
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
|
|
61
|
-
|
|
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="
|
|
67
|
-
return
|
|
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
|
|
71
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
96
|
-
*
|
|
97
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -330,8 +332,17 @@ const ckTitle = (t, ms) => { const m = ms && /^(To reach |To finish )(.+)$/.exec
|
|
|
330
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>`; };
|
|
331
333
|
/** "Tender · KR 2.1": the workflow an initiative runs and its anchor, the kind line over its name (D99: Kind becomes Workflow). */
|
|
332
334
|
function kindOf(id) { return WFM.kindLine(iniRowOf(id) || {}); }
|
|
333
|
-
function cardHtml(id) {
|
|
335
|
+
function cardHtml(id, o = {}) {
|
|
334
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
|
+
}
|
|
335
346
|
let kind, title, turn, turnLabel, stage, lad = '', bars = '', ckh, items, then, time, cta, primary, over = false, foldSum = '', msNext = false;
|
|
336
347
|
if (prod) {
|
|
337
348
|
const C = H.productCard(S.D, S.D.now);
|
|
@@ -341,21 +352,6 @@ function cardHtml(id) {
|
|
|
341
352
|
then = C.payoff; time = C.time; cta = C.cta; primary = !C.sent;
|
|
342
353
|
const risk = C.items.filter((x) => x.kind === 'risk').length;
|
|
343
354
|
foldSum = C.of + (risk ? ' · ' + risk + ' at risk' : '');
|
|
344
|
-
} else {
|
|
345
|
-
const r = iniRowOf(id) || { title: (S.IM && S.IM.title) || id };
|
|
346
|
-
const h = headOf(id); S.H = h;
|
|
347
|
-
kind = kindOf(id);
|
|
348
|
-
title = r.title; turn = h.turn; turnLabel = h.turnLabel; stage = h.stage;
|
|
349
|
-
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>`;
|
|
350
|
-
bars = `<div class="hm-bars" aria-hidden="true">${h.steps.map((s) => `<i class="${s.cls}"></i>`).join('')}</div>`;
|
|
351
|
-
ckh = [h.checkTitle, h.doneOf];
|
|
352
|
-
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>` : '';
|
|
353
|
-
// the agent at work on this initiative: its avatar marks an agent step (AgInitAgents); with none at work the step is next
|
|
354
|
-
const at = S.D.sessions.find((s) => H.iniOfSession(s) === id && s.shown === 'working');
|
|
355
|
-
const io = { role: at ? H.roleOf(at, S.D.desk && S.D.desk.roles) : null, stalled: h.turn === 'stalled' };
|
|
356
|
-
items = doneRow + (S.doneOpen ? h.done.map((x) => itemHtml(x, io)).join('') : '') + h.rest.map((x) => itemHtml(x, io)).join('');
|
|
357
|
-
then = h.payoff; time = h.time; over = h.over; cta = h.cta; primary = h.primary;
|
|
358
|
-
foldSum = h.foldSum; msNext = msStep(h.toReach);
|
|
359
355
|
}
|
|
360
356
|
// on the initiative's page the Viewer's header names it (kind, title, New session): the card is its stage box alone (HbCDesk)
|
|
361
357
|
return `<section class="hm-card hm-pcard" aria-label="${esc(title)}">`
|
|
@@ -392,6 +388,22 @@ function drawList() {
|
|
|
392
388
|
if (PHC && PHC.el.parentNode === sc) PHC.el.remove();
|
|
393
389
|
document.body.classList.toggle('hm-folded', S.folded && !isPhone());
|
|
394
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;
|
|
395
407
|
}
|
|
396
408
|
|
|
397
409
|
function draw() { drawList(); drawTop(); chat.refresh(); }
|
|
@@ -405,7 +417,7 @@ function allRows() {
|
|
|
405
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); }
|
|
406
418
|
if (M.list) M.list.rows.forEach(add);
|
|
407
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); }); }
|
|
408
|
-
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
|
|
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); }
|
|
409
421
|
return out;
|
|
410
422
|
}
|
|
411
423
|
const rowById = (id) => allRows().find((r) => r.id === id) || null;
|
|
@@ -414,11 +426,19 @@ const rowById = (id) => allRows().find((r) => r.id === id) || null;
|
|
|
414
426
|
function drawTop() {
|
|
415
427
|
const n = H.needsOf(S.D).length;
|
|
416
428
|
const cur = S.cur || { title: 'Home', sub: '' };
|
|
417
|
-
|
|
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 = '';
|
|
418
436
|
$('#hmNeedsN').textContent = !S.ready ? 'Reading' : n ? n + (n === 1 ? ' next step' : ' next steps') : 'Today';
|
|
419
437
|
$('#hmNeeds').classList.toggle('loud', n > 0);
|
|
420
|
-
document.title = 'PMOS · ' + (
|
|
438
|
+
document.title = 'PMOS · ' + (title || 'Home');
|
|
421
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(); } });
|
|
422
442
|
|
|
423
443
|
/* ── the chat ── */
|
|
424
444
|
const chat = mountChat($('#hmChat'), {
|
|
@@ -435,7 +455,9 @@ const chat = mountChat($('#hmChat'), {
|
|
|
435
455
|
linkTo: (sid, ini) => link(sid, ini),
|
|
436
456
|
dismissLink: (sid) => { try { localStorage.setItem('cz-linksug-x:' + sid, '1'); } catch { /* a private window: it shows again next time */ } },
|
|
437
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'),
|
|
438
|
-
onTo: (b, t) => menu(b, toItems(t), 'Send your messages to'),
|
|
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
|
|
439
461
|
workItem: (text, t) => workItem(text, t),
|
|
440
462
|
openTerminal: (sid) => openTerminal(sid),
|
|
441
463
|
viewerClosed: () => !VW.isOpen() && !isPhone(),
|
|
@@ -451,6 +473,11 @@ function chatHead(t) {
|
|
|
451
473
|
const r = S.sel ? rowById(S.sel) : null;
|
|
452
474
|
if (t.prog) return { row: r, title: t.title, scope: t.prog.title, prog: true };
|
|
453
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) {
|
|
454
481
|
// the weekly update and the product's own chat sit in the product: its name, no stage track
|
|
455
482
|
if (t.ini === 'product' || (r && r.ini === 'product')) return { row: r, title, scope: H.productName(S.D) };
|
|
456
483
|
const ini = t.ini || (r && r.ini) || null;
|
|
@@ -467,7 +494,7 @@ function toItems(cur) {
|
|
|
467
494
|
const ses = S.D.sessions.filter((s) => H.iniOfSession(s) === id && s.shown !== 'exited');
|
|
468
495
|
const main = iniTarget(id);
|
|
469
496
|
return [{ label: 'The initiative’s chat', sub: 'Claude, with ' + iniTitle(id) + ' as its context', checked: at === main.key, go: () => openTarget(main) }]
|
|
470
|
-
.concat(ses.map((s) => { const r = H.roleOf(s, S.D.desk && S.D.desk.roles), st = sessionTarget(s); return { label: (s
|
|
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) }; }))
|
|
471
498
|
.concat([{ label: 'A new session', sub: 'A fresh conversation in ' + iniTitle(id), go: () => newIn(id) }]);
|
|
472
499
|
}
|
|
473
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).
|
|
@@ -514,9 +541,10 @@ function sessionTarget(s) {
|
|
|
514
541
|
const key = H.keyOfSession(s);
|
|
515
542
|
const ini = H.iniOfSession(s);
|
|
516
543
|
const role = H.roleOf(s, S.D.desk && S.D.desk.roles);
|
|
517
|
-
const t = { title: (s
|
|
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) };
|
|
518
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;
|
|
519
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)
|
|
520
548
|
return t;
|
|
521
549
|
}
|
|
522
550
|
function alsoOf(ini) {
|
|
@@ -644,7 +672,7 @@ function homeTarget() {
|
|
|
644
672
|
empty: 'Ask anything about your work. Claude reads your repositories and works in a real Claude Code session.', also: alsoOf(null) };
|
|
645
673
|
}
|
|
646
674
|
function openTarget(t) {
|
|
647
|
-
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 : '' };
|
|
648
676
|
chat.open(t); drawTop();
|
|
649
677
|
}
|
|
650
678
|
|
|
@@ -677,7 +705,7 @@ function select(id, o = {}) {
|
|
|
677
705
|
* stays as it is. o.page false: the chat alone, the Viewer as it is. */
|
|
678
706
|
async function goIni(id, o = {}) {
|
|
679
707
|
const was = S.ini;
|
|
680
|
-
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;
|
|
681
709
|
if (was !== id) { S.IM = null; S.IMid = null; }
|
|
682
710
|
if (isPhone()) sheet(false);
|
|
683
711
|
syncUrl();
|
|
@@ -1047,7 +1075,7 @@ function addPerson() {
|
|
|
1047
1075
|
const STRAT = { key: 'strategy', name: 'Strategist', initial: 'St' };
|
|
1048
1076
|
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
1049
1077
|
const isMetrics = (s) => /metric/i.test(String((s && [s.task, s.skill, s.name, s.label].filter(Boolean).join(' ')) || ''));
|
|
1050
|
-
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
|
|
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) || ''));
|
|
1051
1079
|
let MET = null;
|
|
1052
1080
|
async function metricsModel() {
|
|
1053
1081
|
if (MET && MET.model && Date.now() - MET.at < 60000) return MET.model;
|
|
@@ -1122,7 +1150,7 @@ function openRoutine(s) {
|
|
|
1122
1150
|
/* the agent's terminal, read only, in the Viewer (term-view.js) */
|
|
1123
1151
|
function openTerminal(sid) {
|
|
1124
1152
|
const s = S.D.sessions.find((x) => x.id === sid);
|
|
1125
|
-
import('./term-view.js').then((M) => M.openTermView(sid, { title: s ? (s
|
|
1153
|
+
import('./term-view.js').then((M) => M.openTermView(sid, { title: s ? H.nameOf(s) : sid }));
|
|
1126
1154
|
}
|
|
1127
1155
|
|
|
1128
1156
|
/* ── meetings and the calendar (the Viewer's own modules, through window.czViews) ── */
|
|
@@ -1146,13 +1174,18 @@ addEventListener('premium-rec', () => drawList());
|
|
|
1146
1174
|
const RECROW = mountRecRow({ notes: () => (REC && REC.notes ? REC.notes() : []), refresh: () => REC && REC.refresh(), redraw: () => drawList() });
|
|
1147
1175
|
/* what the Mentions Viewer needs from Home (home-mentions.js) */
|
|
1148
1176
|
function menCtx() {
|
|
1149
|
-
return { D: () => S.D, pmPost, toast, reload: () => load(),
|
|
1150
|
-
|
|
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
|
|
1151
1180
|
const who = String(m.who || 'them').split(/\s+/)[0];
|
|
1152
1181
|
S.phoneChat = isPhone(); if (isPhone()) VW.close();
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
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.' });
|
|
1156
1189
|
drawList(); chat.focus();
|
|
1157
1190
|
} };
|
|
1158
1191
|
}
|
|
@@ -1381,7 +1414,7 @@ function cta() {
|
|
|
1381
1414
|
/* ── start ── */
|
|
1382
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,
|
|
1383
1416
|
// the initiative's page (HbCDesk): its card, its header and its ⋯
|
|
1384
|
-
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(),
|
|
1385
1418
|
foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
|
|
1386
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.
|
|
1387
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. */
|