create-pmos 0.833.0 → 0.835.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.
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+ /* story-map-cli.js — `pmos story-map …`: a new bet's story map from a terminal or the chat, on the same store the initiative popup reads
3
+ * (initiative story-map, idea A419; lib/story-map.js). Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent and Jira is not written. */
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { TAG, read, save, set, moveTo, keep, unkeep, count, releaseOf } = require('./story-map.js');
7
+
8
+ /* ── pmos story-map ── */
9
+ const COMMANDS = { 'story-map': ['show', 'set', 'move', 'keep', 'unkeep', 'drop', 'count'] };
10
+ const USAGE = [
11
+ 'usage: pmos story-map show|set|move|keep|unkeep|drop|count — a new bet\'s story map: the user\'s journey, and the Release 1 line',
12
+ ' pmos story-map show <initiative> the steps, each with its Release 1 tasks, then the later ones; prints the task ids',
13
+ ' pmos story-map set <initiative> --text "<lines>" write the map: one line per step, "Step: task; task / later task" (--text - reads stdin)',
14
+ ' pmos story-map move <initiative> <task> --above|--below move a task across the Release 1 line',
15
+ ' pmos story-map keep <initiative> make every task a task of the initiative, Release 1 first (once)',
16
+ ' pmos story-map unkeep <initiative> delete the tasks Keep added; the map stays',
17
+ ' pmos story-map drop <initiative> delete a map that is not kept',
18
+ ' pmos story-map count [--days 14] maps kept in the last days; the last line is the number',
19
+ ' every command: [--json] [--root <dir>]. Nothing is sent and Jira is not written.',
20
+ ];
21
+
22
+ function parseArgs(argv) {
23
+ const pos = [], flags = {};
24
+ for (let i = 0; i < argv.length; i++) {
25
+ const a = argv[i];
26
+ if (a === '--root' || a === '--days' || a === '--text') flags[a.slice(2)] = argv[++i];
27
+ else if (a.startsWith('--')) flags[a.slice(2)] = true;
28
+ else if (a === '-h') flags.help = true;
29
+ else pos.push(a);
30
+ }
31
+ return { pos, flags };
32
+ }
33
+
34
+ function cliCtx(root, stateDir) {
35
+ const w = { id: require('./driver.js').wsIdOf(root), name: path.basename(root), root };
36
+ return { w, ctx: { getWs: () => w, workspaceList: () => [w], stateDirFor: () => stateDir, selfRoot: path.resolve(__dirname, '..', '..') } };
37
+ }
38
+
39
+ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), stdin = null, isTTY, env } = {}) {
40
+ const args = argv[0] === 'story-map' ? argv.slice(1) : argv.slice();
41
+ const verb = args[0];
42
+ const { pos, flags } = parseArgs(args.slice(1));
43
+ if (!verb || verb === 'help' || flags.help) { for (const l of USAGE) say(l); return verb ? 0 : 2; }
44
+ if (!COMMANDS['story-map'].includes(verb)) { say(`unknown story-map command "${verb}" — one of ${COMMANDS['story-map'].join(', ')}`); return 2; }
45
+ const json = !!flags.json;
46
+ const fail = (error, code = 1) => { say(json ? JSON.stringify({ ok: false, error }) : `✗ ${error}`); return code; };
47
+ let root = flags.root ? path.resolve(cwd, flags.root) : cwd;
48
+ if (!flags.root) { let d = cwd; while (d !== path.dirname(d) && !fs.existsSync(path.join(d, '.git'))) d = path.dirname(d); root = fs.existsSync(path.join(d, '.git')) ? d : cwd; }
49
+ const driver = require('./driver.js');
50
+ const dir = driver.stateDirOf(root, { create: !['show', 'count'].includes(verb) });
51
+ if (!dir) return fail('this repository has no PMOS state folder (pmos/state, state or .pmos)');
52
+
53
+ if (verb === 'count') {
54
+ const days = Math.max(1, Math.min(365, parseInt(flags.days, 10) || 14));
55
+ const n = count(dir, { days });
56
+ if (json) say(JSON.stringify({ ok: true, days, kept: n }));
57
+ else { say(`${TAG} ${n} story map${n === 1 ? '' : 's'} kept as a task breakdown in the last ${days} days.`); say(String(n)); }
58
+ return 0;
59
+ }
60
+ const ini = pos[0];
61
+ if (!ini) { for (const l of USAGE) say(l); return 2; }
62
+ if (verb === 'show') {
63
+ const m = read(dir, ini);
64
+ if (!m) return fail(`no story map for ${ini}. Write one with pmos story-map set ${ini} --text "Step: task / later"`);
65
+ if (json) { say(JSON.stringify({ ok: true, map: m, release: releaseOf(m) })); return 0; }
66
+ say(`Story map of ${ini} · drafted by ${m.by === 'pm' ? 'you' : 'PMOS'}${m.kept ? ' · kept as ' + m.kept.tasks.length + ' tasks' : ''}`);
67
+ for (const s of m.steps) say(`${s.name}: ${s.tasks.filter((t) => t.rel === 1).map((t) => `${t.title} (${t.id})`).join('; ') || '—'}${s.tasks.some((t) => t.rel !== 1) ? ' / ' + s.tasks.filter((t) => t.rel !== 1).map((t) => `${t.title} (${t.id})`).join('; ') : ''}`);
68
+ say(`Release 1: ${releaseOf(m).length} tasks.`);
69
+ return 0;
70
+ }
71
+ if (verb === 'set') {
72
+ let text = flags.text;
73
+ if (text === '-' || text === true) text = stdin != null ? stdin : fs.readFileSync(0, 'utf8');
74
+ if (!text) return fail('give the map with --text "<lines>"', 2);
75
+ const r = set(dir, ini, text, { by: 'pmos' });
76
+ if (!r.ok) return fail(r.error);
77
+ if (json) say(JSON.stringify({ ok: true, map: r.map })); else say(`✓ story map of ${ini}: ${r.map.steps.length} steps, Release 1 has ${releaseOf(r.map).length} tasks. The initiative on Work shows it.`);
78
+ return 0;
79
+ }
80
+ if (verb === 'move') {
81
+ const side = flags.above ? 'above' : flags.below ? 'below' : '';
82
+ if (!pos[1] || !side) return fail('usage: pmos story-map move <initiative> <task> --above|--below', 2);
83
+ const r = moveTo(dir, ini, pos[1], side);
84
+ if (!r.ok) return fail(r.error);
85
+ if (json) say(JSON.stringify({ ok: true, map: r.map })); else say(`✓ ${pos[1]} is ${side} the line. Release 1 has ${releaseOf(r.map).length} tasks.`);
86
+ return 0;
87
+ }
88
+ if (verb === 'drop') {
89
+ const m = read(dir, ini);
90
+ if (!m) return fail(`no story map for ${ini}`);
91
+ if (m.kept) return fail('this map is kept as the task breakdown; unkeep it first');
92
+ save(dir, ini, null);
93
+ console.info(`${TAG} drop ini=${ini}`);
94
+ if (json) say(JSON.stringify({ ok: true })); else say(`✓ the story map of ${ini} is deleted.`);
95
+ return 0;
96
+ }
97
+ const actorLib = require('./actor.js');
98
+ const cli = { isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env };
99
+ const g = { ok: true, actor: actorLib.fromCli(cli), cli };
100
+ const { w, ctx } = cliCtx(root, dir);
101
+ const r = verb === 'keep' ? keep(ctx, w, ini, dir, g) : unkeep(ctx, w, ini, dir, g);
102
+ if (!r.ok) return fail(r.error);
103
+ if (json) say(JSON.stringify({ ok: true, map: r.map, ...(verb === 'keep' ? { added: r.added.length } : { removed: r.removed }) }));
104
+ else say(verb === 'keep' ? `✓ ${r.added.length} tasks added to ${ini}, Release 1 first. Work shows them. Nothing was sent.` : `✓ ${r.removed} tasks taken back from ${ini}. The map stays.`);
105
+ return 0;
106
+ }
107
+
108
+ module.exports = { run, COMMANDS, USAGE };
@@ -0,0 +1,172 @@
1
+ 'use strict';
2
+ /* story-map.js — a story map with the first release line for a new bet (initiative story-map, idea A419; board BatchPlanDS panel 5).
3
+ *
4
+ * The steps of the user's journey run left to right, the tasks of each step top to bottom, and a dashed line marks Release 1: the thinnest
5
+ * release that works end to end (Jeff Patton's story mapping). PMOS drafts it through the existing read-only ✦ draft job (lib/star-draft.js,
6
+ * the words are askOf below); nothing is kept until the PM's ✓. The PM moves a task across the line; Keep makes every task a task of the
7
+ * initiative's breakdown, Release 1 first, by the boards' own Add a task, and Unkeep deletes them again.
8
+ *
9
+ * PURE
10
+ * parseDraft(text) → { steps: [{ name, tasks: [{ id, title, rel }] }] } | { error } one line per step: `Step: a; b / c; d`;
11
+ * the tasks before the `/` are Release 1 (rel 1), the rest later (rel 2). At least 2 steps and 1 Release 1 task.
12
+ * releaseOf(map) → [{ id, title, step }] the Release 1 tasks, step by step
13
+ * move(map, task, 'above' | 'below') → map | null the task on the other side of the line (null: no such task)
14
+ * newBet(taskCount) → true when the initiative has fewer than NEW_BET tasks (the ✦ line shows only then)
15
+ * askOf({ id, title }) → the ✦ draft words for the initiative
16
+ * textOf(map) → the map as lines (`pmos story-map show`, and the draft form again)
17
+ * STORE (the product's state folder: story-maps.json, { <initiative>: map })
18
+ * read(dir, ini) · save(dir, ini, map | null) · set(dir, ini, text, { by, now }) → { ok, map, prev } | { ok: false, error }
19
+ * moveTo(dir, ini, task, side) → { ok, map, from } | { ok: false, error }
20
+ * keep(ctx, w, ini, dir, g) → { ok, map, added } | { ok: false, status, error } refused when the map is kept already (no second copy)
21
+ * unkeep(ctx, w, ini, dir, g) → { ok, map, removed }
22
+ * count(dir, { days, now }) → maps kept in the window
23
+ * CLI: lib/story-map-cli.js — `pmos story-map show|set|move|keep|unkeep|drop|count`
24
+ *
25
+ * WHAT IT NEVER DOES. It calls no model of its own, writes no Jira and sends nothing. Every write logs one [story-map] line. */
26
+ const fs = require('fs');
27
+ const path = require('path');
28
+
29
+ const TAG = '[story-map]';
30
+ const FILE = 'story-maps.json';
31
+ const NEW_BET = 3;
32
+ const MAX_STEPS = 8, MAX_TASKS = 10, MAX_TITLE = 120;
33
+
34
+ const clip = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
35
+
36
+ /** PURE. */
37
+ function parseDraft(text) {
38
+ const lines = String(text == null ? '' : text).replace(/\r\n?/g, '\n').replace(/```[a-z]*\n?/gi, '').split('\n');
39
+ const steps = [];
40
+ let n = 0;
41
+ for (const raw of lines) {
42
+ const l = raw.replace(/^\s*(?:[-*•]|\d+[.)])\s*/, '').replace(/\*\*/g, '').trim();
43
+ const m = /^([^:]{1,60}):\s*(.+)$/.exec(l);
44
+ if (!m) continue;
45
+ const name = clip(m[1], 40);
46
+ const cut = /\s+\/\s+|\s*\|\s*|^\/\s*|\s*\/$/.exec(m[2]); // the Release 1 line: " / " (or "|")
47
+ const now = cut ? m[2].slice(0, cut.index) : m[2], later = cut ? m[2].slice(cut.index + cut[0].length) : '';
48
+ const tasks = [];
49
+ for (const [part, rel] of [[now, 1], [later, 2]]) {
50
+ for (const t of part.split(/\s*;\s*/)) { const title = clip(t.replace(/[.]+$/, ''), MAX_TITLE); if (title && tasks.length < MAX_TASKS) tasks.push({ id: 't' + (++n), title, rel }); }
51
+ }
52
+ if (!name || !tasks.length) continue;
53
+ steps.push({ name, tasks });
54
+ if (steps.length >= MAX_STEPS) break;
55
+ }
56
+ if (steps.length < 2) return { error: 'a story map needs at least 2 steps of the user\'s journey, one line each: "Step: task; task / later task"' };
57
+ if (!steps.some((s) => s.tasks.some((t) => t.rel === 1))) return { error: 'a story map needs at least one Release 1 task (before the /)' };
58
+ return { steps };
59
+ }
60
+
61
+ /** PURE. */
62
+ function releaseOf(map) {
63
+ const out = [];
64
+ for (const s of (map && map.steps) || []) for (const t of s.tasks || []) if (t.rel === 1) out.push({ id: t.id, title: t.title, step: s.name });
65
+ return out;
66
+ }
67
+
68
+ /** PURE: a new map with the task on the given side of the line; a task keeps its place among its step's tasks. */
69
+ function move(map, task, side) {
70
+ if (!map || !Array.isArray(map.steps) || (side !== 'above' && side !== 'below')) return null;
71
+ let hit = false;
72
+ const steps = map.steps.map((s) => ({ ...s, tasks: s.tasks.map((t) => { if (t.id !== task) return t; hit = true; return { ...t, rel: side === 'above' ? 1 : Math.max(2, t.rel === 1 ? 2 : t.rel) }; }) }));
73
+ return hit ? { ...map, steps } : null;
74
+ }
75
+
76
+ const newBet = (taskCount) => (Number(taskCount) || 0) < NEW_BET;
77
+
78
+ function askOf({ id, title } = {}) {
79
+ return `Draft a story map for the initiative "${clip(title || id, 120)}" (id ${clip(id, 80)}). Read its record, its goal and its sources (PRD, research, notes) first, and use the user's own words from them.`
80
+ + ' Answer 3 to 6 lines, one per step of the user\'s journey, left to right in the order the user goes, each in this form:'
81
+ + '\nStep name: task; task / later task; later task'
82
+ + '\nThe tasks before the / are the thinnest first release that still works from the first step to the last: at least one per step, as few as possible. The tasks after the / come later. Keep each task to a few words.';
83
+ }
84
+
85
+ /** PURE. */
86
+ function textOf(map) {
87
+ return ((map && map.steps) || []).map((s) => {
88
+ const a = s.tasks.filter((t) => t.rel === 1).map((t) => t.title), b = s.tasks.filter((t) => t.rel !== 1).map((t) => t.title);
89
+ return `${s.name}: ${[a.join('; '), b.length ? '/ ' + b.join('; ') : ''].filter(Boolean).join(' ')}`;
90
+ }).join('\n');
91
+ }
92
+
93
+ /* ── the store ── */
94
+ const fileOf = (dir) => path.join(dir, FILE);
95
+ function readAll(dir) { try { const o = JSON.parse(fs.readFileSync(fileOf(dir), 'utf8')); return o && typeof o === 'object' && !Array.isArray(o) ? o : {}; } catch { return {}; } }
96
+ function read(dir, ini) { const m = dir ? readAll(dir)[ini] : null; return m && Array.isArray(m.steps) ? m : null; }
97
+ function save(dir, ini, map) {
98
+ const all = readAll(dir);
99
+ if (map) all[ini] = map; else delete all[ini];
100
+ fs.mkdirSync(dir, { recursive: true });
101
+ const tmp = fileOf(dir) + '.' + process.pid + '.tmp';
102
+ fs.writeFileSync(tmp, JSON.stringify(all, null, 1) + '\n');
103
+ fs.renameSync(tmp, fileOf(dir));
104
+ }
105
+ const okId = (ini) => /^[a-z0-9][a-z0-9._-]{0,80}$/.test(String(ini || ''));
106
+
107
+ function set(dir, ini, text, { by = 'pmos', now = Date.now() } = {}) {
108
+ if (!okId(ini)) return { ok: false, error: 'the initiative id is missing or not a lowercase slug' };
109
+ const prev = read(dir, ini);
110
+ if (prev && prev.kept) return { ok: false, error: 'this map is kept as the task breakdown already; unkeep it first' };
111
+ const p = parseDraft(text);
112
+ if (p.error) return { ok: false, error: p.error };
113
+ const map = { ini, by: by === 'pm' ? 'pm' : 'pmos', at: new Date(now).toISOString(), steps: p.steps, kept: null };
114
+ save(dir, ini, map);
115
+ console.info(`${TAG} set ini=${ini} steps=${map.steps.length} release1=${releaseOf(map).length} by=${map.by}`);
116
+ return { ok: true, map, prev };
117
+ }
118
+
119
+ function moveTo(dir, ini, task, side) {
120
+ const m = read(dir, ini);
121
+ if (!m) return { ok: false, error: `no story map for ${ini}` };
122
+ const t = m.steps.flatMap((s) => s.tasks).find((x) => x.id === task);
123
+ const n = move(m, task, side);
124
+ if (!n || !t) return { ok: false, error: `no task ${task} on the story map of ${ini}, or the side is not above or below` };
125
+ save(dir, ini, n);
126
+ console.info(`${TAG} move ini=${ini} task=${task} ${side} release1=${releaseOf(n).length}`);
127
+ return { ok: true, map: n, from: t.rel === 1 ? 'above' : 'below' };
128
+ }
129
+
130
+ function keep(ctx, w, ini, dir, g) {
131
+ const m = read(dir, ini);
132
+ if (!m) return { ok: false, status: 404, error: `no story map for ${ini}` };
133
+ if (m.kept) return { ok: false, status: 409, error: 'this map is kept as the task breakdown already' };
134
+ const RB = require('./routes-boards.js');
135
+ let wf = RB.initiativeWorkflow(ctx, w, ini);
136
+ // outside the server (pmos story-map keep) the rows may still be read: derive them now, as pmos task add does
137
+ if (wf.pending) { try { require('./initiative-rows.js').deriveNow(w.root); } catch { /* answered below */ } wf = RB.initiativeWorkflow(ctx, w, ini); }
138
+ if (!wf.ok || !wf.board) return { ok: false, status: (wf && wf.status) || 404, error: (wf && wf.error) || 'the initiative is on no board' };
139
+ const order = [], added = [];
140
+ for (const rel of [1, 2]) for (const s of m.steps) for (const t of s.tasks) if ((t.rel === 1) === (rel === 1)) order.push({ s, t });
141
+ for (const { s, t } of order) {
142
+ const r = RB.taskAdd(ctx, { ws: w.id, board: wf.board.id, initiative: ini, title: t.title, notes: `Story map: ${s.name} · ${t.rel === 1 ? 'Release 1' : 'Later'}` }, g);
143
+ if (!r.body || r.body.ok !== true) {
144
+ for (const a of added) RB.taskDelete(ctx, { ws: w.id, board: wf.board.id, task: a.uid, why: 'story map keep did not finish' }, g);
145
+ return { ok: false, status: r.status || 500, error: (r.body && r.body.error) || 'a task could not be added' };
146
+ }
147
+ added.push({ id: t.id, uid: r.body.item.uid || r.body.item.id });
148
+ }
149
+ const n = { ...m, kept: { at: new Date().toISOString(), board: wf.board.id, tasks: added } };
150
+ save(dir, ini, n);
151
+ console.info(`${TAG} keep ini=${ini} tasks=${added.length} release1=${releaseOf(m).length}`);
152
+ return { ok: true, map: n, added };
153
+ }
154
+
155
+ function unkeep(ctx, w, ini, dir, g) {
156
+ const m = read(dir, ini);
157
+ if (!m || !m.kept) return { ok: false, status: 404, error: `no kept story map for ${ini}` };
158
+ const RB = require('./routes-boards.js');
159
+ let removed = 0;
160
+ for (const a of m.kept.tasks || []) { const r = RB.taskDelete(ctx, { ws: w.id, board: m.kept.board, task: a.uid, why: 'story map unkept' }, g); if (r.body && r.body.ok) removed++; }
161
+ const n = { ...m, kept: null };
162
+ save(dir, ini, n);
163
+ console.info(`${TAG} unkeep ini=${ini} removed=${removed}`);
164
+ return { ok: true, map: n, removed };
165
+ }
166
+
167
+ function count(dir, { days = 14, now = Date.now() } = {}) {
168
+ const from = now - days * 864e5;
169
+ return Object.values(readAll(dir)).filter((m) => m && m.kept && Date.parse(m.kept.at) >= from).length;
170
+ }
171
+
172
+ module.exports = { TAG, FILE, NEW_BET, parseDraft, releaseOf, move, newBet, askOf, textOf, read, save, set, moveTo, keep, unkeep, count };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.833.0",
3
+ "version": "0.835.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.833.0",
9
+ "version": "0.835.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.833.0",
3
+ "version": "0.835.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",
@@ -18,6 +18,7 @@
18
18
  * the page already reads stand in. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
19
  import { wireSwipe } from './cozy-phone-swipe.js';
20
20
  import * as M from './pop-work-model.js';
21
+ import * as WD from './work-drag.js'; // drag a bar to change its dates (initiative timeline-bar-drag)
21
22
  import * as CB from './cozy-bar.js';
22
23
  import { openPop, closePop, undoToast } from './hi-pop.js';
23
24
  import { pmGet, pmPost } from './http.js';
@@ -37,6 +38,7 @@ import * as IF from './inline-fields.js'; // a task's sprint and priority, set
37
38
  import * as SD from './star-draft.js'; // a ✦ draft runs as a PMOS background job and lands on its line (star-buttons-act-directly A7)
38
39
  import * as CAP from './pop-cap.js'; // five actions at most: Ask PMOS and the toolbar's four, the rest under ⋯ (popup-cap, idea A498)
39
40
  import { noteUse } from './use-log.js';
41
+ import * as STMAP from './story-map.js'; // a new bet's story map with the Release 1 line (initiative story-map, A419)
40
42
  import * as TLY from './three-layouts.js'; // three layouts for a new screen, pick one (initiative three-layouts, A317)
41
43
  import * as PR from './print-pdf.js'; // Print or PDF under ⋯ (job #1911, A379)
42
44
  import * as SMAP from './stakeholder-map.js'; // the People block: who decides, must agree, needs to know (stakeholder-map, A371)
@@ -497,7 +499,9 @@ function dsHtml(r, v, o, W, S, C, mode) {
497
499
  const lay = TLY.html(TLY.seen(id));
498
500
  // the People block under the Overview (stakeholder-map, BatchPeopleDS panel 9): drawn from memory, read once per initiative; no name, no block
499
501
  const ppl = SMAP.blockFor(id, o.ws, () => { if (artRedraw) artRedraw(); });
500
- return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${lay}${crit}${wbs}</div></div>`;
502
+ // the story map (A419): a new bet's journey and its Release 1 line, above the breakdown; nothing when there is no map and the bet has tasks
503
+ const smap = STMAP.blockHtml({ id, ws: o.ws || '', title: W.title || '', tasks: stagesOf(r, v, { ...o, today: W.today, subAll: true }).filter((x) => x.kind === 'task').length });
504
+ return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${lay}${smap}${crit}${wbs}</div></div>`;
501
505
  }
502
506
 
503
507
  /** The grouping ✦ the PM said no to, for this initiative: 'group:<stage>'. */
@@ -919,6 +923,7 @@ export function wire(body, h0, x0) {
919
923
  goalsRedraw = artRedraw = wsnRedraw = capRedraw = () => { if (body.isConnected && body.querySelector('.pw')) redraw(); };
920
924
  body.__pwcur = cur; body.__pwredraw = redraw; // ⋯ acts on the popup drawn now (capItems)
921
925
  wireGrip(body);
926
+ STMAP.wire(body, { redraw: () => { if (body.querySelector('.pw')) redraw(); } }); // the story map's presses and drag (A419)
922
927
  // the People block's presses (stakeholder-map), before the popup's own handler below
923
928
  body.addEventListener('click', (e) => { SMAP.press(e, body, { say: (t) => { const hh = body.__pwh; if (hh && hh.toast) hh.toast(t); } }); });
924
929
  // a phone: a proposal swiped right says yes, left says no (its own hidden Yes and No presses, so the popup's writes and Undo stay theirs)
@@ -1561,31 +1566,8 @@ function wireMoves(body, cur, redraw) {
1561
1566
  body.addEventListener('pointerup', stopHold, { passive: true });
1562
1567
  body.addEventListener('pointercancel', stopHold, { passive: true });
1563
1568
  body.addEventListener('contextmenu', (e) => { if (body.__pwQuiet && Date.now() - body.__pwQuiet < 700 && e.target.closest && e.target.closest('[data-pw-row]')) e.preventDefault(); });
1564
- // the Gantt: a task's bar (or a parent's) dragged by a mouse moves by whole days; a picked row's bar moves every picked row
1565
- body.addEventListener('pointerdown', (e) => {
1566
- if (e.pointerType !== 'mouse' || e.button !== 0) return;
1567
- const bar = e.target.closest && e.target.closest('.pw-kr .pw-tl .iva-tb, .pw-kr .pw-tl .pw-pbar'); if (!bar) return;
1568
- const rw = bar.closest('[data-pw-row]'), tl = bar.closest('.pw-tlin') || bar.closest('.pw-tl'), c = cur(); if (!rw || !tl || !c) return;
1569
- const all = allOf(c), ids = SEL.shiftIds(c.S.sel, rw.dataset.pwRow, all);
1570
- const span = (Date.parse(c.W.span.b) - Date.parse(c.W.span.a)) / 864e5, w = tl.getBoundingClientRect().width, x0 = e.clientX;
1571
- const els = [...new Set(ids.concat(String(rw.dataset.pwRow)))].map((u) => body.querySelector(`.pw-kr[data-pw-row="${window.CSS.escape(u)}"] .pw-tl`)).filter(Boolean)
1572
- .flatMap((t2) => [...t2.querySelectorAll('.iva-tb, .pw-pbar, .iva-md')]);
1573
- let dx = 0;
1574
- e.preventDefault(); try { bar.setPointerCapture(e.pointerId); } catch { /* fine */ }
1575
- document.body.classList.add('pw-drag');
1576
- const mv = (ev) => { dx = ev.clientX - x0; const n = SEL.daysOf(dx, w, span), px = (n / Math.max(1, span)) * w; for (const el of els) el.style.transform = `translateX(${px.toFixed(1)}px)`; };
1577
- const up = async () => {
1578
- bar.removeEventListener('pointermove', mv); bar.removeEventListener('pointerup', up); bar.removeEventListener('pointercancel', up);
1579
- document.body.classList.remove('pw-drag');
1580
- const n = SEL.daysOf(dx, w, span);
1581
- if (Math.abs(dx) > 3) body.__pwQuiet = Date.now();
1582
- if (!n) { for (const el of els) el.style.transform = ''; return; }
1583
- const h = body.__pwh; if (!h) return;
1584
- moveLog('bar-shift', ids.length);
1585
- await runBulk(ids, 'shift', n, c, h, body.__pwx); // a Jira ticket with no dates in PMOS is skipped, with the reason
1586
- };
1587
- bar.addEventListener('pointermove', mv); bar.addEventListener('pointerup', up); bar.addEventListener('pointercancel', up);
1588
- });
1569
+ // the Gantt: a bar dragged to change its dates, by the middle, an end, a pen, a finger or the keys (pm/work-drag.js, timeline-bar-drag)
1570
+ WD.wireBarDrag(body, { cur, allOf, runBulk, moveLog, ro: () => RO });
1589
1571
  }
1590
1572
  /** The epic check's ✦ fix (WorkJiraDS): every flagged ticket goes under the initiative's epic; Undo withdraws what Jira has not done yet. */
1591
1573
  async function epicFix(c, h, x) {
@@ -6,7 +6,7 @@
6
6
  background: var(--cz-card); box-shadow: 0 40px 100px -30px rgba(20, 24, 32, .6), 0 0 0 1px var(--cz-hair); }
7
7
  .cz-pop-card:focus { outline: none; }
8
8
  /* the left side: the page's Viewer, lifted in (cozy-viewer.js popInst) */
9
- .cz-pop-l { flex: 1 1 auto; min-width: 480px; display: flex; min-height: 0; }
9
+ .cz-pop-l { flex: 1 1 auto; min-width: 640px; display: flex; min-height: 0; }
10
10
  .cz-pop .cz-vw.cz-vw-pop { position: static !important; flex: 1 1 auto !important; width: auto !important; max-width: none !important; height: auto !important;
11
11
  margin: 0 !important; transform: none !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; }
12
12
  .cz-pop .cz-vw.cz-vw-pop > .cz-vw-grip { display: none; }
@@ -4,7 +4,7 @@
4
4
  * One way to open work: a popup that covers almost the whole page, with a thin dimmed edge of the page around it. The thing is on the left, in
5
5
  * the page's own Viewer (cozy-viewer.js lifts #czViewer into the popup, so every page's selectors still find it). Ask PMOS is on the right,
6
6
  * already about that thing. Esc, × or a press on the edge closes it. The phone keeps today's layout (cozy-viewer.js never pops on a phone).
7
- * The grip between the two sides resizes them: each side keeps a smallest width (the work 480 px, the chat 320 px), and PMOS remembers the
7
+ * The grip between the two sides resizes them: each side keeps a smallest width (the work 640 px, the chat 320 px; pop-split.js), and PMOS remembers the
8
8
  * chat's width (localStorage 'cz-pop-chat'). Double-click or Home resets it; ← and → move it 24 px. The chat's top bar hides the chat, and the
9
9
  * work takes the full width; "Ask PMOS" at the top right brings it back.
10
10
  * Ask PMOS is hidden by default (popup round 3 point 11): the thing takes the whole popup. The chat shows by itself only when it was open on
@@ -28,6 +28,8 @@
28
28
  * openChat() the chat icon. openCos(target) the chief-of-staff chat (search's "Ask PMOS: …"). chatTo(target) changes the chat.
29
29
  * Reads GET /api/sessions while it shows (every 6 s). Writes only on a press: End (after its Undo moment). The look is cozy-popup.css. */
30
30
  import * as VW from './cozy-viewer.js';
31
+ import { MIN_WORK, MIN_CHAT, DEF_CHAT, chatWidth, remembered } from './pop-split.js';
32
+ import { noteUse as noteSplit } from './use-log.js'; // tb-chat-split-handle (job 2019): the work keeps 640 px, the chat 320 px
31
33
  import { pmGet, pmPost } from './http.js';
32
34
  import { sessionRows, pickSession, recent, nextKey } from './pop-sessions.js';
33
35
 
@@ -40,7 +42,7 @@ const I = {
40
42
  side: 'M3.5 5h17v14h-17zM12 5v14', more: 'M5 12h.01M12 12h.01M19 12h.01', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4',
41
43
  };
42
44
  const CLAUDE = { key: 'claude', name: 'PMOS', initial: 'P' };
43
- const MIN_WORK = 480, MIN_CHAT = 320, DEF_CHAT = 460, DAY_MS = 864e5, POLL = 6000, UNDO = 6000, CHOOSER = 5;
45
+ const DAY_MS = 864e5, POLL = 6000, UNDO = 6000, CHOOSER = 5;
44
46
  const store = {
45
47
  get(k) { try { return localStorage.getItem(k); } catch { return null; } },
46
48
  set(k, v) { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, String(v)); } catch { /* a private window */ } },
@@ -108,7 +110,7 @@ function frame() {
108
110
  function width(px) {
109
111
  if (!S.card) return;
110
112
  const room = innerWidth - 40; // the card's inset is 20 px a side (cozy-popup.css), so its width is known before its sheet has loaded
111
- const w = Math.max(MIN_CHAT, Math.min(Math.round(px || DEF_CHAT), room - MIN_WORK - 1));
113
+ const w = chatWidth(px, room);
112
114
  S.w = w; S.card.style.setProperty('--pop-chat', w + 'px');
113
115
  const g = S.el.querySelector('.cz-pop-grip'); g.setAttribute('aria-valuenow', String(w)); g.setAttribute('aria-valuemin', String(MIN_CHAT)); g.setAttribute('aria-valuemax', String(Math.max(MIN_CHAT, room - MIN_WORK - 1)));
114
116
  }
@@ -118,7 +120,7 @@ function grip(g) {
118
120
  e.preventDefault(); g.setPointerCapture(e.pointerId); document.body.classList.add('cz-pop-drag');
119
121
  const right = S.card.getBoundingClientRect().right;
120
122
  const mv = (ev) => width(right - ev.clientX);
121
- const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-pop-drag'); store.set('cz-pop-chat', S.w); };
123
+ const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-pop-drag'); store.set('cz-pop-chat', S.w); noteSplit('popSplit'); console.info('[pop-split] chat ' + S.w + ' px'); };
122
124
  g.addEventListener('pointermove', mv); g.addEventListener('pointerup', up); g.addEventListener('pointercancel', up);
123
125
  });
124
126
  g.addEventListener('dblclick', () => { store.set('cz-pop-chat', null); width(DEF_CHAT); });
@@ -185,7 +187,7 @@ function show(pop) {
185
187
  const p = pop && typeof pop === 'object' ? pop : {};
186
188
  S.about = p.session ? (p.session.ini ? { id: p.session.ini, kind: 'initiative', title: p.session.work, ws: p.session.ws } : null) : p.id ? { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws, ...(p.path ? { path: p.path } : {}) } : null;
187
189
  S.base = S.about; S.views = new Map(); S.bind = S.base;
188
- width(parseInt(store.get('cz-pop-chat') || '', 10) || DEF_CHAT);
190
+ width(remembered(store.get('cz-pop-chat')));
189
191
  // the chat shows when it was asked for (the rail's chat icon, a session row, search's Ask PMOS), else when it was recently open on this item
190
192
  S.userSet = false;
191
193
  chatOn(!!(p.session || p.target || p.chat || !S.about || recentOn(S.about)));
@@ -0,0 +1,17 @@
1
+ /* pm/pop-split.js — how the popup shares its width between the work and the chat (job #2019, tb-chat-split-handle; board TbChatOpen on
2
+ * Exploring 3, page balanced: "can resize to the comfortable width for both chat and the panel on the left").
3
+ *
4
+ * The grip between the two sides (cozy-popup.js) moves the split. The work keeps at least 640 px and the chat at least 320 px. PMOS remembers
5
+ * the chat's width on this computer (localStorage 'cz-pop-chat'); a double-click or Home resets it to 460 px.
6
+ * chatWidth(px, room) PURE → the chat's width for a wanted px in a popup room px wide (the room less the work's least width, never under
7
+ * the chat's least width: when the window is too narrow for both, the chat keeps its 320 px).
8
+ * remembered(v) PURE → the stored width as a number, or the default when nothing usable is stored. */
9
+ export const MIN_WORK = 640, MIN_CHAT = 320, DEF_CHAT = 460;
10
+ export function chatWidth(px, room) {
11
+ const want = Math.round(Number(px) || DEF_CHAT), most = Math.round(Number(room) || 0) - MIN_WORK - 1;
12
+ return Math.max(MIN_CHAT, Math.min(want, most));
13
+ }
14
+ export function remembered(v) {
15
+ const n = parseInt(String(v == null ? '' : v), 10);
16
+ return n > 0 ? n : DEF_CHAT;
17
+ }
@@ -39,6 +39,8 @@ export const VIEW_CONTROLS = [
39
39
  // Choose columns (the copy's filter and sort), the timeline switch in it, the Next milestones line's +N marks
40
40
  '[data-wkopen]', '[data-wknav]', '[data-wkmenu]', '.wk-menu [data-wktlsw]', '[data-wkdl="on"]', '[data-wkdl="back"]', '[data-wkdl="fit"]',
41
41
  '#bdFind', '#roFind', '#bdFilter', '.wk-menu [data-wkf]', '.wk-menu [data-wkmore]', '.wk-menu [data-wksortp]', '.wk-menu [data-wksortx]', '.wk-menu [data-wkreset]',
42
+ // Print or PDF on Work's list (print-pdf, A379): it prints what the reader already sees and writes nothing
43
+ '[data-wkprint]',
42
44
  // the popup of a row, read only (Part A 4): its close and its edge, Details, a stage's fold, the done and far folds
43
45
  // its path and ← back to the page it came from (the design-system popup, #1432: "Work ›" and "Back to Work") only navigate
44
46
  '.cz-pop [data-pop="close"]', '.cz-pop [data-cz-vw-path]', '.cz-pop [data-cz-vw="back"]', '.pw [data-pw-details]', '.pw [data-pw-fold]', '.pw [data-pw-more]', '.pw [data-pw-grip]', '.pw [data-pw-done]', '.pw [data-pw-far]', '.pw [data-pw-tl]', '.pw [data-pw-span]', '.hi-pop [data-sp]',
@@ -0,0 +1,22 @@
1
+ /* pm/story-map.css — the story map block on the initiative popup (initiative story-map, idea A419; board BatchPlanDS panel 5). It only
2
+ * places the parts; the tokens are the design system's. */
3
+ .stm-head { gap: 8px; align-items: baseline; }
4
+ .stm-head .pm-h-sm { margin: 0; flex: 1; }
5
+ .stm-acts { display: inline-flex; gap: 6px; }
6
+ .stm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
7
+ .stm-step { background: var(--ink); color: var(--card); border-radius: var(--radius-sm); padding: 5px 8px; font-size: var(--fs-label); font-weight: var(--fw-strong); }
8
+ .stm-cell { display: flex; flex-direction: column; gap: 6px; min-height: 30px; border-radius: var(--radius-sm); }
9
+ .stm-cell.on { box-shadow: var(--glow); }
10
+ .stm-card { all: unset; box-sizing: border-box; display: block; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--raise); padding: 6px 8px; font-size: var(--fs-meta); line-height: 16px; color: var(--ink); }
11
+ button.stm-card { cursor: grab; }
12
+ button.stm-card:focus-visible { box-shadow: var(--glow); }
13
+ .stm-card.later { background: var(--well); }
14
+ .stm-line { grid-column: 1 / -1; border-top: 2px dashed var(--blue); font-size: var(--fs-badge); color: var(--blue); padding-top: 2px; }
15
+ .stm-draft { margin-top: 4px; }
16
+ .stm-grid.stm-n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
17
+ .stm-grid.stm-n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
18
+ .stm-grid.stm-n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
19
+ .stm-grid.stm-n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
20
+ .stm-grid.stm-n6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
21
+ .stm-grid.stm-n7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
22
+ .stm-grid.stm-n8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }