create-pmos 0.832.0 → 0.834.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 (44) hide show
  1. package/package.json +105 -66
  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/changelog.json +104 -27
  7. package/workspace/guide/backlog.md +1 -0
  8. package/workspace/guide/breakdown.md +11 -0
  9. package/workspace/guide/cli.md +11 -0
  10. package/workspace/guide/initiatives-and-next-steps.md +2 -0
  11. package/workspace/guide/layout.md +2 -0
  12. package/workspace/guide/positioning.md +1 -1
  13. package/workspace/lib/features.json +2 -1
  14. package/workspace/lib/line.js +7 -1
  15. package/workspace/lib/pmos-verbs.js +3 -0
  16. package/workspace/lib/route-modules.js +1 -0
  17. package/workspace/lib/routes-story-map.js +62 -0
  18. package/workspace/lib/routes-strategy-card.js +6 -2
  19. package/workspace/lib/story-map-cli.js +108 -0
  20. package/workspace/lib/story-map.js +172 -0
  21. package/workspace/lib/work-kr.js +77 -0
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/public/pm/bd-backlog.css +11 -0
  25. package/workspace/public/pm/bd-ini-panel.js +15 -5
  26. package/workspace/public/pm/bd-positioning.js +6 -4
  27. package/workspace/public/pm/bd-prog-panel.js +16 -5
  28. package/workspace/public/pm/bd-strategy.js +15 -3
  29. package/workspace/public/pm/cozy-pop-work.js +8 -26
  30. package/workspace/public/pm/line-view.js +13 -1
  31. package/workspace/public/pm/ms-strip.js +137 -0
  32. package/workspace/public/pm/page-chat.css +19 -0
  33. package/workspace/public/pm/page-chat.js +2 -0
  34. package/workspace/public/pm/side-fold.js +94 -0
  35. package/workspace/public/pm/story-map.css +22 -0
  36. package/workspace/public/pm/story-map.js +180 -0
  37. package/workspace/public/pm/work-drag.css +14 -0
  38. package/workspace/public/pm/work-drag.js +133 -0
  39. package/workspace/public/pm/work-tree.js +61 -0
  40. package/workspace/test-lists/ms-strip.json +9 -0
  41. package/workspace/test-lists/side-fold.json +9 -0
  42. package/workspace/test-lists/story-map.json +9 -0
  43. package/workspace/test-lists/timeline-bar-drag.json +9 -0
  44. package/workspace/test-lists/work-kr.json +9 -0
