create-pmos 0.615.0 → 0.617.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 +75 -45
- 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 +115 -1940
- package/workspace/extension/README.md +13 -1
- package/workspace/extension/panel.js +7 -5
- package/workspace/guide/backlog.md +70 -0
- package/workspace/guide/cli.md +1 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/layout.md +3 -2
- package/workspace/guide/notes.md +17 -3
- package/workspace/guide/programs.md +1 -1
- package/workspace/guide/routine.md +1 -1
- package/workspace/lib/backlog.js +323 -0
- package/workspace/lib/day-run.js +3 -2
- package/workspace/lib/doc-library.js +26 -3
- package/workspace/lib/jira-status.js +4 -1
- package/workspace/lib/meeting-focus.js +40 -8
- package/workspace/lib/mention-cli.js +7 -5
- package/workspace/lib/mention-store.js +9 -5
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-backlog.js +283 -0
- package/workspace/lib/routes-boards.js +13 -0
- package/workspace/lib/routes-brief-page.js +6 -2
- package/workspace/lib/routes-meeting-focus.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog.css +158 -0
- package/workspace/public/pm/bd-backlog.js +531 -0
- package/workspace/public/pm/bk-model.js +169 -0
- package/workspace/public/pm/buddy-core.js +166 -0
- package/workspace/public/pm/buddy-press.js +66 -0
- package/workspace/public/pm/cozy-buddy.css +52 -0
- package/workspace/public/pm/cozy-buddy.js +115 -0
- package/workspace/public/pm/cozy-pick.js +6 -3
- package/workspace/public/pm/cozy-rec-now.js +35 -4
- package/workspace/public/pm/cozy-rec-tab.js +5 -1
- package/workspace/public/pm/cozy-routine.js +3 -2
- package/workspace/public/pm/cozy-today-app.js +36 -6
- package/workspace/public/pm/cozy-today-model.js +49 -12
- package/workspace/public/pm/cozy-today-page.css +15 -1
- package/workspace/public/pm/cozy-today-view.js +21 -12
- package/workspace/public/pm/home-app.js +6 -1
- package/workspace/public/pm/mention-one-model.js +6 -4
- package/workspace/public/pm/premium-board.js +21 -3
- package/workspace/public/pm/premium-goals.js +12 -9
- package/workspace/public/pm/premium-library.js +15 -3
- package/workspace/public/pm/premium-meeting.js +2 -2
- package/workspace/public/pm/rec-tab-core.js +5 -2
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-buddy.html +27 -0
- package/workspace/server.js +1 -1
- package/workspace/skills/morning-brief.skill +1 -1
- package/workspace/test-lists/backlog.json +9 -0
- package/workspace/test-lists/meeting-buddy.json +9 -0
|
@@ -78,6 +78,26 @@ function byOf({ name = '', email = '', co = '', subject = '' } = {}, me = '') {
|
|
|
78
78
|
return String(name || '').trim() || null;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/** (name, email) → the display name of the person the People directory knows by that name, handle or mail; else null. PURE over `people`. */
|
|
82
|
+
function personOf(people, name, email = '') {
|
|
83
|
+
const n = String(name || '').trim().toLowerCase().replace(/^@/, ''), m = String(email || '').trim().toLowerCase();
|
|
84
|
+
if (!n && !m) return null;
|
|
85
|
+
for (const p of people || []) {
|
|
86
|
+
if (!p || !p.name) continue;
|
|
87
|
+
if (n && String(p.name).trim().toLowerCase() === n) return p.name;
|
|
88
|
+
for (const h of p.handles || []) {
|
|
89
|
+
const v = String(h.value || '').trim().toLowerCase().replace(/^@/, '');
|
|
90
|
+
if (v && ((n && v === n) || (m && v === m))) return p.name;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function personFinder(root) {
|
|
96
|
+
let people = [];
|
|
97
|
+
try { const v = require('./people-store').view(root); people = (v && v.ok && v.people) || []; } catch { people = []; }
|
|
98
|
+
return (name, email) => personOf(people, name, email);
|
|
99
|
+
}
|
|
100
|
+
|
|
81
101
|
/** path → { day, by } of its last commit (one git log). */
|
|
82
102
|
function commitInfo(root) {
|
|
83
103
|
const out = new Map();
|
|
@@ -90,7 +110,7 @@ function commitInfo(root) {
|
|
|
90
110
|
if (raw.startsWith('\x01')) {
|
|
91
111
|
const [day, name, email, subject, rest] = raw.slice(1).split('\x02');
|
|
92
112
|
const co = String(rest || '').split('\x04')[0];
|
|
93
|
-
cur = { day, by: byOf({ name, email, co, subject }, me) };
|
|
113
|
+
cur = { day, by: byOf({ name, email, co, subject }, me), email: String(email || '').toLowerCase() };
|
|
94
114
|
continue;
|
|
95
115
|
}
|
|
96
116
|
if (line && cur && !line.includes('\x04') && !out.has(line)) out.set(line, cur);
|
|
@@ -132,7 +152,10 @@ function library(root, { stateDir, owners = () => new Map() } = {}) {
|
|
|
132
152
|
// an uncommitted change is the PM's own, until it is committed
|
|
133
153
|
// the file's own frontmatter (author, by, owner) names who wrote it first; then the last commit
|
|
134
154
|
const writer = (n) => { const m = /(?:^|\s)(?:author|by|owner):\s*"?([^"\n]{2,60}?)"?(?=\s+[a-z_]+:|\s*---|$)/i.exec(String(n.card || '')); return m ? m[1].trim() : null; };
|
|
135
|
-
|
|
155
|
+
// By names a person the People directory knows, by their display name; a git author it does not know ("rc") shows nothing
|
|
156
|
+
const who = personFinder(root);
|
|
157
|
+
const gitBy = (c) => (c.by === 'You' || c.by === 'PMOS' || !c.by ? c.by : who(c.by, c.email));
|
|
158
|
+
const byOfPath = (rel, n) => { const w = writer(n); return w ? who(w) || w : (dirty.has(rel) || !info.has(rel) ? 'You' : gitBy(info.get(rel))); };
|
|
136
159
|
// An initiative is named by its record's title (planning/initiatives/<id>.md), else by the index's title for it.
|
|
137
160
|
const titleOf = new Map(graph.nodes.map((n) => [n.id, n.title]));
|
|
138
161
|
const named = (o) => String(titleOf.get(`planning/initiatives/${o.id}.md`) || o.title || o.id);
|
|
@@ -159,4 +182,4 @@ function library(root, { stateDir, owners = () => new Map() } = {}) {
|
|
|
159
182
|
return value;
|
|
160
183
|
}
|
|
161
184
|
|
|
162
|
-
module.exports = { CATEGORIES, KINDS, categoryOf, shortTitle, kindOf, library, commitDates, commitInfo, byOf };
|
|
185
|
+
module.exports = { CATEGORIES, KINDS, categoryOf, shortTitle, kindOf, library, commitDates, commitInfo, byOf, personOf };
|
|
@@ -182,13 +182,16 @@ function urlOf(x, key) {
|
|
|
182
182
|
return `${u.origin}/browse/${key}`;
|
|
183
183
|
}
|
|
184
184
|
/** One issue of either shape → a reading, or null when it has no key or no summary. */
|
|
185
|
-
/** The issue type's name
|
|
185
|
+
/** The issue type's name, the parent's key and its name, when the search returned them: { type?, parent?, parentName? }. */
|
|
186
186
|
function typeParent(t, p) {
|
|
187
187
|
const out = {};
|
|
188
188
|
const type = clip(nameOf(t), 40);
|
|
189
189
|
if (type) out.type = type;
|
|
190
190
|
const pk = oneLine(p && typeof p === 'object' ? p.key : p).toUpperCase();
|
|
191
191
|
if (KEY_RE.test(pk)) out.parent = pk;
|
|
192
|
+
// the parent's (the epic's) name, when the search returned it: the Backlog's Epic column names it (initiative work-backlog)
|
|
193
|
+
const pn = KEY_RE.test(pk) && p && typeof p === 'object' ? clip(oneLine((p.fields && p.fields.summary) || p.summary || ''), 120) : '';
|
|
194
|
+
if (pn) out.parentName = pn;
|
|
192
195
|
return out;
|
|
193
196
|
}
|
|
194
197
|
/** The assignee's display name and the last update time, when the read has them (Waiting on others); {} when it has neither. */
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* outLine(parsed, at) · moveLine(...) → the lines the state file takes
|
|
14
14
|
* shouldRun(now, state, note, opts) → { run, reason } the rules of when the companion may run
|
|
15
15
|
* pickNow(events, { now, meet, title }) → { ok, event, date, by } | { ok:false, status:404, error, choices } which meeting a Google Meet call is (the Chrome extension, c3-meet-extension)
|
|
16
|
+
* callLinkOf(event) → { url, app: 'meet'|'zoom'|'teams' } | null the address of the meeting's call (meeting-buddy: the play icon, the buddy)
|
|
16
17
|
*
|
|
17
18
|
* Nothing here reads a file or starts a process; lib/routes-meeting-focus.js does both.
|
|
18
19
|
*
|
|
@@ -36,7 +37,7 @@ const TAIL_MAX = 40; // and at most this many lines
|
|
|
36
37
|
const TOPICS_MAX = 30; // every invite line is kept; lib/agenda-topics.js shows them under 3 to 5 topics
|
|
37
38
|
const NOTES_MAX = 5;
|
|
38
39
|
const CHIPS_MAX = 4;
|
|
39
|
-
const RAISE_KINDS = Object.freeze(['check', 'follow-up', 'no-owner', 'show']);
|
|
40
|
+
const RAISE_KINDS = Object.freeze(['check', 'follow-up', 'no-owner', 'show', 'chat']); // chat: a line the PM may post in the call chat (meeting-buddy); a draft only
|
|
40
41
|
const RAISE_MAX = 2; // the Now panel shows at most this many prompts; a Show it? offer counts as one
|
|
41
42
|
const INI_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/;
|
|
42
43
|
const FROM = Object.freeze(['talk', 'screen', 'prep', 'last']); // where an answer came from: the talk, the shared screen, the prep, last time
|
|
@@ -100,15 +101,22 @@ function capturedFrom(note) {
|
|
|
100
101
|
const sec = n.summary && n.summary.sections && typeof n.summary.sections === 'object' ? n.summary.sections : {};
|
|
101
102
|
const seen = { decision: new Set(), action: new Set(), question: new Set() };
|
|
102
103
|
const out = { decisions: [], actions: [], questions: [] };
|
|
103
|
-
|
|
104
|
+
// a bullet carries its id (meeting-buddy: Undo drops it through POST /api/notes/bullet), also when the summary listed the same text first
|
|
105
|
+
const byText = { decision: new Map(), action: new Map(), question: new Map() };
|
|
106
|
+
const put = (kind, key, item) => {
|
|
107
|
+
const k = norm(item.text); if (!k) return;
|
|
108
|
+
if (seen[kind].has(k)) { const had = byText[kind].get(k); if (had && item.bid && !had.bid) had.bid = item.bid; return; }
|
|
109
|
+
seen[kind].add(k); byText[kind].set(k, item); out[key].push(item);
|
|
110
|
+
};
|
|
111
|
+
const bidOf = (b) => (typeof b.id === 'string' && b.id ? { bid: b.id } : {});
|
|
104
112
|
for (const x of Array.isArray(sec.decisions) ? sec.decisions : []) put('decision', 'decisions', { text: str(x && x.text, 300) });
|
|
105
113
|
for (const x of Array.isArray(sec.actions) ? sec.actions : []) put('action', 'actions', { text: str(x && x.text, 300), owner: str(x && x.owner, 60) || null, due: str(x && x.due, 40) || null });
|
|
106
114
|
for (const x of Array.isArray(sec.questions) ? sec.questions : []) put('question', 'questions', { text: str(x && x.text, 300) });
|
|
107
115
|
for (const b of Array.isArray(n.bullets) ? n.bullets : []) {
|
|
108
116
|
if (!b || b.dropped || b.open || !b.text) continue;
|
|
109
|
-
if (b.cat === 'decision') put('decision', 'decisions', { text: str(b.text, 300) });
|
|
110
|
-
else if (b.cat === 'action') put('action', 'actions', { text: str(b.text, 300), owner: str(b.owner, 60) || null, due: str(b.due, 40) || null });
|
|
111
|
-
else if (b.cat === 'question') put('question', 'questions', { text: str(b.text, 300) });
|
|
117
|
+
if (b.cat === 'decision') put('decision', 'decisions', { text: str(b.text, 300), ...bidOf(b) });
|
|
118
|
+
else if (b.cat === 'action') put('action', 'actions', { text: str(b.text, 300), owner: str(b.owner, 60) || null, due: str(b.due, 40) || null, ...bidOf(b) });
|
|
119
|
+
else if (b.cat === 'question') put('question', 'questions', { text: str(b.text, 300), ...bidOf(b) });
|
|
112
120
|
}
|
|
113
121
|
return out;
|
|
114
122
|
}
|
|
@@ -190,6 +198,7 @@ function companionPrompt(input) {
|
|
|
190
198
|
} else {
|
|
191
199
|
L.push('Say what is being discussed, which topic the room is on, and add a note only when it helps the PM right now: an answer to a question the room asked, a fact to check, a decision forming, a time warning, a topic that came up, context behind a name that was said, or a follow-up. Stay quiet when nothing helps: an empty "notes" list is a good answer.');
|
|
192
200
|
L.push('In "raise", give at most ' + RAISE_MAX + ' things the PM should raise in the room now, each one short line: "check" when the screen and the talk differ (a date, a number, a name), "follow-up" when an action from last time is still open and nobody raised it, "no-owner" when the room agreed something and nobody owns it. An empty "raise" list is a good answer.');
|
|
201
|
+
L.push('Also in "raise", at most one "chat": a line the PM may want to post in the call chat in their own voice, only when it helps the room now (a commitment the PM just made, a link or a number the room asked for). Write it as the PM would type it. The PM copies it and posts it; you never post anything. An empty list is a good answer.');
|
|
193
202
|
L.push('Also in "raise", at most one "show": when the room names an idea that nobody can judge from words alone (a screen, a flow, a layout, a page, how something looks or moves), PMOS can make 3 quick specimens of it while the meeting goes on. Then "text" is one sentence of what to show, "title" names the idea in a few words, and "initiative" is the id of the initiative it belongs to when the brief or a reference above names it. Only offer it for an idea that is new in the talk and not offered before. Never for a decision, a number or a date.');
|
|
194
203
|
}
|
|
195
204
|
L.push('');
|
|
@@ -283,8 +292,8 @@ function parseCompanion(text) {
|
|
|
283
292
|
const topic = { current: str(t.current, 120) || null, add: (Array.isArray(t.add) ? t.add : []).map((x) => str(x, 120)).filter(Boolean).slice(0, 3) };
|
|
284
293
|
if (str(t.under, 80)) topic.under = str(t.under, 80);
|
|
285
294
|
const notes = (Array.isArray(o.notes) ? o.notes : []).map(noteOf).filter(Boolean).slice(0, NOTES_MAX);
|
|
286
|
-
let shows = 0; // one Show it? offer an answer, at most
|
|
287
|
-
const raise = (Array.isArray(o.raise) ? o.raise : []).map(raiseOf).filter(Boolean).filter((r) => r.kind !== 'show' || shows++ === 0).slice(0, RAISE_MAX);
|
|
295
|
+
let shows = 0, chats = 0; // one Show it? offer and one chat draft an answer, at most
|
|
296
|
+
const raise = (Array.isArray(o.raise) ? o.raise : []).map(raiseOf).filter(Boolean).filter((r) => (r.kind !== 'show' || shows++ === 0) && (r.kind !== 'chat' || chats++ === 0)).slice(0, RAISE_MAX);
|
|
288
297
|
if (!gist && !chips.length && !topic.current && !topic.add.length && !notes.length && !raise.length) return null;
|
|
289
298
|
return { gist, chips, topic, notes, raise };
|
|
290
299
|
}
|
|
@@ -433,4 +442,27 @@ function pickNow(events, { now = Date.now(), meet = '', title = '' } = {}) {
|
|
|
433
442
|
return { ok: false, status: 404, error: 'No meeting on the calendar fits this call.', choices };
|
|
434
443
|
}
|
|
435
444
|
|
|
436
|
-
|
|
445
|
+
/* ── the call's address (meeting-buddy) ───────────────────────────────────────────────────────────────────────────── */
|
|
446
|
+
|
|
447
|
+
const CALL_APPS = [
|
|
448
|
+
['meet', /^https:\/\/meet\.google\.com\/[a-z]{3}-[a-z]{4}-[a-z]{3}\b/i],
|
|
449
|
+
['zoom', /^https:\/\/(?:[a-z0-9-]+\.)?zoom\.us\/(?:j|my|w|s)\//i],
|
|
450
|
+
['teams', /^https:\/\/teams\.(?:microsoft|live)\.com\/(?:l\/meetup-join|meet)\//i],
|
|
451
|
+
];
|
|
452
|
+
/** The address of the meeting's call, from its links, its hangout link or a link in its location. The case of the address is kept.
|
|
453
|
+
* → { url, app: 'meet'|'zoom'|'teams' } | null. Only https addresses of those three count. Pure. */
|
|
454
|
+
function callLinkOf(e) {
|
|
455
|
+
if (!e || typeof e !== 'object') return null;
|
|
456
|
+
const texts = [].concat((Array.isArray(e.links) ? e.links : []).map((l) => (l && typeof l === 'object' ? l.url : l)), e.hangoutLink, e.hangout_link, e.meet_url, e.join, e.conference, e.location)
|
|
457
|
+
.filter((x) => typeof x === 'string');
|
|
458
|
+
for (const t of texts) {
|
|
459
|
+
for (const raw of t.match(/https:\/\/[^\s<>"')]+/gi) || []) {
|
|
460
|
+
const url = raw.replace(/[.,;]+$/, '');
|
|
461
|
+
const hit = CALL_APPS.find(([, re]) => re.test(url));
|
|
462
|
+
if (hit && url.length <= 400) return { url, app: hit[0] };
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
module.exports = { CATS, REF_TYPES, RAISE_KINDS, RAISE_MAX, FROM, MIN_GAP_MS, TAIL_MINUTES, TAIL_MAX, topicsFrom, tailOf, capturedFrom, screenOf, companionPrompt, parseCompanion, showIntent, showLine, foldState, outLine, moveLine, raiseLine, shouldRun, pickNow, meetTitle, callLinkOf, norm, str, off };
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* pmos mention stands <id> --settled "<line>"… [--open "<line>"…] "Where it stands": what is settled and what is still open
|
|
8
8
|
* pmos mention watch <id> --what "<Samuel’s tag>" --text "<the offer>" [--due <ISO>] offer to watch for a dated promise (the PM ✓ or ×)
|
|
9
9
|
* pmos mention landed <id> --text "<Samuel’s tag landed.>" the watched promise landed: the opening line says so once
|
|
10
|
+
* pmos mention answered <id> --who "<name>" --text "<their line>" [--on <ISO>] sure someone else answered: it leaves Today, quoted, with Undo
|
|
10
11
|
* pmos mention looks <id> --who "<name>" --text "<their line>" [--on <ISO>] someone else may have answered: the line, quoted
|
|
11
12
|
* <id> is a conversation's id (pmos mention list prints it). Claude runs `draft` from the chat where the PM changes a reply ("Reply to
|
|
12
13
|
* Arif"), and the rest after a source read: the Viewer shows each on its next read. Every mark is one line in
|
|
@@ -16,9 +17,9 @@ const path = require('path');
|
|
|
16
17
|
const stateRoot = require('./state-root');
|
|
17
18
|
const store = require('./mention-store.js');
|
|
18
19
|
|
|
19
|
-
const COMMANDS = { mention: ['list', 'draft', 'gist', 'nodraft', 'stands', 'watch', 'landed', 'looks'] };
|
|
20
|
+
const COMMANDS = { mention: ['list', 'draft', 'gist', 'nodraft', 'stands', 'watch', 'landed', 'looks', 'answered'] };
|
|
20
21
|
const USAGE = [
|
|
21
|
-
'usage: pmos mention list|draft|gist|nodraft|stands|watch|landed|looks — Home\'s Mentions',
|
|
22
|
+
'usage: pmos mention list|draft|gist|nodraft|stands|watch|landed|looks|answered — Home\'s Mentions',
|
|
22
23
|
' pmos mention list the conversations: Your move, To read, Answered this week',
|
|
23
24
|
' pmos mention draft <id> --text "<reply>" change the proposed reply of one conversation (or --file <path|->)',
|
|
24
25
|
' pmos mention gist <id> --text "<one line>" the row\'s line: where the conversation stands',
|
|
@@ -27,6 +28,7 @@ const USAGE = [
|
|
|
27
28
|
' pmos mention watch <id> --what "<Samuel’s tag>" --text "<the offer>" [--due <ISO>] offer to watch for a dated promise',
|
|
28
29
|
' pmos mention landed <id> --text "<Samuel’s tag landed.>" the watched promise landed',
|
|
29
30
|
' pmos mention looks <id> --who "<name>" --text "<their line>" [--on <ISO>] someone else may have answered: quote the line',
|
|
31
|
+
' pmos mention answered <id> --who "<name>" --text "<their line>" [--on <ISO>] you are sure someone else answered it: quote the line',
|
|
30
32
|
' every command: [--json]',
|
|
31
33
|
'This command never posts. You send the reply where the mention is.',
|
|
32
34
|
];
|
|
@@ -83,13 +85,13 @@ function run(argv, { say = console.log, env = process.env, stateDir, cwd = proce
|
|
|
83
85
|
const known = JSON.parse(JSON.stringify(answer()));
|
|
84
86
|
const conv = [...known.waiting, ...known.recent].find((m) => m.id === id || (m.members || []).includes(id));
|
|
85
87
|
if (!conv) { out({ ok: false, error: `no conversation ${id}` }, `✗ no conversation ${id}. pmos mention list shows them.`); return 1; }
|
|
86
|
-
const body = { id: conv.id, act: sub === 'watch' ? 'offer' : sub, text };
|
|
88
|
+
const body = { id: conv.id, act: sub === 'watch' ? 'offer' : sub === 'answered' ? 'others' : sub, text };
|
|
87
89
|
if (sub === 'watch') { body.what = a.what; if (a.due) body.due = a.due; }
|
|
88
90
|
if (sub === 'stands') { body.settled = a.settled || []; body.open = a.open || []; }
|
|
89
|
-
if (sub === 'looks') { if (a.who) body.who = a.who; if (a.on) body.on = a.on; }
|
|
91
|
+
if (sub === 'looks' || sub === 'answered') { if (a.who) body.who = a.who; if (a.on) body.on = a.on; }
|
|
90
92
|
const r = store.mark(dir, body, now(), 'agent');
|
|
91
93
|
if (!r.ok) { out(r, `✗ refused: ${r.error}`); return 1; }
|
|
92
|
-
const SAID = { draft: 'the proposed reply', gist: 'the gist', nodraft: 'why there is no draft', stands: 'Where it stands', watch: 'the watch offer', landed: 'that the promise landed', looks: 'the line that may answer it' };
|
|
94
|
+
const SAID = { draft: 'the proposed reply', gist: 'the gist', nodraft: 'why there is no draft', stands: 'Where it stands', watch: 'the watch offer', landed: 'that the promise landed', looks: 'the line that may answer it', answered: 'who answered it; it left Today, with Undo' };
|
|
93
95
|
out({ ok: true, id: conv.id }, `saved ${SAID[sub]} of ${conv.id}. The Mentions Viewer shows it${sub === 'draft' ? '; you send it where the mention is' : ''}.`);
|
|
94
96
|
return 0;
|
|
95
97
|
}
|
|
@@ -44,13 +44,15 @@ const MENTION_SOURCES = Object.freeze(['slack', 'jira', 'confluence', 'mail']);
|
|
|
44
44
|
const VIAS = Object.freeze(['at', 'dm', 'name']);
|
|
45
45
|
const NAME_SOURCES = new Set(['slack', 'mail']); // where a plain name, with no @, counts (Jira and Confluence mention by handle)
|
|
46
46
|
const ACTS = Object.freeze(['answered', 'notask', 'snooze', 'task', 'keep', 'drafted', 'draft', 'read', 'closed', 'undo',
|
|
47
|
-
'gist', 'nodraft', 'stands', 'offer', 'watch', 'nowatch', 'landed', 'reopen', 'looks']);
|
|
47
|
+
'gist', 'nodraft', 'stands', 'offer', 'watch', 'nowatch', 'landed', 'reopen', 'looks', 'others']);
|
|
48
48
|
// what Undo never takes back: opening, a task closed by a reply, and what Claude wrote (the reply, the gist, why no draft, Where it stands,
|
|
49
49
|
// the watch offer and its landing)
|
|
50
|
-
const NOT_UNDONE = new Set(['read', 'draft', 'closed', 'gist', 'nodraft', 'stands', 'offer', 'landed', 'looks']);
|
|
50
|
+
const NOT_UNDONE = new Set(['read', 'draft', 'closed', 'gist', 'nodraft', 'stands', 'offer', 'landed', 'looks', 'others']);
|
|
51
51
|
// looks: "someone else may have answered" with the quoted line (round 3 point 10d). The morning brief writes it (step 5b, `pmos mention
|
|
52
52
|
// looks`, the PM's yes of 2026-11-19); the row drops to Can wait with ✓ ✕ and nothing closes until the PM says so.
|
|
53
|
-
|
|
53
|
+
// others: PMOS is sure someone else answered (the asker accepted it or moved on): the ask leaves Today with the line quoted, into PMOS
|
|
54
|
+
// handled, Undo (reopen) puts it back. Written by the morning brief (`pmos mention answered`), the PM's yes of 2026-11-19 (round 3 point 14).
|
|
55
|
+
const AGENT_ACTS = new Set(['draft', 'gist', 'nodraft', 'stands', 'offer', 'landed', 'looks', 'others']);
|
|
54
56
|
const STILL_DAYS = 21; // an ask with no move this long asks "Still needed?" once (round 3 point 10g)
|
|
55
57
|
const DAY = 86400000;
|
|
56
58
|
const KEEP_DAYS = 14; // a mention that stopped waiting is kept this long (Last 7 days shows 7 of them)
|
|
@@ -257,11 +259,12 @@ function mark(rt, b, now = new Date(), by = 'pm') {
|
|
|
257
259
|
if (Number.isFinite(d)) line.due = new Date(d).toISOString();
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
|
-
if (b.act === 'looks') { // the quoted line that may answer it, and who wrote it
|
|
262
|
+
if (b.act === 'looks' || b.act === 'others') { // the quoted line that (may) answer it, and who wrote it
|
|
261
263
|
if (typeof b.text !== 'string' || !b.text.trim()) return { ok: false, error: 'text is the line that answers it, quoted from the thread' };
|
|
262
264
|
if (b.text.trim().length > 200) return { ok: false, error: 'text is over 200 characters: quote the one line' };
|
|
263
265
|
line.text = b.text.trim();
|
|
264
266
|
if (b.who) line.who = clip(b.who, 80);
|
|
267
|
+
if (b.act === 'others' && !line.who) return { ok: false, error: 'who is the person who answered it' };
|
|
265
268
|
const t = b.on ? Date.parse(b.on) : NaN; if (Number.isFinite(t)) line.on = new Date(t).toISOString();
|
|
266
269
|
}
|
|
267
270
|
if (b.act === 'stands') {
|
|
@@ -391,7 +394,7 @@ function judgeConv(list, mk, now, me) {
|
|
|
391
394
|
const reopened = mk.reopen ? T(mk.reopen.at) : 0;
|
|
392
395
|
const auto = (t) => (t && t > reopened ? t : 0);
|
|
393
396
|
const cover = [['replied', auto(Math.max(lastMe, upTo(repSeen)))], ['closed', auto(upTo(closedSeen))], ['withdrawn', auto(upTo(wdSeen))],
|
|
394
|
-
['answered', mk.answered ? T(mk.answered.at) : 0], ['notask', mk.notask ? T(mk.notask.at) : 0], ['task', mk.task ? T(mk.task.at) : 0]];
|
|
397
|
+
['others', auto(mk.others ? upTo(T(mk.others.on || mk.others.at)) : 0)], ['answered', mk.answered ? T(mk.answered.at) : 0], ['notask', mk.notask ? T(mk.notask.at) : 0], ['task', mk.task ? T(mk.task.at) : 0]];
|
|
395
398
|
const upto = Math.max(...cover.map((c) => c[1]));
|
|
396
399
|
const how = upto ? cover.filter((c) => c[1] === upto)[0][0] : '';
|
|
397
400
|
const pending = askT.filter((t) => t > upto);
|
|
@@ -451,6 +454,7 @@ function convRow(id, list, j, mk, reads, now, me) {
|
|
|
451
454
|
const kept = mk.keep ? T(mk.keep.at) : 0;
|
|
452
455
|
if (j.waiting && j.since && now - Math.max(j.last, j.since) >= STILL_DAYS * DAY && !(kept && kept >= j.lastOther)) r.check = true;
|
|
453
456
|
// the proof the self check found (round 3 point 10c, 10f): what closed it, from the records only
|
|
457
|
+
if (!j.waiting && j.how === 'others' && mk.others) { r.proof = { how: 'others', at: mk.others.on || mk.others.at, cleared: mk.others.at, who: mk.others.who || '', text: clip(mk.others.text, 160) }; r.auto = true; }
|
|
454
458
|
if (!j.waiting && ['replied', 'closed', 'withdrawn'].includes(j.how)) {
|
|
455
459
|
const mine = msgs.filter((m) => m.me && T(m.at) && T(m.at) <= j.upto + 1).pop() || msgs.filter((m) => m.me).pop();
|
|
456
460
|
const by = (byT.find((e) => e.closed_as) || {}).closed_as;
|
|
@@ -112,6 +112,7 @@ const MODULES = Object.freeze([
|
|
|
112
112
|
'routes-report-setups', // report-workspace: recurring reports, the Ask box, the finder, the report documents and their export (report-setups.jsonl)
|
|
113
113
|
'routes-artefacts', // R18 (D107): the seven artefacts, read-only, and the lossless carry of the older records (artefacts.jsonl)
|
|
114
114
|
'routes-core-docs', // core-documents: the core documents of each level, Draft it (a core-doc run), Issue it and Drop (core-docs.jsonl)
|
|
115
|
+
'routes-backlog', // work-backlog: every open task of a product in one list (No home, Jira epic), and PMOS taking tasks itself through the day run (gives.jsonl; page-press POST)
|
|
115
116
|
'routes-pop-work', // popup-work-contents (slice 3): the summary of an initiative changed or confirmed in place (initiative-writer setDescription; page-press POST)
|
|
116
117
|
'routes-custom-docs', // briefing-premium-adddoc: the documents the PM adds beyond the core set, Add a document (custom-docs.jsonl)
|
|
117
118
|
'routes-library', // library-place (slice 7 of the six-place navigation): GET /api/library-items, what was made, every product (read only)
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-backlog.js — the Backlog in Work: every open task of a product in one list, and PMOS taking tasks and finishing them itself
|
|
3
|
+
* (initiative work-backlog; brief nav-structure/backlog/build-brief.md, Part A and Part B; boards BkList and BkSelect on Exploring 2).
|
|
4
|
+
*
|
|
5
|
+
* GET /api/backlog?ws=&board= → { ok, ws, board, product, mode, modeLabel, factory, readAt, tasks: [task], inis: [{ id, title }] }
|
|
6
|
+
* lib/backlog.js tasksOf: the board's PMOS tasks and Jira tickets, and the tickets of its sprints no
|
|
7
|
+
* initiative holds (No home). 202 { pending } while the initiatives are still being read.
|
|
8
|
+
* POST /api/backlog/give { ws, board, tasks: [id] } PMOS takes each task: one task of today's day run (lib/day-run.js), the
|
|
9
|
+
* same agent path as My work's "Have the agent draft it". What it does and whether the result waits
|
|
10
|
+
* for the PM come from lib/backlog.js takeOf; a task the words do not place gets "write up what you
|
|
11
|
+
* find" as a document.
|
|
12
|
+
* POST /api/backlog/stop { ws, board, task } the PM takes it back before it finishes (its session ends)
|
|
13
|
+
* POST /api/backlog/decide { ws, board, task, action: approve|revise, note?, body? } the PM's Approve or Send back on a result that
|
|
14
|
+
* waits; body: the message's words as the PM changed them in the Review popup
|
|
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
|
+
* in the day run for the record
|
|
17
|
+
* POST /api/backlog/decline { ws, board, task, undo? } ✕ on "PMOS can take these": not for PMOS (and its Undo)
|
|
18
|
+
* POST /api/backlog/place { ws, board, key, to } a No home Jira ticket into an initiative (a ticket-move line on the board
|
|
19
|
+
* ledger, as a split or merge writes it; Jira is not written to, D88). to '' takes it back out.
|
|
20
|
+
*
|
|
21
|
+
* Every POST is a page press (lib/pm-guard.js requirePagePress). The gives ledger is <runtime>/backlog/gives.jsonl, append-only, and this file
|
|
22
|
+
* is its one writer. Nothing here sends anything: a message PMOS drafts goes out only after the PM's Approve, through the day run's own send.
|
|
23
|
+
* A task PMOS finished by itself is closed (Done) on the next read, by the same function `pmos task state` runs, written as the agent. */
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const guard = require('./pm-guard.js');
|
|
27
|
+
const actorLib = require('./actor.js');
|
|
28
|
+
const BL = require('./backlog.js');
|
|
29
|
+
const dayRun = require('./day-run.js');
|
|
30
|
+
const assigned = require('./work-assigned.js');
|
|
31
|
+
const WK = require('./work-kind.js');
|
|
32
|
+
|
|
33
|
+
const RUN_DAYS = 14;
|
|
34
|
+
const bad = (status, error, extra = {}) => ({ status, body: { ok: false, error, ...extra } });
|
|
35
|
+
const text = (v) => (typeof v === 'string' ? v.trim() : '');
|
|
36
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
37
|
+
const localDate = (ms) => { const d = new Date(ms); return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; };
|
|
38
|
+
|
|
39
|
+
const givesFile = (ctx) => path.join(ctx.runtimeDir, 'backlog', 'gives.jsonl');
|
|
40
|
+
function readGives(ctx) {
|
|
41
|
+
let raw = '';
|
|
42
|
+
try { raw = fs.readFileSync(givesFile(ctx), 'utf8'); } catch { return []; }
|
|
43
|
+
const out = [];
|
|
44
|
+
for (const l of raw.split('\n')) { if (!l.trim()) continue; try { out.push(JSON.parse(l)); } catch { /* a torn line has no effect */ } }
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
function appendGive(ctx, line) {
|
|
48
|
+
fs.mkdirSync(path.dirname(givesFile(ctx)), { recursive: true });
|
|
49
|
+
fs.appendFileSync(givesFile(ctx), JSON.stringify({ at: new Date().toISOString(), ...line }) + '\n');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The day runs of the last RUN_DAYS days, newest first, and the newest copy of each task in them. */
|
|
53
|
+
function runsRead(ctx, now) {
|
|
54
|
+
const runs = assigned.recentRuns(ctx.readDayRun, now, RUN_DAYS);
|
|
55
|
+
const tasks = new Map();
|
|
56
|
+
for (const r of runs.slice().reverse()) for (const t of r.tasks || []) if (t && t.id) tasks.set(t.id, t);
|
|
57
|
+
return { runs, tasks };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The Jira readings of a board: every snapshot of its linked initiatives, then the whole-sprint read (the newer one for sprints). */
|
|
61
|
+
function readingsOf(w, jiraStatus) {
|
|
62
|
+
const R = new Map(); let readAt = null; const sprintKeys = [];
|
|
63
|
+
const add = (t) => { if (t && t.key) R.set(String(t.key).toUpperCase(), { ...(R.get(String(t.key).toUpperCase()) || {}), ...t }); };
|
|
64
|
+
try {
|
|
65
|
+
for (const q of jiraStatus.linkedInitiatives(w.root).filter((x) => x.linked)) {
|
|
66
|
+
const s = jiraStatus.readSnapshot(w.root, q.initiative);
|
|
67
|
+
if (!s) continue;
|
|
68
|
+
if (s.fetchedAt && (!readAt || s.fetchedAt < readAt)) readAt = s.fetchedAt;
|
|
69
|
+
for (const t of s.tickets.values()) add(t);
|
|
70
|
+
}
|
|
71
|
+
} catch { /* no reading yet */ }
|
|
72
|
+
try {
|
|
73
|
+
const whole = jiraStatus.readSprints(w.root);
|
|
74
|
+
if (whole) {
|
|
75
|
+
if (whole.fetchedAt && (!readAt || whole.fetchedAt < readAt)) readAt = whole.fetchedAt;
|
|
76
|
+
for (const t of whole.tickets.values()) { add(t); if (t.sprint && t.sprint.name && t.sprint.state !== 'closed') sprintKeys.push(String(t.key).toUpperCase()); }
|
|
77
|
+
}
|
|
78
|
+
} catch { /* no whole-sprint read */ }
|
|
79
|
+
return { R, readAt, sprintKeys };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** One board's tasks, as GET /api/backlog answers them. → { ok, ... } | { pending } | { error, status } */
|
|
83
|
+
function listOf(ctx, wsId, boardId, now) {
|
|
84
|
+
const RB = require('./routes-boards.js');
|
|
85
|
+
const jiraStatus = require('./jira-status.js');
|
|
86
|
+
const w = ctx.getWs(wsId || null);
|
|
87
|
+
if (!w || (wsId && w.id !== wsId)) return { error: 'no such workspace', status: 404 };
|
|
88
|
+
const fr = RB.frameFor(ctx, w);
|
|
89
|
+
const board = fr.boards.find((b) => b.id === (boardId || w.id)) || (!boardId ? fr.boards[0] : null);
|
|
90
|
+
if (!board) return { error: `no board ${boardId} in this workspace`, status: 404 };
|
|
91
|
+
const b = RB.baseRows(w, ctx);
|
|
92
|
+
if (b.pending) return { pending: true, ws: w.id, board: board.id };
|
|
93
|
+
if (!b.ok) return { error: b.error, status: 500 };
|
|
94
|
+
const rows = RB.rowsOfBoard(fr, board, b.rows);
|
|
95
|
+
const live = rows.filter((x) => !x.archived);
|
|
96
|
+
const items = RB.itemsOf(w, fr, board, live);
|
|
97
|
+
const all = new Set(b.rows.map((x) => x.id));
|
|
98
|
+
// a PMOS task of this board whose initiative is on no row at all (a record removed): No home
|
|
99
|
+
const homeless = [];
|
|
100
|
+
for (const t of fr.folded.tasks.values()) if (t.board === board.id && t.kind !== 'Epic' && !all.has(t.initiative)) homeless.push({ uid: t.id, title: t.title, owner: t.owner, status: t.state, end: t.due, milestone: false });
|
|
101
|
+
const { R, readAt, sprintKeys } = readingsOf(w, jiraStatus);
|
|
102
|
+
const today = localDate(now);
|
|
103
|
+
const { tasks: runTasks } = runsRead(ctx, now);
|
|
104
|
+
const gives = BL.foldGives(readGives(ctx));
|
|
105
|
+
let factory = false; try { factory = WK.factoryRuns(w.root); } catch { factory = false; }
|
|
106
|
+
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 || [] }));
|
|
107
|
+
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,
|
|
108
|
+
moves: fr.folded.ticketMoves || new Map(), homeless, gives, runTasks, factory, me: actorLib.PM_SLUG });
|
|
109
|
+
const mode = BL.modeOf(inis.map((x) => x.kind));
|
|
110
|
+
// the product's display name ("IDPF"), not its folder id ("pmos-idpf"): the board's own name first
|
|
111
|
+
const product = board.name || board.product || w.name || w.id;
|
|
112
|
+
return { ok: true, ws: w.id, board: board.id, product, mode, modeLabel: BL.MODE_LABEL[mode], kinds: BL.countKinds(inis.map((x) => x.kind)), factory, readAt, today,
|
|
113
|
+
tasks, inis: inis.map((x) => ({ id: x.id, title: x.title, kind: x.kind })), _w: w, _RB: RB, _runTasks: runTasks };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** 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. */
|
|
117
|
+
function settle(ctx, L) {
|
|
118
|
+
for (const t of L.tasks) {
|
|
119
|
+
if (t.src !== 'pmos' || !t.agent || t.agent.state !== 'done' || !['To do', 'In progress', 'In review'].includes(t.state)) continue;
|
|
120
|
+
const rt = t.given && L._runTasks ? L._runTasks.get(t.given.run) || null : null;
|
|
121
|
+
const sess = rt && actorLib.SESSION_RE.test(String(rt.session_id || '')) ? rt.session_id : null;
|
|
122
|
+
const r = L._RB.taskState(ctx, { ws: L.ws, board: L.board, task: t.id, state: 'Done', why: 'PMOS finished it' + (t.agent.draft && t.agent.draft.summary ? ': ' + t.agent.draft.summary.slice(0, 200) : '') }, { ok: true, actor: { by: sess ? 'agent:' + sess : 'agent:unknown', via: 'cli' } });
|
|
123
|
+
if (r.status === 200) t.state = 'Done';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const strip = (L) => { const { _w, _RB, _runTasks, ...rest } = L; void _w; void _RB; void _runTasks; return rest; };
|
|
128
|
+
|
|
129
|
+
/** What a give asks the agent to do, written for it. */
|
|
130
|
+
function specOf(t, take, id) {
|
|
131
|
+
const review = take ? take.review : null;
|
|
132
|
+
const where = t.iniTitle ? ` It is part of the initiative "${t.iniTitle}".` : '';
|
|
133
|
+
const jira = t.key ? ` It is the Jira ticket ${t.key}${t.epic && t.epic.name ? ` under the epic "${t.epic.name}"` : ''}. Read it; never change it in Jira.` : '';
|
|
134
|
+
const ask = review === 'pr'
|
|
135
|
+
? `Build this task through the factory (D65, propose-only): open ONE pull request in the product repository and put its link as the draft's link. Never merge it and never push to a main branch. The draft's summary says what the pull request changes; its body lists every file it changes, one "diff --git a/<path> b/<path>" line or one "- <path>" line each, and a line "Checks: …" with the checks it passed. PMOS reads the files against the guardrail list (migrations, sign-in, payments, personal data, secrets, CI, dependencies, public API) to decide whether the PM reviews it. If the change cannot be undone for another reason, add one line "Guarded: <two or three words>", for example "Guarded: deletes old records".`
|
|
136
|
+
: review === 'message'
|
|
137
|
+
? `Draft the message this task needs. Draft only: send nothing to anyone. The draft's summary says who it goes to and where, as "To <who> in <where>" (Slack channel, email, Jira comment); its body is the message exactly as it will go. The PM approves it before it goes.`
|
|
138
|
+
: review === 'doc'
|
|
139
|
+
? `Do this task and deliver the result as ONE document${take.to ? ` for ${take.to}` : ''}. Send nothing to anyone: the PM reads it first and passes it on.`
|
|
140
|
+
: `Do this task and deliver the result as ONE document for the PM: the finding, the comparison, the notes or the plan the task asks for. Use what this repository and your connected tools hold. Send nothing to anyone.`;
|
|
141
|
+
// only a message waits inside the day run (its send needs the PM's yes); every other result finishes there, and the Backlog decides from
|
|
142
|
+
// the gives ledger whether it waits (a guarded pull request, a document that goes to others)
|
|
143
|
+
return { id, item_id: null, title: t.title.slice(0, 250), source: 'backlog', link: t.url || null, kind: review === 'message' ? 'approve' : 'auto',
|
|
144
|
+
instruction: `The PM gave this task to PMOS: "${t.title}".${where}${jira} ${ask}`,
|
|
145
|
+
context: { about: t.title, due: t.due || null, from: t.who || null, ask: null } };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function handle(req, res, url, ctx) {
|
|
149
|
+
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
150
|
+
const sub = url.pathname.replace(/^\/api\/backlog\/?/, '');
|
|
151
|
+
const now = Date.now();
|
|
152
|
+
if (sub === '') {
|
|
153
|
+
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
154
|
+
const L = listOf(ctx, url.searchParams.get('ws') || null, url.searchParams.get('board') || null, now);
|
|
155
|
+
if (L.pending) return send({ status: 202, body: { ok: true, pending: true, ws: L.ws, board: L.board } });
|
|
156
|
+
if (!L.ok) return send(bad(L.status || 500, L.error));
|
|
157
|
+
try { settle(ctx, L); } catch { /* the next read tries again */ }
|
|
158
|
+
return send({ status: 200, body: strip(L) });
|
|
159
|
+
}
|
|
160
|
+
if (!['give', 'stop', 'decide', 'undo', 'decline', 'place'].includes(sub)) return send(bad(404, 'no such route'));
|
|
161
|
+
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
162
|
+
const read = await ctx.readJson(req);
|
|
163
|
+
if (!read.ok || !read.body || typeof read.body !== 'object') return send(bad(400, 'the body must be a JSON object'));
|
|
164
|
+
const body = read.body;
|
|
165
|
+
const g = guard.requirePagePress(req, body);
|
|
166
|
+
if (!g.ok) return send(bad(g.status, g.error));
|
|
167
|
+
const L = listOf(ctx, text(body.ws) || null, text(body.board) || null, now);
|
|
168
|
+
if (L.pending) return send(bad(409, 'the initiatives are still being read — try again in a moment'));
|
|
169
|
+
if (!L.ok) return send(bad(L.status || 500, L.error));
|
|
170
|
+
const ws = L.ws, board = L.board;
|
|
171
|
+
const find = (id) => L.tasks.find((t) => t.id === id) || null;
|
|
172
|
+
const gives = BL.foldGives(readGives(ctx));
|
|
173
|
+
const giveOf = (id) => (gives.get(BL.keyOf(ws, board, id)) || { give: null, declined: null, n: 0 });
|
|
174
|
+
|
|
175
|
+
if (sub === 'place') {
|
|
176
|
+
const key = text(body.key).toUpperCase(), to = text(body.to);
|
|
177
|
+
if (!/^[A-Z][A-Z0-9_]*-\d+$/.test(key)) return send(bad(400, 'key is a Jira key like IDPF-3340'));
|
|
178
|
+
if (to && !L.inis.some((x) => x.id === to)) return send(bad(404, `no open initiative ${to} on this board`));
|
|
179
|
+
const file = L._RB.ledgerFile(ctx, L._w);
|
|
180
|
+
if (!file) return send(bad(409, L._RB.NO_STATE));
|
|
181
|
+
const was = (L._RB.frameFor(ctx, L._w).folded.ticketMoves || new Map()).get(key) || '';
|
|
182
|
+
L._RB.append(file, g.actor, { kind: 'ticket-move', board, key, to, why: to ? 'placed from the Backlog' : 'taken back out (Undo)' });
|
|
183
|
+
return send({ status: 200, body: { ok: true, key, to, from: was } });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (sub === 'give') {
|
|
187
|
+
const ids = Array.isArray(body.tasks) ? body.tasks.map(text).filter(Boolean).slice(0, 50) : [text(body.task)].filter(Boolean);
|
|
188
|
+
if (!ids.length) return send(bad(400, 'tasks is a list of task ids'));
|
|
189
|
+
const done = [], refused = [];
|
|
190
|
+
for (const id of ids) {
|
|
191
|
+
const t = find(id);
|
|
192
|
+
if (!t) { refused.push({ id, error: 'not an open task of this board' }); continue; }
|
|
193
|
+
if (t.agent && t.agent.state !== 'failed') { refused.push({ id, error: 'PMOS already has it' }); continue; }
|
|
194
|
+
if (t.milestone) { refused.push({ id, error: 'a milestone is a date, not work PMOS can do' }); continue; }
|
|
195
|
+
const take = t.take || { what: 'writes up what it finds', review: null, to: '' };
|
|
196
|
+
const n = giveOf(id).n + 1, run = BL.runTaskId(ws, board, id, n);
|
|
197
|
+
const b = ctx.myWorkBrief(specOf(t, take, run), ws);
|
|
198
|
+
if (!b.ok) { refused.push({ id, error: b.error }); continue; }
|
|
199
|
+
appendGive(ctx, { ev: 'give', ws, board, task: id, src: t.src, run, review: take.review || null, to: take.to || '', what: take.what, why: BL.reviewWhy(take.review, take.to), by: g.actor.by });
|
|
200
|
+
done.push(id);
|
|
201
|
+
}
|
|
202
|
+
return send({ status: done.length ? 200 : 409, body: { ok: done.length > 0, given: done, refused, ...(done.length ? {} : { error: refused.map((r) => r.error)[0] || 'nothing was given' }) } });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const id = text(body.task);
|
|
206
|
+
const t = find(id), gv = giveOf(id);
|
|
207
|
+
if (sub === 'decline') {
|
|
208
|
+
if (!t) return send(bad(404, 'not an open task of this board'));
|
|
209
|
+
appendGive(ctx, { ev: body.undo ? 'undecline' : 'decline', ws, board, task: id, by: g.actor.by });
|
|
210
|
+
return send({ status: 200, body: { ok: true } });
|
|
211
|
+
}
|
|
212
|
+
if (!gv.give) return send(bad(409, 'PMOS does not have this task'));
|
|
213
|
+
const { runs } = runsRead(ctx, now);
|
|
214
|
+
const run = assigned.runWith(runs, gv.give.run), rt = run ? dayRun.findTask(run, gv.give.run) : null;
|
|
215
|
+
|
|
216
|
+
if (sub === 'stop') {
|
|
217
|
+
if (rt && (rt.status === 'waiting' || rt.status === 'working')) {
|
|
218
|
+
if (rt.session_id && rt.status === 'working' && ctx.endSession) { try { ctx.endSession(rt.session_id); } catch { /* it ended already */ } }
|
|
219
|
+
const f = dayRun.stop(run, rt.id, 'You took it back.', now);
|
|
220
|
+
const wd = f.ok ? dayRun.withdraw(f.run, rt.id) : f;
|
|
221
|
+
if (!wd.ok) return send(bad(409, wd.error));
|
|
222
|
+
if (!ctx.writeDayRun(wd.run)) return send(bad(500, 'could not save — nothing changed'));
|
|
223
|
+
} else if (rt && !['failed'].includes(rt.status)) return send(bad(409, `PMOS has finished it (${rt.status}) — use Undo or Send back`));
|
|
224
|
+
appendGive(ctx, { ev: 'stop', ws, board, task: id, by: g.actor.by });
|
|
225
|
+
return send({ status: 200, body: { ok: true } });
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (sub === 'undo') {
|
|
229
|
+
// the task is open again; a PMOS task PMOS closed goes back to To do (the same write as the Board's status press)
|
|
230
|
+
if (t && t.src === 'pmos' && t.state === 'Done') {
|
|
231
|
+
const r = L._RB.taskState(ctx, { ws, board, task: id, state: 'To do', why: 'Undo of PMOS finishing it' }, g);
|
|
232
|
+
if (r.status !== 200) return send(bad(r.status, (r.body && r.body.error) || 'the task could not be opened again'));
|
|
233
|
+
}
|
|
234
|
+
appendGive(ctx, { ev: 'undo', ws, board, task: id, by: g.actor.by });
|
|
235
|
+
return send({ status: 200, body: { ok: true } });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// decide
|
|
239
|
+
const action = text(body.action);
|
|
240
|
+
if (action !== 'approve' && action !== 'revise') return send(bad(400, 'action is approve or revise'));
|
|
241
|
+
if (!rt) return send(bad(409, 'PMOS has not delivered this task yet'));
|
|
242
|
+
if (action === 'revise') {
|
|
243
|
+
const note = text(body.note).slice(0, 500);
|
|
244
|
+
if (!note) return send(bad(400, 'say what to change: Send back needs a note'));
|
|
245
|
+
if (run.date === localDate(now)) {
|
|
246
|
+
const d = dayRun.decide(run, rt.id, { action: 'revise', note }, now);
|
|
247
|
+
if (!d.ok) return send(bad(409, d.error));
|
|
248
|
+
if (!ctx.writeDayRun(ctx.startDayTasks ? ctx.startDayTasks(d.run, now) : d.run)) return send(bad(500, 'could not save — nothing changed'));
|
|
249
|
+
} else {
|
|
250
|
+
// an earlier day's result: the job reads today's run only, so the next round is a new give of today, with the note and the old draft
|
|
251
|
+
const n = gv.n + 1, nid = BL.runTaskId(ws, board, id, n), take = { review: gv.give.review, to: gv.give.to || '' };
|
|
252
|
+
const spec = specOf(t || { title: rt.title, iniTitle: '', key: '', url: null }, take, nid);
|
|
253
|
+
spec.instruction += `\n\nThe PM sent your earlier result back with this note: ${note}${rt.draft && rt.draft.body ? `\n\nYour earlier result, to change:\n${String(rt.draft.body).slice(0, 4000)}` : ''}`;
|
|
254
|
+
const b = ctx.myWorkBrief(spec, ws);
|
|
255
|
+
if (!b.ok) return send(bad(b.status || 500, b.error));
|
|
256
|
+
appendGive(ctx, { ev: 'give', ws, board, task: id, src: gv.give.src || 'pmos', run: nid, review: gv.give.review || null, to: gv.give.to || '', what: gv.give.what || '', why: gv.give.why || '', by: g.actor.by });
|
|
257
|
+
}
|
|
258
|
+
return send({ status: 200, body: { ok: true } });
|
|
259
|
+
}
|
|
260
|
+
// approve: a message waits for its send; any other result is the PM's yes, and the task closes
|
|
261
|
+
if (rt.kind === 'approve' && rt.status === 'review') {
|
|
262
|
+
// the PM may change the words in the Review popup before the yes: the day run keeps the agent's own words beside them (dayRun.edit)
|
|
263
|
+
const edited = typeof body.body === 'string' ? body.body.trim() : '';
|
|
264
|
+
if (run.date === localDate(now)) {
|
|
265
|
+
let cur = run;
|
|
266
|
+
if (edited && rt.draft && edited !== rt.draft.body) { const e = dayRun.edit(cur, rt.id, edited, now); if (!e.ok) return send(bad(400, e.error)); cur = e.run; }
|
|
267
|
+
const d = dayRun.decide(cur, rt.id, { action: 'approve' }, now);
|
|
268
|
+
if (!d.ok) return send(bad(409, d.error));
|
|
269
|
+
if (!ctx.writeDayRun(ctx.startDayTasks ? ctx.startDayTasks(d.run, now) : d.run)) return send(bad(500, 'could not save — nothing changed'));
|
|
270
|
+
} else {
|
|
271
|
+
const spec = edited && rt.draft ? { ...rt, draft: { ...rt.draft, body: edited.slice(0, 8000) } } : rt;
|
|
272
|
+
const b = ctx.myWorkBrief(spec, ws, (today, sp, at) => dayRun.carry(today, sp, at));
|
|
273
|
+
if (!b.ok) return send(bad(b.status || 500, b.error));
|
|
274
|
+
}
|
|
275
|
+
return send({ status: 200, body: { ok: true, sending: true } });
|
|
276
|
+
}
|
|
277
|
+
if (rt.status !== 'done' && rt.status !== 'review') return send(bad(409, `the task is ${rt.status} — nothing waits for your yes`));
|
|
278
|
+
appendGive(ctx, { ev: 'approve', ws, board, task: id, by: g.actor.by });
|
|
279
|
+
if (t && t.src === 'pmos' && t.state !== 'Done') L._RB.taskState(ctx, { ws, board, task: id, state: 'Done', why: 'you approved what PMOS did' }, g);
|
|
280
|
+
return send({ status: 200, body: { ok: true } });
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
module.exports = { prefixes: ['/api/backlog'], handle, listOf, specOf };
|
|
@@ -802,6 +802,19 @@ function itemsOf(w, fr, board, rows) {
|
|
|
802
802
|
// a split or a merge took a Jira ticket to another initiative (batch 11 item 14): PMOS holds where it belongs; Jira is not written to
|
|
803
803
|
const TM = fr.folded.ticketMoves || new Map();
|
|
804
804
|
if (TM.size) for (const x of out) if (x.src === 'jira' && x.key && TM.has(x.key)) x.ini = TM.get(x.key);
|
|
805
|
+
// a sprint ticket no initiative held, placed in one from the Backlog (work-backlog, a ticket-move line): it shows on that initiative too
|
|
806
|
+
if (TM.size && board.build) {
|
|
807
|
+
let whole = null;
|
|
808
|
+
for (const [k, to] of TM) {
|
|
809
|
+
if (!to || !ids.has(to) || jiraKeys.has(k) || out.some((x) => x.src === 'jira' && x.key === k)) continue;
|
|
810
|
+
if (whole === null) { try { whole = jiraStatus.readSprints(w.root) || false; } catch { whole = false; } }
|
|
811
|
+
const rd = whole && whole.tickets && whole.tickets.get ? whole.tickets.get(k) : null;
|
|
812
|
+
if (!rd) continue;
|
|
813
|
+
const kind = ['Story', 'Task', 'Bug'].find((t) => t.toLowerCase() === String(rd.type || '').toLowerCase()) || 'Task';
|
|
814
|
+
out.push({ uid: k, key: k, kind, src: 'jira', title: rd.summary || k, status: B.itemStatus(rd.status, rd.category), blocked: !!rd.flagged, owner: null, ini: to, epic: rd.parent || null, start: null, end: null, ref: null, board: board.id, readAt: whole.fetchedAt || null, notes: '' });
|
|
815
|
+
jiraKeys.add(k);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
805
818
|
// a task's place in the breakdown (one view): the PM's own choice, else the stage whose To finish entry made it
|
|
806
819
|
const SEC = fr.folded.sections || new Map();
|
|
807
820
|
for (const x of out) if (x.src === 'pmos' && x.kind !== 'Epic') { if (SEC.has(x.uid)) x.section = SEC.get(x.uid); else if (x.from && x.from.stage) x.section = x.from.stage; }
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* READ ONLY, and built only from what PMOS already holds. Nothing is invented.
|
|
7
7
|
* today one row per meeting of the local day, in time order, from every calendar event the workspace holds (calendar-events.js readAll,
|
|
8
|
-
* the same source as /api/calendar-views): { id, title, start, end, minutes, people, initiative, prepared, before, state }.
|
|
8
|
+
* the same source as /api/calendar-views): { id, title, start, end, minutes, people, initiative, join?, app?, prepared, before, state }.
|
|
9
|
+
* join, app: the call's address and its app (meet, zoom or teams) when the meeting has one (meeting-buddy, lib/meeting-focus.js callLinkOf).
|
|
9
10
|
* prepared: [{ kind: 'prep'|'pm-note'|'note'|'last-note', text, id? }] what PMOS holds for the meeting (the agent's prep note,
|
|
10
11
|
* the PM's notes on the event, the note linked to it, the last note of an earlier occurrence). before: [{ id, title, due,
|
|
11
12
|
* done }] the PM's own open items that name the meeting (item.meeting_id or item.event_id equals the event id, or the title
|
|
@@ -54,6 +55,7 @@ function deferred(item, now, todayIso) {
|
|
|
54
55
|
return Number.isFinite(t) && t > now.getTime();
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
const callOf = (e) => { const c = require('./meeting-focus.js').callLinkOf(e); return c ? { join: c.url, app: c.app } : {}; };
|
|
57
59
|
/** The meetings of the local day. `notes` is an optional { findByEvent(ev), lastBefore(ev) } so the route can read the notes store. */
|
|
58
60
|
function todayAgenda(events, items, now, notes = {}) {
|
|
59
61
|
const todayIso = localDate(now);
|
|
@@ -76,7 +78,9 @@ function todayAgenda(events, items, now, notes = {}) {
|
|
|
76
78
|
return { id: e.id, title: e.title, start: s.toISOString(), end: new Date(endMs).toISOString(), startLocal: hhmm(s), minutes: Math.max(0, Math.round((endMs - s.getTime()) / 60000)),
|
|
77
79
|
people: Array.isArray(e.attendees) ? e.attendees.slice(0, 12) : [],
|
|
78
80
|
// the link the PM set on the meeting (lib/calendar-links.js, every occurrence of it) wins; Home's clean-up writes one (batch 13 item 3)
|
|
79
|
-
initiative: (notes.linkOf && notes.linkOf(e)) || e.initiative || null, ...(e.series ? { series: String(e.series).slice(0, 300) } : {}),
|
|
81
|
+
initiative: (notes.linkOf && notes.linkOf(e)) || e.initiative || null, ...(e.series ? { series: String(e.series).slice(0, 300) } : {}),
|
|
82
|
+
// the call's address (meeting-buddy): the play icon on Today's agenda opens it and starts the recording; Home's card shows Join
|
|
83
|
+
...callOf(e), prepared, before, _s: s.getTime(), _e: endMs };
|
|
80
84
|
});
|
|
81
85
|
let nextDone = false;
|
|
82
86
|
for (const r of rows) {
|