create-pmos 0.819.0 → 0.821.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 +38 -38
- 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/scripts/workflows.js +26 -6
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +37 -24
- package/workspace/guide/cli.md +12 -0
- package/workspace/lib/driver.js +2 -0
- package/workspace/lib/engine/workflows.js +26 -6
- package/workspace/lib/hire-draft.js +172 -0
- package/workspace/lib/line-driver.js +40 -12
- package/workspace/lib/line.js +30 -8
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +1 -1
- package/workspace/lib/routes-stage-signoffs.js +71 -0
- package/workspace/lib/routes-your-move.js +10 -1
- package/workspace/lib/signoff-cli.js +13 -3
- package/workspace/lib/signoffs.js +24 -4
- package/workspace/lib/stage-signoffs.js +207 -0
- package/workspace/lib/vendor/scripts/workflows.js +26 -6
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-today-app.js +61 -1
- package/workspace/public/pm/cozy-today-model.js +20 -4
- package/workspace/public/pm/cozy-today-view.js +17 -2
- package/workspace/public/pm/home-app.js +1 -1
- package/workspace/run-tests.js +37 -4
- package/workspace/test-lists/factory-signoffs-reach-you.json +9 -0
- package/workspace/test-lists/next-hire-draft.json +9 -0
- package/workspace/test-timings.json +499 -114
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* hire-draft.js — draft the next hire from the work that waits (initiative next-hire-draft, job #1876, idea A75). `pmos hire …`.
|
|
3
|
+
*
|
|
4
|
+
* A PM who asks for headcount has to show where the team is short. PMOS already holds the open tasks and their owners, each person's
|
|
5
|
+
* role in People and the asks that wait on someone. This adds them up by role and drafts a one-page role brief, a DRAFT document for the
|
|
6
|
+
* PM to edit and share by hand. No model call; every number comes from a record. Nothing is sent.
|
|
7
|
+
*
|
|
8
|
+
* gapOf({ tasks, people, asks, pm }) PURE → { groups: [group], pick: group | null }
|
|
9
|
+
* tasks [{ title, owner, initiative, done }] open board tasks (lib/away-handover.js tasksNow); done ones do not count
|
|
10
|
+
* people [{ name, role }] People (lib/people-store.js view): an owner's role, matched by name
|
|
11
|
+
* asks [{ owner, toPm, n }] the open-questions register (lib/open-questions.js read): asks waiting on someone
|
|
12
|
+
* A group is one role: { role, people: [name], tasks, asks, load (open tasks and asks per person), byIni: [{ ini, n }], titles }.
|
|
13
|
+
* An owner with no role recorded is in the group "No role recorded"; work with no owner is the group "No owner" (load = its tasks).
|
|
14
|
+
* The pick is the group with the highest load, when it reaches LOAD_MIN and no other group has the same load. Otherwise none.
|
|
15
|
+
* briefOf(pick, { day, titles }) PURE → Markdown, the role brief (frontmatter type Research, kind: role-brief)
|
|
16
|
+
* draft(root, { now, sources }) → { ok, file, pick, kept? } | { ok: false, none: true, groups } never writes over a brief
|
|
17
|
+
* count(root, { days, now }) → the briefs drafted in the last days
|
|
18
|
+
* CLI: pmos hire [draft|show|count] [--json] [--days N]
|
|
19
|
+
* The brief is a plain file under planning/hires/ (a kit: pmos/planning/hires/). PMOS runs no git command; the Library lists it once the
|
|
20
|
+
* PM commits it. Each command records one use-log line (control hireDraft), the count the kill reads. Every log line carries [hire-draft]. */
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
|
|
24
|
+
const TAG = '[hire-draft]';
|
|
25
|
+
const LOAD_MIN = 6;
|
|
26
|
+
const NO_ROLE = 'No role recorded';
|
|
27
|
+
const NO_OWNER = 'No owner';
|
|
28
|
+
const one = (s, n = 200) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
29
|
+
const key = (s) => one(s, 120).toLowerCase();
|
|
30
|
+
const localDay = (t = Date.now()) => { const d = new Date(t); return new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().slice(0, 10); };
|
|
31
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
32
|
+
const slug = (s) => key(s).replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40) || 'role';
|
|
33
|
+
|
|
34
|
+
/** PURE. */
|
|
35
|
+
function gapOf({ tasks = [], people = [], asks = [], pm = '' } = {}) {
|
|
36
|
+
const roleOf = new Map();
|
|
37
|
+
for (const p of people || []) if (p && p.name) roleOf.set(key(p.name), one(p.role, 80));
|
|
38
|
+
const G = new Map();
|
|
39
|
+
const group = (role) => { if (!G.has(role)) G.set(role, { role, people: new Set(), tasks: 0, asks: 0, byIni: new Map(), titles: [] }); return G.get(role); };
|
|
40
|
+
for (const t of tasks || []) {
|
|
41
|
+
if (!t || t.done || !one(t.title)) continue;
|
|
42
|
+
const owner = one(t.owner, 80);
|
|
43
|
+
const g = group(owner ? roleOf.get(key(owner)) || NO_ROLE : NO_OWNER);
|
|
44
|
+
if (owner) g.people.add(owner);
|
|
45
|
+
g.tasks += 1;
|
|
46
|
+
if (t.initiative) g.byIni.set(t.initiative, (g.byIni.get(t.initiative) || 0) + 1);
|
|
47
|
+
if (g.titles.length < 8) g.titles.push(one(t.title, 120));
|
|
48
|
+
}
|
|
49
|
+
for (const a of asks || []) {
|
|
50
|
+
if (!a || a.toPm || !one(a.owner) || (pm && key(a.owner) === key(pm))) continue;
|
|
51
|
+
const owner = one(a.owner, 80);
|
|
52
|
+
const g = group(roleOf.get(key(owner)) || NO_ROLE);
|
|
53
|
+
g.people.add(owner);
|
|
54
|
+
g.asks += Math.max(1, Number(a.n) || 1);
|
|
55
|
+
}
|
|
56
|
+
const groups = [...G.values()].map((g) => {
|
|
57
|
+
const n = g.people.size;
|
|
58
|
+
const load = g.role === NO_OWNER ? g.tasks : n ? Math.round(((g.tasks + g.asks) / n) * 10) / 10 : 0;
|
|
59
|
+
return { role: g.role, people: [...g.people].sort(), tasks: g.tasks, asks: g.asks, load,
|
|
60
|
+
byIni: [...g.byIni].map(([ini, k]) => ({ ini, n: k })).sort((a, b) => b.n - a.n || a.ini.localeCompare(b.ini)), titles: g.titles };
|
|
61
|
+
}).sort((a, b) => b.load - a.load || a.role.localeCompare(b.role));
|
|
62
|
+
const top = groups[0];
|
|
63
|
+
const pick = top && top.load >= LOAD_MIN && !(groups[1] && groups[1].load === top.load) ? top : null;
|
|
64
|
+
return { groups, pick };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The one sentence why: the counts it read. */
|
|
68
|
+
function whyOf(g) {
|
|
69
|
+
if (g.role === NO_OWNER) return `${plural(g.tasks, 'open task has', 'open tasks have')} no owner`;
|
|
70
|
+
return `${plural(g.people.length, 'person', 'people')} (${g.people.join(', ')}) ${g.people.length === 1 ? 'holds' : 'hold'} ${plural(g.tasks, 'open task', 'open tasks')}${g.asks ? ' and ' + plural(g.asks, 'waiting ask', 'waiting asks') : ''}: ${g.load} per person`;
|
|
71
|
+
}
|
|
72
|
+
function roleName(g) { return g.role === NO_OWNER ? 'An owner for the work with no owner' : g.role === NO_ROLE ? 'A second person for the work of ' + g.people.join(', ') : g.role; }
|
|
73
|
+
|
|
74
|
+
/** PURE. The role brief. titles: initiative id → title. */
|
|
75
|
+
function briefOf(g, { day, titles = {} } = {}) {
|
|
76
|
+
const role = roleName(g);
|
|
77
|
+
const out = ['---', 'type: Research', 'kind: role-brief', `title: ${JSON.stringify('Role brief: ' + role)}`, `timestamp: ${day}`, `role: ${JSON.stringify(g.role)}`, '---', '',
|
|
78
|
+
`# Role brief: ${role}`, '',
|
|
79
|
+
`_A draft from PMOS, read from your open tasks, People and the asks that wait on someone on ${day}. Edit it before you share it. Nothing was sent._`, '',
|
|
80
|
+
'## Why now', '', `${whyOf(g)}.${g.role === NO_ROLE ? ' People has no role for them yet: add one there and draft again to name the role.' : ''} No other role carries as much open work per person.`, '',
|
|
81
|
+
'## Outcomes for the first 90 days', ''];
|
|
82
|
+
const ini = g.byIni.slice(0, 3);
|
|
83
|
+
if (ini.length) ini.forEach((x, i) => out.push(`${i + 1}. Own the open work on ${titles[x.ini] || x.ini} (${plural(x.n, 'task', 'tasks')} today), and close it or hand it on with a date.`));
|
|
84
|
+
else out.push('1. Take the asks that wait on this role, and answer each within a week.');
|
|
85
|
+
out.push('', '## The work it takes', '');
|
|
86
|
+
for (const t of g.titles.slice(0, 6)) out.push(`- ${t}`);
|
|
87
|
+
if (!g.titles.length) out.push('- The asks that wait on this role.');
|
|
88
|
+
out.push('', '## Skills', '', `- The skills the work above needs${g.role !== NO_OWNER && g.role !== NO_ROLE ? ', as a ' + g.role + ' has them' : ''}. Name them here.`, '');
|
|
89
|
+
return out.join('\n');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function dirOf(root) {
|
|
93
|
+
const kit = fs.existsSync(path.join(root, 'pmos', 'state'));
|
|
94
|
+
return path.join(root, ...(kit ? ['pmos', 'planning'] : ['planning']), 'hires');
|
|
95
|
+
}
|
|
96
|
+
function sourcesOf(root, { now }) {
|
|
97
|
+
let tasks = []; try { tasks = require('./away-handover.js').tasksNow(root); } catch { tasks = []; }
|
|
98
|
+
let people = []; try { const v = require('./people-store.js').view(root, { now }); people = v.ok ? v.people || [] : []; } catch { people = []; }
|
|
99
|
+
let asks = []; try { asks = require('./open-questions.js').read(root, { now }).lines || []; } catch { asks = []; }
|
|
100
|
+
let titles = {}; try { for (const i of require('./live-notes.js').loadInitiatives(root).open) titles[i.id] = i.title; } catch { titles = {}; }
|
|
101
|
+
return { tasks, people, asks, titles };
|
|
102
|
+
}
|
|
103
|
+
function draft(root, { now = Date.now(), sources } = {}) {
|
|
104
|
+
const S = sources || sourcesOf(root, { now });
|
|
105
|
+
const G = gapOf(S);
|
|
106
|
+
if (!G.pick) return { ok: false, none: true, groups: G.groups };
|
|
107
|
+
const day = localDay(now);
|
|
108
|
+
const file = path.join(dirOf(root), `${day}-${slug(G.pick.role)}.md`);
|
|
109
|
+
if (fs.existsSync(file)) return { ok: true, file, pick: G.pick, kept: true }; // the PM may have edited it: a draft is never written over
|
|
110
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
111
|
+
fs.writeFileSync(file, briefOf(G.pick, { day, titles: S.titles || {} }));
|
|
112
|
+
console.log(`${TAG} drafted ${path.basename(file)} role=${G.pick.role} load=${G.pick.load}`);
|
|
113
|
+
return { ok: true, file, pick: G.pick };
|
|
114
|
+
}
|
|
115
|
+
function count(root, { days = 7, now = Date.now() } = {}) {
|
|
116
|
+
const from = localDay(now - (days - 1) * 864e5);
|
|
117
|
+
try { return fs.readdirSync(dirOf(root)).filter((f) => /^\d{4}-\d{2}-\d{2}-.+\.md$/.test(f) && f.slice(0, 10) >= from).length; } catch { return 0; }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* ── pmos hire ─────────────────────────────────────────────────────────────────────────────────────────── */
|
|
121
|
+
const COMMANDS = { hire: ['draft', 'show', 'count'] };
|
|
122
|
+
const USAGE = [
|
|
123
|
+
'usage: pmos hire [draft|show|count] — the role your open work most needs, and a one-page role brief to edit',
|
|
124
|
+
' pmos hire show open tasks and waiting asks per role, most per person first (writes nothing)',
|
|
125
|
+
' pmos hire draft draft the role brief into planning/hires/ (an edited brief is kept as it is)',
|
|
126
|
+
' pmos hire count [--days 7] how many briefs were drafted in the last days; the number is the last line',
|
|
127
|
+
'The brief is a draft for you to read and share. Nothing is sent.',
|
|
128
|
+
];
|
|
129
|
+
function repoOf(cwd) {
|
|
130
|
+
let d = path.resolve(cwd);
|
|
131
|
+
for (;;) { try { if (fs.existsSync(path.join(d, '.git'))) return d; } catch { /* look further up */ } const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
|
|
132
|
+
}
|
|
133
|
+
function used(o, now) {
|
|
134
|
+
try { const dir = o.stateDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }); require('./use-log.js').record(dir, [{ kind: 'use', page: 'today', control: 'hireDraft', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
|
|
135
|
+
}
|
|
136
|
+
function run(argv, o = {}) {
|
|
137
|
+
const say = o.say || ((s) => console.log(s)), now = o.now || Date.now();
|
|
138
|
+
const args = argv[0] === 'hire' ? argv.slice(1) : argv.slice();
|
|
139
|
+
const pos = [], flags = {};
|
|
140
|
+
for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root' || a === '--days') flags[a.slice(2)] = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
|
|
141
|
+
const cmd = pos[0] || 'draft';
|
|
142
|
+
if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
|
|
143
|
+
if (!COMMANDS.hire.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos hire`); USAGE.forEach((l) => say(l)); return 2; }
|
|
144
|
+
const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
|
|
145
|
+
if (cmd === 'count') {
|
|
146
|
+
const days = Math.max(1, Math.min(365, parseInt(flags.days, 10) || 7));
|
|
147
|
+
const n = count(root, { days, now });
|
|
148
|
+
say(`${TAG} ${plural(n, 'role brief', 'role briefs')} drafted in the last ${days} days.`);
|
|
149
|
+
say(String(n));
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
const S = o.sources || sourcesOf(root, { now });
|
|
153
|
+
if (cmd === 'show') {
|
|
154
|
+
const G = gapOf(S);
|
|
155
|
+
if (flags.json) { say(JSON.stringify({ ok: true, ...G })); return 0; }
|
|
156
|
+
if (!G.groups.length) { say('No open task or waiting ask has an owner yet.'); return 0; }
|
|
157
|
+
for (const g of G.groups.slice(0, 10)) say(`- ${g.role}: ${whyOf(g)}.`);
|
|
158
|
+
say(G.pick ? `Most needed: ${roleName(G.pick)}. pmos hire draft writes its brief.` : `No role reaches ${LOAD_MIN} open tasks and asks per person yet.`);
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
used(o, now);
|
|
162
|
+
const d = draft(root, { now, sources: S });
|
|
163
|
+
if (flags.json) { say(JSON.stringify({ ok: d.ok, none: !!d.none, path: d.file ? path.relative(root, d.file) : null, role: d.pick ? d.pick.role : null, kept: !!d.kept })); return 0; }
|
|
164
|
+
if (d.none) { say(`No gap is clear yet: no role reaches ${LOAD_MIN} open tasks and asks per person, and no two are told apart. Nothing was written. pmos hire show lists them.`); return 0; }
|
|
165
|
+
const rel = path.relative(root, d.file);
|
|
166
|
+
if (d.kept) { say(`The role brief for today is already there, and PMOS keeps your edits: ${rel}.`); return 0; }
|
|
167
|
+
say(`✓ Drafted ${rel}: ${roleName(d.pick)}. ${whyOf(d.pick)}.`);
|
|
168
|
+
say('Edit it and share it yourself; PMOS sends nothing. The Library lists it once you commit it.');
|
|
169
|
+
return 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
module.exports = { TAG, LOAD_MIN, NO_ROLE, NO_OWNER, gapOf, briefOf, draft, count, run, COMMANDS, USAGE };
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* workOf(row) PURE → { act, why, station, missing, next, flag } whether the Driver works this row's exit items
|
|
8
8
|
* exitFact(row) PURE → the `exit` fact lib/driver-facts.js adds to one initiative (null when there is no row)
|
|
9
9
|
* blockerOf(fact, state, { now }) PURE → null | { code: 'exit-missing', text, items, key } for lib/driver.js detect: a wake when the
|
|
10
|
-
* missing set is new, and again each REWAKE_DAYS while it stays the same
|
|
10
|
+
* missing set is new, and again each REWAKE_DAYS while it stays the same. Sign-offs are left out.
|
|
11
|
+
* signoffBlockerOf(fact) PURE → null | { code: 'signoff-missing', text, items } the PM's blocker for the stage's sign-offs
|
|
11
12
|
* checkExits(data) PURE → { ok, exits } | { ok: false, error } the shape of a move's `exits` list
|
|
12
13
|
* quoteCheck(exits, readText) PURE → { ok, checks: [{ item, ok, why }] } every exit quotes a line that is really in its record
|
|
13
|
-
* moveGate({ row, exits, from, readText }) PURE → { ok, why, checks } the Checker's gate before PMOS moves a stage by itself
|
|
14
|
+
* moveGate({ row, exits, from, readText, done }) PURE → { ok, why, checks } the Checker's gate before PMOS moves a stage by itself
|
|
15
|
+
* (done: the To finish lines a Done task finished; they need no quote)
|
|
14
16
|
* readerOf(root, initiative) → readText(ref) → text | null a file inside the repository, or a Jira key in the initiative's read
|
|
15
17
|
* trackerOf(root, initiative) → [{ key, summary, assignee, sprint, start, end }] who holds each ticket and in which sprint
|
|
16
18
|
* linesFor(row, tracker) PURE → [text] the work list a Driver run reads (`pmos driver exits <id>`)
|
|
@@ -59,13 +61,18 @@ function workOf(row) {
|
|
|
59
61
|
function exitFact(row) {
|
|
60
62
|
if (!row) return null;
|
|
61
63
|
const w = workOf(row);
|
|
62
|
-
|
|
64
|
+
const so = Array.isArray(row.signoffs) ? row.signoffs.filter((x) => x && x.item).slice(0, 12) : [];
|
|
65
|
+
return { station: w.station ? w.station.name : null, missing: (w.missing || []).slice(0, 12), ...(so.length ? { signoffs: so } : {}), next: w.next, flag: w.flag, act: w.act, why: w.why };
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
/** lib/driver.js detect: one exit-missing blocker while the Driver can act on missing items. It wakes a run when the missing set is new
|
|
66
69
|
* for this station, and again every REWAKE_DAYS while it stays the same (state.blockerDays holds `key|day` of every blocker line). */
|
|
67
|
-
function blockerOf(
|
|
68
|
-
if (!
|
|
70
|
+
function blockerOf(fact0, state, { now = Date.now() } = {}) {
|
|
71
|
+
if (!fact0 || !fact0.act || !Array.isArray(fact0.missing) || !fact0.missing.length) return null;
|
|
72
|
+
// factory-signoffs-reach-you: a sign-off (a To finish line with by:) is the person's to give; the Driver never wakes for it
|
|
73
|
+
const signed = new Set((fact0.signoffs || []).map((x) => lc(x.item)));
|
|
74
|
+
const fact = signed.size ? { ...fact0, missing: fact0.missing.filter((m) => !signed.has(lc(m))) } : fact0;
|
|
75
|
+
if (!fact.missing.length) return null;
|
|
69
76
|
const key = `exit-missing:${hash(`${fact.station}|${fact.missing.join('|')}`)}`;
|
|
70
77
|
const seen = state && state.blockerDays instanceof Set ? state.blockerDays : new Set();
|
|
71
78
|
for (const k of seen) {
|
|
@@ -78,6 +85,15 @@ function blockerOf(fact, state, { now = Date.now() } = {}) {
|
|
|
78
85
|
return { code: 'exit-missing', key, items, text: `${fact.station}: missing ${items.join('; ')}${fact.missing.length > 5 ? ` (+${fact.missing.length - 5} more)` : ''}` };
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
/** lib/driver.js detect: the PM's blocker for the stage's missing sign-offs (factory-signoffs-reach-you). It is owned by the PM, so it never
|
|
89
|
+
* wakes a run; Today › Your move shows one row per sign-off (lib/stage-signoffs.js). PURE → null | { code: 'signoff-missing', text, items } */
|
|
90
|
+
function signoffBlockerOf(fact) {
|
|
91
|
+
if (!fact || !fact.act || !Array.isArray(fact.signoffs) || !fact.signoffs.length) return null;
|
|
92
|
+
const items = fact.signoffs.slice(0, 5);
|
|
93
|
+
return { code: 'signoff-missing', items: items.map((x) => x.item),
|
|
94
|
+
text: `${fact.station}: waits on ${items.map((x) => `${x.by}'s yes on "${x.item}"`).join('; ')}${fact.signoffs.length > 5 ? ` (+${fact.signoffs.length - 5} more)` : ''}` };
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
/** The shape of a move's exits: [{ item, quote, ref }], at most 20. */
|
|
82
98
|
function checkExits(data) {
|
|
83
99
|
const list = isObj(data) ? data.exits : undefined;
|
|
@@ -118,21 +134,27 @@ function exitItemsOf(boardRow) {
|
|
|
118
134
|
}
|
|
119
135
|
|
|
120
136
|
/** The Checker's gate before PMOS moves a stage by itself. row: the line row; boardRow: the Board's row (its stage's To finish lines). */
|
|
121
|
-
function moveGate({ row, boardRow, exits, from, readText }) {
|
|
137
|
+
function moveGate({ row, boardRow, exits, from, readText, done = [] }) {
|
|
122
138
|
const w = workOf(row);
|
|
123
139
|
if (!row || !row.live) return { ok: false, why: 'the initiative is not on the line', checks: [] };
|
|
124
140
|
if (row.flag === 'cant-tell') return { ok: false, why: `can't tell where it stands (${row.why}), so PMOS does not move it`, checks: [] };
|
|
125
141
|
const here = row.station;
|
|
126
142
|
if (!here) return { ok: false, why: 'it has no station', checks: [] };
|
|
127
143
|
if (from && lc(from) !== lc(here.key) && lc(from) !== lc(here.name)) return { ok: false, why: `it moved to ${here.name} since (you or the tracker moved it): the move from ${from} no longer applies`, checks: [] };
|
|
128
|
-
|
|
144
|
+
// done: the To finish lines a Done task already finished (the line's own record; factory-signoffs-reach-you). They need no quote, and the
|
|
145
|
+
// checks say so; every other line, a sign-off included, still needs its quote found in its record.
|
|
146
|
+
const byTask = new Set((done || []).map(lc));
|
|
147
|
+
const need = exitItemsOf(boardRow).filter((n) => !byTask.has(lc(n)));
|
|
129
148
|
const given = new Map((exits || []).map((x) => [lc(x.item), x]));
|
|
130
149
|
const absent = need.filter((n) => !given.has(lc(n)));
|
|
131
150
|
if (absent.length) return { ok: false, why: `every exit item of ${here.name} needs a quote: missing ${absent.join('; ')}`, checks: [] };
|
|
151
|
+
const taskChecks = exitItemsOf(boardRow).filter((n) => byTask.has(lc(n))).map((n) => ({ item: n, ref: null, ok: true, why: 'its task is Done' }));
|
|
152
|
+
if (!need.length && taskChecks.length) return { ok: true, why: `every exit item of ${here.name} has a Done task`, checks: taskChecks };
|
|
132
153
|
const q = quoteCheck(need.map((n) => given.get(lc(n))), readText);
|
|
133
|
-
|
|
154
|
+
const checks = taskChecks.concat(q.checks);
|
|
155
|
+
if (!q.ok) return { ok: false, why: q.checks.filter((c) => !c.ok).map((c) => `${c.item}: ${c.why}`).join('; '), checks };
|
|
134
156
|
void w;
|
|
135
|
-
return { ok: true, why: `${q.checks.length} of ${q.checks.length} exit items of ${here.name} quote a real record line
|
|
157
|
+
return { ok: true, why: `${q.checks.length} of ${q.checks.length} exit items of ${here.name} quote a real record line${taskChecks.length ? `; ${taskChecks.length} have a Done task` : ''}`, checks };
|
|
136
158
|
}
|
|
137
159
|
|
|
138
160
|
/** readText for one repository: a path inside it, or a Jira key the initiative's last read holds (its summary, status and sprint). */
|
|
@@ -173,8 +195,14 @@ function linesFor(row, tracker = []) {
|
|
|
173
195
|
if (!row) return ['Not on the line: `pmos line` does not list this initiative.'];
|
|
174
196
|
out.push(`Station: ${w.station ? `${w.station.name} (${w.station.n} of ${w.station.of})` : 'none'} · flag: ${w.flag || 'none'}${row.why ? ` (${row.why})` : ''}.`);
|
|
175
197
|
if (!w.act) { out.push(`Do not work its exit items and do not propose a stage move: ${w.why}.`); return out; }
|
|
176
|
-
|
|
177
|
-
|
|
198
|
+
const so = Array.isArray(row.signoffs) ? row.signoffs : [];
|
|
199
|
+
if (so.length) {
|
|
200
|
+
out.push(`Sign-offs (a person gives these; do not work them): ${so.map((x) => `"${x.item}" by ${x.by}`).join('; ')}. When you find where the yes is written, run \`pmos signoff list ${row.id}\` for its id, then \`pmos signoff evidence <id> --ref <file or Jira key> --quote "<the line, word for word>" [--doc <the document it agrees to>]\`. The PM records it on Today.`);
|
|
201
|
+
}
|
|
202
|
+
const work = so.length ? w.missing.filter((m) => !so.some((x) => lc(x.item) === lc(m))) : w.missing;
|
|
203
|
+
if (so.length && !work.length && w.missing.length) return out;
|
|
204
|
+
if (work.length) {
|
|
205
|
+
out.push(`Missing exit items (the station's To finish lines): ${work.map((m) => `"${m}"`).join('; ')}.`);
|
|
178
206
|
out.push('Work these items first, in this order. For each, file the proposal that gets it done, with its source.');
|
|
179
207
|
} else {
|
|
180
208
|
out.push(`Every exit item is done. Next move: ${w.next}. Propose it with --what move and data {"to": "<stage>", "from": "${w.station.key}", "exits": [{"item": "<each To finish line>", "quote": "<a line copied word for word>", "ref": "<the file path or Jira key it is in>"}]}.`);
|
|
@@ -220,5 +248,5 @@ function countChecks(stateDir, now = Date.now()) {
|
|
|
220
248
|
return { pass, flag };
|
|
221
249
|
}
|
|
222
250
|
|
|
223
|
-
module.exports = { countChecks, boardRowOf, boardMove, stationNow, sameStage, workOf, exitFact, blockerOf, checkExits, quoteCheck, exitItemsOf, moveGate, readerOf, trackerOf, linesFor, CHECKER_REASON, REWAKE_DAYS, MIN_QUOTE };
|
|
251
|
+
module.exports = { countChecks, boardRowOf, boardMove, stationNow, sameStage, workOf, exitFact, blockerOf, signoffBlockerOf, checkExits, quoteCheck, exitItemsOf, moveGate, readerOf, trackerOf, linesFor, CHECKER_REASON, REWAKE_DAYS, MIN_QUOTE };
|
|
224
252
|
|
package/workspace/lib/line.js
CHANGED
|
@@ -55,13 +55,22 @@ function limitOf(st) {
|
|
|
55
55
|
return CAT_LIMIT[st.cat] != null ? CAT_LIMIT[st.cat] : 15;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
function
|
|
58
|
+
/** Who signs off each To finish line of a stage: { [line in lower case]: who }. The stage's own `by:` wins over a kept suggestion. PURE. */
|
|
59
|
+
function byOf(st, kept = null) {
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const src of [kept, st && st.by]) if (src && typeof src === 'object') for (const [k, v] of Object.entries(src)) if (typeof v === 'string' && v.trim()) out[lc(k)] = v.trim();
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The exit items still missing on the current stage. → [text]
|
|
66
|
+
* answered: the To finish lines (lower case) whose sign-off is answered in lib/signoffs.js (factory-signoffs-reach-you): they are done. */
|
|
67
|
+
function missingOf(st, row, tasks, jira, answered = null) {
|
|
60
68
|
const finish = Array.isArray(st.finish) ? st.finish.filter((f) => typeof f === 'string' && f.trim()) : [];
|
|
61
69
|
if (finish.length) {
|
|
62
70
|
const map = row.wfMap || {};
|
|
63
71
|
const mine = (k) => k === st.key || map[k] === st.key;
|
|
64
|
-
|
|
72
|
+
const signed = answered instanceof Set ? answered : new Set();
|
|
73
|
+
return finish.filter((f) => !signed.has(lc(f)) && !(tasks || []).some((t) => t && t.from && mine(t.from.stage) && t.from.finish === f && DONE_STATES.has(lc(t.state))));
|
|
65
74
|
}
|
|
66
75
|
const out = st.output || {};
|
|
67
76
|
if (out.kind === 'jira' && jira && Array.isArray(jira.tickets) && jira.tickets.length) {
|
|
@@ -75,7 +84,7 @@ function missingOf(st, row, tasks, jira) {
|
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
function place(input, now = Date.now()) {
|
|
78
|
-
const { row, tasks = [], moves = [], jira = null, activity = [] } = input || {};
|
|
87
|
+
const { row, tasks = [], moves = [], jira = null, activity = [], signoffs = [], byKept = null } = input || {};
|
|
79
88
|
const one = row.oneStage || {};
|
|
80
89
|
const base = { id: row.id, title: row.title || row.id, workflow: row.wf ? row.wf.name : null };
|
|
81
90
|
const endWord = row.ended ? (row.ended.as === 'wontdo' ? "Won't do" : 'Archived') : row.archived ? 'Archived'
|
|
@@ -102,7 +111,15 @@ function place(input, now = Date.now()) {
|
|
|
102
111
|
const quietDays = last != null ? days(last, now) : null;
|
|
103
112
|
const clock = daysThere != null ? daysThere : quietDays;
|
|
104
113
|
|
|
105
|
-
|
|
114
|
+
// factory-signoffs-reach-you: the stage's sign-offs (its `by:` lines, and the ones the PM kept from PMOS's suggestion); one answered in
|
|
115
|
+
// the sign-off ledger is done, and a missing one is the person's to give, never the Driver's to work
|
|
116
|
+
const by = byOf(st, byKept);
|
|
117
|
+
const answered = new Set((signoffs || []).filter((x) => x && x.state === 'answered' && by[lc(x.what)] != null).map((x) => lc(x.what)));
|
|
118
|
+
const missing = missingOf(st, row, tasks, jira, answered);
|
|
119
|
+
const signoffList = missing.filter((m) => by[lc(m)] != null).map((m) => ({ item: m, by: by[lc(m)] }));
|
|
120
|
+
// a stage with no sign-off lines and no answer to PMOS's suggestion yet: the lines that read as a person's yes (board LnBy4)
|
|
121
|
+
let suggestBy = null;
|
|
122
|
+
if (!Object.keys(by).length && byKept == null && row.wf && row.wf.id) { try { const g = require('./stage-signoffs.js').suggestOf(st); if (Object.keys(g).length) suggestBy = { wf: row.wf.id, stage: st.key, stageName: st.name, by: g }; } catch { suggestBy = null; } }
|
|
106
123
|
const stages = row.wfStages || [];
|
|
107
124
|
const idx = stages.findIndex((s) => s.key === st.key);
|
|
108
125
|
const nextStage = stages.slice(idx + 1).find((s) => s.status !== 'skipped');
|
|
@@ -115,7 +132,7 @@ function place(input, now = Date.now()) {
|
|
|
115
132
|
else next = nextStage ? `move to ${nextStage.name}` : 'close it';
|
|
116
133
|
|
|
117
134
|
const out = { ...base, station, live: true, ended: null, daysThere, since: since != null ? new Date(since).toISOString() : null, setBy,
|
|
118
|
-
quietDays, clock, missing, next, limit: limit === 'tickets' ? `${TICKET_QUIET_WORKDAYS} working days with no ticket change` : limit };
|
|
135
|
+
quietDays, clock, missing, ...(signoffList.length ? { signoffs: signoffList } : {}), ...(suggestBy ? { suggestBy } : {}), next, limit: limit === 'tickets' ? `${TICKET_QUIET_WORKDAYS} working days with no ticket change` : limit };
|
|
119
136
|
const flag = (f, why) => ({ ...out, flag: f, why });
|
|
120
137
|
|
|
121
138
|
if (one.stage === 'on-hold') return flag('waiting', 'on hold: the clock is stopped');
|
|
@@ -245,6 +262,8 @@ function lineOf(root, { only = null, now = Date.now(), derive = true } = {}) {
|
|
|
245
262
|
const liveIds = new Set(base.rows.filter((x) => !(x.status === 'done' || x.lifecycle)).map((x) => x.id));
|
|
246
263
|
let JS = null; try { JS = require('./jira-status.js'); } catch { JS = null; }
|
|
247
264
|
let JT = null; try { JT = require('./jira-tickets.js'); } catch { JT = null; }
|
|
265
|
+
let SO = null, SS = null, soFile = null, kept = null;
|
|
266
|
+
try { SO = require('./signoffs.js'); SS = require('./stage-signoffs.js'); const soDir = JT ? JT.stateDirOf(root) : stateDir; soFile = SO.fileOf(soDir); kept = SS.keptLedger(soDir); } catch { SO = null; SS = null; }
|
|
248
267
|
const rows = [];
|
|
249
268
|
for (const id of ids) {
|
|
250
269
|
const r = boards.initiativeWorkflow(pass, w, id);
|
|
@@ -266,7 +285,10 @@ function lineOf(root, { only = null, now = Date.now(), derive = true } = {}) {
|
|
|
266
285
|
const recRel = typeof b0.record === 'string' ? path.relative(root, path.resolve(root, b0.record)) : null;
|
|
267
286
|
const activity = (acts.get(id) || []).concat(gitTimes(root, recRel, real));
|
|
268
287
|
const deps = depsOf(root, recRel).filter((d) => d !== id && liveIds.has(d));
|
|
269
|
-
|
|
288
|
+
// factory-signoffs-reach-you: this initiative's sign-offs, and the sign-off lines the PM kept from PMOS's suggestion for its stage
|
|
289
|
+
const signoffs = SO ? SO.list(soFile, { ini: id }) : [];
|
|
290
|
+
const byKept = SS && r.row.wf && r.row.wfStage ? SS.keptFor(kept, r.row.wf.id, r.row.wfStage.key) : null;
|
|
291
|
+
rows.push({ deps, doubt: doubtOf(r.row, derived.get(id)), p: place({ row: r.row, tasks, moves, jira, activity, signoffs, byKept }, now) });
|
|
270
292
|
}
|
|
271
293
|
// a dependency counts while it is itself live on the line (not ended): waiting on it is never stuck
|
|
272
294
|
const first = new Map(rows.map((x) => [x.p.id, x.p]));
|
|
@@ -285,4 +307,4 @@ function summary(line) {
|
|
|
285
307
|
return { live, placed, percent: live ? Math.round((placed / live) * 1000) / 10 : 0 };
|
|
286
308
|
}
|
|
287
309
|
|
|
288
|
-
module.exports = { place, lineOf, summary, missingOf, limitOf, activityIndex, doubtOf, depsOf, settle, LIMITS, STALE_DAYS };
|
|
310
|
+
module.exports = { place, lineOf, summary, missingOf, byOf, limitOf, activityIndex, doubtOf, depsOf, settle, LIMITS, STALE_DAYS };
|
|
@@ -53,7 +53,7 @@ const VERBS = Object.freeze({
|
|
|
53
53
|
help: 'pmos people list|show|record|settings … — the people you work with in this repository (pmos people help)' }),
|
|
54
54
|
// Not a pm-os-absorb verb (run: null): initiative dry-run-tickets-before-build added it through the same table.
|
|
55
55
|
signoff: Object.freeze({ module: 'signoff-cli.js', run: null, guide: 'cli.md',
|
|
56
|
-
help: 'pmos signoff ask|answer|drop|list … — the
|
|
56
|
+
help: 'pmos signoff ask|answer|drop|evidence|list … — the sign-offs an initiative waits on; a stage\'s sign-offs are Your move rows on Today (pmos signoff help)' }),
|
|
57
57
|
// Not a pm-os-absorb verb (run: null): initiative my-work added it through the same table.
|
|
58
58
|
'my-work': Object.freeze({ module: 'my-work-cli.js', run: null, guide: 'cli.md',
|
|
59
59
|
help: 'pmos my-work list|show|submit … — the Jira tickets and WBS items assigned to you, ranked (pmos my-work help)' }),
|
|
@@ -157,6 +157,9 @@ const VERBS = Object.freeze({
|
|
|
157
157
|
// Not a pm-os-absorb verb (run: null): initiative three-line-why (bet A86) added it through the same table.
|
|
158
158
|
why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
|
|
159
159
|
help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
|
|
160
|
+
// Not a pm-os-absorb verb (run: null): initiative next-hire-draft (job #1876, A75) added it through the same table.
|
|
161
|
+
hire: Object.freeze({ module: 'hire-draft.js', run: null, guide: 'cli.md',
|
|
162
|
+
help: 'pmos hire [draft|show|count] — the role your open work most needs, per person, and a one-page role brief PMOS drafts for you to edit (pmos hire help)' }),
|
|
160
163
|
// Not a pm-os-absorb verb (run: null): initiative press-release-faq (bet A362) added it through the same table.
|
|
161
164
|
'press-release': Object.freeze({ module: 'press-release-cli.js', run: null, guide: 'cli.md',
|
|
162
165
|
help: 'pmos press-release <initiative> | count — a one-page press release and FAQ for a bet, drafted from its record, for you to edit (pmos press-release help)' }),
|
|
@@ -99,6 +99,7 @@ const MODULES = Object.freeze([
|
|
|
99
99
|
'routes-task-links', // batch 11 item 15: links between tasks, Claude's proposals, the quiet moves (task-links.jsonl; page-press POST)
|
|
100
100
|
'routes-proposals', // batch 12 items 2, 3 and 4: everything Claude proposes on an initiative, under its one ✦ (proposals.jsonl; page-press POST)
|
|
101
101
|
'routes-autonomy', // D106: what agents did by themselves (the Done group, 14 days), its Undo, and the demotions Home says once (autonomy.jsonl)
|
|
102
|
+
'routes-stage-signoffs', // factory-signoffs-reach-you: a stage's sign-offs as Your move rows, ✓ that records one (and moves the stage), Undo, the ✦ suggestion
|
|
102
103
|
'routes-your-move', // workspace grill W3: Your move's overdue outcome verdicts (drafted from Jira) and the first key result with no reading (GET)
|
|
103
104
|
'routes-tracker-sync', // tracker-sync-on-today: the sync with Jira of a product, the PM's ✓ that takes Jira's value, and its Undo (task ledger; page-press POST)
|
|
104
105
|
'routes-standing-rules', // standing-rules-list (A470): the standing rules PMOS keeps, with edit, retire and bring back (memory + standing-rules.jsonl)
|
|
@@ -545,7 +545,7 @@ const wfRowFields = (x) => {
|
|
|
545
545
|
wf: { id: x.wf.id, name: x.wf.name, icon: x.wf.icon, ...(x.own && x.own.pmos ? { setBy: 'pmos', why: x.own.why, from: x.own.from || null } : {}) },
|
|
546
546
|
wfStage: { key: st.key, name: st.name, cat: st.cat, milestone: !!st.milestone, n: st.n, of: st.of },
|
|
547
547
|
wfStages: x.stages.map((s) => ({ key: s.key, name: s.name, cat: s.cat, milestone: !!s.milestone, auto: !!s.auto, when: s.when, status: s.status, reading: s.reading,
|
|
548
|
-
output: s.output, finish: s.finish })), // output and finish: what finishes the stage (the stage card's exit steps on a library workflow)
|
|
548
|
+
output: s.output, finish: s.finish, ...(s.by ? { by: s.by } : {}) })), // output and finish: what finishes the stage (the stage card's exit steps on a library workflow); by: who signs off a line
|
|
549
549
|
ended: x.ended ? { as: x.ended.as, reason: x.ended.reason, note: x.ended.note, at: x.ended.at } : null,
|
|
550
550
|
// batch 20 item 3: where the tasks of an earlier workflow's stages sit now (old key → stage key), and the switch Undo can still put back (7 days)
|
|
551
551
|
wfMap: x.own && x.own.map ? x.own.map : null,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-stage-signoffs.js — a stage's sign-offs as Today › Your move rows (initiative factory-signoffs-reach-you; lib/stage-signoffs.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/stage-signoffs?ws=<id> → { ok, ws, rows: [lib/stage-signoffs.js row], suggest: [suggestion] }
|
|
5
|
+
* POST /api/stage-signoffs/record { ws, ini, id } → { ok, signoff, moved, gate, undo } ✓: the answer, and the stage move when it
|
|
6
|
+
* was the last missing item (one press)
|
|
7
|
+
* POST /api/stage-signoffs/undo { ws, ini, id, from?, to? } → { ok, reopened, movedBack } one Undo for both
|
|
8
|
+
* POST /api/stage-signoffs/suggest { ws, wf, stage, act: 'keep' | 'change' | 'undo', by? } → { ok, line } the ✦ suggestion's answer
|
|
9
|
+
*
|
|
10
|
+
* The rows read the product's kept line (lib/routes-your-move.js lineRowsKept) and never wait for a first read, so the page opens at once. Every
|
|
11
|
+
* POST is a page press (lib/pm-guard.js requirePagePress). Nothing here sends anything: a row with no source drafts its question, and the
|
|
12
|
+
* page puts it in the outbox (POST /api/outbox/draft) only when the PM presses it. */
|
|
13
|
+
const SS = require('./stage-signoffs.js');
|
|
14
|
+
|
|
15
|
+
async function read(req, res, url, ctx, method) {
|
|
16
|
+
if (req.method !== method) { ctx.json(res, { ok: false, error: method + ' only' }, 405); return null; }
|
|
17
|
+
let body = {};
|
|
18
|
+
if (method === 'POST') {
|
|
19
|
+
const got = await ctx.readJson(req);
|
|
20
|
+
if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return null; }
|
|
21
|
+
body = got.body || {};
|
|
22
|
+
}
|
|
23
|
+
let w = null;
|
|
24
|
+
try { w = ctx.getWs((method === 'POST' ? body.ws : url.searchParams.get('ws')) || null); } catch { w = null; }
|
|
25
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return null; }
|
|
26
|
+
if (method === 'POST') {
|
|
27
|
+
const g = require('./pm-guard.js').requirePagePress(req, body);
|
|
28
|
+
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return null; }
|
|
29
|
+
return { w, body, actor: { by: (g.actor && g.actor.by) || 'pm', via: (g.actor && g.actor.via) || 'page' } };
|
|
30
|
+
}
|
|
31
|
+
return { w, body };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the line row of one initiative: the rows the server already derived; a full read only when they are not ready
|
|
35
|
+
function lineRowOf(root, ini) {
|
|
36
|
+
const L = require('./line.js');
|
|
37
|
+
let r = L.lineOf(root, { only: ini, derive: false });
|
|
38
|
+
if (!r || r.pending) r = L.lineOf(root, { only: ini });
|
|
39
|
+
return r && r.ok ? r.rows[0] || null : null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
prefixes: ['/api/stage-signoffs'],
|
|
44
|
+
handle: async (req, res, url, ctx) => {
|
|
45
|
+
const YM = require('./routes-your-move.js');
|
|
46
|
+
if (url.pathname === '/api/stage-signoffs') {
|
|
47
|
+
const r = await read(req, res, url, ctx, 'GET'); if (!r) return true;
|
|
48
|
+
// the kept line only: a first read of a large product takes a while, so this answers at once and the rows come on a later refresh
|
|
49
|
+
let rows = null;
|
|
50
|
+
try { rows = ctx.signoffLine ? await ctx.signoffLine(r.w) : YM.lineRowsKept(r.w); } catch (e) { ctx.json(res, { ok: false, error: 'the line could not be read: ' + (e && e.message) }, 500); return true; }
|
|
51
|
+
if (!rows) { ctx.json(res, { ok: true, ws: r.w.id, rows: [], suggest: [], reading: true }); return true; }
|
|
52
|
+
const S = SS.rowsOf(r.w.root, rows);
|
|
53
|
+
ctx.json(res, { ok: true, ws: r.w.id, rows: S.rows, suggest: S.suggest });
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const act = url.pathname.slice('/api/stage-signoffs/'.length);
|
|
57
|
+
if (!['record', 'undo', 'suggest'].includes(act)) return false;
|
|
58
|
+
const r = await read(req, res, url, ctx, 'POST'); if (!r) return true;
|
|
59
|
+
const b = r.body;
|
|
60
|
+
let out;
|
|
61
|
+
if (act === 'record') out = SS.record(r.w.root, { ini: String(b.ini || ''), id: String(b.id || '') }, r.actor, { lineRow: ctx.signoffLineRow || lineRowOf });
|
|
62
|
+
else if (act === 'undo') out = SS.undo(r.w.root, { ini: String(b.ini || ''), id: String(b.id || ''), from: b.from ? String(b.from) : null, to: b.to ? String(b.to) : null }, r.actor);
|
|
63
|
+
else {
|
|
64
|
+
let dir = null; try { dir = require('./jira-tickets.js').stateDirOf(r.w.root); } catch { dir = null; }
|
|
65
|
+
out = SS.answerSuggestion(dir, { wf: b.wf, stage: b.stage, act: b.act, by: b.by }, r.actor);
|
|
66
|
+
}
|
|
67
|
+
if (out && out.ok) YM.forgetLine(r.w.id);
|
|
68
|
+
ctx.json(res, out, out && out.ok ? 200 : 400);
|
|
69
|
+
return true;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -154,6 +154,15 @@ async function lineRows(w, now = Date.now()) {
|
|
|
154
154
|
LINES.set(w.id, { at: c ? c.at : 0, rows: c ? c.rows : null, p });
|
|
155
155
|
return c && c.rows ? c.rows : p;
|
|
156
156
|
}
|
|
157
|
+
/** A press that moved a stage or recorded a sign-off: the next read of this product's line reads it again (the old rows serve meanwhile). */
|
|
158
|
+
function forgetLine(wsId) { const c = LINES.get(wsId); if (c) c.at = 0; }
|
|
159
|
+
/** The line's rows as kept now, without waiting: a stale or missing answer starts a new read in the background. null while nothing was read yet.
|
|
160
|
+
* For a row that may come a refresh later (Today's sign-offs), so a slow first read never holds a request open. */
|
|
161
|
+
function lineRowsKept(w, now = Date.now()) {
|
|
162
|
+
const c = LINES.get(w.id);
|
|
163
|
+
if (!c || now - c.at >= LINE_MS) lineRows(w, now).catch(() => {});
|
|
164
|
+
return c && c.rows ? c.rows : null;
|
|
165
|
+
}
|
|
157
166
|
/** The initiatives of a product that are in Your move: a question to the PM, or a check due today. */
|
|
158
167
|
function youOf(ctx, w, today) {
|
|
159
168
|
const out = new Set();
|
|
@@ -217,7 +226,7 @@ async function weekWentRoute(req, res, url, ctx) {
|
|
|
217
226
|
const digestParts = (ctx, w, now) => require('./digest-parts.js').partsOf(ctx, w, lineRows, now); // quiet-rows-digest (reads only)
|
|
218
227
|
|
|
219
228
|
module.exports = {
|
|
220
|
-
expire, questions, asksOf, lineRows, digestParts, quietRoute, weekWentRoute,
|
|
229
|
+
expire, questions, asksOf, lineRows, lineRowsKept, forgetLine, digestParts, quietRoute, weekWentRoute,
|
|
221
230
|
prefixes: ['/api/your-move', '/api/line', '/api/digest', '/api/quiet', '/api/week-went'],
|
|
222
231
|
handle: async (req, res, url, ctx) => {
|
|
223
232
|
if (url.pathname === '/api/week-went') return weekWentRoute(req, res, url, ctx);
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* pmos signoff ask <initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked YYYY-MM-DD] [--due YYYY-MM-DD] [--source <pointer>]
|
|
5
5
|
* pmos signoff answer <id> --answer "<what they said>" --source <pointer>
|
|
6
6
|
* pmos signoff drop <id> [--why "<why it is no longer needed>"]
|
|
7
|
+
* pmos signoff evidence <id> --ref <file or Jira key> --quote "<the line, word for word>" [--doc <the document it agrees to>]
|
|
8
|
+
* where the yes is written (factory-signoffs-reach-you): Today's ✓ records it only when the quote is in the source
|
|
7
9
|
* pmos signoff list [<initiative>] [--all]
|
|
8
10
|
* every command: [--json] [--root <dir>]
|
|
9
11
|
*
|
|
@@ -17,18 +19,19 @@ const { parseArgs } = require('./schedule-cli');
|
|
|
17
19
|
const SO = require('./signoffs.js');
|
|
18
20
|
const jiraTickets = require('./jira-tickets.js');
|
|
19
21
|
|
|
20
|
-
const COMMANDS = { signoff: ['ask', 'answer', 'drop', 'list'] };
|
|
22
|
+
const COMMANDS = { signoff: ['ask', 'answer', 'drop', 'evidence', 'list'] };
|
|
21
23
|
const USAGE = [
|
|
22
|
-
'usage: pmos signoff ask|answer|drop|list — the outside sign-offs an initiative waits on',
|
|
24
|
+
'usage: pmos signoff ask|answer|drop|evidence|list — the outside sign-offs an initiative waits on',
|
|
23
25
|
' pmos signoff ask <initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked <date>] [--due <date>] [--source <pointer>]',
|
|
24
26
|
' pmos signoff answer <id> --answer "<what they said>" --source <pointer> only with a pointer to where they said it',
|
|
25
27
|
' pmos signoff drop <id> [--why "<reason>"] the sign-off is no longer needed',
|
|
28
|
+
' pmos signoff evidence <id> --ref <file or Jira key> --quote "<line>" [--doc <file>] where the yes is written; Today checks it before ✓',
|
|
26
29
|
' pmos signoff list [<initiative>] [--all] the open sign-offs (--all: answered and dropped too)',
|
|
27
30
|
' every command: [--json] [--root <dir>]',
|
|
28
31
|
'An open sign-off that waited 3 days, or is past its due date, goes on your question list for the day. Nothing is sent.',
|
|
29
32
|
];
|
|
30
33
|
const BOOL = new Set(['json', 'help', 'all']);
|
|
31
|
-
const VALUE = new Set(['who', 'what', 'asked', 'due', 'source', 'answer', 'why', 'root']);
|
|
34
|
+
const VALUE = new Set(['who', 'what', 'asked', 'due', 'source', 'answer', 'why', 'root', 'ref', 'quote', 'doc']);
|
|
32
35
|
|
|
33
36
|
function repoRoot(cwd) {
|
|
34
37
|
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; }
|
|
@@ -80,6 +83,13 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now } = {
|
|
|
80
83
|
if (!r.ok) return fail(r.error);
|
|
81
84
|
return out(r, [`dropped: ${lineOf(r.signoff)}`]);
|
|
82
85
|
}
|
|
86
|
+
if (verb === 'evidence') {
|
|
87
|
+
if (!pos[0] || !flags.ref || !flags.quote) return need('<id> --ref <file or Jira key> --quote "<the line, word for word>" [--doc <file>]');
|
|
88
|
+
const r = SO.evidence(file, pos[0], { ref: flags.ref, quote: flags.quote, doc: flags.doc }, t);
|
|
89
|
+
if (!r.ok) return fail(r.error);
|
|
90
|
+
const c = require('./stage-signoffs.js').checkOf(root, r.signoff.ini, r.signoff.evidence, r.signoff.what);
|
|
91
|
+
return out({ ...r, check: c }, [`evidence: ${lineOf(r.signoff)}`, c.ok ? '✓ the quote is in its source: Today can record it' : `✗ Today cannot record it yet: ${c.why}`]);
|
|
92
|
+
}
|
|
83
93
|
const L = SO.list(file, { ini: pos[0], open: !flags.all });
|
|
84
94
|
return out({ ok: true, signoffs: L }, L.length ? L.map(lineOf) : [`no ${flags.all ? '' : 'open '}sign-off${pos[0] ? ` for ${pos[0]}` : ''}`]);
|
|
85
95
|
}
|