@@ -0,0 +1,180 @@
1
+ /* pm/story-map.js — a new bet's story map with the Release 1 line, on the initiative popup on a computer (initiative story-map, idea A419;
2
+ * board BatchPlanDS panel 5). pm/cozy-pop-work.js draws blockHtml() in the popup's main column and calls wire() once per body.
3
+ *
4
+ * PURE
5
+ * showsSuggest(st, taskCount) → true when the ✦ line shows: the map was read, there is none, and the initiative has fewer than 3 tasks
6
+ * parseDraft(text) → the same parse as lib/story-map.js (a preview of PMOS's draft before ✓)
7
+ * releaseOf(map) → the Release 1 tasks
8
+ * mapHtml(map, { live }) → the grid: the steps as dark heads left to right, Release 1's tasks, the dashed line, the later tasks
9
+ * blockHtml({ id, ws, title, tasks }) → the block (pm-block), '' when there is nothing to show (zero is silence); reads the map once
10
+ * READS GET /api/story-map once per initiative (again after a chat turn).
11
+ * WRITES, each on a press: ✦ starts PMOS's read-only draft (pm/star-draft.js run); ✓ on the draft POST /api/story-map/set (Undo /put);
12
+ * a task pressed or dragged across the line POST /move (Undo moves it back); ✓ Keep POST /keep (Undo /unkeep); ✕ POST /put null (Undo /put).
13
+ * The words say PMOS, never Claude; every button is an icon with an aria-label. Nothing is sent and Jira is not written. */
14
+ import * as SD from './star-draft.js';
15
+ import { pmGet, pmPost } from './http.js';
16
+ import { undoToast } from './hi-pop.js';
17
+
18
+ const CSS = new URL('./story-map.css', import.meta.url).href;
19
+ if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
20
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
21
+ }
22
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
23
+ const SVG = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
24
+ const I = { ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18', star: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', again: 'M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8M3 3v5h5' };
25
+ const btn = (attr, icon, label, cls = '') => `<button type="button" class="pm-btn${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon)}</button>`;
26
+ export const NEW_BET = 3;
27
+
28
+ /* state per initiative: undefined not read · null reading · { map, ask, draft } read. draft: { phase: 'pending' | 'ready' | 'failed', text, why } */
29
+ const ST = new Map();
30
+ let redrawAll = null;
31
+ if (typeof document !== 'undefined' && document.addEventListener) document.addEventListener('cz:chat-turn', () => { for (const [k, v] of ST) if (v && !v.draft) ST.delete(k); if (redrawAll) redrawAll(); });
32
+
33
+ /** PURE: the same parse as lib/story-map.js parseDraft (kept in step by story-map.test.js S1). */
34
+ export function parseDraft(text) {
35
+ const lines = String(text == null ? '' : text).replace(/\r\n?/g, '\n').replace(/```[a-z]*\n?/gi, '').split('\n');
36
+ const steps = []; let n = 0;
37
+ for (const raw of lines) {
38
+ const l = raw.replace(/^\s*(?:[-*•]|\d+[.)])\s*/, '').replace(/\*\*/g, '').trim();
39
+ const m = /^([^:]{1,60}):\s*(.+)$/.exec(l);
40
+ if (!m) continue;
41
+ const name = m[1].replace(/\s+/g, ' ').trim().slice(0, 40);
42
+ const cut = /\s+\/\s+|\s*\|\s*|^\/\s*|\s*\/$/.exec(m[2]);
43
+ const now = cut ? m[2].slice(0, cut.index) : m[2], later = cut ? m[2].slice(cut.index + cut[0].length) : '';
44
+ const tasks = [];
45
+ for (const [part, rel] of [[now, 1], [later, 2]]) for (const t of part.split(/\s*;\s*/)) { const title = t.replace(/[.]+$/, '').replace(/\s+/g, ' ').trim().slice(0, 120); if (title && tasks.length < 10) tasks.push({ id: 't' + (++n), title, rel }); }
46
+ if (!name || !tasks.length) continue;
47
+ steps.push({ name, tasks });
48
+ if (steps.length >= 8) break;
49
+ }
50
+ if (steps.length < 2 || !steps.some((s) => s.tasks.some((t) => t.rel === 1))) return null;
51
+ return { steps };
52
+ }
53
+ export const releaseOf = (map) => ((map && map.steps) || []).flatMap((s) => s.tasks.filter((t) => t.rel === 1).map((t) => ({ ...t, step: s.name })));
54
+ export const showsSuggest = (st, taskCount) => !!st && !st.map && (Number(taskCount) || 0) < NEW_BET;
55
+
56
+ /** PURE: the grid. live: the cards move (a press or a drag); a kept map or a draft preview does not. */
57
+ export function mapHtml(map, { live = false } = {}) {
58
+ const steps = (map && map.steps) || [];
59
+ if (!steps.length) return '';
60
+ const card = (t) => live
61
+ ? `<button type="button" class="stm-card${t.rel === 1 ? '' : ' later'}" draggable="true" data-stm-task="${esc(t.id)}" aria-label="${esc(t.title + (t.rel === 1 ? ': move below the line' : ': move into Release 1'))}">${esc(t.title)}</button>`
62
+ : `<span class="stm-card${t.rel === 1 ? '' : ' later'}">${esc(t.title)}</span>`;
63
+ const cell = (s, side) => `<div class="stm-cell" data-stm-side="${side}" role="group" aria-label="${esc(s.name + (side === 'above' ? ', Release 1' : ', later'))}">${s.tasks.filter((t) => (t.rel === 1) === (side === 'above')).map(card).join('')}</div>`;
64
+ const n = releaseOf(map).length;
65
+ return `<div class="stm-grid stm-n${steps.length}">${steps.map((s) => `<div class="stm-step">${esc(s.name)}</div>`).join('')}`
66
+ + steps.map((s) => cell(s, 'above')).join('')
67
+ + `<div class="stm-line" role="separator">Release 1 · thinnest end to end · ${n} ${n === 1 ? 'task' : 'tasks'}</div>`
68
+ + steps.map((s) => cell(s, 'below')).join('') + '</div>';
69
+ }
70
+
71
+ function read(id, ws, title, tasks) {
72
+ if (!id || ST.has(id)) return;
73
+ ST.set(id, null);
74
+ pmGet('/api/story-map?ini=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) : '') + (title ? '&title=' + encodeURIComponent(title) : ''))
75
+ .then((x) => { const st = x && x.ok ? { map: x.map || null, ask: x.ask || '', ws: x.ws || ws } : false; ST.set(id, st);
76
+ // Draw again only when the block now shows: a redraw for nothing would rebuild the popup under an open menu.
77
+ if (redrawAll && st && (st.map || showsSuggest(st, tasks))) redrawAll(); })
78
+ .catch(() => ST.set(id, false));
79
+ }
80
+
81
+ /** The block, '' when nothing shows (zero is silence): an initiative with a map, or a new bet with none. */
82
+ export function blockHtml({ id, ws, title, tasks } = {}) {
83
+ read(id, ws, title, tasks);
84
+ const st = ST.get(id);
85
+ if (!st) return '';
86
+ const head = (extra = '') => `<div class="pm-row stm-head"><h2 class="pm-h-sm">Story map</h2>${extra}</div>`;
87
+ const wrap = (inner) => `<section class="pm-block pwd-blk stm-blk" aria-label="Story map" data-stm-block="${esc(id)}">${inner}</section>`;
88
+ if (st.map) {
89
+ const m = st.map, k = m.kept;
90
+ const meta = `<span class="pm-meta">${k ? 'Kept as ' + k.tasks.length + ' tasks' : m.by === 'pm' ? '' : '✦ drafted by PMOS'}</span>`;
91
+ const acts = k ? '' : `<span class="stm-acts">${btn('data-stm-keep', I.ok, 'Keep the map: its tasks become the task breakdown, Release 1 first', 'primary')}${btn('data-stm-drop', I.x, 'Delete this story map')}</span>`;
92
+ return wrap(head(meta + acts) + mapHtml(m, { live: !k }));
93
+ }
94
+ const d = st.draft;
95
+ if (d && d.phase === 'pending') return wrap(head() + SD.pendingHtml('the story map'));
96
+ if (d && d.phase === 'failed') return wrap(head() + `<p class="pm-state error" role="alert"><span>${esc(d.why)}</span>${btn('data-stm-again', I.again, 'Try again')}</p>`);
97
+ if (d && d.phase === 'ready') {
98
+ const prev = parseDraft(d.text);
99
+ return wrap(head() + `<div class="pm-sug stm-draft" role="group" aria-label="Draft of the story map"><span class="pm-star" aria-hidden="true">✦</span><span class="say">PMOS drafted this map from the goal and sources.</span>`
100
+ + `<span class="ans">${btn('data-stm-take', I.ok, 'Keep this draft', 'primary')}${btn('data-stm-skip', I.x, 'Not this one')}</span></div>` + mapHtml(prev));
101
+ }
102
+ if (!showsSuggest(st, tasks)) return '';
103
+ return wrap(head() + `<div class="pm-sug stm-sug" role="group" aria-label="PMOS suggests"><span class="pm-star" aria-hidden="true">✦</span>`
104
+ + `<span class="say">Map the user's journey for this bet, with the thinnest first release</span><span class="ans">${btn('data-stm-draft', I.star, 'Let PMOS draft the story map', 'primary')}</span></div>`);
105
+ }
106
+
107
+ async function post(p, body) { const r = await pmPost(p, body).catch(() => null); return r && r.ok !== false ? r : { ok: false, error: (r && r.error) || 'PMOS could not save it.' }; }
108
+
109
+ /** Once per popup body: the presses and the drag of the story map block. redraw() draws the popup again. */
110
+ export function wire(body, { redraw } = {}) {
111
+ if (!body || body.__sm) return;
112
+ body.__sm = true;
113
+ redrawAll = () => { if (body.isConnected && redraw) redraw(); };
114
+ const at = (el) => { const b = el && el.closest && el.closest('[data-stm-block]'); const id = b ? b.dataset.stmBlock : ''; return id ? { id, st: ST.get(id) } : null; };
115
+ const apply = (id, map) => { const st = ST.get(id) || {}; ST.set(id, { ...st, map, draft: null }); redrawAll(); };
116
+ const moveIt = async (id, st, task, side) => {
117
+ if (!st || !st.map || st.map.kept) return;
118
+ const r = await post('/api/story-map/move', { ws: st.ws, ini: id, task, side });
119
+ if (!r.ok) { undoToast(r.error, () => {}, 4000, 'OK'); return; }
120
+ apply(id, r.map);
121
+ undoToast(side === 'above' ? 'Moved into Release 1.' : 'Moved below the line.', async () => { const u = await post('/api/story-map/move', { ws: st.ws, ini: id, task, side: r.from }); if (u.ok) apply(id, u.map); });
122
+ };
123
+ const draft = async (id, st, again) => {
124
+ ST.set(id, { ...st, draft: { phase: 'pending' } }); redrawAll();
125
+ const r = await SD.run(st.ask, { ws: st.ws, pmPost, pmGet, again });
126
+ const ok = r.ok && parseDraft(r.text);
127
+ ST.set(id, { ...(ST.get(id) || st), draft: ok ? { phase: 'ready', text: r.text } : { phase: 'failed', why: r.ok ? 'The draft did not read as steps and tasks.' : r.why } });
128
+ redrawAll();
129
+ };
130
+ // one press handler on the document for the presses inside this body (the design system's rule: no click listener on an element)
131
+ const onPress = async (e) => {
132
+ if (!body.isConnected) { document.removeEventListener('click', onPress); return; }
133
+ if (!body.contains(e.target)) return;
134
+ const b = e.target.closest && e.target.closest('[data-stm-draft],[data-stm-again],[data-stm-take],[data-stm-skip],[data-stm-keep],[data-stm-drop],[data-stm-task]');
135
+ const c = b && at(b);
136
+ if (!c || !c.st) return;
137
+ e.preventDefault(); e.stopPropagation();
138
+ const { id, st } = c, d = b.dataset;
139
+ if ('stmDraft' in d || 'stmAgain' in d) { draft(id, st, 'stmAgain' in d); return; }
140
+ if ('stmSkip' in d) { ST.set(id, { ...st, draft: null }); redrawAll(); return; }
141
+ if ('stmTake' in d) {
142
+ const r = await post('/api/story-map/set', { ws: st.ws, ini: id, text: st.draft && st.draft.text, by: 'pmos' });
143
+ if (!r.ok) { undoToast(r.error, () => {}, 4000, 'OK'); return; }
144
+ apply(id, r.map);
145
+ undoToast('Story map kept as a draft.', async () => { const u = await post('/api/story-map/put', { ws: st.ws, ini: id, map: r.prev || null }); if (u.ok) apply(id, u.map); });
146
+ return;
147
+ }
148
+ if ('stmKeep' in d) {
149
+ const r = await post('/api/story-map/keep', { ws: st.ws, ini: id });
150
+ if (!r.ok) { undoToast(r.error, () => {}, 4000, 'OK'); return; }
151
+ apply(id, r.map);
152
+ document.dispatchEvent(new CustomEvent('cz:chat-turn')); // the breakdown reads its tasks again
153
+ undoToast(r.added.length + ' tasks added to the breakdown, Release 1 first.', async () => { const u = await post('/api/story-map/unkeep', { ws: st.ws, ini: id }); if (u.ok) { apply(id, u.map); document.dispatchEvent(new CustomEvent('cz:chat-turn')); } });
154
+ return;
155
+ }
156
+ if ('stmDrop' in d) {
157
+ const was = st.map;
158
+ const r = await post('/api/story-map/put', { ws: st.ws, ini: id, map: null });
159
+ if (!r.ok) { undoToast(r.error, () => {}, 4000, 'OK'); return; }
160
+ apply(id, null);
161
+ undoToast('Story map deleted.', async () => { const u = await post('/api/story-map/put', { ws: st.ws, ini: id, map: was }); if (u.ok) apply(id, u.map); });
162
+ return;
163
+ }
164
+ if ('stmTask' in d) { const side = b.closest('[data-stm-side]'); moveIt(id, st, d.stmTask, side && side.dataset.stmSide === 'above' ? 'below' : 'above'); }
165
+ };
166
+ document.addEventListener('click', onPress);
167
+ // drag a task above or below the line (a mouse); the press does the same on a touch screen and with a keyboard
168
+ body.addEventListener('dragstart', (e) => { const t = e.target.closest && e.target.closest('[data-stm-task]'); if (t && e.dataTransfer) { e.dataTransfer.setData('text/x-stm-task', t.dataset.stmTask); e.dataTransfer.effectAllowed = 'move'; } });
169
+ body.addEventListener('dragover', (e) => { const z = e.target.closest && e.target.closest('[data-stm-side]'); if (z && e.dataTransfer && [...(e.dataTransfer.types || [])].includes('text/x-stm-task')) { e.preventDefault(); z.classList.add('on'); } });
170
+ body.addEventListener('dragleave', (e) => { const z = e.target.closest && e.target.closest('[data-stm-side]'); if (z) z.classList.remove('on'); });
171
+ body.addEventListener('drop', (e) => {
172
+ const z = e.target.closest && e.target.closest('[data-stm-side]'), task = e.dataTransfer && e.dataTransfer.getData('text/x-stm-task');
173
+ if (!z || !task) return;
174
+ e.preventDefault(); z.classList.remove('on');
175
+ const c = at(z); if (!c || !c.st || !c.st.map) return;
176
+ const now = c.st.map.steps.flatMap((s) => s.tasks).find((t) => t.id === task);
177
+ const side = z.dataset.stmSide;
178
+ if (now && (now.rel === 1) !== (side === 'above')) moveIt(c.id, c.st, task, side);
179
+ });
180
+ }
@@ -0,0 +1,14 @@
1
+ /* pm/work-drag.css — the grips and the tip of a bar you drag to change its dates (pm/work-drag.js, initiative timeline-bar-drag) */
2
+ .wd-on { cursor: grab; touch-action: pan-y; }
3
+ .wd-on:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
4
+ .wd-on.wd-live { cursor: grabbing; z-index: 2; }
5
+ .wd-g { position: absolute; top: 0; bottom: 0; width: var(--space-8); cursor: col-resize; opacity: 0; }
6
+ .wd-g::after { content: ''; position: absolute; top: 25%; bottom: 25%; left: 50%; width: 2px; margin-left: -1px; border-radius: var(--radius-pill); background: var(--cz-ink2); }
7
+ .wd-g.s { left: 0; }
8
+ .wd-g.e { right: 0; }
9
+ .wd-on:focus-visible .wd-g, .wd-on.wd-live .wd-g { opacity: 1; }
10
+ @media (hover: hover) { .wd-on:hover .wd-g { opacity: 1; } }
11
+ @media (hover: none) { .wd-g { opacity: 1; } }
12
+ .wd-mv { transform: translateX(var(--tl-dx, 0)); }
13
+ .wd-rs { left: var(--tl-l) !important; width: var(--tl-w) !important; }
14
+ .wd-tip { position: fixed; left: var(--tl-tipx, 0); top: var(--tl-tipy, 0); z-index: 1000; transform: translateX(-50%); padding: var(--space-4) var(--space-8); border-radius: var(--radius-sm); background: var(--cz-ink); color: var(--cz-card); font-size: var(--fs-meta); font-weight: var(--fw-strong); pointer-events: none; white-space: nowrap; }
@@ -0,0 +1,133 @@
1
+ /* pm/work-drag.js — drag a bar on the Gantt to change its dates (initiative timeline-bar-drag, board TbInitTimeline on Exploring 3, page
2
+ * balanced; job #2014). The Work popup's Gantt (pm/cozy-pop-work.js) calls wireBarDrag(body, deps) once.
3
+ *
4
+ * What it does, on every task bar PMOS may change (pm/work-tree.js canDrag):
5
+ * - marks it: "Drag to change dates" in its label and title, a grip at each end, a place in the Tab order (zero is silence: a bar PMOS
6
+ * may not change, a stage, and a read-only copy get nothing);
7
+ * - the middle moves the whole task by whole days, with every picked row, through the old shift (one Undo);
8
+ * - an end changes that date only, and a milestone's ◇ moves its one date, through the host's dates() writer: the same as the date
9
+ * picker, whose toast says "Dates saved" with Undo;
10
+ * - a tip shows the new dates while dragging; a mouse starts after 3 px, a pen or a finger after 6 px sideways (a smaller move stays a tap);
11
+ * - on a focused bar, ← → move the task a day, Shift moves the due day, Alt the start.
12
+ * Nothing is sent to anyone and nothing is written to Jira: a Jira ticket's dates are PMOS only, as the date picker says.
13
+ *
14
+ * wireBarDrag(body, { cur, allOf, runBulk, moveLog, ro }) cur() → the popup's current { W, S }; allOf(c) → its rows in order;
15
+ * runBulk(ids, 'shift', days, c, h, x); moveLog(how, n); ro() → read-only
16
+ * decorate(root, rowOf, ro) marks the bars under root (exported for the test) */
17
+ import * as WT from './work-tree.js';
18
+ import * as SEL from './work-select.js';
19
+ import { noteUse } from './use-log.js';
20
+
21
+ const BAR = '.pw-kr .pw-tl .iva-tb, .pw-kr .pw-tl .iva-md, .pw-kr .pw-tl .pw-pbar';
22
+ const HINT = 'Drag to change dates';
23
+
24
+ if (typeof document !== 'undefined' && document.head && !document.querySelector('link[data-wd-css]')) {
25
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./work-drag.css', import.meta.url).href; l.dataset.wdCss = '1';
26
+ document.head.appendChild(l);
27
+ }
28
+
29
+ const uidOf = (bar) => { const rw = bar && bar.closest && bar.closest('[data-pw-row]'); return rw ? String(rw.dataset.pwRow) : ''; };
30
+
31
+ /** Mark every bar under root that PMOS may change. rowOf(uid) → the row; ro: a read-only copy. Returns how many bars it marked. */
32
+ export function decorate(root, rowOf, ro = false) {
33
+ if (!root || !root.querySelectorAll) return 0;
34
+ let n = 0;
35
+ for (const bar of root.querySelectorAll(BAR)) {
36
+ if (bar.dataset.wd) continue;
37
+ const row = rowOf(uidOf(bar));
38
+ if (bar.classList.contains('pw-pbar')) { bar.dataset.wd = 'par'; continue; } // a parent keeps its whole-bar move, with no grips
39
+ if (!WT.canDrag(row, ro)) { bar.dataset.wd = 'no'; continue; }
40
+ bar.dataset.wd = row.ms ? 'ms' : 'on';
41
+ bar.classList.add('wd-on');
42
+ const words = (row.title ? row.title + ': ' : '') + WT.dragTip(row, 'move', 0) + '. ' + HINT;
43
+ bar.setAttribute('aria-label', words);
44
+ bar.setAttribute('title', HINT);
45
+ if (bar.tagName !== 'BUTTON') { bar.setAttribute('tabindex', '0'); bar.setAttribute('role', 'button'); }
46
+ if (!row.ms) bar.insertAdjacentHTML('beforeend', '<b class="wd-g s" aria-hidden="true"></b><b class="wd-g e" aria-hidden="true"></b>');
47
+ n++;
48
+ }
49
+ return n;
50
+ }
51
+
52
+ function tipAt(text, x, y) {
53
+ let t = document.querySelector('.wd-tip');
54
+ if (!t) { t = document.createElement('div'); t.className = 'wd-tip'; t.setAttribute('role', 'status'); document.body.appendChild(t); }
55
+ t.textContent = text; t.style.setProperty('--tl-tipx', Math.round(x) + 'px'); t.style.setProperty('--tl-tipy', Math.round(y - 36) + 'px');
56
+ }
57
+ const tipOff = () => { const t = document.querySelector('.wd-tip'); if (t) t.remove(); };
58
+ /* after a drag the press is not a click: the ◇'s card and the row's open stay shut */
59
+ const eatClick = () => { const f = (e) => { e.stopPropagation(); e.preventDefault(); }; window.addEventListener('click', f, { capture: true, once: true }); setTimeout(() => window.removeEventListener('click', f, { capture: true }), 400); };
60
+
61
+ export function wireBarDrag(body, d) {
62
+ if (!body || body.__wdWired) return; body.__wdWired = true;
63
+ const ro = () => !!(d.ro && d.ro());
64
+ const rowOf = (uid) => { const c = d.cur(); return c && c.W ? c.W.rows.find((r) => String(r.uid) === String(uid)) : null; };
65
+ const mark = () => decorate(body, rowOf, ro());
66
+ mark();
67
+ if (typeof MutationObserver !== 'undefined') new MutationObserver(mark).observe(body, { childList: true, subtree: true });
68
+
69
+ const save = async (kind, n, uid, ids, c) => {
70
+ const h = body.__pwh; if (!h || !n) return;
71
+ const row = rowOf(uid); if (!row && kind !== 'par') return;
72
+ try { noteUse('barDrag'); } catch { /* the use log is a convenience */ }
73
+ try { console.info('[bar-drag]', kind, n, uid); } catch { /* no console */ }
74
+ if (kind === 'move' && !(row && row.ms) || kind === 'par') { d.moveLog('bar-shift', ids.length); await d.runBulk(ids, 'shift', n, c, h, body.__pwx); return; }
75
+ const patch = WT.dragPatch(row, kind, n); if (!patch) return;
76
+ d.moveLog('bar-' + (row.ms ? 'ms' : kind), 1);
77
+ if (h.dates) await h.dates(uid, patch);
78
+ };
79
+
80
+ // the listeners sit on the document (a drag can leave the popup), and answer only for a bar inside this popup
81
+ document.addEventListener('pointerdown', (e) => {
82
+ if (e.button !== 0 || ro() || !body.isConnected || !body.contains(e.target)) return;
83
+ const bar = e.target.closest && e.target.closest(BAR); if (!bar || !bar.dataset.wd || bar.dataset.wd === 'no') return;
84
+ const uid = uidOf(bar), tl = bar.closest('.pw-tlin') || bar.closest('.pw-tl'), c = d.cur(); if (!uid || !tl || !c) return;
85
+ const row = rowOf(uid), par = bar.dataset.wd === 'par';
86
+ const r0 = bar.getBoundingClientRect(), pr = tl.getBoundingClientRect(), w = Math.max(1, pr.width);
87
+ const kind = par ? 'par' : row && row.ms ? 'move' : WT.dragKind(e.clientX, r0.left, r0.width);
88
+ const span = (Date.parse(c.W.span.b) - Date.parse(c.W.span.a)) / 864e5, dayPx = w / Math.max(1, span);
89
+ // the middle moves every picked row with it (shift-click picks); an end or a ◇ changes this one row
90
+ const ids = kind === 'move' || par ? [...new Set(SEL.shiftIds(c.S.sel, uid, d.allOf(c)).concat(uid))] : [uid];
91
+ const els = kind === 'move' || par ? ids.map((u) => body.querySelector(`.pw-kr[data-pw-row="${window.CSS.escape(u)}"] .pw-tl`)).filter(Boolean).flatMap((t2) => [...t2.querySelectorAll('.iva-tb, .pw-pbar, .iva-md')]) : [bar];
92
+ const x0 = e.clientX, y0 = e.clientY, pointer = e.pointerType || 'mouse';
93
+ let on = false, dx = 0;
94
+ const begin = () => { on = true; try { bar.setPointerCapture(e.pointerId); } catch { /* fine */ } document.body.classList.add('pw-drag'); bar.classList.add('wd-live'); };
95
+ if (pointer === 'mouse') { e.preventDefault(); begin(); }
96
+ const draw = (n) => {
97
+ const px = n * dayPx;
98
+ if (kind === 'move' || par) { for (const el of els) { el.classList.add('wd-mv'); el.style.setProperty('--tl-dx', px.toFixed(1) + 'px'); } return; }
99
+ const L = r0.left - pr.left, W0 = r0.width;
100
+ const l = kind === 'start' ? Math.min(L + px, L + W0 - dayPx) : L, wd = kind === 'start' ? W0 - (l - L) : Math.max(dayPx, W0 + px);
101
+ bar.classList.add('wd-rs'); bar.style.setProperty('--tl-l', l.toFixed(1) + 'px'); bar.style.setProperty('--tl-w', wd.toFixed(1) + 'px');
102
+ };
103
+ const mv = (ev) => {
104
+ dx = ev.clientX - x0;
105
+ if (!on) { if (!WT.dragStarts(dx, ev.clientY - y0, pointer)) return; begin(); }
106
+ ev.preventDefault();
107
+ const n = SEL.daysOf(dx, w, span);
108
+ draw(n);
109
+ if (row) tipAt(WT.dragTip(row, kind === 'par' ? 'move' : kind, n), ev.clientX, r0.top);
110
+ };
111
+ const up = async () => {
112
+ document.removeEventListener('pointermove', mv); document.removeEventListener('pointerup', up); document.removeEventListener('pointercancel', up);
113
+ tipOff();
114
+ if (!on) return; // a tap: the ◇'s card, the row's pick and the hold to pick work as before
115
+ document.body.classList.remove('pw-drag'); bar.classList.remove('wd-live');
116
+ const n = SEL.daysOf(dx, w, span);
117
+ if (Math.abs(dx) > 3) { body.__pwQuiet = Date.now(); eatClick(); }
118
+ if (!n) { for (const el of els) { el.classList.remove('wd-mv'); el.style.removeProperty('--tl-dx'); } bar.classList.remove('wd-rs'); return; }
119
+ await save(kind, n, uid, ids, c);
120
+ };
121
+ document.addEventListener('pointermove', mv); document.addEventListener('pointerup', up); document.addEventListener('pointercancel', up);
122
+ });
123
+
124
+ // the keys, on a focused bar: ← → a day; Shift the due day, Alt the start
125
+ body.addEventListener('keydown', (e) => {
126
+ const bar = e.target.closest && e.target.closest(BAR); if (!bar || ro() || (bar.dataset.wd !== 'on' && bar.dataset.wd !== 'ms')) return;
127
+ const st = WT.keyStep(e.key, e); if (!st) return;
128
+ e.preventDefault();
129
+ const uid = uidOf(bar), c = d.cur(); if (!uid || !c) return;
130
+ const row = rowOf(uid);
131
+ save(row && row.ms ? 'move' : st.kind, st.days, uid, [uid], c);
132
+ });
133
+ }
@@ -197,3 +197,64 @@ export function allJira(rows, uids) {
197
197
  const L = [...(uids || [])];
198
198
  return L.length > 0 && L.every((u) => { const x = by.get(String(u)); return !!(x && keyOf(x) && !x.jsub); });
199
199
  }
200
+
201
+ /* Drag a bar on the Gantt to change its dates (initiative timeline-bar-drag, board TbInitTimeline). Pure, like the rest of this file;
202
+ * pm/work-drag.js draws the grips and wires the pointer and the keys.
203
+ * canDrag(row, ro) → true when PMOS may change this bar's dates: a task (not a stage, not a Jira sub-task PMOS only read) with a
204
+ * date, outside a read-only copy
205
+ * dragKind(x, left, width, grip) → 'start' | 'due' | 'move' where a press at x lands on a bar from left to left + width; a grip is the
206
+ * outer `grip` px of each end (8), or a third of a bar too short for both
207
+ * dragPatch(row, kind, days) → { start?, due? } | null the dates after a drag of whole days; an end stops at the other end; a milestone
208
+ * has one date, written as due; 0 days is null (nothing to write)
209
+ * dragTip(row, kind, days) → "9 Nov to 18 Nov" the new dates in words, shown while dragging
210
+ * keyStep(key, mods) → { kind, days } | null ← → move the task a day; Shift moves the due day, Alt the start
211
+ * dragStarts(dx, dy, pointer) → true once a press has moved far enough sideways to be a drag (mouse 3 px, pen and touch 6 px) */
212
+ const DAY_MS = 864e5;
213
+ const isoDay = (v) => (v ? String(v).slice(0, 10) : '');
214
+ const dayNum = (v) => { const t = Date.parse(isoDay(v)); return Number.isFinite(t) ? Math.round(t / DAY_MS) : null; };
215
+ const dayIso = (n) => new Date(n * DAY_MS).toISOString().slice(0, 10);
216
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
217
+ const dayWords = (n) => { const d = new Date(n * DAY_MS); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
218
+
219
+ export function canDrag(row, ro = false) {
220
+ if (ro || !row || row.kind !== 'task' || row.kids || row.jsub) return false;
221
+ if (!editOf(row, ro).dates) return false;
222
+ return dayNum(row.start) != null || dayNum(row.end) != null;
223
+ }
224
+ export function dragKind(x, left, width, grip = 8) {
225
+ const w = Math.max(0, Number(width) || 0), at = (Number(x) || 0) - (Number(left) || 0), g = Math.min(grip, w / 3);
226
+ if (at <= g) return 'start';
227
+ if (at >= w - g) return 'due';
228
+ return 'move';
229
+ }
230
+ function span(row) {
231
+ const a = dayNum(row.start), b = dayNum(row.end);
232
+ return { a: a == null ? b : a, b: b == null ? a : Math.max(a, b), hasA: a != null, hasB: b != null };
233
+ }
234
+ export function dragPatch(row, kind, days) {
235
+ const n = Math.round(Number(days) || 0); if (!row || !n) return null;
236
+ const s = span(row); if (s.a == null) return null;
237
+ if (row.ms) return { due: dayIso(s.b + n) };
238
+ if (kind === 'start') { const a = Math.min(s.a + n, s.b); return a === s.a ? null : { start: dayIso(a) }; }
239
+ if (kind === 'due') { const b = Math.max(s.b + n, s.a); return b === s.b ? null : { due: dayIso(b) }; }
240
+ const out = {};
241
+ if (s.hasA) out.start = dayIso(s.a + n);
242
+ if (s.hasB) out.due = dayIso(s.b + n);
243
+ return out;
244
+ }
245
+ export function dragTip(row, kind, days) {
246
+ if (!row) return '';
247
+ const s = span(row); if (s.a == null) return '';
248
+ const p = dragPatch(row, kind, days) || {};
249
+ const a = p.start ? dayNum(p.start) : s.a, b = p.due ? dayNum(p.due) : s.b;
250
+ if (row.ms) return dayWords(b);
251
+ return a === b ? dayWords(b) : dayWords(a) + ' to ' + dayWords(b);
252
+ }
253
+ export function keyStep(key, mods = {}) {
254
+ const d = key === 'ArrowLeft' ? -1 : key === 'ArrowRight' ? 1 : 0; if (!d) return null;
255
+ return { kind: mods.shiftKey ? 'due' : mods.altKey ? 'start' : 'move', days: d };
256
+ }
257
+ export function dragStarts(dx, dy, pointer = 'mouse') {
258
+ const need = pointer === 'mouse' ? 3 : 6, x = Math.abs(Number(dx) || 0), y = Math.abs(Number(dy) || 0);
259
+ return x >= need && x > y;
260
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Next milestones on the product, program and initiative pages (job #2020, initiative milestone-strip-pages, done test S1, V1-V4, N1-N2): the strip's markup from pm/ms-strip.js over pm/bd-stands.js and its wiring in pm/bd-ini-panel.js and pm/bd-prog-panel.js. No browser, model or network.",
3
+ "modules": [
4
+ "ms-strip.test.js"
5
+ ],
6
+ "seconds": {
7
+ "ms-strip.test.js": 1
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "tb-chat-open-fold (job #2017): with the chat open, the side column folds into one-line rows (pm/side-fold.js, page-chat.css). No browser, no network.",
3
+ "modules": [
4
+ "side-fold.test.js"
5
+ ],
6
+ "seconds": {
7
+ "side-fold.test.js": 2
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "A new bet's story map with the Release 1 line (initiative story-map, done test S1-S7, N1-N4): the pure parse and move, the popup block, the routes and pmos story-map on one scratch server. No browser, model or network.",
3
+ "modules": [
4
+ "story-map.test.js"
5
+ ],
6
+ "seconds": {
7
+ "story-map.test.js": 25
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Drag task bars on the Gantt to change dates (initiative timeline-bar-drag, job #2014; done test D1-D9, N1-N3): the pure helpers of pm/work-tree.js, the bar marking of pm/work-drag.js over a stand-in, and the wiring read from the source. No server, browser, model or network.",
3
+ "modules": [
4
+ "timeline-bar-drag.test.js"
5
+ ],
6
+ "seconds": {
7
+ "timeline-bar-drag.test.js": 1
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Each initiative on Work names its key result; Strategy and Positioning name their OKR period (job tb-work-kr, board TbWork, done test planning/done-tests/tb-work-kr.md W1-W7, N1, N2): lib/work-kr.js, the Line table and the Strategy card drawn as strings, the strategy-card route on a scratch OKR file. No server, network or browser.",
3
+ "modules": [
4
+ "work-kr.test.js"
5
+ ],
6
+ "seconds": {
7
+ "work-kr.test.js": 2
8
+ }
9
+ }