create-pmos 0.611.0 → 0.613.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 +105 -27
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/briefing-premium-calendar-2-test.js +3 -2
- package/workspace/briefing-premium-calendar-3-test.js +1 -1
- package/workspace/briefing-premium-calendar-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +1 -1
- package/workspace/briefing-premium-test.js +1 -1
- package/workspace/changelog.json +104 -0
- package/workspace/guide/layout.md +52 -18
- package/workspace/guide/programs.md +3 -3
- package/workspace/guide/routine.md +28 -13
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/lib/board-premium.js +12 -4
- package/workspace/lib/cos-chat.js +1 -0
- package/workspace/lib/doc-library.js +43 -12
- package/workspace/lib/doc-path.js +30 -0
- package/workspace/lib/engine/boards.js +4 -2
- package/workspace/lib/events-place.js +190 -38
- package/workspace/lib/events-stated.js +129 -0
- package/workspace/lib/initiative-chat.js +1 -0
- package/workspace/lib/insights-premium.js +13 -1
- package/workspace/lib/library-find.js +162 -0
- package/workspace/lib/library-items.js +196 -24
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/plan-items.js +17 -3
- package/workspace/lib/routes-artefacts.js +5 -2
- package/workspace/lib/routes-boards.js +6 -2
- package/workspace/lib/routes-doc-sheet.js +1 -0
- package/workspace/lib/routes-events-place.js +47 -10
- package/workspace/lib/routes-library.js +74 -8
- package/workspace/lib/routes-report-setups.js +13 -2
- package/workspace/lib/routine-reports.js +36 -4
- package/workspace/lib/status-when.js +36 -0
- package/workspace/lib/task-items.js +5 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-meet-test.js +2 -1
- package/workspace/premium-vw-notes-test.js +3 -2
- package/workspace/public/pm/artefact-kind.js +87 -0
- package/workspace/public/pm/bd-ini-panel.js +6 -6
- package/workspace/public/pm/bd-span.js +7 -1
- package/workspace/public/pm/bd-work.css +62 -0
- package/workspace/public/pm/bd-work.js +195 -68
- package/workspace/public/pm/cozy-bar.css +11 -0
- package/workspace/public/pm/cozy-bar.js +99 -0
- package/workspace/public/pm/cozy-day-pick.css +27 -0
- package/workspace/public/pm/cozy-day-pick.js +97 -0
- package/workspace/public/pm/cozy-ev.css +0 -4
- package/workspace/public/pm/cozy-events-view.js +165 -33
- package/workspace/public/pm/cozy-events.css +75 -3
- package/workspace/public/pm/cozy-events.js +86 -18
- package/workspace/public/pm/cozy-goals.css +172 -0
- package/workspace/public/pm/cozy-library.css +106 -17
- package/workspace/public/pm/cozy-nav.js +2 -3
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pop-work.css +83 -24
- package/workspace/public/pm/cozy-pop-work.js +313 -72
- package/workspace/public/pm/cozy-popup.css +11 -2
- package/workspace/public/pm/cozy-popup.js +67 -9
- package/workspace/public/pm/cozy-routine-job.js +203 -0
- package/workspace/public/pm/cozy-routine-model.js +139 -31
- package/workspace/public/pm/cozy-routine-pop.js +164 -42
- package/workspace/public/pm/cozy-routine.css +61 -8
- package/workspace/public/pm/cozy-routine.js +207 -28
- package/workspace/public/pm/cozy-settings.js +1 -5
- package/workspace/public/pm/cozy-status-when.js +48 -0
- package/workspace/public/pm/cozy-viewer.js +19 -8
- package/workspace/public/pm/cozy-vw-mtg.css +39 -0
- package/workspace/public/pm/goals-model.js +205 -0
- package/workspace/public/pm/goals-open.js +124 -0
- package/workspace/public/pm/home-chat.js +4 -2
- package/workspace/public/pm/home-ini.js +8 -6
- package/workspace/public/pm/ini-edit.js +3 -1
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/library-model.js +170 -42
- package/workspace/public/pm/library-open.js +8 -5
- package/workspace/public/pm/page-chat.js +12 -2
- package/workspace/public/pm/pop-work-model.js +199 -41
- package/workspace/public/pm/premium-board.js +108 -43
- package/workspace/public/pm/premium-goals.js +213 -0
- package/workspace/public/pm/premium-library.js +376 -62
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +79 -1
- package/workspace/public/pm/scope-chip.js +207 -0
- package/workspace/public/premium-events.html +3 -1
- package/workspace/public/premium-goals.html +37 -0
- package/workspace/public/premium-library.html +15 -7
- package/workspace/public/premium-routine.html +2 -0
- package/workspace/server.js +2 -1
- package/workspace/test-lists/doc-path.json +9 -0
- package/workspace/test-lists/goals-place.json +9 -0
- package/workspace/test-lists/status-when.json +9 -0
|
@@ -6,10 +6,16 @@
|
|
|
6
6
|
* Board reads: milestones, plan ends, tasks, forecasts), the calendar (lib/calendar-events.js), the report schedules and the drafts
|
|
7
7
|
* that wait (lib/report-needs.js), and the PM's own items (lib/pm-items.js). While a Board is still being read the answer is 202 and
|
|
8
8
|
* the page asks again. A source that cannot be read is named in `missing`, never read as nothing.
|
|
9
|
+
* Round 2 (events-round2.md) adds the Jira tickets assigned to the PM (<runtime>/my-work/read.json), the program milestones
|
|
10
|
+
* (lib/routes-programs.js all), the dates people state in the sources (lib/events-stated.js over lib/source-reads.js), the link the PM
|
|
11
|
+
* set on a meeting (lib/calendar-links.js, as Today reads it), `filters` (the products, programs and projects with a date) and
|
|
12
|
+
* `unread`: { meeting?: 'calendar not connected', deadline?: 'no source read yet' }, a type whose source PMOS does not read.
|
|
9
13
|
* POST /api/events-place/mark { key, fixed } → { ok } a date is fixed (true) or not (false): Events never offers it a new date
|
|
10
14
|
* POST /api/events-place/mark { sig, no } → { ok } the PM said no to a suggestion (no: true), or took the no back (no: false)
|
|
15
|
+
* POST /api/events-place/mark { key, gone } → { ok } a date PMOS cannot write is met ('met') or dropped ('dropped'): Events stops listing
|
|
16
|
+
* it; gone: false lists it again (Undo)
|
|
11
17
|
*
|
|
12
|
-
* STATE. <runtime>/events/marks.jsonl, append-only, one line per press: { at, by, kind: fixed | unfixed | no | unno, key | sig }. The fold
|
|
18
|
+
* STATE. <runtime>/events/marks.jsonl, append-only, one line per press: { at, by, kind: fixed | unfixed | no | unno | met | dropped | back, key | sig }. The fold
|
|
13
19
|
* keeps the last line of each key or sig. Writes pass pm-guard requirePagePress: the page only. Every other write of Events (✓ on a
|
|
14
20
|
* suggestion, a new day, +) goes through the routes that already make it: /api/boards/tasks/state, /api/boards/tasks/edit, /api/pm-items/*. */
|
|
15
21
|
const fs = require('fs');
|
|
@@ -23,15 +29,17 @@ const reason = (e) => String((e && e.message) || e).slice(0, 160);
|
|
|
23
29
|
|
|
24
30
|
/* ── the marks ── */
|
|
25
31
|
const marksFile = (runtimeDir) => path.join(runtimeDir, 'events', 'marks.jsonl');
|
|
26
|
-
/** The marks folded: { fixed: Set<key>, declined: Set<sig> }. PURE over the lines. */
|
|
32
|
+
/** The marks folded: { fixed: Set<key>, declined: Set<sig>, gone: Map<key, 'met' | 'dropped'> }. PURE over the lines. */
|
|
27
33
|
function foldMarks(lines) {
|
|
28
|
-
const fixed = new Map(), no = new Map();
|
|
34
|
+
const fixed = new Map(), no = new Map(), gone = new Map();
|
|
29
35
|
for (const l of lines || []) {
|
|
30
36
|
if (!l || typeof l !== 'object') continue;
|
|
31
37
|
if ((l.kind === 'fixed' || l.kind === 'unfixed') && typeof l.key === 'string') fixed.set(l.key, l.kind === 'fixed');
|
|
32
38
|
if ((l.kind === 'no' || l.kind === 'unno') && typeof l.sig === 'string') no.set(l.sig, l.kind === 'no');
|
|
39
|
+
if ((l.kind === 'met' || l.kind === 'dropped') && typeof l.key === 'string') gone.set(l.key, l.kind);
|
|
40
|
+
if (l.kind === 'back' && typeof l.key === 'string') gone.delete(l.key);
|
|
33
41
|
}
|
|
34
|
-
return { fixed: new Set([...fixed].filter(([, v]) => v).map(([k]) => k)), declined: new Set([...no].filter(([, v]) => v).map(([k]) => k)) };
|
|
42
|
+
return { gone, fixed: new Set([...fixed].filter(([, v]) => v).map(([k]) => k)), declined: new Set([...no].filter(([, v]) => v).map(([k]) => k)) };
|
|
35
43
|
}
|
|
36
44
|
function readMarks(runtimeDir) {
|
|
37
45
|
let text = '';
|
|
@@ -44,7 +52,8 @@ function markLine(body, by, at) {
|
|
|
44
52
|
const okStr = (s) => typeof s === 'string' && s.length > 0 && s.length <= MAX_LEN;
|
|
45
53
|
if (okStr(b.key) && typeof b.fixed === 'boolean') return { at, by, kind: b.fixed ? 'fixed' : 'unfixed', key: b.key };
|
|
46
54
|
if (okStr(b.sig) && typeof b.no === 'boolean') return { at, by, kind: b.no ? 'no' : 'unno', sig: b.sig };
|
|
47
|
-
|
|
55
|
+
if (okStr(b.key) && (b.gone === 'met' || b.gone === 'dropped' || b.gone === false)) return { at, by, kind: b.gone || 'back', key: b.key };
|
|
56
|
+
return { error: "send { key, fixed: true | false }, { sig, no: true | false } or { key, gone: 'met' | 'dropped' | false }" };
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
/* ── the readers ── */
|
|
@@ -104,6 +113,22 @@ function readDrafts(roots) {
|
|
|
104
113
|
}
|
|
105
114
|
return out;
|
|
106
115
|
}
|
|
116
|
+
/** The Jira tickets assigned to the PM, as the last my-work read holds them. */
|
|
117
|
+
function readJira(runtimeDir) {
|
|
118
|
+
try { const r = JSON.parse(fs.readFileSync(path.join(runtimeDir, 'my-work', 'read.json'), 'utf8')); return r && Array.isArray(r.items) ? r.items.filter((x) => x && x.key) : []; } catch { return []; }
|
|
119
|
+
}
|
|
120
|
+
/** The calendar's meetings with the link the PM set on each (lib/calendar-links.js wins over the brief's guess, as on Today). */
|
|
121
|
+
function readMeetings(runtimeDir, now) {
|
|
122
|
+
const events = require('./calendar-events.js').readAll(runtimeDir, { now: now.getTime() });
|
|
123
|
+
let links = null;
|
|
124
|
+
try { const CL = require('./calendar-links.js'); links = CL.read(runtimeDir); for (const e of events) { const l = links.get(CL.keyOf(e)); if (l && l.kind === 'initiative' && l.initiative) e.initiative = l.initiative; } } catch { /* the brief's own link stays */ }
|
|
125
|
+
return events;
|
|
126
|
+
}
|
|
127
|
+
/** Does PMOS read a calendar at all: an import ledger, the remembered calendar, or a meeting in hand? */
|
|
128
|
+
function calendarRead(runtimeDir, meetings) {
|
|
129
|
+
if ((meetings || []).length) return true;
|
|
130
|
+
return ['calendar-import/events.jsonl', 'calendar-memory.json'].some((f) => { try { return fs.statSync(path.join(runtimeDir, f)).size > 0; } catch { return false; } });
|
|
131
|
+
}
|
|
107
132
|
function readOwn(runtimeDir) {
|
|
108
133
|
const P = require('./pm-items.js');
|
|
109
134
|
return P.fold(P.readLines(path.join(runtimeDir, 'pm-items', 'items.jsonl'))).map((o) => ({ id: o.id, title: o.title, due: o.due || null, done: !!o.done }));
|
|
@@ -121,13 +146,21 @@ async function handle(deps) {
|
|
|
121
146
|
const schedules = tryRead('the report schedules', () => deps.readSchedules(), []);
|
|
122
147
|
const drafts = tryRead('the report drafts', () => deps.readDrafts(boards), []);
|
|
123
148
|
const own = tryRead('your items', () => deps.readOwn(), []);
|
|
124
|
-
const marks = tryRead('your marks', () => deps.readMarks(), { fixed: new Set(), declined: new Set() });
|
|
125
|
-
const
|
|
126
|
-
|
|
149
|
+
const marks = tryRead('your marks', () => deps.readMarks(), { fixed: new Set(), declined: new Set(), gone: new Map() });
|
|
150
|
+
const jira = deps.readJira ? tryRead('your Jira tickets', () => deps.readJira(), []) : [];
|
|
151
|
+
const programs = deps.readPrograms ? tryRead('the programs', () => deps.readPrograms(), []) : [];
|
|
152
|
+
const reads = deps.readSources ? tryRead('the sources', () => deps.readSources(), {}) : {};
|
|
153
|
+
const stated = require('./events-stated.js').statedDates(reads, { today: deps.today });
|
|
154
|
+
const model = EP.build({ today: deps.today, boards, meetings, schedules, drafts, own, marks, jira, programs, stated });
|
|
155
|
+
// a type whose source PMOS does not read says so in the key, never as an empty tick (round 2, point 2)
|
|
156
|
+
const unread = {};
|
|
157
|
+
if (!(deps.calendarRead ? deps.calendarRead(meetings) : meetings.length)) unread.meeting = 'calendar not connected';
|
|
158
|
+
if (!Object.values(reads || {}).some((r) => r && r.state === 'read')) unread.deadline = 'no source read yet';
|
|
159
|
+
return { status: 200, body: { ok: true, state: 'ready', today: model.today, items: model.items, later: model.later, filters: model.filters, unread, missing } };
|
|
127
160
|
}
|
|
128
161
|
|
|
129
162
|
module.exports = {
|
|
130
|
-
foldMarks, markLine, handlePure: handle, readers: { readSchedules, readDrafts, readOwn, readMarks },
|
|
163
|
+
foldMarks, markLine, handlePure: handle, readers: { readSchedules, readDrafts, readOwn, readMarks, readJira, readMeetings, calendarRead },
|
|
131
164
|
prefixes: ['/api/events-place'],
|
|
132
165
|
handle: async (req, res, url, ctx) => {
|
|
133
166
|
if (url.pathname === '/api/events-place/mark') {
|
|
@@ -153,7 +186,11 @@ module.exports = {
|
|
|
153
186
|
const out = await handle({
|
|
154
187
|
today: localDay(now),
|
|
155
188
|
readBoards: () => readBoards(req, ctx),
|
|
156
|
-
readMeetings: () => (ctx.runtimeDir ?
|
|
189
|
+
readMeetings: () => (ctx.runtimeDir ? readMeetings(ctx.runtimeDir, now) : []),
|
|
190
|
+
calendarRead: (m) => (ctx.runtimeDir ? calendarRead(ctx.runtimeDir, m) : false),
|
|
191
|
+
readJira: () => (ctx.runtimeDir ? readJira(ctx.runtimeDir) : []),
|
|
192
|
+
readPrograms: () => require('./routes-programs.js').all(ctx),
|
|
193
|
+
readSources: () => (ctx.runtimeDir ? require('./source-reads.js').all(ctx.runtimeDir) : {}),
|
|
157
194
|
readSchedules: () => readSchedules(now),
|
|
158
195
|
readDrafts: (boards) => readDrafts([...new Set(boards.map((x) => x.ws))].map((ws) => ({ ws, w: ctx.getWs ? ctx.getWs(ws || null) : null })).filter((x) => x.w && x.w.root).map((x) => ({ ws: x.ws, root: x.w.root }))),
|
|
159
196
|
readOwn: () => (ctx.runtimeDir ? readOwn(ctx.runtimeDir) : []),
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-library.js — GET /api/library-items[?ws=<id>&initiative=<id>] (initiative library-place, slice 7 of the six-place navigation).
|
|
3
3
|
*
|
|
4
|
-
* The Library place reads every product; slice 3's Artefacts table reads one initiative. → { ok, items } (lib/library-items.js ITEM),
|
|
4
|
+
* The Library place reads every product; slice 3's Artefacts table reads one initiative. → { ok, items, programs } (lib/library-items.js ITEM),
|
|
5
5
|
* newest first. READ ONLY: it folds what is already recorded and writes nothing.
|
|
6
6
|
* files lib/doc-library.js library() — the tracked markdown files, attributed to the initiative that owns them (server.js initiativeIndex)
|
|
7
7
|
* links lib/custom-docs.js — the links the PM added to an initiative (Confluence, Google Docs, Google Slides)
|
|
8
8
|
* rounds lib/idle-lab.js roundsOf over lib/proposals.js — the prototype rounds of each initiative
|
|
9
9
|
* notes lib/notes.js list() — the meeting notes of the runtime directory
|
|
10
|
+
* programs lib/routes-programs.js all() — the program each initiative stands in (About is "Program › Initiative"); the answer lists them
|
|
11
|
+
* for the scope chip as { id, title }
|
|
10
12
|
* A source that cannot be read is left out, and the answer says which in `unread` (the page says nothing about it unless every source failed).
|
|
13
|
+
*
|
|
14
|
+
* GET /api/library-items/find?q=<words>[&ws=<id,id>][&rank=1] → { ok, q, ranked, why?, results: [{ id, passage, words? , idea? }] } search by meaning
|
|
15
|
+
* (lib/library-find.js): the items whose text holds the question's words, each with its passage; rank=1 asks one PMOS session to keep
|
|
16
|
+
* the ones about the question, best first, with the idea to show in bold. When it cannot, the word ranking comes back with `why`.
|
|
17
|
+
* GET /api/library-items/peek?ws=<id>&path=<p> → { ok, head: [line], from: [{ path, title }] } the record preview on a wide screen:
|
|
18
|
+
* the file's first lines and the files that link to it (the knowledge graph's links)
|
|
11
19
|
* (/api/library is the old file tree of one workspace, server.js; this route is a different one.) */
|
|
12
20
|
const Items = require('./library-items.js');
|
|
13
21
|
|
|
@@ -66,24 +74,82 @@ function gather(ctx, list) {
|
|
|
66
74
|
}
|
|
67
75
|
let notes = [];
|
|
68
76
|
try { const l = require('./notes.js').list(ctx.runtimeDir); notes = l.ok ? l.notes : []; } catch { unread.push({ ws: null, source: 'meeting notes' }); }
|
|
69
|
-
|
|
77
|
+
let programs = [];
|
|
78
|
+
try { programs = require('./routes-programs.js').all(ctx); } catch { programs = []; }
|
|
79
|
+
return { items: Items.build({ products, notes, programs }), unread, programs: programs.map((g) => ({ id: g.id, title: g.title || g.id })) };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The first lines of one listed file (no frontmatter), and the files that link to it. → { ok, head, from } */
|
|
83
|
+
function peek(ctx, w, rel) {
|
|
84
|
+
const lib = require('./doc-library.js').library(w.root, { stateDir: ctx.runtimeDir, owners: () => ownersOf(ctx, w.root) });
|
|
85
|
+
if (!lib.ok) return { ok: false, status: 404, error: lib.error };
|
|
86
|
+
const i = lib.files.findIndex((f) => f.path === rel);
|
|
87
|
+
if (i < 0) return { ok: false, status: 404, error: 'no such file in the Library' };
|
|
88
|
+
let text = '';
|
|
89
|
+
try { text = require('fs').readFileSync(require('path').join(w.root, rel), 'utf8').slice(0, 64 * 1024); } catch { text = ''; }
|
|
90
|
+
const body = text.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, '');
|
|
91
|
+
const head = [];
|
|
92
|
+
for (const l of body.split(/\r?\n/)) {
|
|
93
|
+
if (/^#\s/.test(l)) continue; // the page title repeats the name the preview already shows
|
|
94
|
+
const t = l.replace(/^\s*(?:#+|[-*+>]|\d+[.)])\s*/, '').replace(/\*\*|__|`/g, '').replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').trim();
|
|
95
|
+
if (!t || /^\|?[\s:|-]*-{3,}[\s:|-]*$/.test(t) || /^<!--/.test(t)) continue;
|
|
96
|
+
// a table row reads as one line: "T1 · GET … · Unit test"
|
|
97
|
+
head.push(t.replace(/^\|\s*|\s*\|$/g, '').replace(/\s*\|\s*/g, ' · ').slice(0, 240));
|
|
98
|
+
if (head.length >= 6) break;
|
|
99
|
+
}
|
|
100
|
+
const seen = new Set(), from = [];
|
|
101
|
+
for (const [a, b] of lib.edges) {
|
|
102
|
+
if (b !== i || seen.has(a)) continue;
|
|
103
|
+
seen.add(a);
|
|
104
|
+
const f = lib.files[a];
|
|
105
|
+
from.push({ path: f.path, title: String(f.title || f.path) });
|
|
106
|
+
if (from.length >= 8) break;
|
|
107
|
+
}
|
|
108
|
+
return { ok: true, head, from };
|
|
70
109
|
}
|
|
71
110
|
|
|
72
111
|
async function handle(req, res, url, ctx) {
|
|
73
|
-
|
|
112
|
+
const P = url.pathname;
|
|
113
|
+
if (P !== '/api/library-items' && P !== '/api/library-items/find' && P !== '/api/library-items/peek') return false;
|
|
74
114
|
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
115
|
+
let all = [];
|
|
116
|
+
try { all = typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : []; } catch { all = []; }
|
|
117
|
+
if (P === '/api/library-items/peek') {
|
|
118
|
+
const w = all.find((x) => x.id === (url.searchParams.get('ws') || ''));
|
|
119
|
+
const rel = String(url.searchParams.get('path') || '');
|
|
120
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
121
|
+
if (!rel || rel.includes('..') || rel.startsWith('/')) { ctx.json(res, { ok: false, error: 'path names a file of the Library' }, 400); return true; }
|
|
122
|
+
let r; try { r = peek(ctx, w, rel); } catch (e) { r = { ok: false, status: 500, error: 'the file could not be read' }; }
|
|
123
|
+
ctx.json(res, r, r.ok ? 200 : r.status || 400);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
if (P === '/api/library-items/find') {
|
|
127
|
+
// search by meaning (round 2, point 7): the shortlist by words; with rank=1, one PMOS session ranks it by meaning
|
|
128
|
+
const q = String(url.searchParams.get('q') || '').slice(0, 300).trim();
|
|
129
|
+
if (!q) { ctx.json(res, { ok: true, q, results: [], ranked: false }); return true; }
|
|
130
|
+
const F = require('./library-find.js');
|
|
131
|
+
// ws=<id,id>: the products the page shows (its product pick), so the shortlist is not spent on products the PM is not looking at
|
|
132
|
+
const only = new Set(String(url.searchParams.get('ws') || '').split(',').map((x) => x.trim()).filter(Boolean));
|
|
133
|
+
const among = only.size ? all.filter((w) => only.has(w.id)) : all;
|
|
134
|
+
const { items } = gather(ctx, among);
|
|
135
|
+
const list = F.shortlist({ roots: among.map((w) => ({ ws: w.id, root: w.root })), items, q });
|
|
136
|
+
if (url.searchParams.get('rank') !== '1') { ctx.json(res, { ok: true, q, ranked: false, results: list.map(({ id, passage, words }) => ({ id, passage, words })) }); return true; }
|
|
137
|
+
const r = await F.rank(ctx, q, list, items);
|
|
138
|
+
if (!r.ok) { ctx.json(res, { ok: true, q, ranked: false, why: r.why, results: list.map(({ id, passage, words }) => ({ id, passage, words })) }); return true; }
|
|
139
|
+
ctx.json(res, { ok: true, q, ranked: true, results: r.results });
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
75
142
|
const ws = url.searchParams.get('ws') || '', ini = url.searchParams.get('initiative') || '';
|
|
76
143
|
if (ini && !ID_RE.test(ini)) { ctx.json(res, { ok: false, error: 'initiative names an initiative' }, 400); return true; }
|
|
77
|
-
let list =
|
|
78
|
-
try { list = typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : []; } catch { list = []; }
|
|
144
|
+
let list = all;
|
|
79
145
|
if (ws) {
|
|
80
146
|
const w = list.find((x) => x.id === ws);
|
|
81
147
|
if (!w) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
82
148
|
list = [w];
|
|
83
149
|
}
|
|
84
|
-
const { items, unread } = gather(ctx, list);
|
|
85
|
-
ctx.json(res, { ok: true, items: Items.narrow(items, { ws: ws || null, initiative: ini || null }), unread });
|
|
150
|
+
const { items, unread, programs } = gather(ctx, list);
|
|
151
|
+
ctx.json(res, { ok: true, items: Items.narrow(items, { ws: ws || null, initiative: ini || null }), programs, unread });
|
|
86
152
|
return true;
|
|
87
153
|
}
|
|
88
154
|
|
|
89
|
-
module.exports = { prefixes: ['/api/library-items'], handle, gather, roundsOf };
|
|
155
|
+
module.exports = { prefixes: ['/api/library-items'], handle, gather, roundsOf, peek };
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* POST /api/report-setups/move { ws, id, to } → { ok, id, to, moved } ✦ Move to <product>: definition, drafts and setup go to
|
|
22
22
|
* the workspace `to`; a report with an issued issue is 409 (redesign R)
|
|
23
23
|
* POST /api/report-setups/remove { ws, id } → { ok } delete a TEMPLATE: its schedule stops; its drafts and issued reports stay (L2)
|
|
24
|
+
* POST /api/report-setups/drop { ws, id } → { ok } ✕ on a report PMOS proposes: its draft definition moves to
|
|
25
|
+
* definitions/.dropped/ (lib/routine-reports.js dropDefinition); a set-up report is 409
|
|
24
26
|
* POST /api/report-setups/from-dashboard { ws, key, name, output, schedule, audience } → { ok, setup }
|
|
25
27
|
* POST /api/report-setups/finder { ws, cadence?, sources? } → { ok, finder }
|
|
26
28
|
* GET /api/report-setups/storyline?ws&board&scope&story? → { ok, storyline, defaults, checks, proposals } a report from Intelligence (batch 15 item 4,
|
|
@@ -67,7 +69,7 @@ const headless = require('./headless.js');
|
|
|
67
69
|
|
|
68
70
|
const text = (v) => (typeof v === 'string' ? v : '');
|
|
69
71
|
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
70
|
-
const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder', 'edit', 'remove', 'documents/discard', 'documents/archive', 'strip-dismiss', 'confirm', 'move'];
|
|
72
|
+
const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder', 'edit', 'remove', 'documents/discard', 'documents/archive', 'strip-dismiss', 'confirm', 'move', 'drop'];
|
|
71
73
|
const IR = require('./intel-report.js');
|
|
72
74
|
const MADE_BY = ['schedule', 'you', 'agent'];
|
|
73
75
|
|
|
@@ -350,7 +352,7 @@ async function handle(req, res, url, ctx) {
|
|
|
350
352
|
const setups = [...RS.fold(RS.readLines(RS.ledgerFile(w.root))).setups.values()].map((s) => {
|
|
351
353
|
let next = null;
|
|
352
354
|
if (s.status === 'active' && s.schedule) { try { const n = RS.nextDraftAt(s.schedule, s.last_run, now); next = n ? n.toISOString() : null; } catch { next = null; } }
|
|
353
|
-
return { id: s.id, name: s.name, purpose: s.purpose, audience: s.audience, source: s.source, output: s.output, schedule: s.schedule, label: RS.scheduleLabel(s.schedule), next_draft: next, status: s.status };
|
|
355
|
+
return { id: s.id, name: s.name, purpose: s.purpose, audience: s.audience, source: s.source, output: s.output, schedule: s.schedule, label: RS.scheduleLabel(s.schedule), next_draft: next, status: s.status, ...(s.ready ? { ready: s.ready } : {}) };
|
|
354
356
|
});
|
|
355
357
|
const reports = require('./routine-reports.js').routineReports({ setups, docs: documentsOf(ctx, w).docs, defs, boards, here: w.id });
|
|
356
358
|
return send({ status: 200, body: { ok: true, ws: w.id, name: w.name || w.id, reports } });
|
|
@@ -553,6 +555,15 @@ async function handle(req, res, url, ctx) {
|
|
|
553
555
|
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg();
|
|
554
556
|
return send({ status: 200, body: Object.assign({ to: t.id }, r) });
|
|
555
557
|
}
|
|
558
|
+
if (sub === 'drop') {
|
|
559
|
+
const id = text(body.id);
|
|
560
|
+
const s = RS.fold(RS.readLines(file)).setups.get(id);
|
|
561
|
+
if (s && s.status !== 'removed') return send(bad(409, 'it is set up: pause or delete it instead'));
|
|
562
|
+
const r = require('./routine-reports.js').dropDefinition(root, id);
|
|
563
|
+
if (!r.ok) return fail(r);
|
|
564
|
+
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg();
|
|
565
|
+
return send({ status: 200, body: { ok: true } });
|
|
566
|
+
}
|
|
556
567
|
if (sub === 'remove') {
|
|
557
568
|
const r = RS.remove(root, text(body.id), opts);
|
|
558
569
|
if (!r.ok) return fail(r);
|
|
@@ -3,20 +3,26 @@
|
|
|
3
3
|
* board 11 on Exploring 2; done test planning/done-tests/routine-place.md T1).
|
|
4
4
|
*
|
|
5
5
|
* routineReports({ setups, docs, defs, boards, here }) → [row] PURE
|
|
6
|
-
* setups GET /api/report-setups setups (lib/routes-report-setups.js listAnswer): { id, name, purpose, audience, source, output, schedule,
|
|
6
|
+
* setups GET /api/report-setups setups (lib/routes-report-setups.js listAnswer): { id, name, purpose, audience, source, output, schedule, ready?,
|
|
7
7
|
* label, next_draft, status: active | paused }
|
|
8
8
|
* docs the report documents (routes-report-setups.js documentsOf docs): { path, setup, name, slot, state: draft | issued, archived, source, output }
|
|
9
9
|
* defs the definitions (lib/report-setups.js definitionsOf): { id, title, audience, status, source, output }
|
|
10
10
|
* boards [{ ws, name }] and here: the workspace the reports sit in (for the ✦ Move of lib/report-acts.js)
|
|
11
|
-
* row: { id, name, audience, purpose, when, schedule, next, status: 'active' | 'paused' | null, output, source, act, issues, latest }
|
|
11
|
+
* row: { id, name, audience, purpose, when, schedule, next, status: 'active' | 'paused' | null, output, source, about, definition, act, issues, latest }
|
|
12
12
|
* when the setup's schedule in words; '' when no setup says it (a definition drafted by a skill has no schedule here)
|
|
13
13
|
* next the setup's next draft (ISO) while it is active, else null
|
|
14
14
|
* act the report's one ✓ (lib/report-acts.js reportActOf): move | confirm | issue | resume, or null
|
|
15
15
|
* issues its files, newest first: { path, slot, state, archived }; latest is the newest one not archived, or null
|
|
16
16
|
*
|
|
17
17
|
* A report is a row when it has a setup or at least one issue. A definition with neither is not drawn (zero is silence). Nothing is filled with a
|
|
18
|
-
* guess: a field the records leave silent is '' or null.
|
|
18
|
+
* guess: a field the records leave silent is '' or null. routineReports only reads.
|
|
19
|
+
*
|
|
20
|
+
* dropDefinition(root, id) → { ok } | { ok: false, status, error } ✕ on a report PMOS proposes (Routine round 3 item 1): the definition
|
|
21
|
+
* moves to definitions/.dropped/<id>.md, so it is no longer read (definitionsOf reads *.md of definitions/ only) and nothing is lost: moving it
|
|
22
|
+
* back brings the proposal back. Only a proposed definition (status: draft) with no setup can be dropped; the route checks the setup.
|
|
19
23
|
*/
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
20
26
|
const RA = require('./report-acts.js');
|
|
21
27
|
|
|
22
28
|
const str = (v) => (typeof v === 'string' ? v : '');
|
|
@@ -42,6 +48,8 @@ function routineReports(f = {}) {
|
|
|
42
48
|
when: s ? str(s.label) : '', schedule: s && s.schedule ? s.schedule : null, next: s && s.status === 'active' ? s.next_draft || null : null,
|
|
43
49
|
status: s ? (s.status === 'paused' ? 'paused' : 'active') : null,
|
|
44
50
|
output: str(s && s.output) || str(def && def.output) || str(named && named.output), source: str(s && s.source) || str(def && def.source) || str(named && named.source),
|
|
51
|
+
about: aboutOf(s), // the program or project (initiative) its setup is about, for Routine's chip; null for a product's report
|
|
52
|
+
definition: str(def && def.path) || null, // the definition file, whose body is the report's Instruction (round 3 item 3)
|
|
45
53
|
act, issues, latest: issues.find((x) => !x.archived) || null,
|
|
46
54
|
});
|
|
47
55
|
}
|
|
@@ -49,4 +57,28 @@ function routineReports(f = {}) {
|
|
|
49
57
|
return out.sort((a, b) => (a.status ? 0 : 1) - (b.status ? 0 : 1) || a.name.localeCompare(b.name));
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
/** What a setup is about, from the setup only: a ready-made report's scope, an initiative dashboard, or an Intelligence scope. */
|
|
61
|
+
function aboutOf(s) {
|
|
62
|
+
if (!s) return null;
|
|
63
|
+
const m = /^(program|initiative):(.+)$/.exec(String((s.ready && s.ready.scope) || ''))
|
|
64
|
+
|| /^dashboard:(initiative):(.+)$/.exec(str(s.source)) || /^intelligence:(program|initiative):(.+)$/.exec(str(s.source));
|
|
65
|
+
return m ? { level: m[1], id: m[2] } : null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const DEF_ID = /^[a-z][a-z0-9-]{0,39}$/;
|
|
69
|
+
function dropDefinition(root, id) {
|
|
70
|
+
if (!DEF_ID.test(String(id || ''))) return { ok: false, status: 400, error: 'no such proposal' };
|
|
71
|
+
const abs = path.resolve(String(root));
|
|
72
|
+
const dir = path.join(abs, require('./report-draft.js').stateRel(abs), 'reports', 'definitions');
|
|
73
|
+
const from = path.join(dir, id + '.md');
|
|
74
|
+
let txt;
|
|
75
|
+
try { txt = fs.readFileSync(from, 'utf8'); } catch { return { ok: false, status: 404, error: 'no such proposal' }; }
|
|
76
|
+
const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(txt);
|
|
77
|
+
const st = fm && /^status:\s*["']?([\w-]+)/m.exec(fm[1]);
|
|
78
|
+
if (!st || st[1] !== 'draft') return { ok: false, status: 409, error: 'it is not a proposal: it was confirmed, so pause or delete it instead' };
|
|
79
|
+
const to = path.join(dir, '.dropped');
|
|
80
|
+
try { fs.mkdirSync(to, { recursive: true }); fs.renameSync(from, path.join(to, id + '.md')); } catch (e) { return { ok: false, status: 500, error: 'it could not be dropped: ' + e.message }; }
|
|
81
|
+
return { ok: true };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = { routineReports, dropDefinition, aboutOf };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/status-when.js — the day a status move really happened (popup round 3 point 18). A person often moves a task late, so the move can carry
|
|
3
|
+
* `happened` (YYYY-MM-DD) apart from `at`, the time it was recorded. The server checks it here; pm/cozy-status-when.js asks it on the page.
|
|
4
|
+
*
|
|
5
|
+
* checkHappened(v, { today, floor }) → null, or the refusal in plain words. v is a YYYY-MM-DD day, never after today (today is the server's
|
|
6
|
+
* UTC day; one day of slack lets a person east of UTC say their own today), never before floor (the
|
|
7
|
+
* previous move's day, or the day the task was made)
|
|
8
|
+
* floorOf(t) → that floor for a folded PMOS task: the day of its last move (its happened, else its at), else its at
|
|
9
|
+
* lateDays(due, done) → whole days a Done came after its due day (0 when on time or a day is missing) */
|
|
10
|
+
const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
11
|
+
const DAY = 864e5;
|
|
12
|
+
const ms = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
13
|
+
const iso = (n) => new Date(n).toISOString().slice(0, 10);
|
|
14
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
15
|
+
const words = (v) => { const d = new Date(ms(v)); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()] + ' ' + d.getUTCFullYear(); };
|
|
16
|
+
|
|
17
|
+
function checkHappened(v, o = {}) {
|
|
18
|
+
if (typeof v !== 'string' || !DAY_RE.test(v) || iso(ms(v)) !== v) return 'happened is a day, YYYY-MM-DD';
|
|
19
|
+
const today = o.today || iso(Date.now());
|
|
20
|
+
if (ms(v) > ms(today) + DAY) return 'A move cannot happen in the future.';
|
|
21
|
+
const floor = o.floor && DAY_RE.test(String(o.floor).slice(0, 10)) ? String(o.floor).slice(0, 10) : null;
|
|
22
|
+
if (floor && v < floor) return 'The previous change was on ' + words(floor) + '. Pick that day or later.';
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function floorOf(t) {
|
|
26
|
+
if (!t) return null;
|
|
27
|
+
const h = (t.history || []).filter((x) => x && x.state);
|
|
28
|
+
const last = h[h.length - 1];
|
|
29
|
+
const v = last ? last.happened || last.at : t.at;
|
|
30
|
+
return v ? String(v).slice(0, 10) : null;
|
|
31
|
+
}
|
|
32
|
+
function lateDays(due, done) {
|
|
33
|
+
const a = ms(due), b = ms(done);
|
|
34
|
+
return a == null || b == null || b <= a ? 0 : Math.round((b - a) / DAY);
|
|
35
|
+
}
|
|
36
|
+
module.exports = { checkHappened, floorOf, lateDays, DAY_RE };
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* STATE_OF[item.state] → its task state: todo To do · doing, review In progress · done Done
|
|
9
9
|
* rowsOf(root, ids, board) → the items of those initiatives as work items (routes-boards itemsOf's shape, src 'pmos', store 'item')
|
|
10
10
|
* itemOf(root, id) → the folded item, or null (a withdrawn item is gone: it was Won't do)
|
|
11
|
-
* stateEvents(it, state, why)
|
|
11
|
+
* stateEvents(it, state, why, happened) → the plan-items lines that set a task state: a move (happened: the day it really happened), or a
|
|
12
|
+
* withdraw for Won't do and Archived
|
|
12
13
|
* deleteEvents(it, why) · restoreEvents(id) → a Delete (a withdraw with why "deleted") and its Undo (batch 11 item 16)
|
|
13
14
|
* goneOf(root, id) → a withdrawn item as it was, or null: what a restore brings back
|
|
14
15
|
* editEvents(it, edit) → the lines of a rename, a reschedule or the Viewer's edits (title, owner, notes, start, due)
|
|
@@ -60,7 +61,7 @@ function rowsOf(root, ids, board) {
|
|
|
60
61
|
const it = f.items[id];
|
|
61
62
|
if (!it || it.proposed || !ids.has(it.initiative)) continue;
|
|
62
63
|
out.push({ uid: it.id, key: '', kind: 'Task', src: 'pmos', store: 'item', title: it.title, status: STATE_OF[it.state] || 'To do', blocked: !!it.blocked, owner: ownerName(it.owner),
|
|
63
|
-
notes: it.note || '', ini: it.initiative, epic: null, start: it.start || null, end: it.due || null, ref: it.id, board, ...(it.milestone ? { milestone: true } : {}),
|
|
64
|
+
notes: it.note || '', ini: it.initiative, epic: null, start: it.start || null, end: it.due || null, ref: it.id, board, ...(it.milestone ? { milestone: true } : {}), ...((it.history || []).some((h) => h.ev === 'moved') ? { since: planItems.sinceOf(it) } : {}),
|
|
64
65
|
// the breakdown's own stage (plan-tree) and order: the one view places the item in the workflow stage of the same name
|
|
65
66
|
...(it.stage ? { itemStage: it.stage } : {}), ...(Number.isFinite(it.order) ? { order: it.order } : {}) });
|
|
66
67
|
}
|
|
@@ -68,12 +69,13 @@ function rowsOf(root, ids, board) {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/** → { events } | { same: true } | { error } */
|
|
71
|
-
function stateEvents(it, state, why) {
|
|
72
|
+
function stateEvents(it, state, why, happened) {
|
|
72
73
|
if (state === "Won't do" || state === 'Archived') return { events: [{ ev: 'withdrawn', item: it.id }] };
|
|
73
74
|
const to = MOVE_TO[state];
|
|
74
75
|
if (!to) return { error: `state is one of ${Object.keys(MOVE_TO).concat("Won't do", 'Archived').join(', ')}` };
|
|
75
76
|
if (STATE_OF[it.state] === state) return { same: true };
|
|
76
77
|
const ev = { ev: 'moved', item: it.id, to };
|
|
78
|
+
if (happened) ev.happened = happened;
|
|
77
79
|
// the reason a person gave is the Done's evidence: an agent Done with none goes to the PM to check (lib/plan-items.js noEvidence)
|
|
78
80
|
if (to === 'done' && typeof why === 'string' && why.trim()) ev.evidence = { kind: 'note', ref: why.trim().replace(/\s+/g, ' ').slice(0, 200) };
|
|
79
81
|
return { events: [ev] };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.613.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.613.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -52,7 +52,8 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
|
52
52
|
/* an ended meeting with notes and a recording */
|
|
53
53
|
const A = await open('/premium-viewer.html?open=meeting¬e=n1');
|
|
54
54
|
const p = A.page;
|
|
55
|
-
|
|
55
|
+
// a held meeting opens in its notes view (board 34); its full card, which this suite reads, is one press away
|
|
56
|
+
const up = await until(() => p.evaluate(() => { const f = document.querySelector('#czViewer [data-a="h-full"]'); if (f) f.click(); return !!document.querySelector('#czViewer .vz-mtg[data-mk="notes"]') && !!document.querySelector('#czViewer .czs-sum'); }), 15000);
|
|
56
57
|
ok('0 the meeting opens in the Viewer on its own page', up);
|
|
57
58
|
if (!up) return finish(1);
|
|
58
59
|
|
|
@@ -77,13 +77,14 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
|
77
77
|
/* N5 a note opens in the card */
|
|
78
78
|
await tap(p, '[data-c="note"][data-id="n3"]');
|
|
79
79
|
ok('N5 a note opens as the meeting card in place of the list', await until(() => p.evaluate(() => !!document.querySelector('#czViewer .vz-mtg') && /Compare meeting note apps/.test(document.querySelector('#czViewer .cz-vw-title').textContent))), (await text(p)).slice(0, 300));
|
|
80
|
-
|
|
80
|
+
const full = (pg) => pg.evaluate(() => { const f = document.querySelector('#czViewer [data-a="h-full"]'); if (f) f.click(); }); // a held note opens in its notes view (board 34); the full card is one press away
|
|
81
|
+
ok('N5 a note that is not linked offers What it is about', await until(async () => (await full(p), true) && /What it is about/.test(await text(p)) && !!(await p.$('#czViewer [data-a="m-about"]'))), (await text(p)).slice(0, 400));
|
|
81
82
|
await p.evaluate(() => window.czViews.openNotes({}));
|
|
82
83
|
await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-c="ser"][data-k="viewer-sync"]')));
|
|
83
84
|
await tap(p, '[data-c="ser"][data-k="viewer-sync"]');
|
|
84
85
|
ok('N3 pressing the series card unfolds its notes, newest first', await until(async () => (await ids(p)).slice(0, 2).join() === 'n1,n0'), JSON.stringify(await ids(p)));
|
|
85
86
|
await tap(p, '[data-c="note"][data-id="n1"]');
|
|
86
|
-
ok('N5 a note of the series opens and its summary says 4 of 4 in the series', await until(async () => /4 of 4/.test(await text(p))) && A.S.gets.some((x) => /notes\/one\?id=n1/.test(x)), (await text(p)).slice(0, 300));
|
|
87
|
+
ok('N5 a note of the series opens and its summary says 4 of 4 in the series', await until(async () => (await full(p), true) && /4 of 4/.test(await text(p))) && A.S.gets.some((x) => /notes\/one\?id=n1/.test(x)), (await text(p)).slice(0, 300));
|
|
87
88
|
ok('N5 ⋯ holds the meeting before, and no meeting after the last one', await until(async () => { const r = await F.more(p); return r && r.some((x) => /^The meeting before/.test(x)) && !r.some((x) => /^The meeting after/.test(x)); }));
|
|
88
89
|
await F.more(p, 'The meeting before');
|
|
89
90
|
ok('N5 paging (⋯ The meeting before) reads the meeting before into the same card', await until(() => A.S.gets.some((x) => /notes\/one\?id=n0/.test(x))) && await p.evaluate(() => document.querySelectorAll('#czViewer .vz-mtg').length === 1));
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* pm/artefact-kind.js — what kind of artefact a file is, and one row per kind (popup round 3 point 16: "Make the Kind specific such as
|
|
2
|
+
* prototype or PRD. And each type ideally should have 1 artefact only, with version shows if necessary. If there are multiple artefact for the
|
|
3
|
+
* same kind, then propose to merge"). Pure: no DOM, no reads. The popup's Artefacts table (pm/cozy-pop-work.js) and the Library share it.
|
|
4
|
+
*
|
|
5
|
+
* kindOf({ type, title, path, kind }) → 'PRD' | 'Prototype brief' | 'Design brief' | 'Eval rubric' | 'User stories' | 'Grilling critique' |
|
|
6
|
+
* 'Minutes' | 'Pre-read' | 'Update note' | 'API spec' | 'Guideline' | 'Anchor' | 'Report' | 'Brief' | 'Spec' | 'Done test' | 'Research' |
|
|
7
|
+
* 'Prototype' | 'Link' | 'Note' the frontmatter or Library type first, then the title, then the path; "Note" last, never "Document"
|
|
8
|
+
* versionOf(title) → 3 for "PRD v3", else 0
|
|
9
|
+
* group(rows, { at(row) → ms, current?(row) → bool, dropped: Set }) → { groups: [{ kind, cur, earlier, files, versions, series }], merge }
|
|
10
|
+
* one group per kind, in lifecycle order. cur: the record's own file when current() names one, else the newest. versions: the files
|
|
11
|
+
* are versions of one document (the same name but for a version mark or a date); files: different documents of one kind. merge:
|
|
12
|
+
* { id, say, kinds, ask } — one ✦ line that proposes to merge the kinds with several different files (never a series kind,
|
|
13
|
+
* Minutes, Update note, Report, nor a Note, Link or Research: separate things by nature), or null. dropped: the merge ids the PM said No to.
|
|
14
|
+
*/
|
|
15
|
+
const RULES = [
|
|
16
|
+
[/\bprd\b|product requirements/i, 'PRD'],
|
|
17
|
+
[/prototype brief|proto(type)?[ -]brief/i, 'Prototype brief'],
|
|
18
|
+
[/design brief/i, 'Design brief'],
|
|
19
|
+
[/\brubric\b|\beval(uation)?\b/i, 'Eval rubric'],
|
|
20
|
+
[/user stor/i, 'User stories'],
|
|
21
|
+
[/\bgrill|critique/i, 'Grilling critique'],
|
|
22
|
+
[/minutes|meeting notes|\bmom\b/i, 'Minutes'],
|
|
23
|
+
[/pre-?read/i, 'Pre-read'],
|
|
24
|
+
[/update note|weekly update|status update/i, 'Update note'],
|
|
25
|
+
[/api spec|openapi|swagger/i, 'API spec'],
|
|
26
|
+
[/guideline|style guide|playbook/i, 'Guideline'],
|
|
27
|
+
[/\banchor\b/i, 'Anchor'],
|
|
28
|
+
[/\breport\b/i, 'Report'],
|
|
29
|
+
[/done test/i, 'Done test'],
|
|
30
|
+
[/\bresearch\b|interview/i, 'Research'],
|
|
31
|
+
[/\bbrief\b/i, 'Brief'],
|
|
32
|
+
[/\bspec(ification)?\b/i, 'Spec'],
|
|
33
|
+
];
|
|
34
|
+
const TYPES = { prd: 'PRD', spec: 'Spec', 'done test': 'Done test', rubric: 'Eval rubric', 'eval rubric': 'Eval rubric', 'prototype brief': 'Prototype brief', 'design brief': 'Design brief',
|
|
35
|
+
research: 'Research', brief: 'Brief', report: 'Report', minutes: 'Minutes', 'meeting notes': 'Minutes', 'user stories': 'User stories', guideline: 'Guideline', guide: 'Guideline', 'api spec': 'API spec' };
|
|
36
|
+
export const SERIES = new Set(['Minutes', 'Update note', 'Report']);
|
|
37
|
+
const NOMERGE = new Set(['Minutes', 'Update note', 'Report', 'Note', 'Link', 'Research']); // separate things by nature: counted, never merged
|
|
38
|
+
export const ORDER = ['Anchor', 'Brief', 'Prototype brief', 'Prototype', 'Design brief', 'PRD', 'User stories', 'Eval rubric', 'Done test', 'Spec', 'API spec', 'Grilling critique', 'Guideline', 'Research', 'Pre-read', 'Minutes', 'Update note', 'Report', 'Link', 'Note'];
|
|
39
|
+
|
|
40
|
+
export function kindOf(x = {}) {
|
|
41
|
+
const t = String(x.type || '').trim().toLowerCase();
|
|
42
|
+
if (TYPES[t]) return TYPES[t];
|
|
43
|
+
if (x.kind === 'meeting') return 'Minutes';
|
|
44
|
+
if (x.kind === 'proto') return 'Prototype';
|
|
45
|
+
const words = String(x.title || '');
|
|
46
|
+
for (const [re, k] of RULES) if (re.test(words)) return k;
|
|
47
|
+
const p = String(x.path || '').split('/').pop().replace(/[-_.]+/g, ' ');
|
|
48
|
+
for (const [re, k] of RULES) if (re.test(p)) return k;
|
|
49
|
+
return x.kind === 'link' ? 'Link' : 'Note';
|
|
50
|
+
}
|
|
51
|
+
export function versionOf(title) { const m = /\bv(\d{1,3})\b/i.exec(String(title || '')); return m ? +m[1] : 0; }
|
|
52
|
+
/* the name without a version mark, a date or a "copy": two files with the same base are versions of one document */
|
|
53
|
+
const baseOf = (s) => String(s || '').toLowerCase().replace(/\bv\d{1,3}\b/g, '').replace(/\b\d{4}-\d{2}-\d{2}\b|\b\d{1,2} [a-z]{3}( \d{4})?\b/g, '').replace(/\b(copy|draft|final|old|new)\b/g, '').replace(/[^a-z0-9]+/g, ' ').trim();
|
|
54
|
+
const ACR = /^(PRD|API spec)$/;
|
|
55
|
+
const many = (k, n) => n + ' ' + (ACR.test(k) ? k + 's' : (k.toLowerCase().endsWith('s') ? k.toLowerCase() : k.toLowerCase() + 's')).replace(/^api specs$/, 'API specs');
|
|
56
|
+
const andList = (a) => (a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
|
|
57
|
+
|
|
58
|
+
export function group(rows, o = {}) {
|
|
59
|
+
const at = o.at || (() => 0), cur = o.current || (() => false), drop = o.dropped || new Set();
|
|
60
|
+
const by = new Map();
|
|
61
|
+
for (const r of rows || []) { const k = r.kindName || kindOf({ type: r.type, title: r.title, path: r.path, kind: r.akind || r.kind }); if (!by.has(k)) by.set(k, []); by.get(k).push(r); }
|
|
62
|
+
const rank = (k) => { const i = ORDER.indexOf(k); return i < 0 ? ORDER.length : i; };
|
|
63
|
+
const groups = [...by.entries()].sort((a, b) => rank(a[0]) - rank(b[0]) || a[0].localeCompare(b[0])).map(([kind, L]) => {
|
|
64
|
+
const real = L.filter((r) => !r.missing), miss = L.filter((r) => r.missing);
|
|
65
|
+
const sorted = real.slice().sort((a, b) => at(b) - at(a) || versionOf(b.title) - versionOf(a.title));
|
|
66
|
+
const named = sorted.find((r) => cur(r));
|
|
67
|
+
const c = named || sorted[0] || miss[0];
|
|
68
|
+
const rest = (sorted.length ? sorted : miss).filter((r) => r !== c);
|
|
69
|
+
const bases = new Set(sorted.map((r) => baseOf(r.title)));
|
|
70
|
+
const series = SERIES.has(kind);
|
|
71
|
+
const versions = sorted.length > 1 && bases.size === 1 && !series;
|
|
72
|
+
return { kind, cur: c, earlier: rest, n: sorted.length, versions, files: sorted.length > 1 && !versions ? sorted.length : 0, series, v: versionOf(c && c.title) };
|
|
73
|
+
});
|
|
74
|
+
const mergeable = groups.filter((g) => g.files > 1 && !NOMERGE.has(g.kind));
|
|
75
|
+
const id = 'merge:' + mergeable.map((g) => g.kind).join('+');
|
|
76
|
+
const merge = mergeable.length && !drop.has(id) ? { id, kinds: mergeable.map((g) => g.kind),
|
|
77
|
+
say: andList(mergeable.map((g) => many(g.kind, g.files))) + ' can each be one artefact. Merge them?',
|
|
78
|
+
ask: 'Merge the ' + andList(mergeable.map((g) => many(g.kind, g.files))) + ' of this initiative into one artefact per kind: the newest is the base, add the parts only the others have, name the sources at the end, and keep the old files as earlier versions. Delete nothing. Tell me what you merged.' } : null;
|
|
79
|
+
return { groups, merge };
|
|
80
|
+
}
|
|
81
|
+
/** The Version cell: "v3 · 2 earlier" when there is more than one; "v2" for one file that says its version; '' otherwise (zero is silence). */
|
|
82
|
+
export function versionText(g) {
|
|
83
|
+
if (g.series) return g.n > 1 ? g.n + (g.kind === 'Minutes' ? ' meetings' : ' in all') : '';
|
|
84
|
+
if (g.versions) return (g.v ? 'v' + g.v : 'v' + g.n) + ' · ' + g.earlier.length + ' earlier';
|
|
85
|
+
if (g.files) return g.files + ' files';
|
|
86
|
+
return g.v ? 'v' + g.v : '';
|
|
87
|
+
}
|