create-pmos 0.476.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.
Files changed (82) hide show
  1. package/package.json +20 -14
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/board-publish-ui-test.js +11 -16
  7. package/workspace/board-shared-ui-test.js +34 -33
  8. package/workspace/changelog.json +19 -0
  9. package/workspace/guide/briefing-premium.md +2 -2
  10. package/workspace/guide/claude-proposes.md +3 -1
  11. package/workspace/guide/forecast.md +16 -3
  12. package/workspace/guide/home.md +2 -2
  13. package/workspace/guide/workflows.md +13 -2
  14. package/workspace/home-railcard-test.js +4 -4
  15. package/workspace/home-rows-test.js +15 -4
  16. package/workspace/ini-workflow-test.js +1 -1
  17. package/workspace/lib/board-pack.js +20 -1
  18. package/workspace/lib/board-trail.js +17 -1
  19. package/workspace/lib/boards-host.js +22 -2
  20. package/workspace/lib/briefing-premium-agent.js +2 -2
  21. package/workspace/lib/engine/boards.js +15 -3
  22. package/workspace/lib/engine/workflows.js +79 -10
  23. package/workspace/lib/forecast-offer.js +57 -0
  24. package/workspace/lib/grill-runs.js +1 -0
  25. package/workspace/lib/grill.js +1 -1
  26. package/workspace/lib/insight-moves.js +8 -6
  27. package/workspace/lib/news-for-you.js +6 -4
  28. package/workspace/lib/report-chat.js +2 -0
  29. package/workspace/lib/routes-board-publish.js +7 -2
  30. package/workspace/lib/routes-boards.js +18 -5
  31. package/workspace/lib/routes-briefing-premium.js +16 -2
  32. package/workspace/lib/routes-forecast.js +8 -1
  33. package/workspace/lib/routes-insight-moves.js +7 -5
  34. package/workspace/lib/routes-news.js +3 -1
  35. package/workspace/lib/routes-workflows.js +13 -0
  36. package/workspace/lib/wf-bridge.js +165 -0
  37. package/workspace/package-lock.json +2 -2
  38. package/workspace/package.json +1 -1
  39. package/workspace/panels-test.js +1 -2
  40. package/workspace/public/pm/bd-fc-card.js +45 -0
  41. package/workspace/public/pm/bd-next.js +1 -1
  42. package/workspace/public/pm/bd-publish.css +22 -18
  43. package/workspace/public/pm/bd-publish.js +57 -48
  44. package/workspace/public/pm/bd-shared.css +92 -30
  45. package/workspace/public/pm/bd-shared.js +143 -55
  46. package/workspace/public/pm/bd-span.js +27 -7
  47. package/workspace/public/pm/cozy-board.css +15 -0
  48. package/workspace/public/pm/cozy-ev.css +46 -0
  49. package/workspace/public/pm/cozy-home.css +4 -4
  50. package/workspace/public/pm/cozy-insights.css +21 -0
  51. package/workspace/public/pm/cozy-jl.js +158 -0
  52. package/workspace/public/pm/cozy-news.js +56 -2
  53. package/workspace/public/pm/cozy-panels.js +3 -2
  54. package/workspace/public/pm/cozy-settings.js +11 -7
  55. package/workspace/public/pm/cozy-today.css +3 -0
  56. package/workspace/public/pm/cozy-viewer.js +19 -3
  57. package/workspace/public/pm/goal-forecast.js +101 -0
  58. package/workspace/public/pm/hi-pop.css +16 -0
  59. package/workspace/public/pm/home-app.js +11 -4
  60. package/workspace/public/pm/home-day.js +5 -3
  61. package/workspace/public/pm/home-list.js +14 -4
  62. package/workspace/public/pm/home-mentions.js +5 -0
  63. package/workspace/public/pm/home-task.js +1 -1
  64. package/workspace/public/pm/home-today.js +11 -4
  65. package/workspace/public/pm/ini-view-model.js +27 -14
  66. package/workspace/public/pm/ini-view.js +1 -1
  67. package/workspace/public/pm/ini-wf-model.js +76 -19
  68. package/workspace/public/pm/ini-wf.js +69 -18
  69. package/workspace/public/pm/metric-drafts.css +9 -0
  70. package/workspace/public/pm/metric-drafts.js +2 -2
  71. package/workspace/public/pm/premium-board.js +13 -3
  72. package/workspace/public/pm/premium-insights.js +43 -6
  73. package/workspace/public/pm/premium-report-tab.js +13 -3
  74. package/workspace/public/pm/premium-vw-item.js +1 -1
  75. package/workspace/public/pm/readonly.js +1 -0
  76. package/workspace/public/pm/report-chat.js +2 -1
  77. package/workspace/public/pm/task-card.js +4 -3
  78. package/workspace/public/pm/wf-page.css +9 -0
  79. package/workspace/public/pm/wf-page.js +30 -1
  80. package/workspace/run-tests.js +10 -2
  81. package/workspace/server.js +5 -2
  82. package/workspace/test-lists/forecast-board.json +5 -0
@@ -4,6 +4,8 @@
4
4
  * POST /api/forecast/baseline { ws, goal, label, exclude: [{ from, to }] } keep a baseline: those readings leave the goal's range
5
5
  * POST /api/forecast/baseline-off { ws, goal } back to every reading
6
6
  * GET /api/forecast/turned?ws=<id>&since=<ISO time> → { ok, turned: [line] } the forecasts whose state changed
7
+ * POST /api/forecast/offer { goal: { id, series, target, byAt, unit, direction, base, type }, today } → { ok, offer | null }
8
+ * the baseline worth offering in the goal Viewer (lib/forecast-offer.js). Reads and writes nothing
7
9
  *
