create-pmos 0.625.0 → 0.626.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +8 -8
- package/workspace/guide/backlog.md +9 -0
- package/workspace/lib/routes-backlog.js +25 -2
- package/workspace/lib/sprint-overview.js +162 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog.css +44 -0
- package/workspace/public/pm/bd-backlog.js +21 -4
- package/workspace/public/pm/bd-sprint.js +180 -0
- package/workspace/public/pm/bk-sprint.js +268 -0
- package/workspace/public/pm/premium-board.js +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.626.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -34,21 +34,21 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-19T05:
|
|
37
|
+
"v": "0.626.0",
|
|
38
|
+
"at": "2026-11-19T05:42:19.332Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
|
-
{
|
|
42
|
-
"n": 1404,
|
|
43
|
-
"t": "A shared copy carries no task in no stage",
|
|
44
|
-
"s": "A shared copy carries no task in no stage",
|
|
45
|
-
"k": "fix"
|
|
46
|
-
},
|
|
47
41
|
{
|
|
48
42
|
"n": 1406,
|
|
49
43
|
"t": "One product-name rule for desk and shared copy; no raw report ids on Events",
|
|
50
44
|
"s": "One product-name rule for desk and shared copy; no raw report ids on Events",
|
|
51
45
|
"k": "fix"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1407,
|
|
49
|
+
"t": "Sprint overview on Work > Backlog > This sprint",
|
|
50
|
+
"s": "Sprint overview on Work > Backlog > This sprint",
|
|
51
|
+
"k": "new"
|
|
52
52
|
}
|
|
53
53
|
]
|
|
54
54
|
},
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-19T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-19T05:42:16Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-19T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-19T05:42:16Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-19T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-19T05:42:16Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-19T05:
|
|
3
|
+
"v": "0.626.0",
|
|
4
|
+
"at": "2026-11-19T05:42:19.332Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
|
-
{
|
|
8
|
-
"n": 1404,
|
|
9
|
-
"t": "A shared copy carries no task in no stage",
|
|
10
|
-
"s": "A shared copy carries no task in no stage",
|
|
11
|
-
"k": "fix"
|
|
12
|
-
},
|
|
13
7
|
{
|
|
14
8
|
"n": 1406,
|
|
15
9
|
"t": "One product-name rule for desk and shared copy; no raw report ids on Events",
|
|
16
10
|
"s": "One product-name rule for desk and shared copy; no raw report ids on Events",
|
|
17
11
|
"k": "fix"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1407,
|
|
15
|
+
"t": "Sprint overview on Work > Backlog > This sprint",
|
|
16
|
+
"s": "Sprint overview on Work > Backlog > This sprint",
|
|
17
|
+
"k": "new"
|
|
18
18
|
}
|
|
19
19
|
]
|
|
20
20
|
},
|
|
@@ -43,6 +43,15 @@ The quick filters at the top count each group alone. Group filters add to each o
|
|
|
43
43
|
|
|
44
44
|
Tick rows to give them to PMOS or to a person, move them to an initiative, set a date, or archive them. On a phone, a long press on a row shows the tick boxes.
|
|
45
45
|
|
|
46
|
+
## The sprint overview
|
|
47
|
+
|
|
48
|
+
Press **This sprint** to see the current sprint above the list:
|
|
49
|
+
|
|
50
|
+
- **The sprint.** The sprint name, how many of its tickets move (In progress or In review), how many are to do, and how many are in no initiative. The line under the name says when PMOS last read Jira. An amber dot shows that the read is old. Press the read-again button to read Jira again. PMOS does not store the sprint dates, owners or story points, so the overview does not show them.
|
|
51
|
+
- **Themes.** PMOS groups the tickets by what their titles are about. Jira does not store themes, so they have the ✦ mark. Press a theme to show only its tickets in the list. Press it again, or press **Show all**, to show all the tickets again.
|
|
52
|
+
- **Sprint goals, Doing now and Planned next.** PMOS writes them from the tickets, not from the goal in Jira. A short PMOS session reads only the ticket keys, titles and states. Until it answers, PMOS groups the tickets by shared words. The counts add up to the ticket counts. Press the pencil to change a block. PMOS does not write over your words. When its draft changes, it asks with ✓ (use the new draft) and ✕ (keep yours).
|
|
53
|
+
- **Proposals.** For example, put sub-tasks in the initiative of their parent ticket, or make an initiative for a theme. Nothing changes until you press ✓. Each ✓ and ✕ has Undo.
|
|
54
|
+
|
|
46
55
|
## What PMOS can take
|
|
47
56
|
|
|
48
57
|
What PMOS can take depends on the initiative's kind of work and on the task's own words. The line under the filters names the kind, for example "Most work here runs as Full SDLC (3 of 5 initiatives)". **Change** lists each initiative with its kind of work, and you can change each one there. This is the same setting as the one in the initiative's popup.
|
|
@@ -29,6 +29,7 @@ const BL = require('./backlog.js');
|
|
|
29
29
|
const dayRun = require('./day-run.js');
|
|
30
30
|
const assigned = require('./work-assigned.js');
|
|
31
31
|
const WK = require('./work-kind.js');
|
|
32
|
+
const SO = require('./sprint-overview.js');
|
|
32
33
|
|
|
33
34
|
const RUN_DAYS = 14;
|
|
34
35
|
const bad = (status, error, extra = {}) => ({ status, body: { ok: false, error, ...extra } });
|
|
@@ -109,7 +110,8 @@ function listOf(ctx, wsId, boardId, now) {
|
|
|
109
110
|
const mode = BL.modeOf(inis.map((x) => x.kind));
|
|
110
111
|
// the product's display name ("IDPF"), not its folder id ("pmos-idpf"): the board's own name first
|
|
111
112
|
const product = board.name || board.product || w.name || w.id;
|
|
112
|
-
|
|
113
|
+
let sprintNotes = {}; try { sprintNotes = SO.foldNotes(SO.readNotes(ctx), w.id, board.id); } catch { sprintNotes = {}; }
|
|
114
|
+
return { ok: true, ws: w.id, board: board.id, product, mode, sprintNotes, modeLabel: BL.MODE_LABEL[mode], kinds: BL.countKinds(inis.map((x) => x.kind)), factory, readAt, today,
|
|
113
115
|
tasks, inis: inis.map((x) => ({ id: x.id, title: x.title, kind: x.kind })), _w: w, _RB: RB, _runTasks: runTasks };
|
|
114
116
|
}
|
|
115
117
|
|
|
@@ -157,7 +159,7 @@ async function handle(req, res, url, ctx) {
|
|
|
157
159
|
try { settle(ctx, L); } catch { /* the next read tries again */ }
|
|
158
160
|
return send({ status: 200, body: strip(L) });
|
|
159
161
|
}
|
|
160
|
-
if (!['give', 'stop', 'decide', 'undo', 'decline', 'place'].includes(sub)) return send(bad(404, 'no such route'));
|
|
162
|
+
if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'sprint-draft', 'sprint-note'].includes(sub)) return send(bad(404, 'no such route'));
|
|
161
163
|
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
162
164
|
const read = await ctx.readJson(req);
|
|
163
165
|
if (!read.ok || !read.body || typeof read.body !== 'object') return send(bad(400, 'the body must be a JSON object'));
|
|
@@ -172,6 +174,27 @@ async function handle(req, res, url, ctx) {
|
|
|
172
174
|
const gives = BL.foldGives(readGives(ctx));
|
|
173
175
|
const giveOf = (id) => (gives.get(BL.keyOf(ws, board, id)) || { give: null, declined: null, n: 0 });
|
|
174
176
|
|
|
177
|
+
// the sprint overview (initiative sprint-overview): PMOS's written draft of one active sprint, and the PM's edits of it
|
|
178
|
+
if (sub === 'sprint-draft' || sub === 'sprint-note') {
|
|
179
|
+
const sprint = text(body.sprint).slice(0, 120);
|
|
180
|
+
const T = L.tasks.filter((t) => t.sprint && t.sprint.state === 'active' && t.sprint.name === sprint && t.key);
|
|
181
|
+
if (!sprint || !T.length) return send(bad(404, 'no active sprint of that name on this board'));
|
|
182
|
+
if (sub === 'sprint-draft') {
|
|
183
|
+
const tickets = T.map((t) => ({ key: t.key, title: t.title, state: t.state, parent: t.epic ? t.epic.name || t.epic.key : '' }));
|
|
184
|
+
const r = SO.draft(ctx, tickets, { again: body.again === true });
|
|
185
|
+
return send({ status: r.state === 'pending' ? 202 : 200, body: { ok: r.state !== 'failed', ...r } });
|
|
186
|
+
}
|
|
187
|
+
const ev = text(body.ev), block = text(body.block), id = text(body.id).slice(0, 200);
|
|
188
|
+
if (!['note', 'clear', 'keep', 'dismiss', 'undismiss'].includes(ev)) return send(bad(400, 'ev is note, clear, keep, dismiss or undismiss'));
|
|
189
|
+
if (['note', 'clear', 'keep'].includes(ev) && !SO.BLOCKS.includes(block)) return send(bad(400, 'block is goals, doing or next'));
|
|
190
|
+
if ((ev === 'dismiss' || ev === 'undismiss') && !id) return send(bad(400, 'id names the proposal'));
|
|
191
|
+
const words = typeof body.text === 'string' ? body.text.split('\n').map((x) => x.trim()).filter(Boolean).slice(0, 8).map((x) => x.slice(0, 200)).join('\n') : '';
|
|
192
|
+
if (ev === 'note' && !words) return send(bad(400, 'text is the block as you wrote it, one point a line'));
|
|
193
|
+
const was = (SO.foldNotes(SO.readNotes(ctx), ws, board)[sprint] || {})[block] || null;
|
|
194
|
+
SO.appendNote(ctx, { ev, ws, board, sprint, ...(block ? { block } : {}), ...(ev === 'note' ? { text: words } : {}), ...(ev === 'note' || ev === 'keep' ? { base: text(body.base).slice(0, 40) } : {}), ...(id ? { id } : {}), by: g.actor.by });
|
|
195
|
+
return send({ status: 200, body: { ok: true, was } });
|
|
196
|
+
}
|
|
197
|
+
|
|
175
198
|
if (sub === 'place') {
|
|
176
199
|
const key = text(body.key).toUpperCase(), to = text(body.to);
|
|
177
200
|
if (!/^[A-Z][A-Z0-9_]*-\d+$/.test(key)) return send(bad(400, 'key is a Jira key like IDPF-3340'));
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* sprint-overview.js — the sprint overview on Work › Backlog › This sprint (initiative sprint-overview; brief sprint-overview/build-brief.md;
|
|
3
|
+
* boards SpA and SpA2 on Exploring 2).
|
|
4
|
+
*
|
|
5
|
+
* The written draft (Wawan chose "Yes, a background run writes them", 2026-11-19): one short PMOS session reads ONLY the sprint's ticket
|
|
6
|
+
* keys, titles, states and parent names, and answers JSON: the themes (every ticket in exactly one), two to four sprint goals, and the
|
|
7
|
+
* lines of Doing now and Planned next, each with the keys it covers. It runs as an `ask` job (lib/headless.js, origin briefing-ask:…):
|
|
8
|
+
* no tool, nothing written, nothing sent. normalize() makes the answer honest before the page sees it: unknown keys are dropped, a ticket
|
|
9
|
+
* no theme holds goes to "Everything else", Doing now holds only moving tickets and Planned next only the ones to do, and a ticket no line
|
|
10
|
+
* holds gets an "Other work" line, so the counts add up to the ticket counts. When the run cannot start or its answer cannot be read, the
|
|
11
|
+
* page keeps its own word-matching draft (pm/bk-sprint.js).
|
|
12
|
+
*
|
|
13
|
+
* The PM's edits: <runtime>/backlog/sprint-notes.jsonl, append-only, this file and routes-backlog.js its only writers. A line is
|
|
14
|
+
* { at, ev: note|clear|keep|dismiss|undismiss, ws, board, sprint, block?, text?, base?, id?, by }. PMOS never writes over an edit: when its
|
|
15
|
+
* draft changes after an edit, the page proposes the new draft with a yes (clear) and a no (keep: the edit's base moves to the new draft).
|
|
16
|
+
*
|
|
17
|
+
* promptOf(tickets) · normalize(answer, tickets) · keyOf(tickets) · foldNotes(lines, ws, board) · draft(ctx, tickets, opts) */
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const crypto = require('crypto');
|
|
21
|
+
|
|
22
|
+
const MODEL = 'claude-sonnet-5-5';
|
|
23
|
+
const LEAN = Object.freeze([{ flag: '--strict-mcp-config' }, { flag: '--disable-slash-commands' }, { flag: '--setting-sources', value: 'user' }, { flag: '--tools', value: 'Read' }]);
|
|
24
|
+
const TIMEOUT_MS = 120000;
|
|
25
|
+
const SPARE = 'Everything else';
|
|
26
|
+
const BLOCKS = ['goals', 'doing', 'next'];
|
|
27
|
+
const MOVING = new Set(['In progress', 'In review']);
|
|
28
|
+
const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
|
|
29
|
+
|
|
30
|
+
/** tickets: [{ key, title, state, parent }] → the stable key of one sprint's tickets (a new key = a new draft). */
|
|
31
|
+
function keyOf(tickets) {
|
|
32
|
+
const s = (tickets || []).map((t) => [t.key, t.title, MOVING.has(t.state) ? 'm' : 't', t.parent || ''].join('\t')).sort().join('\n');
|
|
33
|
+
return crypto.createHash('sha1').update(s).digest('hex').slice(0, 16);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function promptOf(tickets) {
|
|
37
|
+
const lines = tickets.map((t) => `${t.key} | ${MOVING.has(t.state) ? 'moving' : 'to do'} | ${clip(t.title, 160)}${t.parent ? ' | parent: ' + clip(t.parent, 80) : ''}`);
|
|
38
|
+
return [
|
|
39
|
+
'You summarise one sprint of Jira tickets for a product manager. Do not use any tool. Answer with JSON only.',
|
|
40
|
+
'The tickets, one per line: key | moving or to do | title | parent (when it has one):',
|
|
41
|
+
lines.join('\n'),
|
|
42
|
+
'Write in plain, short English. Use the words of the titles; never invent work, dates, people or numbers that are not in the titles.',
|
|
43
|
+
'1. themes: group the tickets by what they are about, 3 to 7 themes of 2 or more tickets, plus one theme "Everything else" for the rest. Every key in exactly one theme. A theme name is 2 to 5 words, like "Email OTP design" or "Security and upkeep".',
|
|
44
|
+
'2. goals: 2 to 4 sprint goals, each one sentence of at most 20 words that says what the sprint is getting done, drawn from the biggest themes and the moving work.',
|
|
45
|
+
'3. doing: the moving tickets in 3 to 6 lines; each line names the work in at most 12 words and lists the keys it covers. Every moving key in one line.',
|
|
46
|
+
'4. next: the tickets to do in 3 to 6 lines, the same way. Every "to do" key in one line.',
|
|
47
|
+
'Answer: {"themes":[{"name":"…","keys":["KEY-1"]}],"goals":["…"],"doing":[{"text":"…","keys":["KEY-1"]}],"next":[{"text":"…","keys":["KEY-2"]}]}',
|
|
48
|
+
].join('\n\n');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The answer made honest. → { themes: [{ name, keys }], goals: [text], doing: [{ text, keys }], next: [{ text, keys }] } | null */
|
|
52
|
+
function normalize(text, tickets) {
|
|
53
|
+
const t = String(text || ''), at = t.indexOf('{'), end = t.lastIndexOf('}');
|
|
54
|
+
if (at < 0 || end < at) return null;
|
|
55
|
+
let o; try { o = JSON.parse(t.slice(at, end + 1)); } catch { return null; }
|
|
56
|
+
if (!o || !Array.isArray(o.themes)) return null;
|
|
57
|
+
const by = new Map(tickets.map((x) => [String(x.key).toUpperCase(), x]));
|
|
58
|
+
const keysIn = (L) => (Array.isArray(L) ? L : []).map((k) => String(k || '').trim().toUpperCase()).filter((k) => by.has(k));
|
|
59
|
+
const seen = new Set(), themes = [];
|
|
60
|
+
for (const th of o.themes.slice(0, 12)) {
|
|
61
|
+
const name = clip(th && th.name, 48); if (!name) continue;
|
|
62
|
+
const keys = keysIn(th.keys).filter((k) => !seen.has(k));
|
|
63
|
+
keys.forEach((k) => seen.add(k));
|
|
64
|
+
if (!keys.length) continue;
|
|
65
|
+
const same = themes.find((x) => x.name.toLowerCase() === name.toLowerCase());
|
|
66
|
+
if (same) same.keys.push(...keys); else themes.push({ name, keys });
|
|
67
|
+
}
|
|
68
|
+
if (!themes.length) return null;
|
|
69
|
+
const rest = [...by.keys()].filter((k) => !seen.has(k));
|
|
70
|
+
let spare = themes.find((x) => x.name.toLowerCase() === SPARE.toLowerCase());
|
|
71
|
+
if (spare) { spare.name = SPARE; themes.splice(themes.indexOf(spare), 1); themes.push(spare); }
|
|
72
|
+
if (rest.length) { if (!spare) { spare = { name: SPARE, keys: [] }; themes.push(spare); } spare.keys.push(...rest); }
|
|
73
|
+
const linesOf = (L, moving) => {
|
|
74
|
+
const used = new Set(), out = [];
|
|
75
|
+
for (const l of (Array.isArray(L) ? L : []).slice(0, 8)) {
|
|
76
|
+
const text2 = clip(l && l.text, 120); if (!text2) continue;
|
|
77
|
+
const keys = keysIn(l.keys).filter((k) => MOVING.has(by.get(k).state) === moving && !used.has(k));
|
|
78
|
+
if (!keys.length) continue;
|
|
79
|
+
keys.forEach((k) => used.add(k)); out.push({ text: text2, keys });
|
|
80
|
+
}
|
|
81
|
+
const left = [...by.values()].filter((x) => MOVING.has(x.state) === moving && !used.has(String(x.key).toUpperCase())).map((x) => String(x.key).toUpperCase());
|
|
82
|
+
if (left.length) out.push({ text: 'Other work', keys: left });
|
|
83
|
+
return out;
|
|
84
|
+
};
|
|
85
|
+
const goals = (Array.isArray(o.goals) ? o.goals : []).map((g) => clip(g, 160)).filter(Boolean).slice(0, 4);
|
|
86
|
+
return { themes, goals, doing: linesOf(o.doing, true), next: linesOf(o.next, false) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* ── drafts: one run per sprint's tickets, kept on disk ───────────────────────────────────────────────────────── */
|
|
90
|
+
const draftsFile = (ctx) => path.join(ctx.runtimeDir, 'backlog', 'sprint-drafts.json');
|
|
91
|
+
function readDrafts(ctx) { try { const o = JSON.parse(fs.readFileSync(draftsFile(ctx), 'utf8')); return o && typeof o === 'object' ? o : {}; } catch { return {}; } }
|
|
92
|
+
function keepDraft(ctx, key, value) {
|
|
93
|
+
const all = readDrafts(ctx); all[key] = { at: new Date().toISOString(), ...value };
|
|
94
|
+
const keys = Object.keys(all).sort((a, b) => String(all[b].at).localeCompare(String(all[a].at)));
|
|
95
|
+
for (const k of keys.slice(40)) delete all[k]; // the newest 40 sprints' drafts
|
|
96
|
+
fs.mkdirSync(path.dirname(draftsFile(ctx)), { recursive: true });
|
|
97
|
+
fs.writeFileSync(draftsFile(ctx), JSON.stringify(all));
|
|
98
|
+
}
|
|
99
|
+
const running = new Map(); // key → started at (ms)
|
|
100
|
+
|
|
101
|
+
function viaSession(ctx, prompt, key) {
|
|
102
|
+
if (typeof ctx.askClaude === 'function') return Promise.resolve(ctx.askClaude(prompt, { job: 'sprint-overview', key })).catch(() => null);
|
|
103
|
+
const headless = require('./headless.js');
|
|
104
|
+
const origin = 'briefing-ask:sprint-overview:' + key;
|
|
105
|
+
if (typeof ctx.spawnSession !== 'function' || headless.kindFor({ agent: 'claude', origin }) !== 'ask') return Promise.resolve(null);
|
|
106
|
+
return new Promise((resolve) => {
|
|
107
|
+
let settled = false; const done = (v) => { if (settled) return; settled = true; clearTimeout(tm); resolve(v); };
|
|
108
|
+
const tm = setTimeout(() => done(null), TIMEOUT_MS);
|
|
109
|
+
let s = null;
|
|
110
|
+
try {
|
|
111
|
+
s = ctx.spawnSession({ name: 'sprint: themes and goals', agent: 'claude', origin, initialInput: prompt,
|
|
112
|
+
modelAsk: { explicit: { model: MODEL, effort: 'low' } }, launchFlags: LEAN.map((f) => ({ ...f })),
|
|
113
|
+
onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null); } });
|
|
114
|
+
} catch { s = null; }
|
|
115
|
+
if (!s || s.state === 'exited') done(null);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The written draft of one sprint. → { state: 'ready', draft } | { state: 'pending' } | { state: 'failed', why } (the page keeps its own)
|
|
120
|
+
* opts.again: the PM pressed read-again, so a failed run may start once more. */
|
|
121
|
+
function draft(ctx, tickets, opts = {}) {
|
|
122
|
+
if (!tickets || tickets.length < 2) return { state: 'failed', why: 'too few tickets to group' };
|
|
123
|
+
const key = keyOf(tickets), have = readDrafts(ctx)[key];
|
|
124
|
+
if (have && have.draft) return { state: 'ready', key, draft: have.draft, at: have.at };
|
|
125
|
+
if (running.has(key)) return { state: 'pending', key };
|
|
126
|
+
if (have && have.failed && !opts.again && Date.now() - Date.parse(have.at) < 3600000) return { state: 'failed', key, why: have.failed };
|
|
127
|
+
running.set(key, Date.now());
|
|
128
|
+
Promise.resolve(viaSession(ctx, promptOf(tickets), key)).then((text) => {
|
|
129
|
+
const d = text == null ? null : normalize(text, tickets);
|
|
130
|
+
try { keepDraft(ctx, key, d ? { draft: d } : { failed: text == null ? 'PMOS could not start a session' : 'the answer could not be read' }); } catch { /* the next read tries again */ }
|
|
131
|
+
}).catch(() => {}).finally(() => running.delete(key));
|
|
132
|
+
return { state: 'pending', key };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* ── the PM's edits ───────────────────────────────────────────────────────────────────────────────────────────── */
|
|
136
|
+
const notesFile = (ctx) => path.join(ctx.runtimeDir, 'backlog', 'sprint-notes.jsonl');
|
|
137
|
+
function readNotes(ctx) {
|
|
138
|
+
let raw = ''; try { raw = fs.readFileSync(notesFile(ctx), 'utf8'); } catch { return []; }
|
|
139
|
+
const out = [];
|
|
140
|
+
for (const l of raw.split('\n')) { if (!l.trim()) continue; try { out.push(JSON.parse(l)); } catch { /* a torn line has no effect */ } }
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
function appendNote(ctx, line) {
|
|
144
|
+
fs.mkdirSync(path.dirname(notesFile(ctx)), { recursive: true });
|
|
145
|
+
fs.appendFileSync(notesFile(ctx), JSON.stringify({ at: new Date().toISOString(), ...line }) + '\n');
|
|
146
|
+
}
|
|
147
|
+
/** The notes of one board, by sprint name: { [sprint]: { goals?: { text, base, at }, doing?, next?, dismissed: [id] } } */
|
|
148
|
+
function foldNotes(lines, ws, board) {
|
|
149
|
+
const out = {};
|
|
150
|
+
for (const l of lines || []) {
|
|
151
|
+
if (!l || l.ws !== ws || l.board !== board || !l.sprint) continue;
|
|
152
|
+
const s = out[l.sprint] || (out[l.sprint] = { dismissed: [] });
|
|
153
|
+
if (l.ev === 'note' && BLOCKS.includes(l.block)) s[l.block] = { text: String(l.text || ''), base: l.base || '', at: l.at };
|
|
154
|
+
else if (l.ev === 'clear' && BLOCKS.includes(l.block)) delete s[l.block];
|
|
155
|
+
else if (l.ev === 'keep' && BLOCKS.includes(l.block) && s[l.block]) s[l.block] = { ...s[l.block], base: l.base || '' };
|
|
156
|
+
else if (l.ev === 'dismiss' && l.id && !s.dismissed.includes(l.id)) s.dismissed.push(l.id);
|
|
157
|
+
else if (l.ev === 'undismiss' && l.id) s.dismissed = s.dismissed.filter((x) => x !== l.id);
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = { BLOCKS, SPARE, MODEL, keyOf, promptOf, normalize, draft, readDrafts, foldNotes, readNotes, appendNote, notesFile };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.626.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.626.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -157,3 +157,47 @@ textarea.bk-rvl-ed, .bk-rvl textarea.bd { resize: vertical; min-height: 180px; }
|
|
|
157
157
|
.bk-emb .bk-i > .c-ck .bk-ck { visibility: hidden; } /* ticking is the Backlog's, not an embedded list's */
|
|
158
158
|
.bk-r > .c-due.lt { color: var(--cz-late); } /* the popup's optional Due cell: late in red words */
|
|
159
159
|
@media (max-width: 760px) { .bk-i > .c-due { display: none; } }
|
|
160
|
+
|
|
161
|
+
/* the sprint overview while "This sprint" is on (pm/bd-sprint.js; boards SpA and SpA2) */
|
|
162
|
+
.sp-band { margin: 6px 0 16px; padding: 20px 22px; border-radius: 18px; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); color: var(--cz-ink2); }
|
|
163
|
+
.sp-top { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 40px; }
|
|
164
|
+
.sp-h { display: flex; align-items: center; gap: 10px; }
|
|
165
|
+
.sp-h b { font-size: var(--fs-panel); font-weight: var(--fw-strong); color: var(--cz-ink); }
|
|
166
|
+
.sp-meta { margin: 4px 0 0; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
167
|
+
.sp-big { margin: 18px 0 8px; font-size: var(--fs-row); color: var(--cz-ink3); }
|
|
168
|
+
.sp-big b { font-size: var(--fs-display); font-weight: var(--fw-strong); color: var(--cz-ink); }
|
|
169
|
+
.sp-bar { display: flex; height: 8px; border-radius: 999px; background: var(--cz-well); overflow: hidden; }
|
|
170
|
+
.sp-bar s { display: block; height: 100%; background: var(--cz-blue); text-decoration: none; }
|
|
171
|
+
.sp-s { color: var(--cz-blue); }
|
|
172
|
+
.sp-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
|
|
173
|
+
.sp-thl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(4, auto); grid-auto-flow: column; gap: 2px 32px; margin-top: 6px; }
|
|
174
|
+
.sp-t { all: unset; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) minmax(56px, 104px) 56px; gap: 12px; align-items: center; min-height: 36px; padding: 0 8px; border-radius: 10px; font-size: var(--fs-row); color: var(--cz-ink); }
|
|
175
|
+
.sp-t b { font-weight: var(--fw-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
176
|
+
.sp-t .c { font-size: var(--fs-meta); color: var(--cz-ink3); text-align: right; white-space: nowrap; }
|
|
177
|
+
.sp-t.on { background: var(--cz-bluebg); }
|
|
178
|
+
.sp-pl { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 32px; margin-top: 18px; padding-top: 16px; box-shadow: inset 0 1px 0 var(--cz-hair); }
|
|
179
|
+
.sp-b h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: var(--fs-row); font-weight: var(--fw-strong); color: var(--cz-ink); }
|
|
180
|
+
.sp-b h4 .k { font-size: var(--fs-meta); font-weight: var(--fw-regular); color: var(--cz-ink3); }
|
|
181
|
+
.sp-b h4 .bk-ib { margin-left: auto; }
|
|
182
|
+
.sp-b ul { margin: 0; padding: 0; list-style: none; }
|
|
183
|
+
.sp-b li { display: flex; gap: 10px; padding: 4px 0; font-size: var(--fs-row); color: var(--cz-ink); }
|
|
184
|
+
.sp-b li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: 8px; border-radius: 50%; background: var(--cz-ink3); opacity: .4; }
|
|
185
|
+
.sp-b li span { flex: 1; min-width: 0; }
|
|
186
|
+
.sp-b li em { font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
187
|
+
.sp-ta { box-sizing: border-box; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: var(--cz-well); color: var(--cz-ink); font: inherit; font-size: var(--fs-row); resize: vertical; }
|
|
188
|
+
.sp-ed { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
|
|
189
|
+
.sp-new { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: var(--fs-meta); color: var(--cz-ink2); }
|
|
190
|
+
.sp-props { margin-top: 14px; }
|
|
191
|
+
.sp-p { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: var(--fs-row); color: var(--cz-ink); box-shadow: inset 0 1px 0 var(--cz-hair); }
|
|
192
|
+
.sp-p .x { flex: 1; min-width: 0; }
|
|
193
|
+
.sp-p .x em { font-style: normal; margin-left: 8px; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
194
|
+
.sp-t:focus-visible, .sp-ta:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
195
|
+
@media (hover: hover) { .sp-t:hover:not(.on) { background: var(--cz-well); } }
|
|
196
|
+
@media (max-width: 1100px) { .sp-pl { grid-template-columns: 1fr 1fr; } }
|
|
197
|
+
@media (max-width: 760px) {
|
|
198
|
+
.sp-band { padding: 16px; }
|
|
199
|
+
.sp-top, .sp-pl { grid-template-columns: 1fr; gap: 18px; }
|
|
200
|
+
.sp-thl { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; }
|
|
201
|
+
.sp-t { min-height: 44px; grid-template-columns: minmax(0, 1fr) 40px 52px; gap: 10px; }
|
|
202
|
+
.sp-p { flex-wrap: wrap; padding: 8px 0; }
|
|
203
|
+
}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* Every write is a route's own (lib/routes-backlog.js, and the Board's task routes for a person, a date, an initiative and Archive) and comes
|
|
15
15
|
* with Undo where the route has one. The words say PMOS, never the model's name. pm/premium-board.js calls sync() after each read of the board. */
|
|
16
16
|
import * as BM from './bk-model.js';
|
|
17
|
+
import * as SP from './bd-sprint.js'; // the sprint overview while "This sprint" is on (initiative sprint-overview)
|
|
17
18
|
|
|
18
19
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
19
20
|
const SV = (d, n) => `<svg viewBox="0 0 24 24"${n ? ` width="${n}" height="${n}"` : ''} aria-hidden="true"><path d="${d}"/></svg>`;
|
|
@@ -74,7 +75,9 @@ export async function load() {
|
|
|
74
75
|
const got = await Promise.all(S.map((s) => readOne(s)));
|
|
75
76
|
loading = false; loadedAt = Date.now();
|
|
76
77
|
const ok = got.filter(Boolean);
|
|
77
|
-
|
|
78
|
+
// the oldest Jira read of the pick (the sprint band says when Jira was last read) and the PM's edits of each sprint's overview
|
|
79
|
+
const reads = ok.map((r) => r.readAt).filter(Boolean).sort();
|
|
80
|
+
DATA = { readAt: reads[0] || null, notes: Object.fromEntries(ok.map((r) => [r.ws + '|' + r.board, r.sprintNotes || {}])), tasks: ok.flatMap((r) => r.tasks || []), modes: ok.map((r) => ({ product: r.product, mode: r.mode, label: r.modeLabel, kinds: r.kinds || null })), inis: ok.flatMap((r) => (r.inis || []).map((x) => ({ ...x, ws: r.ws, board: r.board, product: r.product }))),
|
|
78
81
|
err: ok.length ? (ok.length < S.length ? 'One product could not be read; its tasks are not here.' : '') : 'The tasks could not be read. Try again in a moment.', many: S.length > 1 };
|
|
79
82
|
// ?ini=<initiative id> (the initiative popup's "Open in Backlog"): the Initiative facet starts on that initiative, once
|
|
80
83
|
if (!iniApplied) {
|
|
@@ -118,10 +121,15 @@ function draw() {
|
|
|
118
121
|
const said = SAID ? `<p class="bk-said" role="status">${esc(SAID.text)}${SAID.undo ? ' <button type="button" class="bk-lnk" data-bksaid>Undo</button>' : ''}</p>` : '';
|
|
119
122
|
const sh = BM.showingLine(T, { chips: CHIPS, pick: PICK, partB: partB() });
|
|
120
123
|
const showing = sh ? `<p class="bk-show">${esc(sh.text)}${sh.hidden ? ` · ${sh.hidden} hidden` : ''} · <button type="button" class="bk-lnk" data-bkall>Show all</button></p>` : '';
|
|
121
|
-
const
|
|
124
|
+
const band = CHIPS.has('sprint') ? SP.bandHtml({ tasks: T.filter(BM.isOpen), all: T, inis: DATA.inis, readAt: DATA.readAt, notes: DATA.notes }, spDeps()) : '';
|
|
125
|
+
const th = band ? SP.themeOf() : null;
|
|
126
|
+
// a theme pressed in the band: the list is its tickets only, in one group with "Show all" (board SpA2)
|
|
127
|
+
const G = th ? [{ k: 'theme', n: th.name, sub: '', open: true, total: th.total,
|
|
128
|
+
rows: BM.sortRows(T.filter((t) => th.uids.has(uidOf(t)) && BM.keeps(t, CHIPS, PICK, partB())), SORT) }]
|
|
129
|
+
: BM.groupsOf(T, { chips: CHIPS, pick: PICK, sort: SORT, partB: partB() });
|
|
122
130
|
const head = headHtml(COLS);
|
|
123
131
|
const body = G.map((g) => groupHtml(g)).join('') || `<p class="bk-none">${T.length ? 'No task matches these filters.' : 'No open task here. A task added to an initiative, or a Jira ticket of a sprint, shows here.'}</p>`;
|
|
124
|
-
host.innerHTML = `<div class="bk-chips" role="group" aria-label="Show">${chips}</div>${mode}${showing}${said}${DATA.err ? `<p class="bk-err">${esc(DATA.err)}</p>` : ''}`
|
|
132
|
+
host.innerHTML = `<div class="bk-chips" role="group" aria-label="Show">${chips}</div>${mode}${showing}${said}${DATA.err ? `<p class="bk-err">${esc(DATA.err)}</p>` : ''}${band}`
|
|
125
133
|
+ `<div class="bk" role="table" aria-label="Backlog">${head}${body}</div>`;
|
|
126
134
|
drawBar();
|
|
127
135
|
}
|
|
@@ -133,6 +141,10 @@ function headHtml(cols) {
|
|
|
133
141
|
return `<div class="bk-r bk-h" role="row"><span class="c-ck"></span><span class="c-n">Task</span>${cols.map((c) => `<span class="c-${c}">${COL[c][0]}</span>`).join('')}<span class="c-a"></span></div>`;
|
|
134
142
|
}
|
|
135
143
|
function groupHtml(g, cols = COLS) {
|
|
144
|
+
if (g.k === 'theme') {
|
|
145
|
+
return `<div class="bk-r bk-g open" role="row"><span class="bk-gt"><span class="sp-s" aria-hidden="true">${SPARK}</span><b>${esc(g.n)}</b><span class="k">${g.rows.length} ${g.rows.length === 1 ? 'ticket' : 'tickets'}</span></span>`
|
|
146
|
+
+ `<button type="button" class="bk-lnk" data-spall>Show all ${g.total}</button></div>` + g.rows.map((t) => rowHtml(t, BM.groupOf(t, partB()), cols)).join('');
|
|
147
|
+
}
|
|
136
148
|
const open = FOLD[g.k] != null ? FOLD[g.k] : g.open;
|
|
137
149
|
const rows = open ? (MORE.has(g.k) ? g.rows : g.rows.slice(0, BM.SHOW)) : [];
|
|
138
150
|
// Yes acts on the rows in view, never blind (design check 1 a): "Yes to these 5" while the group is cut to 5, "Yes to all 31" once open
|
|
@@ -178,6 +190,10 @@ function rowHtml(t, gk, cols = COLS) {
|
|
|
178
190
|
+ `<span class="c-a bk-a">${act}</span></div>`;
|
|
179
191
|
}
|
|
180
192
|
|
|
193
|
+
/** What the sprint band (pm/bd-sprint.js) needs from the Backlog and its page. */
|
|
194
|
+
const spDeps = () => ({ post, say: (m, u) => AP().say(m, u), draw, load, reload: () => AP().reload(), taskOf,
|
|
195
|
+
readJira: A && A.readJira ? () => A.readJira() : null, newInitiative: A && A.newInitiative ? (name, from) => A.newInitiative(name, from) : null });
|
|
196
|
+
|
|
181
197
|
/* ── the bar under ticked rows (board BkSelect) ───────────────────────────────────────────────────────────────── */
|
|
182
198
|
let bar = null;
|
|
183
199
|
function drawBar() {
|
|
@@ -386,9 +402,10 @@ function closeRv() { if (rv) { rv.remove(); rv = null; } }
|
|
|
386
402
|
const taskOf = (u) => (SC ? SC.tasks() : DATA ? DATA.tasks : []).find((t) => uidOf(t) === u) || null;
|
|
387
403
|
async function press(e, emb) {
|
|
388
404
|
const t0 = e.target;
|
|
405
|
+
if (!emb && t0.closest('.sp-band, [data-spall]') && await SP.press(e, spDeps())) return;
|
|
389
406
|
const chip = t0.closest('[data-bkchip]');
|
|
390
407
|
if (chip) { const k = chip.dataset.bkchip; if (k === 'all') CHIPS.clear(); else if (CHIPS.has(k)) CHIPS.delete(k); else CHIPS.add(k); draw(); const n = host.querySelector(`[data-bkchip="${k}"]`); if (n) n.focus(); return; }
|
|
391
|
-
if (t0.closest('[data-bkall]')) { CHIPS.clear(); PICK = {}; draw(); return; }
|
|
408
|
+
if (t0.closest('[data-bkall]')) { CHIPS.clear(); PICK = {}; SP.clearTheme(); draw(); return; }
|
|
392
409
|
if (t0.closest('[data-bkmode]')) { kindsPop(t0.closest('[data-bkmode]')); return; }
|
|
393
410
|
if (t0.closest('[data-bksaid]')) { const u = SAID && SAID.undo; SAID = null; draw(); if (u) await u(); return; }
|
|
394
411
|
const f = t0.closest('[data-bkfold]');
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/* pm/bd-sprint.js — the sprint overview on Work › Backlog, shown while the "This sprint" chip is on (initiative sprint-overview; Exploring 2
|
|
2
|
+
* page "Sprint overview on the Backlog", boards SpA and SpA2; brief sprint-overview/build-brief.md).
|
|
3
|
+
*
|
|
4
|
+
* · The sprint: its name in plain words, Read Jira again (icon only), "Jira says active · last read <day>" (amber when the read is old),
|
|
5
|
+
* "N of M moving" with a bar, and "N to do · K of M are in no initiative". Zero is silence. No dates, owners or points: PMOS does not
|
|
6
|
+
* store them and does not guess them.
|
|
7
|
+
* · ✦ Themes: PMOS's own grouping of the tickets (Jira stores none). A short PMOS session reads the titles and writes them
|
|
8
|
+
* (lib/sprint-overview.js); until it answers, or when it cannot, the page's word matching (pm/bk-sprint.js) draws them. A press
|
|
9
|
+
* shortlists the list below to the theme's tickets; a second press, or "Show all", clears it.
|
|
10
|
+
* · Sprint goals, Doing now, Planned next: written from the tickets, never from the goal set in Jira. The pencil edits a block; PMOS never
|
|
11
|
+
* writes over an edit and offers a newer draft with a yes and a no instead (POST /api/backlog/sprint-note).
|
|
12
|
+
* · ✦ proposals with ✓ and ✕: link sub-tasks to the initiative their parent is in, place a theme's tickets in an initiative of the same
|
|
13
|
+
* name, make a home for a theme. Nothing applies without the ✓; every ✓ and ✕ comes with Undo.
|
|
14
|
+
* pm/bd-backlog.js calls bandHtml() while the chip is on, themeOf() for the list, and press() first on each press in the Backlog. */
|
|
15
|
+
import * as SK from './bk-sprint.js';
|
|
16
|
+
|
|
17
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
18
|
+
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
19
|
+
const I = { ok: 'M5 12.5l4.5 4.5L19 7', x: 'M6 6l12 12M18 6L6 18', pen: 'M4 20h4L19 9l-4-4L4 16z', read: 'M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7' };
|
|
20
|
+
const SPARK = '✦';
|
|
21
|
+
const OLD_MS = 36 * 3600000; // the Board's own line for an old Jira read (pm/premium-board.js jMood)
|
|
22
|
+
const MON3 = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
23
|
+
const BLOCK = { goals: 'Sprint goals', doing: 'Doing now', next: 'Planned next' };
|
|
24
|
+
|
|
25
|
+
let PICK = ''; // the sprint shown (its id), when there are more than one
|
|
26
|
+
let THEME = ''; // the theme pressed (its id): the list below shows only its tickets
|
|
27
|
+
let EDIT = ''; // the block being edited
|
|
28
|
+
let CUR = null; // what the band drew last: { sp, themes, draft, props }
|
|
29
|
+
const DR = new Map(); // sprint id → { sig, state: pending|ready|failed, d, again }
|
|
30
|
+
|
|
31
|
+
const sigOf = (T) => T.map((t) => t.key + (SK.isMoving(t) ? 'm' : 't')).sort().join(',');
|
|
32
|
+
const dayOf = (iso) => { const d = new Date(iso); return isNaN(d) ? '' : d.getDate() + ' ' + MON3[d.getMonth()]; };
|
|
33
|
+
|
|
34
|
+
/** PMOS's written draft of a sprint: asked once per set of tickets, read again every few seconds while the session works. */
|
|
35
|
+
function ask(sp, deps) {
|
|
36
|
+
const sig = sigOf(sp.tasks), have = DR.get(sp.id);
|
|
37
|
+
if (have && have.sig === sig && !have.again) return have;
|
|
38
|
+
const again = !!(have && have.again);
|
|
39
|
+
const e = { sig, state: 'pending', d: null };
|
|
40
|
+
DR.set(sp.id, e);
|
|
41
|
+
(async () => {
|
|
42
|
+
for (let i = 0; i < 40 && DR.get(sp.id) === e; i++) {
|
|
43
|
+
const r = await deps.post('/api/backlog/sprint-draft', { ws: sp.ws, board: sp.board, sprint: sp.name, again: again && i === 0 });
|
|
44
|
+
if (r && r.state === 'ready' && r.draft) { e.state = 'ready'; e.d = r.draft; if (!EDIT) deps.draw(); return; }
|
|
45
|
+
if (!r || r.state === 'failed' || r.ok === false && r.state !== 'pending') { e.state = 'failed'; return; }
|
|
46
|
+
await new Promise((f) => setTimeout(f, 5000));
|
|
47
|
+
}
|
|
48
|
+
if (e.state === 'pending') e.state = 'failed';
|
|
49
|
+
})();
|
|
50
|
+
return e;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The band's HTML. o: { tasks (the open tasks), all, inis, readAt, notes: { 'ws|board': { [sprint]: … } } }, deps: { post, draw }. '' when
|
|
54
|
+
* no sprint is active. */
|
|
55
|
+
export function bandHtml(o, deps) {
|
|
56
|
+
const S = SK.sprintsOf(o.tasks);
|
|
57
|
+
if (!S.length) { CUR = null; return ''; }
|
|
58
|
+
const sp = S.find((x) => x.id === PICK) || S[0];
|
|
59
|
+
const T = sp.tasks, st = SK.statsOf(T);
|
|
60
|
+
const dr = ask(sp, deps);
|
|
61
|
+
const written = dr.state === 'ready' ? SK.fromDraft(T, dr.d) : null;
|
|
62
|
+
const themes = written ? written.themes : SK.themesOf(T);
|
|
63
|
+
const draft = written ? written.draft : SK.draftOf(T, themes);
|
|
64
|
+
if (THEME && !themes.some((t) => t.id === THEME)) THEME = '';
|
|
65
|
+
const note = ((o.notes || {})[sp.ws + '|' + sp.board] || {})[sp.name] || { dismissed: [] };
|
|
66
|
+
const props = SK.proposalsOf(T, o.all, o.inis, themes, note.dismissed);
|
|
67
|
+
CUR = { sp, themes, draft, props, note };
|
|
68
|
+
|
|
69
|
+
const pct = (a, b) => (b ? Math.round((a / b) * 1000) / 10 : 0);
|
|
70
|
+
const old = !o.readAt || Date.now() - Date.parse(o.readAt) > OLD_MS;
|
|
71
|
+
const read = `Jira says active${o.readAt ? ' · last read ' + dayOf(o.readAt) : ''}`;
|
|
72
|
+
const pick = S.length > 1 ? `<div class="sp-pick" role="group" aria-label="Sprint">${S.map((x) => `<button type="button" class="bk-chip${x.id === sp.id ? ' on' : ''}" data-sppick="${esc(x.id)}" aria-pressed="${x.id === sp.id}">${esc(x.label)}<span class="k">${x.tasks.length}</span></button>`).join('')}</div>` : '';
|
|
73
|
+
const tail = [st.todo ? st.todo + ' to do' : '', st.homeless ? `${st.homeless} of ${st.all} ${st.homeless === 1 ? 'is' : 'are'} in no initiative` : ''].filter(Boolean).join(' · ');
|
|
74
|
+
const sum = `<div class="sp-sum">${pick}<div class="sp-h"><b title="${esc(sp.name)}">${esc(sp.label)}</b><button type="button" class="bk-ib" data-spread aria-label="Read Jira again" title="Read Jira again">${SV(I.read)}</button></div>`
|
|
75
|
+
+ `<p class="sp-meta">${old ? '<i class="bk-dot amber"></i>' : ''}${esc(read)}</p>`
|
|
76
|
+
+ `<p class="sp-big"><b>${st.moving} of ${st.all}</b> <span>moving</span></p><div class="sp-bar" aria-hidden="true"><s style="width:${pct(st.moving, st.all)}%"></s></div>`
|
|
77
|
+
+ (tail ? `<p class="sp-meta">${esc(tail)}</p>` : '') + '</div>';
|
|
78
|
+
const th = `<div class="sp-th"><p class="sp-meta"><span class="sp-s">${SPARK}</span> Themes PMOS found in the ticket titles. Press one to list its tickets below.</p>`
|
|
79
|
+
+ `<div class="sp-thl">${themes.map((t) => `<button type="button" class="sp-t${t.id === THEME ? ' on' : ''}" data-sptheme="${esc(t.id)}" aria-pressed="${t.id === THEME}" title="${esc(t.name)}: ${t.moving} of ${t.n} moving">`
|
|
80
|
+
+ `<b>${esc(t.name)}</b><span class="sp-bar" aria-hidden="true"><s style="width:${pct(t.moving, t.n)}%"></s></span><span class="c">${t.moving} of ${t.n}</span></button>`).join('')}</div></div>`;
|
|
81
|
+
const blocks = ['goals', 'doing', 'next'].map((k) => blockHtml(k, draft, note, st)).join('');
|
|
82
|
+
const pr = props.length ? `<div class="sp-props">${props.map((p) => `<div class="sp-p"><span class="sp-s" aria-hidden="true">${SPARK}</span><span class="x">${esc(p.text)}${p.sub ? `<em>${esc(p.sub)}</em>` : ''}</span>`
|
|
83
|
+
+ `<span class="bk-two"><button type="button" class="bk-ib" data-spok="${esc(p.id)}" aria-label="Yes: ${esc(p.text)}" title="Yes">${SV(I.ok)}</button><button type="button" class="bk-ib" data-spno="${esc(p.id)}" aria-label="No: ${esc(p.text)}" title="No">${SV(I.x)}</button></span></div>`).join('')}</div>` : '';
|
|
84
|
+
return `<section class="sp-band" aria-label="Sprint overview"><div class="sp-top">${sum}${th}</div><div class="sp-pl">${blocks}</div>${pr}</section>`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function blockHtml(k, draft, note, st) {
|
|
88
|
+
const L = draft[k] || [], b = SK.blockOf(note[k], L);
|
|
89
|
+
const count = k === 'doing' ? st.moving : k === 'next' ? st.todo : 0;
|
|
90
|
+
const head = `<h4>${k === 'goals' && !b.mine ? `<span class="sp-s" aria-hidden="true">${SPARK}</span>` : ''}${BLOCK[k]}${count ? `<span class="k">${count} ${count === 1 ? 'ticket' : 'tickets'}</span>` : ''}`
|
|
91
|
+
+ `<button type="button" class="bk-ib" data-spedit="${k}" aria-label="Edit ${BLOCK[k]}" title="Edit">${SV(I.pen)}</button></h4>`;
|
|
92
|
+
if (EDIT === k) {
|
|
93
|
+
return `<div class="sp-b">${head}<textarea class="sp-ta" data-spta="${k}" rows="${Math.max(3, b.lines.length + 1)}" aria-label="${BLOCK[k]}, one point a line">${esc(b.lines.map((l) => l.text).join('\n'))}</textarea>`
|
|
94
|
+
+ `<div class="sp-ed"><button type="button" class="bk-ib ok" data-spsave="${k}" aria-label="Save ${BLOCK[k]}" title="Save">${SV(I.ok)}</button><button type="button" class="bk-ib" data-spcancel aria-label="Cancel" title="Cancel">${SV(I.x)}</button></div></div>`;
|
|
95
|
+
}
|
|
96
|
+
const ul = b.lines.length ? `<ul>${b.lines.map((l) => `<li><span>${esc(l.text)}</span>${l.n ? `<em>${l.n}</em>` : ''}</li>`).join('')}</ul>` : '';
|
|
97
|
+
const foot = b.newer ? `<div class="sp-new"><span><span class="sp-s" aria-hidden="true">${SPARK}</span> PMOS has a newer draft from the tickets.</span><span class="bk-two"><button type="button" class="bk-ib" data-spnew="${k}" aria-label="Use PMOS's newer draft of ${BLOCK[k]}" title="Use it">${SV(I.ok)}</button><button type="button" class="bk-ib" data-spkeep="${k}" aria-label="Keep yours" title="Keep yours">${SV(I.x)}</button></span></div>`
|
|
98
|
+
: k === 'goals' && !b.mine && L.length ? `<p class="sp-meta">Drafted from the ${st.all} tickets, not from the goal set in Jira. Edit to make it yours.</p>` : '';
|
|
99
|
+
return `<div class="sp-b">${head}${ul}${foot}</div>`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The theme pressed, for the list below: { name, uids: Set, total } | null. */
|
|
103
|
+
export function themeOf() {
|
|
104
|
+
if (!THEME || !CUR) return null;
|
|
105
|
+
const t = CUR.themes.find((x) => x.id === THEME);
|
|
106
|
+
return t ? { id: t.id, name: t.name, uids: new Set(t.uids), total: CUR.sp.tasks.length } : null;
|
|
107
|
+
}
|
|
108
|
+
export function clearTheme() { THEME = ''; }
|
|
109
|
+
|
|
110
|
+
/** A press in the Backlog. → true when it was the band's. deps: { post, say, draw, load, reload, readJira, newInitiative, taskOf(uid) } */
|
|
111
|
+
export async function press(e, deps) {
|
|
112
|
+
const t0 = e.target;
|
|
113
|
+
const hit = (a) => t0.closest('[' + a + ']');
|
|
114
|
+
let b;
|
|
115
|
+
if ((b = hit('data-sppick'))) { PICK = b.dataset.sppick; THEME = ''; EDIT = ''; deps.draw(); return true; }
|
|
116
|
+
if ((b = hit('data-sptheme'))) {
|
|
117
|
+
const id = b.dataset.sptheme; THEME = THEME === id ? '' : id; deps.draw();
|
|
118
|
+
const n = document.querySelector(`[data-sptheme="${CSS.escape(id)}"]`); if (n) n.focus();
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (hit('data-spall')) { THEME = ''; deps.draw(); return true; }
|
|
122
|
+
if (hit('data-spread')) {
|
|
123
|
+
if (CUR) { const e2 = DR.get(CUR.sp.id); if (e2 && e2.state === 'failed') e2.again = true; }
|
|
124
|
+
if (deps.readJira) await deps.readJira(); else deps.load();
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
if (!CUR) return false;
|
|
128
|
+
const sp = CUR.sp, at = { ws: sp.ws, board: sp.board, sprint: sp.name };
|
|
129
|
+
if ((b = hit('data-spedit'))) { EDIT = EDIT === b.dataset.spedit ? '' : b.dataset.spedit; deps.draw(); const ta = document.querySelector('[data-spta]'); if (ta) ta.focus(); return true; }
|
|
130
|
+
if (hit('data-spcancel')) { EDIT = ''; deps.draw(); return true; }
|
|
131
|
+
if ((b = hit('data-spsave'))) {
|
|
132
|
+
const k = b.dataset.spsave, ta = document.querySelector(`[data-spta="${k}"]`), words = ta ? ta.value.trim() : '';
|
|
133
|
+
const base = SK.hashOf(SK.textOf(CUR.draft[k]));
|
|
134
|
+
const r = words ? await deps.post('/api/backlog/sprint-note', { ...at, ev: 'note', block: k, text: words, base }) : await deps.post('/api/backlog/sprint-note', { ...at, ev: 'clear', block: k });
|
|
135
|
+
if (!r || r.ok === false) { deps.say((r && r.error) || 'The edit was not saved.'); return true; }
|
|
136
|
+
EDIT = '';
|
|
137
|
+
deps.say(words ? BLOCK[k] + ' saved. PMOS will not write over it.' : BLOCK[k] + ': PMOS\'s draft again.', () => back(deps, at, k, r.was));
|
|
138
|
+
await deps.load(); return true;
|
|
139
|
+
}
|
|
140
|
+
if ((b = hit('data-spnew')) || (b = hit('data-spkeep'))) {
|
|
141
|
+
const use = b.hasAttribute('data-spnew'), k = use ? b.dataset.spnew : b.dataset.spkeep;
|
|
142
|
+
const r = await deps.post('/api/backlog/sprint-note', use ? { ...at, ev: 'clear', block: k } : { ...at, ev: 'keep', block: k, base: SK.hashOf(SK.textOf(CUR.draft[k])) });
|
|
143
|
+
if (!r || r.ok === false) { deps.say((r && r.error) || 'Nothing was changed.'); return true; }
|
|
144
|
+
deps.say(use ? BLOCK[k] + ': PMOS\'s newer draft.' : BLOCK[k] + ': yours kept.', () => back(deps, at, k, r.was));
|
|
145
|
+
await deps.load(); return true;
|
|
146
|
+
}
|
|
147
|
+
if ((b = hit('data-spno'))) {
|
|
148
|
+
const p = CUR.props.find((x) => x.id === b.dataset.spno); if (!p) return true;
|
|
149
|
+
const r = await deps.post('/api/backlog/sprint-note', { ...at, ev: 'dismiss', id: p.id });
|
|
150
|
+
if (!r || r.ok === false) { deps.say((r && r.error) || 'Nothing was changed.'); return true; }
|
|
151
|
+
deps.say('Not now: ' + p.text + '.', async () => { await deps.post('/api/backlog/sprint-note', { ...at, ev: 'undismiss', id: p.id }); deps.load(); });
|
|
152
|
+
await deps.load(); return true;
|
|
153
|
+
}
|
|
154
|
+
if ((b = hit('data-spok'))) {
|
|
155
|
+
const p = CUR.props.find((x) => x.id === b.dataset.spok); if (!p) return true;
|
|
156
|
+
if (p.kind === 'home') {
|
|
157
|
+
if (deps.newInitiative) deps.newInitiative(p.theme, b); else deps.say('Make the initiative with New initiative, then place the tickets.');
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
const done = [];
|
|
161
|
+
for (const u of p.uids) {
|
|
162
|
+
const t = deps.taskOf(u); if (!t) continue;
|
|
163
|
+
const r = await deps.post('/api/backlog/place', { ws: t.ws, board: t.board, key: t.id, to: p.ini });
|
|
164
|
+
if (r && r.ok) done.push({ t, from: r.from || '' }); else { deps.say((r && r.error) || 'Nothing was placed.'); break; }
|
|
165
|
+
}
|
|
166
|
+
if (done.length) {
|
|
167
|
+
deps.say(`Placed ${done.length === 1 ? done[0].t.title : done.length + ' tickets'} in ${p.iniTitle}.`, async () => {
|
|
168
|
+
for (const x of done) await deps.post('/api/backlog/place', { ws: x.t.ws, board: x.t.board, key: x.t.id, to: x.from });
|
|
169
|
+
deps.say('Put back.'); deps.load(); deps.reload();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
await deps.load(); deps.reload(); return true;
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
/** Undo of an edit: the block as it was (the PM's earlier words, or PMOS's draft). */
|
|
177
|
+
async function back(deps, at, k, was) {
|
|
178
|
+
await deps.post('/api/backlog/sprint-note', was ? { ...at, ev: 'note', block: k, text: was.text, base: was.base } : { ...at, ev: 'clear', block: k });
|
|
179
|
+
deps.load();
|
|
180
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/* pm/bk-sprint.js — the pure half of the sprint overview on Work › Backlog › This sprint (initiative sprint-overview; Exploring 2 page
|
|
2
|
+
* "Sprint overview on the Backlog", boards SpA and SpA2; brief sprint-overview/build-brief.md). No DOM, no fetch: pm/bd-backlog.js draws
|
|
3
|
+
* and wires; backlog.test.js tests this file in node.
|
|
4
|
+
*
|
|
5
|
+
* sprintsOf(tasks) → [{ id, name, label, ws, board, tasks }] the active sprints in the tasks, biggest first
|
|
6
|
+
* statsOf(tasks) → { all, moving, todo, homeless } "17 of 52 moving · 35 to do · 50 of 52 are in no initiative"
|
|
7
|
+
* themesOf(tasks) → [{ id, name, uids, n, moving, homeless }] PMOS's own grouping of the tickets by their titles; Jira stores no
|
|
8
|
+
* themes, so the page marks them with ✦. Every ticket is in exactly one theme; "Everything else" is last.
|
|
9
|
+
* draftOf(tasks, themes) → { goals: [{ text }], doing: [{ text, n }], next: [{ text, n }], nDoing, nNext } the three blocks, written
|
|
10
|
+
* from the tickets (never from the goal set in Jira). The counts of Doing now add up to the moving tickets and
|
|
11
|
+
* the counts of Planned next to the tickets to do.
|
|
12
|
+
* proposalsOf(tasks, all, inis, themes, dismissed) → [{ id, kind: link|place|home, text, sub, uids, ini, iniTitle, theme }]
|
|
13
|
+
* link: tickets whose parent ticket is already in an initiative go to that initiative; place: a theme's
|
|
14
|
+
* homeless tickets go to an open initiative of the same name; home: a theme with no initiative gets one.
|
|
15
|
+
* blockOf(note, draftLines) → { lines, mine, newer } what a block shows: the PM's edit when there is one (PMOS never writes over it),
|
|
16
|
+
* and whether PMOS has a newer draft since the edit (a ✦ proposal with a yes and a no)
|
|
17
|
+
* hashOf(text) → a short hash of a draft, the base an edit is made against
|
|
18
|
+
*
|
|
19
|
+
* Honest data (design principles 7 and 8): PMOS does not store a sprint's dates, assignees or story points, so nothing here guesses them. */
|
|
20
|
+
|
|
21
|
+
const STOP = new Set(('a an and are as at be been by can do does for from has have how in into is it its of on or our should so that the their them then '
|
|
22
|
+
+ 'there these this to was we when where which while who will with within without not no yes all any each more most other some such only own same '
|
|
23
|
+
+ 'than too very just also via per add adds added adding new fix fixes fixed fixing update updates updated make makes create created use using used '
|
|
24
|
+
+ 'investigate investigation check checks review support supports supporting handle handling need needs needed please help able unable issue issues '
|
|
25
|
+
+ 'ticket tickets task tasks story stories item items part phase step steps follow up follows first second third one two three after before '
|
|
26
|
+
+ 'should user users get set show showing shows also via etc vs').split(/\s+/));
|
|
27
|
+
const SPARE = 'Everything else';
|
|
28
|
+
const MAX_THEMES = 6;
|
|
29
|
+
const MOVING = new Set(['In progress', 'In review']);
|
|
30
|
+
export const isMoving = (t) => MOVING.has(t.state);
|
|
31
|
+
export const uidOf = (t) => t.ws + '|' + t.board + '|' + t.id;
|
|
32
|
+
|
|
33
|
+
/** "MAD Sprint 116" → "Sprint 116": the sprint in plain words. A name with no "Sprint <n>" stays as it is. */
|
|
34
|
+
export function labelOf(name) {
|
|
35
|
+
const m = /\bsprint\s*(\d+)\b/i.exec(String(name || ''));
|
|
36
|
+
return m ? 'Sprint ' + m[1] : String(name || '').trim();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The active sprints in the tasks, biggest first. */
|
|
40
|
+
export function sprintsOf(tasks) {
|
|
41
|
+
const m = new Map();
|
|
42
|
+
for (const t of tasks || []) {
|
|
43
|
+
if (!t.sprint || t.sprint.state !== 'active') continue;
|
|
44
|
+
const id = t.ws + '|' + t.board + '|' + t.sprint.name;
|
|
45
|
+
if (!m.has(id)) m.set(id, { id, name: t.sprint.name, label: labelOf(t.sprint.name), ws: t.ws, board: t.board, tasks: [] });
|
|
46
|
+
m.get(id).tasks.push(t);
|
|
47
|
+
}
|
|
48
|
+
return [...m.values()].sort((a, b) => b.tasks.length - a.tasks.length || a.name.localeCompare(b.name));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function statsOf(tasks) {
|
|
52
|
+
const T = tasks || [];
|
|
53
|
+
return { all: T.length, moving: T.filter(isMoving).length, todo: T.filter((t) => !isMoving(t)).length, homeless: T.filter((t) => !t.ini).length };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* ── themes ───────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
57
|
+
const stem = (w) => (w.length > 4 && /[^s]s$/.test(w) ? w.slice(0, -1) : w);
|
|
58
|
+
/** The words of a title that can name a theme: the bracket tags' words and the title's own, lower case, no small or common words. */
|
|
59
|
+
function wordsOf(s) {
|
|
60
|
+
const out = [];
|
|
61
|
+
for (const raw of String(s || '').replace(/[[\]()/:,.;!?"'`]+/g, ' ').split(/[\s_]+/)) {
|
|
62
|
+
const w = raw.replace(/^[^A-Za-z0-9]+|[^A-Za-z0-9]+$/g, '');
|
|
63
|
+
if (!w || /^\d+$/.test(w) || /^v\d+$/i.test(w)) continue;
|
|
64
|
+
const k = stem(w.toLowerCase());
|
|
65
|
+
if (k.length < 3 && !/^[A-Z]{2}$/.test(w)) continue; // two capital letters is a name (LB, UI); two small ones is not a word
|
|
66
|
+
if (STOP.has(k)) continue;
|
|
67
|
+
out.push({ k, w });
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/** A title without its bracket tags, cut to about n characters at a word. */
|
|
72
|
+
export function shortOf(title, n = 38) {
|
|
73
|
+
const s = String(title || '').replace(/\[[^\]]*\]/g, ' ').replace(/\s+/g, ' ').trim() || String(title || '').trim();
|
|
74
|
+
if (s.length <= n) return s;
|
|
75
|
+
const cut = s.slice(0, n), sp = cut.lastIndexOf(' ');
|
|
76
|
+
return (sp > n * 0.5 ? cut.slice(0, sp) : cut).replace(/[\s,;:-]+$/, '') + '…';
|
|
77
|
+
}
|
|
78
|
+
/** A stable id for a name: the theme's key in the page and in a dismissed proposal. */
|
|
79
|
+
export function hashOf(text) {
|
|
80
|
+
let h = 2166136261;
|
|
81
|
+
for (const c of String(text || '')) { h ^= c.codePointAt(0); h = Math.imul(h, 16777619); }
|
|
82
|
+
return (h >>> 0).toString(36);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** PMOS's themes for the tickets of one sprint: a greedy grouping by the word (or the parent ticket) most tickets share, widened once by the
|
|
86
|
+
* word most of the group shares next. At most MAX_THEMES themes of two tickets or more; the rest is "Everything else". */
|
|
87
|
+
export function themesOf(tasks) {
|
|
88
|
+
const T = (tasks || []).slice().sort((a, b) => String(a.id).localeCompare(String(b.id)));
|
|
89
|
+
if (!T.length) return [];
|
|
90
|
+
const keys = new Set(T.map((t) => t.key).filter(Boolean));
|
|
91
|
+
const parentN = new Map();
|
|
92
|
+
for (const t of T) if (t.epic && t.epic.key) parentN.set(t.epic.key, (parentN.get(t.epic.key) || 0) + 1);
|
|
93
|
+
const shown = new Map(); // a word → its forms as written, with counts: the theme's name uses the most common form
|
|
94
|
+
const toks = new Map();
|
|
95
|
+
for (const t of T) {
|
|
96
|
+
const s = new Set();
|
|
97
|
+
for (const { k, w } of wordsOf(t.title).concat(wordsOf(t.epic && t.epic.name))) {
|
|
98
|
+
s.add(k);
|
|
99
|
+
const f = shown.get(k) || new Map(); f.set(w, (f.get(w) || 0) + 1); shown.set(k, f);
|
|
100
|
+
}
|
|
101
|
+
// the parent ticket: a strong tie when two tickets share it, or when the parent is in the sprint itself
|
|
102
|
+
const p = t.epic && t.epic.key;
|
|
103
|
+
if (p && (parentN.get(p) >= 2 || keys.has(p))) s.add('p:' + p);
|
|
104
|
+
if (t.key && parentN.get(t.key) >= 1) s.add('p:' + t.key);
|
|
105
|
+
toks.set(uidOf(t), s);
|
|
106
|
+
}
|
|
107
|
+
const by = new Map(T.map((t) => [uidOf(t), t]));
|
|
108
|
+
const left = new Set(by.keys());
|
|
109
|
+
const countIn = (set) => { const c = new Map(); for (const u of set) for (const k of toks.get(u)) c.set(k, (c.get(k) || 0) + 1); return c; };
|
|
110
|
+
const tooCommon = (n) => T.length >= 8 && n > T.length * 0.5;
|
|
111
|
+
const out = [];
|
|
112
|
+
while (out.length < MAX_THEMES && left.size >= 2) {
|
|
113
|
+
const c = countIn(left);
|
|
114
|
+
let best = null, bs = 0;
|
|
115
|
+
for (const [k, n] of c) {
|
|
116
|
+
if (n < 2 || tooCommon(n)) continue;
|
|
117
|
+
const s = n * (k.startsWith('p:') ? 1.5 : 1);
|
|
118
|
+
if (s > bs || (s === bs && best && k < best)) { best = k; bs = s; }
|
|
119
|
+
}
|
|
120
|
+
if (!best) break;
|
|
121
|
+
const group = new Set([...left].filter((u) => toks.get(u).has(best)));
|
|
122
|
+
// widen once: the word the group shares most next, when it holds at least two of them and two in five
|
|
123
|
+
const inG = countIn(group); let co = null, cn = 0;
|
|
124
|
+
for (const [k, n] of inG) if (k !== best && !k.startsWith('p:') && n >= 2 && n >= group.size * 0.4 && !tooCommon(c.get(k) || 0) && (n > cn || (n === cn && co && k < co))) { co = k; cn = n; }
|
|
125
|
+
if (co) for (const u of left) if (toks.get(u).has(co)) group.add(u);
|
|
126
|
+
for (const u of group) left.delete(u);
|
|
127
|
+
out.push({ seed: best, co, uids: [...group] });
|
|
128
|
+
}
|
|
129
|
+
const form = (k) => { const f = shown.get(k); return f ? [...f].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0][0] : k; };
|
|
130
|
+
const nameOf = (g) => {
|
|
131
|
+
if (g.seed.startsWith('p:')) {
|
|
132
|
+
const key = g.seed.slice(2), p = T.find((t) => t.key === key), child = T.find((t) => t.epic && t.epic.key === key && t.epic.name);
|
|
133
|
+
return shortOf(p ? p.title : child ? child.epic.name : key, 34);
|
|
134
|
+
}
|
|
135
|
+
const a = form(g.seed), b = g.co ? form(g.co) : '';
|
|
136
|
+
const cap = (w) => (w[0] === w[0].toLowerCase() ? w[0].toUpperCase() + w.slice(1) : w);
|
|
137
|
+
const low = (w) => (/[A-Z].*[A-Z]/.test(w) || /^[A-Z][a-z]+[A-Z]/.test(w) ? w : w === w.toLowerCase() ? w : T.some((t) => new RegExp('\\b' + w + '\\b').test(t.title)) && w[0] === w[0].toUpperCase() && w.slice(1) === w.slice(1).toLowerCase() ? w : w.toLowerCase());
|
|
138
|
+
return b ? cap(a) + ' and ' + low(b) : cap(a);
|
|
139
|
+
};
|
|
140
|
+
const themes = out.map((g) => ({ name: nameOf(g), uids: g.uids }));
|
|
141
|
+
if (left.size) themes.push({ name: SPARE, uids: [...left], spare: true });
|
|
142
|
+
// two themes with the same name are one
|
|
143
|
+
const merged = [];
|
|
144
|
+
for (const t of themes) { const m = merged.find((x) => x.name === t.name && !x.spare === !t.spare); if (m) m.uids.push(...t.uids); else merged.push(t); }
|
|
145
|
+
return merged.map((t) => {
|
|
146
|
+
const rows = t.uids.map((u) => by.get(u));
|
|
147
|
+
return { id: hashOf(t.name), name: t.name, spare: !!t.spare, uids: t.uids, n: rows.length, moving: rows.filter(isMoving).length, homeless: rows.filter((r) => !r.ini).length };
|
|
148
|
+
}).sort((a, b) => (a.spare - b.spare) || b.n - a.n || a.name.localeCompare(b.name));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* ── the three blocks ─────────────────────────────────────────────────────────────────────────────────────────── */
|
|
152
|
+
const listOf = (rows, n = 2) => rows.slice(0, n).map((t) => shortOf(t.title, 30)).join(', ');
|
|
153
|
+
/** Sprint goals, Doing now and Planned next, written from the tickets. */
|
|
154
|
+
export function draftOf(tasks, themes) {
|
|
155
|
+
const by = new Map((tasks || []).map((t) => [uidOf(t), t]));
|
|
156
|
+
const rowsOf = (th) => th.uids.map((u) => by.get(u)).filter(Boolean);
|
|
157
|
+
const lead = (th) => (th.spare ? 'Other work' : th.name);
|
|
158
|
+
const doing = [], next = [];
|
|
159
|
+
for (const th of themes || []) {
|
|
160
|
+
const R = rowsOf(th), m = R.filter(isMoving), d = R.filter((t) => !isMoving(t));
|
|
161
|
+
if (m.length) doing.push({ text: lead(th) + ': ' + listOf(m), n: m.length, spare: th.spare });
|
|
162
|
+
if (d.length) next.push({ text: lead(th) + ': ' + listOf(d), n: d.length, spare: th.spare });
|
|
163
|
+
}
|
|
164
|
+
const order = (L) => L.sort((a, b) => (a.spare - b.spare) || b.n - a.n).map(({ text, n }) => ({ text, n }));
|
|
165
|
+
// goals: the themes with the most moving, then the biggest; two to four of them, never the spare one
|
|
166
|
+
const G = (themes || []).filter((th) => !th.spare && th.n >= 2).slice().sort((a, b) => b.moving - a.moving || b.n - a.n).slice(0, 4);
|
|
167
|
+
const goals = G.map((th) => {
|
|
168
|
+
const R = rowsOf(th), m = R.filter(isMoving);
|
|
169
|
+
return { text: (m.length ? 'Move ' : 'Start ') + th.name + ': ' + listOf(m.length ? m : R, 3) };
|
|
170
|
+
});
|
|
171
|
+
return { goals, doing: order(doing), next: order(next), nDoing: doing.reduce((s, x) => s + x.n, 0), nNext: next.reduce((s, x) => s + x.n, 0) };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* ── PMOS's proposals under the blocks ────────────────────────────────────────────────────────────────────────── */
|
|
175
|
+
const sig = (s) => new Set(wordsOf(s).map((x) => x.k));
|
|
176
|
+
/** The ✦ proposals for one sprint. tasks: the sprint's tickets; all: every task of the product (a parent ticket may be outside the sprint);
|
|
177
|
+
* inis: [{ id, title, ws, board }] the open initiatives; dismissed: [proposal id] the PM said no to. Nothing applies without the PM's ✓. */
|
|
178
|
+
export function proposalsOf(tasks, all, inis, themes, dismissed) {
|
|
179
|
+
const no = new Set(dismissed || []), out = [];
|
|
180
|
+
const T = tasks || [];
|
|
181
|
+
const inisOf = (t) => (inis || []).filter((x) => (!x.ws || x.ws === t.ws) && (!x.board || x.board === t.board));
|
|
182
|
+
// link: a ticket in no initiative whose parent ticket is in one (and that the No home list does not already propose)
|
|
183
|
+
const parentIni = new Map();
|
|
184
|
+
for (const t of all || []) if (t.key && t.ini) parentIni.set(t.ws + '|' + t.key, t);
|
|
185
|
+
const link = new Map();
|
|
186
|
+
for (const t of T) {
|
|
187
|
+
if (t.ini || t.propose || !t.epic || !t.epic.key) continue;
|
|
188
|
+
const p = parentIni.get(t.ws + '|' + t.epic.key); if (!p) continue;
|
|
189
|
+
const id = 'link:' + t.ws + '|' + t.epic.key;
|
|
190
|
+
if (!link.has(id)) link.set(id, { id, kind: 'link', parent: p, uids: [] });
|
|
191
|
+
link.get(id).uids.push(uidOf(t));
|
|
192
|
+
}
|
|
193
|
+
for (const L of link.values()) {
|
|
194
|
+
if (no.has(L.id)) continue;
|
|
195
|
+
const n = L.uids.length;
|
|
196
|
+
out.push({ id: L.id, kind: 'link', ini: L.parent.ini, iniTitle: L.parent.iniTitle || L.parent.ini, uids: L.uids, ws: L.parent.ws, board: L.parent.board,
|
|
197
|
+
text: `Link ${n === 1 ? 'the sub-task' : 'the ' + n + ' sub-tasks'} of ${L.parent.key} to ${L.parent.iniTitle || L.parent.ini}`,
|
|
198
|
+
sub: `their parent ${L.parent.key} is already in it` });
|
|
199
|
+
}
|
|
200
|
+
// place / home: a theme whose tickets have no initiative
|
|
201
|
+
const by = new Map(T.map((t) => [uidOf(t), t]));
|
|
202
|
+
const linked = new Set(out.flatMap((p) => p.uids));
|
|
203
|
+
let home = null;
|
|
204
|
+
for (const th of themes || []) {
|
|
205
|
+
if (th.spare) continue;
|
|
206
|
+
const R = th.uids.map((u) => by.get(u)).filter((t) => t && !t.ini && !linked.has(uidOf(t)));
|
|
207
|
+
if (R.length < 2) continue;
|
|
208
|
+
const want = sig(th.name);
|
|
209
|
+
const hit = want.size ? inisOf(R[0]).map((x) => ({ x, n: [...sig(x.title)].filter((w) => want.has(w)).length })).filter((m) => m.n >= Math.max(1, Math.ceil(want.size / 2)))
|
|
210
|
+
.sort((a, b) => b.n - a.n)[0] : null;
|
|
211
|
+
if (hit) {
|
|
212
|
+
const id = 'place:' + th.id + '>' + hit.x.id;
|
|
213
|
+
if (!no.has(id)) out.push({ id, kind: 'place', ini: hit.x.id, iniTitle: hit.x.title, uids: R.map(uidOf), theme: th.name, ws: R[0].ws, board: R[0].board,
|
|
214
|
+
text: `Place the ${R.length} ${th.name} tickets in ${hit.x.title}`, sub: 'the initiative has the same name' });
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const id = 'home:' + th.id;
|
|
218
|
+
// one "make a home" at a time: the theme with most work moving, then the biggest (quiet by default)
|
|
219
|
+
if (R.length === th.n && th.n >= 3 && !no.has(id) && (!home || th.moving > home.th.moving || (th.moving === home.th.moving && th.n > home.th.n))) home = { id, th, R };
|
|
220
|
+
}
|
|
221
|
+
if (home) out.push({ id: home.id, kind: 'home', uids: home.R.map(uidOf), theme: home.th.name, ws: home.R[0].ws, board: home.R[0].board,
|
|
222
|
+
text: `Make a home for ${home.th.name}`, sub: `${home.th.n} tickets, ${home.th.moving} moving, no initiative yet` });
|
|
223
|
+
return out.slice(0, 3);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* ── a block: PMOS's draft or the PM's edit ───────────────────────────────────────────────────────────────────── */
|
|
227
|
+
/** The draft's lines as one text (what an edit starts from and what its base hash is taken of). */
|
|
228
|
+
export const textOf = (lines) => (lines || []).map((l) => l.text).join('\n');
|
|
229
|
+
/** note: { text, base } | null (the PM's edit of this block, newest). → { lines: [{ text, n? }], mine, newer } */
|
|
230
|
+
export function blockOf(note, lines) {
|
|
231
|
+
if (!note || typeof note.text !== 'string') return { lines: lines || [], mine: false, newer: false };
|
|
232
|
+
const mine = note.text.split('\n').map((s) => s.trim()).filter(Boolean).map((text) => ({ text }));
|
|
233
|
+
return { lines: mine, mine: true, newer: !!note.base && note.base !== hashOf(textOf(lines)) };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* ── the written draft (lib/sprint-overview.js: a short PMOS session read the titles) ─────────────────────────── */
|
|
237
|
+
/** d: { themes: [{ name, keys }], goals: [text], doing: [{ text, keys }], next: [{ text, keys }] } → { themes, draft } in the shapes of
|
|
238
|
+
* themesOf and draftOf, over the tickets on the page now (a key no longer in the sprint is dropped; a ticket the draft does not hold goes to
|
|
239
|
+
* "Everything else" and "Other work", so the counts still add up). null when the draft does not fit these tickets. */
|
|
240
|
+
export function fromDraft(tasks, d) {
|
|
241
|
+
if (!d || !Array.isArray(d.themes)) return null;
|
|
242
|
+
const T = tasks || [], byKey = new Map(T.filter((t) => t.key).map((t) => [String(t.key).toUpperCase(), t]));
|
|
243
|
+
const seen = new Set(), themes = [];
|
|
244
|
+
for (const th of d.themes) {
|
|
245
|
+
const rows = (th.keys || []).map((k) => byKey.get(String(k).toUpperCase())).filter((t) => t && !seen.has(uidOf(t)));
|
|
246
|
+
rows.forEach((t) => seen.add(uidOf(t)));
|
|
247
|
+
if (rows.length) themes.push({ name: String(th.name), rows });
|
|
248
|
+
}
|
|
249
|
+
const rest = T.filter((t) => !seen.has(uidOf(t)));
|
|
250
|
+
if (!themes.length) return null;
|
|
251
|
+
if (rest.length) { const sp = themes.find((x) => x.name === SPARE); if (sp) sp.rows.push(...rest); else themes.push({ name: SPARE, rows: rest }); }
|
|
252
|
+
const TH = themes.map((t) => ({ id: hashOf(t.name), name: t.name, spare: t.name === SPARE, uids: t.rows.map(uidOf), n: t.rows.length, moving: t.rows.filter(isMoving).length, homeless: t.rows.filter((r) => !r.ini).length }))
|
|
253
|
+
.sort((a, b) => (a.spare - b.spare) || b.n - a.n || a.name.localeCompare(b.name));
|
|
254
|
+
const lines = (L, moving) => {
|
|
255
|
+
const used = new Set(), out = [];
|
|
256
|
+
for (const l of L || []) {
|
|
257
|
+
const rows = (l.keys || []).map((k) => byKey.get(String(k).toUpperCase())).filter((t) => t && isMoving(t) === moving && !used.has(uidOf(t)));
|
|
258
|
+
rows.forEach((t) => used.add(uidOf(t)));
|
|
259
|
+
if (rows.length) out.push({ text: String(l.text), n: rows.length });
|
|
260
|
+
}
|
|
261
|
+
const left = T.filter((t) => isMoving(t) === moving && !used.has(uidOf(t))).length;
|
|
262
|
+
if (left) { const o = out.find((x) => x.text === 'Other work'); if (o) o.n += left; else out.push({ text: 'Other work', n: left }); }
|
|
263
|
+
return out;
|
|
264
|
+
};
|
|
265
|
+
const doing = lines(d.doing, true), next = lines(d.next, false);
|
|
266
|
+
const goals = (d.goals || []).map((g) => ({ text: String(g) })).filter((g) => g.text);
|
|
267
|
+
return { themes: TH, draft: { goals, doing, next, nDoing: doing.reduce((s, x) => s + x.n, 0), nNext: next.reduce((s, x) => s + x.n, 0) } };
|
|
268
|
+
}
|
|
@@ -1392,6 +1392,13 @@ const bkApi = () => ({
|
|
|
1392
1392
|
scope: () => (M.board.all ? (M.board.products || []).map((p) => ({ ws: p.ws, board: p.id || '', name: p.name })) : [{ ws: M.board.ws || '', board: M.board.id || '', name: M.board.product || M.board.name || '' }]),
|
|
1393
1393
|
// CLASSIC (lib/classic-board.js) is the test seam of the four Board views: Work and its Backlog switch are not there
|
|
1394
1394
|
post: pmPost, say, reload: () => load(), readonly: !!window.PMOS_READONLY || CLASSIC,
|
|
1395
|
+
// the sprint band (pm/bd-sprint.js): Read Jira again is the Board's own; "Make a home" opens New initiative with the theme's name
|
|
1396
|
+
readJira: () => refreshJira(null),
|
|
1397
|
+
newInitiative: async (name, from) => {
|
|
1398
|
+
await Asks.openNew(from, null);
|
|
1399
|
+
const i = document.querySelector('form[data-form="new2"] input[name="title"]');
|
|
1400
|
+
if (i) { i.value = name; i.dispatchEvent(new Event('input', { bubbles: true })); i.focus(); }
|
|
1401
|
+
},
|
|
1395
1402
|
// a row's name: a Jira ticket opens in its initiative's ticket view or its Jira page; a PMOS task in the small task popup
|
|
1396
1403
|
openTask: (t, from) => {
|
|
1397
1404
|
const r = (M.rows || []).find((x) => x.id === t.ini && x.track && (x.ws || M.board.ws) === t.ws);
|