create-pmos 0.414.0 → 0.416.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 +25 -25
- 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/bin/pmos.js +1 -1
- package/workspace/briefing-premium-adddoc-test.js +3 -3
- package/workspace/briefing-premium-board-test.js +72 -43
- package/workspace/briefing-premium-doc-edit-test.js +2 -2
- package/workspace/briefing-premium-initiative-test.js +19 -22
- package/workspace/briefing-premium-insights-test.js +28 -17
- package/workspace/changelog.json +24 -0
- package/workspace/core-docs-workflow-test.js +1 -1
- package/workspace/guide/workflows.md +6 -2
- package/workspace/ini-workflow-test.js +11 -11
- package/workspace/lib/board-premium.js +13 -0
- package/workspace/lib/board-trail.js +6 -1
- package/workspace/lib/engine/boards.js +12 -4
- package/workspace/lib/goal-chat.js +46 -15
- package/workspace/lib/initiative-chat.js +7 -5
- package/workspace/lib/initiative-premium.js +4 -2
- package/workspace/lib/insights-premium.js +9 -1
- package/workspace/lib/item-cli.js +2 -1
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +149 -18
- package/workspace/lib/routes-briefing-premium.js +14 -1
- package/workspace/lib/routes-live.js +53 -0
- package/workspace/lib/task-cli.js +137 -25
- package/workspace/lib/task-items.js +88 -0
- package/workspace/lib/workflow-cli.js +1 -1
- package/workspace/milestone-suggest-test.js +2 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +3 -3
- package/workspace/premium-chat-report-tab-test.js +13 -5
- package/workspace/premium-core-doc-issue-test.js +1 -1
- package/workspace/premium-report-read-test.js +66 -51
- package/workspace/premium-vw-backlog-test.js +3 -3
- package/workspace/premium-vw-doc-test.js +3 -3
- package/workspace/premium-vw-item-test.js +4 -4
- package/workspace/premium-vw-jira-test.js +14 -13
- package/workspace/premium-vw-slides-test.js +7 -5
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-ini-panel.js +68 -210
- package/workspace/public/pm/cozy-insights.css +15 -0
- package/workspace/public/pm/cozy-live-pill.css +48 -0
- package/workspace/public/pm/cozy-live-pill.js +141 -0
- package/workspace/public/pm/cozy-viewer.js +4 -3
- package/workspace/public/pm/cozy-vw-rp.css +48 -0
- package/workspace/public/pm/home-app.js +45 -8
- package/workspace/public/pm/home-chat.js +5 -2
- package/workspace/public/pm/home-ini.js +57 -22
- package/workspace/public/pm/home-stage-card.js +3 -2
- package/workspace/public/pm/home-task.js +16 -5
- package/workspace/public/pm/ini-view-model.js +277 -0
- package/workspace/public/pm/ini-view.css +122 -0
- package/workspace/public/pm/ini-view.js +180 -0
- package/workspace/public/pm/live-model.js +104 -0
- package/workspace/public/pm/ov-view.css +44 -0
- package/workspace/public/pm/premium-board.js +23 -15
- package/workspace/public/pm/premium-initiative-head.js +12 -2
- package/workspace/public/pm/premium-insights.js +61 -35
- package/workspace/public/pm/premium-report-read.js +74 -50
- package/workspace/public/pm/premium-report-tab.js +36 -15
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-item-model.js +6 -3
- package/workspace/public/pm/premium-vw-item.js +25 -6
- package/workspace/public/pm/premium-vw-jira.js +17 -15
- package/workspace/public/pm/rp-parts.js +75 -12
- package/workspace/public/pm/task-card.css +24 -49
- package/workspace/public/pm/task-card.js +90 -64
- package/workspace/public/pm/tk-view.css +21 -0
- package/workspace/public/pm/tk-view.js +216 -0
- package/workspace/public/pm/wf-page.js +2 -0
- package/workspace/server.js +24 -1
- package/workspace/stage-card-test.js +49 -41
- package/workspace/task-card-test.js +83 -38
- package/workspace/test-files.json +3 -1
- package/workspace/test-lists/bd-ini-panel.json +3 -3
- package/workspace/test-lists/one-task-list.json +5 -0
- package/workspace/tk-tasks-test.js +3 -3
- package/workspace/public/pm/bd-ini-model.js +0 -81
- package/workspace/public/pm/cozy-rec-pill.css +0 -12
- package/workspace/public/pm/cozy-rec-pill.js +0 -46
|
@@ -67,7 +67,7 @@ const VERBS = Object.freeze({
|
|
|
67
67
|
help: 'pmos workflow list|show|draft|show-draft|judge|of|move|switch … — the workflows of this repository, the New workflow draft, a reading of an Only-when stage, and an initiative\'s workflow stage (pmos workflow help)' }),
|
|
68
68
|
// Not a pm-os-absorb verb (run: null): feedback batch 4 (Wawan, 2026-10-25) added it through the same table.
|
|
69
69
|
task: Object.freeze({ module: 'task-cli.js', run: null, guide: 'workflows.md',
|
|
70
|
-
help: 'pmos task list|state … — an initiative\'s
|
|
70
|
+
help: 'pmos task add|list|state|set … — an initiative\'s tasks: add one, list them, set their state or group them under a stage when the PM asks (pmos task help)' }),
|
|
71
71
|
// Not a pm-os-absorb verb (run: null): feedback batch 4 item 6 (Claude suggests program milestones) added it through the same table.
|
|
72
72
|
program: Object.freeze({ module: 'program-cli.js', run: null, guide: 'programs.md',
|
|
73
73
|
help: 'pmos program suggest — Claude\'s milestone suggestions for a program, filed by its review run (pmos program help)' }),
|
|
@@ -53,6 +53,7 @@ const MODULES = Object.freeze([
|
|
|
53
53
|
'routes-board-grill', // premium-uncovered-features (Board): a new initiative's Why, material and first questions (page press; file mode)
|
|
54
54
|
'routes-insights-premium', // briefing-premium-insights: the premium Insights page's model from the KR metric records and report files (read-only)
|
|
55
55
|
'routes-home-desk', // premium-agreed-design (Home): seen marks, queued messages, the weekly update's recipients and sends, stakeholders (page press; file mode)
|
|
56
|
+
'routes-live', // batch 6 item 2: the Live pill's sessions and the titles of their initiatives (read-only)
|
|
56
57
|
'routes-home-review', // premium-uncovered-features (Home): the weekly review's four steps and the untouched work looked at (page press; file mode)
|
|
57
58
|
'routes-initiative-premium', // briefing-premium-initiative: the premium initiative page's model from the Initiatives sheet's own routes (read-only)
|
|
58
59
|
'routes-initiative-layout', // premium-uncovered-features (Initiative): Moves on by itself, held stages, task groups and saved group sets (page press; file mode)
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
* POST /api/boards/settings { ws, board, buildDeliver?, jira?, offer?, defTpl? } → { ok, board } jira: one key or a list
|
|
25
25
|
* POST /api/boards/ini-workflow { ws, board, id, template?, stages, moveTo? } → { ok, row, moved }
|
|
26
26
|
* POST /api/boards/ini-epics { ws, board, id, epics: [Jira key] } → { ok, row } the Jira epics of an initiative ([] unlinks)
|
|
27
|
-
* POST /api/boards/tasks/add { ws, board, initiative, title, type?, epic?, start?, due?, owner? } → { ok, item }
|
|
27
|
+
* POST /api/boards/tasks/add { ws, board, initiative, title, type?, epic?, start?, due?, owner?, notes? } → { ok, item } also `pmos task add`
|
|
28
28
|
* POST /api/boards/tasks/state { ws, board, task, state } → { ok, item }
|
|
29
29
|
* POST /api/boards/tasks/reschedule { ws, board, task, days } → { ok, item }
|
|
30
30
|
* POST /api/boards/tasks/undo-add { ws, board, task } → { ok } takes back a task added in the last 2 minutes, still To do
|
|
31
31
|
* POST /api/boards/tasks/rename { ws, board, task, title } → { ok, from, item } only the title changes
|
|
32
|
-
* POST /api/boards/tasks/edit { ws, board, task, owner?, notes?, start?, due?, initiative? } → { ok, from, item } the Viewer's edits in place
|
|
32
|
+
* POST /api/boards/tasks/edit { ws, board, task, owner?, notes?, start?, due?, initiative?, section? } → { ok, from, item } the Viewer's edits in place
|
|
33
|
+
* (section: the task's place in the breakdown, a stage key of its initiative's workflow or '' — a task-section line)
|
|
33
34
|
* (canvas XetX1Rest); `from` holds the fields as they were, so Undo is the same call with `from`
|
|
34
35
|
* POST /api/boards/tickets/note { ws, board, ref, notes } → { ok, from, notes } the PM's notes on a Jira ticket
|
|
35
36
|
* POST /api/boards/archive { ws, board, id, archived, reason? } → { ok, row } archive (hidden everywhere, kept whole) or restore;
|
|
@@ -82,6 +83,7 @@ const { repoScript } = require('./repo-script.js');
|
|
|
82
83
|
const B = require(repoScript('boards.js'));
|
|
83
84
|
const WF = require(repoScript('workflows.js'));
|
|
84
85
|
const WS = require('./workflows-store.js');
|
|
86
|
+
const TI = require('./task-items.js');
|
|
85
87
|
const intake = require(repoScript('intake.js'));
|
|
86
88
|
|
|
87
89
|
const LEDGER = 'boards.jsonl';
|
|
@@ -367,6 +369,42 @@ function rowsOfBoard(fr, board, base) {
|
|
|
367
369
|
}
|
|
368
370
|
return rows;
|
|
369
371
|
}
|
|
372
|
+
/** A stage's To finish entries are tasks of the initiative (feedback batch 5: "Also there is workflow tasks, confusing"). Each entry of the
|
|
373
|
+
* current stage becomes one Board task, once: its `from` marker names the stage and the entry, so a move back and forth makes no second
|
|
374
|
+
* one. It runs on a move, a switch and the first read that finds none, so closing one (on the stage card, in the Tasks section or with
|
|
375
|
+
* `pmos task state`) is one write. Product feature's stages have no To finish list. `by` is who put the initiative on the stage.
|
|
376
|
+
* → the number of tasks made. */
|
|
377
|
+
function stageTasks(file, folded, board, row, by) {
|
|
378
|
+
if (!file || !row || !row.wfStage || board.self || row.ended || row.archived) return 0;
|
|
379
|
+
const st = (row.wfStages || []).find((s) => s.key === row.wfStage.key);
|
|
380
|
+
const list = st && Array.isArray(st.finish) ? st.finish.filter((f) => typeof f === 'string' && f.trim()) : [];
|
|
381
|
+
if (!list.length) return 0;
|
|
382
|
+
const have = new Set();
|
|
383
|
+
for (const t of folded.tasks.values()) if (t.initiative === row.id && t.from && t.from.stage === st.key) have.add(t.from.finish);
|
|
384
|
+
let n = 0;
|
|
385
|
+
for (const f of list) {
|
|
386
|
+
if (have.has(f)) continue;
|
|
387
|
+
append(file, { by: by || 'agent:unknown' }, { kind: 'task', board: board.id, task: `task-${crypto.randomBytes(5).toString('hex')}`, type: 'Task', initiative: row.id,
|
|
388
|
+
title: f.trim().charAt(0).toUpperCase() + f.trim().slice(1), epic: null, owner: null, state: 'To do', from: { stage: st.key, finish: f } });
|
|
389
|
+
have.add(f); n++;
|
|
390
|
+
}
|
|
391
|
+
return n;
|
|
392
|
+
}
|
|
393
|
+
/** Who put an initiative on its current stage: the last move or workflow switch of it on this board. */
|
|
394
|
+
function stagedBy(folded, boardId, id) {
|
|
395
|
+
const m = [...folded.moves].reverse().find((x) => x.board === boardId && x.id === id);
|
|
396
|
+
const own = folded.iniWf ? folded.iniWf.get(B.key(boardId, id)) : null;
|
|
397
|
+
return (m && m.by) || (own && own.by) || null;
|
|
398
|
+
}
|
|
399
|
+
/** The read-time pass of stageTasks over rows of one board; a fresh fold when it made any. */
|
|
400
|
+
function seedRows(ctx, w, fr, board, rows) {
|
|
401
|
+
const file = ledgerFile(ctx, w);
|
|
402
|
+
let n = 0;
|
|
403
|
+
for (const r of rows) if (r.wf && r.wf.id !== 'product-feature') n += stageTasks(file, fr.folded, board, r, stagedBy(fr.folded, board.id, r.id));
|
|
404
|
+
if (n) fr.folded = foldOf(ctx, w);
|
|
405
|
+
return n;
|
|
406
|
+
}
|
|
407
|
+
|
|
370
408
|
/** The archive entry of an initiative, as a page row carries it, or null while it is not archived. */
|
|
371
409
|
function archivedOf(folded, id) {
|
|
372
410
|
const a = folded && folded.archives && folded.archives.get(id);
|
|
@@ -412,7 +450,7 @@ const openAsks = (folded, boardId) => [...folded.asks.values()].filter((a) => a.
|
|
|
412
450
|
const pageAsk = (a) => ({ ...a, by: actorLib.pageName(a.by) });
|
|
413
451
|
const pageMove = (m) => ({ ...m, by: actorLib.pageName(m.by) });
|
|
414
452
|
|
|
415
|
-
/** The work items of a board: its PMOS tasks (the ledger) and, with Build and deliver on, the Jira items of its initiatives
|
|
453
|
+
/** The work items of a board: its PMOS tasks (the ledger and the initiatives' breakdown items) and, with Build and deliver on, the Jira items of its initiatives
|
|
416
454
|
* (the ticket drafts this repository pushed, with the status of the cached readings; read-only, no dates or people). */
|
|
417
455
|
function itemsOf(w, fr, board, rows) {
|
|
418
456
|
const ids = new Set(rows.map((x) => x.id));
|
|
@@ -442,7 +480,11 @@ function itemsOf(w, fr, board, rows) {
|
|
|
442
480
|
}
|
|
443
481
|
}
|
|
444
482
|
for (const t of fr.folded.tasks.values()) if (t.board === board.id && ids.has(t.initiative)) out.push(B.taskItem(t));
|
|
483
|
+
out.push(...TI.rowsOf(w.root, ids, board.id)); // one kind of task: an initiative's breakdown items show as its tasks (lib/task-items.js)
|
|
445
484
|
for (const x of out) if (x.src === 'jira') x.notes = (fr.folded.ticketNotes && fr.folded.ticketNotes.get(board.id + '\u0000' + x.key)) || ''; // the PM's notes (canvas XetX1Jira)
|
|
485
|
+
// a task's place in the breakdown (one view): the PM's own choice, else the stage whose To finish entry made it
|
|
486
|
+
const SEC = fr.folded.sections || new Map();
|
|
487
|
+
for (const x of out) if (x.src === 'pmos' && x.kind !== 'Epic') { if (SEC.has(x.uid)) x.section = SEC.get(x.uid); else if (x.from && x.from.stage) x.section = x.from.stage; }
|
|
446
488
|
return B.rollupItems(out);
|
|
447
489
|
}
|
|
448
490
|
|
|
@@ -562,6 +604,7 @@ const READS = {
|
|
|
562
604
|
if (!base) return fail(ctx, res, 404, `no work-lane initiative ${id} in this workspace`);
|
|
563
605
|
const own = r.fr.boards.find((b) => b.id === boardIdOf(base, r.fr.boards, r.fr.folded, r.w)) || r.board;
|
|
564
606
|
const row = boardRow(own, base, r.fr.folded);
|
|
607
|
+
seedRows(ctx, r.w, r.fr, own, [row]);
|
|
565
608
|
const F = r.fr.folded;
|
|
566
609
|
const ownRows = own.id === r.board.id ? r.rows : rowsOfBoard(r.fr, own, r.base);
|
|
567
610
|
const mine = ownRows.find((x) => x.id === id);
|
|
@@ -599,8 +642,10 @@ const READS = {
|
|
|
599
642
|
const r = boardRead(ctx, res, url);
|
|
600
643
|
if (!r) return;
|
|
601
644
|
const live = r.rows.filter((x) => !x.archived); // an archived initiative leaves every list and timeline (c3-initiative-lifecycle)
|
|
645
|
+
seedRows(ctx, r.w, r.fr, r.board, live);
|
|
602
646
|
ctx.json(res, { ok: true, ws: r.w.id, board: r.board.id, build: r.board.build, jira: r.board.jira, jiraProjects: r.board.jiraProjects, items: itemsOf(r.w, r.fr, r.board, live),
|
|
603
|
-
initiatives: live.map((x) => ({ id: x.id, title: x.title, stage: x.stage, cat: x.cat, status: x.status, owner: x.owner, horizon: x.horizon, start: x.start, end: x.end, progress: x.progress, template: x.template, epics: x.epics
|
|
647
|
+
initiatives: live.map((x) => ({ id: x.id, title: x.title, stage: x.stage, cat: x.cat, status: x.status, owner: x.owner, horizon: x.horizon, start: x.start, end: x.end, progress: x.progress, template: x.template, epics: x.epics,
|
|
648
|
+
stages: (x.wfStages || []).map((st) => ({ key: st.key, name: st.name, milestone: !!st.milestone })) })) }); // the sections a task can sit in (the task Viewer's move icon)
|
|
604
649
|
},
|
|
605
650
|
'/api/boards/sprints': (ctx, res, url) => {
|
|
606
651
|
const r = boardRead(ctx, res, url);
|
|
@@ -690,7 +735,31 @@ function moveOnWorkflow(ctx, res, body, g, p, own) {
|
|
|
690
735
|
for (let i = a + 1; i < b; i++) { const sk = before.wfStages[i]; if (sk && sk.status !== 'skipped' && sk.when.mode !== 'optional') warnings.push('Skipped ' + sk.name); }
|
|
691
736
|
if (!before.anchor) warnings.push('No anchor');
|
|
692
737
|
append(p.file, g.actor, { kind: 'move', board: p.board.id, id: body.id, from: before.wfStage.key, to: t.key, why: body.why || '', warnings });
|
|
693
|
-
|
|
738
|
+
const f1 = foldOf(ctx, p.w), row = boardRow(p.board, b0, f1);
|
|
739
|
+
const made = stageTasks(p.file, f1, p.board, row, g.actor.by); // the new stage's To finish entries, as tasks
|
|
740
|
+
ctx.json(res, { ok: true, row, warnings, ...(made ? { tasksMade: made } : {}) });
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/** A breakdown item named as a task (lib/task-items.js), when its initiative is on this board; answers and returns null when not. */
|
|
744
|
+
function itemOnBoard(ctx, res, p, id) {
|
|
745
|
+
const it = TI.isItemId(id) ? TI.itemOf(p.w.root, id) : null;
|
|
746
|
+
if (!it) { fail(ctx, res, 404, `no PMOS task ${id} on this board`); return null; }
|
|
747
|
+
const base = needRows(ctx, res, p.w);
|
|
748
|
+
if (!base) return null;
|
|
749
|
+
const b0 = base.find((r) => r.id === it.initiative);
|
|
750
|
+
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) { fail(ctx, res, 404, `no PMOS task ${id} on this board`); return null; }
|
|
751
|
+
return it;
|
|
752
|
+
}
|
|
753
|
+
/** Writes an item's lines (r: TI.stateEvents or TI.editEvents) as the task routes do and answers the item as a task. */
|
|
754
|
+
function itemWrite(ctx, res, p, it, r, g, extra = {}) {
|
|
755
|
+
if (r.error) return fail(ctx, res, 400, r.error);
|
|
756
|
+
if (!r.same) {
|
|
757
|
+
const w = TI.write(p.w.root, r.events, g.actor, g.cli || null);
|
|
758
|
+
if (!w.ok) return fail(ctx, res, w.status || 400, w.error);
|
|
759
|
+
}
|
|
760
|
+
const ids = new Set([it.initiative]);
|
|
761
|
+
const row = TI.rowsOf(p.w.root, ids, p.board.id).find((x) => x.uid === it.id) || { ...TI.rowsOf(p.w.root, ids, p.board.id)[0], uid: it.id, ref: it.id, title: it.title, status: "Won't do" };
|
|
762
|
+
ctx.json(res, { ok: true, item: B.rollupItems([row])[0], ...extra });
|
|
694
763
|
}
|
|
695
764
|
|
|
696
765
|
const WRITES = {
|
|
@@ -869,8 +938,9 @@ const WRITES = {
|
|
|
869
938
|
if (body.to != null) { const t = WF.stageByRef(to, body.to); if (!t) return fail(ctx, res, 400, `"${body.to}" is not a stage of ${to.name}`); target = t.key; }
|
|
870
939
|
const moved = { from: before.wfStage.key, to: target };
|
|
871
940
|
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 } : {}) });
|
|
872
|
-
const row = boardRow(p.board, b0,
|
|
873
|
-
|
|
941
|
+
const f1 = foldOf(ctx, p.w), row = boardRow(p.board, b0, f1);
|
|
942
|
+
const made = stageTasks(p.file, f1, p.board, row, g.actor.by);
|
|
943
|
+
ctx.json(res, { ok: true, row, moved, ...(made ? { tasksMade: made } : {}) });
|
|
874
944
|
},
|
|
875
945
|
'/api/boards/wontdo': (ctx, res, body, g) => {
|
|
876
946
|
const p = postFrame(ctx, res, body);
|
|
@@ -958,16 +1028,18 @@ const WRITES = {
|
|
|
958
1028
|
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`);
|
|
959
1029
|
if (body.owner != null && body.owner !== '' && !ONE_LINE(body.owner, 80)) return fail(ctx, res, 400, 'owner is one line of at most 80 characters');
|
|
960
1030
|
if (body.epic != null && body.epic !== '' && !ONE_LINE(body.epic, 80)) return fail(ctx, res, 400, 'epic is one line of at most 80 characters');
|
|
1031
|
+
if (body.notes != null && (typeof body.notes !== 'string' || body.notes.length > 4000)) return fail(ctx, res, 400, 'notes are text of at most 4000 characters');
|
|
1032
|
+
if (body.start && body.due && body.start > body.due) return fail(ctx, res, 400, 'the start is after the due day');
|
|
961
1033
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
962
1034
|
const base = needRows(ctx, res, p.w);
|
|
963
1035
|
if (!base) return;
|
|
964
1036
|
const b0 = base.find((r) => r.id === body.initiative);
|
|
965
1037
|
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404, `no initiative ${body.initiative} on this board`);
|
|
966
1038
|
const id = `task-${crypto.randomBytes(5).toString('hex')}`;
|
|
967
|
-
const start = body.start || B.shiftDay(today(), 1);
|
|
1039
|
+
const start = body.start || (body.due && body.due < B.shiftDay(today(), 1) ? body.due : B.shiftDay(today(), 1));
|
|
968
1040
|
const due = body.due || B.shiftDay(start, 7);
|
|
969
1041
|
append(p.file, g.actor, { kind: 'task', board: p.board.id, task: id, type: body.type || 'Task', initiative: body.initiative, title: body.title.trim(), epic: body.epic ? String(body.epic).trim() : null,
|
|
970
|
-
owner: body.owner ? String(body.owner).trim() : actorLib.pageName(g.actor.by), state: 'To do', start, due });
|
|
1042
|
+
owner: body.owner ? String(body.owner).trim() : actorLib.pageName(g.actor.by), state: 'To do', start, due, ...(body.notes && body.notes.trim() ? { notes: body.notes.replace(/\s+$/, '') } : {}) });
|
|
971
1043
|
const t = B.taskOf(B.fold(readLedger(ctx, p.w)), id);
|
|
972
1044
|
ctx.json(res, { ok: true, item: B.rollupItems([B.taskItem(t)])[0] });
|
|
973
1045
|
},
|
|
@@ -975,8 +1047,15 @@ const WRITES = {
|
|
|
975
1047
|
const p = postFrame(ctx, res, body);
|
|
976
1048
|
if (!p) return;
|
|
977
1049
|
const t = B.taskOf(p.fr.folded, body.task);
|
|
978
|
-
if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
979
1050
|
const state = B.taskState(body.state); // the five task states; an old 'In review' is In progress
|
|
1051
|
+
if (!t && TI.isItemId(body.task)) {
|
|
1052
|
+
// a breakdown item is a task too (one list, feedback batch 5): its state is written to the plan-items ledger
|
|
1053
|
+
if (!state) return fail(ctx, res, 400, `state is one of ${B.TASK_STATES.join(', ')}`);
|
|
1054
|
+
const it = itemOnBoard(ctx, res, p, body.task);
|
|
1055
|
+
if (!it) return;
|
|
1056
|
+
return itemWrite(ctx, res, p, it, TI.stateEvents(it, state, body.why), g);
|
|
1057
|
+
}
|
|
1058
|
+
if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
980
1059
|
if (!state) return fail(ctx, res, 400, `state is one of ${B.TASK_STATES.join(', ')}`);
|
|
981
1060
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
982
1061
|
append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, state, why: typeof body.why === 'string' && body.why.trim() ? body.why.trim().slice(0, 300) : 'status move' });
|
|
@@ -999,8 +1078,13 @@ const WRITES = {
|
|
|
999
1078
|
const p = postFrame(ctx, res, body);
|
|
1000
1079
|
if (!p) return;
|
|
1001
1080
|
const t = B.taskOf(p.fr.folded, body.task);
|
|
1002
|
-
if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
1003
1081
|
if (!ONE_LINE(body.title, 200)) return fail(ctx, res, 400, 'title is one line of 1 to 200 characters');
|
|
1082
|
+
if (!t && TI.isItemId(body.task)) {
|
|
1083
|
+
const it = itemOnBoard(ctx, res, p, body.task);
|
|
1084
|
+
if (!it) return;
|
|
1085
|
+
return itemWrite(ctx, res, p, it, TI.editEvents(it, { title: body.title }), g, { from: it.title });
|
|
1086
|
+
}
|
|
1087
|
+
if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
1004
1088
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1005
1089
|
append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, title: body.title.trim(), why: 'renamed' });
|
|
1006
1090
|
const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
|
|
@@ -1010,8 +1094,17 @@ const WRITES = {
|
|
|
1010
1094
|
// the task Viewer edits in place (canvas XetX1Rest, XetX1Dates): each change saves at once; Undo sends `from` back
|
|
1011
1095
|
const p = postFrame(ctx, res, body);
|
|
1012
1096
|
if (!p) return;
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1097
|
+
const t0 = B.taskOf(p.fr.folded, body.task);
|
|
1098
|
+
let t = t0;
|
|
1099
|
+
if (!t0 && TI.isItemId(body.task)) {
|
|
1100
|
+
// a breakdown item: the same checks, on the item's own fields (it stays on its initiative)
|
|
1101
|
+
t = itemOnBoard(ctx, res, p, body.task);
|
|
1102
|
+
if (!t) return;
|
|
1103
|
+
if (body.initiative != null && body.initiative !== t.initiative) return fail(ctx, res, 409, 'a breakdown item stays on its initiative');
|
|
1104
|
+
t = { ...t, owner: TI.ownerName(t.owner), notes: t.note || '', item: true };
|
|
1105
|
+
delete body.initiative;
|
|
1106
|
+
}
|
|
1107
|
+
if (!t || (!t.item && t.board !== p.board.id)) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
1015
1108
|
const ev = {}, from = {};
|
|
1016
1109
|
if (body.owner != null) { if (body.owner !== '' && !ONE_LINE(body.owner, 80)) return fail(ctx, res, 400, 'owner is one line of at most 80 characters'); ev.owner = String(body.owner).trim(); from.owner = t.owner || ''; }
|
|
1017
1110
|
if (body.notes != null) { if (typeof body.notes !== 'string' || body.notes.length > 4000) return fail(ctx, res, 400, 'notes are text of at most 4000 characters'); ev.notes = body.notes.replace(/\s+$/, ''); from.notes = t.notes || ''; }
|
|
@@ -1025,7 +1118,29 @@ const WRITES = {
|
|
|
1025
1118
|
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404, `no initiative ${body.initiative} on this board`);
|
|
1026
1119
|
ev.initiative = body.initiative; from.initiative = t.initiative;
|
|
1027
1120
|
}
|
|
1028
|
-
|
|
1121
|
+
// the task's place in the breakdown (one view, feedback batch 6 item 1): a stage key of its initiative's workflow, or '' for Not in a
|
|
1122
|
+
// stage. It is a board-ledger line for both kinds of task, so a breakdown item and a Board task move the same way, and it never moves
|
|
1123
|
+
// the initiative's own stage
|
|
1124
|
+
let sec = null;
|
|
1125
|
+
if (body.section != null) {
|
|
1126
|
+
if (typeof body.section !== 'string' || body.section.length > 80) return fail(ctx, res, 400, "section is a stage key of the initiative's workflow, or '' for Not in a stage");
|
|
1127
|
+
const iniId = ev.initiative || t.initiative, base = needRows(ctx, res, p.w);
|
|
1128
|
+
if (!base) return;
|
|
1129
|
+
const b0 = base.find((r) => r.id === iniId);
|
|
1130
|
+
if (!b0) return fail(ctx, res, 404, `no initiative ${iniId} on this board`);
|
|
1131
|
+
const st = boardRow(p.board, b0, p.fr.folded).wfStages || [];
|
|
1132
|
+
if (body.section && !st.some((x) => x.key === body.section)) return fail(ctx, res, 400, `"${body.section}" is not a stage of this initiative's workflow: one of ${st.map((x) => x.key).join(', ')}, or ''`);
|
|
1133
|
+
const S0 = p.fr.folded.sections || new Map();
|
|
1134
|
+
sec = body.section; from.section = S0.has(t.id) ? S0.get(t.id) : (t.from && t.from.stage) || '';
|
|
1135
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1136
|
+
}
|
|
1137
|
+
if (!Object.keys(ev).length && sec == null) return fail(ctx, res, 400, 'nothing to change: send owner, notes, start, due, initiative or section');
|
|
1138
|
+
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' });
|
|
1139
|
+
if (!Object.keys(ev).length) {
|
|
1140
|
+
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));
|
|
1141
|
+
return ctx.json(res, { ok: true, from, item: items.find((x) => x.uid === t.id) || null });
|
|
1142
|
+
}
|
|
1143
|
+
if (t.item) return itemWrite(ctx, res, p, t, TI.editEvents(t, ev), g, { from });
|
|
1029
1144
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1030
1145
|
append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, ...ev, why: 'edited ' + Object.keys(ev).join(', ') });
|
|
1031
1146
|
const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
|
|
@@ -1046,13 +1161,17 @@ const WRITES = {
|
|
|
1046
1161
|
'/api/boards/tasks/reschedule': (ctx, res, body, g) => {
|
|
1047
1162
|
const p = postFrame(ctx, res, body);
|
|
1048
1163
|
if (!p) return;
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1164
|
+
const t0 = B.taskOf(p.fr.folded, body.task);
|
|
1165
|
+
const it = !t0 && TI.isItemId(body.task) ? itemOnBoard(ctx, res, p, body.task) : null;
|
|
1166
|
+
if (!t0 && TI.isItemId(body.task) && !it) return;
|
|
1167
|
+
const t = t0 || (it ? { start: it.start, due: it.due } : null);
|
|
1168
|
+
if (!t || (t0 && t0.board !== p.board.id)) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
1051
1169
|
const days = Number(body.days);
|
|
1052
1170
|
if (!Number.isInteger(days) || days === 0 || Math.abs(days) > 730) return fail(ctx, res, 400, 'days is a whole number of days, not 0, at most 730 either way');
|
|
1053
|
-
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1054
1171
|
const start = B.shiftDay(t.start || B.shiftDay(t.due || today(), -7), days);
|
|
1055
1172
|
const due = B.shiftDay(t.due || B.shiftDay(t.start || today(), 7), days);
|
|
1173
|
+
if (it) return itemWrite(ctx, res, p, it, TI.editEvents(it, { start, due }), g);
|
|
1174
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1056
1175
|
append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, start, due, why: `rescheduled ${days > 0 ? '+' : ''}${days} days` });
|
|
1057
1176
|
const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
|
|
1058
1177
|
ctx.json(res, { ok: true, item: B.rollupItems([B.taskItem(t2)])[0] });
|
|
@@ -1190,6 +1309,10 @@ function move(ctx, body, g) { return writeAs(ctx, '/api/boards/move', body, g);
|
|
|
1190
1309
|
function switchWorkflow(ctx, body, g) { return writeAs(ctx, '/api/boards/ini-wf', body, g); }
|
|
1191
1310
|
/** A Board task's state, by the same function POST /api/boards/tasks/state runs (`pmos task state`). body: { ws, board, task, state, why? }. */
|
|
1192
1311
|
function taskState(ctx, body, g) { return writeAs(ctx, '/api/boards/tasks/state', body, g); }
|
|
1312
|
+
/** A new Board task, by the same function as the page's Add a task (POST /api/boards/tasks/add; `pmos task add`). body: { ws, board, initiative, title, start?, due?, owner? }. */
|
|
1313
|
+
function taskAdd(ctx, body, g) { return writeAs(ctx, '/api/boards/tasks/add', body, g); }
|
|
1314
|
+
/** A task's edit, by the same function as the Viewer's (POST /api/boards/tasks/edit; `pmos task set`). body: { ws, board, task, section?, start?, due?, owner?, notes? }. */
|
|
1315
|
+
function taskEdit(ctx, body, g) { return writeAs(ctx, '/api/boards/tasks/edit', body, g); }
|
|
1193
1316
|
|
|
1194
1317
|
/** The workflow one initiative runs and where it stands in it, as the Board's row has it (boardRow: wf, wfStage, wfStages, ended), with the
|
|
1195
1318
|
* board it is on. For `pmos workflow of|move|switch` and the initiative chat's opening (bug 2026-10-25: an agent that could not see the
|
|
@@ -1205,6 +1328,14 @@ function initiativeWorkflow(ctx, w, id) {
|
|
|
1205
1328
|
return { ok: true, board, row: boardRow(board, b0, fr.folded) };
|
|
1206
1329
|
}
|
|
1207
1330
|
|
|
1331
|
+
/** stageTasks for one initiative outside HTTP (`pmos task list|state`): its current stage's To finish entries made tasks once. → the number made, or 0. */
|
|
1332
|
+
function seedInitiative(ctx, w, id) {
|
|
1333
|
+
const r = initiativeWorkflow(ctx, w, id);
|
|
1334
|
+
if (!r.ok || !r.row.wf || r.row.wf.id === 'product-feature') return 0;
|
|
1335
|
+
const folded = foldOf(ctx, w);
|
|
1336
|
+
return stageTasks(ledgerFile(ctx, w), folded, r.board, r.row, stagedBy(folded, r.board.id, id));
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1208
1339
|
/** The board of each initiative of a workspace, for other routes (Reports): { boards: [{ id, title }], of(id) → board id }.
|
|
1209
1340
|
* Rows still being read fall back to the ledger's assignment, else the default board. */
|
|
1210
1341
|
function boardIndex(ctx, w) {
|
|
@@ -1269,4 +1400,4 @@ function meetingBoards(ctx) {
|
|
|
1269
1400
|
return { list, detail };
|
|
1270
1401
|
}
|
|
1271
1402
|
|
|
1272
|
-
module.exports = { prefixes: ['/api/boards'], handle, move, switchWorkflow, taskState, initiativeWorkflow, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
1403
|
+
module.exports = { prefixes: ['/api/boards'], handle, move, switchWorkflow, taskState, taskAdd, taskEdit, initiativeWorkflow, seedInitiative, stageTasks, itemsOf, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
@@ -213,7 +213,20 @@ module.exports = {
|
|
|
213
213
|
const tok = req.headers && req.headers['x-pmos-session'];
|
|
214
214
|
const who = actor.sessionForToken(Array.isArray(tok) ? tok[0] : tok, { sessDir: ctx.sessDir || path.join(ctx.runtimeDir || '', 'sessions') });
|
|
215
215
|
if (!who) { ctx.json(res, { ok: false, error: 'no valid session token' }, 401); return true; }
|
|
216
|
-
ctx.
|
|
216
|
+
const key = ctx.runtimeDir && Goal.keyOfSession(ctx.runtimeDir, who.session, Ag.CHATS);
|
|
217
|
+
ctx.json(res, Goal.askToolReply(key ? Goal.goalOf(ctx.runtimeDir, key) : null));
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
if (url.pathname === '/api/briefing-premium/goal-tool') {
|
|
221
|
+
// Claude Code's PreToolUse hook for every tool in a chat session: a started goal runs without permission prompts. Any other chat asks as usual.
|
|
222
|
+
if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
|
|
223
|
+
const got = await ctx.readJson(req);
|
|
224
|
+
const tok = req.headers && req.headers['x-pmos-session'];
|
|
225
|
+
const who = actor.sessionForToken(Array.isArray(tok) ? tok[0] : tok, { sessDir: ctx.sessDir || path.join(ctx.runtimeDir || '', 'sessions') });
|
|
226
|
+
if (!who || !ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'no valid session token' }, 401); return true; }
|
|
227
|
+
const key = Goal.keyOfSession(ctx.runtimeDir, who.session, Ag.CHATS);
|
|
228
|
+
const body = got.ok && got.body && typeof got.body === 'object' ? got.body : {};
|
|
229
|
+
ctx.json(res, key ? Goal.goalToolReply(Goal.goalOf(ctx.runtimeDir, key), body.tool_name) : {});
|
|
217
230
|
return true;
|
|
218
231
|
}
|
|
219
232
|
if (url.pathname === '/api/briefing-premium/seen') {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-live.js — what the Live pill reads (batch 6 item 2, canvas XrrAGrill "Live pill · every scenario"; pm/cozy-live-pill.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/live → { ok, sessions: [row], titles: { [initiative id]: title } }
|
|
5
|
+
* row = the /api/sessions fields the pill needs: id, ws, name, auto_name, name_by, agent, origin, automatic, shown, created,
|
|
6
|
+
* lastOutputAt, touched_at, exited_at, auto_ended, outcome { ok } | null, initiative, hx { title, turn } | null
|
|
7
|
+
* titles = the initiatives those sessions work on, by id, from each workspace's records (kept 60 s per workspace)
|
|
8
|
+
*
|
|
9
|
+
* Read-only. The pill shows on every page, so it reads this small answer every 10 s rather than the whole of /api/sessions; the
|
|
10
|
+
* times the PM touched a session are kept by server.js (touchSession: opened on Home, typed or answered). Nothing is written. */
|
|
11
|
+
|
|
12
|
+
const TITLES_MS = 60000;
|
|
13
|
+
const cache = new Map(); // workspace root → { at, titles }
|
|
14
|
+
|
|
15
|
+
function titlesOf(ctx, ws) {
|
|
16
|
+
const w = ctx.getWs ? ctx.getWs(ws) : null;
|
|
17
|
+
if (!w || !w.root || typeof ctx.initiativeIndex !== 'function') return {};
|
|
18
|
+
const c = cache.get(w.root);
|
|
19
|
+
if (c && Date.now() - c.at < TITLES_MS) return c.titles;
|
|
20
|
+
const titles = {};
|
|
21
|
+
try { for (const g of ctx.initiativeIndex(w.root).initiatives || []) if (g && g.id) titles[g.id] = g.title || g.id; } catch { /* a folder with no records names none */ }
|
|
22
|
+
cache.set(w.root, { at: Date.now(), titles });
|
|
23
|
+
return titles;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const iniOf = (s) => s.initiative || ((/^chat:(?:init|board):([^:]+)/.exec(String(s.origin || '')) || [])[1]) || null;
|
|
27
|
+
|
|
28
|
+
function rowOf(s) {
|
|
29
|
+
return {
|
|
30
|
+
id: s.id, ws: s.ws, name: s.name, auto_name: s.auto_name || null, name_by: s.name_by || null, agent: s.agent, origin: s.origin || null,
|
|
31
|
+
automatic: !!s.automatic, shown: s.shown, created: s.created || null, lastOutputAt: s.lastOutputAt || null,
|
|
32
|
+
touched_at: s.touched_at || null, exited_at: s.exited_at || null, auto_ended: !!s.auto_ended,
|
|
33
|
+
outcome: s.outcome ? { ok: s.outcome.ok !== false } : null, initiative: s.initiative || null,
|
|
34
|
+
hx: s.hx ? { title: s.hx.title || null, turn: s.hx.turn || null } : null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function handle(req, res, url, ctx) {
|
|
39
|
+
if (url.pathname !== '/api/live') return false;
|
|
40
|
+
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
41
|
+
let list = [];
|
|
42
|
+
try { list = ctx.sessionList ? ctx.sessionList() : []; } catch { list = []; }
|
|
43
|
+
const sessions = list.map(rowOf);
|
|
44
|
+
const titles = {};
|
|
45
|
+
for (const s of sessions) {
|
|
46
|
+
const id = iniOf(s); if (!id || titles[id]) continue;
|
|
47
|
+
const t = titlesOf(ctx, s.ws)[id]; if (t) titles[id] = t;
|
|
48
|
+
}
|
|
49
|
+
ctx.json(res, { ok: true, sessions, titles });
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = { prefixes: ['/api/live'], handle, rowOf };
|