create-pmos 0.828.0 → 0.830.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 +237 -35
- 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/board-deliveries-test.js +2 -2
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +1 -1
- package/workspace/changelog.json +236 -8
- package/workspace/guide/agent-capabilities.md +1 -1
- package/workspace/guide/backlog.md +12 -1
- package/workspace/guide/cli.md +46 -1
- package/workspace/guide/home.md +2 -1
- package/workspace/guide/layout.md +1 -0
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/board-premium.js +1 -0
- package/workspace/lib/code-map.js +8 -2
- package/workspace/lib/critical-needs.js +162 -0
- package/workspace/lib/deps-cli.js +102 -0
- package/workspace/lib/engine/boards.js +13 -2
- package/workspace/lib/factory-floor.js +16 -8
- package/workspace/lib/features.json +17 -13
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/page-one-answer.js +86 -0
- package/workspace/lib/pages-cli.js +6 -2
- package/workspace/lib/people-cli.js +9 -1
- package/workspace/lib/people-prep.js +140 -0
- package/workspace/lib/pmos-verbs.js +10 -0
- package/workspace/lib/print-cli.js +49 -0
- package/workspace/lib/print-pdf.js +96 -0
- package/workspace/lib/prototype-cli.js +86 -0
- package/workspace/lib/report-cli.js +12 -2
- package/workspace/lib/report-readers.js +5 -3
- package/workspace/lib/review-pack.js +348 -0
- package/workspace/lib/review-reasons.js +121 -9
- package/workspace/lib/route-modules.js +5 -0
- package/workspace/lib/routes-boards.js +25 -2
- package/workspace/lib/routes-report-design.js +3 -1
- package/workspace/lib/routes-review-pack.js +42 -0
- package/workspace/lib/routes-roadmap-ops.js +53 -1
- package/workspace/lib/routes-sim-users.js +66 -0
- package/workspace/lib/routes-skill-map.js +39 -0
- package/workspace/lib/routes-strategy-card.js +13 -6
- package/workspace/lib/routes-team-waits.js +24 -0
- package/workspace/lib/sim-users.js +329 -0
- package/workspace/lib/skill-map.js +199 -0
- package/workspace/lib/task-store.js +1 -1
- package/workspace/lib/team-cli.js +20 -1
- package/workspace/lib/team-waits.js +167 -0
- package/workspace/lib/tradeoff-cards.js +258 -0
- package/workspace/lib/tradeoff-cli.js +83 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/action-keys.js +1 -0
- package/workspace/public/pm/ask-here-ctx.js +25 -1
- package/workspace/public/pm/ask-here.css +7 -0
- package/workspace/public/pm/ask-here.js +15 -2
- package/workspace/public/pm/bd-backlog.css +61 -0
- package/workspace/public/pm/bd-backlog.js +99 -7
- package/workspace/public/pm/bd-work.js +12 -1
- package/workspace/public/pm/code-map.js +15 -4
- package/workspace/public/pm/cozy-board.css +5 -1
- package/workspace/public/pm/cozy-library.css +5 -0
- package/workspace/public/pm/cozy-pop-work.js +4 -1
- package/workspace/public/pm/cozy-proto.css +5 -0
- package/workspace/public/pm/cozy-proto.js +11 -3
- package/workspace/public/pm/cozy-search.js +2 -2
- package/workspace/public/pm/cozy-today-app.js +5 -2
- package/workspace/public/pm/day-time.js +8 -0
- package/workspace/public/pm/factory.js +199 -0
- package/workspace/public/pm/home-ini.js +3 -2
- package/workspace/public/pm/ini-links.js +2 -1
- package/workspace/public/pm/ini-tasks.js +5 -2
- package/workspace/public/pm/ini-view-model.js +14 -6
- package/workspace/public/pm/ini-view.js +12 -2
- package/workspace/public/pm/library-model.js +1 -1
- package/workspace/public/pm/page-one-answer.css +18 -0
- package/workspace/public/pm/page-one-answer.js +134 -0
- package/workspace/public/pm/pop-cap.js +5 -3
- package/workspace/public/pm/pop-work-model.js +8 -6
- package/workspace/public/pm/portfolio.js +1 -1
- package/workspace/public/pm/premium-board.js +23 -6
- package/workspace/public/pm/premium-library.js +27 -3
- package/workspace/public/pm/premium-report-read.js +11 -2
- package/workspace/public/pm/print-pdf.js +191 -0
- package/workspace/public/pm/range-pick.css +12 -0
- package/workspace/public/pm/range-pick.js +30 -6
- package/workspace/public/pm/review-pack.js +47 -0
- package/workspace/public/pm/review-reasons.js +19 -5
- package/workspace/public/pm/sim-users.js +34 -0
- package/workspace/public/pm/skill-map.js +57 -0
- package/workspace/public/pm/sort-order.js +3 -0
- package/workspace/public/pm/task-card.js +10 -7
- package/workspace/public/pm/team-waits.js +56 -0
- package/workspace/public/pm/tradeoff-cards.css +27 -0
- package/workspace/public/pm/tradeoff-cards.js +183 -0
- package/workspace/public/premium-board.html +3 -0
- package/workspace/public/today.html +1 -0
- package/workspace/run-tests.js +9 -1
- package/workspace/test-lists/critical-needs.json +9 -0
- package/workspace/test-lists/factory-page-ui.json +9 -0
- package/workspace/test-lists/page-one-answer.json +9 -0
- package/workspace/test-lists/people-prep.json +9 -0
- package/workspace/test-lists/print-pdf.json +9 -0
- package/workspace/test-lists/review-pack.json +9 -0
- package/workspace/test-lists/sim-users.json +9 -0
- package/workspace/test-lists/skill-map.json +9 -0
- package/workspace/test-lists/surface-ask-card.json +9 -0
- package/workspace/test-lists/task-time-optional.json +9 -0
- package/workspace/test-lists/team-waits.json +9 -0
- package/workspace/test-lists/tradeoff-cards.json +9 -0
- package/workspace/test-lists/voice-files.json +9 -0
- package/workspace/test-timings.json +25 -0
|
@@ -962,6 +962,9 @@ function itemsOf(w, fr, board, rows) {
|
|
|
962
962
|
// the PM's priority (inline-sprint-priority): carried only when set
|
|
963
963
|
const PR = fr.folded.priorities || new Map();
|
|
964
964
|
if (PR.size) for (const x of out) if (x.kind !== 'Epic' && x.src !== 'jira' && PR.has(x.uid)) x.priority = PR.get(x.uid);
|
|
965
|
+
// the PM's optional times (task-time-optional): carried only when set, so a task with no time reads exactly as before
|
|
966
|
+
const TMS = fr.folded.times || new Map();
|
|
967
|
+
if (TMS.size) for (const x of out) if (x.kind !== 'Epic' && x.src !== 'jira' && TMS.has(x.uid)) Object.assign(x, timeFields(TMS, x.uid));
|
|
965
968
|
// the task's description (task-descriptions): carried only when set; descBy 'pmos' when PMOS wrote the last one, with its sources
|
|
966
969
|
const DS = fr.folded.descriptions || new Map();
|
|
967
970
|
if (DS.size) for (const x of out) if (x.src !== 'jira' && DS.has(x.uid)) Object.assign(x, descFields(DS.get(x.uid)));
|
|
@@ -971,6 +974,9 @@ function itemsOf(w, fr, board, rows) {
|
|
|
971
974
|
return B.rollupItems(out);
|
|
972
975
|
}
|
|
973
976
|
|
|
977
|
+
/** A task's times as item fields (task-time-optional): start_time and due_time, each only when set. */
|
|
978
|
+
function timeFields(TM, id) { const v = TM && TM.get(id); const o = {}; if (v && v.start_time) o.start_time = v.start_time; if (v && v.due_time) o.due_time = v.due_time; return o; }
|
|
979
|
+
|
|
974
980
|
/** tracker-daily: a PMOS task that names a Jira key carries `tracker` { key, status, readAt, stale }: Jira's status at the last read, and
|
|
975
981
|
* stale when that read is older than a day or did not return the ticket (lib/task-jira.js staleOf). Its state is already the read's
|
|
976
982
|
* (readLedger). A page or a forecast says "not read since" instead of trusting a stale state. */
|
|
@@ -1758,6 +1764,8 @@ const WRITES = {
|
|
|
1758
1764
|
if (body.milestone != null && typeof body.milestone !== 'boolean') return fail(ctx, res, 400, 'milestone is true or false');
|
|
1759
1765
|
// the priority and the sprint, set in the row (initiative inline-sprint-priority): sprint is the sprint's name, only to word the line's why
|
|
1760
1766
|
if (body.priority != null && (typeof body.priority !== 'string' || !/^(P[1-3])?$/.test(body.priority))) return fail(ctx, res, 400, "priority is P1, P2, P3, or '' for none");
|
|
1767
|
+
// an optional time of day on the start and due (task-time-optional): "HH:MM", or '' to take it out; the day stays in start and due
|
|
1768
|
+
for (const k of ['start_time', 'due_time']) if (body[k] != null && body[k] !== '' && !(typeof body[k] === 'string' && B.TIME_RE.test(body[k]))) return fail(ctx, res, 400, `${k} is a time of day, HH:MM (00:00 to 23:59), or '' for none`);
|
|
1761
1769
|
if (body.sprint != null && body.sprint !== '' && !ONE_LINE(body.sprint, 80)) return fail(ctx, res, 400, 'sprint is the sprint\'s name, one line of at most 80 characters');
|
|
1762
1770
|
if (body.pinned !== undefined && body.pinned !== null && typeof body.pinned !== 'boolean') return fail(ctx, res, 400, 'pinned is true, false, or null for the rule (the last milestone only)');
|
|
1763
1771
|
const pinWas = (id) => { const PN = p.fr.folded.pins || new Map(); return PN.has(id) ? PN.get(id) : null; };
|
|
@@ -1765,7 +1773,7 @@ const WRITES = {
|
|
|
1765
1773
|
// a Jira ticket takes the milestone flag (feedback batch 11 item 3) and the PM's own start and due days, kept in PMOS only (item 23):
|
|
1766
1774
|
// Jira keeps its title, status and assignee, and nothing is written to Jira
|
|
1767
1775
|
if (typeof body.task === 'string' && B.JIRA_KEY_RE.test(body.task) && !B.taskOf(p.fr.folded, body.task)) {
|
|
1768
|
-
if (['owner', 'notes', 'initiative', 'section', 'priority', 'description'].some((k) => body[k] != null)) return fail(ctx, res, 409, 'Jira owns this ticket: only its dates, its milestone flag and its pin change here');
|
|
1776
|
+
if (['owner', 'notes', 'initiative', 'section', 'priority', 'description', 'start_time', 'due_time'].some((k) => body[k] != null)) return fail(ctx, res, 409, 'Jira owns this ticket: only its dates, its milestone flag and its pin change here');
|
|
1769
1777
|
if (body.milestone == null && body.start == null && body.due == null && body.pinned === undefined && body.parent == null) return fail(ctx, res, 400, 'nothing to change: send start, due, milestone, pinned or parent');
|
|
1770
1778
|
if (body.parent != null) { const pe = parentError(p, body.task, body.parent, null); if (pe) return fail(ctx, res, 400, pe); }
|
|
1771
1779
|
for (const k of ['start', 'due']) if (body[k] != null && body[k] !== '' && !/^\d{4}-\d{2}-\d{2}$/.test(String(body[k]))) return fail(ctx, res, 400, `${k} is a day, YYYY-MM-DD, or '' for none`);
|
|
@@ -1857,12 +1865,26 @@ const WRITES = {
|
|
|
1857
1865
|
const d0 = (p.fr.folded.descriptions || new Map()).get(t.id);
|
|
1858
1866
|
desc = body.description.replace(/\s+$/, ''); from.description = d0 ? d0.text : '';
|
|
1859
1867
|
}
|
|
1860
|
-
|
|
1868
|
+
// the times (task-time-optional): a board-ledger line for every kind of PMOS task, like the priority. A day cleared to '' takes its time
|
|
1869
|
+
// with it, so a task never keeps a time on a day it no longer has
|
|
1870
|
+
let tm = null;
|
|
1871
|
+
{
|
|
1872
|
+
const T0 = (p.fr.folded.times || new Map()).get(t.id) || { start_time: '', due_time: '' }, next = {};
|
|
1873
|
+
for (const k of ['start_time', 'due_time']) if (body[k] != null) next[k] = String(body[k]);
|
|
1874
|
+
if (ev.start === '' && T0.start_time && next.start_time == null) next.start_time = '';
|
|
1875
|
+
if (ev.due === '' && T0.due_time && next.due_time == null) next.due_time = '';
|
|
1876
|
+
if (Object.keys(next).length) {
|
|
1877
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1878
|
+
tm = next; for (const k of Object.keys(next)) if (body[k] != null) from[k] = T0[k] || '';
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
if (!Object.keys(ev).length && sec == null && ms == null && !pin && !prio && par == null && desc == null && tm == null) return fail(ctx, res, 400, 'nothing to change: send owner, notes, start, due, start_time, due_time, initiative, section, milestone, pinned, priority, parent or description');
|
|
1861
1882
|
if (sec != null) append(p.file, g.actor, { kind: 'task-section', board: p.board.id, task: t.id, section: sec, why: sec ? 'placed under ' + sec : 'placed under no stage' });
|
|
1862
1883
|
if (ms != null) append(p.file, g.actor, { kind: 'task-milestone', board: p.board.id, task: t.id, milestone: ms, why: ms ? 'made a milestone' : 'no longer a milestone' });
|
|
1863
1884
|
if (pin) append(p.file, g.actor, pinLine(t.id));
|
|
1864
1885
|
if (prio) { append(p.file, g.actor, { kind: 'task-priority', board: p.board.id, task: t.id, priority: body.priority, why: body.priority ? 'priority ' + body.priority : 'no priority' }); console.info('[inline-field] priority'); }
|
|
1865
1886
|
if (par != null) append(p.file, g.actor, parentLine(p, t.id, par));
|
|
1887
|
+
if (tm) append(p.file, g.actor, { kind: 'task-time', board: p.board.id, task: t.id, ...tm, why: Object.values(tm).some(Boolean) ? 'time set' : 'time taken out' });
|
|
1866
1888
|
if (desc != null) append(p.file, g.actor, { kind: 'task-description', board: p.board.id, task: t.id, description: desc, ...(Array.isArray(g.sources) && desc ? { sources: g.sources } : {}), why: desc ? (g.sources ? 'written from ' + g.sources.length + (g.sources.length === 1 ? ' source' : ' sources') : 'description edited') : 'description cleared' });
|
|
1867
1889
|
if (!Object.keys(ev).length) {
|
|
1868
1890
|
const items = itemsOf(p.w, { ...p.fr, folded: B.fold(readLedger(ctx, p.w)) }, p.board, (needRows(ctx, res, p.w) || []).filter((r) => r.id === t.initiative));
|
|
@@ -1876,6 +1898,7 @@ const WRITES = {
|
|
|
1876
1898
|
if (intoSprint) console.info('[inline-field] sprint');
|
|
1877
1899
|
const F2 = B.fold(readLedger(ctx, p.w)), t2 = B.taskOf(F2, t.id), it2 = B.rollupItems([B.taskItem(t2)])[0];
|
|
1878
1900
|
if (F2.priorities && F2.priorities.has(t.id)) it2.priority = F2.priorities.get(t.id);
|
|
1901
|
+
Object.assign(it2, timeFields(F2.times, t.id));
|
|
1879
1902
|
ctx.json(res, { ok: true, from, item: it2 });
|
|
1880
1903
|
},
|
|
1881
1904
|
'/api/boards/tasks/describe-draft': async (ctx, res, body, g) => {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* GET /api/report-notes?ws&path → { ok, speaker, suggestions, pins }
|
|
20
20
|
* POST /api/report-notes/speaker { ws, path, slide, text } | { ws, path, slide, keep: true }
|
|
21
21
|
* POST /api/report-notes/pin { ws, path, op, id?, slide, x, y, text, section? }
|
|
22
|
+
* GET /api/print?ws → { ok, brand } Print or PDF's brand, the product's own design system (lib/print-pdf.js handle, job #1911)
|
|
22
23
|
*
|
|
23
24
|
* WHO WRITES. Every POST passes pm-guard requirePagePress, and a request with an agent session header is refused first (403), as
|
|
24
25
|
* routes-report-setups.js does. A job's render is data: the server sanitizes it (lib/report-design.js sanitize) before it is written or served.
|
|
@@ -455,6 +456,7 @@ function cycleAnswer(w, c) {
|
|
|
455
456
|
}
|
|
456
457
|
|
|
457
458
|
async function handle(req, res, url, ctx) {
|
|
459
|
+
if (url.pathname === '/api/print') return require('./print-pdf.js').handle(req, res, url, ctx); // Print or PDF's brand (job #1911): the product's own design system
|
|
458
460
|
lastCtx = ctx;
|
|
459
461
|
const p = url.pathname;
|
|
460
462
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
@@ -637,4 +639,4 @@ async function handle(req, res, url, ctx) {
|
|
|
637
639
|
return send(bad(404, 'no such route'));
|
|
638
640
|
}
|
|
639
641
|
|
|
640
|
-
module.exports = { prefixes: ['/api/report-design', '/api/report-notes'], handle, attach, sweep, startCycle, resultJson, _promptFor: promptFor, _jobs: jobs, _fetches: fetches, startFetch };
|
|
642
|
+
module.exports = { prefixes: ['/api/report-design', '/api/report-notes', '/api/print'], handle, attach, sweep, startCycle, resultJson, _promptFor: promptFor, _jobs: jobs, _fetches: fetches, startFetch };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-review-pack.js — the monthly review packs of every product, for Library › Reports (initiative review-pack, job #1910; lib/review-pack.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/review-packs → { ok, items } each product's packs as Library rows (lib/review-pack.js itemsOf), newest first. Read only.
|
|
5
|
+
* POST /api/review-packs/due {} → { ok, written, items } Library calls it when it opens: in the last 7 days of the month, PMOS drafts the month's
|
|
6
|
+
* pack of each product that has none (lib/review-pack.js tick). A pack that exists is
|
|
7
|
+
* never written over, and nothing is shared: Share is the PM's Issue press.
|
|
8
|
+
* PMOS_REVIEW_PACK=0 turns the drafting off (=1 on); a scratch server (its own PMOS_STATE_DIR) drafts none by default (lib/review-pack.js autoOn).
|
|
9
|
+
* The POST comes from the page only (pm-guard requirePagePress); an agent session is refused (403). */
|
|
10
|
+
const guard = require('./pm-guard.js');
|
|
11
|
+
const RP = require('./review-pack.js');
|
|
12
|
+
|
|
13
|
+
function itemsAll(ctx) {
|
|
14
|
+
const list = typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : [];
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const w of list) {
|
|
17
|
+
if (!w || !w.root) continue;
|
|
18
|
+
try { out.push(...RP.itemsOf({ ws: w.id, name: w.label || w.name || w.id, packs: RP.list(w.root) })); } catch { /* an unreadable product shows no pack */ }
|
|
19
|
+
}
|
|
20
|
+
return out.sort((a, b) => String(b.updated || '').localeCompare(String(a.updated || '')));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function handle(req, res, url, ctx) {
|
|
24
|
+
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
25
|
+
const what = url.pathname.replace(/^\/api\/review-packs\/?/, '');
|
|
26
|
+
if (what === '') {
|
|
27
|
+
if (req.method !== 'GET') return send(405, { ok: false, error: 'GET only' });
|
|
28
|
+
return send(200, { ok: true, items: itemsAll(ctx) });
|
|
29
|
+
}
|
|
30
|
+
if (what !== 'due') return send(404, { ok: false, error: 'no such review-pack route' });
|
|
31
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'POST only' });
|
|
32
|
+
if (req.headers && req.headers['x-pmos-session']) return send(403, { ok: false, error: 'An agent session does not open Library. Draft a pack with pmos report pack.' });
|
|
33
|
+
const rd = await ctx.readJson(req);
|
|
34
|
+
if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
35
|
+
const g = guard.requirePagePress(req, rd.body || {});
|
|
36
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
37
|
+
let written = [];
|
|
38
|
+
if (RP.autoOn(process.env)) try { written = (await RP.tick({ workspaceList: ctx.workspaceList, stateDirFor: ctx.stateDirFor })).filter((r) => r.written).map((r) => ({ ws: r.ws, path: r.path })); } catch { written = []; }
|
|
39
|
+
return send(200, { ok: true, written, items: itemsAll(ctx) });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { prefixes: ['/api/review-packs'], handle, itemsAll };
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* POST /api/roadmap-ops/breakdown/dependency { rid, jira, remove? } → { ok } the item waits on that Jira ticket
|
|
13
13
|
* POST /api/roadmap-ops/people { id, points_per_week } → { ok, people } writes <runtime>/people.json
|
|
14
14
|
*
|
|
15
|
+
* TRADE-OFF CARDS (initiative tradeoff-cards, job #1918, idea A325; lib/tradeoff-cards.js), a second prefix:
|
|
16
|
+
* GET /api/tradeoffs?ws=<id> → { ok, ws, margin, pairs: [card], kept: { id: { eid, other, other_title, reason, at } } }
|
|
17
|
+
* GET /api/tradeoffs?ids=<a,b,…> → the same for the workspace whose records hold most of those initiatives (Work's rows on screen)
|
|
18
|
+
* GET /api/tradeoffs/card?ws=<id>&a=&b= → { ok, ws, card } any two on the Roadmap (a drag put one above the other)
|
|
19
|
+
* POST /api/tradeoffs/keep { ws, a, b, first, reason } → { ok, note } the reason, and the rank when the lower one goes first
|
|
20
|
+
* POST /api/tradeoffs/undo { ws, note } → { ok, of } (note: the kept note's eid; `eid` is a writer field)
|
|
21
|
+
*
|
|
15
22
|
* STATE: bets in planning/records/bets.jsonl (scripts/records); breakdown items in <records>/breakdown-pmos.jsonl
|
|
16
23
|
* (scripts/breakdown-ops.js); people in <runtime>/people.json (the file routes-forecast.js already reads).
|
|
17
24
|
* WHO WRITES: every POST passes pm-guard requirePagePress; an agent session is refused (403). Pure handlers are exported.
|
|
@@ -121,10 +128,55 @@ const POSTS = {
|
|
|
121
128
|
'/people': (c, b) => setPeople(c.runtimeDir, b),
|
|
122
129
|
};
|
|
123
130
|
|
|
131
|
+
/** Trade-off cards (A325): reads answer the workspace's repository; the writes are the page's press (requirePagePress). */
|
|
132
|
+
async function tradeoffs(req, res, url, ctx) {
|
|
133
|
+
const TC = require('./tradeoff-cards.js');
|
|
134
|
+
const actorLib = require('./actor.js');
|
|
135
|
+
const wsOf = (id) => { try { return ctx.getWs(id || null); } catch { return null; } };
|
|
136
|
+
const now = ctx.now ? ctx.now() : Date.now();
|
|
137
|
+
if (req.method === 'GET') {
|
|
138
|
+
const ids = url.searchParams.get('ids');
|
|
139
|
+
const w = !url.searchParams.get('ws') && ids
|
|
140
|
+
? TC.wsForIds(typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : [], ids.split(','))
|
|
141
|
+
: wsOf(url.searchParams.get('ws'));
|
|
142
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
143
|
+
try {
|
|
144
|
+
if (url.pathname === '/api/tradeoffs/card') {
|
|
145
|
+
const r = TC.cardFor(w.root, url.searchParams.get('a') || '', url.searchParams.get('b') || '', { now });
|
|
146
|
+
ctx.json(res, r.ok ? { ok: true, ws: w.id, card: r.card } : { ok: false, error: r.error }, r.ok ? 200 : r.status);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
const r = TC.read(w.root, { now });
|
|
150
|
+
console.info(TC.TAG + ' read ws=' + w.id + ' pairs=' + r.pairs.length + ' kept=' + Object.keys(r.kept).length);
|
|
151
|
+
ctx.json(res, { ok: true, ws: w.id, ...r });
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.warn(TC.TAG + ' could not read ' + w.id + ': ' + ((e && e.message) || e));
|
|
154
|
+
ctx.json(res, { ok: false, error: 'The trade-offs could not be read.' }, 500);
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (req.method !== 'POST' || !['/api/tradeoffs/keep', '/api/tradeoffs/undo'].includes(url.pathname)) { ctx.json(res, { ok: false, error: 'GET, or POST keep or undo' }, 405); return true; }
|
|
159
|
+
const got = await ctx.readJson(req);
|
|
160
|
+
if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
|
|
161
|
+
const body = got.body || {};
|
|
162
|
+
const g = guard.requirePagePress(req, body);
|
|
163
|
+
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
|
|
164
|
+
const w = wsOf(body.ws);
|
|
165
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
166
|
+
const actor = g.actor || actorLib.fromUi(); // D98: an agent session's press keeps the agent's name
|
|
167
|
+
const r = url.pathname === '/api/tradeoffs/keep'
|
|
168
|
+
? TC.keep(w.root, { a: body.a, b: body.b, first: body.first, reason: body.reason }, { actor, now })
|
|
169
|
+
: TC.undo(w.root, String(body.note || ''), { actor, now });
|
|
170
|
+
ctx.json(res, r.ok ? { ok: true, ...(r.note ? { note: r.note } : { of: r.of }) } : { ok: false, error: r.error }, r.ok ? 200 : r.status);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
124
174
|
module.exports = {
|
|
125
|
-
prefixes: ['/api/roadmap-ops'],
|
|
175
|
+
prefixes: ['/api/roadmap-ops', '/api/tradeoffs'],
|
|
176
|
+
tradeoffs,
|
|
126
177
|
betAdd, betMove, betTakeOff, betAnchorSuggestions, breakdownAdd, breakdownEdit, breakdownDelete, breakdownUndo, breakdownDependency, setPeople, healthBudgets, rootOf,
|
|
127
178
|
handle: async (req, res, url, ctx) => {
|
|
179
|
+
if (url.pathname === '/api/tradeoffs' || url.pathname.startsWith('/api/tradeoffs/')) return tradeoffs(req, res, url, ctx);
|
|
128
180
|
const sub = url.pathname.slice('/api/roadmap-ops'.length);
|
|
129
181
|
if (req.method === 'GET' && sub === '/bet/anchor-suggestions') {
|
|
130
182
|
const r = betAnchorSuggestions(rootOf(ctx, url.searchParams.get('ws')), { id: url.searchParams.get('id') }, ctx);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-sim-users.js — simulated users try the prototype (initiative sim-users, idea A20, board BatchReleaseDS panel 24). The store and the
|
|
3
|
+
* walk are lib/sim-users.js; the Viewer (pm/cozy-proto.js through pm/sim-users.js) and `pmos prototype` (lib/prototype-cli.js) read and
|
|
4
|
+
* write the same store through these routes, so what the chat changes shows in the Viewer's Findings.
|
|
5
|
+
*
|
|
6
|
+
* GET /api/sim-users/findings?ws&initiative[&file] → { ok, findings, file, version, personas, base } the findings of one prototype
|
|
7
|
+
* version (file: a version's specimen path; without it, the initiative's prototype now). The first read of a version and persona
|
|
8
|
+
* set runs the walk and stores it; later reads read the stored run. findings is null when the version's flow has no key task.
|
|
9
|
+
* GET /api/sim-users/personas?ws → { ok, personas, base, removed } the personas that walk (the base four when none is recorded)
|
|
10
|
+
* POST /api/sim-users/personas { ws?, op: add, name, needs, from } | { ws?, op: remove | restore, id } → { ok, persona, undo? }
|
|
11
|
+
* `pmos prototype persona …` (the chat's agent, no Origin, D98, like the prototype rules); from a page, a page press.
|
|
12
|
+
* A finding never scores the prototype; nothing here writes to a version's folder or the proposals ledger, and no model is called. */
|
|
13
|
+
const guard = require('./pm-guard.js');
|
|
14
|
+
const SU = require('./sim-users.js');
|
|
15
|
+
|
|
16
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
17
|
+
const fail = (ctx, res, status, error) => { ctx.json(res, { ok: false, error }, status); return true; };
|
|
18
|
+
const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
|
|
19
|
+
function wsOf(ctx, id) { let w = null; try { w = ctx.getWs(id || null); } catch { w = null; } return w && (!id || w.id === id) ? w : null; }
|
|
20
|
+
const dirOf = (ctx, w) => { try { return ctx.stateDirFor ? ctx.stateDirFor(w) : null; } catch { return null; } };
|
|
21
|
+
|
|
22
|
+
function findings(ctx, res, url) {
|
|
23
|
+
const w = wsOf(ctx, url.searchParams.get('ws')); if (!w) return fail(ctx, res, 404, 'no such workspace');
|
|
24
|
+
const dir = dirOf(ctx, w), ini = url.searchParams.get('initiative') || '', want = url.searchParams.get('file') || '';
|
|
25
|
+
if (!dir || !ID_RE.test(ini)) return fail(ctx, res, 400, 'initiative names an initiative');
|
|
26
|
+
const PR = require('./proposals.js'), LAB = require('./idle-lab.js'), LR = require('./live-round.js');
|
|
27
|
+
const F = PR.read(dir), all = PR.versionsOf(F, ini, 500);
|
|
28
|
+
// a named file must be a version of this initiative; without one, the prototype now (or its newest version)
|
|
29
|
+
const cur = want ? all.find((v) => v.file === want) || null : PR.currentOf(F, ini) || all[0] || null;
|
|
30
|
+
if (want && !cur) return fail(ctx, res, 404, 'That version is no longer here');
|
|
31
|
+
const P = SU.personasOf(SU.read(dir));
|
|
32
|
+
const abs = cur ? LAB.specimenPath(ctx.runtimeDir, cur.file) : null, data = abs ? LR.partsAt(abs) : {};
|
|
33
|
+
let out = null;
|
|
34
|
+
if (abs && data.flow) { try { out = SU.forVersion(dir, { ini, file: cur.file, abs, flow: data.flow }); } catch (e) { console.warn(SU.LOG, 'findings:', e.message); } }
|
|
35
|
+
ctx.json(res, { ok: true, findings: out, file: cur ? cur.file : null, version: cur ? cur.n : null, personas: P.walking, base: P.base });
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
function personas(ctx, res, url) {
|
|
39
|
+
const w = wsOf(ctx, url.searchParams.get('ws')); if (!w) return fail(ctx, res, 404, 'no such workspace');
|
|
40
|
+
const P = SU.personasOf(SU.read(dirOf(ctx, w)));
|
|
41
|
+
ctx.json(res, { ok: true, personas: P.walking, base: P.base, removed: P.removed });
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
const READS = { '/api/sim-users/findings': findings, '/api/sim-users/personas': personas };
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
prefixes: ['/api/sim-users'],
|
|
48
|
+
handle: async (req, res, url, ctx) => {
|
|
49
|
+
const p0 = url.pathname;
|
|
50
|
+
if (req.method === 'GET') { const fn = READS[p0]; if (!fn) return fail(ctx, res, 404, 'not found'); return fn(ctx, res, url); }
|
|
51
|
+
if (req.method !== 'POST') return fail(ctx, res, 405, 'GET or POST only');
|
|
52
|
+
if (p0 !== '/api/sim-users/personas') return fail(ctx, res, 404, 'not found');
|
|
53
|
+
const got = await ctx.readJson(req);
|
|
54
|
+
if (!got.ok || !isObj(got.body)) return fail(ctx, res, 400, 'the body must be a JSON object');
|
|
55
|
+
let by;
|
|
56
|
+
if (req.headers.origin) { const g = guard.requirePagePress(req, got.body); if (!g.ok) return fail(ctx, res, g.status, g.error); by = (g.actor && g.actor.by) || 'pm:page'; }
|
|
57
|
+
else by = /^(pm|agent):[\w.:-]{1,80}$/.test(String(got.body.by || '')) ? got.body.by : 'agent:cli';
|
|
58
|
+
const w = wsOf(ctx, typeof got.body.ws === 'string' && got.body.ws ? got.body.ws : null); if (!w) return fail(ctx, res, 404, 'no such workspace');
|
|
59
|
+
const dir = dirOf(ctx, w); if (!dir) return fail(ctx, res, 409, 'This repository has no PMOS state folder.');
|
|
60
|
+
const b = got.body, op = b.op;
|
|
61
|
+
const r = op === 'add' ? SU.addPersona(dir, b, { by }) : op === 'remove' ? SU.removePersona(dir, b.id, { by }) : op === 'restore' ? SU.restorePersona(dir, b.id, { by }) : { ok: false, error: 'op is add, remove or restore' };
|
|
62
|
+
if (!r.ok) return fail(ctx, res, 400, r.error);
|
|
63
|
+
ctx.json(res, r);
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-skill-map.js — the team skill map over HTTP (bet A208, initiative skill-map). The core is lib/skill-map.js; the verb is `pmos team skills`.
|
|
3
|
+
*
|
|
4
|
+
* GET /api/team/skills?ws=<id>[&as=<name>] → { ok, people, pair, window_days, for_reports: false }
|
|
5
|
+
* POST /api/team/skills { ws, act, key } → { ok, line } | 400 act ∈ skip · undo (a page press only)
|
|
6
|
+
*
|
|
7
|
+
* WHO SEES IT. The person and their lead, never a report or a published page: a GET that carries `pack=` (the read of a published
|
|
8
|
+
* page, public/pm/readonly.js) is refused with 403 and no rows. `as` gives a person's own view (only their row).
|
|
9
|
+
* Nothing here is sent anywhere.
|
|
10
|
+
*/
|
|
11
|
+
const guard = require('./pm-guard.js');
|
|
12
|
+
const SM = require('./skill-map.js');
|
|
13
|
+
const { recordsDirFor } = require('./records-dir.js');
|
|
14
|
+
|
|
15
|
+
const CHECKOUT = require('path').join(__dirname, '..', '..');
|
|
16
|
+
function wsOf(ctx, ws) { try { return ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; } catch { return null; } }
|
|
17
|
+
const rootFor = (ctx, w) => (ctx && ctx.repoRoot) || (w && w.root) || CHECKOUT;
|
|
18
|
+
|
|
19
|
+
async function handle(req, res, url, ctx) {
|
|
20
|
+
if (url.pathname !== '/api/team/skills') return false;
|
|
21
|
+
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
22
|
+
if (req.method === 'GET') {
|
|
23
|
+
if (url.searchParams.has('pack')) return send(403, { ok: false, error: 'the team skill map is only for the person and their lead; it is never on a published page' });
|
|
24
|
+
const wsId = url.searchParams.get('ws') || null;
|
|
25
|
+
const w = wsOf(ctx, wsId);
|
|
26
|
+
const v = SM.view(rootFor(ctx, w), { as: url.searchParams.get('as') || null, dir: recordsDirFor(ctx, wsId), now: ctx.now ? ctx.now() : Date.now(), log: ctx.log || ((s) => console.log(s)) });
|
|
27
|
+
return send(200, v);
|
|
28
|
+
}
|
|
29
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
|
|
30
|
+
const rd = await ctx.readJson(req);
|
|
31
|
+
if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
32
|
+
const body = rd.body || {};
|
|
33
|
+
const g = guard.requirePagePress(req, body);
|
|
34
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
35
|
+
const r = SM.act(recordsDirFor(ctx, body.ws || null), String(body.act || ''), body.key, { by: (g.actor && g.actor.by) || 'pm' });
|
|
36
|
+
return r.ok ? send(200, { ok: true, line: r.line }) : send(400, { ok: false, error: r.error });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = { prefixes: ['/api/team/skills'], handle };
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*
|
|
21
21
|
* GET /api/voice?ws=<id> → { ok, rows, unsorted, score, suggest } customer voice by reason (lib/review-reasons.js, idea A427)
|
|
22
22
|
* POST /api/voice/file { ws, reason } → { ok, capture } the ✦: file the complaint as a triage item; /api/voice/undo { ws, capture } takes it back
|
|
23
|
+
* POST /api/voice/unread { ws, file } → { ok } takes back an export PMOS read by itself from the product's files
|
|
23
24
|
*
|
|
24
25
|
* The notes come from the Board's own backlog route (GET /api/boards/backlog, every view, the new-work stages), so they read the rows the Board draws.
|
|
25
26
|
* WHO WRITES. A page press: pm-guard requirePagePress checks the page's Origin and launch nonce. Nothing here is sent anywhere. */
|
|
@@ -109,16 +110,21 @@ async function positioning(req, res, url, ctx, send) {
|
|
|
109
110
|
|
|
110
111
|
/** Customer voice (idea A427, initiative review-reasons): survey comments and app-store reviews grouped by reason, lib/review-reasons.js.
|
|
111
112
|
* GET /api/voice?ws=<id> → { ok, rows, unsorted, score, suggest }; POST /api/voice/file { ws, reason } → { ok, capture };
|
|
112
|
-
* POST /api/voice/undo { ws, capture } → { ok }
|
|
113
|
+
* POST /api/voice/undo { ws, capture } → { ok }; POST /api/voice/unread { ws, file } → { ok } takes back an export PMOS read by itself
|
|
114
|
+
* (review-reasons-files). The GET reads new exports in the product's files first and returns `reads`. The POSTs are page presses.
|
|
115
|
+
* Nothing is sent anywhere. */
|
|
113
116
|
async function voice(req, res, url, ctx, send) {
|
|
114
117
|
const RR = require('./review-reasons.js');
|
|
115
118
|
if (url.pathname === '/api/voice' && req.method === 'GET') {
|
|
116
119
|
const root = rootFor(ctx, wsOf(ctx, url.searchParams.get('ws') || null));
|
|
117
|
-
let G;
|
|
118
|
-
try {
|
|
119
|
-
|
|
120
|
+
let G, lines;
|
|
121
|
+
try {
|
|
122
|
+
RR.readExports(root); // an export in the product's files shows with no typed ask (review-reasons-files); kept 60 s per product
|
|
123
|
+
lines = RR.read(root); G = RR.group(lines, Date.now());
|
|
124
|
+
} catch (e) { return send(500, { ok: false, error: String((e && e.message) || e).slice(0, 160) }); }
|
|
125
|
+
return send(200, { ok: true, rows: G.rows, unsorted: G.unsorted, score: G.score, suggest: G.suggest, reads: RR.readsOf(lines, Date.now()) });
|
|
120
126
|
}
|
|
121
|
-
if (
|
|
127
|
+
if (!['/api/voice/file', '/api/voice/undo', '/api/voice/unread'].includes(url.pathname)) return send(404, { ok: false, error: 'no such voice route' });
|
|
122
128
|
if (req.method !== 'POST') return send(405, { ok: false, error: 'POST' });
|
|
123
129
|
const rd = await ctx.readJson(req);
|
|
124
130
|
if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
@@ -126,7 +132,8 @@ async function voice(req, res, url, ctx, send) {
|
|
|
126
132
|
const g = guard.requirePagePress(req, body);
|
|
127
133
|
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
128
134
|
const w = wsOf(ctx, body.ws || null), root = rootFor(ctx, w);
|
|
129
|
-
const r = url.pathname === '/api/voice/file' ? RR.file(root, body.reason, { actor: g.actor })
|
|
135
|
+
const r = url.pathname === '/api/voice/file' ? RR.file(root, body.reason, { actor: g.actor })
|
|
136
|
+
: url.pathname === '/api/voice/unread' ? RR.unread(root, body.file, { actor: g.actor }) : RR.undo(root, body.capture, { actor: g.actor });
|
|
130
137
|
if (r.ok && ctx.invalidateNeedsAgg) { try { ctx.invalidateNeedsAgg(w ? w.id : null); } catch { /* the needs queue recounts on its own read */ } }
|
|
131
138
|
return r.ok ? send(200, { ok: true, capture: r.capture || null }) : send(r.status || 400, { ok: false, error: r.error });
|
|
132
139
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-team-waits.js — Work › Dependencies' "Waiting on other teams" (initiative team-waits, bet A364). lib/team-waits.js is the store.
|
|
3
|
+
*
|
|
4
|
+
* GET /api/team-waits?ws=<id> → { ok, ws, today, waits: [lib/team-waits.js wait] } open waits, oldest first; 404 for an unknown ws
|
|
5
|
+
*
|
|
6
|
+
* Read only. The chat and a terminal write the same store with `pmos deps wait|done|undo` (lib/deps-cli.js), so what they write shows here
|
|
7
|
+
* on the next read. Nothing is sent: Chase is a draft in the PM's own mail app (public/pm/team-waits.js chaseDraft). */
|
|
8
|
+
const TW = require('./team-waits.js');
|
|
9
|
+
const { todayOf } = require('./parked-reasons.js');
|
|
10
|
+
|
|
11
|
+
async function handle(req, res, url, ctx) {
|
|
12
|
+
if (url.pathname !== '/api/team-waits') { ctx.json(res, { ok: false, error: 'no such route' }, 404); return true; }
|
|
13
|
+
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
14
|
+
let w = null;
|
|
15
|
+
try { w = ctx.getWs(url.searchParams.get('ws') || null); } catch { w = null; }
|
|
16
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
17
|
+
const today = todayOf();
|
|
18
|
+
let waits = [];
|
|
19
|
+
try { waits = TW.waitsOf(w.root, { today }).waits; } catch { waits = []; }
|
|
20
|
+
ctx.json(res, { ok: true, ws: w.id, today, waits });
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { prefixes: ['/api/team-waits'], handle };
|