8
10
  * The writes are page presses (pm-guard requirePagePress); `pmos forecast` is the terminal's way. The forecasts themselves ride on
9
11
  * /api/insights-premium and /api/board-premium (lib/forecast.js). File mode only: <state>/forecast.jsonl. */
@@ -16,7 +18,7 @@ const NO_STATE = 'This repository has no PMOS state folder (pmos/state, state or
16
18
  async function handle(req, res, url, ctx) {
17
19
  const send = (status, body) => { ctx.json(res, body, status); return true; };
18
20
  const what = url.pathname.replace(/^\/api\/forecast\/?/, '');
19
- if (!['baseline', 'baseline-off', 'turned'].includes(what)) return send(404, { ok: false, error: 'no such forecast route' });
21
+ if (!['baseline', 'baseline-off', 'turned', 'offer'].includes(what)) return send(404, { ok: false, error: 'no such forecast route' });
20
22
  let body = {};
21
23
  if (what === 'turned') {
22
24
  if (req.method !== 'GET') return send(405, { ok: false, error: 'GET only' });
@@ -26,6 +28,11 @@ async function handle(req, res, url, ctx) {
26
28
  if (!read.ok) return send(400, { ok: false, error: 'the body is not JSON' });
27
29
  body = read.body || {};
28
30
  }
31
+ if (what === 'offer') {
32
+ let offer = null;
33
+ try { offer = require('./forecast-offer.js').forGoal(body.goal, text(body.today) || new Date().toISOString().slice(0, 10)); } catch { offer = null; }
34
+ return send(200, { ok: true, offer });
35
+ }
29
36
  const wsId = what === 'turned' ? url.searchParams.get('ws') : text(body.ws);
30
37
  let w = null;
31
38
  try { w = ctx.getWs(wsId || null); } catch { w = null; }
@@ -10,7 +10,7 @@
10
10
  * THE WRITERS, the same ones the rest of PMOS uses:
11
11
  * date scripts/records edit of the KR metric record: { by } Undo: { by: the day it had }
12
12
  * anchor lib/initiative-writer.js setAnchor (PM-only act 'anchor', pm-guard) Undo: restoreAnchor, the line exactly as it was
13
- * chase scripts/outbox.js draftOutbox → lib/outbox-store.js, channel jira-write Undo: the outbox entry discarded (a sent entry stays: 409)
13
+ * chase scripts/outbox.js draftOutbox → lib/outbox-store.js: channel jira-write on the epic, or team-note to the owner when there is no epic. Undo: the outbox entry discarded (a sent entry stays: 409)
14
14
  * Each ✓ and each Undo is one line of <state>/insight-moves.jsonl. With no state folder every write answers 409. Nothing is sent outward. */
15
15
  const guard = require('./pm-guard.js');
16
16
  const MV = require('./insight-moves.js');
@@ -45,13 +45,15 @@ function write(ctx, w, mv, actor) {
45
45
  return r.ok ? { undo: { from: r.from || '' } } : { error: r.error || 'The anchor could not be set.' };
46
46
  }
47
47
  if (mv.kind === 'chase') {
48
- if (!ctx.runtimeDir) return { error: 'This workspace has no outbox, so the comment could not be drafted.' };
48
+ if (!ctx.runtimeDir) return { error: 'This workspace has no outbox, so the message could not be drafted.' };
49
49
  try {
50
- const e = require(repoScript('outbox.js')).draftOutbox({ channel: 'jira-write', recipient: mv.epic, subject: 'A new date for ' + mv.ini, body: mv.body, origin: 'pm' });
50
+ const e = require(repoScript('outbox.js')).draftOutbox(mv.epic
51
+ ? { channel: 'jira-write', recipient: mv.epic, subject: 'A new date for ' + mv.ini, body: mv.body, origin: 'pm' }
52
+ : { channel: 'team-note', recipient: mv.owner, subject: 'A new date for ' + mv.ini, body: mv.body, origin: 'pm' });
51
53
  const entry = { id: 'out-' + require('crypto').randomBytes(6).toString('hex'), ...e };
52
54
  require('./outbox-store.js').appendEvent(ctx.runtimeDir, { event: 'queued', ...entry }, new Date());
53
55
  return { undo: { entry: entry.id } };
54
- } catch (x) { return { error: 'The comment could not go to the outbox: ' + String((x && x.message) || x).slice(0, 160) }; }
56
+ } catch (x) { return { error: 'The message could not go to the outbox: ' + String((x && x.message) || x).slice(0, 160) }; }
55
57
  }
56
58
  return { error: 'There is no such move.' };
57
59
  }
@@ -69,7 +71,7 @@ function unwrite(ctx, w, x, actor, req) {
69
71
  }
70
72
  if (mv.kind === 'chase') {
71
73
  const r = require('./routes-outbox.js').discard(req, { id: u.entry }, ctx.runtimeDir);
72
- return r.status === 200 ? {} : { status: r.status, error: (r.body && r.body.error) === 'a sent entry is a record and is not discarded' ? 'The comment was sent already, so it cannot be taken back.' : 'The comment could not be taken out of the outbox.' };
74
+ return r.status === 200 ? {} : { status: r.status, error: (r.body && r.body.error) === 'a sent entry is a record and is not discarded' ? 'The message was sent already, so it cannot be taken back.' : 'The message could not be taken out of the outbox.' };
73
75
  }
74
76
  return { error: 'There is no such move.' };
75
77
  }
