create-pmos 0.629.0 → 0.631.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 +27 -27
- 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 +26 -0
- package/workspace/guide/backlog.md +3 -1
- package/workspace/guide/cli.md +2 -0
- package/workspace/guide/jira.md +13 -0
- package/workspace/lib/backlog.js +15 -4
- package/workspace/lib/engine/boards.js +16 -0
- package/workspace/lib/jira-cli.js +23 -2
- package/workspace/lib/jira-status.js +64 -20
- package/workspace/lib/routes-backlog.js +37 -5
- package/workspace/lib/routes-board-publish.js +1 -1
- package/workspace/lib/routes-boards.js +4 -1
- package/workspace/lib/routes-sources.js +8 -1
- package/workspace/lib/sprint-history.js +294 -0
- package/workspace/lib/sprint-overview.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog.css +38 -0
- package/workspace/public/pm/bd-backlog.js +14 -8
- package/workspace/public/pm/bd-sprint.js +174 -7
- package/workspace/public/pm/bk-model.js +3 -2
- package/workspace/public/pm/bk-sprint.js +42 -0
- package/workspace/skills/jira-sync.skill +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.631.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": {
|
|
@@ -33,6 +33,32 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.631.0",
|
|
38
|
+
"at": "2026-11-19T11:03:25.147Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1412,
|
|
43
|
+
"t": "Keep a snapshot of every past sprint, with a sprint picker on the Backlog",
|
|
44
|
+
"s": "Keep a snapshot of every past sprint, with a sprint picker on the Backlog",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"v": "0.630.0",
|
|
51
|
+
"at": "2026-11-19T08:05:45.827Z",
|
|
52
|
+
"f": 4,
|
|
53
|
+
"prs": [
|
|
54
|
+
{
|
|
55
|
+
"n": 1411,
|
|
56
|
+
"t": "Backlog shows names not ids, the product's name, and no empty columns",
|
|
57
|
+
"s": "Backlog shows names not ids, the product's name, and no empty columns",
|
|
58
|
+
"k": "fix"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
36
62
|
{
|
|
37
63
|
"v": "0.629.0",
|
|
38
64
|
"at": "2026-11-19T07:37:18.343Z",
|
|
@@ -428,32 +454,6 @@
|
|
|
428
454
|
"k": "new"
|
|
429
455
|
}
|
|
430
456
|
]
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
"v": "0.609.0",
|
|
434
|
-
"at": "2026-11-18T14:50:56.888Z",
|
|
435
|
-
"f": 4,
|
|
436
|
-
"prs": [
|
|
437
|
-
{
|
|
438
|
-
"n": 1357,
|
|
439
|
-
"t": "No Specimens line or prototype file once every version is deleted",
|
|
440
|
-
"s": "No Specimens line or prototype file once every version is deleted",
|
|
441
|
-
"k": "fix"
|
|
442
|
-
}
|
|
443
|
-
]
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
"v": "0.608.0",
|
|
447
|
-
"at": "2026-11-18T14:38:04.592Z",
|
|
448
|
-
"f": 4,
|
|
449
|
-
"prs": [
|
|
450
|
-
{
|
|
451
|
-
"n": 1356,
|
|
452
|
-
"t": "Prototype rules: each correction becomes a check before a version opens",
|
|
453
|
-
"s": "Prototype rules: each correction becomes a check before a version opens",
|
|
454
|
-
"k": "new"
|
|
455
|
-
}
|
|
456
|
-
]
|
|
457
457
|
}
|
|
458
458
|
]
|
|
459
459
|
}
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-19T11:03:21Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-19T11:03:21Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-19T11:03:21Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.631.0",
|
|
4
|
+
"at": "2026-11-19T11:03:25.147Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1412,
|
|
9
|
+
"t": "Keep a snapshot of every past sprint, with a sprint picker on the Backlog",
|
|
10
|
+
"s": "Keep a snapshot of every past sprint, with a sprint picker on the Backlog",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.630.0",
|
|
17
|
+
"at": "2026-11-19T08:05:45.827Z",
|
|
18
|
+
"f": 4,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1411,
|
|
22
|
+
"t": "Backlog shows names not ids, the product's name, and no empty columns",
|
|
23
|
+
"s": "Backlog shows names not ids, the product's name, and no empty columns",
|
|
24
|
+
"k": "fix"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"v": "0.629.0",
|
|
4
30
|
"at": "2026-11-19T07:37:18.343Z",
|
|
@@ -24,9 +24,11 @@ On a phone the switch has its own line above the list. PMOS remembers your choic
|
|
|
24
24
|
| Jira ticket | The key, when the task is a Jira ticket. |
|
|
25
25
|
| Epic | The epic of the Jira ticket, or **No epic**. |
|
|
26
26
|
| Initiative | The initiative that holds the task. In No home it is empty, or it shows ✦ the initiative PMOS proposes. |
|
|
27
|
-
| Who | The task owner, else the Jira assignee. When PMOS has the task, it shows **PMOS**. |
|
|
27
|
+
| Who | The first name of the task owner, else of the Jira assignee. Your own tasks show your name. When PMOS has the task, it shows **PMOS**. When the owner is an id and not a name, Who is empty and the task is in **Nobody has these**. |
|
|
28
28
|
| State | The state, how late the task is, and what PMOS does or why the task waits for you. |
|
|
29
29
|
|
|
30
|
+
When no task in the list has a Jira ticket, the **Jira ticket** column does not show. When no task has an epic, the **Epic** column does not show.
|
|
31
|
+
|
|
30
32
|
## The groups
|
|
31
33
|
|
|
32
34
|
The groups show in this order. An empty group does not show.
|
package/workspace/guide/cli.md
CHANGED
|
@@ -603,6 +603,8 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
|
|
|
603
603
|
- `pmos jira sync <initiative> --from <file|-> [--query "<jql>"] [--dry-run]`
|
|
604
604
|
- `pmos jira query --sprints`
|
|
605
605
|
- `pmos jira sync --sprints --from <file|-> [--query "<jql>"] [--dry-run]`
|
|
606
|
+
- `pmos jira query --sprint "<name>"`
|
|
607
|
+
- `pmos jira sync --sprint "<name>" --from <file|-> [--dry-run]`
|
|
606
608
|
- `pmos jira summary [--from <file|->] [--dry-run]`
|
|
607
609
|
- `pmos jira which <KEY>`
|
|
608
610
|
- `pmos jira moves`
|
package/workspace/guide/jira.md
CHANGED
|
@@ -165,6 +165,19 @@ pmos jira query --sprints
|
|
|
165
165
|
pmos jira sync --sprints --from <file|-> [--query "<jql>"]
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
+
## Past sprints keep every ticket
|
|
169
|
+
|
|
170
|
+
Each sprint read also goes to an append-only history, `<state>/tracker/jira/_sprint-history.jsonl`. It has one line for each sprint at each read, written only when something changed. A ticket that Jira carried from one sprint to the next stays in both sprints. When a sprint closes, the first read after the close freezes it: later reads add nothing to it. PMOS counts the close numbers itself from this record (done, total, carried in, carried to the next sprint, points). The agent does not count them.
|
|
171
|
+
|
|
172
|
+
The read also asks for the open sprints of the tickets' Jira projects, and for the closed sprints whose tickets changed in the last 21 days. Thus a sprint that opened and closed between two reads is still kept.
|
|
173
|
+
|
|
174
|
+
On Work › Backlog › This sprint, the sprint's name is a picker. Pick a past sprint to see its snapshot and its tickets as they were at close. To keep a sprint that PMOS never saw, press the read icon on it. PMOS then reads that sprint from Jira:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
pmos jira query --sprint "<name>"
|
|
178
|
+
pmos jira sync --sprint "<name>" --from <file|->
|
|
179
|
+
```
|
|
180
|
+
|
|
168
181
|
## Each sprint's goal and summary
|
|
169
182
|
|
|
170
183
|
The check then writes a goal and a short summary for each sprint, from the tickets it read. The Sprints tab shows them above the sprint's items, with one row for each group of related work.
|
package/workspace/lib/backlog.js
CHANGED
|
@@ -51,6 +51,13 @@ const OPEN = new Set(['To do', 'In progress', 'In review']);
|
|
|
51
51
|
const DAY = 864e5;
|
|
52
52
|
const JIRA_KEY = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
53
53
|
const ME = /^(pm|you|me|wawan)$/i;
|
|
54
|
+
/** A person's first name, or '' when the text is an id and not a name ("557058:4f2a…", "pm:root", "u_12ab", an email, a uuid). */
|
|
55
|
+
function firstName(v) {
|
|
56
|
+
const t = String(v == null ? '' : v).trim();
|
|
57
|
+
if (!t || /[:@\/]/.test(t) || /\d/.test(t) || !/\p{L}/u.test(t)) return '';
|
|
58
|
+
const w = t.split(/\s+/)[0];
|
|
59
|
+
return /^[\p{L}][\p{L}'.-]*$/u.test(w) ? w.slice(0, 40) : '';
|
|
60
|
+
}
|
|
54
61
|
|
|
55
62
|
const str = (v, n = 200) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
56
63
|
const dayNum = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) / DAY : null; };
|
|
@@ -255,11 +262,15 @@ function tasksOf(input) {
|
|
|
255
262
|
const G = I.gives instanceof Map ? I.gives : new Map(), RT = I.runTasks instanceof Map ? I.runTasks : new Map();
|
|
256
263
|
const me = str(I.me, 80).toLowerCase();
|
|
257
264
|
const out = [], seen = new Set();
|
|
265
|
+
const pmName = firstName(I.pmName);
|
|
266
|
+
// names, not ids (audit round 4): the PM ("pm", "pm:<slug>", their slug) by their own first name, else "You"; a person by first name;
|
|
267
|
+
// an owner PMOS cannot read as a name (an account id, a key) is nobody, so the task counts under "Nobody has these"
|
|
258
268
|
const whoOf = (owner) => {
|
|
259
|
-
const o = str(owner, 80);
|
|
269
|
+
const o = str(owner, 80).replace(/^(?:person|tracker):/, '').trim();
|
|
260
270
|
if (!o) return { who: '', whoKind: 'none' };
|
|
261
|
-
if (ME.test(o) || (me && o.toLowerCase() === me)) return { who: 'You', whoKind: 'pm' };
|
|
262
|
-
|
|
271
|
+
if (ME.test(o) || /^pm:/i.test(o) || (me && o.toLowerCase() === me)) return { who: pmName || 'You', whoKind: 'pm' };
|
|
272
|
+
const n = firstName(o);
|
|
273
|
+
return n ? { who: n, whoKind: 'person' } : { who: '', whoKind: 'none' };
|
|
263
274
|
};
|
|
264
275
|
const epicOf = (key) => {
|
|
265
276
|
if (!key) return null;
|
|
@@ -320,4 +331,4 @@ function tasksOf(input) {
|
|
|
320
331
|
return out;
|
|
321
332
|
}
|
|
322
333
|
|
|
323
|
-
module.exports = { KINDS, MODE_LABEL, GUARDS, modeOf, countKinds, takeOf, reviewWhy, guardOf, filesOf, messageTo, docTo, agentOf, foldGives, runTaskId, proposeHome, tasksOf, keyOf };
|
|
334
|
+
module.exports = { KINDS, MODE_LABEL, GUARDS, modeOf, countKinds, takeOf, reviewWhy, guardOf, filesOf, messageTo, docTo, agentOf, foldGives, runTaskId, proposeHome, tasksOf, keyOf, firstName };
|
|
@@ -814,6 +814,22 @@ function sprintsOf(snapshots, onBoard = () => true, whole = null, notes = null,
|
|
|
814
814
|
byName.set(n.name, { name: n.name, state: 'closed', start: n.start || null, end: n.end || null, issues, counts });
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
|
+
// The active sprint of the board's Jira projects, from the whole-sprint read, even when none of the board's initiatives holds a ticket
|
|
818
|
+
// in it (initiative sprint-snapshots: Sprint 118 was missing, the list came from the initiatives' reads only). opts.projects opts in.
|
|
819
|
+
if (Array.isArray(opts.projects) && opts.projects.length) {
|
|
820
|
+
const P = new Set(opts.projects.map((k) => String(k).toUpperCase()));
|
|
821
|
+
for (const t of wt) {
|
|
822
|
+
if (!t || !t.key || !t.sprint || !t.sprint.name || t.sprint.state !== 'active' || !P.has(String(t.key).split('-')[0].toUpperCase())) continue;
|
|
823
|
+
const name = String(t.sprint.name);
|
|
824
|
+
if (!byName.has(name)) { byName.set(name, { name, state: 'active', start: t.sprint.start || null, end: t.sprint.end || null, issues: [], counts: { todo: 0, doing: 0, done: 0 } }); any = true; }
|
|
825
|
+
const sp = byName.get(name);
|
|
826
|
+
if (sp.issues.some((i) => i.key === t.key)) continue;
|
|
827
|
+
const category = ['todo', 'doing', 'done'].includes(t.category) ? t.category : 'todo';
|
|
828
|
+
sp.issues.push({ key: t.key, summary: t.summary || '', status: t.status || '', category, initiative: null, flagged: !!t.flagged, reason: t.flagged && t.reason ? String(t.reason) : null, points: ptsOf(t), ...urlOf(t) });
|
|
829
|
+
sp.counts[category]++;
|
|
830
|
+
}
|
|
831
|
+
if (any && whole && whole.fetchedAt && (!readAt || whole.fetchedAt < readAt)) readAt = whole.fetchedAt;
|
|
832
|
+
}
|
|
817
833
|
const jiraGoal = (sp) => {
|
|
818
834
|
for (const t of wt) if (t && t.sprint && String(t.sprint.name) === sp.name && t.sprint.goal) return String(t.sprint.goal);
|
|
819
835
|
for (const s of snapshots || []) for (const t of s && s.tickets instanceof Map ? s.tickets.values() : s && Array.isArray(s.tickets) ? s.tickets : []) if (t && t.sprint && String(t.sprint.name) === sp.name && t.sprint.goal) return String(t.sprint.goal);
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* pmos jira sync <initiative> --from <file|-> [--query "<jql>"] [--dry-run] a saved search → the status snapshot
|
|
13
13
|
* pmos jira query --sprints the Jira search for every issue in the sprints the tickets are in
|
|
14
14
|
* pmos jira sync --sprints --from <file|-> [--query "<jql>"] a saved whole-sprint search → the Sprints tab (jira-sprint-scope)
|
|
15
|
+
* pmos jira query --sprint "<name>" the Jira search for every ticket one sprint held (a sprint PMOS never saw)
|
|
16
|
+
* pmos jira sync --sprint "<name>" --from <file|-> keep that read as the sprint's snapshot (initiative sprint-snapshots)
|
|
15
17
|
* pmos jira summary [--from <file|->] [--dry-run] the sprints to summarise, or save their goal and summary (sprint-goal-summary)
|
|
16
18
|
* pmos jira which <KEY> [<KEY> …] the initiative a Jira key belongs to
|
|
17
19
|
* pmos jira moves the status moves the PM asked in PMOS, not answered yet (lib/jira-moves.js)
|
|
@@ -45,6 +47,8 @@ const USAGE = [
|
|
|
45
47
|
' pmos jira sync <initiative> --from <file|-|a,b> [--query "<jql>"] [--dry-run] save the status read from Jira (a,b: one file per page)',
|
|
46
48
|
' pmos jira query --sprints the Jira search for every issue in those tickets\' sprints',
|
|
47
49
|
' pmos jira sync --sprints --from <file|-> [--query "<jql>"] save every issue of the sprints, for the Sprints tab',
|
|
50
|
+
' pmos jira query --sprint "<name>" the Jira search for every ticket one sprint held',
|
|
51
|
+
' pmos jira sync --sprint "<name>" --from <file|-> keep that read as the sprint\'s snapshot',
|
|
48
52
|
' pmos jira summary the sprints that need a goal and summary written',
|
|
49
53
|
' pmos jira summary --from <file|-> [--dry-run] save each sprint\'s goal, summary and themes (a closed sprint is kept once written)',
|
|
50
54
|
' pmos jira which <KEY> [<KEY> …] the initiative a Jira key belongs to',
|
|
@@ -54,7 +58,7 @@ const USAGE = [
|
|
|
54
58
|
'This command never calls Jira. Your agent reads and writes Jira with your own connection.',
|
|
55
59
|
];
|
|
56
60
|
const BOOL = new Set(['json', 'dry-run', 'help', 'sprints']);
|
|
57
|
-
const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused']);
|
|
61
|
+
const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint']);
|
|
58
62
|
const FLAG_TEXT = { 'prd-changed': 'PRD changed', removed: 'Removed from PRD', blocked: 'Blocked', incomplete: 'Missing text', pushing: 'Selected, waiting for the push', edited: 'Edited, not in Jira yet' };
|
|
59
63
|
|
|
60
64
|
function parse(argv) {
|
|
@@ -113,6 +117,21 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
113
117
|
|
|
114
118
|
try {
|
|
115
119
|
if (flags.sprints && verb !== 'query' && verb !== 'sync') return fail('--sprints goes with query or sync', 2);
|
|
120
|
+
if (flags.sprint != null && verb !== 'query' && verb !== 'sync') return fail('--sprint goes with query or sync', 2);
|
|
121
|
+
if (verb === 'query' && flags.sprint != null) {
|
|
122
|
+
const q = jiraStatus.sprintQueryOne(root, flags.sprint);
|
|
123
|
+
if (!q.ok) return fail(q.error);
|
|
124
|
+
return out(q, [q.query]);
|
|
125
|
+
}
|
|
126
|
+
if (verb === 'sync' && flags.sprint != null) {
|
|
127
|
+
if (!flags.from) return need('--sprint "<name>" --from <file|->');
|
|
128
|
+
let raw;
|
|
129
|
+
try { raw = readSearch(flags.from, cwd, stdin); }
|
|
130
|
+
catch (e) { return fail(`could not read ${flags.from} as JSON — ${String((e && e.message) || e).slice(0, 160)}`); }
|
|
131
|
+
const r = jiraStatus.syncSprints(root, raw, { query: flags.query || undefined, dryRun: !!flags['dry-run'], now, backfill: flags.sprint });
|
|
132
|
+
if (!r.ok) return fail(r.error);
|
|
133
|
+
return out(r, [`${r.backfill} · kept ${r.read} ${r.read === 1 ? 'ticket' : 'tickets'}${r.ignored ? ` · ${r.ignored} not in it, ignored` : ''}${r.dryRun ? ' · dry run, nothing written' : ''}`, ...(r.dryRun ? [] : [`history ${r.snapshot}`])]);
|
|
134
|
+
}
|
|
116
135
|
if (verb === 'query' && flags.sprints) {
|
|
117
136
|
const q = jiraStatus.sprintQuery(root);
|
|
118
137
|
return out(q, [q.linked ? q.query : q.kept.length ? 'every sprint is closed and summarised once — nothing to read' : 'no Jira reading has a sprint yet — run the initiatives\' searches first']);
|
|
@@ -126,6 +145,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
126
145
|
if (!r.ok) return fail(r.error);
|
|
127
146
|
const lines = [`sprints · read ${r.read} ${r.read === 1 ? 'issue' : 'issues'}${r.ignored ? ` · ${r.ignored} in no sprint, ignored` : ''}${r.skipped ? ` · ${r.skipped} skipped (no key or summary)` : ''}${r.dryRun ? ' · dry run, nothing written' : ''}`];
|
|
128
147
|
for (const [name, n] of Object.entries(r.sprints)) lines.push(` ${name} · ${n} ${n === 1 ? 'issue' : 'issues'}`);
|
|
148
|
+
for (const name of r.closedNow || []) lines.push(` ${name} closed since the last read: write its summary now (pmos jira summary)`);
|
|
129
149
|
if (!r.dryRun) lines.push(`snapshot ${r.snapshot}`);
|
|
130
150
|
return out(r, lines);
|
|
131
151
|
}
|
|
@@ -133,7 +153,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
133
153
|
if (!flags.from) {
|
|
134
154
|
const r = jiraStatus.sprintsToSummarise(root);
|
|
135
155
|
if (!r.read) return out(r, ['no whole-sprint read yet — run pmos jira query --sprints and sync --sprints first']);
|
|
136
|
-
const lines = r.sprints.map((s) => `${s.name}\t${s.state}\t${s.tickets} ${s.tickets === 1 ? 'issue' : 'issues'}\t${s.jiraGoal ? `goal in Jira: ${s.jiraGoal}` : 'no goal in Jira'}`
|
|
156
|
+
const lines = r.sprints.map((s) => `${s.name}\t${s.state}\t${s.tickets} ${s.tickets === 1 ? 'issue' : 'issues'}\t${s.jiraGoal ? `goal in Jira: ${s.jiraGoal}` : 'no goal in Jira'}`
|
|
157
|
+
+ (s.closed ? `\tat close (PMOS's count): ${s.closed.done} of ${s.closed.total} done${s.closed.carriedIn ? `, ${s.closed.carriedIn} carried in` : ''}${s.closed.carried ? `, ${s.closed.carried} carried to ${s.closed.carriedTo || 'the next sprint'}` : ''}` : ''));
|
|
137
158
|
if (!lines.length) lines.push('no sprint needs a summary');
|
|
138
159
|
for (const k of r.kept) lines.push(`${k}\tclosed\tkept, summarised once`);
|
|
139
160
|
return out(r, lines);
|
|
@@ -151,13 +151,21 @@ function sprintOf(v) {
|
|
|
151
151
|
return all.find((s) => s.state === 'active') || all.find((s) => s.state === 'future') || all[all.length - 1] || null;
|
|
152
152
|
}
|
|
153
153
|
/** Jira Cloud keeps the sprint in a custom field: any array of objects that carry a sprint's name and state. */
|
|
154
|
-
function
|
|
155
|
-
if ('sprint' in fields) return
|
|
154
|
+
function sprintField(fields) {
|
|
155
|
+
if ('sprint' in fields) return fields.sprint;
|
|
156
156
|
for (const v of Object.values(fields)) {
|
|
157
|
-
if (Array.isArray(v) && v.length && v.every((x) => x && typeof x === 'object' && 'name' in x && 'state' in x && ('boardId' in x || 'id' in x))) return
|
|
157
|
+
if (Array.isArray(v) && v.length && v.every((x) => x && typeof x === 'object' && 'name' in x && 'state' in x && ('boardId' in x || 'id' in x))) return v;
|
|
158
158
|
}
|
|
159
159
|
return null;
|
|
160
160
|
}
|
|
161
|
+
function sprintIn(fields) { const v = sprintField(fields); return v == null ? null : sprintOf(v); }
|
|
162
|
+
/** Every sprint the ticket was in, oldest first, when Jira gave more than one (initiative sprint-snapshots): a ticket carried from Sprint 114
|
|
163
|
+
* to 115 keeps 114 in its list, so the old sprint keeps it (lib/sprint-history.js). {} when there is one or none. */
|
|
164
|
+
function sprintsAll(v) {
|
|
165
|
+
if (!Array.isArray(v) || v.length < 2) return {};
|
|
166
|
+
const all = v.map(sprintOne).filter(Boolean).map((s) => { const { goal, ...rest } = s; void goal; return rest; });
|
|
167
|
+
return all.length > 1 ? { sprints: all } : {};
|
|
168
|
+
}
|
|
161
169
|
function subtasksOf(v) {
|
|
162
170
|
if (Array.isArray(v)) {
|
|
163
171
|
const done = v.filter((s) => {
|
|
@@ -211,7 +219,7 @@ function normalizeIssue(x) {
|
|
|
211
219
|
const st = f.status || {};
|
|
212
220
|
const status = nameOf(st) || 'Unknown';
|
|
213
221
|
const flagged = flaggedIn(f) || /block|impediment|on hold/i.test(status);
|
|
214
|
-
return { key, summary, status, category: categoryOf(status, st.statusCategory), sprint: sprintIn(f), subtasks: subtasksOf(f.subtasks), fixVersion: fixVersionsOf(f.fixVersions),
|
|
222
|
+
return { key, summary, status, category: categoryOf(status, st.statusCategory), sprint: sprintIn(f), ...sprintsAll(sprintField(f)), subtasks: subtasksOf(f.subtasks), fixVersion: fixVersionsOf(f.fixVersions),
|
|
215
223
|
points: pointsIn(f), resolved: dayOf(f.resolutiondate || f.resolved),
|
|
216
224
|
flagged, reason: flagged ? (flaggedIn(f) ? 'Flagged in Jira' : `Status: ${status}`) : null, url: urlOf(x, key),
|
|
217
225
|
...typeParent(f.issuetype, f.parent), ...whoWhen(f.assignee, f.updated) };
|
|
@@ -221,7 +229,7 @@ function normalizeIssue(x) {
|
|
|
221
229
|
if (!summary) return null;
|
|
222
230
|
const status = oneLine(x.status) || 'Unknown';
|
|
223
231
|
const flagged = x.flagged === true || /block|impediment|on hold/i.test(status);
|
|
224
|
-
return { key, summary, status, category: categoryOf(status, x.category), sprint: sprintOf(x.sprint), subtasks: subtasksOf(x.subtasks), fixVersion: fixVersionsOf(x.fixVersions != null ? x.fixVersions : x.fixVersion),
|
|
232
|
+
return { key, summary, status, category: categoryOf(status, x.category), sprint: sprintOf(x.sprint), ...sprintsAll(x.sprints != null ? x.sprints : x.sprint), subtasks: subtasksOf(x.subtasks), fixVersion: fixVersionsOf(x.fixVersions != null ? x.fixVersions : x.fixVersion),
|
|
225
233
|
points: pointsIn(x), resolved: dayOf(x.resolved || x.resolutiondate),
|
|
226
234
|
flagged, reason: flagged ? clip(oneLine(x.reason || x.flag_reason || (x.flagged === true ? 'Flagged in Jira' : `Status: ${status}`)), 160) : null,
|
|
227
235
|
url: urlOf(x, key), ...typeParent(x.type != null ? x.type : x.issuetype, x.parent), ...whoWhen(x.assignee, x.updated) };
|
|
@@ -340,6 +348,7 @@ function sync(root, initiative, raw, { query, dryRun = false, now } = {}) {
|
|
|
340
348
|
// not the sprint. This second read asks Jira for every issue in the sprints those tickets are in, whoever holds them.
|
|
341
349
|
const SPRINTS_FILE = '_sprints';
|
|
342
350
|
const jqlName = (n) => `"${String(n).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
351
|
+
const CLOSED_DAYS = 21; // a closed sprint is read again while its tickets changed in the last three weeks (initiative sprint-snapshots)
|
|
343
352
|
function sprintQuery(root) {
|
|
344
353
|
const frozen = frozenNotes(root);
|
|
345
354
|
const seen = new Map(); const kept = new Set(); const projectKeys = new Set();
|
|
@@ -356,23 +365,42 @@ function sprintQuery(root) {
|
|
|
356
365
|
}
|
|
357
366
|
}
|
|
358
367
|
const sprints = [...seen.values()].sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
return { ok: true, linked: true,
|
|
368
|
+
const projects = [...projectKeys].sort();
|
|
369
|
+
// bug 2026-11-19: on a Jira site whose Sprint field is not the usual custom field, the initiatives' reads came back with no sprint, and
|
|
370
|
+
// the band kept a 28 Oct read; and a sprint that opened and closed between two reads was never read (116, 117). So the read always asks
|
|
371
|
+
// for the open sprints of the tickets' Jira projects, and for the closed ones whose tickets changed lately (initiative sprint-snapshots).
|
|
372
|
+
const proj = projects.length ? `project in (${projects.join(', ')}) AND (sprint in openSprints() OR (sprint in closedSprints() AND updated >= -${CLOSED_DAYS}d))` : null;
|
|
373
|
+
const ids = sprints.length ? `sprint in (${sprints.map((s) => s.id || jqlName(s.name)).join(', ')})` : null;
|
|
374
|
+
if (!proj && !ids) return { ok: true, linked: false, sprints, kept: [...kept], query: null };
|
|
375
|
+
const query = proj && ids ? `(${proj}) OR ${ids} ORDER BY key` : `${proj || ids} ORDER BY key`;
|
|
376
|
+
return { ok: true, linked: true, ...(ids ? {} : { mode: 'open' }), projects, sprints, kept: [...kept], query };
|
|
377
|
+
}
|
|
378
|
+
/** The search for one named sprint, every ticket it ever held (Jira's `sprint = X` matches a ticket carried out of it too): the
|
|
379
|
+
* "read it from Jira now" press of a sprint PMOS never saw (SpH3). → { ok, query } | { ok: false, error } */
|
|
380
|
+
function sprintQueryOne(root, name) {
|
|
381
|
+
const n = oneLine(name);
|
|
382
|
+
if (!n || n.length > 80) return { ok: false, error: 'name the sprint, as Jira names it (at most 80 characters)' };
|
|
383
|
+
const p = sprintQuery(root).projects || [];
|
|
384
|
+
return { ok: true, name: n, query: `${p.length ? `project in (${p.join(', ')}) AND ` : ''}sprint = ${jqlName(n)} ORDER BY key` };
|
|
368
385
|
}
|
|
369
386
|
/** Save a whole-sprint read. The read replaces the last one whole: an issue moved out of a sprint is gone from it. A closed
|
|
370
387
|
* sprint that has its summary is not searched again, so its issues are kept from the last read. */
|
|
371
|
-
function syncSprints(root, raw, { query, dryRun = false, now } = {}) {
|
|
388
|
+
function syncSprints(root, raw, { query, dryRun = false, now, backfill = null } = {}) {
|
|
372
389
|
const n = normalize(raw);
|
|
373
390
|
if (n.error) return { ok: false, error: n.error };
|
|
374
|
-
const kept = n.issues.filter((i) => i.sprint && i.sprint.name);
|
|
375
391
|
const fetchedAt = nowIso(now);
|
|
392
|
+
// every read also goes to the append-only sprint history, which keeps every ticket a sprint held (initiative sprint-snapshots)
|
|
393
|
+
const SH = require('./sprint-history.js');
|
|
394
|
+
if (backfill) {
|
|
395
|
+
// "read it from Jira now" for one closed sprint (SpH3): only the history takes it; the whole-sprint read stays as it was
|
|
396
|
+
const name = oneLine(backfill);
|
|
397
|
+
const mine = n.issues.map((i) => ({ ...i, sprints: (i.sprints && i.sprints.length ? i.sprints : i.sprint ? [i.sprint] : []).map((s) => (s.name === name ? { ...s, state: 'closed' } : s)) }))
|
|
398
|
+
.filter((i) => i.sprints.some((s) => s.name === name));
|
|
399
|
+
const h = SH.append(root, mine, { at: fetchedAt, backfill: name, dryRun });
|
|
400
|
+
return { ok: true, backfill: name, read: mine.length, ignored: n.issues.length - mine.length, skipped: n.skipped, sprints: { [name]: mine.length }, history: h, snapshot: jiraTickets.relOf(root, SH.fileOf(root)), dryRun: !!dryRun, fetchedAt };
|
|
401
|
+
}
|
|
402
|
+
const history = SH.append(root, n.issues, { at: fetchedAt, dryRun });
|
|
403
|
+
const kept = n.issues.filter((i) => i.sprint && i.sprint.name);
|
|
376
404
|
const prev = readSprints(root);
|
|
377
405
|
const frozen = frozenNotes(root);
|
|
378
406
|
if (prev && frozen.length) {
|
|
@@ -382,7 +410,7 @@ function syncSprints(root, raw, { query, dryRun = false, now } = {}) {
|
|
|
382
410
|
const bySprint = {};
|
|
383
411
|
for (const i of kept) bySprint[i.sprint.name] = (bySprint[i.sprint.name] || 0) + 1;
|
|
384
412
|
const result = { ok: true, read: kept.length, ignored: n.issues.length - kept.length, skipped: n.skipped, sprints: bySprint,
|
|
385
|
-
was: prev ? prev.tickets.size : null, snapshot: snapshotRel(root, SPRINTS_FILE), dryRun: !!dryRun };
|
|
413
|
+
was: prev ? prev.tickets.size : null, snapshot: snapshotRel(root, SPRINTS_FILE), history, closedNow: history.closedNow, dryRun: !!dryRun };
|
|
386
414
|
if (dryRun) return result;
|
|
387
415
|
const file = snapshotPath(root, SPRINTS_FILE);
|
|
388
416
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
@@ -468,7 +496,9 @@ function noteOne(x) {
|
|
|
468
496
|
if (tickets == null) return { error: `${name}: theme "${title}" needs a ticket count` };
|
|
469
497
|
const ini = t.initiative == null || t.initiative === '' ? null : String(t.initiative).trim();
|
|
470
498
|
if (ini != null && !INI_RE.test(ini)) return { error: `${name}: theme "${title}" has a bad initiative id` };
|
|
471
|
-
|
|
499
|
+
// the theme's ticket keys, when the agent gave them: a closed sprint's snapshot lists a theme's tickets on a press (SpH2)
|
|
500
|
+
const keys = Array.isArray(t.keys) ? [...new Set(t.keys.map((k) => oneLine(k).toUpperCase()).filter((k) => KEY_RE.test(k)))].slice(0, 300) : [];
|
|
501
|
+
themes.push({ title, line: text(t.line, 200), tickets, done: Math.min(count(t.done) || 0, tickets), blocked: Math.min(count(t.blocked) || 0, tickets), people: text(t.people, 80), initiative: ini, ...(keys.length ? { keys } : {}) });
|
|
472
502
|
}
|
|
473
503
|
const note = { name, state, goal, summary, themes };
|
|
474
504
|
// The sprint brief (sprint-goal-summary, mockup-c3-sprint-brief): where the sprint stands, the issues to resolve with a proposed
|
|
@@ -505,9 +535,19 @@ function sprintsToSummarise(root) {
|
|
|
505
535
|
o.tickets++;
|
|
506
536
|
if (!o.jiraGoal && sp.goal) o.jiraGoal = sp.goal;
|
|
507
537
|
}
|
|
538
|
+
// a sprint PMOS saw open and then closed is summarised at close from the kept record, carried-in tickets included, even when the
|
|
539
|
+
// whole-sprint read no longer holds it (initiative sprint-snapshots; Sprint 115's "21 of 23" left out the 56 carried in)
|
|
540
|
+
const SH = require('./sprint-history.js');
|
|
541
|
+
const H = SH.read(root);
|
|
542
|
+
for (const name of new Set(H.map((l) => l.sprint.name))) {
|
|
543
|
+
const c = SH.closeOf(H, name);
|
|
544
|
+
if (!c) continue;
|
|
545
|
+
if (!by.has(name)) by.set(name, { name, state: 'closed', tickets: c.total, jiraGoal: null });
|
|
546
|
+
const o = by.get(name); o.state = 'closed'; o.tickets = c.total; o.closed = c;
|
|
547
|
+
}
|
|
508
548
|
const all = [...by.values()].sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
|
|
509
549
|
const isKept = (s) => frozen.some((f) => sameSprint(f, s)); // the note was written when Jira said closed
|
|
510
|
-
return { ok: true, read: !!whole, sprints: all.filter((s) => !isKept(s)), kept: all.filter(isKept).map((s) => s.name) };
|
|
550
|
+
return { ok: true, read: !!whole || H.length > 0, sprints: all.filter((s) => !isKept(s)), kept: all.filter(isKept).map((s) => s.name) };
|
|
511
551
|
}
|
|
512
552
|
/** Save the notes the agent wrote. A closed sprint already noted keeps its first note. A bad note refuses the whole file. */
|
|
513
553
|
function saveSprintNotes(root, raw, { dryRun = false, now } = {}) {
|
|
@@ -521,7 +561,11 @@ function saveSprintNotes(root, raw, { dryRun = false, now } = {}) {
|
|
|
521
561
|
const wt = whole ? [...whole.tickets.values()] : [];
|
|
522
562
|
const writtenAt = nowIso(now);
|
|
523
563
|
const saved = []; const kept = [];
|
|
564
|
+
let H = null; try { H = require('./sprint-history.js').read(root); } catch { H = []; }
|
|
524
565
|
for (const n of got) {
|
|
566
|
+
// a closed sprint PMOS kept from open to close: the close numbers are PMOS's own count, never the agent's (initiative sprint-snapshots)
|
|
567
|
+
const own = n.state === 'closed' ? require('./sprint-history.js').closeOf(H, n.name) : null;
|
|
568
|
+
if (own) n.closed = { done: own.done, total: own.total, carried: own.carried, carriedTo: own.carriedTo || (n.closed && n.closed.carriedTo) || null, carriedIn: own.carriedIn, points: own.points || (n.closed && n.closed.points) || null };
|
|
525
569
|
const i = notes.findIndex((o) => sameSprint(o, n));
|
|
526
570
|
if (i >= 0 && notes[i].state === 'closed') { kept.push(n.name); continue; }
|
|
527
571
|
const mine = wt.filter((t) => t.sprint && sameSprint(t.sprint, n));
|
|
@@ -562,5 +606,5 @@ function which(root, key) {
|
|
|
562
606
|
return { ok: true, key: k, initiatives: hits };
|
|
563
607
|
}
|
|
564
608
|
|
|
565
|
-
module.exports = { queryFor, linkedInitiatives, normalize, sync, readSnapshot, findTicket, which, sprintLabel, snapshotPath, snapshotRel, sprintQuery, syncSprints, readSprints, SPRINTS_FILE,
|
|
609
|
+
module.exports = { queryFor, linkedInitiatives, normalize, sync, readSnapshot, findTicket, which, sprintLabel, snapshotPath, snapshotRel, sprintQuery, sprintQueryOne, syncSprints, readSprints, SPRINTS_FILE,
|
|
566
610
|
sprintsToSummarise, saveSprintNotes, readSprintNotes, sameSprint, noteOne, NOTES_FILE };
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* POST /api/backlog/undo { ws, board, task } the Undo of "Done by PMOS today": the task is open again, PMOS's result stays
|
|
16
16
|
* in the day run for the record
|
|
17
17
|
* POST /api/backlog/decline { ws, board, task, undo? } ✕ on "PMOS can take these": not for PMOS (and its Undo)
|
|
18
|
+
* GET /api/backlog/sprint?ws=&board=&sprint= → { ok, sprint } one sprint as PMOS kept it (initiative sprint-snapshots; SpH2, SpH3):
|
|
19
|
+
* lib/sprint-history.js detailOf. GET /api/backlog also carries sprintList (the picker, SpH1) and
|
|
20
|
+
* sprintTrend (the carried-over line and bars).
|
|
18
21
|
* POST /api/backlog/place { ws, board, key, to } a No home Jira ticket into an initiative (a ticket-move line on the board
|
|
19
22
|
* ledger, as a split or merge writes it; Jira is not written to, D88). to '' takes it back out.
|
|
20
23
|
*
|
|
@@ -30,6 +33,9 @@ const dayRun = require('./day-run.js');
|
|
|
30
33
|
const assigned = require('./work-assigned.js');
|
|
31
34
|
const WK = require('./work-kind.js');
|
|
32
35
|
const SO = require('./sprint-overview.js');
|
|
36
|
+
const SH = require('./sprint-history.js');
|
|
37
|
+
/** The PM's own name for Who (PMOS_PM_NAME, else git's user.name: the name Home greets them by); '' when neither is set. */
|
|
38
|
+
const pmNameOf = () => { try { return require('./routes-board-publish.js').sharedBy() || ''; } catch { return ''; } };
|
|
33
39
|
|
|
34
40
|
const RUN_DAYS = 14;
|
|
35
41
|
const bad = (status, error, extra = {}) => ({ status, body: { ok: false, error, ...extra } });
|
|
@@ -115,15 +121,30 @@ function listOf(ctx, wsId, boardId, now) {
|
|
|
115
121
|
let factory = false; try { factory = WK.factoryRuns(w.root); } catch { factory = false; }
|
|
116
122
|
const inis = live.filter((x) => !x.closed).map((x) => ({ id: x.id, title: x.title, kind: BL.KINDS.includes(x.kind) ? x.kind : 'product', epics: x.epics || [] }));
|
|
117
123
|
const tasks = BL.tasksOf({ ws: w.id, board: board.id, product: board.product || board.name || w.name || w.id, today, items, inis, readings: R, sprintKeys,
|
|
118
|
-
moves: fr.folded.ticketMoves || new Map(), homeless, gives, runTasks, factory, me: actorLib.PM_SLUG });
|
|
124
|
+
moves: fr.folded.ticketMoves || new Map(), homeless, gives, runTasks, factory, me: actorLib.PM_SLUG, pmName: pmNameOf() });
|
|
119
125
|
const mode = BL.modeOf(inis.map((x) => x.kind));
|
|
120
126
|
// the product's display name ("IDPF"), not its folder id ("pmos-idpf"): the board's own name first
|
|
121
127
|
const product = board.name || board.product || w.name || w.id;
|
|
122
128
|
let sprintNotes = {}; try { sprintNotes = SO.foldNotes(SO.readNotes(ctx), w.id, board.id); } catch { sprintNotes = {}; }
|
|
123
|
-
|
|
129
|
+
const sin = sprintInputs(w, board, sprintNotes, tasks, jiraStatus);
|
|
130
|
+
let sprintList = [], sprintTrend = null;
|
|
131
|
+
try { sprintList = SH.listOf(sin); sprintTrend = SH.trendOf(sprintList); } catch { sprintList = []; sprintTrend = null; }
|
|
132
|
+
return { ok: true, ws: w.id, board: board.id, product, mode, sprintNotes, sprintList, sprintTrend, _sin: sin, modeLabel: BL.MODE_LABEL[mode], kinds: BL.countKinds(inis.map((x) => x.kind)), factory, readAt, today,
|
|
124
133
|
tasks, inis: inis.map((x) => ({ id: x.id, title: x.title, kind: x.kind })), _w: w, _RB: RB, _runTasks: runTasks };
|
|
125
134
|
}
|
|
126
135
|
|
|
136
|
+
/** What lib/sprint-history.js needs for one board: the kept record, the Jira sprint notes, the whole-sprint read, the PM's notes, and the
|
|
137
|
+
* board's Jira projects (its setting, else the keys of its tickets). */
|
|
138
|
+
function sprintInputs(w, board, pmNotes, tasks, jiraStatus) {
|
|
139
|
+
const read = (f) => { try { return f(); } catch { return null; } };
|
|
140
|
+
const projects = new Set();
|
|
141
|
+
const set = board.jira ? (Array.isArray(board.jira) ? board.jira : [board.jira]) : [];
|
|
142
|
+
for (const k of set) if (typeof k === 'string' && k) projects.add(k.toUpperCase());
|
|
143
|
+
if (!projects.size) for (const t of tasks || []) if (t.key) projects.add(String(t.key).split('-')[0].toUpperCase());
|
|
144
|
+
const notes = read(() => jiraStatus.readSprintNotes(w.root));
|
|
145
|
+
return { lines: read(() => SH.read(w.root)) || [], notes: notes ? notes.notes : [], whole: read(() => jiraStatus.readSprints(w.root)), pmNotes: pmNotes || {}, projects: [...projects] };
|
|
146
|
+
}
|
|
147
|
+
|
|
127
148
|
/** A task PMOS finished by itself (or the PM approved) is closed in PMOS, once: the same write as `pmos task state --to Done`, as the agent. */
|
|
128
149
|
function settle(ctx, L) {
|
|
129
150
|
for (const t of L.tasks) {
|
|
@@ -135,7 +156,7 @@ function settle(ctx, L) {
|
|
|
135
156
|
}
|
|
136
157
|
}
|
|
137
158
|
|
|
138
|
-
const strip = (L) => { const { _w, _RB, _runTasks, ...rest } = L; void _w; void _RB; void _runTasks; return rest; };
|
|
159
|
+
const strip = (L) => { const { _w, _RB, _runTasks, _sin, ...rest } = L; void _w; void _RB; void _runTasks; void _sin; return rest; };
|
|
139
160
|
|
|
140
161
|
/** What a give asks the agent to do, written for it. */
|
|
141
162
|
function specOf(t, take, id) {
|
|
@@ -168,6 +189,15 @@ async function handle(req, res, url, ctx) {
|
|
|
168
189
|
try { settle(ctx, L); } catch { /* the next read tries again */ }
|
|
169
190
|
return send({ status: 200, body: strip(L) });
|
|
170
191
|
}
|
|
192
|
+
if (sub === 'sprint' && req.method === 'GET') {
|
|
193
|
+
const L = listOf(ctx, url.searchParams.get('ws') || null, url.searchParams.get('board') || null, now);
|
|
194
|
+
if (L.pending) return send({ status: 202, body: { ok: true, pending: true, ws: L.ws, board: L.board } });
|
|
195
|
+
if (!L.ok) return send(bad(L.status || 500, L.error));
|
|
196
|
+
const name = text(url.searchParams.get('sprint')).slice(0, 120);
|
|
197
|
+
const d = name ? SH.detailOf(name, L._sin) : null;
|
|
198
|
+
if (!d) return send(bad(404, 'PMOS knows no sprint of that name on this board'));
|
|
199
|
+
return send({ status: 200, body: { ok: true, ws: L.ws, board: L.board, sprint: d } });
|
|
200
|
+
}
|
|
171
201
|
if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'sprint-draft', 'sprint-note'].includes(sub)) return send(bad(404, 'no such route'));
|
|
172
202
|
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
173
203
|
const read = await ctx.readJson(req);
|
|
@@ -187,7 +217,9 @@ async function handle(req, res, url, ctx) {
|
|
|
187
217
|
if (sub === 'sprint-draft' || sub === 'sprint-note') {
|
|
188
218
|
const sprint = text(body.sprint).slice(0, 120);
|
|
189
219
|
const T = L.tasks.filter((t) => t.sprint && t.sprint.state === 'active' && t.sprint.name === sprint && t.key);
|
|
190
|
-
|
|
220
|
+
// a past sprint takes notes too: What happened and Lessons, kept with its snapshot (initiative sprint-snapshots)
|
|
221
|
+
const past = sub === 'sprint-note' && !T.length && (L.sprintList || []).some((x) => x.name === sprint && x.state === 'closed');
|
|
222
|
+
if (!sprint || (!T.length && !past)) return send(bad(404, 'no active sprint of that name on this board'));
|
|
191
223
|
if (sub === 'sprint-draft') {
|
|
192
224
|
const tickets = T.map((t) => ({ key: t.key, title: t.title, state: t.state, parent: t.epic ? t.epic.name || t.epic.key : '' }));
|
|
193
225
|
const r = SO.draft(ctx, tickets, { again: body.again === true });
|
|
@@ -195,7 +227,7 @@ async function handle(req, res, url, ctx) {
|
|
|
195
227
|
}
|
|
196
228
|
const ev = text(body.ev), block = text(body.block), id = text(body.id).slice(0, 200);
|
|
197
229
|
if (!['note', 'clear', 'keep', 'dismiss', 'undismiss'].includes(ev)) return send(bad(400, 'ev is note, clear, keep, dismiss or undismiss'));
|
|
198
|
-
if (['note', 'clear', 'keep'].includes(ev) && !SO.BLOCKS.includes(block)) return send(bad(400, 'block is goals, doing or
|
|
230
|
+
if (['note', 'clear', 'keep'].includes(ev) && !SO.BLOCKS.includes(block)) return send(bad(400, 'block is goals, doing, next, happened or lessons'));
|
|
199
231
|
if ((ev === 'dismiss' || ev === 'undismiss') && !id) return send(bad(400, 'id names the proposal'));
|
|
200
232
|
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') : '';
|
|
201
233
|
if (ev === 'note' && !words) return send(bad(400, 'text is the block as you wrote it, one point a line'));
|
|
@@ -85,7 +85,7 @@ const kindOf = (pack) => (pack && pack.scope && pack.scope.kind) || 'multi';
|
|
|
85
85
|
const stateDir = (ctx) => ctx.runtimeDir;
|
|
86
86
|
|
|
87
87
|
module.exports = {
|
|
88
|
-
viewerVersion, cleanBy,
|
|
88
|
+
viewerVersion, cleanBy, sharedBy,
|
|
89
89
|
prefixes: ['/api/board-publish'],
|
|
90
90
|
handle: async (req, res, url, ctx) => {
|
|
91
91
|
const p = url.pathname;
|
|
@@ -1020,7 +1020,10 @@ const READS = {
|
|
|
1020
1020
|
try { whole = jiraStatus.readSprints(r.w.root); } catch { whole = null; }
|
|
1021
1021
|
let notes = null;
|
|
1022
1022
|
try { notes = jiraStatus.readSprintNotes(r.w.root); } catch { notes = null; }
|
|
1023
|
-
|
|
1023
|
+
// the board's Jira projects (its setting, else its tickets' keys): their active sprint is listed even when no initiative holds a ticket in it
|
|
1024
|
+
const projects = new Set(B.jiraProjectsOf(r.board));
|
|
1025
|
+
if (!projects.size) for (const s of snaps) if (ids.has(s.initiative)) for (const k of s.tickets.keys()) projects.add(String(k).split('-')[0].toUpperCase());
|
|
1026
|
+
ctx.json(res, { ok: true, ws: r.w.id, board: r.board.id, ...B.sprintsOf(snaps, (id) => ids.has(id), whole, notes, { projects: [...projects] }), backlog: B.backlogOf(snaps, (id) => ids.has(id), whole) });
|
|
1024
1027
|
},
|
|
1025
1028
|
};
|
|
1026
1029
|
|