create-pmos 0.444.0 → 0.445.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 +13 -13
- 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/adler-moments-test.js +8 -0
- package/workspace/adler-seasons-art-test.js +3 -0
- package/workspace/board-columns-test.js +168 -0
- package/workspace/board-programs-test.js +1 -1
- package/workspace/briefing-premium-board-test.js +83 -6
- package/workspace/briefing-premium-insights-test.js +43 -0
- package/workspace/calm-timeline-test.js +3 -1
- package/workspace/changelog.json +12 -0
- package/workspace/guide/jira.md +13 -1
- package/workspace/guide/ready-made-dashboards.md +2 -2
- package/workspace/lib/board-fold.js +33 -5
- package/workspace/lib/console-state.js +5 -1
- package/workspace/lib/factory-join.js +46 -14
- package/workspace/lib/freshness.js +14 -1
- package/workspace/lib/initiative-rows.js +38 -4
- package/workspace/lib/issues.js +8 -1
- package/workspace/lib/jira-cli.js +18 -2
- package/workspace/lib/jira-moves.js +119 -0
- package/workspace/lib/jira-tickets.js +23 -4
- package/workspace/lib/notes.js +4 -2
- package/workspace/lib/offloop.js +75 -29
- package/workspace/lib/page-build.js +97 -0
- package/workspace/lib/plan-items.js +24 -3
- package/workspace/lib/plan-tree.js +62 -9
- package/workspace/lib/ready-reports.js +22 -8
- package/workspace/lib/refresh.js +14 -2
- package/workspace/lib/routes-board-premium.js +9 -1
- package/workspace/lib/routes-boards.js +74 -15
- package/workspace/lib/routes-brief-page.js +3 -1
- package/workspace/lib/routes-calendar-import.js +13 -1
- package/workspace/lib/routes-ready-reports.js +28 -5
- package/workspace/lib/task-links.js +12 -1
- package/workspace/lib/workflows-store.js +14 -3
- package/workspace/milestone-pins-test.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +150 -6
- package/workspace/program-panel-test.js +6 -6
- package/workspace/public/pm/bd-cols.js +149 -0
- package/workspace/public/pm/bd-pane.js +41 -0
- package/workspace/public/pm/bd-span.js +29 -11
- package/workspace/public/pm/cozy-board.css +45 -0
- package/workspace/public/pm/cozy-insights.css +8 -0
- package/workspace/public/pm/cozy-live-pill.css +1 -0
- package/workspace/public/pm/cozy-live-pill.js +10 -1
- package/workspace/public/pm/cozy-panels.css +24 -3
- package/workspace/public/pm/cozy-panels.js +275 -108
- package/workspace/public/pm/cozy-viewer.js +3 -1
- package/workspace/public/pm/dash-view.js +5 -2
- package/workspace/public/pm/home-app.js +8 -8
- package/workspace/public/pm/ini-edit.js +5 -1
- package/workspace/public/pm/ini-tasks.js +134 -29
- package/workspace/public/pm/ini-view-model.js +4 -3
- package/workspace/public/pm/ini-view.css +74 -25
- package/workspace/public/pm/ini-view.js +4 -4
- package/workspace/public/pm/ini-wf-model.js +9 -0
- package/workspace/public/pm/ini-wf.js +14 -9
- package/workspace/public/pm/ins-pane.js +55 -0
- package/workspace/public/pm/jira-move.js +50 -0
- package/workspace/public/pm/live-model.js +3 -2
- package/workspace/public/pm/pn-narrow.js +76 -0
- package/workspace/public/pm/premium-board.js +77 -26
- package/workspace/public/pm/premium-insights.js +7 -1
- package/workspace/public/premium-board.html +2 -0
- package/workspace/ready-dash-ui-test.js +4 -4
- package/workspace/server.js +71 -20
- package/workspace/skills/jira-move.skill +35 -0
- package/workspace/stage-card-tasks-test.js +1 -0
- package/workspace/task-links-test.js +1 -0
- package/workspace/task-plans-test.js +1 -1
- package/workspace/task-views-test.js +161 -12
- package/workspace/test-lists/board-columns.json +5 -0
- package/workspace/test-lists/jira-moves.json +11 -0
- package/workspace/test-lists/page-speed-fold.json +5 -0
- package/workspace/test-lists/page-speed-reads.json +5 -0
- package/workspace/timeline-holds-test.js +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* (c3-initiative-boards; planning/prd/c3-initiative-boards-prd.md "Model", "State", "API contract").
|
|
4
4
|
*
|
|
5
5
|
* GET /api/boards → { ok, boards: [portfolio row] } every workspace; `ws` is ignored
|
|
6
|
+
* GET /api/boards?names=1 → the same rows without health, counts and next release (no row is derived)
|
|
6
7
|
* GET /api/boards/board?ws&board → { ok, board, counts: { total, byStage, byStatus }, asks, nextRelease, recent }
|
|
7
8
|
* GET /api/boards/backlog?ws&board&q&stage&status&owner&horizon&anchor&view&sort&offset&limit
|
|
8
9
|
* → { ok, total, offset, limit, rows, facets: { stage, status, owner, horizon } }
|
|
@@ -109,10 +110,21 @@ function ledgerFile(ctx, w) {
|
|
|
109
110
|
const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
110
111
|
return d ? path.join(d, LEDGER) : null;
|
|
111
112
|
}
|
|
113
|
+
// The ledger's lines, read again only when its stat changes (a write shows on the next read). The lines are strings; every
|
|
114
|
+
// caller folds them into objects of its own, so nothing a caller changes reaches the memo.
|
|
115
|
+
const ledgerMemo = new Map(); // file -> { key, lines }
|
|
112
116
|
function readLedger(ctx, w) {
|
|
113
117
|
const f = ledgerFile(ctx, w);
|
|
114
118
|
if (!f) return [];
|
|
115
|
-
|
|
119
|
+
let key = null;
|
|
120
|
+
try { const st = fs.statSync(f); key = `${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`; } catch { return []; }
|
|
121
|
+
const hit = ledgerMemo.get(f);
|
|
122
|
+
if (hit && hit.key === key) return hit.lines.slice();
|
|
123
|
+
let lines;
|
|
124
|
+
try { lines = fs.readFileSync(f, 'utf8').split('\n').filter(Boolean); } catch { return []; }
|
|
125
|
+
if (ledgerMemo.size > 100) ledgerMemo.clear();
|
|
126
|
+
ledgerMemo.set(f, { key, lines });
|
|
127
|
+
return lines.slice();
|
|
116
128
|
}
|
|
117
129
|
function append(file, actor, ev) {
|
|
118
130
|
const line = { at: new Date().toISOString(), by: actor.by, ...ev };
|
|
@@ -236,7 +248,18 @@ function statusOf(rec, healthLevel, end, day) {
|
|
|
236
248
|
}
|
|
237
249
|
|
|
238
250
|
/** The board-independent part of every work row of a repository, cached by the read signature. */
|
|
239
|
-
|
|
251
|
+
/* A READ PASS (ctx.boardsPass, a Map): a page that asks several of these routes for one answer (GET /api/board-premium asks ten)
|
|
252
|
+
* hands them one pass, and each workspace's frame and base rows are then derived once for all of them, not once per route. A
|
|
253
|
+
* pass lives for that one request; without one every call derives again, as before. */
|
|
254
|
+
const inPass = (ctx, key, make) => {
|
|
255
|
+
const m = ctx && ctx.boardsPass;
|
|
256
|
+
if (!(m instanceof Map)) return make();
|
|
257
|
+
if (m.has(key)) return m.get(key);
|
|
258
|
+
const v = make(); m.set(key, v); return v;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
function baseRows(w, ctx) { return inPass(ctx, 'base\u0000' + w.root, () => baseRowsRead(w)); }
|
|
262
|
+
function baseRowsRead(w) {
|
|
240
263
|
const got = rowsLib.rowsFor(w.root);
|
|
241
264
|
if (got.pending) return { pending: true };
|
|
242
265
|
if (!got.ok) return { ok: false, error: got.error || 'the initiatives could not be read' };
|
|
@@ -359,9 +382,22 @@ function taskSpanOf(folded, id) {
|
|
|
359
382
|
}
|
|
360
383
|
/** Each dated task of an initiative as { start, due, stage } (Won't do and Archived left out). stage: the PM's placement (a task-section line),
|
|
361
384
|
* else the stage whose To finish entry made it, else null. */
|
|
385
|
+
// each fold's tasks by initiative, made once per fold (a fold is never changed after it is made: a write folds again), so a row
|
|
386
|
+
// does not walk every task of the board
|
|
387
|
+
const tasksByIni = new WeakMap();
|
|
388
|
+
function tasksOfIni(folded, id) {
|
|
389
|
+
if (!folded || !folded.tasks) return [];
|
|
390
|
+
let by = tasksByIni.get(folded);
|
|
391
|
+
if (!by) {
|
|
392
|
+
by = new Map();
|
|
393
|
+
for (const t of folded.tasks.values()) { if (!t) continue; if (!by.has(t.initiative)) by.set(t.initiative, []); by.get(t.initiative).push(t); }
|
|
394
|
+
tasksByIni.set(folded, by);
|
|
395
|
+
}
|
|
396
|
+
return by.get(id) || [];
|
|
397
|
+
}
|
|
362
398
|
function taskSpansOf(folded, id) {
|
|
363
399
|
const out = [], SEC = (folded && folded.sections) || new Map();
|
|
364
|
-
for (const t of (folded
|
|
400
|
+
for (const t of tasksOfIni(folded, id)) {
|
|
365
401
|
if (!t || t.initiative !== id || t.state === "Won't do" || t.state === 'Archived') continue;
|
|
366
402
|
const a = t.start || t.due, z = t.due || t.start;
|
|
367
403
|
const stage = SEC.has(t.id) ? SEC.get(t.id) || null : (t.from && t.from.stage) || null;
|
|
@@ -403,16 +439,32 @@ function boardRow(board, base, folded, lib) {
|
|
|
403
439
|
}
|
|
404
440
|
|
|
405
441
|
/** Everything a read of one workspace needs. */
|
|
406
|
-
function frameFor(ctx, w) {
|
|
442
|
+
function frameFor(ctx, w) { return inPass(ctx, 'frame\u0000' + w.root, () => frameRead(ctx, w)); }
|
|
443
|
+
function frameRead(ctx, w) {
|
|
407
444
|
const folded = B.fold(readLedger(ctx, w));
|
|
408
445
|
const boards = boardsOf(ctx, w, folded);
|
|
409
446
|
const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
410
447
|
folded.wfLib = WS.library(d); // D99: the workflow library rides on the fold, so every boardRow call reads one copy
|
|
411
448
|
return { w, folded, boards };
|
|
412
449
|
}
|
|
413
|
-
/** A fresh fold with the workflow library on it (frameFor's, without the boards). */
|
|
414
|
-
function foldOf(ctx, w) { const f = B.fold(readLedger(ctx, w)); const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null; f.wfLib = WS.library(d); return f; }
|
|
450
|
+
/** A fresh fold with the workflow library on it (frameFor's, without the boards). Inside a read pass, the pass's own fold. */
|
|
451
|
+
function foldOf(ctx, w) { if (ctx && ctx.boardsPass instanceof Map) return frameFor(ctx, w).folded; const f = B.fold(readLedger(ctx, w)); const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null; f.wfLib = WS.library(d); return f; }
|
|
415
452
|
const libOf = (folded) => (folded && folded.wfLib) || WS.library(null);
|
|
453
|
+
/** A workflow by id for workspace w: its own library first, then the home workspace's, then any other open workspace's (not archived there).
|
|
454
|
+
* → { wf, ws: null } | { wf, ws: <the workspace it came from> } | null */
|
|
455
|
+
function workflowFor(ctx, w, lib, id) {
|
|
456
|
+
const own = lib.byId.get(id);
|
|
457
|
+
if (own) return { wf: own, ws: null };
|
|
458
|
+
const home = ctx.getWs ? ctx.getWs(null) : null;
|
|
459
|
+
const others = [home, ...(ctx.workspaceList ? ctx.workspaceList() : [])].filter((x, i, a) => x && x !== w && x.id !== w.id && a.indexOf(x) === i);
|
|
460
|
+
for (const x of others) {
|
|
461
|
+
let d = null; try { d = ctx.stateDirFor ? ctx.stateDirFor(x) : null; } catch { d = null; }
|
|
462
|
+
if (!d) continue;
|
|
463
|
+
const wf = WS.library(d).byId.get(id);
|
|
464
|
+
if (wf && !wf.archived) return { wf, ws: x };
|
|
465
|
+
}
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
416
468
|
function rowsOfBoard(fr, board, base) {
|
|
417
469
|
const rows = base.filter((r) => boardIdOf(r, fr.boards, fr.folded, fr.w) === board.id).map((r) => boardRow(board, r, fr.folded));
|
|
418
470
|
// c3-initiative-lifecycle: what was merged into each row, and the likely duplicates among the active rows of this board.
|
|
@@ -438,7 +490,7 @@ function stageTasks(file, folded, board, row, by) {
|
|
|
438
490
|
if (!list.length) return 0;
|
|
439
491
|
const have = new Set();
|
|
440
492
|
// a To finish task the PM deleted stays deleted: the next read must not make it again (batch 17 item 2: "Deleting task, but keep appearing")
|
|
441
|
-
for (const t of [...folded.
|
|
493
|
+
for (const t of [...tasksOfIni(folded, row.id), ...(folded.removed ? folded.removed.values() : [])]) if (t.initiative === row.id && t.from && t.from.stage === st.key) have.add(t.from.finish);
|
|
442
494
|
let n = 0;
|
|
443
495
|
for (const f of list) {
|
|
444
496
|
if (have.has(f)) continue;
|
|
@@ -597,18 +649,21 @@ function wsOf(ctx, wsParam) {
|
|
|
597
649
|
}
|
|
598
650
|
const fail = (ctx, res, status, error, extra = {}) => { ctx.json(res, { ok: false, error, ...extra }, status); return true; };
|
|
599
651
|
|
|
600
|
-
|
|
652
|
+
/** Every board of every workspace. With `names` (GET /api/boards?names=1), only who each board is (ws, id, name and the board's
|
|
653
|
+
* own settings, no rows): a page that only needs the board list does not derive the rows of every workspace. */
|
|
654
|
+
function portfolio(ctx, { names = false } = {}) {
|
|
601
655
|
const list = ctx.workspaceList ? ctx.workspaceList() : [];
|
|
602
656
|
const releases = readReleases(ctx);
|
|
603
657
|
const out = [];
|
|
604
658
|
for (const w of list) {
|
|
605
659
|
let fr;
|
|
606
660
|
try { fr = frameFor(ctx, w); } catch (e) { out.push({ ws: w.id, id: w.id, name: w.name, error: String((e && e.message) || e).slice(0, 160) }); continue; }
|
|
661
|
+
if (names) { for (const board of fr.boards) out.push({ ...board, health: null, counts: null, asks: openAsks(fr.folded, board.id), nextRelease: null }); continue; }
|
|
607
662
|
let base = null;
|
|
608
663
|
let pending = false;
|
|
609
664
|
let error = null;
|
|
610
665
|
try {
|
|
611
|
-
const b = baseRows(w);
|
|
666
|
+
const b = baseRows(w, ctx);
|
|
612
667
|
if (b.pending) pending = true; else if (!b.ok) error = b.error; else base = b.rows;
|
|
613
668
|
} catch (e) { error = String((e && e.message) || e).slice(0, 160); }
|
|
614
669
|
for (const board of fr.boards) {
|
|
@@ -637,7 +692,7 @@ function boardRead(ctx, res, url, { rows = true } = {}) {
|
|
|
637
692
|
const board = fr.boards.find((b) => b.id === bid);
|
|
638
693
|
if (!board) { fail(ctx, res, 404, `no board ${bid} in this workspace`); return null; }
|
|
639
694
|
if (!rows) return { w, fr, board, rows: null };
|
|
640
|
-
const b = baseRows(w);
|
|
695
|
+
const b = baseRows(w, ctx);
|
|
641
696
|
if (b.pending) { ctx.json(res, { ok: true, pending: true, ws: w.id, board: board.id }, 202); return null; }
|
|
642
697
|
if (!b.ok) { fail(ctx, res, 500, b.error); return null; }
|
|
643
698
|
return { w, fr, board, base: b.rows, rows: rowsOfBoard(fr, board, b.rows) };
|
|
@@ -1044,18 +1099,22 @@ const WRITES = {
|
|
|
1044
1099
|
if (body.why != null && body.why !== '' && !ONE_LINE(body.why, 500)) return fail(ctx, res, 400, 'why is one line of at most 500 characters');
|
|
1045
1100
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1046
1101
|
const lib = libOf(p.fr.folded);
|
|
1047
|
-
const
|
|
1048
|
-
if (!
|
|
1102
|
+
const found = workflowFor(ctx, p.w, lib, body.wf);
|
|
1103
|
+
if (!found) return fail(ctx, res, 404, 'That workflow could not be found. It may have been removed in Settings, Workflows.');
|
|
1104
|
+
const to = found.wf;
|
|
1049
1105
|
if (to.archived) return fail(ctx, res, 409, `${to.name} is archived. Bring it back first.`);
|
|
1050
1106
|
const base = needRows(ctx, res, p.w);
|
|
1051
1107
|
if (!base) return;
|
|
1052
1108
|
const b0 = base.find((r) => r.id === body.id);
|
|
1053
|
-
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404,
|
|
1109
|
+
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404, 'That initiative is not on this board any more.');
|
|
1054
1110
|
const before = boardRow(p.board, b0, p.fr.folded);
|
|
1055
1111
|
const from = WF.resolve(lib, before.wf.id);
|
|
1056
1112
|
let target = WF.switchTarget(from, to, before.wfStage.key);
|
|
1057
|
-
if (body.to != null) { const t = WF.stageByRef(to, body.to); if (!t) return fail(ctx, res, 400, `
|
|
1113
|
+
if (body.to != null) { const t = WF.stageByRef(to, body.to); if (!t) return fail(ctx, res, 400, `That stage is not part of ${to.name}.`); target = t.key; }
|
|
1058
1114
|
const moved = { from: before.wfStage.key, to: target };
|
|
1115
|
+
// A workflow the PM saved in another workspace's library (Settings opens on the home workspace) is written into this one's first, so
|
|
1116
|
+
// this workspace's own record still reads the initiative's workflow when the other workspace is not open.
|
|
1117
|
+
if (found.ws) { const a = WS.adopt(ctx.stateDirFor(p.w), to, g.actor, found.ws.id); if (!a.ok) return fail(ctx, res, a.status || 400, a.error); }
|
|
1059
1118
|
append(p.file, g.actor, { kind: 'ini-wf', board: p.board.id, id: body.id, wf: to.id, from: from.id, moved, why: body.why ? body.why.trim() : '', ...(body.pmos === true ? { pmos: true } : {}) });
|
|
1060
1119
|
const f1 = foldOf(ctx, p.w), row = boardRow(p.board, b0, f1);
|
|
1061
1120
|
const made = stageTasks(p.file, f1, p.board, row, g.actor.by);
|
|
@@ -1539,7 +1598,7 @@ const WRITES = {
|
|
|
1539
1598
|
async function handle(req, res, url, ctx) {
|
|
1540
1599
|
const p = url.pathname;
|
|
1541
1600
|
if (req.method === 'GET') {
|
|
1542
|
-
if (p === '/api/boards') { ctx.json(res, portfolio(ctx)); return true; }
|
|
1601
|
+
if (p === '/api/boards') { ctx.json(res, portfolio(ctx, { names: url.searchParams.get('names') === '1' })); return true; }
|
|
1543
1602
|
const fn = READS[p];
|
|
1544
1603
|
if (!fn) return fail(ctx, res, 404, 'not found');
|
|
1545
1604
|
fn(ctx, res, url);
|
|
@@ -213,7 +213,9 @@ function build(query, deps = {}) {
|
|
|
213
213
|
|
|
214
214
|
function notesAdapter(runtimeDir) {
|
|
215
215
|
let notes; try { notes = require('./notes.js'); } catch { return {}; }
|
|
216
|
-
|
|
216
|
+
// one list per adapter: lastBefore asks once per meeting of the day, and the list is the same for all of them (page-speed)
|
|
217
|
+
let listed = null;
|
|
218
|
+
const rows = () => { if (listed) return listed; try { const l = notes.list(runtimeDir); listed = l && l.ok ? l.notes.filter((n) => !n.private) : []; } catch { listed = []; } return listed; };
|
|
217
219
|
let links = null;
|
|
218
220
|
return {
|
|
219
221
|
linkOf: (e) => {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* (scripts/calendar-import.js through scripts/trust/import-guard.js). Writes pass pm-guard requirePagePress, so an agent
|
|
11
11
|
* token is refused (403). readEvents(runtimeDir) is for routes-calendar-views.js.
|
|
12
12
|
* File: <runtime>/calendar-import/events.jsonl (append only, scripts/trust/ledger.js). */
|
|
13
|
+
const fs = require('fs');
|
|
13
14
|
const path = require('path');
|
|
14
15
|
const guard = require('./pm-guard.js');
|
|
15
16
|
const { repoScript } = require('./repo-script.js');
|
|
@@ -19,7 +20,18 @@ const L = require(repoScript('trust/ledger.js'));
|
|
|
19
20
|
const fileOf = (runtimeDir) => path.join(runtimeDir, 'calendar-import', 'events.jsonl');
|
|
20
21
|
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
// The fold is kept until the ledger's size or time changes (page-speed): Home, Your day and the calendar read it on every load. The
|
|
24
|
+
// events are shared, so a caller must copy before it changes one (calendar-events.js readAll does).
|
|
25
|
+
const folds = new Map(); // file -> { sig, events }
|
|
26
|
+
function readEvents(runtimeDir) {
|
|
27
|
+
const f = fileOf(runtimeDir);
|
|
28
|
+
let sig = 'none'; try { const st = fs.statSync(f); sig = st.size + ':' + st.mtimeMs + ':' + st.ino; } catch { /* no ledger yet */ }
|
|
29
|
+
const hit = folds.get(f);
|
|
30
|
+
if (hit && hit.sig === sig) return hit.events;
|
|
31
|
+
const events = CI.foldEvents(CI.readLines(f));
|
|
32
|
+
folds.set(f, { sig, events });
|
|
33
|
+
return events;
|
|
34
|
+
}
|
|
23
35
|
|
|
24
36
|
function list(runtimeDir) { return { status: 200, body: { ok: true, events: readEvents(runtimeDir) } }; }
|
|
25
37
|
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
* tick(ctx, now) drafts each weekly that is due (skipped in a week where nothing moved), each checkpoint and Did it work? at its
|
|
17
17
|
* moment, and a heads-up for a broken health budget or a critical slip. server.js runs it after the setups tick.
|
|
18
18
|
*
|
|
19
|
-
* SEND IS ISSUE. PMOS sends nothing outward: Send on a report row is the
|
|
20
|
-
* so every row with a document carries cadence, slot, sha and path.
|
|
21
|
-
*
|
|
19
|
+
* SEND IS ISSUE. PMOS sends nothing outward: Send on a report row is the Issue press, POST /api/report/issue { ws, cadence, slot, sha },
|
|
20
|
+
* so every row with a document carries cadence, slot, sha and path. A calm week's weekly (RR.autoOk: no miss, no decision, nothing off plan) goes by
|
|
21
|
+
* itself (Wawan 2026-10-28, "Calm weeks send themselves"): the tick issues it 10 minutes after its time as the schedule (agent:unknown, D98), unless
|
|
22
|
+
* the PM held it or turned "Send by itself" off for that report, and writes an `auto-sent` line so its row says "Sent … by itself". A busy week still
|
|
23
|
+
* waits for the PM's press.
|
|
22
24
|
* Every POST passes pm-guard requirePagePress. With no state folder the reads answer and the writes answer 409. */
|
|
23
25
|
const fs = require('fs');
|
|
24
26
|
const path = require('path');
|
|
@@ -180,7 +182,10 @@ function reportRows(w, X) {
|
|
|
180
182
|
let sha = null; try { sha = issues.blobSha(fs.readFileSync(path.join(abs, x.path))); } catch { sha = null; }
|
|
181
183
|
const d = setup ? setup.drafted.find((y) => y.slot === x.slot) : null;
|
|
182
184
|
let md = ''; try { md = fs.readFileSync(path.join(abs, x.path), 'utf8'); } catch { md = ''; }
|
|
183
|
-
|
|
185
|
+
const key = RR.keyOf(setup.ready.scope, setup.ready.kind);
|
|
186
|
+
// auto: a calm weekly that goes by itself, or, once issued, one the schedule sent by itself (batch 17 item 6)
|
|
187
|
+
const auto = x.issued ? X.st.autoSent.has(key + '|' + x.slot) : setup.ready.kind === 'weekly' && RR.autoOn(X.st, key) && RR.autoOk(md);
|
|
188
|
+
return { slot: x.slot, path: x.path, issued: x.issued, sha, draftSha: d ? d.sha || null : null, auto };
|
|
184
189
|
});
|
|
185
190
|
docsBy.set(id, list);
|
|
186
191
|
return list;
|
|
@@ -410,6 +415,8 @@ async function tickScope(ctx, w, s, now, cache = null) {
|
|
|
410
415
|
if (!moved) { RR.append(RR.ledgerFile(stateDir(w)), { ev: 'quiet', key: RR.keyOf(s.scope, 'weekly'), slot }, { now }); out.push({ scope: s.scope, kind: 'weekly', slot, ok: true, why: 'quiet' }); }
|
|
411
416
|
else { const r = await SR.draftIntelligence(ctx, w, wk, slot, { model: X.model, now, ready: extras(X) }); out.push({ scope: s.scope, kind: 'weekly', slot, ...r }); }
|
|
412
417
|
}
|
|
418
|
+
// a calm weekly goes by itself 10 minutes after its time (batch 17 item 6)
|
|
419
|
+
if (wk && wk.status === 'active' && wk.drafted.length) out.push(...autoSend(w, wk, st, s.scope, X, now));
|
|
413
420
|
const items = X.row ? (X.f.checklist || []) : [];
|
|
414
421
|
for (const m of RR.momentsOf(P.level, { today, row: X.row, rows: X.rows, program: X.program, checklist: items, quarterEnd: RR.quarterEndOf(today) })) {
|
|
415
422
|
const key = RR.keyOf(s.scope, m.kind);
|
|
@@ -436,6 +443,22 @@ async function tickScope(ctx, w, s, now, cache = null) {
|
|
|
436
443
|
}
|
|
437
444
|
return out;
|
|
438
445
|
}
|
|
446
|
+
/** Issue the newest drafted weekly when it is calm and its time + 10 minutes has passed. → [{ scope, kind, slot, ok, why: 'auto-sent' | error }] */
|
|
447
|
+
function autoSend(w, wk, st, scope, X, now) {
|
|
448
|
+
const last = wk.drafted[wk.drafted.length - 1];
|
|
449
|
+
if (!last || !last.path) return [];
|
|
450
|
+
const key = RR.keyOf(scope, 'weekly');
|
|
451
|
+
const done = issues.readIssues(w.root);
|
|
452
|
+
const issued = issues.isIssued(done, wk.id, last.slot);
|
|
453
|
+
let md = '', sha = null;
|
|
454
|
+
try { const buf = fs.readFileSync(path.join(path.resolve(w.root), last.path)); md = buf.toString('utf8'); sha = issues.blobSha(buf); } catch { return []; }
|
|
455
|
+
const auto = RR.autoOn(st, key) && RR.autoOk(md);
|
|
456
|
+
if (!RR.autoDue({ slot: last.slot, issued, auto }, { time: (RS.scheduleOf(wk) || {}).time, now: now.getTime(), hold: st.holds.get(key + '|' + last.slot), stale: X.f && X.f.stale })) return [];
|
|
457
|
+
const r = issues.appendFromSchedule(w.root, [{ ev: 'issued', cadence: wk.id, slot: last.slot, path: last.path, sha }], { now: now.getTime() });
|
|
458
|
+
if (!r.ok) return [{ scope, kind: 'weekly', slot: last.slot, ok: false, error: r.error }];
|
|
459
|
+
RR.append(RR.ledgerFile(stateDir(w)), { ev: 'auto-sent', key, slot: last.slot }, { now });
|
|
460
|
+
return [{ scope, kind: 'weekly', slot: last.slot, ok: true, why: 'auto-sent' }];
|
|
461
|
+
}
|
|
439
462
|
/** The sections a ready report adds: milestones (a program), the tickets closed this week, the products not read, the held source's note. */
|
|
440
463
|
function readyExtras(X) {
|
|
441
464
|
const S = RR.stageOf(X.P.level, { today: X.f.today, row: X.row, rows: X.rows, jira: X.row ? X.f.jiraOf[X.row.id] : null, jiraOf: X.f.jiraOf, program: X.program, intel: X.model, kept: X.f.kept, multi: X.f.products.length > 1 });
|
|
@@ -452,4 +475,4 @@ function headsUpMd(setup, h, today) {
|
|
|
452
475
|
`Source: ${h.why === 'budget' ? 'the health budget readings' : 'the Jira tickets and the promise date'}, read ${today}.`, ''].join('\n');
|
|
453
476
|
}
|
|
454
477
|
|
|
455
|
-
module.exports = { prefixes: ['/api/ready-reports'], handle, tick, factsFor, readyExtras, ensureSetup };
|
|
478
|
+
module.exports = { prefixes: ['/api/ready-reports'], handle, tick, factsFor, readyExtras, ensureSetup, autoSend };
|
|
@@ -255,8 +255,19 @@ function namedIn(text, tasks) {
|
|
|
255
255
|
}
|
|
256
256
|
return best;
|
|
257
257
|
}
|
|
258
|
-
/** The PRD's sentences that say an order: "B once A", "B after A", "after A, B", "B with A". → [{ from, to, type, text }]
|
|
258
|
+
/** The PRD's sentences that say an order: "B once A", "B after A", "after A, B", "B with A". → [{ from, to, type, text }]
|
|
259
|
+
* PURE, so the answer for the same text and the same task titles is kept: the Board asks for every initiative on every read. */
|
|
260
|
+
const prdMemo = new Map();
|
|
259
261
|
function prdOrders(text, tasks) {
|
|
262
|
+
const key = String(text || '') + '\u0000' + JSON.stringify((tasks || []).map((t) => [t.uid, t.title]));
|
|
263
|
+
const hit = prdMemo.get(key);
|
|
264
|
+
if (hit) return hit.map((x) => ({ ...x }));
|
|
265
|
+
const out = prdOrdersRead(text, tasks);
|
|
266
|
+
if (prdMemo.size > 500) prdMemo.clear();
|
|
267
|
+
prdMemo.set(key, out.map((x) => ({ ...x })));
|
|
268
|
+
return out;
|
|
269
|
+
}
|
|
270
|
+
function prdOrdersRead(text, tasks) {
|
|
260
271
|
const out = [];
|
|
261
272
|
const body = String(text || '').replace(/^---\n[\s\S]*?\n---\n?/, '').replace(/[`*_>#|]/g, ' ');
|
|
262
273
|
for (const raw of body.split(/(?<=[.!?;])\s+|\n+/)) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* library(stateDir) → the folded library (scripts/workflows.js fold)
|
|
5
5
|
* save(stateDir, { wf, moveRemoved }, actor, { standing }) → { ok, workflow, moved } | { ok:false, status, error, inUse? }
|
|
6
6
|
* copy(stateDir, id, name, actor) → { ok, workflow }
|
|
7
|
+
* adopt(stateDir, wf, actor, fromWs) → { ok, workflow } another workspace's workflow written into this library
|
|
7
8
|
* archive(stateDir, id, archived, actor, { inUse }) → { ok }
|
|
8
9
|
* saveDraft(stateDir, { draft, note }, actor) → { ok, draft } (the chat's draft; null clears it)
|
|
9
10
|
* readDraft(stateDir) → { draft, note, at } | null
|
|
@@ -63,7 +64,7 @@ function copy(stateDir, id, name, actor) {
|
|
|
63
64
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
64
65
|
const lib = library(stateDir);
|
|
65
66
|
const src = lib.byId.get(id);
|
|
66
|
-
if (!src) return { ok: false, status: 404, error:
|
|
67
|
+
if (!src) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
|
|
67
68
|
const wf = W.copyOf(src, name, new Set(lib.byId.keys()));
|
|
68
69
|
const c = W.check(wf);
|
|
69
70
|
if (!c.ok) return c;
|
|
@@ -71,11 +72,21 @@ function copy(stateDir, id, name, actor) {
|
|
|
71
72
|
return { ok: true, workflow: c.workflow };
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
/** An initiative here switches to a workflow saved in another workspace's library: the same definition (same id) is saved here. */
|
|
76
|
+
function adopt(stateDir, wf, actor, fromWs) {
|
|
77
|
+
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
78
|
+
if (!wf || wf.id === W.PRODUCT_FEATURE_ID) return { ok: true, workflow: wf };
|
|
79
|
+
const c = W.check({ id: wf.id, name: wf.name, icon: wf.icon, decide: wf.decide, stages: wf.stages });
|
|
80
|
+
if (!c.ok) return c;
|
|
81
|
+
append(fileOf(stateDir), actor, { kind: 'wf-save', wf: c.workflow, ...(fromWs ? { adoptedFrom: fromWs } : {}) });
|
|
82
|
+
return { ok: true, workflow: c.workflow };
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
function archive(stateDir, id, archived, actor, { inUse = [] } = {}) {
|
|
75
86
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
76
87
|
if (id === W.PRODUCT_FEATURE_ID) return { ok: false, status: 409, error: 'Product feature is built in and stays.' };
|
|
77
88
|
const lib = library(stateDir);
|
|
78
|
-
if (!lib.byId.has(id)) return { ok: false, status: 404, error:
|
|
89
|
+
if (!lib.byId.has(id)) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
|
|
79
90
|
if (archived && inUse.length) return { ok: false, status: 409, error: `${inUse.length} ${inUse.length === 1 ? 'initiative runs' : 'initiatives run'} this workflow. Move ${inUse.length === 1 ? 'it' : 'them'} to another workflow first.`, inUse };
|
|
80
91
|
append(fileOf(stateDir), actor, { kind: 'wf-archive', id, archived: !!archived });
|
|
81
92
|
return { ok: true };
|
|
@@ -105,4 +116,4 @@ function judge(stateDir, { board, id, stage, runs, why, cite, undo } = {}, actor
|
|
|
105
116
|
return { ok: true };
|
|
106
117
|
}
|
|
107
118
|
|
|
108
|
-
module.exports = { FILE, library, save, copy, archive, saveDraft, readDraft, judge, fileOf };
|
|
119
|
+
module.exports = { FILE, library, save, copy, adopt, archive, saveDraft, readDraft, judge, fileOf };
|
|
@@ -75,7 +75,7 @@ const ITEMS = [
|
|
|
75
75
|
PIN.set(b.task, b.pinned);
|
|
76
76
|
return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, from: { pinned: null }, item: null }) });
|
|
77
77
|
});
|
|
78
|
-
await page.addInitScript(([s]) => { try { if (!sessionStorage.getItem('set')) { sessionStorage.setItem('set', '1'); for (const [k, v] of Object.entries(s)) localStorage.setItem(k, v); } } catch { /* none */ } }, [{ 'pmos.board.view': o.view || 'time', 'pmos.board.pview': o.view || 'time', 'pmos.board.span': 'year' }]);
|
|
78
|
+
await page.addInitScript(([s]) => { try { if (!sessionStorage.getItem('set')) { sessionStorage.setItem('set', '1'); for (const [k, v] of Object.entries(s)) localStorage.setItem(k, v); } } catch { /* none */ } }, [{ 'pmos.board.tlcols': '[]', 'pmos.board.view': o.view || 'time', 'pmos.board.pview': o.view || 'time', 'pmos.board.span': 'year' }]);
|
|
79
79
|
await page.goto(BASE + '/premium-board.html?ws=w1&board=w1');
|
|
80
80
|
await page.waitForSelector('#ibBody [data-row]', { timeout: 15000 });
|
|
81
81
|
await page.waitForTimeout(400);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.445.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.445.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED