create-pmos 0.614.0 → 0.616.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 +57 -39
- 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 +56 -0
- 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 +5 -4
- 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/events-place.js +45 -9
- package/workspace/lib/jira-status.js +4 -1
- 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/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/cozy-events-view.js +23 -4
- package/workspace/public/pm/cozy-events.js +8 -2
- package/workspace/public/pm/cozy-pick.js +6 -3
- package/workspace/public/pm/cozy-routine.js +3 -2
- package/workspace/public/pm/cozy-today-app.js +23 -5
- package/workspace/public/pm/cozy-today-model.js +44 -10
- package/workspace/public/pm/cozy-today-page.css +9 -1
- package/workspace/public/pm/cozy-today-view.js +14 -9
- package/workspace/public/pm/home-app.js +5 -0
- 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/scope-chip.js +5 -2
- package/workspace/public/premium-board.html +1 -0
- package/workspace/skills/morning-brief.skill +1 -1
- package/workspace/test-lists/backlog.json +9 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* backlog.js — every open task of a product in one list, the way Jira's backlog lists them (initiative work-backlog; Exploring 2 canvas page
|
|
3
|
+
* "Backlog: every task in one list", boards BkList and BkSelect; brief nav-structure/backlog/build-brief.md).
|
|
4
|
+
*
|
|
5
|
+
* Wawan (2026-11-19): "better to have the Backlog page that list all the tasks just like Jira did, so this no stage or no EPIC stays there
|
|
6
|
+
* instead of on the initiative." "Indicate which one is Jira tickets and its EPIC." "Stage not apply to task, it only apply to initiative."
|
|
7
|
+
* Part B (his pick "Yes, build all of it" on the decision card, 2026-11-19): "depends on the work type … agent can work on task by itself …
|
|
8
|
+
* human is verifying only when necessary".
|
|
9
|
+
*
|
|
10
|
+
* PURE: no file, process, network or clock of its own. lib/routes-backlog.js reads the board, the Jira readings, the gives ledger and the day
|
|
11
|
+
* runs, and passes them in with `today`.
|
|
12
|
+
*
|
|
13
|
+
* tasksOf(input) → [task] every open task of one board: its PMOS tasks, its Jira tickets, and the tickets of its sprints that
|
|
14
|
+
* no initiative holds (No home). One shape for both kinds.
|
|
15
|
+
* takeOf(task, mode, o) → { what, review, to } | null what PMOS can do with a task in this kind of work, in a few words, and the one
|
|
16
|
+
* review object the result needs (pr | message | doc | null). PROVEN ONLY: a task the words do not
|
|
17
|
+
* place is not offered (null), and PMOS does not guess.
|
|
18
|
+
* reviewWhy(review, to, guard) → string | '' why a result waits for the PM, in two or three words ('' = it finishes by itself)
|
|
19
|
+
* guardOf(draft) → why a pull request waits: the guarded part its changed files touch (GUARDS), 'files unread' when no
|
|
20
|
+
* file can be read; the agent's "Guarded: …" line only adds. '' = the repo's checks decide
|
|
21
|
+
* filesOf(draft) → the files a pull request changes, read from the agent's result
|
|
22
|
+
* messageTo(title) · docTo(title) → who a message or a document goes to, from the task's words; '' = unnamed / the PM
|
|
23
|
+
* agentOf(give, runTask, today) → { state, why, draft? } | null where PMOS stands on a task it was given (working | review | done |
|
|
24
|
+
* failed), read from the day run that holds it
|
|
25
|
+
* proposeHome(task, epicHome) → { ini, why } | null the initiative a No home ticket belongs in, only when a record proves it: the
|
|
26
|
+
* ticket's epic is the epic an initiative names
|
|
27
|
+
* foldGives(lines) → Map task-key → the live give or decline of each task (the last line wins; undo and stop clear it)
|
|
28
|
+
* runTaskId(ws, board, task, n) → 't-<12 hex>' the day-run task id of the n-th give of a task
|
|
29
|
+
* modeOf(kinds) → 'product' | 'project' | 'sdlc' a product's kind of work: the one most of its initiatives carry
|
|
30
|
+
*
|
|
31
|
+
* A TASK: { id, src: pmos|jira, key, title, ini, iniTitle, kind: Task|Story|Bug|Milestone, milestone, epic: { key, name } | null,
|
|
32
|
+
* who, whoKind: pm|person|none, state: To do|In progress|In review, due, late, sprint: { name, state } | null, mode, take, propose,
|
|
33
|
+
* agent, declined, ws, board, url }. Its `id` is the PMOS task id or the Jira key. Done, Won't do and Archived are not open and are not
|
|
34
|
+
* listed, except a task PMOS finished today (agent.state 'done'), which "Done by PMOS today" lists with its Undo.
|
|
35
|
+
*
|
|
36
|
+
* WHAT NEEDS A REVIEW (Wawan, 2026-11-19: "human is verifying when only and only necessary"; design check 1, point 4):
|
|
37
|
+
* a message that goes out always waits (outward, the standing rule)
|
|
38
|
+
* a pull request waits only when its changed files touch a guarded part (the AUTO-MERGE GUARDRAIL list, GUARDS:
|
|
39
|
+
* migrations, auth, payments, personal data, secrets, CI, dependencies, public API), when its files
|
|
40
|
+
* cannot be read, or when the agent marks it "Guarded: …" (a mark adds a review, never removes one). Any
|
|
41
|
+
* other pull request stays in "PMOS is working": the repository's own checks decide, and PMOS never
|
|
42
|
+
* merges in a product repository (D65).
|
|
43
|
+
* a document that goes to others waits ("goes to the CFO"; "goes to people" when the words share it with no one named)
|
|
44
|
+
* a document for the PM finishes by itself, with Undo
|
|
45
|
+
* A Jira ticket is not a reason by itself: PMOS does not write to Jira (D88); its status is read. */
|
|
46
|
+
const crypto = require('crypto');
|
|
47
|
+
|
|
48
|
+
const KINDS = Object.freeze(['product', 'project', 'sdlc']);
|
|
49
|
+
const MODE_LABEL = Object.freeze({ product: 'Product management', project: 'Project management', sdlc: 'Full SDLC' });
|
|
50
|
+
const OPEN = new Set(['To do', 'In progress', 'In review']);
|
|
51
|
+
const DAY = 864e5;
|
|
52
|
+
const JIRA_KEY = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
53
|
+
const ME = /^(pm|you|me|wawan)$/i;
|
|
54
|
+
|
|
55
|
+
const str = (v, n = 200) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
56
|
+
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; };
|
|
57
|
+
const word = (re) => (t) => re.test(t);
|
|
58
|
+
|
|
59
|
+
/** A product's kind of work: the kind most of its initiatives carry (ties go to the wider kind: sdlc, then project); product with none. */
|
|
60
|
+
function modeOf(kinds) {
|
|
61
|
+
const n = countKinds(kinds);
|
|
62
|
+
const top = Math.max(n.product, n.project, n.sdlc);
|
|
63
|
+
return top ? ['sdlc', 'project', 'product'].find((k) => n[k] === top) : 'product';
|
|
64
|
+
}
|
|
65
|
+
/** How many initiatives carry each kind of work: { product, project, sdlc } (the mode line says "9 of 12 initiatives" from it). */
|
|
66
|
+
function countKinds(kinds) {
|
|
67
|
+
const n = { product: 0, project: 0, sdlc: 0 };
|
|
68
|
+
for (const k of kinds || []) if (KINDS.includes(k)) n[k]++;
|
|
69
|
+
return n;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ── what PMOS can do with a task (proven only: the task's own words and kind of work decide) ── */
|
|
73
|
+
const IS_MESSAGE = word(/\b(reply|respond|answer|e-?mail|message|send|notify|announce|invite|ask (?:\w+ )?(?:for|about|to)|tell)\b/i);
|
|
74
|
+
const IS_CHASE = word(/\b(chase|follow[- ]?up|remind|status (?:note|update|report)|weekly (?:note|update|report)|nudge)\b/i);
|
|
75
|
+
const IS_DOC = word(/\b(research|compare|comparison|analy[sz]e|analysis|document|write[- ]?up|write|draft|spec|prd|brief|summary|summari[sz]e|report|notes?|outline|evaluate|evaluation|assess|assessment|audit|investigate|find out|options|proposal|recommend\w*|criteria|checklist|plan for|faq|glossary)\b/i);
|
|
76
|
+
const IS_CHECK = word(/\b(test|check|verify|parity|establish (?:the )?current|reproduce|confirm (?:the )?behaviou?r)\b/i);
|
|
77
|
+
const IS_BUILD = word(/\b(build|implement|fix|remove|add|refactor|rate[- ]limit|migrate|endpoint|api|bug|deprecat\w*|upgrade|wire|hook up|rename|delete|ui|page|button|screen|flow|feature|cache|login|sign[- ]?in|otp)\b/i);
|
|
78
|
+
|
|
79
|
+
/* who a result goes to, read from the task's words only (proven only: no name, no audience) */
|
|
80
|
+
const ROLE = /^(?:the\s+)?(cfo|ceo|cto|coo|cpo|board|legal(?: team)?|finance(?: team)?|vendors?|clients?|customers?|stakeholders|leadership|execs?|management|[a-z]+ team)\b/i;
|
|
81
|
+
const UPPER_ROLE = /^(cfo|ceo|cto|coo|cpo)$/i;
|
|
82
|
+
const roleName = (m) => (UPPER_ROLE.test(m) ? 'the ' + m.toUpperCase() : /^(board|leadership|management|stakeholders|execs?)$/i.test(m) ? 'the ' + m.toLowerCase() : m.toLowerCase());
|
|
83
|
+
const MSG_VERB = /\b(?:reply to|respond to|answer|e-?mail|message|tell|ask|remind|chase|nudge|notify|invite|follow[- ]?up with|send (?:it |this )?to|write to)\s+/i;
|
|
84
|
+
/** The person or audience a message goes to: "Reply to Daryl: …" → "Daryl"; "Chase finance for the PO" → "finance"; '' when unnamed. */
|
|
85
|
+
function messageTo(title) {
|
|
86
|
+
const t = str(title, 400), m = MSG_VERB.exec(t);
|
|
87
|
+
if (!m) return '';
|
|
88
|
+
const rest = t.slice(m.index + m[0].length);
|
|
89
|
+
const r = ROLE.exec(rest);
|
|
90
|
+
if (r) return roleName(r[1]);
|
|
91
|
+
const n = /^(?:the\s+)?([A-Z][a-z][\w'-]*(?:\s+[A-Z][a-z][\w'-]*)?)/.exec(rest);
|
|
92
|
+
return n ? n[1] : '';
|
|
93
|
+
}
|
|
94
|
+
/** The audience a document goes to, when the words name one ("Budget summary for the CFO"), or 'people' when the words share it with no
|
|
95
|
+
* one named ("Present the findings", "share", "circulate", "publish"): it waits either way. '' = a document for the PM. */
|
|
96
|
+
const IS_SHARE = /\b(share|present|circulate|publish|distribute|hand ?out|post|send)\b/i;
|
|
97
|
+
function docTo(title) {
|
|
98
|
+
const t = str(title, 400);
|
|
99
|
+
const re = /\b(?:for|to|with)\s+/gi;
|
|
100
|
+
let m;
|
|
101
|
+
while ((m = re.exec(t))) { const r = ROLE.exec(t.slice(m.index + m[0].length)); if (r) return roleName(r[1]); }
|
|
102
|
+
return IS_SHARE.test(t) ? 'people' : '';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* What PMOS can do with `task` in this kind of work, or null → { what, review: 'pr' | 'message' | 'doc' | null, to }. o: { factory } — a
|
|
107
|
+
* D65 factory runs in the product's repository (only then a build task becomes a pull request PMOS opens; lib/work-kind.js factoryRuns).
|
|
108
|
+
* A milestone, a task someone already works on, and a task the words do not place are not offered.
|
|
109
|
+
* review 'pr' waits only when the result is guarded (agentOf reads that from the agent's result); 'doc' is a document that goes to others.
|
|
110
|
+
*/
|
|
111
|
+
function takeOf(task, mode, o = {}) {
|
|
112
|
+
if (!task || task.milestone) return null;
|
|
113
|
+
if (task.state !== 'To do') return null; // In progress or In review: someone is on it
|
|
114
|
+
const t = str(task.title, 400);
|
|
115
|
+
if (!t) return null;
|
|
116
|
+
const m = KINDS.includes(mode) ? mode : 'product';
|
|
117
|
+
const doc = (what) => { const to = docTo(t); return { what, review: to ? 'doc' : null, to }; };
|
|
118
|
+
if (m === 'sdlc' && o.factory && (IS_BUILD(t) || (task.src === 'jira' && /^(bug|story)$/i.test(task.kind || '')))) {
|
|
119
|
+
if (IS_CHECK(t) && !IS_BUILD(t)) return doc('tests it and writes what it found');
|
|
120
|
+
return { what: 'opens a pull request', review: 'pr', to: '' };
|
|
121
|
+
}
|
|
122
|
+
if (((m === 'project' || m === 'sdlc') && IS_CHASE(t)) || IS_MESSAGE(t)) return { what: 'drafts it, you send', review: 'message', to: messageTo(t) };
|
|
123
|
+
if (m === 'sdlc' && IS_CHECK(t)) return doc('tests each row');
|
|
124
|
+
if (IS_DOC(t)) { const d = doc('writes it up'); if (d.to) d.what = 'writes it for ' + d.to; return d; }
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Why a result waits for the PM, in two or three words; '' when it finishes by itself. to: who it goes to; guard: the agent's own words for
|
|
129
|
+
* the guarded part a pull request touches ("changes sign-in"). */
|
|
130
|
+
function reviewWhy(review, to, guard) {
|
|
131
|
+
if (review === 'message') return 'goes out to ' + (to || 'people');
|
|
132
|
+
if (review === 'doc') return to ? 'goes to ' + to : '';
|
|
133
|
+
if (review === 'pr') return guard ? str(guard, 40) : '';
|
|
134
|
+
return '';
|
|
135
|
+
}
|
|
136
|
+
/* the AUTO-MERGE GUARDRAIL list, read from the files a pull request changes (design check 2: from the facts, never the agent's word alone).
|
|
137
|
+
* The first rule a file meets names the reason, in two or three words. */
|
|
138
|
+
const GUARDS = [
|
|
139
|
+
[/(^|\/)(migrations?|migrate)\/|\.sql$|(^|\/)schema\.(prisma|rb|sql)$/i, 'changes the database'],
|
|
140
|
+
[/(^|[\/_.-])(auth\w*|login|log-?in|sign-?in|signin|session|oauth|oidc|saml|sso|otp|mfa|2fa|password|passwd|token|jwt)([\/_.-]|$)/i, 'changes sign-in'],
|
|
141
|
+
[/(^|[\/_.-])(pay\w*|billing|checkout|stripe|invoice|subscription|refund)([\/_.-]|$)/i, 'changes payments'],
|
|
142
|
+
[/(^|[\/_.-])(pii|personal|gdpr|privacy|consent|user-?data|profile)([\/_.-]|$)/i, 'touches personal data'],
|
|
143
|
+
[/(^|\/)\.env(\.|$)|(^|[\/_.-])(secrets?|credentials?|vault|keystore)([\/_.-]|$)|\.(pem|key|p12)$/i, 'touches secrets'],
|
|
144
|
+
[/^\.github\/|(^|\/)\.gitlab-ci\.yml$|(^|\/)\.circleci\/|(^|\/)jenkinsfile$|(^|\/)\.buildkite\/|(^|\/)azure-pipelines\.yml$/i, 'changes CI'],
|
|
145
|
+
[/(^|\/)(package(-lock)?\.json|yarn\.lock|pnpm-lock\.yaml|npm-shrinkwrap\.json|requirements[\w-]*\.txt|pyproject\.toml|poetry\.lock|go\.(mod|sum)|gemfile(\.lock)?|pom\.xml|build\.gradle(\.kts)?|cargo\.(toml|lock)|composer\.(json|lock))$/i, 'changes dependencies'],
|
|
146
|
+
[/(^|[\/_.-])(openapi|swagger)([\/_.-]|$)|(^|\/)public[-_]?api\/|(^|\/)api\/v\d+\/|\.proto$|(^|\/)schema\.graphql$/i, 'changes the public API'],
|
|
147
|
+
];
|
|
148
|
+
/** The files a pull request changes, from the agent's result: draft.files, diff headers, and one path per line under "Files". */
|
|
149
|
+
function filesOf(draft) {
|
|
150
|
+
if (!draft) return [];
|
|
151
|
+
const out = new Set();
|
|
152
|
+
for (const f of Array.isArray(draft.files) ? draft.files : []) if (typeof f === 'string' && f.trim()) out.add(f.trim());
|
|
153
|
+
const B = String(draft.body || '');
|
|
154
|
+
for (const m of B.matchAll(/^diff --git a\/(\S+)/gm)) out.add(m[1]);
|
|
155
|
+
for (const m of B.matchAll(/^[ \t]*(?:[-*]|[MADR]\t?)[ \t]+([\w@.\/-]+\/[\w@.\/-]+|[\w@.-]+\.\w{1,8})[ \t]*$/gm)) out.add(m[1]);
|
|
156
|
+
return [...out].slice(0, 400);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Does a pull request wait for the PM, and why, in two or three words; '' = it does not (the repository's checks decide).
|
|
160
|
+
* From the facts: each changed file against the guardrail list. The files cannot be read → it waits ("files unread"). The agent's own
|
|
161
|
+
* "Guarded: …" line may add a review, never take one away.
|
|
162
|
+
*/
|
|
163
|
+
function guardOf(draft) {
|
|
164
|
+
if (!draft) return 'files unread';
|
|
165
|
+
const files = filesOf(draft);
|
|
166
|
+
if (!files.length) return 'files unread';
|
|
167
|
+
for (const f of files) for (const [re, why] of GUARDS) if (re.test(f)) return why;
|
|
168
|
+
const m = /^\s*guarded\s*:\s*(.+)$/im.exec(String(draft.summary || '') + '\n' + String(draft.body || '').slice(0, 2000));
|
|
169
|
+
return m ? str(m[1].replace(/[.;]+$/, ''), 40) : '';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* ── where PMOS stands on a task it was given ── */
|
|
173
|
+
/**
|
|
174
|
+
* give: the live give line ({ at, run, review, why }); rt: the day run's task with that id, or null; today: 'YYYY-MM-DD'.
|
|
175
|
+
* → { state: 'working' | 'review' | 'done' | 'failed', why, draft?, at? } or null when the give has no task in the runs read (gone).
|
|
176
|
+
* working waiting or working in the day run, or sending after the PM's yes
|
|
177
|
+
* review a draft waits for the PM: a message, or a result whose kind needs a review (give.review) and the PM has not approved
|
|
178
|
+
* done finished: an auto result, an approved one, or a sent message. Only a task finished today is listed (Done by PMOS today)
|
|
179
|
+
* failed the day run says so; the Backlog puts it back where it came from, with the reason (honest state)
|
|
180
|
+
*/
|
|
181
|
+
function agentOf(give, rt, today) {
|
|
182
|
+
if (!give || !give.run) return null;
|
|
183
|
+
const isToday = (at) => String(at || '').slice(0, 10) === today;
|
|
184
|
+
if (!rt) return give.approvedAt ? { state: 'done', why: 'approved', at: give.approvedAt, today: isToday(give.approvedAt) } : null;
|
|
185
|
+
const draft = rt.draft ? { summary: str(rt.draft.summary, 240), body: String(rt.draft.body || '').slice(0, 8000), link: rt.draft.link || null, at: rt.draft.at || null } : null;
|
|
186
|
+
const st = rt.status;
|
|
187
|
+
if (st === 'waiting' || st === 'working') return { state: 'working', why: st === 'waiting' ? 'starts soon' : rt.progress ? str(rt.progress, 80) : 'working on it', draft: null };
|
|
188
|
+
if (st === 'sending') return { state: 'working', why: 'sending what you approved', draft };
|
|
189
|
+
if (st === 'failed') return { state: 'failed', why: str(rt.error || 'it stopped before it finished', 160), draft };
|
|
190
|
+
const doneAt = (rt.decided && rt.decided.action === 'approve' && rt.decided.at) || (draft && draft.at) || give.at;
|
|
191
|
+
if (st === 'sent') return { state: 'done', why: 'sent', draft, at: doneAt, today: isToday(doneAt) };
|
|
192
|
+
if (st === 'review') return { state: 'review', why: give.why || reviewWhy('message', give.to), to: give.to || '', draft };
|
|
193
|
+
if (st === 'done') {
|
|
194
|
+
if (!give.approvedAt && give.review === 'pr') {
|
|
195
|
+
const guard = guardOf(draft);
|
|
196
|
+
if (guard) return { state: 'review', why: reviewWhy('pr', '', guard), guard, draft };
|
|
197
|
+
// not guarded: the repository's own checks decide; PMOS never merges (D65), so the row stays here until the task closes
|
|
198
|
+
return { state: 'working', why: draft && draft.link ? "Pull request open · the repo's checks decide" : 'passed its checks, no pull request link', pr: true, draft };
|
|
199
|
+
}
|
|
200
|
+
if (!give.approvedAt && give.review === 'doc' && give.to) return { state: 'review', why: reviewWhy('doc', give.to), to: give.to, draft };
|
|
201
|
+
const at = give.approvedAt || doneAt;
|
|
202
|
+
return { state: 'done', why: give.approvedAt ? 'approved' : 'passed its checks', draft, at, today: isToday(at) };
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* ── the gives ledger (<runtime>/backlog/gives.jsonl, written by lib/routes-backlog.js) ── */
|
|
208
|
+
const keyOf = (ws, board, task) => `${ws}\u0000${board}\u0000${task}`;
|
|
209
|
+
/** The live state of each task: { give: { at, run, review, why, n, approvedAt? } | null, declined: { at } | null, n }. */
|
|
210
|
+
function foldGives(lines) {
|
|
211
|
+
const by = new Map();
|
|
212
|
+
for (const e of lines || []) {
|
|
213
|
+
if (!e || typeof e !== 'object' || typeof e.task !== 'string') continue;
|
|
214
|
+
const k = keyOf(e.ws || '', e.board || '', e.task);
|
|
215
|
+
const cur = by.get(k) || { give: null, declined: null, n: 0 };
|
|
216
|
+
if (e.ev === 'give' && typeof e.run === 'string') { cur.n += 1; cur.give = { at: e.at || null, run: e.run, review: e.review || null, why: e.why || '', to: e.to || '', what: e.what || '', n: cur.n, src: e.src || 'pmos' }; cur.declined = null; }
|
|
217
|
+
else if (e.ev === 'approve' && cur.give) cur.give = { ...cur.give, approvedAt: e.at || null };
|
|
218
|
+
else if (e.ev === 'stop' || e.ev === 'undo') cur.give = null;
|
|
219
|
+
else if (e.ev === 'decline') cur.declined = { at: e.at || null };
|
|
220
|
+
else if (e.ev === 'undecline') cur.declined = null;
|
|
221
|
+
by.set(k, cur);
|
|
222
|
+
}
|
|
223
|
+
return by;
|
|
224
|
+
}
|
|
225
|
+
/** The day-run task id of the n-th give of a task: the same give is the same id, a new give after an Undo is a new one. */
|
|
226
|
+
const runTaskId = (ws, board, task, n) => 't-' + crypto.createHash('sha1').update(`backlog\u0000${keyOf(ws, board, task)}\u0000${n}`).digest('hex').slice(0, 12);
|
|
227
|
+
|
|
228
|
+
/** The initiative a No home ticket belongs in, when a record proves it: its epic is the Jira epic an initiative names. */
|
|
229
|
+
function proposeHome(task, epicHome) {
|
|
230
|
+
if (!task || task.ini || !task.epic || !task.epic.key) return null;
|
|
231
|
+
const h = epicHome && epicHome.get(task.epic.key);
|
|
232
|
+
return h ? { ini: h.id, title: h.title, why: 'its epic ' + task.epic.key + ' belongs to it' } : null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Every open task of one board. input: {
|
|
237
|
+
* ws, board, product, today,
|
|
238
|
+
* items the board's work items (lib/routes-boards.js itemsOf): PMOS tasks (src pmos) and Jira tickets (src jira) of its initiatives
|
|
239
|
+
* inis [{ id, title, kind, epics }] the board's open initiatives
|
|
240
|
+
* readings Map key → a Jira reading { key, summary, status, category, type, parent, parentName, assignee, sprint, url } from every
|
|
241
|
+
* snapshot of the board and the whole-sprint read (lib/jira-status.js)
|
|
242
|
+
* sprintKeys [key] the tickets the whole-sprint read holds: the ones no initiative holds are No home
|
|
243
|
+
* moves Map KEY → initiative id (the ticket-move lines: a ticket the PM placed)
|
|
244
|
+
* homeless [PMOS task item] tasks of this board whose initiative is on no board row
|
|
245
|
+
* gives foldGives(...) · runTasks Map run-task id → day-run task · factory bool · me: the PM's own name
|
|
246
|
+
* } */
|
|
247
|
+
function tasksOf(input) {
|
|
248
|
+
const I = input || {};
|
|
249
|
+
const today = I.today || new Date().toISOString().slice(0, 10), t0 = dayNum(today);
|
|
250
|
+
const iniBy = new Map((I.inis || []).map((r) => [r.id, r]));
|
|
251
|
+
const R = I.readings instanceof Map ? I.readings : new Map();
|
|
252
|
+
const epicHome = new Map();
|
|
253
|
+
for (const r of I.inis || []) for (const e of r.epics || []) if (JIRA_KEY.test(e) && !epicHome.has(e)) epicHome.set(e, { id: r.id, title: r.title });
|
|
254
|
+
const mode = modeOf((I.inis || []).map((r) => r.kind));
|
|
255
|
+
const G = I.gives instanceof Map ? I.gives : new Map(), RT = I.runTasks instanceof Map ? I.runTasks : new Map();
|
|
256
|
+
const me = str(I.me, 80).toLowerCase();
|
|
257
|
+
const out = [], seen = new Set();
|
|
258
|
+
const whoOf = (owner) => {
|
|
259
|
+
const o = str(owner, 80);
|
|
260
|
+
if (!o) return { who: '', whoKind: 'none' };
|
|
261
|
+
if (ME.test(o) || (me && o.toLowerCase() === me)) return { who: 'You', whoKind: 'pm' };
|
|
262
|
+
return { who: o, whoKind: 'person' };
|
|
263
|
+
};
|
|
264
|
+
const epicOf = (key) => {
|
|
265
|
+
if (!key) return null;
|
|
266
|
+
const rd = R.get(key);
|
|
267
|
+
// the name: the epic's own reading, else the parent name a child's reading carries (lib/jira-status.js parentName)
|
|
268
|
+
let name = rd && rd.summary ? rd.summary : '';
|
|
269
|
+
if (!name) for (const x of R.values()) if (x && x.parent === key && x.parentName) { name = x.parentName; break; }
|
|
270
|
+
return { key, name: str(name, 120) };
|
|
271
|
+
};
|
|
272
|
+
const push = (t) => {
|
|
273
|
+
const g = G.get(keyOf(I.ws || '', I.board || '', t.id)) || { give: null, declined: null };
|
|
274
|
+
const ini = t.ini ? iniBy.get(t.ini) : null;
|
|
275
|
+
const m = ini && KINDS.includes(ini.kind) ? ini.kind : mode;
|
|
276
|
+
const due = dayNum(t.due), late = due != null && t0 != null && due < t0 && OPEN.has(t.state) ? t0 - due : 0;
|
|
277
|
+
const agent0 = g.give ? agentOf({ ...g.give, src: t.src }, RT.get(g.give.run) || null, today) : null;
|
|
278
|
+
const agent = agent0 ? { ...agent0, review: g.give.review || null } : null;
|
|
279
|
+
if (!OPEN.has(t.state) && !(agent && agent.state === 'done' && agent.today)) return;
|
|
280
|
+
const take = agent && agent.state !== 'failed' ? null : takeOf(t, m, { factory: !!I.factory });
|
|
281
|
+
const row = { ...t, iniTitle: ini ? str(ini.title, 160) : '', mode: m, late, take, agent, declined: !!g.declined, given: g.give ? { at: g.give.at, n: g.give.n, run: g.give.run } : null,
|
|
282
|
+
ws: I.ws || '', board: I.board || '', product: I.product || '' };
|
|
283
|
+
if (!row.ini) row.propose = row.declined ? null : proposeHome(row, epicHome); // ✕ on a proposal: not there
|
|
284
|
+
out.push(row);
|
|
285
|
+
};
|
|
286
|
+
for (const w of I.items || []) {
|
|
287
|
+
if (!w || w.kind === 'Epic' || !w.uid) continue;
|
|
288
|
+
const id = w.src === 'jira' ? String(w.key || w.uid).toUpperCase() : String(w.uid);
|
|
289
|
+
if (seen.has(id)) continue;
|
|
290
|
+
seen.add(id);
|
|
291
|
+
if (w.src === 'jira') {
|
|
292
|
+
const rd = R.get(id) || {};
|
|
293
|
+
const ini = (I.moves && I.moves.get(id)) || w.ini || null;
|
|
294
|
+
push({ id, src: 'jira', key: id, title: str(w.title || rd.summary || id, 300), ini: ini && iniBy.has(ini) ? ini : null, kind: str(rd.type || w.kind || 'Task', 20), milestone: !!w.milestone,
|
|
295
|
+
epic: epicOf(w.epic || rd.parent || null), ...whoOf(rd.assignee), state: OPEN.has(w.status) ? w.status : w.status || 'To do', due: w.end || null,
|
|
296
|
+
sprint: rd.sprint && rd.sprint.name ? { name: str(rd.sprint.name, 80), state: rd.sprint.state || '' } : null, url: rd.url || null });
|
|
297
|
+
} else {
|
|
298
|
+
push({ id, src: 'pmos', key: '', title: str(w.title, 300), ini: iniBy.has(w.ini) ? w.ini : null, kind: w.milestone ? 'Milestone' : 'Task', milestone: !!w.milestone, epic: null,
|
|
299
|
+
...whoOf(w.owner), state: w.status === "Won't do" || w.status === 'Archived' || w.status === 'Done' ? w.status : OPEN.has(w.status) ? w.status : 'To do', due: w.end || null, sprint: null, url: null, item: !!w.item });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// the tickets of the board's sprints that no initiative holds: No home, unless the PM placed one (a ticket-move line)
|
|
303
|
+
for (const k0 of I.sprintKeys || []) {
|
|
304
|
+
const id = String(k0).toUpperCase();
|
|
305
|
+
if (seen.has(id)) continue;
|
|
306
|
+
const rd = R.get(id);
|
|
307
|
+
if (!rd || rd.category === 'done' || /^epic$/i.test(rd.type || '')) continue;
|
|
308
|
+
seen.add(id);
|
|
309
|
+
const placed = I.moves && I.moves.get(id);
|
|
310
|
+
push({ id, src: 'jira', key: id, title: str(rd.summary || id, 300), ini: placed && iniBy.has(placed) ? placed : null, kind: str(rd.type || 'Task', 20), milestone: false,
|
|
311
|
+
epic: epicOf(rd.parent || null), ...whoOf(rd.assignee), state: rd.category === 'doing' ? 'In progress' : 'To do', due: null,
|
|
312
|
+
sprint: rd.sprint && rd.sprint.name ? { name: str(rd.sprint.name, 80), state: rd.sprint.state || '' } : null, url: rd.url || null });
|
|
313
|
+
}
|
|
314
|
+
for (const w of I.homeless || []) {
|
|
315
|
+
if (!w || !w.uid || seen.has(w.uid)) continue;
|
|
316
|
+
seen.add(w.uid);
|
|
317
|
+
push({ id: String(w.uid), src: 'pmos', key: '', title: str(w.title, 300), ini: null, kind: w.milestone ? 'Milestone' : 'Task', milestone: !!w.milestone, epic: null, ...whoOf(w.owner),
|
|
318
|
+
state: OPEN.has(w.status) ? w.status : w.status || 'To do', due: w.end || null, sprint: null, url: null });
|
|
319
|
+
}
|
|
320
|
+
return out;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
module.exports = { KINDS, MODE_LABEL, GUARDS, modeOf, countKinds, takeOf, reviewWhy, guardOf, filesOf, messageTo, docTo, agentOf, foldGives, runTaskId, proposeHome, tasksOf, keyOf };
|
package/workspace/lib/day-run.js
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
*
|
|
15
15
|
* newRun(date, now) · readRun(raw, date)
|
|
16
16
|
* addTasks(run, brief) agent priorities (kind approve|auto) → waiting tasks
|
|
17
|
-
* addBriefed(run, spec) one task the PM briefed in My work (initiative my-work, PRD R5)
|
|
17
|
+
* addBriefed(run, spec) one task the PM briefed in My work (initiative my-work, PRD R5), or gave to PMOS in the
|
|
18
|
+
* Backlog (work-backlog): spec.kind 'auto' finishes when its draft arrives, else it waits
|
|
18
19
|
* withdraw(run, taskId) a failed task taken out, so its item can be briefed again
|
|
19
20
|
* addSend(run, spec, now) the PM's own text, written in the card, to post as written (today-act-prepare)
|
|
20
21
|
* toStart(run, limit) the tasks to start now, each with its mode (do | revise | send)
|
|
@@ -130,7 +131,7 @@ function addBriefed(run, spec) {
|
|
|
130
131
|
if (!text(s.instruction)) return { ok: false, error: 'a briefed task needs the PM\'s instruction' };
|
|
131
132
|
if (findTask(run, s.id)) return { ok: false, error: `task ${s.id} is already in today's run` };
|
|
132
133
|
const next = clone(run);
|
|
133
|
-
next.tasks.push({ id: s.id, item_id: /^[0-9a-f]{12}$/.test(String(s.item_id || '')) ? s.item_id : null, title: text(s.title).slice(0, 250) || s.id, kind: 'approve', source: s.source || 'my-work', link: isUrl(s.link) ? s.link : null,
|
|
134
|
+
next.tasks.push({ id: s.id, item_id: /^[0-9a-f]{12}$/.test(String(s.item_id || '')) ? s.item_id : null, title: text(s.title).slice(0, 250) || s.id, kind: s.kind === 'auto' ? 'auto' : 'approve', source: s.source || 'my-work', link: isUrl(s.link) ? s.link : null,
|
|
134
135
|
goal: null, my_work: s.my_work || null, brief_at: s.brief_at || null, instruction: text(s.instruction), context: s.context && typeof s.context === 'object' ? clone(s.context) : null,
|
|
135
136
|
status: 'waiting', session_id: null, started_at: null, attempts: 0, revisions: [], draft: null, decided: null, error: null,
|
|
136
137
|
...(Array.isArray(s.log) && s.log.length ? { log: clone(s.log).slice(-MAX_LOG) } : {}) });
|
|
@@ -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 };
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
* A Jira item and a plan end: no route here writes them, so what PMOS suggests is kept by Events or is a task for the PM:
|
|
43
43
|
* met late, and its initiative is in a stage after Deliver: "It looks done. Mark it done". Events stops listing it.
|
|
44
44
|
* gone late OLD_DAYS days or more: "Drop this date". Events stops listing it.
|
|
45
|
+
* drafts a report draft older than DRAFT_OLD_DAYS is not a row of its own: the old ones are one row, "N old report drafts", with "Drop them"
|
|
46
|
+
* (suggest.keys: each draft's key, marked dropped). A report row says the report's name and the day in words, never a file name.
|
|
45
47
|
* ask any other late one: "Ask the owner for a new date". Coming up and at risk: "Ask the owner if <day> holds". ✓ adds the ask as the
|
|
46
48
|
* PM's own task, due today.
|
|
47
49
|
* EVERY LATE AND AT-RISK ROW HAS ONE (round 2, point 5). What the rules above leave empty:
|
|
@@ -79,6 +81,9 @@ function shortDay(d, today) {
|
|
|
79
81
|
}
|
|
80
82
|
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
81
83
|
const cap = (s) => String(s || '').replace(/[-_]+/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
84
|
+
/** A person's name as a name: "vidhi" → "Vidhi", "budi santoso" → "Budi Santoso". A name written with any capital stays as written. */
|
|
85
|
+
const personName = (s) => { const t = String(s || '').trim(); return /[A-Z]/.test(t) ? t : t.replace(/(^|[\s.'-])([a-z])/g, (m, a, c) => a + c.toUpperCase()); };
|
|
86
|
+
const DRAFT_OLD_DAYS = 14;
|
|
82
87
|
|
|
83
88
|
/** The name of a stage key or name, from the row's own workflow when it has one. */
|
|
84
89
|
function stageName(r, sec) {
|
|
@@ -207,22 +212,46 @@ function build(input = {}) {
|
|
|
207
212
|
}
|
|
208
213
|
}
|
|
209
214
|
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
// a report's name, never its file: the schedule's name, else its cadence in words ("idpf-sprint-biweekly-update" → "IDPF sprint biweekly
|
|
216
|
+
// update"; a word that is a product's short name is written in capitals); the date goes beside it in words
|
|
217
|
+
const shorts = new Set(['pmos']);
|
|
218
|
+
for (const b of input.boards || []) for (const w of String(b.name || b.ws || '').toLowerCase().split(/[-_\s]+/)) if (/^[a-z]{2,5}$/.test(w) && w !== 'the') shorts.add(w);
|
|
219
|
+
const nameOfCadence = new Map((input.schedules || []).filter((x) => x && x.cadence && x.name).map((x) => [x.cadence, x.name]));
|
|
220
|
+
const reportName = (cadence) => {
|
|
221
|
+
const n = nameOfCadence.get(cadence);
|
|
222
|
+
if (n) return clip(n, 120);
|
|
223
|
+
const words = String(cadence || 'report').split(/[-_\s]+/).filter(Boolean).map((w) => (shorts.has(w.toLowerCase()) ? w.toUpperCase() : w.toLowerCase()));
|
|
224
|
+
const t = words.join(' ');
|
|
225
|
+
// one word ("weekly") is a cadence, so it is "Weekly report"; more words are the report's own name
|
|
226
|
+
return clip((/^[A-Z]{2,}\b/.test(t) ? t : t.replace(/^./, (c) => c.toUpperCase())) + (words.length === 1 && !/^report$/i.test(t) ? ' report' : ''), 120);
|
|
227
|
+
};
|
|
228
|
+
const draftOf = new Map(); // ws|cadence → the newest draft
|
|
229
|
+
for (const d of input.drafts || []) { const k = (d && d.ws || '') + '|' + (d && d.cadence); if (d && d.cadence && !draftOf.has(k)) draftOf.set(k, d); }
|
|
212
230
|
// a draft whose report goes out today is said on that report's row, not on a row of its own
|
|
213
231
|
const outToday = new Set((input.schedules || []).filter((s) => s && isDay(s.next) && day10(s.next) === today).map((s) => s.cadence));
|
|
232
|
+
const oldDrafts = [];
|
|
214
233
|
for (const d of draftOf.values()) {
|
|
215
234
|
if (outToday.has(d.cadence)) continue;
|
|
216
|
-
|
|
217
|
-
|
|
235
|
+
const key = 'draft:' + (d.ws || '') + '|' + d.cadence + '|' + (d.slot || '');
|
|
236
|
+
if (gone.has(key)) continue;
|
|
237
|
+
// a draft more than two weeks old is not today's work: the old ones are one line, "N old report drafts", that PMOS offers to drop
|
|
238
|
+
if (isDay(d.slot) && daysBetween(day10(d.slot), today) > DRAFT_OLD_DAYS) { oldDrafts.push(key); continue; }
|
|
239
|
+
put({ key, kind: 'report', date: today, time: null, until: null, title: reportName(d.cadence) + (isDay(d.slot) ? ' · ' + shortDay(d.slot, today) : ''),
|
|
240
|
+
line: 'The draft waits for you to issue it', product: '', work: null, task: null, own: null, jira: false, canFix: false, editable: false, draft: true,
|
|
218
241
|
scope: d.ws ? ['p:' + d.ws] : [], act: { label: 'Read the draft', href: '/premium-intelligence.html?tab=library' } });
|
|
219
242
|
}
|
|
243
|
+
if (oldDrafts.length) {
|
|
244
|
+
put({ key: 'drafts:old', kind: 'report', date: today, time: null, until: null, title: oldDrafts.length + ' old report ' + (oldDrafts.length === 1 ? 'draft' : 'drafts'),
|
|
245
|
+
line: 'More than ' + DRAFT_OLD_DAYS + ' days old, not issued', product: '', work: null, task: null, own: null, jira: false, canFix: false, editable: false, draft: true,
|
|
246
|
+
oldDrafts, scope: [], act: { label: 'Read the drafts', href: '/premium-intelligence.html?tab=library' } });
|
|
247
|
+
}
|
|
248
|
+
const draftByCadence = new Map([...draftOf.values()].map((d) => [d.cadence, d]));
|
|
220
249
|
for (const s of input.schedules || []) {
|
|
221
250
|
if (!s || !isDay(s.next)) continue;
|
|
222
|
-
const name =
|
|
223
|
-
const d =
|
|
251
|
+
const name = reportName(s.cadence) ;
|
|
252
|
+
const d = draftByCadence.get(s.cadence);
|
|
224
253
|
const waits = d && daysBetween(today, s.next) === 0;
|
|
225
|
-
put({ key: 'rep:' + (s.id || s.cadence) + ':' + day10(s.next), kind: 'report', date: s.next, time: /^\d{2}:\d{2}$/.test(String(s.time || '')) ? s.time : null, until: null, title: name,
|
|
254
|
+
put({ key: 'rep:' + (s.id || s.cadence) + ':' + day10(s.next), kind: 'report', date: s.next, time: /^\d{2}:\d{2}$/.test(String(s.time || '')) ? s.time : null, until: null, title: s.name ? clip(s.name, 120) : name,
|
|
226
255
|
line: [s.cadence ? 'Goes out ' + String(s.cadence).replace(/[-_]+/g, ' ') : 'Goes out', waits ? 'the draft waits for you' : ''].filter(Boolean).join(' · '), product: '', work: null, task: null, own: null, jira: false, canFix: false, editable: false,
|
|
227
256
|
scope: [], act: waits ? { label: 'Read the draft', href: '/premium-intelligence.html?tab=library' } : null });
|
|
228
257
|
}
|
|
@@ -274,7 +303,7 @@ function build(input = {}) {
|
|
|
274
303
|
return declined.has(sig) ? null : { ...s, sig };
|
|
275
304
|
};
|
|
276
305
|
// a Jira date or a plan end: Events keeps the PM's answer (met, gone), or the PM asks the owner
|
|
277
|
-
const owner = (r) => (r && r.owner && !MINE.test(String(r.owner).trim()) ? clip(r.owner, 40) : 'the owner');
|
|
306
|
+
const owner = (r) => (r && r.owner && !MINE.test(String(r.owner).trim()) ? clip(personName(r.owner), 40) : 'the owner');
|
|
278
307
|
const askHolds = (x, r, why) => { const who = owner(r), d = shortDay(x.date, today); return say(x, { op: 'ask', ask: 'Ask ' + who + ' if ' + d + ' holds: ' + x.title, text: 'Ask ' + who + ' if ' + d + ' holds', why }); };
|
|
279
308
|
const noWrite = (x, r) => {
|
|
280
309
|
if (x.group === 'late') {
|
|
@@ -295,7 +324,7 @@ function build(input = {}) {
|
|
|
295
324
|
if (x.kind === 'deadline') {
|
|
296
325
|
if (x.group !== 'late') continue;
|
|
297
326
|
if (-x.days >= DROP_DAYS) { x.suggest = say(x, { op: 'gone', text: 'Drop this date', why: 'It is ' + (-x.days) + ' days past, and no source names a new one.' }); continue; }
|
|
298
|
-
const who = x.who ? clip(x.who, 40) : 'them';
|
|
327
|
+
const who = x.who ? clip(personName(x.who), 40) : 'them';
|
|
299
328
|
x.suggest = say(x, { op: 'ask', ask: 'Ask ' + who + ' where it stands: ' + x.title, text: 'Ask ' + who + ' where it stands', why: 'The day ' + x.source.from + ' named has passed.' });
|
|
300
329
|
continue;
|
|
301
330
|
}
|
|
@@ -347,6 +376,13 @@ function build(input = {}) {
|
|
|
347
376
|
x.suggest = askHolds(x, x.row, 'The work is at risk.');
|
|
348
377
|
}
|
|
349
378
|
}
|
|
379
|
+
// the old report drafts: one suggestion for all of them. ✓ marks each one dropped (Events stops listing it; the files stay), with Undo
|
|
380
|
+
for (const x of items) {
|
|
381
|
+
if (!x.oldDrafts) continue;
|
|
382
|
+
const sig = 'drafts:old|gone|' + x.oldDrafts.length;
|
|
383
|
+
x.suggest = declined.has(sig) ? null : { op: 'gone', keys: x.oldDrafts.slice(), text: 'Drop them', why: 'None was issued, and the newest is more than ' + DRAFT_OLD_DAYS + ' days old. The files stay in the Library.', sig };
|
|
384
|
+
delete x.oldDrafts;
|
|
385
|
+
}
|
|
350
386
|
|
|
351
387
|
const ORDER = { late: 0, today: 1, coming: 2, later: 3 };
|
|
352
388
|
// Late: the newest first, so the dates you can still save come before the old ones. A day: the dates with no time first, then by time
|
|
@@ -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. */
|
|
@@ -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
|
}
|