@@ -58,7 +58,9 @@ module.exports = {
58
58
  ask('./routes-inbox.js', req, ctx, '/api/inbox'),
59
59
  ask('./routes-pm-items.js', req, ctx, '/api/pm-items'),
60
60
  ]);
61
- const out = News.build({ inbox, work: work && work.ok !== false ? work : null, seen: ctx.runtimeDir ? News.readSeen(ctx.runtimeDir) : new Set(), name: namesOf(ctx) });
61
+ let bridges = [];
62
+ try { bridges = require('./wf-bridge.js').proposals(ctx); } catch { bridges = []; } // batch 20 item 3: Claude's ✦ to move a replaced workflow's initiatives
63
+ const out = News.build({ inbox, work: work && work.ok !== false ? work : null, seen: ctx.runtimeDir ? News.readSeen(ctx.runtimeDir) : new Set(), name: namesOf(ctx), bridges });
62
64
  ctx.json(res, { ok: true, ...out });
63
65
  return true;
64
66
  },
@@ -7,12 +7,17 @@
7
7
  * POST /api/workflows/copy { ws, id, name? } → { ok, workflow }
8
8
  * POST /api/workflows/archive { ws, id, archived } → { ok } | 409 { inUse }
9
9
  * POST /api/workflows/draft { ws, draft | null, note? } → { ok, draft } (the page relays the chat's draft; the agent writes through `pmos workflow draft`)
10
+ * GET /api/workflows/proposals → { ok, items } Claude's ✦: move the initiatives of a replaced workflow (batch 20 item 3, lib/wf-bridge.js)
11
+ * POST /api/workflows/bridge { ws, id, from, map } → { ok, workflow } the bridge saved with the new workflow (WmB, Settings)
12
+ * POST /api/workflows/switch-all { ws, id, from, map?, save? } → { ok, batch, moved, tasks, failed } every initiative on `from` moves (WmB ✓)
13
+ * POST /api/workflows/switch-all/undo { ws, batch } → { ok, undone, of, kept } within 7 days (WmD)
10
14
  *
11
15
  * WHO WRITES. Every POST passes pm-guard requirePagePress and refuses an agent session header (403), as routes-premium-dashboards.js does.
12
16
  * The agent drafts and judges through lib/workflow-cli.js, which calls lib/workflows-store.js; only the PM's press saves a workflow.
13
17
  * A save that removes a stage moves the initiatives standing in it with one `move` line each in boards.jsonl, on their own board. */
14
18
  const guard = require('./pm-guard.js');
15
19
  const WS = require('./workflows-store.js');
20
+ const Bridge = require('./wf-bridge.js');
16
21
  const boards = require('./routes-boards.js');
17
22
  const { repoScript } = require('./repo-script.js');
18
23
  const WF = require(repoScript('workflows.js'));
@@ -50,6 +55,7 @@ async function handle(req, res, url, ctx) {
50
55
  if (!w) return send(bad(404, 'no such workspace'));
51
56
  const lib = WS.library(stateOf(ctx, w));
52
57
  if (p === '/api/workflows/draft') return send({ body: { ok: true, draft: lib.draft } });
58
+ if (p === '/api/workflows/proposals') return send({ body: { ok: true, items: Bridge.proposals(ctx) } });
53
59
  if (p !== '/api/workflows') return send(bad(404, 'not found'));
54
60
  const st = standingOf(ctx, w) || [];
55
61
  const counts = {};
@@ -95,6 +101,13 @@ async function handle(req, res, url, ctx) {
95
101
  const r = WS.archive(dir, body.id, body.archived, g.actor, { inUse });
96
102
  return send(r.ok ? { body: { ok: true } } : bad(r.status || 400, r.error, r.inUse ? { inUse: r.inUse } : null));
97
103
  }
104
+ if (p === '/api/workflows/bridge' || p === '/api/workflows/switch-all' || p === '/api/workflows/switch-all/undo') {
105
+ if (p !== '/api/workflows/switch-all/undo' && (typeof body.id !== 'string' || !body.id || typeof body.from !== 'string' || !body.from)) return send(bad(400, 'id (the new workflow) and from (the one it replaces) are required'));
106
+ const r = p === '/api/workflows/bridge' ? Bridge.saveBridge(ctx, w, body, g.actor) : p === '/api/workflows/switch-all' ? Bridge.switchAll(ctx, w, body, g) : Bridge.undoAll(ctx, w, body, g);
107
+ if (!r.ok) return send(bad(r.status || 400, r.error, r.pending ? { pending: true } : null));
108
+ const { ok, status, ...rest } = r;
109
+ return send({ body: { ok: true, ...rest } });
110
+ }
98
111
  if (p === '/api/workflows/draft') {
99
112
  const r = WS.saveDraft(dir, { draft: body.draft, note: body.note }, g.actor);
100
113
  return send(r.ok ? { body: { ok: true, draft: r.draft } } : bad(r.status || 400, r.error));
@@ -0,0 +1,165 @@
1
+ 'use strict';
2
+ /* wf-bridge.js — moving initiatives to a new workflow together (feedback batch 20 item 3; canvas In development WmB, WmD).
3
+ *
4
+ * The PM simplifies the workflow (for example Discovery, Implementation, Evaluation in place of Product feature's eight stages). The BRIDGE
5
+ * says where each old stage lands; it is saved with the new workflow (scripts/workflows.js `bridge`), so it is set once and every later switch
6
+ * from the old workflow uses it. Claude proposes it once, as a ✦ in New for you; the PM only approves.
7
+ *
8
+ * proposals(ctx) → [item] the ✦: a workflow that replaces another (its bridge, or it began as a copy of it) while
9
+ * initiatives still run the old one. One per workflow; New for you shows it once.
10
+ * saveBridge(ctx, w, { id, from, map }, actor) → { ok, workflow } | { ok:false, status, error }
11
+ * switchAll(ctx, w, body, g) → { ok, batch, moved, tasks, failed } every initiative on `from` switches, one batch id
12
+ * undoAll(ctx, w, body, g) → { ok, undone, of, kept } within 7 days; an initiative that moved since stays where it is
13
+ *
14
+ * Every switch is POST /api/boards/ini-wf's own function (routes-boards switchWorkflow), so each initiative gets the route's line, its stage map
15
+ * (its tasks move with their stage) and its To finish tasks. Nothing is deleted: Undo writes the way back. */
16
+ const crypto = require('crypto');
17
+ const WS = require('./workflows-store.js');
18
+ const { repoScript } = require('./repo-script.js');
19
+ const WF = require(repoScript('workflows.js'));
20
+
21
+ const UNDO_MS = 7 * 864e5;
22
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
23
+ const boards = () => require('./routes-boards.js');
24
+
25
+ /** Every open workspace: the home one first, then the products, each once. */
26
+ function workspaces(ctx) {
27
+ const home = ctx.getWs ? ctx.getWs(null) : null;
28
+ return [home, ...(ctx.workspaceList ? ctx.workspaceList() : [])].filter((x, i, a) => x && a.findIndex((y) => y && y.id === x.id) === i);
29
+ }
30
+
31
+ /** Every initiative of one workspace with its board, workflow, stage key and its tasks' places. null while its rows are being read. */
32
+ function standing(ctx, w) {
33
+ const B = boards();
34
+ const got = B.baseRows(w);
35
+ if (!got || !got.ok) return null;
36
+ let fr;
37
+ try { fr = B.frameFor(ctx, w); } catch { return null; }
38
+ const SEC = (fr.folded && fr.folded.sections) || new Map();
39
+ const out = [];
40
+ for (const b of fr.boards) {
41
+ for (const r of got.rows) {
42
+ if (B.boardIdOf(r, fr.boards, fr.folded, w) !== b.id) continue;
43
+ let row; try { row = B.boardRow(b, r, fr.folded); } catch { continue; }
44
+ const tasks = B.tasksOfIni(fr.folded, r.id).filter((t) => t && t.initiative === r.id && t.state !== 'Archived')
45
+ .map((t) => (SEC.has(t.id) ? SEC.get(t.id) || '' : (t.from && t.from.stage) || ''));
46
+ out.push({ w, id: r.id, title: r.title, board: b.id, self: !!b.self, wf: row.wf.id, stage: row.wfStage.key, ended: !!row.ended, tasks, own: fr.folded.iniWf ? fr.folded.iniWf.get(b.id + '\u0000' + r.id) || null : null });
47
+ }
48
+ }
49
+ return out;
50
+ }
51
+ const movable = (x, from) => x.wf === from && !x.ended && !x.self;
52
+
53
+ /** The workflow a new one replaces: its saved bridge's, else the one it began as a copy of, when that one has a stage the new one dropped. */
54
+ function replacesOf(lib, wf) {
55
+ if (!wf || wf.builtin || wf.archived) return null;
56
+ const fromId = (wf.bridge && wf.bridge.from) || wf.copiedFrom || null;
57
+ if (!fromId || fromId === wf.id) return null;
58
+ const from = WF.resolve(lib, fromId);
59
+ if (!from || from.id !== fromId) return null;
60
+ const keys = new Set(wf.stages.map((s) => s.key));
61
+ if (!wf.bridge && from.stages.every((s) => keys.has(s.key))) return null; // a plain copy that keeps every stage replaces nothing
62
+ return from;
63
+ }
64
+
65
+ /** The ✦ (WmB): "Move 12 initiatives to the 3-stage workflow", each new stage with the old ones that go into it and how many initiatives and
66
+ * tasks land there. Read from the home workspace's library; the initiatives from every open workspace. */
67
+ function proposals(ctx) {
68
+ const home = ctx.getWs ? ctx.getWs(null) : null;
69
+ const dir = home && ctx.stateDirFor ? ctx.stateDirFor(home) : null;
70
+ if (!dir) return [];
71
+ const lib = WS.library(dir);
72
+ const all = [];
73
+ for (const w of workspaces(ctx)) { const st = standing(ctx, w); if (st) all.push(...st); }
74
+ const out = [];
75
+ for (const wf of lib.byId.values()) {
76
+ const from = replacesOf(lib, wf);
77
+ if (!from) continue;
78
+ const mine = all.filter((x) => movable(x, from.id));
79
+ if (!mine.length) continue;
80
+ const map = WF.mapOf(from, wf);
81
+ const groups = wf.stages.map((t) => ({ key: t.key, name: t.name, from: from.stages.filter((s) => map[s.key] === t.key).map((s) => s.name), inis: 0, tasks: 0 }));
82
+ const g = (k) => groups.find((x) => x.key === k);
83
+ for (const x of mine) {
84
+ const cur = WF.stageByRef(from, x.stage); const to = g((cur && map[cur.key]) || wf.stages[0].key); if (to) to.inis++;
85
+ for (const sec of x.tasks) { const s = WF.stageByRef(from, sec); const tg = s ? g(map[s.key]) : null; if (tg) tg.tasks++; }
86
+ }
87
+ out.push({ id: 'prop:wf-bridge:' + wf.id + ':' + from.id, kind: 'wf-bridge', title: 'Move ' + mine.length + (mine.length === 1 ? ' initiative' : ' initiatives') + ' to ' + wf.name,
88
+ ws: home.id, wf: { id: wf.id, name: wf.name, icon: wf.icon }, from: { id: from.id, name: from.name }, n: mine.length,
89
+ saved: !!(wf.bridge && wf.bridge.from === from.id), map, groups: groups.filter((x) => x.from.length || x.inis || x.tasks), at: wf.at ? Date.parse(wf.at) || null : null });
90
+ }
91
+ return out;
92
+ }
93
+
94
+ /** The bridge saved with the new workflow (WmB, right: Settings › Workflows). map: { old stage key: stage key or name of the new workflow }. */
95
+ function saveBridge(ctx, w, { id, from, map } = {}, actor) {
96
+ const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
97
+ if (!dir) return { ok: false, status: 409, error: 'This workspace has no state folder yet, so the bridge cannot be saved.' };
98
+ const lib = WS.library(dir);
99
+ const wf = lib.byId.get(id);
100
+ if (!wf) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
101
+ if (wf.builtin) return { ok: false, status: 409, error: 'Product feature is built in. Its stages stay as they are.' };
102
+ const src = WF.resolve(lib, from);
103
+ if (!src || src.id !== from) return { ok: false, status: 404, error: 'The workflow it replaces could not be found.' };
104
+ if (!isObj(map)) return { ok: false, status: 400, error: 'map is { old stage key: stage of the new workflow }' };
105
+ const full = WF.mapOf(src, wf, map);
106
+ const { count, at, copiedFrom, archived, ...plain } = wf;
107
+ return WS.save(dir, { wf: { ...plain, bridge: { from, map: full } } }, actor, { standing: [] });
108
+ }
109
+
110
+ /** Every initiative on `from` switches to `id` with one batch id (WmB ✓). body: { id, from, map?, save? } — save (default true) keeps the map as
111
+ * the bridge. Answers how many initiatives and tasks moved, and the batch Undo names. */
112
+ function switchAll(ctx, w, body, g) {
113
+ const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
114
+ if (!dir) return { ok: false, status: 409, error: 'This workspace has no state folder yet.' };
115
+ const lib = WS.library(dir);
116
+ const to = lib.byId.get(body.id);
117
+ if (!to) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
118
+ if (to.archived) return { ok: false, status: 409, error: `${to.name} is archived. Bring it back first.` };
119
+ const from = WF.resolve(lib, body.from);
120
+ if (!from || from.id !== body.from) return { ok: false, status: 404, error: 'The workflow it replaces could not be found.' };
121
+ if (from.id === to.id) return { ok: false, status: 400, error: 'Pick another workflow to move to.' };
122
+ if (body.map != null && !isObj(body.map)) return { ok: false, status: 400, error: 'map is { old stage key: stage of the new workflow }' };
123
+ let target = to;
124
+ if (body.save !== false) {
125
+ const s = saveBridge(ctx, w, { id: to.id, from: from.id, map: body.map || {} }, g.actor);
126
+ if (!s.ok) return s;
127
+ target = s.workflow;
128
+ }
129
+ const map = WF.mapOf(from, target, body.map || null);
130
+ const all = [];
131
+ for (const x of workspaces(ctx)) { const st = standing(ctx, x); if (st === null) return { ok: false, status: 202, error: 'The initiatives are still being read. Try again in a moment.', pending: true }; all.push(...st); }
132
+ const batch = 'wfb-' + crypto.randomBytes(5).toString('hex');
133
+ let moved = 0, tasks = 0;
134
+ const failed = [];
135
+ for (const x of all.filter((y) => movable(y, from.id))) {
136
+ const r = boards().switchWorkflow(ctx, { ws: x.w.id, board: x.board, id: x.id, wf: target.id, map, batch, why: 'moved with ' + from.name + ' to ' + target.name + ' (approved ✦)' }, g);
137
+ if (r.status === 200 && r.body && r.body.ok) { moved++; tasks += x.tasks.length; } else failed.push({ id: x.id, title: x.title, error: (r.body && r.body.error) || 'not moved' });
138
+ }
139
+ return { ok: true, batch, moved, tasks, failed, workflow: { id: target.id, name: target.name }, from: { id: from.id, name: from.name } };
140
+ }
141
+
142
+ /** Undo a batch (WmD): within 7 days, every initiative of the batch that still stands where the switch put it goes back to its old workflow
143
+ * and stage; its tasks go back with the map from before. One that moved since stays where it is, and the answer says so ("11 of 12 undone"). */
144
+ function undoAll(ctx, w, body, g) {
145
+ if (typeof body.batch !== 'string' || !/^wfb-[a-f0-9]{10}$/.test(body.batch)) return { ok: false, status: 400, error: 'batch names the move to undo' };
146
+ let of = 0, undone = 0;
147
+ const kept = [];
148
+ for (const x of workspaces(ctx)) {
149
+ const st = standing(ctx, x);
150
+ if (st === null) return { ok: false, status: 202, error: 'The initiatives are still being read. Try again in a moment.', pending: true };
151
+ for (const y of st) {
152
+ const own = y.own;
153
+ if (!own || own.batch !== body.batch || own.undo) continue;
154
+ of++;
155
+ if (!own.at || Date.now() - Date.parse(own.at) > UNDO_MS) { kept.push({ id: y.id, title: y.title, why: 'more than 7 days ago' }); continue; }
156
+ if (y.wf !== own.wf || (own.landed && y.stage !== own.landed)) { kept.push({ id: y.id, title: y.title, why: 'moved since' }); continue; }
157
+ const r = boards().switchWorkflow(ctx, { ws: x.id, board: y.board, id: y.id, wf: own.from || WF.PRODUCT_FEATURE_ID, ...(own.left ? { to: own.left } : {}), undo: true, why: 'undo of the move to the new workflow' }, g);
158
+ if (r.status === 200 && r.body && r.body.ok) undone++; else kept.push({ id: y.id, title: y.title, why: (r.body && r.body.error) || 'not undone' });
159
+ }
160
+ }
161
+ if (!of) return { ok: false, status: 404, error: 'That move could not be found.' };
162
+ return { ok: true, undone, of, kept };
163
+ }
164
+
165
+ module.exports = { proposals, saveBridge, switchAll, undoAll, standing, replacesOf, UNDO_MS };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.476.0",
3
+ "version": "0.477.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.476.0",
9
+ "version": "0.477.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.476.0",
3
+ "version": "0.477.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -177,8 +177,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
177
177
  // a third row: it replaces the Viewer used least recently (v0, as v1 was used last)
178
178
  await A.page.click('#czViewer2 .cz-vw-hd', { position: { x: 30, y: 20 } });
179
179
  await A.page.evaluate(() => window.czPanels.putAway());
180
- await A.page.click('[data-cz-vw-rail="show"]'); // two Viewers fold the list to a rail; its list button brings the rows back
181
- await until(() => lay(A.page).then((l) => (!l.rail ? l : null)), 3000);
180
+ ok('N6 two Viewers leave the list as it was: only its own fold folds it (batch 20 item 6)', !(await lay(A.page)).rail);
182
181
  const v1r = (await lay(A.page)).panels.find((p) => p.id === 'v1').box;
183
182
  await drag(A.page, `#hmList .hm-rm[data-hm-sel="${R[2]}"]`, v1r.r - 60, 450);
184
183
  const l6c = await until(() => lay(A.page).then((l) => { const t = l.panels.filter((p) => p.kind === 'viewer' && p.box.shown); return t.length === 2 && t.some((p) => p.title !== t6[0] && p.title !== t6[1]) ? l : null; }), 6000);
@@ -0,0 +1,45 @@
1
+ /* pm/bd-fc-card.js — the forecast card on the Board timeline (build brief Grill and Forecast, UI-B Board; canvas FcBoard "Tap the hatched part").
2
+ * A press on a row's hatched range (`[data-fc-pick]`, drawn by pm/bd-span.js) opens a small card under it, never a panel: the range in one
3
+ * line, one line on why it is that wide, and the blue ✦ that opens what Claude proposes on the initiative (pm/ini-props.js, where the Grill's
4
+ * findings go). The ✦ shows only when there is something to open (zero is silence).
5
+ * init(api): api = { rowOf(key), openFindings(r, from) }. */
6
+ import { esc } from './premium-shell.js';
7
+ import * as Pop from './bd-pop.js';
8
+ import { fcRange, md } from './bd-span.js';
9
+
10
+ const SPARK = '<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/></svg>';
11
+ let A = null, curKey = null;
12
+ export function init(api) { A = api; }
13
+
14
+ /** The card's words for row r: { head, why, n } | null. Pure, so a test reads it without a page. */
15
+ export function cardWords(r) {
16
+ const fr = fcRange(r); if (!fr) return null;
17
+ const F = r.forecast, range = +fr.low !== +fr.high ? md(fr.low) + ' to ' + md(fr.high) : md(fr.high);
18
+ const head = fr.tone === 'held' ? 'The forecast for ' + r.title + ' is held at ' + range + '.' : r.title + ' will land ' + range + '.';
19
+ const open = F.total > 0 && F.done != null ? F.total - F.done : null;
20
+ const why = fr.tone === 'held' ? F.why || 'Jira has not been read for over a week, so the range is held where it was.'
21
+ : open != null ? 'Jira shows ' + open + ' of ' + F.total + ' tickets open' + (F.promised ? ', and the promise is ' + md(new Date(+F.promised.slice(0, 4), +F.promised.slice(5, 7) - 1, +F.promised.slice(8, 10))) : '') + '.'
22
+ : F.why || '';
23
+ const n = r.props && r.props.n > 0 ? r.props.n : 0;
24
+ return { head, why, n };
25
+ }
26
+
27
+ function cardHtml(r) {
28
+ const w = cardWords(r); if (!w) return '';
29
+ const go = w.n ? `<div class="bd-fc-go"><button type="button" class="bd-fc-sp" data-fc-props aria-label="${esc('See what Claude proposes: ' + w.n)}" title="What Claude proposes">${SPARK}</button></div>` : '';
30
+ return `<p class="bd-pc-h">${esc(w.head)}</p>${w.why ? `<p class="bd-amut bd-pc-sub">${esc(w.why)}</p>` : ''}${go}`;
31
+ }
32
+
33
+ export function openCard(btn, key) {
34
+ const r = A && A.rowOf(key); if (!r) return;
35
+ const html = cardHtml(r); if (!html) return;
36
+ curKey = key;
37
+ Pop.open(html, btn, { label: 'Forecast of ' + r.title, width: 300, cls: 'bd-pc bd-fc', focus: '[data-fc-props]', onClose: () => { curKey = null; } });
38
+ }
39
+
40
+ document.addEventListener('click', (e) => {
41
+ if (!A) return;
42
+ const pk = e.target.closest('[data-fc-pick]'); if (pk) { e.preventDefault(); openCard(pk, pk.dataset.fcPick); return; }
43
+ const go = e.target.closest('[data-fc-props]');
44
+ if (go && Pop.isOpen() && Pop.el().contains(go) && curKey) { const r = A.rowOf(curKey); Pop.close(false); if (r) A.openFindings(r, null); }
45
+ });
@@ -65,7 +65,7 @@ export function nextOf(r, ctx = {}) {
65
65
  // another workflow: the first open task of its stage, by order
66
66
  if (r.wf && r.wf.id && r.wf.id !== PF && r.wfStage) {
67
67
  const st = r.wfStage, list = r.wfStages || [st];
68
- const mine = (r.tasks || []).filter((k) => sectionOf(k, list) === st.key && k.status !== 'Archived')
68
+ const mine = (r.tasks || []).filter((k) => sectionOf(k, list, r.wfMap) === st.key && k.status !== 'Archived')
69
69
  .map((k, i) => ({ k, i })).sort((a, b) => (Number.isFinite(a.k.order) ? a.k.order : 1e9 + a.i) - (Number.isFinite(b.k.order) ? b.k.order : 1e9 + b.i)).map((x) => x.k);
70
70
  const counted = mine.filter((k) => k.status !== "Won't do"), done = counted.filter((k) => k.status === 'Done').length;
71
71
  if (!mine.length) return { verb: 'Add what finishes', obj: st.name, act: { kind: 'add', label: 'Add a task to ' + st.name, stage: st.key } };
@@ -1,6 +1,22 @@
1
- /* pm/bd-publish.css — the Publish popover (pm/bd-publish.js). It looks like the viewer's share popover (premium-vw-doc.css .vwshp): the same card, rows,
2
- * switch, segmented control and Open links list. A bottom sheet on a phone. Design: prototype/board-publish/publish-popover-design.html. */
3
- .bppop{position:absolute;right:0;top:calc(100% + 6px);z-index:30;width:360px;max-width:min(360px,calc(100vw - 32px));max-height:min(80vh,640px);overflow:auto;padding:8px;border-radius:12px;background:var(--card-solid);border:1px solid var(--hair);box-shadow:0 10px 30px rgb(0 0 0 / .14);color:var(--ink);font:inherit;text-align:left}
1
+ /* pm/bd-publish.css — the Publish popover (pm/bd-publish.js). Design: batch 20 item 2, SbPublish: a card under the share icon with a caret to it,
2
+ * icon-only buttons, one row to the Shared tab. A bottom sheet on a phone. pm/bd-publish.js places it (position: fixed, from the icon's box). */
3
+ .bppop{--card-solid:var(--cz-card);--hair:var(--cz-hair);--ink:var(--cz-ink);--ink-2:var(--cz-ink2);--ink-3:var(--cz-ink3);--solid:var(--cz-blueink);--on-solid:var(--cz-card);--bad:var(--cz-red);--mono:var(--cz-mono);--ember:var(--cz-blue);position:fixed;left:16px;top:64px;z-index:60;width:380px;max-width:calc(100vw - 32px);border-radius:20px;background:var(--card-solid);border:1px solid var(--hair);box-shadow:0 14px 40px rgb(20 24 40 / .14);color:var(--ink);font:inherit;text-align:left}
4
+ .bppop .bpbody{max-height:min(80vh,640px);overflow:auto;padding:10px 8px}
5
+ .bppop .bpcaret{position:absolute;top:-8px;left:var(--bp-caret,330px);width:14px;height:14px;background:var(--card-solid);border-left:1px solid var(--hair);border-top:1px solid var(--hair);transform:rotate(45deg)}
6
+ .bppop .bpib{width:36px;height:36px;border-radius:999px;border:1px solid var(--hair);background:var(--card-solid);color:var(--ink-2);display:inline-flex;align-items:center;justify-content:center;padding:0;flex:none;cursor:pointer;font:inherit}
7
+ .bppop .bpib .i{width:18px;height:18px;color:inherit}
8
+ .bppop .bpib.gh{background:transparent;border-color:transparent}.bppop .bpib:hover{background:color-mix(in srgb,var(--ink) 6%,transparent)}
9
+ .bppop .bpib.pri{background:var(--solid);border-color:var(--solid);color:var(--on-solid)}
10
+ .bppop .bpib.sm,.bppop .bpib.xs{width:34px;height:34px}.bppop .bpib.xs .i{width:14px;height:14px}
11
+ .bppop .bpib.big{width:48px;height:48px}.bppop .bpib.big .i{width:20px;height:20px}
12
+ .bppop .bpib:disabled{opacity:.55;cursor:default}
13
+ .bppop .bphead{display:flex;align-items:center;gap:10px;padding:4px 8px 10px}.bppop .bphead b{display:block;font-weight:800}.bppop .bphead em{font-style:normal;color:var(--ink-3);font-size:12px}
14
+ .bppop .bptile{width:36px;height:36px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--cz-risk) 14%,transparent);flex:none}.bppop .bptile .i{color:var(--cz-risk)}
15
+ .bppop .bpfoot{display:flex;align-items:center;gap:8px;padding:8px 8px 4px}
16
+ .bppop .bphost{display:flex;align-items:center;gap:6px;min-width:0;padding:0}.bppop .bphn{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
17
+ .bppop .bpoff{color:var(--ink-3)}
18
+ .bppop .bpshared{display:flex;align-items:center;gap:8px;width:calc(100% - 16px);min-height:44px;margin:10px 8px 0;padding:0 2px;border:0;border-top:1px solid var(--hair);background:transparent;color:var(--ink-2);font:inherit;text-align:left;cursor:pointer}
19
+ .bppop .bpshared:hover{color:var(--ink)}
4
20
  .bppop .i{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;color:var(--ink-3)}
5
21
  .bppop .bpeye{font:500 11px var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);padding:8px 8px 2px}
6
22
  .bppop .bpchips{display:flex;flex-wrap:wrap;gap:6px;padding:2px 8px 6px}
@@ -14,7 +30,8 @@
14
30
  .bppop .bpfield{display:grid;gap:2px;padding:2px 8px}.bppop .bpfield>label{font-size:12px;color:var(--ink-3)}
15
31
  .bppop .bpinp,.bppop .bpinp2{min-height:40px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);color:inherit;font:inherit}
16
32
  .bppop .bpinp{padding:0 12px;width:100%}
17
- .bppop .bpinp2{display:flex;align-items:center;gap:8px;padding:0 6px 0 12px}.bppop .bpinp2 input{flex:1;min-width:0;border:0;background:transparent;color:inherit;font:500 12px var(--mono);outline:0;min-height:38px}
33
+ .bppop .bpinp2{display:flex;align-items:center;gap:8px;padding:0 4px 0 12px;min-height:44px;border-radius:22px}.bppop .bpinp2 input{flex:1;min-width:0;border:0;background:transparent;color:inherit;font:inherit;outline:0;min-height:40px}.bppop .bpinp2 #bpPass{font:700 14px var(--mono)}
34
+ .bppop .bpfield{padding:3px 8px}
18
35
  .bppop .bpline2{display:flex;align-items:center;gap:10px;min-height:40px;padding:2px 8px}.bppop .bpg{flex:1;min-width:0}
19
36
  .bppop .bpsw{width:48px;height:40px;border:0;background:transparent;position:relative;cursor:pointer;flex:none;padding:0}
20
37
  .bppop .bpsw::before{content:"";position:absolute;left:6px;top:9px;width:36px;height:22px;border-radius:99px;background:var(--hair)}
@@ -23,23 +40,10 @@
23
40
  .bppop .bpseg{display:inline-flex;border:1px solid var(--hair);border-radius:8px;overflow:hidden}
24
41
  .bppop .bpseg button{border:0;background:transparent;color:var(--ink-2);min-height:36px;padding:0 12px;font:inherit;cursor:pointer}
25
42
  .bppop .bpseg button[aria-pressed="true"]{background:color-mix(in srgb, var(--ink) 6%, transparent);color:inherit;font-weight:600}
26
- .bppop .bpbtn{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 14px;border-radius:8px;border:1px solid var(--hair);background:var(--card-solid);color:inherit;font:600 14px inherit;font-family:inherit;cursor:pointer;text-decoration:none}
27
- .bppop .bpbtn.pri{background:var(--solid);border-color:var(--solid);color:var(--on-solid)}
28
- .bppop .bpbtn.sm{min-height:34px;padding:0 10px;font-size:12px}
29
- .bppop .bpbtn.bad{color:var(--bad)}.bppop .bpbtn.bad.sure{background:color-mix(in srgb,var(--bad) 12%,transparent)}
30
- .bppop .bpbtn:disabled{opacity:.55;cursor:default}
31
- .bppop .bpgo{margin:6px 8px 2px;width:calc(100% - 16px)}
32
43
  .bppop .bpnote{color:var(--ink-3);font-size:12px;padding:4px 8px;margin:0}
33
44
  .bppop .bperr{margin:4px 8px;padding:8px 10px;border-radius:8px;background:color-mix(in srgb,var(--bad) 12%,transparent);color:var(--bad);font-size:14px}
34
- .bppop .bplink{display:inline-flex;align-items:center;border:0;background:transparent;color:var(--solid);font:inherit;text-decoration:underline;cursor:pointer;padding:0 8px;min-height:36px}
35
- .bppop .bpsep{height:1px;background:var(--hair);margin:8px 0 2px}
36
45
  .bppop .bplnk{margin:2px 8px;padding:10px 12px;border-radius:8px;background:color-mix(in srgb, var(--ink) 6%, transparent);display:grid;gap:8px}
37
46
  .bppop .bpline{display:flex;align-items:center;gap:8px}.bppop .bplnk code{font:500 12px var(--mono);overflow-wrap:anywhere}
38
- .bppop .bpact{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.bppop .bpok{color:var(--ink-2);font-size:14px}
39
- .bppop .bprow{display:flex;align-items:center;gap:8px;padding:6px 8px}.bppop .bprow .bpg b{display:block;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
40
- .bppop .bprow em{font-style:normal;color:var(--ink-3);font-size:12px}.bppop .bprow em.soon{color:var(--bad)}
41
- .bppop .bpempty{display:grid;gap:10px;padding:12px 8px 10px;justify-items:start}.bppop .bpempty p{margin:0;color:var(--ink-2)}
42
47
  .bppop :focus-visible{outline:2px solid var(--ember);outline-offset:2px}
43
- .bd-tools:has(.bppop){position:relative}
44
48
  #bdPublish{position:relative}#bdPublish .bpn{position:absolute;top:2px;right:0;min-width:16px;padding:0 5px;border-radius:99px;background:var(--solid);color:var(--on-solid);font:600 11px var(--mono);text-align:center;line-height:16px}
45
- @media (max-width:640px){.bppop{position:fixed;left:0;right:0;bottom:0;top:auto;width:auto;max-width:none;max-height:85vh;border-radius:16px 16px 0 0;border-width:1px 0 0;padding:12px 12px calc(18px + env(safe-area-inset-bottom,0px));box-shadow:0 -8px 30px rgb(0 0 0 / .18)}}
49
+ @media (max-width:640px){.bppop{left:0 !important;right:0;bottom:0;top:auto !important;width:auto;max-width:none;border-radius:16px 16px 0 0;border-width:1px 0 0;box-shadow:0 -8px 30px rgb(0 0 0 / .18)}.bppop .bpbody{max-height:85vh;padding:12px 12px calc(18px + env(safe-area-inset-bottom,0px))}.bppop .bpcaret{display:none}}