create-pmos 0.475.0 → 0.477.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 +33 -33
- 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/board-publish-ui-test.js +11 -16
- package/workspace/board-shared-ui-test.js +34 -33
- package/workspace/changelog.json +32 -0
- package/workspace/guide/briefing-premium.md +2 -2
- package/workspace/guide/claude-proposes.md +8 -2
- package/workspace/guide/forecast.md +16 -3
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/settings.md +9 -0
- package/workspace/guide/workflows.md +13 -2
- package/workspace/home-railcard-test.js +4 -4
- package/workspace/home-rows-test.js +15 -4
- package/workspace/ini-workflow-test.js +1 -1
- package/workspace/lib/board-pack.js +20 -1
- package/workspace/lib/board-trail.js +17 -1
- package/workspace/lib/boards-host.js +22 -2
- package/workspace/lib/briefing-premium-agent.js +2 -2
- package/workspace/lib/engine/boards.js +15 -3
- package/workspace/lib/engine/workflows.js +79 -10
- package/workspace/lib/forecast-offer.js +57 -0
- package/workspace/lib/grill-runs.js +1 -0
- package/workspace/lib/grill.js +1 -1
- package/workspace/lib/insight-moves.js +8 -6
- package/workspace/lib/news-for-you.js +6 -4
- package/workspace/lib/proposals.js +4 -3
- package/workspace/lib/report-chat.js +2 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-board-publish.js +7 -2
- package/workspace/lib/routes-boards.js +18 -5
- package/workspace/lib/routes-briefing-premium.js +16 -2
- package/workspace/lib/routes-forecast.js +8 -1
- package/workspace/lib/routes-grill.js +70 -0
- package/workspace/lib/routes-insight-moves.js +7 -5
- package/workspace/lib/routes-news.js +3 -1
- package/workspace/lib/routes-proposals.js +8 -6
- package/workspace/lib/routes-workflows.js +13 -0
- package/workspace/lib/wf-bridge.js +165 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +1 -2
- package/workspace/public/pm/bd-fc-card.js +45 -0
- package/workspace/public/pm/bd-next.js +1 -1
- package/workspace/public/pm/bd-publish.css +22 -18
- package/workspace/public/pm/bd-publish.js +57 -48
- package/workspace/public/pm/bd-shared.css +92 -30
- package/workspace/public/pm/bd-shared.js +143 -55
- package/workspace/public/pm/bd-span.js +27 -7
- package/workspace/public/pm/cozy-board.css +15 -0
- package/workspace/public/pm/cozy-ev.css +52 -0
- package/workspace/public/pm/cozy-home.css +4 -4
- package/workspace/public/pm/cozy-insights.css +23 -0
- package/workspace/public/pm/cozy-jl.js +158 -0
- package/workspace/public/pm/cozy-news.js +56 -2
- package/workspace/public/pm/cozy-panels.js +3 -2
- package/workspace/public/pm/cozy-settings.js +35 -7
- package/workspace/public/pm/cozy-today.css +6 -0
- package/workspace/public/pm/cozy-viewer.js +19 -3
- package/workspace/public/pm/goal-forecast.js +101 -0
- package/workspace/public/pm/grill-words.js +53 -0
- package/workspace/public/pm/hi-pop.css +16 -0
- package/workspace/public/pm/home-app.js +42 -5
- package/workspace/public/pm/home-day.js +5 -3
- package/workspace/public/pm/home-list.js +14 -4
- package/workspace/public/pm/home-mentions.js +5 -0
- package/workspace/public/pm/home-task.js +1 -1
- package/workspace/public/pm/home-today.js +14 -5
- package/workspace/public/pm/ini-props.js +41 -8
- package/workspace/public/pm/ini-view-model.js +27 -14
- package/workspace/public/pm/ini-view.css +62 -37
- package/workspace/public/pm/ini-view.js +1 -1
- package/workspace/public/pm/ini-wf-model.js +76 -19
- package/workspace/public/pm/ini-wf.js +69 -18
- package/workspace/public/pm/metric-drafts.css +9 -0
- package/workspace/public/pm/metric-drafts.js +2 -2
- package/workspace/public/pm/premium-board.js +13 -3
- package/workspace/public/pm/premium-insights.js +86 -11
- package/workspace/public/pm/premium-report-tab.js +13 -3
- package/workspace/public/pm/premium-vw-item.js +1 -1
- package/workspace/public/pm/readonly.js +1 -0
- package/workspace/public/pm/report-chat.js +2 -1
- package/workspace/public/pm/task-card.js +4 -3
- package/workspace/public/pm/wf-page.css +9 -0
- package/workspace/public/pm/wf-page.js +30 -1
- package/workspace/run-tests.js +10 -2
- package/workspace/server.js +5 -2
- package/workspace/test-lists/forecast-board.json +5 -0
|
@@ -151,6 +151,9 @@ const recentOf = (m) => ({ ...m, recent: [...m.toread, ...m.answered] });
|
|
|
151
151
|
|
|
152
152
|
/* M3 */
|
|
153
153
|
await p.click('#hmList [data-hr-mentions]');
|
|
154
|
+
// batch 20 item 6: a wide Viewer no longer folds the list by itself; at 1440 the PM folds it to give Mentions the room to sit side by side
|
|
155
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden])')));
|
|
156
|
+
await p.click('#hmList .hm-hd [data-hm-fold]');
|
|
154
157
|
const L1 = await until(() => listOf(p).then((l) => (l && l.move.length ? l : null)));
|
|
155
158
|
ok('M3 the row opens the Mentions Viewer, wide on a desktop, the list and the conversation side by side', !!L1 && L1.split, JSON.stringify(L1 && L1.secs));
|
|
156
159
|
ok('M3 Adler opens on who waits and what Claude drafted, plainly; no button on a light day', !!L1 && L1.face && L1.open === 'Four people wait on you. I drafted one reply; Maya and Dion’s needs you.' && !L1.go.length, JSON.stringify(L1 && [L1.open, L1.go]));
|
|
@@ -328,10 +331,16 @@ const recentOf = (m) => ({ ...m, recent: [...m.toread, ...m.answered] });
|
|
|
328
331
|
const lay = async (px) => { await W.page.evaluate((x) => window.czViewer.setWidth(x, false), px); return W.page.evaluate(() => ({ rail: window.czViewer.railOn(), list: Math.round(document.getElementById('hmList').getBoundingClientRect().width), chat: Math.round(document.getElementById('hmChat').getBoundingClientRect().width) })); };
|
|
329
332
|
const w0 = await lay(600);
|
|
330
333
|
ok('W at a narrow width the list shows', !w0.rail && w0.list > 200, JSON.stringify(w0));
|
|
331
|
-
const w1 = await lay(
|
|
332
|
-
ok('W
|
|
333
|
-
|
|
334
|
-
|
|
334
|
+
const w1 = await lay(1600);
|
|
335
|
+
ok('W a wider Viewer never folds the list (batch 20 item 6): it stops where the chat keeps its room', !w1.rail && w1.list > 200 && w1.chat >= 350, JSON.stringify(w1));
|
|
336
|
+
await W.page.click('#hmList .hm-hd [data-hm-fold]');
|
|
337
|
+
const w2 = await until(() => W.page.evaluate(() => window.czViewer.railOn() && Math.round(document.getElementById('hmList').getBoundingClientRect().width) < 100));
|
|
338
|
+
ok('W only the list\'s own fold folds it, to the rail', !!w2);
|
|
339
|
+
const w3 = await lay(600);
|
|
340
|
+
ok('W a narrower Viewer leaves the folded list folded', w3.rail && w3.list < 100, JSON.stringify(w3));
|
|
341
|
+
await W.page.click('[data-cz-vw-rail="show"]');
|
|
342
|
+
const w4 = await until(() => W.page.evaluate(() => !window.czViewer.railOn() && Math.round(document.getElementById('hmList').getBoundingClientRect().width) > 200));
|
|
343
|
+
ok('W the rail\'s list button unfolds it', !!w4);
|
|
335
344
|
ok('W no page error', !W.errors.length, W.errors.join(' | '));
|
|
336
345
|
await W.close();
|
|
337
346
|
|
|
@@ -363,6 +372,8 @@ const recentOf = (m) => ({ ...m, recent: [...m.toread, ...m.answered] });
|
|
|
363
372
|
/* Y (batch 17 item 6): Your day's opening card names the oldest ask in Your move; its icon opens that conversation in Mentions */
|
|
364
373
|
{ const Q = await open();
|
|
365
374
|
await Q.page.click('#hmList [data-hm-day]');
|
|
375
|
+
await until(() => Q.page.evaluate(() => !!document.querySelector('#czViewer:not([hidden])')));
|
|
376
|
+
await Q.page.click('#hmList .hm-hd [data-hm-fold]'); // batch 20 item 6: the PM folds the list, so Mentions has the room to sit side by side at 1440
|
|
366
377
|
const ya = await until(() => Q.page.evaluate(() => { const a = document.querySelector('#czViewer .yd-open .yd-ask'); return a ? { id: a.dataset.id, b: a.querySelector('b').textContent, em: a.querySelector('em').textContent, btn: (a.querySelector('[data-yd="ask"]') || {}).getAttribute?.('aria-label') } : null; }), 15000);
|
|
367
378
|
ok('Y Your day names the oldest ask: who, where, how many more, the gist', !!ya && ya.id === 'aaaaaaaaaaa1' && ya.b === 'Samuel asked you in #tech-team-cem · 2 more' && /before he tags it/.test(ya.em) && ya.btn === 'Open in Mentions', JSON.stringify(ya));
|
|
368
379
|
await shot(Q.page, 'day-ask-1440');
|
|
@@ -117,7 +117,7 @@ const BRIEF = BRP.build(BRF.facts());
|
|
|
117
117
|
await shot(p, 'picker-1440');
|
|
118
118
|
await p.click('.hi-pop [data-wf-pick="product-feature"]');
|
|
119
119
|
const sw = await until(() => p.evaluate(() => { const el = document.querySelector('.hi-pop[role="dialog"]'); return el && /Switch Office network tender to Product feature\?/.test(el.textContent) ? { text: el.textContent.replace(/\s+/g, ' '), land: el.querySelector('#wfLand').value, opts: el.querySelectorAll('#wfLand option').length } : null; }));
|
|
120
|
-
ok('W4 Switch to another workflow asks first: each stage
|
|
120
|
+
ok('W4 Switch to another workflow asks first: the old stages in each new stage, a picker per old stage, "It lands in" Triage, the rule in one line (WfAChange, WmB)', sw && /Triage\s*now\s*Triage/.test(sw.text) && /Change where a stage goes/.test(sw.text) && sw.land === 'triage' && sw.opts === 8 && /Nothing is deleted\./.test(sw.text), JSON.stringify(sw));
|
|
121
121
|
await shot(p, 'switch-1440');
|
|
122
122
|
await p.selectOption('#wfLand', 'discover');
|
|
123
123
|
await p.click('.hi-pop [data-wf-go]');
|
|
@@ -25,6 +25,23 @@ const VIEWS = ['track', 'stages', 'time', 'list']; // the Board's views a pack
|
|
|
25
25
|
const MODEL_KEYS = ['pending', 'workflows', 'today', 'header', 'board', 'initiatives', 'steps', 'rows'];
|
|
26
26
|
// a key that is the publisher's own, wherever it sits: what only they can do, and what is theirs to answer
|
|
27
27
|
const OWN_KEYS = new Set(['acts', 'dialog', 'you']);
|
|
28
|
+
// what Claude proposes to the publisher, wherever it sits on a row: a split or a merge, the ✦ proposals and Grill findings, an unsaved draft plan
|
|
29
|
+
// (batch 20 item 1). A teammate sees what is decided, not what waits on the publisher's ✓.
|
|
30
|
+
const PROPOSAL_KEYS = new Set(['suggest', 'props', 'draft']);
|
|
31
|
+
|
|
32
|
+
/** A row as a teammate may see it: no proposal, the links without Claude's link proposals, quiet moves and asks, a ticket without a move in flight. */
|
|
33
|
+
function settled(v) {
|
|
34
|
+
if (Array.isArray(v)) return v.map(settled);
|
|
35
|
+
if (!v || typeof v !== 'object') return v;
|
|
36
|
+
const o = {};
|
|
37
|
+
for (const k of Object.keys(v)) {
|
|
38
|
+
if (PROPOSAL_KEYS.has(k)) continue;
|
|
39
|
+
if (k === 'move' && v.key) continue; // a Jira ticket's move the publisher asked for: the reading stands
|
|
40
|
+
o[k] = settled(v[k]);
|
|
41
|
+
}
|
|
42
|
+
if (o.links && typeof o.links === 'object' && Array.isArray(o.links.links)) o.links = Object.assign({}, o.links, { proposals: [], moved: { n: 0, batches: [], tasks: [] }, asks: [] });
|
|
43
|
+
return o;
|
|
44
|
+
}
|
|
28
45
|
|
|
29
46
|
const pathOf = (k) => String(k).split('?')[0];
|
|
30
47
|
const queryOf = (k) => { const i = String(k).indexOf('?'); return new URLSearchParams(i < 0 ? '' : String(k).slice(i + 1)); };
|
|
@@ -107,7 +124,9 @@ function buildPack({ ws, board, selection, answers, meta }) {
|
|
|
107
124
|
// the model: only the keys that are drawn, only the selection's records, then the sweep
|
|
108
125
|
const model = {};
|
|
109
126
|
for (const k of MODEL_KEYS) if (k in model0) model[k] = model0[k];
|
|
110
|
-
const swept = sweep(pruneRecords(model, outside), needles);
|
|
127
|
+
const swept = sweep(settled(pruneRecords(model, outside)), needles);
|
|
128
|
+
// the header names what this computer could not read: the publisher's own business, and the line above the copy says when it was made
|
|
129
|
+
if (swept.header && typeof swept.header.text === 'string') swept.header = { text: swept.header.text.replace(/ · not read: .*$/, ''), missing: [] };
|
|
111
130
|
|
|
112
131
|
// programs: a program selection keeps that program, a product keeps the programs that hold something of it, an initiative keeps none
|
|
113
132
|
const kept = R.wholeBoard ? R.progs.filter((p) => ((p && p.members) || []).some((m) => m && m.ws === ws)) : R.keptPrograms;
|
|
@@ -189,6 +189,22 @@ function trail({ root, ids, rows = [], moves = [], now = Date.now(), io } = {})
|
|
|
189
189
|
const mv = (byIni.get(id) || []).filter((m) => (wk ? m.to === wk : stageKey(m.to) === stage)).pop();
|
|
190
190
|
if (mv) { since = Date.parse(mv.at); sinceFrom = 'move'; }
|
|
191
191
|
else if (!wk) { const L = ladderDates(id, fm, seen, evals); if (L.length) { since = L[L.length - 1][1]; sinceFrom = 'git'; } }
|
|
192
|
+
// batch 20 item 3 (canvas WmD): a switch that merged old stages into this one counts from the day the first of them began, so "20 days in
|
|
193
|
+
// Discovery" is true; the old stages' own days stay in `before`
|
|
194
|
+
let before = null;
|
|
195
|
+
if (wk && mv && mv.via === 'ini-wf' && mv.map) {
|
|
196
|
+
const L = (byIni.get(id) || []).slice().sort((a, b) => String(a.at).localeCompare(String(b.at)));
|
|
197
|
+
const ok = (t) => !!t && (mv.map[t] === wk || mv.map[stageKey(t)] === wk);
|
|
198
|
+
let first = null;
|
|
199
|
+
for (let j = L.indexOf(mv) - 1; j >= 0 && ok(L[j].to); j--) first = L[j];
|
|
200
|
+
if (first) { since = Date.parse(first.at); sinceFrom = 'merged'; }
|
|
201
|
+
else if (ok(mv.from)) { const LD = ladderDates(id, fm, seen, evals); let t0 = null; for (let q = LD.length - 1; q >= 0 && ok(LD[q][0]); q--) t0 = LD[q][1]; if (t0) { since = t0; sinceFrom = 'merged'; } }
|
|
202
|
+
const at = L.indexOf(mv);
|
|
203
|
+
let s0 = 0; for (let j = 0; j < at; j++) if (L[j].via === 'ini-wf') s0 = j;
|
|
204
|
+
const seg = [];
|
|
205
|
+
for (let j = s0; j < at; j++) { const k = String(L[j].to || ''); if (!k) continue; seg.push({ key: k, name: LABEL[stageKey(k)] || (k.charAt(0).toUpperCase() + k.slice(1)).replace(/-/g, ' '), days: Math.max(0, Math.round((Date.parse(L[j + 1].at) - Date.parse(L[j].at)) / DAY)) }); }
|
|
206
|
+
before = seg.length ? seg.slice(-8) : null;
|
|
207
|
+
}
|
|
192
208
|
|
|
193
209
|
// skipped: the lane's own ladder, then a move past a stage (with the move's reason)
|
|
194
210
|
const k = STAGES.indexOf(stage), laneSet = new Set(LANE_STAGES[lane] || STAGES);
|
|
@@ -229,7 +245,7 @@ function trail({ root, ids, rows = [], moves = [], now = Date.now(), io } = {})
|
|
|
229
245
|
let mvFrom = 0; if (wk) for (let i = 0; i < mvAll.length; i++) if (mvAll[i].via === 'ini-wf') mvFrom = i;
|
|
230
246
|
const ran = mvAll.slice(mvFrom).filter((m) => m.to && m.at).slice(-40).map((m) => ({ to: String(m.to), at: dayIso(Date.parse(m.at)) }));
|
|
231
247
|
items[id] = {
|
|
232
|
-
since: since ? dayIso(since) : null, sinceFrom, days: since ? Math.max(0, Math.floor((now - since) / DAY)) : null, moves: ran,
|
|
248
|
+
since: since ? dayIso(since) : null, sinceFrom, days: since ? Math.max(0, Math.floor((now - since) / DAY)) : null, moves: ran, ...(before ? { before } : {}),
|
|
233
249
|
skipped, parts, next: parts ? (parts.find((p) => !p.done) || {}).name || null : null, you,
|
|
234
250
|
links: { prd: prdRel, prdVersion: prdRel && (typeof prdFm.version === 'string' || typeof prdFm.version === 'number') && String(prdFm.version).trim() ? String(prdFm.version).trim().slice(0, 12) : null,
|
|
235
251
|
rubric: rubRel, evaluation: evals[0] || null, epic: jv && jv.ok && jv.epic && jv.epic.key ? jv.epic.key : null },
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* POST <host>/api/publish Authorization: Bearer <publish key> { team, name, kind, by, days, password, pack } -> { ok, id, url, ends }
|
|
6
6
|
* POST <host>/api/republish Authorization: Bearer <publish key> { id, pack } -> { ok, ends }
|
|
7
7
|
* DELETE <host>/api/links/<id> Authorization: Bearer <publish key> -> { ok }
|
|
8
|
+
* POST <host>/api/links/<id>/password Authorization: Bearer <publish key> -> { ok, password }
|
|
8
9
|
* The host answers a refusal as { ok: false, error } with a plain sentence. It makes the link id; the workspace never does.
|
|
9
10
|
*
|
|
10
11
|
* THE PUBLISH KEY. Made here, once, on the first publish: 32 random bytes. It is kept in <runtime state>/board-publish/state.json (mode 0600)
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
* publish(dir, o, { fetch, env, now }) o = { pack, team, name, kind, by, days, password, selection, ws, board } -> { ok, id, url, ends } | { ok: false, error, status }
|
|
26
27
|
* republish(dir, id, pack, { fetch, env, now }) -> { ok, ends } | { ok: false, error }
|
|
27
28
|
* turnOff(dir, id, { fetch, env }) -> { ok } | { ok: false, error }
|
|
29
|
+
* newPassword(dir, id, { fetch, env }) -> { ok, password } | { ok: false, error } the host makes it; it is passed on once and never kept here
|
|
28
30
|
*/
|
|
29
31
|
const fs = require('fs');
|
|
30
32
|
const path = require('path');
|
|
@@ -53,7 +55,12 @@ function readState(dir) {
|
|
|
53
55
|
catch { return { key: null, host: '', teams: [], links: [] }; }
|
|
54
56
|
}
|
|
55
57
|
/** The address the PM saved on the Publish popover ('' when none). The environment variable PMOS_BOARDS_HOST wins over it (see addressOf). */
|
|
56
|
-
function savedHost(dir) {
|
|
58
|
+
function savedHost(dir) {
|
|
59
|
+
const st = readState(dir); if (st.host) return st.host;
|
|
60
|
+
// no saved address, but a link is open (it was published while PMOS_BOARDS_HOST was set): that link's host is the address (batch 20 item 2)
|
|
61
|
+
for (const l of st.links.slice().reverse()) { try { const o = hostOrigin({ PMOS_BOARDS_HOST: new URL(l.url).origin }); if (o) return o; } catch { /* not an address */ } }
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
57
64
|
/** Save the host address: '' clears it. Returns { ok, host } or { ok: false, error } with a sentence for the PM. */
|
|
58
65
|
function setHost(dir, value) {
|
|
59
66
|
const v = String(value == null ? '' : value).trim();
|
|
@@ -150,4 +157,17 @@ async function turnOff(dir, id, opts = {}) {
|
|
|
150
157
|
return { ok: true };
|
|
151
158
|
}
|
|
152
159
|
|
|
153
|
-
|
|
160
|
+
async function newPassword(dir, id, opts = {}) {
|
|
161
|
+
const origin = hostOrigin(opts.env);
|
|
162
|
+
if (!origin) return noHost;
|
|
163
|
+
const st = readState(dir);
|
|
164
|
+
const l = st.links.find((x) => x.id === id);
|
|
165
|
+
if (!st.key || !l) return { ok: false, status: 404, error: 'This link is not one of yours.' };
|
|
166
|
+
const r = await call(origin, 'POST', '/api/links/' + encodeURIComponent(id) + '/password', st.key, {}, opts.fetch);
|
|
167
|
+
if (!r.ok) return r;
|
|
168
|
+
const pw = r.body.password;
|
|
169
|
+
if (typeof pw !== 'string' || pw.length < 6 || pw.length > 100) return { ok: false, status: 502, error: 'The host sent an answer this workspace does not accept.' };
|
|
170
|
+
return { ok: true, password: pw };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
module.exports = { DAYS, TEAM_RX, MAX_PACK, hostOrigin, savedHost, setHost, addressOf, readState, writeState, links, publish, republish, turnOff, newPassword };
|
|
@@ -239,8 +239,8 @@ function chat({ runtimeDir, key, text, model, context, sessions, wsId, iniInfo,
|
|
|
239
239
|
let s;
|
|
240
240
|
// an initiative chat's opening (or its resumed first message) states the initiative's workflow and stage (lib/initiative-chat.js)
|
|
241
241
|
const iniRule = /^init:/.test(key) && !goal ? IniChat.rule(info(), iniId(key)) : [];
|
|
242
|
-
if (resume && iniRule.length && msg === q) msg = IniChat.wrap(q, info(), iniId(key));
|
|
243
|
-
try { s = sessions.spawn({ name, agent: 'claude', ws: wsId, origin: 'chat:' + key, chatClaude: { id: claude, resume }, initialInput: (resume ? msg : openingFor(row, msg, iniRule)) + '\r' }); } catch (e) { s = { state: 'exited', note: String((e && e.message) || e).slice(0, 120) }; }
|
|
242
|
+
if (resume && iniRule.length && msg === q && !/^\/[A-Za-z0-9]/.test(q)) msg = IniChat.wrap(q, info(), iniId(key)); // a / command goes as typed (batch 20 item 7)
|
|
243
|
+
try { s = sessions.spawn({ name, agent: 'claude', ws: wsId, origin: 'chat:' + key, chatClaude: { id: claude, resume }, initialInput: (resume ? msg : openingFor(row, msg, iniRule)) + '\r', ...(resume && /^\/[A-Za-z0-9]/.test(msg) ? { typedByPm: true } : {}) }); } catch (e) { s = { state: 'exited', note: String((e && e.message) || e).slice(0, 120) }; }
|
|
244
244
|
if (!s || s.state === 'exited' || !s.id) return fail(409, 'Claude could not start: ' + ((s && s.note) || 'no session'));
|
|
245
245
|
fs.mkdirSync(runtimeDir, { recursive: true });
|
|
246
246
|
fs.appendFileSync(path.join(runtimeDir, CHATS), JSON.stringify({ key, session: s.id, claude, name, at: now.toISOString() }) + '\n');
|
|
@@ -219,7 +219,7 @@ function fold(events) {
|
|
|
219
219
|
const deleted = new Map(); // initiative id → { at, by, board, title, tasks, items } while deleted (an ini-restore line brings it back)
|
|
220
220
|
const notDup = new Map(); // initiative id → Set of initiative ids the PM said it is not a duplicate of
|
|
221
221
|
// D99 workflows per initiative: the workflow each initiative runs, Won't do, the agent's readings of Only-when stages, Moves on by itself
|
|
222
|
-
const iniWf = new Map(); // key(board, id) → { wf, at, by, why, from } (the last ini-wf line)
|
|
222
|
+
const iniWf = new Map(); // key(board, id) → { wf, at, by, why, from, map, before, batch, undo } (the last ini-wf line; map: old stage key → stage now)
|
|
223
223
|
const ends = new Map(); // key(board, id) → { as: 'wontdo', reason, note, at, by } while it is out (a `back` line brings it back to Triage)
|
|
224
224
|
const judged = new Map(); // key(board, id) → { [stageKey]: { runs, why, cite, at, by } } (an `undo` line drops the reading)
|
|
225
225
|
const autoOver = new Map(); // key(board, id) → { [stageKey]: true|false } the PM's own Moves on by itself for one initiative
|
|
@@ -338,10 +338,22 @@ function fold(events) {
|
|
|
338
338
|
notDup.get(e.id).add(e.of);
|
|
339
339
|
} else if (e.kind === 'ini-wf' && b && typeof e.id === 'string' && typeof e.wf === 'string' && e.wf) {
|
|
340
340
|
const k = key(b, e.id);
|
|
341
|
-
|
|
341
|
+
// the stage map (batch 20 item 3): every stage key the initiative's tasks may name → the stage of this workflow it sits in now, composed
|
|
342
|
+
// over each switch; an undo line puts back the map from before the switch it undoes
|
|
343
|
+
const prev = iniWf.get(k) || null;
|
|
344
|
+
let map = null, before = prev;
|
|
345
|
+
if (e.undo === true) { map = prev && prev.before ? prev.before.map : null; before = prev && prev.before ? prev.before.before : null; }
|
|
346
|
+
else if (isObj(e.map)) {
|
|
347
|
+
map = {};
|
|
348
|
+
if (prev && prev.map) for (const [o, v] of Object.entries(prev.map)) if (typeof e.map[v] === 'string') map[o] = e.map[v];
|
|
349
|
+
for (const [o, v] of Object.entries(e.map)) if (typeof v === 'string') map[o] = v;
|
|
350
|
+
}
|
|
351
|
+
iniWf.set(k, { wf: e.wf, at: e.at || null, by: e.by || null, why: typeof e.why === 'string' ? e.why : '', from: typeof e.from === 'string' ? e.from : null, pmos: e.pmos === true,
|
|
352
|
+
map, before: before ? { map: before.map || null, before: before.before || null } : null, batch: typeof e.batch === 'string' ? e.batch : null, undo: e.undo === true,
|
|
353
|
+
left: isObj(e.moved) ? e.moved.from || null : null, landed: isObj(e.moved) ? e.moved.to || null : null });
|
|
342
354
|
if (isObj(e.moved) && typeof e.moved.to === 'string') {
|
|
343
355
|
stages.set(k, e.moved.to);
|
|
344
|
-
moves.push({ at: e.at || null, by: e.by || null, board: b, id: e.id, from: e.moved.from || null, to: e.moved.to, why: 'workflow changed', warnings: [], via: 'ini-wf' });
|
|
356
|
+
moves.push({ at: e.at || null, by: e.by || null, board: b, id: e.id, from: e.moved.from || null, to: e.moved.to, why: 'workflow changed', warnings: [], via: 'ini-wf', ...(isObj(e.map) && e.undo !== true ? { map: e.map } : {}) });
|
|
345
357
|
}
|
|
346
358
|
} else if (e.kind === 'ini-end' && b && typeof e.id === 'string') {
|
|
347
359
|
const k = key(b, e.id);
|
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
* list(folded, counts?) → [workflow + { count }] Product feature first, archived last
|
|
9
9
|
* resolve(folded, id) → the workflow (Product feature when the id is unknown or missing)
|
|
10
10
|
* stageByRef(wf, ref) → the stage a key or a name names, or null
|
|
11
|
-
* switchTarget(from, to, stageKey) → the key an initiative lands on when it switches workflow
|
|
11
|
+
* switchTarget(from, to, stageKey) → the key an initiative lands on when it switches workflow (the bridge's stage, see mapOf)
|
|
12
|
+
* proposeBridge(from, to) → { [fromKey]: toKey } Claude's proposal of where each old stage goes (batch 20 item 3)
|
|
13
|
+
* mapOf(from, to, override?) → { [fromKey]: toKey } every old stage's new stage: the PM's override, the saved bridge, the proposal
|
|
12
14
|
* removedInUse(before, after, standing)→ [{ id, stage }] initiatives that stand in a stage the edit removes
|
|
13
15
|
* stagesOf(wf, { judged, current }) → the initiative's own stages, each with its reading and status (the ONE function every surface reads)
|
|
14
16
|
* copyOf(wf, name, taken) → a new editable copy
|
|
15
17
|
*
|
|
16
|
-
* A WORKFLOW is { id, name, icon, builtin?, decide, archived?, stages: [STAGE] }.
|
|
18
|
+
* A WORKFLOW is { id, name, icon, builtin?, decide, archived?, stages: [STAGE], bridge? }.
|
|
19
|
+
* bridge { from, map: { [fromStageKey]: stageKey } }: where each stage of the workflow it replaces lands (batch 20 item 3, canvas WmB).
|
|
20
|
+
* It is saved with the new workflow, so every later switch from `from` uses it. Many old stages may land in one new stage.
|
|
17
21
|
* A STAGE is { key, name, cat, output: { name, kind, template? }, finish: [text], milestone, auto, when: { mode, text? }, then, unless: [{ text, to }] }.
|
|
18
22
|
* cat ∈ CATS (To do, In progress, Done). Won't do and Archived (ENDS) are in every workflow and are not stages.
|
|
19
23
|
* The first stage is always `triage`, in To do. `then` null means the next stage in the list. `unless` sends the initiative elsewhere
|
|
@@ -110,7 +114,21 @@ function check(wf) {
|
|
|
110
114
|
if (s.then) { const k = ref(s.then); if (!k || k === s.key) return bad(`stage "${s.name}": Then must name another stage of this workflow`); s.then = k; }
|
|
111
115
|
for (const u of s.unless) { const k = ref(u.to); if (!k || k === s.key) return bad(`stage "${s.name}": Unless must go to another stage of this workflow`); u.to = k; }
|
|
112
116
|
}
|
|
113
|
-
|
|
117
|
+
let bridge = null;
|
|
118
|
+
if (wf.bridge != null) {
|
|
119
|
+
const br = wf.bridge;
|
|
120
|
+
if (!isObj(br) || typeof br.from !== 'string' || !br.from || !isObj(br.map)) return bad('a bridge is { from: the workflow id it replaces, map: { old stage key: stage of this workflow } }');
|
|
121
|
+
const ent = Object.entries(br.map);
|
|
122
|
+
if (ent.length > STAGES_MAX) return bad(`a bridge maps at most ${STAGES_MAX} stages`);
|
|
123
|
+
const map = {};
|
|
124
|
+
for (const [k, v] of ent) {
|
|
125
|
+
// a stage the bridge sends to that an edit removed drops out: that old stage falls back to Claude's proposal (mapOf), the save goes on
|
|
126
|
+
const nk = typeof v === 'string' ? ref(v) : null;
|
|
127
|
+
if (slug(k) && nk) map[slug(k)] = nk;
|
|
128
|
+
}
|
|
129
|
+
if (Object.keys(map).length && slug(br.from) !== id) bridge = { from: slug(br.from), map };
|
|
130
|
+
}
|
|
131
|
+
return { ok: true, workflow: { id, name, icon, decide, stages, ...(bridge ? { bridge } : {}) } };
|
|
114
132
|
}
|
|
115
133
|
|
|
116
134
|
/** Fold workflows.jsonl (objects or JSON strings), oldest first. */
|
|
@@ -125,7 +143,10 @@ function fold(lines) {
|
|
|
125
143
|
const c = check(e.wf);
|
|
126
144
|
if (!c.ok) continue;
|
|
127
145
|
const was = byId.get(c.workflow.id);
|
|
128
|
-
|
|
146
|
+
// copiedFrom: the workflow it began as a copy of (Product feature cannot be edited, so a simpler one starts as its copy): the ✦ that moves
|
|
147
|
+
// the initiatives over reads it (batch 20 item 3)
|
|
148
|
+
const cf = typeof e.copiedFrom === 'string' ? e.copiedFrom : was && was.copiedFrom ? was.copiedFrom : null;
|
|
149
|
+
byId.set(c.workflow.id, { ...c.workflow, ...(was && was.archived ? { archived: true } : {}), ...(cf ? { copiedFrom: cf } : {}), at: e.at || null });
|
|
129
150
|
} else if (e.kind === 'wf-archive' && typeof e.id === 'string' && byId.has(e.id) && e.id !== PRODUCT_FEATURE_ID) {
|
|
130
151
|
const w = { ...byId.get(e.id) };
|
|
131
152
|
if (e.archived) w.archived = true; else delete w.archived;
|
|
@@ -154,14 +175,62 @@ function stageByRef(wf, ref) {
|
|
|
154
175
|
return wf.stages.find((s) => s.key === r || s.key === old) || wf.stages.find((s) => s.name.toLowerCase() === low) || null;
|
|
155
176
|
}
|
|
156
177
|
|
|
157
|
-
/**
|
|
178
|
+
/** Claude's proposal of where each stage of `from` lands in `to` (batch 20 item 3, canvas WmB). Order is kept, so no stage is guessed out of
|
|
179
|
+
* sequence. Anchors first: the same key or name, the same stem in the same category ("Discover" → "Discovery"), the stage whose output is Jira tickets, the first
|
|
180
|
+
* stage to the first and the last to the last. Between two anchors an old stage stays with the earlier one until a ◆ milestone closes it
|
|
181
|
+
* (Build, ◆ Deliver → Implementation; Monitor → Evaluation); a wider gap spreads in order. → { [fromKey]: toKey } for every stage of from. */
|
|
182
|
+
function proposeBridge(from, to) {
|
|
183
|
+
const F = (from && from.stages) || [], T = (to && to.stages) || [];
|
|
184
|
+
const out = {};
|
|
185
|
+
if (!T.length) return out;
|
|
186
|
+
const low = (x) => String(x || '').toLowerCase().trim();
|
|
187
|
+
const stem = (x) => { const v = low(x).replace(/[^a-z0-9]/g, ''); return v.length >= 6 ? v.slice(0, 6) : null; };
|
|
188
|
+
const anchor = F.map((s) => {
|
|
189
|
+
let j = T.findIndex((t) => t.key === s.key || low(t.name) === low(s.name));
|
|
190
|
+
if (j < 0 && stem(s.name)) j = T.findIndex((t) => t.cat === s.cat && stem(t.name) === stem(s.name));
|
|
191
|
+
return j;
|
|
192
|
+
});
|
|
193
|
+
const tj = T.findIndex((t) => t.output && t.output.kind === 'jira');
|
|
194
|
+
if (tj >= 0 && !anchor.includes(tj)) { const i = F.findIndex((s, n) => anchor[n] < 0 && s.output && s.output.kind === 'jira'); if (i >= 0) anchor[i] = tj; }
|
|
195
|
+
if (F.length && anchor[0] < 0) anchor[0] = 0;
|
|
196
|
+
if (F.length > 1 && anchor[F.length - 1] < 0) anchor[F.length - 1] = T.length - 1;
|
|
197
|
+
// keep the order: an anchor that would go back is dropped
|
|
198
|
+
let hi = -1;
|
|
199
|
+
for (let i = 0; i < F.length; i++) { if (anchor[i] < 0) continue; if (anchor[i] < hi) anchor[i] = -1; else hi = anchor[i]; }
|
|
200
|
+
for (let i = 0; i < F.length;) {
|
|
201
|
+
if (anchor[i] >= 0) { out[F[i].key] = T[anchor[i]].key; i++; continue; }
|
|
202
|
+
let j = i; while (j < F.length && anchor[j] < 0) j++;
|
|
203
|
+
const a = i > 0 ? anchor[i - 1] : 0, b = j < F.length ? anchor[j] : a, n = j - i;
|
|
204
|
+
let closed = false;
|
|
205
|
+
for (let k = 0; k < n; k++) {
|
|
206
|
+
let t = a;
|
|
207
|
+
if (b - a === 1) { t = closed ? b : a; if (F[i + k].milestone) closed = true; }
|
|
208
|
+
else if (b - a > 1) t = Math.min(b, a + Math.round(((k + 1) * (b - a)) / (n + 1)));
|
|
209
|
+
out[F[i + k].key] = T[t].key;
|
|
210
|
+
}
|
|
211
|
+
i = j;
|
|
212
|
+
}
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Every stage of `from` and where it lands in `to`: the PM's own pick (override), the bridge saved with `to`, else Claude's proposal. */
|
|
217
|
+
function mapOf(from, to, override) {
|
|
218
|
+
const p = proposeBridge(from, to);
|
|
219
|
+
const br = to && to.bridge && from && to.bridge.from === from.id ? to.bridge.map : {};
|
|
220
|
+
const ok = (k) => !!k && !!(to.stages || []).find((s) => s.key === k);
|
|
221
|
+
const out = {};
|
|
222
|
+
for (const s of (from && from.stages) || []) {
|
|
223
|
+
const o = override && override[s.key];
|
|
224
|
+
out[s.key] = ok(o) ? o : ok(br[s.key]) ? br[s.key] : p[s.key];
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Switching workflow (WfAChange): the stage the bridge (or Claude's proposal) sends the current stage to; no current stage, the first stage. */
|
|
158
230
|
function switchTarget(from, to, stageRef) {
|
|
159
231
|
const cur = stageByRef(from, stageRef);
|
|
160
232
|
if (!cur) return to.stages[0].key;
|
|
161
|
-
|
|
162
|
-
if (same) return same.key;
|
|
163
|
-
const cat = to.stages.find((s) => s.cat === cur.cat);
|
|
164
|
-
return (cat || to.stages[0]).key;
|
|
233
|
+
return mapOf(from, to)[cur.key] || to.stages[0].key;
|
|
165
234
|
}
|
|
166
235
|
|
|
167
236
|
/** standing: [{ id, stage }] (stage = key). The ones whose stage the edit removes (WfARemove). */
|
|
@@ -200,5 +269,5 @@ const milestonesOf = (wf) => (wf || PRODUCT_FEATURE).stages.filter((s) => s.mile
|
|
|
200
269
|
|
|
201
270
|
module.exports = {
|
|
202
271
|
CATS, CAT_LABEL, ENDS, OUTPUT_KINDS, WHEN_MODES, DECIDE, ICONS, PRODUCT_FEATURE_ID, PRODUCT_FEATURE,
|
|
203
|
-
slug, check, fold, list, resolve, stageByRef, switchTarget, removedInUse, stagesOf, copyOf, milestonesOf,
|
|
272
|
+
slug, check, fold, list, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
|
|
204
273
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/forecast-offer.js — a baseline worth offering in the goal Viewer (canvas FcViewer's ✓ "Without the promo weeks"; build brief Grill and
|
|
3
|
+
* Forecast). It finds the readings, and lib/forecast.js goalForecast says the range without them: the one straight-line method, nothing new.
|
|
4
|
+
* The goal Viewer asks for it when a goal opens (POST /api/forecast/offer, lib/routes-forecast.js); the ✓ keeps it through
|
|
5
|
+
* POST /api/forecast/baseline. Nothing is written until that ✓.
|
|
6
|
+
*
|
|
7
|
+
* offerOf(g, f, o) PURE → { label, exclude: [{ from, to }], likely, low, high, state } | null
|
|
8
|
+
* g: a goal of the Insights model (series, target, byAt, unit, direction, base, type). f: its forecast. o: { today }
|
|
9
|
+
* forGoal(g, today) PURE → the offer for a goal as the page sends it: its forecast worked out again here, then offerOf */
|
|
10
|
+
const FC = require('./forecast.js');
|
|
11
|
+
|
|
12
|
+
const DAY = 864e5, WEEK = 7 * DAY;
|
|
13
|
+
const fin = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
14
|
+
const dayMs = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
15
|
+
const dayOf = (v) => (dayMs(v) !== null ? String(v).slice(0, 10) : null);
|
|
16
|
+
|
|
17
|
+
/** A baseline worth offering ("without the promo weeks", FcViewer's ✓): a run of 1 to 3 recent readings that sit off the goal's own line, and
|
|
18
|
+
* the range without them. The line is the median-slope line through the last 8 readings (so the odd ones do not bend it); a reading is off
|
|
19
|
+
* when it sits more than 3 times the usual distance from that line. The last reading is never left out. null when nothing sits off, a
|
|
20
|
+
* baseline is kept already, the forecast is not a range, or leaving the run out changes nothing a person would read (zero is silence).
|
|
21
|
+
* PURE → { label, exclude: [{ from, to }], likely, low, high, state } | null. f: the goal's forecast (goalForecast). */
|
|
22
|
+
function offerOf(g, f, o = {}) {
|
|
23
|
+
if (!f || f.baseline || !['on-track', 'at-risk', 'will-miss'].includes(f.state)) return null;
|
|
24
|
+
const S = (g.series || []).filter((r) => r && fin(r.v) && dayMs(r.at) !== null).slice(-8);
|
|
25
|
+
if (S.length < 5) return null;
|
|
26
|
+
const t = S.map((r) => dayMs(r.at) / WEEK), med = (a) => { const b = a.slice().sort((x, y) => x - y), m = b.length >> 1; return b.length % 2 ? b[m] : (b[m - 1] + b[m]) / 2; };
|
|
27
|
+
const sl = []; for (let i = 0; i < S.length; i++) for (let j = i + 1; j < S.length; j++) if (t[j] > t[i]) sl.push((S[j].v - S[i].v) / (t[j] - t[i]));
|
|
28
|
+
if (!sl.length) return null;
|
|
29
|
+
const k = med(sl), c = med(S.map((r, i) => r.v - k * t[i])), res = S.map((r, i) => r.v - (c + k * t[i]));
|
|
30
|
+
const spread = Math.max(...S.map((r) => r.v)) - Math.min(...S.map((r) => r.v)), cut = Math.max(3 * med(res.map(Math.abs)), 0.1 * spread);
|
|
31
|
+
if (!(cut > 0)) return null;
|
|
32
|
+
let best = null, run = null;
|
|
33
|
+
for (let i = 0; i < S.length - 1; i++) {
|
|
34
|
+
const off = Math.abs(res[i]) > cut, sign = Math.sign(res[i]);
|
|
35
|
+
if (off && run && run.sign === sign && run.to === i - 1 && run.to - run.from < 2) { run.to = i; run.w += Math.abs(res[i]); }
|
|
36
|
+
else run = off ? { from: i, to: i, sign, w: Math.abs(res[i]) } : null;
|
|
37
|
+
if (run && (!best || run.w > best.w)) best = { ...run };
|
|
38
|
+
}
|
|
39
|
+
if (!best) return null;
|
|
40
|
+
const a = dayOf(S[best.from].at), z = dayOf(S[best.to].at), exclude = [{ from: a, to: z }];
|
|
41
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], dm = (d) => MON[+d.slice(5, 7) - 1] + ' ' + +d.slice(8, 10);
|
|
42
|
+
const label = 'without the reading' + (a === z ? ' of ' + dm(a) : 's of ' + dm(a) + ' to ' + dm(z));
|
|
43
|
+
const w = FC.goalForecast(g, { today: o.today, baseline: { label, exclude } });
|
|
44
|
+
if (!w || !['on-track', 'at-risk', 'will-miss'].includes(w.state)) return null;
|
|
45
|
+
const r1 = (v) => Math.round(v * 10) / 10;
|
|
46
|
+
if (r1(w.low) === r1(f.low) && r1(w.high) === r1(f.high)) return null;
|
|
47
|
+
return { label, exclude, likely: w.likely, low: w.low, high: w.high, state: w.state };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function forGoal(g, today) {
|
|
51
|
+
if (!g || typeof g !== 'object') return null;
|
|
52
|
+
const G = { id: String(g.id || ''), type: g.type, target: g.target, byAt: g.byAt, unit: g.unit, direction: g.direction, base: g.base,
|
|
53
|
+
series: Array.isArray(g.series) ? g.series.slice(-40).filter((r) => r && fin(r.v) && dayMs(r.at) !== null).map((r) => ({ at: dayOf(r.at), v: r.v })) : [] };
|
|
54
|
+
return offerOf(G, FC.goalForecast(G, { today }), { today });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = { offerOf, forGoal };
|
|
@@ -28,6 +28,7 @@ const WHY = {
|
|
|
28
28
|
forecast: 'Its forecast just turned. Grill it: why, and what would bring it back?',
|
|
29
29
|
move: 'Its scope or dates moved a lot. Grill it: is the plan still the right plan?',
|
|
30
30
|
monthly: 'The monthly look at running work that feels off (it has late work). Grill it.',
|
|
31
|
+
ask: 'The PM asked for it in the initiative\'s chat. Grill it now: what would make it fail, and what is the next step?',
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
function promptOf(skill, o) {
|
package/workspace/lib/grill.js
CHANGED
|
@@ -48,7 +48,7 @@ const KINDS = new Set(['start', 'voices', 'end', 'snap', 'paused']);
|
|
|
48
48
|
const ANGLES = Object.freeze(['premortem', 'redteam', 'voices', 'reframe', 'scope', 'whatif']);
|
|
49
49
|
const LABEL = Object.freeze({ premortem: 'Premortem', redteam: 'Red team', voices: 'Voices', reframe: 'Reframe', scope: 'Scope', whatif: 'What-if' });
|
|
50
50
|
const SIMULATED = Object.freeze({ voices: 'Simulated, not evidence', whatif: 'Simulated, not the plan' });
|
|
51
|
-
const WHYS = Object.freeze(['exit', 'forecast', 'move', 'monthly']);
|
|
51
|
+
const WHYS = Object.freeze(['exit', 'forecast', 'move', 'monthly', 'ask']);
|
|
52
52
|
const MODES = Object.freeze(['full', 'exits', 'off']);
|
|
53
53
|
const VOICES_MIN = 3;
|
|
54
54
|
const RUN_MAX_USD = 2; // one run never spends more than this
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* of <state>/insight-moves.jsonl. Pure apart from the ledger file, with no clock of its own: every time comes in.
|
|
6
6
|
*
|
|
7
7
|
* THE MOVES, tried in this order; the first that fits is the one drafted, and a finding with none draws no ✓ (zero is silence):
|
|
8
|
-
* chase an active initiative that moves the goal is past its end date
|
|
9
|
-
*
|
|
8
|
+
* chase an active initiative that moves the goal is past its end date and has an owner: a note asking the owner for a new date goes to the
|
|
9
|
+
* outbox. With a Jira epic it is a comment on the epic (channel jira-write); with none it is a note to the owner (channel team-note,
|
|
10
|
+
* the channel the goal-watch thank-you uses), written from the PMOS records alone. Nothing is sent: it waits for the PM's own Send.
|
|
10
11
|
* anchor nothing active moves the goal, and one active initiative of the board has no anchor that resolves while its title shares a word with
|
|
11
12
|
* the goal: its parent_kr is set to the goal (an anchor the OKR files declare, the same check as any anchor change).
|
|
12
13
|
* date the goal will miss its target at this pace and the straight line reaches the target on a later day: the KR metric record's `by`
|
|
@@ -56,16 +57,17 @@ function draftFor(f, model, o = {}) {
|
|
|
56
57
|
if (!goal || !goal.id) return null;
|
|
57
58
|
const today = DAY_RE.test(str(o.today)) ? o.today : null, t0 = ms(today);
|
|
58
59
|
const active = (goal.moves || []).filter(ACTIVE);
|
|
59
|
-
// chase: the initiative most days past its end, with someone to ask
|
|
60
|
+
// chase: the initiative most days past its end, with someone to ask; on its Jira epic when it has one, else a note to the owner
|
|
60
61
|
if (t0 !== null) {
|
|
61
|
-
const late = active.filter((r) => r.owner &&
|
|
62
|
+
const late = active.filter((r) => r.owner && ms(r.endAt) !== null && ms(r.endAt) < t0).sort((a, b) => ms(a.endAt) - ms(b.endAt))[0];
|
|
62
63
|
if (late) {
|
|
63
64
|
const days = Math.round((t0 - ms(late.endAt)) / DAY), who = clip(late.owner, 40);
|
|
64
65
|
const body = 'Hi ' + first(who) + ', ' + clip(late.title, 80) + ' was due on ' + full(late.endAt) + ' and is ' + days + (days === 1 ? ' day' : ' days') + ' over. '
|
|
65
66
|
+ clip(goal.title, 80) + ' is behind its line' + (goal.nowTxt ? ' at ' + goal.nowTxt : '') + (goal.targetTxt ? ' against a target of ' + goal.targetTxt : '') + '. What is the new date?';
|
|
66
|
-
const
|
|
67
|
+
const epic = str(late.epic).trim() || null, what = epic ? 'comment' : 'note';
|
|
68
|
+
const m = { kind: 'chase', goal: goal.id, ini: late.id, owner: who, epic, channel: epic ? 'jira-write' : 'team-note', days, body,
|
|
67
69
|
text: 'Ask ' + who + ' for a new date on ' + clip(late.title, 60) + ', ' + days + (days === 1 ? ' day' : ' days') + ' over.',
|
|
68
|
-
label: 'Put the
|
|
70
|
+
label: 'Put the ' + what + ' to ' + who + ' in the outbox', said: 'The ' + what + ' to ' + who + ' is in the outbox. Nothing is sent until you send it.' };
|
|
69
71
|
return Object.assign(m, { sig: sigOf(m) });
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* news-for-you.js — New for you, which replaces the Inbox (initiative premium-uncovered-features, E2; canvas EvInbox, HmAround).
|
|
3
3
|
*
|
|
4
|
-
* build({ inbox, work, seen, name }) → { count, groups: [{ key, label, items }] } PURE
|
|
4
|
+
* build({ inbox, work, seen, name, bridges }) → { count, groups: [{ key, label, items }] } PURE
|
|
5
5
|
* readSeen(runtimeDir) → Set of ids · appendSeen(runtimeDir, ids, now) · badSeen(body) → null | the reason
|
|
6
6
|
*
|
|
7
7
|
* New for you holds items for the PM's information only, in three groups (EvInbox):
|
|
8
|
-
* propose Claude proposes: an agent's possible-overlap note between two open initiatives (batch 18 item 2b, OvA5), with its pick
|
|
8
|
+
* propose Claude proposes: an agent's possible-overlap note between two open initiatives (batch 18 item 2b, OvA5), with its pick; and
|
|
9
|
+
* moving the initiatives of a replaced workflow to the new one (batch 20 item 3, WmB; GET /api/workflows/proposals), raised once
|
|
9
10
|
* given a task given to the PM: an open Work item that came from a source (Jira, the work breakdown), not one the PM typed
|
|
10
11
|
* finished what the agents finished while the PM was away: the new items of the agent inbox (GET /api/inbox items)
|
|
11
12
|
* An item leaves once it is seen: its id is in <runtime>/news-seen.jsonl. A passed review or a proposal is its initiative's next step, so it
|
|
@@ -58,11 +59,12 @@ function finishedItems(inbox, seen) {
|
|
|
58
59
|
|
|
59
60
|
/** The groups, newest first in each; an empty group is left out. inbox: GET /api/inbox; work: GET /api/pm-items; name(id, ws?) → an initiative's
|
|
60
61
|
* title, or '' (an id is never shown). */
|
|
61
|
-
function build({ inbox = null, work = null, seen = new Set(), name = () => '' } = {}) {
|
|
62
|
+
function build({ inbox = null, work = null, seen = new Set(), name = () => '', bridges = [] } = {}) {
|
|
62
63
|
const by = (a, b) => (b.at || 0) - (a.at || 0);
|
|
63
64
|
const ib = inbox && inbox.ok !== false && Array.isArray(inbox.items) ? inbox.items : [];
|
|
64
65
|
const groups = [
|
|
65
|
-
{ key: 'propose', label: 'Claude proposes', items: ib.filter((x) => x && x.id && x.overlap && x.overlap.with && !seen.has(x.id)).map((x) => overlapItem(x, name))
|
|
66
|
+
{ key: 'propose', label: 'Claude proposes', items: ib.filter((x) => x && x.id && x.overlap && x.overlap.with && !seen.has(x.id)).map((x) => overlapItem(x, name))
|
|
67
|
+
.concat((bridges || []).filter((x) => x && x.id && x.kind === 'wf-bridge' && !seen.has(x.id))).sort(by) },
|
|
66
68
|
{ key: 'given', label: 'Given to you', items: givenItems(work, seen, name).sort(by) },
|
|
67
69
|
{ key: 'finished', label: 'Finished while you were away', items: finishedItems(inbox, seen).sort(by) },
|
|
68
70
|
].filter((g) => g.items.length);
|
|
@@ -304,7 +304,7 @@ const ORDER = { found: 0, dates: 1, status: 2, names: 3, links: 4, grill: 5 };
|
|
|
304
304
|
const GRILL_SHOWN = 3;
|
|
305
305
|
/**
|
|
306
306
|
* One initiative's proposals, as the ✦ and the Viewer draw them, or null when there is nothing to show.
|
|
307
|
-
* o: { T (Map uid → task), today (iso), stages: [{ key, name }], links: approved task links, settle, linkProps: [task-links proposal] }
|
|
307
|
+
* o: { T (Map uid → task), today (iso), stages: [{ key, name }], links: approved task links, settle, linkProps: [task-links proposal], grillAll (no fold) }
|
|
308
308
|
* → { n, sure, look: { run, why, at, ended, stopped, sources: [{ source, name, state, n, what }] } | null, groups: [{ group, props: [p] }], t }
|
|
309
309
|
*/
|
|
310
310
|
function viewOf(F, ini, o = {}) {
|
|
@@ -324,8 +324,9 @@ function viewOf(F, ini, o = {}) {
|
|
|
324
324
|
}
|
|
325
325
|
// Grill findings (lib/grill.js): 3 show, the best first (rank); the rest wait folded and come up as the PM keeps or drops one
|
|
326
326
|
const grill = props.filter((p) => p.group === 'grill').sort((a, b) => ((a.data && a.data.rank) || 5) - ((b.data && b.data.rank) || 5) || String(b.at).localeCompare(String(a.at)));
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
// o.grillAll (the PM pressed "Show the rest", or a keep names a folded one): every finding shows
|
|
328
|
+
const grillMore = o.grillAll ? 0 : Math.max(0, grill.length - GRILL_SHOWN);
|
|
329
|
+
if (!o.grillAll) for (const p of grill.slice(GRILL_SHOWN)) props.splice(props.indexOf(p), 1);
|
|
329
330
|
if (today != null) for (const p of datesOf(ini, T, { today, filed: [...F.props.values()].filter((x) => x.group === 'dates' && x.ini === ini), stages: o.stages, links: o.links, settle: o.settle, drops: F.drops })) if (!kept.has(p.id + ':' + p.sig)) props.push(p);
|
|
330
331
|
for (const lp of o.linkProps || []) props.push({ id: 'lk:' + lp.id, group: 'links', type: lp.kind, section: 'sure', link: lp, title: '', why: lp.why || '', sources: [], items: [] });
|
|
331
332
|
// ✕ on one item drops that item for good: the page sends its signature
|
|
@@ -20,6 +20,8 @@ const RULE = [
|
|
|
20
20
|
'You never set up, schedule, change or delete a report yourself, and you never write report-setups.jsonl: the PM presses in the tab.',
|
|
21
21
|
'- A new report: {"kind":"report","proposal":{"name":"short name","purpose":"what it answers, one line","audience":"who reads it","output":"google-doc|google-slides|google-sheets|confluence|pdf","schedule":null,"sources":["what it draws from"]}}',
|
|
22
22
|
' schedule stays null unless the PM named one; then it is {"cadence":"daily|weekly|bi-weekly|monthly","day":"Mon","dayOfMonth":1,"time":"09:00"}. A report with no schedule runs once.',
|
|
23
|
+
' A new report always starts with the standard sections: Headline, Timeline, Initiatives, New since last report, Decided this cycle, Needs your call, Sources. When the PM wants other contents (or you propose them), add "structure": "the sections it should have instead, in plain words" next to "proposal". Once the PM sets it up, the tab starts that change at once and the PM keeps it with one press.',
|
|
24
|
+
' In your words, say what the tab will show: the standard sections, and the change in "structure" if there is one. Never describe contents the block does not carry.',
|
|
23
25
|
'- A report that is set up already: {"kind":"report","id":"<its id>"} and, only when the PM asked for it, "schedule": {…} or "off", "structure": "the change to its sections, in the PM\'s words", "design": "the change to its look, in the PM\'s words".',
|
|
24
26
|
' The set-up reports are the setup lines of report-setups.jsonl (planning/ or pmos/state/); a later change line wins, a remove line deletes one.',
|
|
25
27
|
'- A chart of one measure: {"kind":"chart","proposal":{"measure":"<KR metric id>","title":"short title","question":"what it answers","form":"line|bars|number|meter","range":null,"target":null,"better":"higher|lower","note":""}}',
|
|
@@ -55,6 +55,7 @@ const MODULES = Object.freeze([
|
|
|
55
55
|
'routes-board-grill', // premium-uncovered-features (Board): a new initiative's Why, material and first questions (page press; file mode)
|
|
56
56
|
'routes-insights-premium', // briefing-premium-insights: the premium Insights page's model from the KR metric records and report files (read-only)
|
|
57
57
|
'routes-forecast', // build brief Grill and Forecast F-A: a goal forecast's kept baseline, and the forecasts that turned
|
|
58
|
+
'routes-grill', // Grill and Forecast screens: Claude's checks for the pages (mode, cap, spend, each initiative's last run, Home's one line; read-only)
|
|
58
59
|
'routes-home-desk', // premium-agreed-design (Home): seen marks, queued messages, the weekly update's recipients and sends, stakeholders (page press; file mode)
|
|
59
60
|
'routes-live', // batch 6 item 2: the Live pill's sessions and the titles of their initiatives (read-only)
|
|
60
61
|
'routes-home-review', // premium-uncovered-features (Home): the weekly review's four steps and the untouched work looked at (page press; file mode)
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* POST /api/board-publish { ws, board, select, team, password, days, shared_by } -> { ok, id, url, ends }
|
|
6
6
|
* POST /api/board-publish/republish { id } -> { ok, ends } the same selection, as the board is now; same link, same password
|
|
7
7
|
* POST /api/board-publish/off { id } -> { ok } the host deletes the copy at once
|
|
8
|
+
* POST /api/board-publish/password { id } -> { ok, password } a new link password from the host, shown once; the old one stops
|
|
8
9
|
* POST /api/board-publish/host { host } -> { ok, host } save the host address ('' clears it); PMOS_BOARDS_HOST wins over it
|
|
9
10
|
* GET /api/board-publish/shared -> { ok, readAt, yours, teams } the Shared view: your links, and each joined team read now (lib/boards-teams.js)
|
|
10
11
|
* POST /api/board-publish/join { invite } or { host, team, password } -> { ok, team } verified with the host first; the password stays on this computer
|
|
@@ -73,7 +74,7 @@ module.exports = {
|
|
|
73
74
|
prefixes: ['/api/board-publish'],
|
|
74
75
|
handle: async (req, res, url, ctx) => {
|
|
75
76
|
const p = url.pathname;
|
|
76
|
-
if (!/^\/api\/board-publish(\/(republish|off|host|shared|join|leave|open))?$/.test(p)) return false;
|
|
77
|
+
if (!/^\/api\/board-publish(\/(republish|off|password|host|shared|join|leave|open))?$/.test(p)) return false;
|
|
77
78
|
const send = (obj, code) => { ctx.json(res, obj, code); return true; };
|
|
78
79
|
const dir = stateDir(ctx);
|
|
79
80
|
if (!dir) return send({ ok: false, error: 'No state folder.' }, 500);
|
|
@@ -97,7 +98,7 @@ module.exports = {
|
|
|
97
98
|
const g = guard.requirePagePress(req, body);
|
|
98
99
|
if (!g.ok) return send({ ok: false, error: g.error }, g.status);
|
|
99
100
|
// D103 point 6 and PRD P2: a copy leaves this computer only on a press by the person. D98 lets an agent session take PM-only acts; this one it does not.
|
|
100
|
-
if (g.actor && /^agent/.test(String(g.actor.by || ''))) return send({ ok: false, error: 'Publishing is a press on the page. An agent session cannot publish, republish
|
|
101
|
+
if (g.actor && /^agent/.test(String(g.actor.by || ''))) return send({ ok: false, error: 'Publishing is a press on the page. An agent session cannot publish, republish, turn off or change the password of a board.' }, 403);
|
|
101
102
|
|
|
102
103
|
if (p === '/api/board-publish/join') { // a team is joined by a pasted invite link, or by host, team and password typed
|
|
103
104
|
const r = await Teams.join(dir, { invite: body.invite, host: body.host, team: body.team, password: body.password });
|
|
@@ -112,6 +113,10 @@ module.exports = {
|
|
|
112
113
|
const r = Host.setHost(dir, body.host);
|
|
113
114
|
return send(r.ok ? { ok: true, host: r.host } : { ok: false, error: r.error }, r.ok ? 200 : 400);
|
|
114
115
|
}
|
|
116
|
+
if (p === '/api/board-publish/password') { // the answer carries the password once; nothing here keeps or logs it (D08)
|
|
117
|
+
const r = await Host.newPassword(dir, String(body.id || ''), { env });
|
|
118
|
+
return send(r.ok ? { ok: true, password: r.password } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|
|
119
|
+
}
|
|
115
120
|
if (p === '/api/board-publish/off') {
|
|
116
121
|
const r = await Host.turnOff(dir, String(body.id || ''), { env });
|
|
117
122
|
return send(r.ok ? { ok: true } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|