create-pmos 0.842.0 → 0.844.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 +37 -3
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-shared-ui-test.js +1 -0
- package/workspace/changelog.json +36 -2
- package/workspace/guide/cli.md +13 -1
- package/workspace/guide/layout.md +2 -0
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/build-engine.js +4 -1
- package/workspace/lib/factory-traces.js +2 -1
- package/workspace/lib/features.json +1 -0
- package/workspace/lib/initiative-cost.js +259 -0
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/routes-factory-metrics.js +54 -1
- package/workspace/lib/routes-proposals.js +7 -0
- package/workspace/lib/sprint-cli.js +30 -4
- package/workspace/lib/sprint-now.js +39 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog-ds.js +24 -4
- package/workspace/public/pm/bd-backlog.css +3 -0
- package/workspace/public/pm/bd-backlog.js +36 -7
- package/workspace/public/pm/bd-sprint-ds.js +117 -23
- package/workspace/public/pm/bd-sprint.js +9 -1
- package/workspace/public/pm/bd-work-ds.css +29 -0
- package/workspace/public/pm/cozy-pop-work.js +14 -1
- package/workspace/public/pm/initiative-cost.js +103 -0
- package/workspace/task-press-test.js +1 -1
- package/workspace/test-lists/initiative-cost.json +9 -0
- package/workspace/test-lists/tb-sprint-balanced.json +9 -0
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* The factory floor per product as the Driver saved it after its last run (lib/factory-floor.js load). It reads one file per product and
|
|
13
13
|
* folds nothing, so the Factory page opens in 200 ms or less. snapshot is null while no run has saved one: a read never computes or writes.
|
|
14
14
|
* ws: one workspace (404 when unknown); without it, every workspace.
|
|
15
|
+
*
|
|
16
|
+
* GET /api/initiative-cost?ws → { ok, products: [{ ws, name, total, rows }] } (initiative initiative-cost, A17; lib/initiative-cost.js)
|
|
17
|
+
* What the factory spent per initiative and per merged pull request, and which initiatives are stalled or paused. Zero is silence: a
|
|
18
|
+
* product where no factory ran is left out, so Work shows no Cost tab. It reads two small files per product and writes nothing.
|
|
19
|
+
* POST /api/initiative-cost/pause|resume|keep { ws, ini } → { ok, ini, paused } page press only (pm-guard requirePagePress)
|
|
20
|
+
* pause: the factory takes no new job of the initiative (work it holds finishes), and the stall's ✦ is answered. resume: Undo.
|
|
21
|
+
* keep: "Keep going", the stall's ✦ is answered and nothing pauses. The same store as `pmos cost pause|resume`.
|
|
15
22
|
*/
|
|
16
23
|
const FT = require('./factory-traces.js');
|
|
17
24
|
|
|
@@ -45,8 +52,54 @@ function floorFor(ctx, { ws = '' } = {}) {
|
|
|
45
52
|
return { status: 200, body: { ok: true, products } };
|
|
46
53
|
}
|
|
47
54
|
|
|
55
|
+
const PASS_AT = new Map(), PASS_EVERY = 30 * 60 * 1000;
|
|
56
|
+
function costFor(ctx, { ws = '', now = Date.now() } = {}) {
|
|
57
|
+
let list;
|
|
58
|
+
if (ws) {
|
|
59
|
+
const w = ctx.getWs(ws);
|
|
60
|
+
if (!w || w.id !== ws) return bad(404, 'no such workspace');
|
|
61
|
+
list = [w];
|
|
62
|
+
} else list = (ctx.workspaceList ? ctx.workspaceList() : []).filter((w) => w && w.root && !w.linked);
|
|
63
|
+
const IC = require('./initiative-cost.js'), products = [];
|
|
64
|
+
for (const w of list) {
|
|
65
|
+
let C = null;
|
|
66
|
+
const sd = (ctx.stateDirFor && ctx.stateDirFor(w)) || null;
|
|
67
|
+
// the pause ✦ (no model): filed when Work reads the costs, at most once per half hour per product
|
|
68
|
+
if (now - (PASS_AT.get(w.root) || 0) >= PASS_EVERY) { PASS_AT.set(w.root, now); try { IC.proposePass(w.root, { now, stateDir: sd }); } catch { /* the read still answers */ } }
|
|
69
|
+
try { C = IC.readOf(w.root, { now, stateDir: sd }); } catch { C = null; }
|
|
70
|
+
if (C && C.rows.length) products.push({ ws: w.id, name: w.name || w.id, ...C });
|
|
71
|
+
}
|
|
72
|
+
return { status: 200, body: { ok: true, products } };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function costPost(req, url, ctx) {
|
|
76
|
+
const sub = url.pathname.replace(/^\/api\/initiative-cost\/?/, '');
|
|
77
|
+
if (!['pause', 'resume', 'keep'].includes(sub)) return bad(404, 'no such cost route');
|
|
78
|
+
if (req.method !== 'POST') return bad(405, 'POST only');
|
|
79
|
+
const read = await ctx.readJson(req);
|
|
80
|
+
if (!read.ok || !read.body || typeof read.body !== 'object') return bad(400, 'the body must be a JSON object');
|
|
81
|
+
const g = require('./pm-guard.js').requirePagePress(req, read.body);
|
|
82
|
+
if (!g.ok) return bad(g.status, g.error);
|
|
83
|
+
const ini = typeof read.body.ini === 'string' ? read.body.ini : '';
|
|
84
|
+
if (!/^[a-z0-9][a-z0-9._-]*$/.test(ini)) return bad(400, 'ini must name an initiative');
|
|
85
|
+
const w = ctx.getWs(typeof read.body.ws === 'string' && read.body.ws ? read.body.ws : null);
|
|
86
|
+
if (!w || (read.body.ws && w.id !== read.body.ws)) return bad(404, 'no such workspace');
|
|
87
|
+
const IC = require('./initiative-cost.js'), sd = (ctx.stateDirFor && ctx.stateDirFor(w)) || require('./driver.js').stateDirOf(w.root, { create: true });
|
|
88
|
+
const by = (g.actor && g.actor.by) || 'pm';
|
|
89
|
+
if (sub === 'keep') { IC.answer(sd, ini, 'keep going', { by }); return { status: 200, body: { ok: true, ini, paused: IC.pausedOf(sd).has(ini) } }; }
|
|
90
|
+
const r = (sub === 'pause' ? IC.pause : IC.resume)(sd, ini, { by, why: sub === 'pause' ? 'Work › Cost' : 'Undo' });
|
|
91
|
+
if (!r.ok) return bad(400, r.error);
|
|
92
|
+
if (sub === 'pause') IC.answer(sd, ini, 'paused from Work › Cost', { by });
|
|
93
|
+
return { status: 200, body: { ok: true, ini, paused: sub === 'pause' } };
|
|
94
|
+
}
|
|
95
|
+
|
|
48
96
|
async function handle(req, res, url, ctx) {
|
|
49
97
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
98
|
+
if (url.pathname === '/api/initiative-cost') {
|
|
99
|
+
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
100
|
+
return send(costFor(ctx, { ws: String(url.searchParams.get('ws') || '') }));
|
|
101
|
+
}
|
|
102
|
+
if (url.pathname.startsWith('/api/initiative-cost/')) return send(await costPost(req, url, ctx));
|
|
50
103
|
if (url.pathname === '/api/factory') {
|
|
51
104
|
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
52
105
|
return send(floorFor(ctx, { ws: String(url.searchParams.get('ws') || '') }));
|
|
@@ -59,4 +112,4 @@ async function handle(req, res, url, ctx) {
|
|
|
59
112
|
return send(metricsFor(ctx, { ws: String(url.searchParams.get('ws') || ''), days }));
|
|
60
113
|
}
|
|
61
114
|
|
|
62
|
-
module.exports = { prefixes: ['/api/factory/metrics', '/api/factory'], handle, metricsFor, floorFor };
|
|
115
|
+
module.exports = { prefixes: ['/api/factory/metrics', '/api/factory', '/api/initiative-cost'], handle, metricsFor, floorFor, costFor };
|
|
@@ -157,6 +157,7 @@ function undoCore(ctx, p, g, id) {
|
|
|
157
157
|
// a new experiment the ✦ made goes from every list (the Board's own Delete: the record file stays, a restore brings it back)
|
|
158
158
|
else if (w.op === 'created') { r = RB.writeAs(ctx, '/api/boards/ini-delete', { ws: p.w.id, board: p.board.id, id: w.id }, g); }
|
|
159
159
|
else if (w.op === 'round') { const LR = require('./live-round.js'); LR.cancel(w.round); if (w.proposal) LR.dropCard(dir, w.proposal); back++; continue; } // a live round: its runs stop and its card goes
|
|
160
|
+
else if (w.op === 'pause') { const r2 = require('./initiative-cost.js').resume(dir, w.ini || k.ini, { by: (g.actor && g.actor.by) || 'pm', why: 'Undo' }); if (r2.ok) back++; else kept++; continue; } // initiative-cost: Undo starts its jobs again
|
|
160
161
|
else if (w.op === 'pr') { const r2 = require('./build-engine.js').close(p.w.root, w.item, { url: w.url }); if (r2.ok) back++; else kept++; continue; } // D108: Undo closes the pull request (the branch stays)
|
|
161
162
|
else if (w.op === 'verdict') {
|
|
162
163
|
// the PM's Undo of a verdict PMOS recorded by itself: the check is taken back (the outcome is due again, and Your move asks the PM),
|
|
@@ -383,6 +384,12 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
|
|
|
383
384
|
const pol = r.policy || null, guard = pol ? { verdict: pol.verdict, rules: (pol.reasons || []).map((y) => String(y.rule || '')).filter(Boolean).slice(0, 12), detail: String(pol.why || '').slice(0, 300) } : null;
|
|
384
385
|
if (r.ok) add({ op: 'pr', item: d.item, branch: d.branch, url: r.url || '', ...(guard ? { guard } : {}) });
|
|
385
386
|
else x.failed = r.error;
|
|
387
|
+
} else if (x.group === 'cost') {
|
|
388
|
+
// a stall: the factory spent 7 days on the initiative with no merge (lib/initiative-cost.js, A17). Class C: only the PM's ✓ reaches
|
|
389
|
+
// here. It pauses the initiative's NEW factory jobs; an item a Builder holds finishes. Undo starts them again
|
|
390
|
+
const r = require('./initiative-cost.js').pause(dirOf(ctx, p.w), ini, { by: (g.actor && g.actor.by) || 'pm', why: 'the ✦ pause proposal' });
|
|
391
|
+
if (r.ok && !r.already) add({ op: 'pause', ini });
|
|
392
|
+
else if (!r.ok) x.failed = r.error;
|
|
386
393
|
} else if (x.group === 'harness') {
|
|
387
394
|
// a failure the factory repeated (lib/factory-lessons.js). Class C: only the PM's ✓ reaches here. It adds a task for the PM with the
|
|
388
395
|
// evidence; the harness itself changes only through the PM's own reviewed pull request
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
/* sprint-cli.js — `pmos sprint`: the retro of a closed sprint and its one tracked change, the same block the past sprint view on Work ›
|
|
3
3
|
* Backlog shows (initiative sprint-retro-one-change). The store is lib/sprint-retro.js (_sprint-retro.jsonl beside the kept sprint history).
|
|
4
4
|
*
|
|
5
|
+
* pmos sprint now [--sprint "<name>"] [--ws <id>] [--json] the sprint running now: To do, In progress, Done and who holds what,
|
|
6
|
+
* the Summary card of Work › This sprint (asks the running PMOS)
|
|
5
7
|
* pmos sprint retro [--sprint "<name>"] [--json] the retro (default: the newest closed sprint PMOS kept)
|
|
6
8
|
* pmos sprint change --sprint "<name>" --pick <reason> | --drop | --undo the PM's override of the tracked change (the chat writes it)
|
|
7
9
|
* every command: [--root <dir>] (default: this repository)
|
|
@@ -12,16 +14,18 @@ const { execFileSync } = require('child_process');
|
|
|
12
14
|
const SR = require('./sprint-retro.js');
|
|
13
15
|
const SH = require('./sprint-history.js');
|
|
14
16
|
|
|
15
|
-
const COMMANDS = { sprint: ['retro', 'change'] };
|
|
17
|
+
const COMMANDS = { sprint: ['now', 'retro', 'change'] };
|
|
18
|
+
const SN = require('./sprint-now.js');
|
|
16
19
|
const REASONS = SR.REASONS.map((x) => x.reason);
|
|
17
20
|
const USAGE = [
|
|
18
|
-
'usage: pmos sprint retro|change — a closed sprint\'s retro
|
|
21
|
+
'usage: pmos sprint now|retro|change — the sprint running now, and a closed sprint\'s retro with its one tracked change',
|
|
22
|
+
' pmos sprint now [--sprint "<name>"] [--ws <id>] [--json] To do, In progress, Done and who holds what, as Work › This sprint shows it',
|
|
19
23
|
' pmos sprint retro [--sprint "<name>"] [--json] the retro (default: the newest closed sprint PMOS kept)',
|
|
20
24
|
' pmos sprint change --sprint "<name>" --pick <reason> track another change (reasons: ' + REASONS.join(', ') + ')',
|
|
21
25
|
' pmos sprint change --sprint "<name>" --drop | --undo track no change, or go back to PMOS\'s pick',
|
|
22
26
|
'Run it in the product\'s repository, or pass --root <dir>.',
|
|
23
27
|
];
|
|
24
|
-
const ALLOWED = { retro: ['json', 'root', 'sprint'], change: ['json', 'root', 'sprint', 'pick', 'drop', 'undo'] };
|
|
28
|
+
const ALLOWED = { now: ['json', 'sprint', 'ws'], retro: ['json', 'root', 'sprint'], change: ['json', 'root', 'sprint', 'pick', 'drop', 'undo'] };
|
|
25
29
|
const BOOL = new Set(['json', 'drop', 'undo']);
|
|
26
30
|
|
|
27
31
|
function parse(args) {
|
|
@@ -39,7 +43,7 @@ function repoRoot(cwd) {
|
|
|
39
43
|
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd() } = {}) {
|
|
46
|
+
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), call } = {}) {
|
|
43
47
|
const args = argv[0] === 'sprint' ? argv.slice(1) : argv.slice();
|
|
44
48
|
const sub = args[0];
|
|
45
49
|
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
@@ -47,6 +51,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd() } =
|
|
|
47
51
|
const { pos, flags } = parse(args.slice(1));
|
|
48
52
|
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos sprint ${sub}`); return 2; }
|
|
49
53
|
if (pos.length) { say(`✗ pmos sprint ${sub} takes options, not an argument (pmos sprint help)`); return 2; }
|
|
54
|
+
if (sub === 'now') return now(flags, { say, call });
|
|
50
55
|
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
51
56
|
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
52
57
|
const lines = SH.read(root);
|
|
@@ -76,4 +81,25 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd() } =
|
|
|
76
81
|
return 0;
|
|
77
82
|
}
|
|
78
83
|
|
|
84
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
85
|
+
const dayText = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
86
|
+
/** pmos sprint now: the Summary card of Work › This sprint, read from the running PMOS (GET /api/backlog sprintNow). Writes nothing. */
|
|
87
|
+
async function now(flags, { say, call }) {
|
|
88
|
+
const fail = (error) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return 1; };
|
|
89
|
+
if (typeof call !== 'function') return fail('no PMOS server answers: start PMOS, then ask again');
|
|
90
|
+
let r = null; try { r = await call('GET', '/api/backlog' + (flags.ws ? '?ws=' + encodeURIComponent(flags.ws) : '')); } catch { r = null; }
|
|
91
|
+
if (!r) return fail('no PMOS server answers: start PMOS, then ask again');
|
|
92
|
+
if (r.ok === false) return fail(r.error || 'PMOS could not read the backlog');
|
|
93
|
+
const L = Array.isArray(r.sprintNow) ? r.sprintNow : [];
|
|
94
|
+
const sp = flags.sprint ? L.find((x) => x.name === flags.sprint || x.label === flags.sprint) : L[0];
|
|
95
|
+
if (!sp) return fail(flags.sprint ? `no sprint named ${flags.sprint} is running now` : 'no sprint is running now. When Jira has one, its work and the tasks outside Jira in its dates show here');
|
|
96
|
+
const S = sp.summary || SN.summaryOf(sp.rows);
|
|
97
|
+
if (flags.json) { say(JSON.stringify({ ok: true, sprint: { name: sp.name, label: sp.label, start: sp.start, end: sp.end, jira: sp.jira, other: sp.other, summary: S } })); return 0; }
|
|
98
|
+
const unit = sp.other ? (S.all === 1 ? 'task' : 'tasks') : (S.all === 1 ? 'ticket' : 'tickets');
|
|
99
|
+
say([sp.label || sp.name, S.all + ' ' + unit, sp.end ? 'ends ' + dayText(sp.end) : ''].filter(Boolean).join(' · '));
|
|
100
|
+
say(`To do ${S.todo} · In progress ${S.doing} · Done ${S.done} of ${S.all}`);
|
|
101
|
+
const by = SN.byTextOf(S); if (by) say(by);
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
79
105
|
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* title }], projects: [Jira project key] (empty = every project), today: 'YYYY-MM-DD', me, pmName }
|
|
12
12
|
* row: { uid, id, src: jira|pmos, key, title, ini, iniTitle, who, state: To do|In progress|In review|Done, due, late (days), moved (other
|
|
13
13
|
* sprints the ticket was in), url, open (the row is in the Backlog's task list, so it opens as a task) }
|
|
14
|
+
* row.epic: { key, name, url } | null, the Jira ticket's epic; summary: summaryOf(rows), the Summary card's counts (board TbSprint)
|
|
14
15
|
* nextSprintOf(R, projects) → { name, label, start, end } | null the earliest future sprint (the Backlog pulls work into it)
|
|
15
16
|
*/
|
|
16
17
|
const BL = require('./backlog.js');
|
|
@@ -21,6 +22,23 @@ const str = (v, n) => String(v == null ? '' : v).slice(0, n);
|
|
|
21
22
|
const labelOf = (name) => { const m = /(sprint\s*\d+)\s*$/i.exec(String(name || '')); return m ? m[1].replace(/^s/, 'S') : String(name || ''); };
|
|
22
23
|
const stateOfJira = (rd) => (rd.category === 'done' ? 'Done' : rd.category === 'doing' ? (/review/i.test(rd.status || '') ? 'In review' : 'In progress') : 'To do');
|
|
23
24
|
const OPEN = new Set(['To do', 'In progress', 'In review']);
|
|
25
|
+
/** The Jira link of another key on the same site as a reading's link: https://x.atlassian.net/browse/A-1 → …/browse/<key>. */
|
|
26
|
+
const urlOf = (key, rd) => { const m = /^(https:\/\/[^/]+\/browse\/)[A-Z][A-Z0-9_]*-\d+$/i.exec(String((rd && rd.url) || '')); return m ? m[1] + String(key).toUpperCase() : null; };
|
|
27
|
+
const tabOf = (state) => (state === 'Done' ? 'done' : state === 'To do' ? 'todo' : 'doing');
|
|
28
|
+
/** The sprint in three counts and who holds what (board TbSprint, Summary): { todo, doing, done, all, by: [{ who, todo, doing, open }] }.
|
|
29
|
+
* by: the holders of open work, most first; work with no owner is one entry with who '' (no one), last. Done work is in no one's hands. */
|
|
30
|
+
function summaryOf(rows) {
|
|
31
|
+
const s = { todo: 0, doing: 0, done: 0, all: 0, by: [] }, m = new Map();
|
|
32
|
+
for (const r of rows || []) {
|
|
33
|
+
const k = tabOf(r.state); s[k]++; s.all++;
|
|
34
|
+
if (k === 'done') continue;
|
|
35
|
+
const w = String(r.who || '');
|
|
36
|
+
if (!m.has(w)) m.set(w, { who: w, todo: 0, doing: 0, open: 0 });
|
|
37
|
+
const e = m.get(w); e[k]++; e.open++;
|
|
38
|
+
}
|
|
39
|
+
s.by = [...m.values()].sort((a, b) => (!a.who) - (!b.who) || b.open - a.open || a.who.localeCompare(b.who));
|
|
40
|
+
return s;
|
|
41
|
+
}
|
|
24
42
|
|
|
25
43
|
function sprintsNowOf(I) {
|
|
26
44
|
const R = I.R instanceof Map ? I.R : new Map();
|
|
@@ -35,6 +53,16 @@ function sprintsNowOf(I) {
|
|
|
35
53
|
if (/^(pm|you|me)$/i.test(o) || /^pm:/i.test(o) || (me && o.toLowerCase() === me)) return I.pmName || 'You';
|
|
36
54
|
return BL.firstName(o);
|
|
37
55
|
};
|
|
56
|
+
// the ticket's epic: the Backlog task's own, else the parent the reading names (lib/jira-status.js parent, parentName); its name from
|
|
57
|
+
// the epic's own reading when there is one. A parent that is not an epic (a sub-task's story) is not an epic.
|
|
58
|
+
const epicOf = (t, rd) => {
|
|
59
|
+
if (t && t.epic && t.epic.key) return { key: str(t.epic.key, 40), name: str(t.epic.name, 120), url: urlOf(t.epic.key, rd) };
|
|
60
|
+
const k = rd && rd.parent ? String(rd.parent).toUpperCase() : '';
|
|
61
|
+
if (!k) return null;
|
|
62
|
+
const p = R.get(k);
|
|
63
|
+
if (p && p.type && !/^epic$/i.test(p.type)) return null;
|
|
64
|
+
return { key: str(k, 40), name: str((p && p.summary) || rd.parentName || '', 120), url: urlOf(k, rd) };
|
|
65
|
+
};
|
|
38
66
|
const lateOf = (due, state) => { const d = dayNum(due); return d != null && t0 != null && d < t0 && OPEN.has(state) ? t0 - d : 0; };
|
|
39
67
|
const by = new Map();
|
|
40
68
|
for (const rd of R.values()) {
|
|
@@ -51,8 +79,9 @@ function sprintsNowOf(I) {
|
|
|
51
79
|
const ini = t ? t.ini : null;
|
|
52
80
|
const moved = Array.isArray(rd.sprints) ? rd.sprints.filter((s) => s && s.name && s.name !== name).length : 0;
|
|
53
81
|
const due = t ? t.due : null;
|
|
82
|
+
const epic = epicOf(t, rd);
|
|
54
83
|
sp.rows.push({ uid: t ? t.ws + '|' + t.board + '|' + t.id : key, id: key, src: 'jira', key, title: str((t && t.title) || rd.summary || key, 300), ini, iniTitle: ini && iniBy.has(ini) ? str(iniBy.get(ini).title, 160) : '',
|
|
55
|
-
who: t ? t.who : whoOf(rd.assignee), state, due, late: lateOf(due, state), moved, url: (t && t.url) || rd.url || null, open: !!t });
|
|
84
|
+
who: t ? t.who : whoOf(rd.assignee), state, due, late: lateOf(due, state), moved, url: (t && t.url) || rd.url || null, open: !!t, epic });
|
|
56
85
|
}
|
|
57
86
|
for (const sp of by.values()) {
|
|
58
87
|
const s = dayNum(sp.start), e = dayNum(sp.end);
|
|
@@ -68,12 +97,12 @@ function sprintsNowOf(I) {
|
|
|
68
97
|
const state = w.status === 'Done' ? 'Done' : OPEN.has(w.status) ? w.status : 'To do';
|
|
69
98
|
const ini = iniBy.has(w.ini) ? w.ini : null;
|
|
70
99
|
sp.rows.push({ uid: t ? t.ws + '|' + t.board + '|' + t.id : id, id, src: 'pmos', key: '', title: str(w.title, 300), ini, iniTitle: ini ? str(iniBy.get(ini).title, 160) : '',
|
|
71
|
-
who: t ? t.who : whoOf(w.owner), state, due: w.end || null, late: lateOf(w.end, state), moved: 0, url: null, open: !!t });
|
|
100
|
+
who: t ? t.who : whoOf(w.owner), state, due: w.end || null, late: lateOf(w.end, state), moved: 0, url: null, open: !!t, epic: null });
|
|
72
101
|
}
|
|
73
102
|
}
|
|
74
103
|
return [...by.values()].map((sp) => {
|
|
75
104
|
const jira = sp.rows.filter((r) => r.src === 'jira').length;
|
|
76
|
-
return { ...sp, jira, other: sp.rows.length - jira, done: sp.rows.filter((r) => r.state === 'Done').length, total: sp.rows.length };
|
|
105
|
+
return { ...sp, jira, other: sp.rows.length - jira, done: sp.rows.filter((r) => r.state === 'Done').length, total: sp.rows.length, summary: summaryOf(sp.rows) };
|
|
77
106
|
}).sort((a, b) => b.total - a.total || a.name.localeCompare(b.name));
|
|
78
107
|
}
|
|
79
108
|
|
|
@@ -93,4 +122,10 @@ function nextSprintOf(R, projects) {
|
|
|
93
122
|
return [...by.values()].sort((a, b) => (a.start || '9999').localeCompare(b.start || '9999') || a.name.localeCompare(b.name))[0] || null;
|
|
94
123
|
}
|
|
95
124
|
|
|
96
|
-
|
|
125
|
+
/** "By person: Wawan 4 to do · Suhas 1 to do, 1 in progress · no one 5"; '' when nobody holds open work (pm/bd-sprint-ds.js byText too). */
|
|
126
|
+
function byTextOf(S) {
|
|
127
|
+
const one = (e) => (e.who ? [e.todo ? e.todo + ' to do' : '', e.doing ? e.doing + ' in progress' : ''].filter(Boolean).join(', ') : String(e.open));
|
|
128
|
+
return S && S.by && S.by.length ? 'By person: ' + S.by.map((e) => (e.who || 'no one') + ' ' + one(e)).join(' · ') : '';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = { sprintsNowOf, nextSprintOf, labelOf, summaryOf, byTextOf };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.844.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.844.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -14,7 +14,7 @@ import { canEdit } from './inline-fields.js'; // a task's sprint and priority,
|
|
|
14
14
|
|
|
15
15
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
16
16
|
const SV = (d, n = 16) => `<svg class="pm-ic" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
17
|
-
const I = { star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M7 10l5 5 5-5',
|
|
17
|
+
const I = { out: 'M14 5h5v5M19 5l-8 8M17 14v5H5V7h5', star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M7 10l5 5 5-5',
|
|
18
18
|
sprint: 'M4 12h11M11 8l4 4-4 4M19 6v12', flag: 'M6 21V4M6 4h11l-2 4 2 4H6' };
|
|
19
19
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
20
20
|
const DAY = 864e5;
|
|
@@ -191,6 +191,26 @@ export function captureOf(line, inis) {
|
|
|
191
191
|
return { title: text, ini: null };
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/** A Jira link of another key on the same site as a task's own link (…/browse/A-1 → …/browse/<key>); null when the task has none. */
|
|
195
|
+
const linkOf = (key, url) => { const m = /^(https:\/\/[^/]+\/browse\/)[A-Z][A-Z0-9_]*-\d+$/i.exec(String(url || '')); return m ? m[1] + String(key).toUpperCase() : null; };
|
|
196
|
+
/** The Ticket cell (board TbBacklog): the Jira key, a link to the ticket; a task outside Jira says so. */
|
|
197
|
+
export function ticketHtml(t) {
|
|
198
|
+
if (!t.key) return '<span class="pm-chip">Not in Jira</span>';
|
|
199
|
+
return t.url ? `<a class="pm-meta code wk-tk" href="${esc(t.url)}" target="_blank" rel="noopener" data-splink title="Open ${esc(t.key)} in Jira">${esc(t.key)}${SV(I.out, 12)}</a>` : `<span class="pm-meta code">${esc(t.key)}</span>`;
|
|
200
|
+
}
|
|
201
|
+
/** The epic most of a group's tickets sit under (board TbBacklog: on the initiative's group line), with a link when a ticket has one. */
|
|
202
|
+
export function epicOfGroup(rows) {
|
|
203
|
+
const m = new Map();
|
|
204
|
+
for (const t of rows || []) if (t.epic && t.epic.key) { const e = m.get(t.epic.key) || { key: t.epic.key, name: t.epic.name || '', url: linkOf(t.epic.key, t.url), n: 0 }; e.n++; if (!e.url) e.url = linkOf(t.epic.key, t.url); m.set(t.epic.key, e); }
|
|
205
|
+
return [...m.values()].sort((a, b) => b.n - a.n || a.key.localeCompare(b.key))[0] || null;
|
|
206
|
+
}
|
|
207
|
+
/** The epic as a link: its key and name; '' with no epic. */
|
|
208
|
+
export function epicHtml(e) {
|
|
209
|
+
if (!e || !e.key) return '';
|
|
210
|
+
const inner = `<b class="code">${esc(e.key)}</b>${e.name ? ' ' + esc(e.name) : ''}`;
|
|
211
|
+
return e.url ? ` <a class="wk-ep" href="${esc(e.url)}" target="_blank" rel="noopener" data-splink title="Open epic ${esc(e.key)} in Jira">${inner}</a>` : ` <span class="wk-ep">${inner}</span>`;
|
|
212
|
+
}
|
|
213
|
+
|
|
194
214
|
/** The Backlog block. o: { tab, group, menu, today, rank (number by id), sel: Set of uids, picking, act(t) → the row's action html,
|
|
195
215
|
* stateOf(t) → { text, tone } for PMOS's own states, groupsPmos(rows) → [{ k, n, rows, yes }], mode (the kind-of-work line's html) } */
|
|
196
216
|
export function tableHtml(order, o = {}) {
|
|
@@ -213,9 +233,9 @@ export function tableHtml(order, o = {}) {
|
|
|
213
233
|
for (const g of G) { const e = whole.get(g.k); g.sub = `${plural(e.n, 'item', 'items')} · ${e.r} ready`; }
|
|
214
234
|
}
|
|
215
235
|
const drag = group !== 'pmos';
|
|
216
|
-
const body = G.map((g) => (g.n ? `<tr class="wk-g"><td colspan="7"><div class="pm-group"><b>${esc(g.n)}</b>${g.sub ? ` <span class="pm-meta">${esc(g.sub)}</span>` : ''}${g.yes || ''}</div></td></tr>` : '')
|
|
236
|
+
const body = G.map((g) => (g.n ? `<tr class="wk-g"><td colspan="7"><div class="pm-group"><b>${esc(g.n)}</b>${g.sub ? ` <span class="pm-meta">${esc(g.sub)}</span>` : ''}${group === 'ini' ? epicHtml(epicOfGroup(g.rows)) : ''}${g.yes || ''}</div></td></tr>` : '')
|
|
217
237
|
+ g.rows.map((t) => rowHtml(t, o, drag)).join('')).join('');
|
|
218
|
-
const table = R.length ? `<table class="pm-table wk-bkt${o.picking ? ' picking' : ''}"><thead><tr><th class="wk-rk">Rank</th><th>Item</th><th>Who</th><th>State</th><th>
|
|
238
|
+
const table = R.length ? `<table class="pm-table wk-bkt${o.picking ? ' picking' : ''}"><thead><tr><th class="wk-rk">Rank</th><th>Item</th><th>Who</th><th>State</th><th>Ticket</th><th>Last change</th><th class="wk-ac" aria-label="Actions"></th></tr></thead><tbody>${body}</tbody></table>`
|
|
219
239
|
: `<p class="pm-meta">${order.length ? 'Nothing here.' : 'Nothing waits outside the sprint.'}</p>`;
|
|
220
240
|
const foot = R.length && drag ? '<p class="pm-meta">Drag a row to change its rank. The rank is one list across initiatives; groups only show where each item belongs.</p>' : '';
|
|
221
241
|
return `<section class="pm-block wk-blk wk-bk" aria-label="Backlog"><div class="head"><h2 class="pm-h">Backlog</h2><span class="sp"></span>${tabs}${menu}${tune}</div>${cap}${o.above || ''}${o.said || ''}${table}${foot}${o.mode || ''}</section>`;
|
|
@@ -226,7 +246,7 @@ function rowHtml(t, o, drag) {
|
|
|
226
246
|
const who = pmosHas(t) ? '<span class="pm-star">✦</span> PMOS' : t.who ? esc(t.who) : '<span class="pm-meta">no one</span>';
|
|
227
247
|
const ps = o.stateOf ? o.stateOf(t) : null;
|
|
228
248
|
const state = ps ? `<span class="pm-badge${ps.tone === 'late' ? ' alert' : ' blue'}" title="${esc(ps.title || ps.text)}">${esc(ps.text)}</span>` : `<span class="pm-badge${ready ? ' blue' : ''}">${ready ? 'Ready' : 'Needs detail'}</span>`;
|
|
229
|
-
const src =
|
|
249
|
+
const src = ticketHtml(t);
|
|
230
250
|
const n = o.rank ? o.rank.get(t.id) : null;
|
|
231
251
|
// Sprint and Priority in the row (inline-sprint-priority): an open PMOS task only, when the page wires them (o.inline); a set priority shows
|
|
232
252
|
const ib = (attr, label, d) => `<button type="button" class="pm-btn" ${attr}="${esc(u)}" aria-haspopup="menu" aria-label="${esc(label)}" title="${esc(label)}">${SV(d, 14)}</button>`;
|
|
@@ -350,3 +350,6 @@ textarea.bk-rvl-ed, .bk-rvl textarea.bd { resize: vertical; min-height: 180px; }
|
|
|
350
350
|
.fx-sheet .fx-fold summary { cursor: pointer; padding: 6px 0; font-size: var(--fs-meta); color: var(--muted); }
|
|
351
351
|
.fx-sheet .ff-undo { all: unset; box-sizing: border-box; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-md); cursor: pointer; }
|
|
352
352
|
.fx-sheet .ff-undo:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
|
|
353
|
+
/* Work › Cost (initiative-cost, A17): a stalled initiative's result, and the ✦ line under the table */
|
|
354
|
+
.ic-alert { color: var(--alert); }
|
|
355
|
+
.ic-ask { margin-top: var(--space-8); }
|
|
@@ -26,6 +26,7 @@ import * as TWV from './team-waits.js'; // team-waits (A364): Work › Depende
|
|
|
26
26
|
import * as TSV from './team-slips.js'; // team-slips (A15): Upstream on Work › Dependencies, other teams' slips (GET /api/team-slips)
|
|
27
27
|
import * as LV from './line-view.js'; // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
|
|
28
28
|
import * as FV from './factory.js'; // Work › Factory (factory-page-ui): the stations and the work they make, from GET /api/factory
|
|
29
|
+
import * as IC from './initiative-cost.js'; // Work › Cost (initiative-cost, A17): what the factory spent per initiative, from GET /api/initiative-cost
|
|
29
30
|
import * as LB from './list-balance.js'; // the balance meter under the Backlog header (bet A448, board BalanceDS) // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
|
|
30
31
|
import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
|
|
31
32
|
|
|
@@ -73,10 +74,11 @@ export function tabOf() {
|
|
|
73
74
|
if (q === 'sprint') return 'sp';
|
|
74
75
|
if (q === 'line') return 'ln';
|
|
75
76
|
if (q === 'factory') return 'fx';
|
|
77
|
+
if (q === 'cost') return 'co';
|
|
76
78
|
if (q === 'deps') return 'dp';
|
|
77
79
|
if (q === 'initiatives') return 'ini';
|
|
78
80
|
const v = (get(KEY, {}) || {})[scopeKey()];
|
|
79
|
-
return v === 'bk' || v === 'sp' || v === 'ln' || v === 'fx' || v === 'dp' ? v : 'ini';
|
|
81
|
+
return v === 'bk' || v === 'sp' || v === 'ln' || v === 'fx' || v === 'dp' || v === 'co' ? v : 'ini';
|
|
80
82
|
}
|
|
81
83
|
/** Is a task tab (Backlog or This sprint) the view now? */
|
|
82
84
|
export const on = () => tabOf() === 'bk' || tabOf() === 'sp';
|
|
@@ -86,6 +88,8 @@ export const lineOn = () => tabOf() === 'ln';
|
|
|
86
88
|
export const factoryOn = () => tabOf() === 'fx';
|
|
87
89
|
/** Is the Dependencies tab the view now? (team-waits) */
|
|
88
90
|
export const depsOn = () => tabOf() === 'dp';
|
|
91
|
+
/** Is the Cost tab the view now? (initiative-cost) */
|
|
92
|
+
export const costOn = () => tabOf() === 'co';
|
|
89
93
|
function setOn(v) {
|
|
90
94
|
v = v === true ? 'bk' : v === false ? 'ini' : v;
|
|
91
95
|
const m = get(KEY, {}) || {}; m[scopeKey()] = v; put(KEY, m);
|
|
@@ -137,7 +141,8 @@ export async function load() {
|
|
|
137
141
|
// the Line (quiet-rows-line) is a five-column table for a desk; a phone keeps its three tabs (Today's dashed line is desk-only too)
|
|
138
142
|
// the Factory (factory-page-ui) sits beside Line, a desk's too: its tiles are a row of five
|
|
139
143
|
// Dependencies (team-waits) is a desk tab as well: a phone keeps its three
|
|
140
|
-
|
|
144
|
+
// the Cost tab (initiative-cost) shows on a desk only while some factory spent on the pick (zero is silence)
|
|
145
|
+
export const tabNames = (phone, n, cost = false) => [['ini', 'Initiatives'], ...(phone ? [] : [['ln', 'Line'], ['fx', 'Factory']]), ['bk', 'Backlog' + (phone && n > 0 ? ` <span class="bk-swn">${Number(n)}</span>` : '')], ['sp', phone ? 'Sprint' : 'This sprint'], ...(phone ? [] : [['dp', 'Dependencies']]), ...(!phone && cost ? [['co', 'Cost']] : [])];
|
|
141
146
|
const phoneNow = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
|
|
142
147
|
function drawSwitch() {
|
|
143
148
|
if (!sw) return;
|
|
@@ -145,22 +150,45 @@ function drawSwitch() {
|
|
|
145
150
|
// one Tabs part for the three (WorkDS); no count on a desk tab: Where it stands says what matters (say it once).
|
|
146
151
|
// A phone (PhoneWorkDS, job 1540) has no Where it stands over the Backlog, so its tab carries the count, and the short name "Sprint"
|
|
147
152
|
const ph = phoneNow();
|
|
148
|
-
sw.innerHTML = tabNames(ph, ph && DATA ? backlogOf().length : 0).map(([k, n]) => tb(k, n)).join('');
|
|
153
|
+
sw.innerHTML = tabNames(ph, ph && DATA ? backlogOf().length : 0, IC.hasSpend(costScoped()) || t === 'co').map(([k, n]) => tb(k, n)).join('');
|
|
149
154
|
}
|
|
150
155
|
function apply() {
|
|
151
|
-
const bk = on(), ln = lineOn(), fx = factoryOn(), dp = depsOn();
|
|
156
|
+
const bk = on(), ln = lineOn(), fx = factoryOn(), dp = depsOn(), co = costOn();
|
|
152
157
|
if (tabOf() === 'sp') CHIPS.add('sprint');
|
|
153
158
|
document.body.classList.toggle('sp-on', tabOf() === 'sp');
|
|
154
|
-
document.body.classList.toggle('bk-on', bk || ln || fx || dp);
|
|
155
|
-
if (host) host.hidden = !(bk || ln || fx || dp);
|
|
159
|
+
document.body.classList.toggle('bk-on', bk || ln || fx || dp || co);
|
|
160
|
+
if (host) host.hidden = !(bk || ln || fx || dp || co);
|
|
156
161
|
drawSwitch();
|
|
157
162
|
if (ln) { closeAll(); drawLine(); return; }
|
|
158
163
|
if (fx) { closeAll(); drawFactory(); return; }
|
|
159
164
|
if (dp) { closeAll(); drawDeps(); return; }
|
|
165
|
+
if (co) { closeAll(); drawCost(); return; }
|
|
160
166
|
if (bk) { if (!DATA || scopeKey() !== lastScope) { lastScope = scopeKey(); host.innerHTML = '<p class="bk-wait">Reading the tasks…</p>'; load(); } else draw(); }
|
|
161
167
|
else closeAll();
|
|
162
168
|
}
|
|
163
169
|
|
|
170
|
+
/* ── the Cost tab (initiative-cost, board BatchReleaseDS panel 21) ── what the factory spent per initiative, from GET /api/initiative-cost ── */
|
|
171
|
+
const CO = { used: false, undone: new Set() };
|
|
172
|
+
/** The products of the pick, as the Cost read has them. */
|
|
173
|
+
function costScoped() {
|
|
174
|
+
const got = IC.cached() || [];
|
|
175
|
+
if (!A) return got;
|
|
176
|
+
const ws = new Set(A.scope().map((x) => x.ws || ''));
|
|
177
|
+
return ws.has('') ? got : got.filter((p) => ws.has(p.ws));
|
|
178
|
+
}
|
|
179
|
+
function drawCost() {
|
|
180
|
+
if (!host) return;
|
|
181
|
+
if (!CO.used) { CO.used = true; noteUse('costOpen'); console.info('[initiative-cost] cost tab opened'); }
|
|
182
|
+
if (!IC.cached()) { host.innerHTML = '<p class="bk-wait">Reading the cost…</p>'; IC.load().then(() => { if (costOn()) drawCost(); }); return; }
|
|
183
|
+
host.innerHTML = IC.tabHtml(costScoped(), { undone: CO.undone });
|
|
184
|
+
IC.load().then(() => { if (costOn()) host.innerHTML = IC.tabHtml(costScoped(), { undone: CO.undone }); }); // a read older than a minute comes again
|
|
185
|
+
}
|
|
186
|
+
/** A press in the Cost tab: Pause (with Undo), Keep going, Resume, or a name (opens the initiative). true when it was one. */
|
|
187
|
+
function costPress(e) {
|
|
188
|
+
if (!costOn()) return false;
|
|
189
|
+
return IC.press(e, { post: (u, b) => AP().post(u, b).catch(() => null), say: (m, undo) => (A.say ? A.say(m, undo) : null), redraw: () => { if (costOn()) drawCost(); }, open: (id, ws) => (A.openIni ? A.openIni(id, ws) : null), undone: CO.undone });
|
|
190
|
+
}
|
|
191
|
+
|
|
164
192
|
/* ── the Line tab (quiet-rows slice B, board QuietLine) ── every live initiative of the pick by station, from GET /api/line ── */
|
|
165
193
|
const LN = { tab: '', got: null, key: '', used: false };
|
|
166
194
|
async function readLine() {
|
|
@@ -914,7 +942,8 @@ export function sync(api) {
|
|
|
914
942
|
sw.addEventListener('click', (e) => { const b = e.target.closest('[data-bksw]'); if (b) setOn(b.dataset.bksw); });
|
|
915
943
|
host = document.createElement('div'); host.id = 'bkBody'; host.className = 'bk-host'; host.hidden = true;
|
|
916
944
|
ib.insertAdjacentElement('afterend', host);
|
|
917
|
-
host.addEventListener('click', (e) => { if (linePress(e) || factoryPress(e) || depsPress(e)) return; press(e); });
|
|
945
|
+
host.addEventListener('click', (e) => { if (linePress(e) || factoryPress(e) || depsPress(e) || costPress(e)) return; press(e); });
|
|
946
|
+
IC.load().then(() => drawSwitch()); // the Cost tab shows only when some factory spent (initiative-cost)
|
|
918
947
|
host.addEventListener('change', (e) => { if (e.target.closest('[data-bkck]')) press(e); });
|
|
919
948
|
host.addEventListener('keydown', (e) => { const c = e.target.closest('[data-bkcap]'); if (c && e.key === 'Enter') { e.preventDefault(); capture(c); } });
|
|
920
949
|
dragWire();
|