create-pmos 0.818.0 → 0.820.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 +48 -23
- 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 +47 -9
- package/workspace/guide/cli.md +21 -0
- package/workspace/guide/layout.md +2 -0
- package/workspace/lib/driver-run.js +4 -2
- package/workspace/lib/factory-cli.js +25 -1
- package/workspace/lib/factory-floor.js +245 -0
- package/workspace/lib/hire-draft.js +172 -0
- package/workspace/lib/pick-cli.js +75 -0
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/routes-factory-metrics.js +22 -1
- package/workspace/lib/routes-search.js +17 -1
- package/workspace/lib/time-box-pick.js +141 -0
- package/workspace/lib/waiting-on.js +2 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-search.js +1 -0
- package/workspace/run-tests.js +37 -4
- package/workspace/test-lists/factory-floor.json +9 -0
- package/workspace/test-lists/next-hire-draft.json +9 -0
- package/workspace/test-lists/time-box-pick-chat.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 };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* pick-cli.js — `pmos pick --minutes <n>`: the one ask that fits the time you have and unblocks the most (initiative time-box-pick-chat,
|
|
3
|
+
* job #1873, idea A293; lib/time-box-pick.js).
|
|
4
|
+
*
|
|
5
|
+
* pmos pick --minutes 30 [--ws <id>] [--json]
|
|
6
|
+
* pmos pick --minutes 30 --root <dir> [--json]
|
|
7
|
+
*
|
|
8
|
+
* With a workspace server running it asks the server (GET /api/find with "I have N minutes", the same answer Ctrl K shows, waiting
|
|
9
|
+
* sessions included). With none it reads the repository and the runtime folder itself. It calls no model, sends nothing and changes no
|
|
10
|
+
* record; the only write is one line in the local use log. Exit codes: 0 done (nothing to pick is done), 1 the asks could not be read,
|
|
11
|
+
* 2 usage. */
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const TB = require('./time-box-pick.js');
|
|
15
|
+
const { parseArgs } = require('./schedule-cli');
|
|
16
|
+
|
|
17
|
+
const COMMANDS = { pick: [] };
|
|
18
|
+
const USAGE = [
|
|
19
|
+
'usage: pmos pick --minutes <n> [--ws <id>] [--json]',
|
|
20
|
+
' pmos pick --minutes <n> --root <dir> [--json]',
|
|
21
|
+
'Picks the one ask from Your move and Waiting on others that fits in <n> minutes and unblocks the most others, with why in one line.',
|
|
22
|
+
'It calls no model, sends nothing and changes nothing.',
|
|
23
|
+
];
|
|
24
|
+
const BOOL = new Set(['json', 'help']);
|
|
25
|
+
const VALUE = new Set(['minutes', 'ws', 'root']);
|
|
26
|
+
|
|
27
|
+
/** The repository this directory is in: the nearest folder up with a .git (no git process), else the directory itself. */
|
|
28
|
+
function repoRoot(cwd) {
|
|
29
|
+
let d = path.resolve(cwd);
|
|
30
|
+
for (;;) { try { if (fs.existsSync(path.join(d, '.git'))) return d; } catch { /* unreadable: look further up */ } const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function run(argv, { say, call = async () => null, runtimeDir } = {}) {
|
|
34
|
+
const rest = [], bools = {};
|
|
35
|
+
for (const a of argv.slice(1)) {
|
|
36
|
+
if (a.startsWith('--') && BOOL.has(a.slice(2))) bools[a.slice(2)] = true;
|
|
37
|
+
else if (a === '-h' || a === 'help') bools.help = true;
|
|
38
|
+
else rest.push(a);
|
|
39
|
+
}
|
|
40
|
+
const { pos, flags } = parseArgs(rest);
|
|
41
|
+
const f = { ...flags, ...bools };
|
|
42
|
+
if (f.help) { USAGE.forEach((l) => say(l)); return 0; }
|
|
43
|
+
const bad = Object.keys(f).find((k) => !BOOL.has(k) && !VALUE.has(k));
|
|
44
|
+
if (bad || pos.length) { say(`✗ ${bad ? '--' + bad : pos[0]} is not an option of pmos pick`); USAGE.forEach((l) => say(l)); return 2; }
|
|
45
|
+
const mins = TB.minutesOf(String(f.minutes || '').trim() + (/^\d+(?:\.\d+)?$/.test(String(f.minutes || '').trim()) ? ' min' : ''));
|
|
46
|
+
if (!mins) { say('✗ say how long you have: --minutes 30'); USAGE.forEach((l) => say(l)); return 2; }
|
|
47
|
+
if (f.ws && f.root) { say('✗ --ws and --root name two different things: use one'); return 2; }
|
|
48
|
+
const root = path.resolve(f.root ? f.root : repoRoot(process.cwd()));
|
|
49
|
+
let p = null;
|
|
50
|
+
if (!f.root) {
|
|
51
|
+
let ws = f.ws || null;
|
|
52
|
+
if (!ws) {
|
|
53
|
+
const list = await call('GET', '/api/workspaces');
|
|
54
|
+
const mine = list && Array.isArray(list.workspaces) ? list.workspaces.find((x) => x && x.root && path.resolve(x.root) === root) : null;
|
|
55
|
+
ws = mine ? mine.id : null;
|
|
56
|
+
}
|
|
57
|
+
const r = ws ? await call('GET', '/api/find?q=' + encodeURIComponent('I have ' + mins + ' minutes') + '&ws=' + encodeURIComponent(ws)) : null;
|
|
58
|
+
if (f.ws && !(r && r.ok)) { say(`✗ the workspace ${f.ws} could not be reached: no workspace server answered. Start it, or give --root <dir>.`); return 1; }
|
|
59
|
+
if (r && r.ok && r.answer) p = { line: r.answer.text, pick: r.answer.pick || null, minutes: mins, via: 'server' };
|
|
60
|
+
}
|
|
61
|
+
if (!p) {
|
|
62
|
+
let rt = runtimeDir;
|
|
63
|
+
if (rt === undefined) { try { rt = require('./state-root.js').defaultRoot({ env: process.env }); } catch { rt = null; } }
|
|
64
|
+
let t = null;
|
|
65
|
+
try { t = TB.read({ w: { id: 'local', root }, runtimeDir: rt, minutes: mins }); } catch (e) { say('✗ the asks could not be read: ' + ((e && e.message) || e)); return 1; }
|
|
66
|
+
TB.logUse(rt, 'cli');
|
|
67
|
+
const c = t.pick || t.shortest;
|
|
68
|
+
p = { line: t.line, pick: c ? { key: c.key, kind: c.kind, minutes: c.minutes, unblocks: c.unblocks, ini: c.ini || null } : null, minutes: mins, fits: t.fits, via: 'local' };
|
|
69
|
+
}
|
|
70
|
+
if (f.json) say(JSON.stringify({ ok: true, ...p }));
|
|
71
|
+
else { say(p.line); if (p.pick && p.pick.ini) say(' open: ' + p.pick.ini); }
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -29,6 +29,9 @@ const VERBS = Object.freeze({
|
|
|
29
29
|
help: 'pmos measure … — record a measured value of a KR or a health budget, with its source (pmos measure help)' }),
|
|
30
30
|
today: Object.freeze({ module: 'today-cli.js', run: 3, guide: 'cli.md',
|
|
31
31
|
help: 'pmos today — what needs you, ranked as Today shows it' }),
|
|
32
|
+
// Not a pm-os-absorb verb (run: null): time-box-pick-chat (idea A293) added it through the same table.
|
|
33
|
+
pick: Object.freeze({ module: 'pick-cli.js', run: null, guide: 'cli.md',
|
|
34
|
+
help: 'pmos pick --minutes <n> — for "I have 30 minutes": the one ask that fits the time and unblocks the most' }),
|
|
32
35
|
board: Object.freeze({ module: 'board-cli.js', run: 4, guide: 'cli.md',
|
|
33
36
|
help: 'pmos board [--mine] [--init <id>] — the items of every initiative, by column' }),
|
|
34
37
|
'verify-work': Object.freeze({ module: 'verify-work-cli.js', run: 4, guide: 'cli.md',
|
|
@@ -154,6 +157,9 @@ const VERBS = Object.freeze({
|
|
|
154
157
|
// Not a pm-os-absorb verb (run: null): initiative three-line-why (bet A86) added it through the same table.
|
|
155
158
|
why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
|
|
156
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)' }),
|
|
157
163
|
// Not a pm-os-absorb verb (run: null): initiative press-release-faq (bet A362) added it through the same table.
|
|
158
164
|
'press-release': Object.freeze({ module: 'press-release-cli.js', run: null, guide: 'cli.md',
|
|
159
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)' }),
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* merge, cost per merged pull request, human corrections per item. Zero is silence: a product with no factory run in the window
|
|
8
8
|
* is left out, so no factory runs anywhere answers products: [].
|
|
9
9
|
* `pmos build metrics` prints the same numbers for one repository.
|
|
10
|
+
*
|
|
11
|
+
* GET /api/factory?ws → { ok, products: [{ ws, name, snapshot }] } (initiative factory-floor-snapshot)
|
|
12
|
+
* The factory floor per product as the Driver saved it after its last run (lib/factory-floor.js load). It reads one file per product and
|
|
13
|
+
* folds nothing, so the Factory page opens in 200 ms or less. snapshot is null while no run has saved one: a read never computes or writes.
|
|
14
|
+
* ws: one workspace (404 when unknown); without it, every workspace.
|
|
10
15
|
*/
|
|
11
16
|
const FT = require('./factory-traces.js');
|
|
12
17
|
|
|
@@ -28,8 +33,24 @@ function metricsFor(ctx, { ws = '', days = 30, now = Date.now() } = {}) {
|
|
|
28
33
|
return { status: 200, body: { ok: true, days, products } };
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
function floorFor(ctx, { ws = '' } = {}) {
|
|
37
|
+
let list;
|
|
38
|
+
if (ws) {
|
|
39
|
+
const w = ctx.getWs(ws);
|
|
40
|
+
if (!w || w.id !== ws) return bad(404, 'no such workspace');
|
|
41
|
+
list = [w];
|
|
42
|
+
} else list = (ctx.workspaceList ? ctx.workspaceList() : []).filter((w) => w && w.root && !w.linked);
|
|
43
|
+
const FF = require('./factory-floor.js');
|
|
44
|
+
const products = list.map((w) => ({ ws: w.id, name: w.name || w.id, snapshot: FF.load(w.root, { stateDir: require('./driver.js').stateDirOf(w.root) || (ctx.stateDirFor ? ctx.stateDirFor(w) : null) }) }));
|
|
45
|
+
return { status: 200, body: { ok: true, products } };
|
|
46
|
+
}
|
|
47
|
+
|
|
31
48
|
async function handle(req, res, url, ctx) {
|
|
32
49
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
50
|
+
if (url.pathname === '/api/factory') {
|
|
51
|
+
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
52
|
+
return send(floorFor(ctx, { ws: String(url.searchParams.get('ws') || '') }));
|
|
53
|
+
}
|
|
33
54
|
if (url.pathname !== '/api/factory/metrics') return send(bad(404, 'no such factory route'));
|
|
34
55
|
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
35
56
|
const d = url.searchParams.get('days');
|
|
@@ -38,4 +59,4 @@ async function handle(req, res, url, ctx) {
|
|
|
38
59
|
return send(metricsFor(ctx, { ws: String(url.searchParams.get('ws') || ''), days }));
|
|
39
60
|
}
|
|
40
61
|
|
|
41
|
-
module.exports = { prefixes: ['/api/factory/metrics'], handle, metricsFor };
|
|
62
|
+
module.exports = { prefixes: ['/api/factory/metrics', '/api/factory'], handle, metricsFor, floorFor };
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
/* routes-search.js — Search across the repository and every worktree (initiative premium-uncovered-features, E1; lib/search-index.js).
|
|
3
3
|
*
|
|
4
4
|
* GET /api/find?q=<words>&ws=<id>&wt=<id,id> → { ok, q, worktrees, counts, results, more, answer? } wt: the worktrees to search (none: all)
|
|
5
|
-
* answer: one sentence from the user's own files with its source (lib/search-answer.js); absent when nothing is clear
|
|
5
|
+
* answer: one sentence from the user's own files with its source (lib/search-answer.js); absent when nothing is clear.
|
|
6
|
+
* "I have 30 minutes" (time-box-pick-chat, A293): the answer is instead the one ask that fits the time and unblocks the most
|
|
7
|
+
* (lib/time-box-pick.js, read-only, no model), and the use log counts it
|
|
6
8
|
* GET /api/search-ask?q=<question>&ws=<id> → { ok, answer, why? } a question's answer (lib/search-ask.js): the copied sentence when there is
|
|
7
9
|
* one, else one written by a read-only PMOS session from passages of the user's files, with those files as its sources (search-answers-questions)
|
|
8
10
|
* GET /api/find/file?ws=<id>&wt=<id>&path=<p> → { ok, wt, branch, main, path, text, mtime } one file of a listed worktree, for the Viewer
|
|
@@ -36,6 +38,20 @@ module.exports = {
|
|
|
36
38
|
ctx.json(res, { ws: w.id, q: String(url.searchParams.get('q') || '').trim(), ...r });
|
|
37
39
|
return true;
|
|
38
40
|
}
|
|
41
|
+
const mins = require('./time-box-pick.js').minutesOf(url.searchParams.get('q') || '');
|
|
42
|
+
if (mins) {
|
|
43
|
+
const TB = require('./time-box-pick.js');
|
|
44
|
+
let sessions = [];
|
|
45
|
+
try { sessions = ctx.sessionList ? ctx.sessionList() : []; } catch { sessions = []; }
|
|
46
|
+
try {
|
|
47
|
+
const p = TB.read({ w, stateDir: ctx.stateDirFor ? ctx.stateDirFor(w) : undefined, runtimeDir: ctx.runtimeDir, sessions, minutes: mins });
|
|
48
|
+
TB.logUse(ctx.runtimeDir, 'search');
|
|
49
|
+
ctx.json(res, { ok: true, ws: w.id, q: String(url.searchParams.get('q') || '').trim(), worktrees: [], counts: {}, results: [], more: false, answer: TB.answerOf(p) });
|
|
50
|
+
} catch (e) {
|
|
51
|
+
ctx.json(res, { ok: false, error: 'the pick could not be made: ' + String((e && e.message) || e).slice(0, 160) }, 500);
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
39
55
|
let notes = [];
|
|
40
56
|
try { const l = ctx.runtimeDir ? require('./notes.js').list(ctx.runtimeDir) : null; notes = l && l.ok ? l.notes : []; } catch { notes = []; }
|
|
41
57
|
const only = (url.searchParams.get('wt') || '').split(',').map((x) => x.trim()).filter(Boolean);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* time-box-pick.js — "I have N minutes": the one thing that fits the time and unblocks the most (initiative time-box-pick-chat, job #1873,
|
|
3
|
+
* idea A293; done test planning/done-tests/time-box-pick-chat.md).
|
|
4
|
+
*
|
|
5
|
+
* minutesOf(text) → the minutes the PM says they have ("I have 30 minutes", "an hour", "2h"), or null PURE
|
|
6
|
+
* candidatesOf({ cards, gaps, nudges }) → [candidate] one per Today card, action with no owner, and drafted nudge PURE
|
|
7
|
+
* pick(cands, minutes) → { pick, line, fits, minutes, shortest } the choice and its one line of why PURE
|
|
8
|
+
* read({ w, stateDir, runtimeDir, sessions, minutes }) → pick() over what PMOS holds now READ-ONLY
|
|
9
|
+
* answerOf(p) → the Ctrl K answer row (lib/search-answer.js shape) | null PURE
|
|
10
|
+
* logUse(runtimeDir, page) → one `timeBoxPick` line in the local use log (the kill line's count)
|
|
11
|
+
*
|
|
12
|
+
* WHERE IT LOOKS. The asks Today ranks (lib/today.js todayFor cards, in Today's order) and Waiting on others (lib/waiting-on.js): an
|
|
13
|
+
* action a meeting agreed that nobody owns, and a nudge PMOS drafted that is not sent yet. Nothing else: no model picks and no new list.
|
|
14
|
+
*
|
|
15
|
+
* HOW LONG. A fixed time per kind, so the PM can check it (MINUTES): a session that asks 5 min, a gate 10, a returned step or work to
|
|
16
|
+
* check 15, a breakdown or a capture 5, a cycle review 30, a repair 20, naming an owner or sending a nudge 2.
|
|
17
|
+
*
|
|
18
|
+
* WHAT IT UNBLOCKS. 1 when a person or a run waits on it (a gate, a session, a returned step, an action with no owner, a nudge), plus
|
|
19
|
+
* the other candidates on the same initiative, which move once this one does. The pick is the candidate that fits and unblocks the most;
|
|
20
|
+
* a tie goes to Today's order, then the shorter. Nothing fits: the shortest is named with its time. Nothing at all: "Nothing needs you".
|
|
21
|
+
*
|
|
22
|
+
* It calls no model, sends nothing and changes no record. The only write is the use log line, through lib/use-log.js. */
|
|
23
|
+
const TAG = '[time-box-pick]';
|
|
24
|
+
|
|
25
|
+
const NUM = { a: 1, an: 1, one: 1, two: 2, three: 3, four: 4, five: 5, ten: 10, fifteen: 15, twenty: 20, thirty: 30, forty: 40, 'forty-five': 45, sixty: 60, ninety: 90 };
|
|
26
|
+
const UNIT = '(minutes?|mins?|m|hours?|hrs?|h)';
|
|
27
|
+
const AMOUNT = '(\\d+(?:[.,]\\d+)?|a|an|one|two|three|four|five|ten|fifteen|twenty|thirty|forty-five|forty|sixty|ninety)';
|
|
28
|
+
const TIME_RE = new RegExp('(?:^|[^a-z0-9])' + AMOUNT + '\\s*' + UNIT + '(?![a-z])', 'i');
|
|
29
|
+
const HALF_RE = /\bhalf an? hour\b/i;
|
|
30
|
+
const QUARTER_RE = /\ba quarter of an hour\b/i;
|
|
31
|
+
// the time must be the PM's own: "I have", "I've got", "got", "free for", "with", or the time alone ("30 min")
|
|
32
|
+
const OWN_RE = /\b(i\s*have|i've|ive|i\s*got|got|have|free|spare|with|only|just|next)\b/i;
|
|
33
|
+
|
|
34
|
+
/** The minutes in "I have 30 minutes" (1 to 480), or null when the text names no time the PM has. Pure. */
|
|
35
|
+
function minutesOf(text) {
|
|
36
|
+
const s = String(text || '').trim();
|
|
37
|
+
if (!s || s.length > 120) return null;
|
|
38
|
+
let m = null;
|
|
39
|
+
if (QUARTER_RE.test(s)) m = 15;
|
|
40
|
+
else if (HALF_RE.test(s)) m = 30;
|
|
41
|
+
else {
|
|
42
|
+
const t = TIME_RE.exec(s);
|
|
43
|
+
if (!t) return null;
|
|
44
|
+
const raw = t[1].toLowerCase(), n = /\d/.test(raw) ? Number(raw.replace(',', '.')) : NUM[raw];
|
|
45
|
+
if (!Number.isFinite(n) || n <= 0) return null;
|
|
46
|
+
m = /^h/i.test(t[2]) ? n * 60 : n;
|
|
47
|
+
// "30 min" alone is the time; a longer sentence must say it is the PM's time
|
|
48
|
+
const alone = s.replace(t[0], ' ').replace(/[\s?.!,]+/g, '') === '';
|
|
49
|
+
if (!alone && !OWN_RE.test(s)) return null;
|
|
50
|
+
}
|
|
51
|
+
m = Math.round(m);
|
|
52
|
+
return m >= 1 && m <= 480 ? m : null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** How long each kind of ask takes, in minutes (Today's kinds 1 to 8, then Waiting on others). */
|
|
56
|
+
const MINUTES = Object.freeze({ 1: 10, 2: 5, 3: 15, 4: 15, 5: 5, 6: 5, 7: 30, 8: 20, owner: 2, nudge: 2 });
|
|
57
|
+
const WAITS = new Set([1, 2, 3, 'owner', 'nudge']);
|
|
58
|
+
const VERB = Object.freeze({ 1: 'a gate you owe', 2: 'a session waits on you', 3: 'a step came back to you', 4: 'work to check', 5: 'a breakdown to keep',
|
|
59
|
+
6: 'a capture to file', 7: 'a cycle review', 8: 'something to repair', owner: 'an action with no owner', nudge: 'a nudge to send' });
|
|
60
|
+
const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
|
|
61
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
62
|
+
const timeWord = (m) => (m >= 60 && m % 60 === 0 ? plural(m / 60, 'hour', 'hours') : m > 60 ? (m / 60).toFixed(1).replace(/\.0$/, '') + ' hours' : m + ' min');
|
|
63
|
+
|
|
64
|
+
/** One candidate per ask. cards: lib/today.js cards (Today's order); gaps: waiting-on gaps; nudges: outbox entries drafted, not sent. Pure. */
|
|
65
|
+
function candidatesOf({ cards = [], gaps = [], nudges = [] } = {}) {
|
|
66
|
+
const out = [];
|
|
67
|
+
(cards || []).forEach((c, i) => {
|
|
68
|
+
if (!c || !Number.isInteger(c.kind)) return;
|
|
69
|
+
out.push({ key: 'card:' + (c.id || i), kind: c.kind, title: clip(c.cause, 140), minutes: MINUTES[c.kind] || 15, ini: c.initiative_id || '',
|
|
70
|
+
ws: c.ws || '', order: i, base: WAITS.has(c.kind) ? 1 : 0, open: c.act && c.act.cli ? c.act.cli : '' });
|
|
71
|
+
});
|
|
72
|
+
for (const g of gaps || []) {
|
|
73
|
+
if (!g || !g.key) continue;
|
|
74
|
+
out.push({ key: g.key, kind: 'owner', title: clip('Name an owner for: ' + g.title, 140), minutes: MINUTES.owner, ini: g.ini || '', ws: g.ws || '', order: 1000 + out.length, base: 1, open: '' });
|
|
75
|
+
}
|
|
76
|
+
for (const e of nudges || []) {
|
|
77
|
+
if (!e || !e.id || !e.about || e.state !== 'queued') continue;
|
|
78
|
+
out.push({ key: 'nudge:' + e.id, kind: 'nudge', title: clip('Send the nudge to ' + (e.recipient || 'them') + (e.subject ? ': ' + String(e.subject).replace(/^Nudge:\s*/, '') : ''), 140),
|
|
79
|
+
minutes: MINUTES.nudge, ini: '', ws: '', order: 2000 + out.length, base: 1, open: '' });
|
|
80
|
+
}
|
|
81
|
+
const perIni = new Map();
|
|
82
|
+
for (const c of out) if (c.ini) perIni.set(c.ini, (perIni.get(c.ini) || 0) + 1);
|
|
83
|
+
for (const c of out) c.unblocks = c.base + (c.ini ? perIni.get(c.ini) - 1 : 0);
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The pick for a time: { pick, line, fits, minutes, shortest }. pick is null when nothing fits or nothing waits. Pure. */
|
|
88
|
+
function pick(cands, minutes) {
|
|
89
|
+
const all = (cands || []).filter(Boolean);
|
|
90
|
+
const m = Number(minutes);
|
|
91
|
+
if (!all.length) return { pick: null, fits: 0, minutes: m, shortest: null, line: 'Nothing needs you, so the ' + timeWord(m) + ' are yours.' };
|
|
92
|
+
const fit = all.filter((c) => c.minutes <= m).sort((a, b) => b.unblocks - a.unblocks || a.order - b.order || a.minutes - b.minutes);
|
|
93
|
+
if (!fit.length) {
|
|
94
|
+
const s = all.slice().sort((a, b) => a.minutes - b.minutes || a.order - b.order)[0];
|
|
95
|
+
return { pick: null, fits: 0, minutes: m, shortest: s, line: 'Nothing fits in ' + timeWord(m) + '. The shortest is "' + s.title + '", about ' + timeWord(s.minutes) + '.' };
|
|
96
|
+
}
|
|
97
|
+
const p = fit[0];
|
|
98
|
+
const why = p.unblocks ? 'it unblocks ' + plural(p.unblocks, 'other', 'others') : 'nothing else that fits unblocks more';
|
|
99
|
+
return { pick: p, fits: fit.length, minutes: m, shortest: null,
|
|
100
|
+
line: 'In ' + timeWord(m) + ': ' + p.title.replace(/[.…]+$/, '') + ' (about ' + timeWord(p.minutes) + '). ' + VERB[p.kind].replace(/^./, (x) => x.toUpperCase()) + ', and ' + why + '.' };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** What PMOS holds now, picked for the time. READ-ONLY: it never runs Waiting on others' view (that drafts nudges). */
|
|
104
|
+
function read({ w, stateDir, runtimeDir, sessions = [], registered, minutes, cards } = {}) {
|
|
105
|
+
let list = Array.isArray(cards) ? cards : null;
|
|
106
|
+
if (!list) {
|
|
107
|
+
try { const t = require('./today.js').todayFor(w, { stateDir: stateDir || undefined, sessions, registered }); list = t && t.ok ? t.cards : []; } catch { list = []; }
|
|
108
|
+
}
|
|
109
|
+
let gaps = [], nudges = [];
|
|
110
|
+
if (runtimeDir) {
|
|
111
|
+
try {
|
|
112
|
+
const WO = require('./waiting-on.js'), store = require('./outbox-store.js');
|
|
113
|
+
const entries = store.readOutbox(runtimeDir);
|
|
114
|
+
nudges = entries.filter((e) => e && e.about && e.state === 'queued');
|
|
115
|
+
gaps = WO.derive({ notes: WO.notesOf(runtimeDir, Date.now()), jira: [], sent: entries, mentions: [] }, {}).gaps || [];
|
|
116
|
+
} catch { gaps = []; }
|
|
117
|
+
}
|
|
118
|
+
const p = pick(candidatesOf({ cards: list, gaps, nudges }), minutes);
|
|
119
|
+
console.info(TAG + ' minutes=' + minutes + ' candidates=' + (list.length + gaps.length + nudges.length) + ' fits=' + p.fits + ' pick=' + (p.pick ? p.pick.kind : 'none'));
|
|
120
|
+
return p;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** The Ctrl K answer row: the line, opening the item's initiative, else Today. Pure. */
|
|
124
|
+
function answerOf(p) {
|
|
125
|
+
if (!p || !p.line) return null;
|
|
126
|
+
const c = p.pick || p.shortest;
|
|
127
|
+
const source = c && c.ini ? { kind: 'initiative', id: c.ini, title: c.ini, path: '', main: true, ...(c.ws ? { ws: c.ws } : {}) } : { kind: 'today', title: 'Today', path: '', main: true };
|
|
128
|
+
return { text: p.line, facts: [], made: true, source, sources: [{ title: 'Your move and Waiting on others', path: '' }], pick: c ? { key: c.key, kind: c.kind, minutes: c.minutes, unblocks: c.unblocks, ini: c.ini || null } : null };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** One `timeBoxPick` line in the local use log, so the kill line can count picks. Ctrl K asks again as the PM types ("30 m", "30 min",
|
|
132
|
+
* "30 minutes"), so a second pick within a minute is the same pick and is not counted. Never throws. */
|
|
133
|
+
const lastLog = new Map();
|
|
134
|
+
function logUse(runtimeDir, page = 'search', now = Date.now()) {
|
|
135
|
+
if (!runtimeDir) return;
|
|
136
|
+
if (now - (lastLog.get(runtimeDir) || 0) < 60e3) return;
|
|
137
|
+
lastLog.set(runtimeDir, now);
|
|
138
|
+
try { require('./use-log.js').record(runtimeDir, [{ kind: 'use', page, control: 'timeBoxPick', device: 'desk' }]); } catch { /* the count misses one */ }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = { TAG, MINUTES, minutesOf, candidatesOf, pick, read, answerOf, logUse };
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* nudgesToDraft(rows, lines, now) → [entry] pure. The nudges to put in the outbox (drafted, never sent)
|
|
9
9
|
* view(rt, o) → { ok, rows, gaps, closed } the files: reads the records, writes <rt>/waiting/state.json and the drafts
|
|
10
10
|
* channelWord(channel) → 'Jira comment' · 'team note' · …
|
|
11
|
+
* notesOf(rt, now) → the notes derive reads (read-only; lib/time-box-pick.js reads the gaps with it)
|
|
11
12
|
*
|
|
12
13
|
* THE SOURCES (the brief, item 2). A row exists only with a real who: a name or a Jira assignee.
|
|
13
14
|
* note a meeting note's action item whose owner is not the PM (the final notes' actions when they exist, else the local summary's).
|
|
@@ -249,4 +250,4 @@ function view(rt, o = {}) {
|
|
|
249
250
|
return { ok: true, rows, gaps: d.gaps, closed: t.closed, as_of: new Date(now).toISOString() };
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
module.exports = { WINDOW_DAYS, STALE_DAYS, NUDGE_DAYS, CLOSED_DAYS, realWho, isMe, derive, track, nudgeOf, nudgesToDraft, nudgeBody, channelWord, view, stateFile };
|
|
253
|
+
module.exports = { WINDOW_DAYS, STALE_DAYS, NUDGE_DAYS, CLOSED_DAYS, realWho, isMe, derive, track, nudgeOf, nudgesToDraft, nudgeBody, channelWord, view, stateFile, notesOf };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.820.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.820.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -215,6 +215,7 @@ function go(r) {
|
|
|
215
215
|
closeSearch();
|
|
216
216
|
if (r.kind === 'ask') { askClaude(r.title); return; }
|
|
217
217
|
if (r.kind === 'answer') { const src = r.answer.source; go({ ...src, kind: src.kind || 'document', title: src.title || src.path }); return; }
|
|
218
|
+
if (r.kind === 'today') { location.assign(homeUrl({})); return; } // "I have 30 minutes" with no initiative: the ask is on Today (time-box-pick-chat)
|
|
218
219
|
if (r.kind === 'scoped') { if (typeof r.open === 'function') r.open(); return; }
|
|
219
220
|
if (r.kind === 'initiative') { if (S.go) { S.go({ ini: r.id }); return; } location.assign(homeUrl(r.board ? { ini: r.id, board: r.board } : { ini: r.id })); return; }
|
|
220
221
|
if (r.kind === 'session') { if (S.go) { S.go({ ses: r.id }); return; } location.assign(homeUrl({ session: r.id })); return; }
|
package/workspace/run-tests.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
/* run-tests.js — run the workspace suites side by side.
|
|
4
4
|
*
|
|
5
|
-
* node run-tests.js <group> [--jobs=N] [--shard=I/N] [--changed[=REF]] [--retry-browser] [--timings-out=FILE] [--list] [--verbose]
|
|
5
|
+
* node run-tests.js <group> [--jobs=N] [--shard=I/N] [--changed[=REF]] [--retry-browser] [--timings-out=FILE] [--list] [--plan] [--verbose]
|
|
6
6
|
* node run-tests.js --check
|
|
7
7
|
* node run-tests.js --merge-timings=DIR
|
|
8
8
|
*
|
|
@@ -172,6 +172,7 @@ const WIDE = new Set([
|
|
|
172
172
|
* - lib/routes-<x>.js (a route module that lib/route-modules.js loads): every '/api/…' route the file names under the
|
|
173
173
|
* prefixes it declares (a route it only calls through ctx is left out). With no prefixes it can read: every route it names.
|
|
174
174
|
* - lib/pmos-verbs.js, when the diff only adds a verb (its module line and its help line): the suites that name pmos-verbs or the new module.
|
|
175
|
+
* - lib/needs-providers.js, when the diff only adds a provider name to PROVIDERS: the suites that name needs-providers or the new provider.
|
|
175
176
|
* - lib/route-modules.js, when the diff only adds module names to its list: what each added lib/routes-<x>.js reaches. Any other change to it is the rule below.
|
|
176
177
|
* - Any other file: the files that name it (a require, an import or a path string), followed the same way: server.js
|
|
177
178
|
* through the names it binds the module to, a lib/ file through its own users, a suite directly. A lib/ file that no
|
|
@@ -725,6 +726,11 @@ function traceChanges(changes, ctx) {
|
|
|
725
726
|
for (const s of list) { const t = get(s) || ''; if (t.includes('pmos-verbs') || nv.some((m) => t.includes(m))) picked.add(s); }
|
|
726
727
|
continue;
|
|
727
728
|
}
|
|
729
|
+
const np = f === PROVIDERS_FILE ? newProviderOnly(sget(f), lines) : null;
|
|
730
|
+
if (np) { // a new needs provider: only its own rows are new, so the suites that name the provider table or the new provider
|
|
731
|
+
for (const s of list) { const t = get(s) || ''; if (t.includes('needs-providers') || np.some((m) => t.includes(m))) picked.add(s); }
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
728
734
|
let why = null;
|
|
729
735
|
const before = picked.size;
|
|
730
736
|
if (get(f) == null) { // removed: only the names in the suites can say who used it
|
|
@@ -766,6 +772,28 @@ function newVerbOnly(src, lines) {
|
|
|
766
772
|
return mods.length ? mods : null;
|
|
767
773
|
}
|
|
768
774
|
|
|
775
|
+
/* decision-journal-outcome-checks: server.js folds every needs provider into deriveNeeds through lib/needs-providers.js, so a change there
|
|
776
|
+
* reaches every suite. A change that only ADDS a provider's name to PROVIDERS (` '<name>-needs',`) adds that provider's rows and nothing
|
|
777
|
+
* else: a provider that fails gives one error row of its own. Returns the new providers' names, or null when any changed line is something
|
|
778
|
+
* else. `src` is without comments. */
|
|
779
|
+
const PROVIDERS_FILE = ['lib', 'needs-providers'].join('/') + '.js'; // built, so this file does not read as a user of it
|
|
780
|
+
function newProviderOnly(src, lines) {
|
|
781
|
+
if (src == null || !Array.isArray(lines) || !lines.length) return null;
|
|
782
|
+
const all = src.split('\n'), names = [];
|
|
783
|
+
for (const n of lines) {
|
|
784
|
+
const l = all[n - 1];
|
|
785
|
+
if (l == null) return null;
|
|
786
|
+
if (!l.trim()) continue;
|
|
787
|
+
const m = /^\s*'([\w-]+-needs)',\s*$/.exec(l);
|
|
788
|
+
if (!m) return null;
|
|
789
|
+
names.push(m[1]);
|
|
790
|
+
}
|
|
791
|
+
if (!names.length) return null;
|
|
792
|
+
const start = all.findIndex((l) => /^const PROVIDERS = Object\.freeze\(\[\s*$/.test(l));
|
|
793
|
+
const end = start < 0 ? -1 : all.findIndex((l, i) => i > start && /^\]\);\s*$/.test(l));
|
|
794
|
+
return start >= 0 && end > start && lines.every((n) => n - 1 > start && n - 1 < end) ? names : null;
|
|
795
|
+
}
|
|
796
|
+
|
|
769
797
|
/* live-round (W1): lib/headless.js decides the kind of EVERY spawn through kindFor(), so a change there reaches every suite. A change that
|
|
770
798
|
* only ADDS a kind is narrower: a new `const X_ORIGINS = Object.freeze(['p:'])`, its `if (X_ORIGINS.some(...)) return 'k';` line in kindFor,
|
|
771
799
|
* its TOOLS entry and its name on WRITE_DIR_KINDS or WRITE_PATH_KINDS change only runs whose origin starts with 'p:'. Returns the new
|
|
@@ -983,15 +1011,20 @@ async function main() {
|
|
|
983
1011
|
}
|
|
984
1012
|
let list = GROUPS[group];
|
|
985
1013
|
const shard = flag('shard');
|
|
986
|
-
|
|
1014
|
+
// --changed first, then --shard (ci-dynamic-shards): the shards split the suites the diff reaches, so they finish
|
|
1015
|
+
// together. Sharding the whole group first left a wide diff's reached suites piled into one or two shards.
|
|
987
1016
|
const changed = flag('changed');
|
|
988
1017
|
if (changed) {
|
|
989
1018
|
const ref = changed === true ? 'origin/main' : changed;
|
|
990
1019
|
const pick = changedSuites(list, ref);
|
|
991
|
-
console.log(`run-tests: --changed against ${ref}: ${pick.why}. ${pick.suites.length} of ${list.length} suites run here; a workflow_dispatch run runs every suite.`);
|
|
1020
|
+
console.log(`run-tests: --changed against ${ref}: ${pick.why}. ${pick.suites.length} of ${list.length} suites run${shard ? ', split across the shards' : ' here'}; a workflow_dispatch run runs every suite.`);
|
|
992
1021
|
list = pick.suites;
|
|
993
|
-
if (!list.length) return;
|
|
994
1022
|
}
|
|
1023
|
+
// --plan: one JSON line, {"suites":N,"seconds":S}, the suites this command would run and their CI time added up. The
|
|
1024
|
+
// Workspace CI scope job reads it to choose how many shards each group gets.
|
|
1025
|
+
if (flag('plan')) { console.log(JSON.stringify({ suites: list.length, seconds: Math.round(list.reduce((t, f) => t + secs(f), 0)) })); return; }
|
|
1026
|
+
if (changed && !list.length) return;
|
|
1027
|
+
list = shard ? shardOf(list, shard) : bySlowest(list);
|
|
995
1028
|
// --skip-passed / --since: suites that passed on an earlier head of this PR and that the new commits cannot reach
|
|
996
1029
|
let carried = [];
|
|
997
1030
|
const passedIn = flag('skip-passed'); const since = flag('since');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Factory page slice B (factory-floor-snapshot): the factory's numbers per product and station, saved after each Driver run (lib/factory-floor.js, GET /api/factory in lib/routes-factory-metrics.js, pmos factory). Temporary state folders; no git, no server, no browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"factory-floor.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"factory-floor.test.js": 2
|
|
8
|
+
}
|
|
9
|
+
}
|