create-pmos 0.411.0 → 0.413.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 +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/pmos-log.sh +6 -3
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +2 -2
- package/workspace/briefing-premium-adddoc-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +2 -2
- package/workspace/briefing-premium-test.js +3 -3
- package/workspace/changelog.json +24 -0
- package/workspace/core-docs-workflow-test.js +144 -0
- package/workspace/guide/board.md +1 -1
- package/workspace/guide/breakdown.md +6 -13
- package/workspace/guide/index.md +1 -1
- package/workspace/guide/initiative-driver.md +1 -1
- package/workspace/guide/initiatives-screen.md +1 -1
- package/workspace/guide/pm-only-acts.md +23 -24
- package/workspace/guide/today.md +1 -1
- package/workspace/guide/workflows.md +8 -1
- package/workspace/lib/board-premium.js +7 -2
- package/workspace/lib/briefing-premium-agent.js +16 -4
- package/workspace/lib/briefing-premium-writes.js +5 -4
- package/workspace/lib/core-docs.js +79 -14
- package/workspace/lib/coredoc-cli.js +1 -1
- package/workspace/lib/driver-cli.js +2 -1
- package/workspace/lib/driver-decide.js +3 -2
- package/workspace/lib/driver.js +2 -1
- package/workspace/lib/engine/boards.js +20 -12
- package/workspace/lib/grant-mint.js +3 -2
- package/workspace/lib/initiative-chat.js +49 -0
- package/workspace/lib/initiative-cli.js +9 -9
- package/workspace/lib/initiative-premium.js +17 -7
- package/workspace/lib/issues.js +5 -4
- package/workspace/lib/item-cli.js +7 -2
- package/workspace/lib/people-store.js +1 -1
- package/workspace/lib/people.js +3 -1
- package/workspace/lib/placements.js +13 -15
- package/workspace/lib/plan-items.js +18 -49
- package/workspace/lib/pm-guard.js +18 -5
- package/workspace/lib/pm-lines-needs.js +9 -5
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/program-chat.js +1 -1
- package/workspace/lib/programs.js +21 -5
- package/workspace/lib/report-cli.js +2 -2
- package/workspace/lib/routes-board-metric-targets.js +0 -1
- package/workspace/lib/routes-boards.js +75 -13
- package/workspace/lib/routes-briefing-premium.js +20 -6
- package/workspace/lib/routes-core-docs.js +3 -2
- package/workspace/lib/routes-custom-docs.js +0 -1
- package/workspace/lib/routes-driver.js +0 -1
- package/workspace/lib/routes-home-desk.js +1 -1
- package/workspace/lib/routes-home-review.js +1 -1
- package/workspace/lib/routes-initiative-layout.js +1 -1
- package/workspace/lib/routes-insights-records.js +0 -1
- package/workspace/lib/routes-meeting-material.js +0 -1
- package/workspace/lib/routes-onboarding.js +3 -1
- package/workspace/lib/routes-orchestrator.js +0 -1
- package/workspace/lib/routes-premium-charts.js +0 -1
- package/workspace/lib/routes-premium-dashboards.js +0 -1
- package/workspace/lib/routes-programs.js +13 -2
- package/workspace/lib/routes-records.js +1 -1
- package/workspace/lib/routes-report-design.js +7 -3
- package/workspace/lib/routes-report-setups.js +0 -1
- package/workspace/lib/routes-report-structure.js +0 -1
- package/workspace/lib/routes-runs.js +2 -5
- package/workspace/lib/routes-scan.js +0 -1
- package/workspace/lib/routes-sources.js +1 -1
- package/workspace/lib/run-answers.js +14 -5
- package/workspace/lib/scan-cli.js +2 -1
- package/workspace/lib/scan.js +2 -1
- package/workspace/lib/vendor/scripts/onboarding/proposals.js +7 -3
- package/workspace/lib/workflow-chat.js +1 -0
- package/workspace/lib/workflow-cli.js +91 -6
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-line-test.js +9 -0
- package/workspace/premium-core-doc-issue-test.js +1 -1
- package/workspace/premium-viewer-share-test.js +5 -2
- package/workspace/premium-vw-item-test.js +3 -3
- package/workspace/premium-vw-jira-test.js +2 -1
- package/workspace/program-order-test.js +180 -0
- package/workspace/public/pm/bd-prog.js +3 -3
- package/workspace/public/pm/cozy-viewer.js +8 -3
- package/workspace/public/pm/goal-chat.js +1 -1
- package/workspace/public/pm/home-app.js +22 -8
- package/workspace/public/pm/home-chat.js +6 -1
- package/workspace/public/pm/home-ini-model.js +42 -29
- package/workspace/public/pm/home-ini.css +1 -0
- package/workspace/public/pm/home-ini.js +26 -34
- package/workspace/public/pm/home-list.js +2 -1
- package/workspace/public/pm/home-stage-card.js +3 -1
- package/workspace/public/pm/home-task.js +41 -65
- package/workspace/public/pm/home-today.js +7 -5
- package/workspace/public/pm/premium-board.js +12 -6
- package/workspace/public/pm/premium-initiative-head.js +21 -11
- package/workspace/public/pm/premium-viewer.js +1 -0
- package/workspace/public/pm/premium-vw-item-model.js +13 -7
- package/workspace/public/pm/premium-vw-item.js +49 -5
- package/workspace/public/pm/prog-order.css +47 -0
- package/workspace/public/pm/prog-order.js +188 -0
- package/workspace/public/pm/program-model.js +75 -0
- package/workspace/public/pm/task-card.css +108 -0
- package/workspace/public/pm/task-card.js +271 -0
- package/workspace/replaced-tests.json +101 -0
- package/workspace/server.js +8 -9
- package/workspace/skills/workflow-setup.skill +14 -5
- package/workspace/stage-card-test.js +11 -0
- package/workspace/task-card-test.js +248 -0
- package/workspace/test-lists/core-documents-backend.json +15 -3
- package/workspace/test-lists/program-order.json +6 -0
- package/workspace/test-lists/task-card.json +6 -0
- package/workspace/test-lists/workflow-stage.json +5 -0
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* fold(lines) → { [id]: program } PURE. The program records of ONE workspace's ledger
|
|
5
5
|
* merge(perWs) → [program] PURE. perWs: [{ ws, lines }]; the same program id in two workspaces is one program
|
|
6
|
-
* program: { id, title, owner, goal, why, start, target, jira, from, milestones, members, tasks, home }
|
|
6
|
+
* program: { id, title, owner, goal, why, start, target, jira, from, milestones, members, tasks, order, home }
|
|
7
7
|
* validProgram(b) · validMilestone(m, taken) what a write accepts, or { error }; a milestone with no id gets one from its name
|
|
8
|
+
* validOrder(list) the initiative ids of an order line, or { error }
|
|
8
9
|
*
|
|
9
10
|
* WHERE A PROGRAM LIVES. A program spans products, and a product is a workspace with its own state folder. So there is no one folder a
|
|
10
11
|
* program "belongs" to: each workspace's <state>/programs.jsonl holds the program lines written FROM that workspace — the charter where the
|
|
@@ -21,11 +22,15 @@
|
|
|
21
22
|
* { kind: 'task', program, key, title, owner?, due? } a task on the program itself; the last line for a key wins
|
|
22
23
|
* { kind: 'task-done', program, key, done: true|false }
|
|
23
24
|
* { kind: 'archive', program }
|
|
25
|
+
* { kind: 'order', program, order: [initiative id] } the PM's sequence of the program's initiatives (canvas RoADrag, RoASuggest); the last
|
|
26
|
+
* line wins. It is a line of its own, not a charter key, so a charter save never drops it
|
|
24
27
|
* A PROGRAM'S SPAN is `start` to `target` (canvas PgProgram, "Sep 2026 to Jun 2028"): a program can run for years, longer than any one
|
|
25
28
|
* initiative. A MILESTONE waits on initiatives (it is ready when they pass ◆ Deliver, derived on the page), or on none: then it is "a program
|
|
26
29
|
* check" (canvas PgMilestones) and its `done` is the PM's own mark, a `check` line. A milestone that waits on initiatives carries no `done`.
|
|
27
30
|
* Nothing about a program is typed that its initiatives already say: its products, its state and its stage spread are derived on the page
|
|
28
|
-
* (public/pm/program-model.js), from the initiatives' own rows.
|
|
31
|
+
* (public/pm/program-model.js), from the initiatives' own rows.
|
|
32
|
+
* THE ORDER is one per program (option A, agreed 2026-10-25): the planned sequence the work happens in, not a dependency. Every place that lists
|
|
33
|
+
* the program's initiatives uses it (program-model.js inOrder); an initiative it does not name follows the named ones, A to Z. */
|
|
29
34
|
|
|
30
35
|
const ID_RE = /^[a-z0-9][a-z0-9-]{0,60}$/;
|
|
31
36
|
const INI_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/;
|
|
@@ -79,7 +84,15 @@ function validProgram(b) {
|
|
|
79
84
|
return { kind: 'program', id, title, owner: str(b.owner, 80), goal: str(b.goal, 160), why: str(b.why, 600), start: b.start || '', target: b.target || '', jira: str(b.jira, 40), milestones };
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
|
|
87
|
+
/** An order line's ids: initiative ids, each once, at most 80. An empty list is valid: it goes back to A to Z. */
|
|
88
|
+
function validOrder(list) {
|
|
89
|
+
if (!Array.isArray(list)) return { error: 'order is a list of initiative ids' };
|
|
90
|
+
const out = [];
|
|
91
|
+
for (const x of list) { const id = String(x == null ? '' : x); if (!INI_RE.test(id)) return { error: 'order names an initiative that is not an id: ' + str(id, 40) }; if (!out.includes(id)) out.push(id); }
|
|
92
|
+
return out.length > 80 ? { error: 'an order holds at most 80 initiatives' } : out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const blank = (id) => ({ id, title: id, owner: '', goal: '', why: '', start: '', target: '', jira: '', from: '', milestones: [], members: [], tasks: [], order: [], archived: false, at: '' });
|
|
83
96
|
|
|
84
97
|
/** A program check's done mark from the `check` lines (the last line for a milestone wins) over the charter's own `done`. */
|
|
85
98
|
const withChecks = (milestones, checks) => (milestones || []).map((m) => {
|
|
@@ -115,6 +128,7 @@ function fold(lines) {
|
|
|
115
128
|
const t = p.tasks.find((x) => x.key === String(l.key));
|
|
116
129
|
if (t) t.done = !!l.done;
|
|
117
130
|
} else if (l.kind === 'check' && ID_RE.test(String(l.milestone || ''))) p.checks[String(l.milestone)] = !!l.done;
|
|
131
|
+
else if (l.kind === 'order' && Array.isArray(l.order)) { const v = validOrder(l.order); if (!v.error) { p.order = v; p.orderSet = true; } }
|
|
118
132
|
else if (l.kind === 'archive') p.archived = true;
|
|
119
133
|
}
|
|
120
134
|
for (const p of Object.values(out)) p.milestones = withChecks(p.milestones, p.checks);
|
|
@@ -130,15 +144,17 @@ function merge(perWs) {
|
|
|
130
144
|
const m = all[p.id] || (all[p.id] = { ...blank(p.id), home: '', checks: {} });
|
|
131
145
|
if (p.charter) Object.assign(m, { title: p.title, owner: p.owner, goal: p.goal, why: p.why, start: p.start, target: p.target, jira: p.jira, from: p.from, milestones: p.milestones, home: ws, at: p.at });
|
|
132
146
|
Object.assign(m.checks, p.checks);
|
|
147
|
+
// the route writes the order line to the charter's workspace; a line elsewhere counts only while the charter's has none
|
|
148
|
+
if (p.orderSet && (p.charter || !m.orderHome)) { m.order = p.order; if (p.charter) m.orderHome = true; }
|
|
133
149
|
for (const ini of p.members) if (!m.members.some((x) => x.ws === ws && x.initiative === ini)) m.members.push({ ws, initiative: ini });
|
|
134
150
|
for (const t of p.tasks) m.tasks.push({ ...t, ws });
|
|
135
151
|
if (p.archived) m.archived = true;
|
|
136
152
|
}
|
|
137
153
|
}
|
|
138
154
|
// the check lines of every workspace apply to the charter's milestones (the route writes them to the charter's workspace)
|
|
139
|
-
for (const m of Object.values(all)) { m.milestones = withChecks(m.milestones, m.checks); delete m.checks; }
|
|
155
|
+
for (const m of Object.values(all)) { m.milestones = withChecks(m.milestones, m.checks); delete m.checks; delete m.orderHome; }
|
|
140
156
|
// a program with no charter anywhere is a member line whose program was never made: it is not shown
|
|
141
157
|
return Object.values(all).filter((p) => p.home && !p.archived).sort((a, b) => String(a.title).localeCompare(String(b.title)));
|
|
142
158
|
}
|
|
143
159
|
|
|
144
|
-
module.exports = { fold, merge, validProgram, validMilestone, slug, ID_RE, INI_RE };
|
|
160
|
+
module.exports = { fold, merge, validProgram, validMilestone, validOrder, slug, ID_RE, INI_RE };
|
|
@@ -191,8 +191,8 @@ function reportWorkspace(verb, { pos, flags, root, json, say, fail, isTTY, env,
|
|
|
191
191
|
}
|
|
192
192
|
const who = actorLib.fromCli({ ...(isTTY === undefined ? {} : { isTTY }), ...(env === undefined ? {} : { env }) });
|
|
193
193
|
if (verb === 'finder') {
|
|
194
|
-
//
|
|
195
|
-
if (!actorLib.isPm(who)) return fail(
|
|
194
|
+
// D98: the PM or an agent session turns the finder or a source on or off; the line names who.
|
|
195
|
+
if (!actorLib.isPm(who) && !actorLib.isAgent(who)) return fail('only the PM or an agent session can change the report finder');
|
|
196
196
|
const file = RS.ledgerFile(root);
|
|
197
197
|
let r;
|
|
198
198
|
if (pos[0] === 'source') {
|
|
@@ -19,7 +19,6 @@ async function handle(req, res, url, ctx) {
|
|
|
19
19
|
const read = await ctx.readJson(req);
|
|
20
20
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
21
21
|
const body = read.body || {};
|
|
22
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot set a target. Only a press on the page does'));
|
|
23
22
|
const g = guard.requirePagePress(req, body);
|
|
24
23
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
25
24
|
const id = typeof body.ws === 'string' ? body.ws : '';
|
|
@@ -29,6 +29,9 @@
|
|
|
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
|
|
33
|
+
* (canvas XetX1Rest); `from` holds the fields as they were, so Undo is the same call with `from`
|
|
34
|
+
* POST /api/boards/tickets/note { ws, board, ref, notes } → { ok, from, notes } the PM's notes on a Jira ticket
|
|
32
35
|
* POST /api/boards/archive { ws, board, id, archived, reason? } → { ok, row } archive (hidden everywhere, kept whole) or restore;
|
|
33
36
|
* restoring a merged initiative moves its epics and tasks back
|
|
34
37
|
* POST /api/boards/merge { ws, board, id, into, epics?, tasks? } → { ok, row, into } moves the picked Jira epic links and PMOS
|
|
@@ -309,7 +312,8 @@ const wfRowFields = (x) => {
|
|
|
309
312
|
return {
|
|
310
313
|
wf: { id: x.wf.id, name: x.wf.name, icon: x.wf.icon, ...(x.own && x.own.pmos ? { setBy: 'pmos', why: x.own.why, from: x.own.from || null } : {}) },
|
|
311
314
|
wfStage: { key: st.key, name: st.name, cat: st.cat, milestone: !!st.milestone, n: st.n, of: st.of },
|
|
312
|
-
wfStages: x.stages.map((s) => ({ key: s.key, name: s.name, cat: s.cat, milestone: !!s.milestone, auto: !!s.auto, when: s.when, status: s.status, reading: s.reading
|
|
315
|
+
wfStages: x.stages.map((s) => ({ key: s.key, name: s.name, cat: s.cat, milestone: !!s.milestone, auto: !!s.auto, when: s.when, status: s.status, reading: s.reading,
|
|
316
|
+
output: s.output, finish: s.finish })), // output and finish: what finishes the stage (the stage card's exit steps on a library workflow)
|
|
313
317
|
ended: x.ended ? { as: x.ended.as, reason: x.ended.reason, note: x.ended.note, at: x.ended.at } : null,
|
|
314
318
|
};
|
|
315
319
|
};
|
|
@@ -425,19 +429,20 @@ function itemsOf(w, fr, board, rows) {
|
|
|
425
429
|
const epicKey = /^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(String((d.fm && d.fm.epic) || '')) ? String(d.fm.epic).toUpperCase() : null;
|
|
426
430
|
if (epicKey) {
|
|
427
431
|
const rd = reading(epicKey);
|
|
428
|
-
out.push({ uid: epicKey, key: epicKey, kind: 'Epic', src: 'jira', title: (rd && rd.summary) || row.title, status: B.itemStatus(rd && rd.status, rd && rd.category), blocked: !!(rd && rd.flagged), owner: null, ini: row.id, epic: null, start: null, end: null, ref: null, board: board.id });
|
|
432
|
+
out.push({ uid: epicKey, key: epicKey, kind: 'Epic', src: 'jira', title: (rd && rd.summary) || row.title, status: B.itemStatus(rd && rd.status, rd && rd.category), blocked: !!(rd && rd.flagged), owner: null, ini: row.id, epic: null, start: null, end: null, ref: null, board: board.id, readAt: (snap && snap.fetchedAt) || null });
|
|
429
433
|
jiraKeys.add(epicKey);
|
|
430
434
|
}
|
|
431
435
|
for (const t of d.tickets || []) {
|
|
432
436
|
if (!t.jira || jiraKeys.has(t.jira)) continue;
|
|
433
437
|
const rd = reading(t.jira);
|
|
434
438
|
out.push({ uid: t.jira, key: t.jira, kind: ['Story', 'Task', 'Bug'].includes(t.type) ? t.type : 'Task', src: 'jira', title: (rd && rd.summary) || t.summary || t.jira,
|
|
435
|
-
status: B.itemStatus(rd && rd.status, rd && rd.category), blocked: !!(rd && rd.flagged), owner: null, ini: row.id, epic: epicKey, start: null, end: null, ref: null, board: board.id });
|
|
439
|
+
status: B.itemStatus(rd && rd.status, rd && rd.category), blocked: !!(rd && rd.flagged), owner: null, ini: row.id, epic: epicKey, start: null, end: null, ref: null, board: board.id, readAt: (snap && snap.fetchedAt) || null });
|
|
436
440
|
jiraKeys.add(t.jira);
|
|
437
441
|
}
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
for (const t of fr.folded.tasks.values()) if (t.board === board.id && ids.has(t.initiative)) out.push(B.taskItem(t));
|
|
445
|
+
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)
|
|
441
446
|
return B.rollupItems(out);
|
|
442
447
|
}
|
|
443
448
|
|
|
@@ -447,7 +452,7 @@ function epicItems(row, board, snap, seen, out) {
|
|
|
447
452
|
if (!snap || !snap.tickets || !snap.tickets.size || !(row.epics || []).length) return;
|
|
448
453
|
const epics = row.epics.filter((k) => snap.tickets.has(k));
|
|
449
454
|
const first = epics[0] || null;
|
|
450
|
-
const item = (r, kind, epic) => ({ uid: r.key, key: r.key, kind, src: 'jira', title: r.summary || r.key, status: B.itemStatus(r.status, r.category), blocked: !!r.flagged, owner: null, ini: row.id, epic, start: null, end: null, ref: null, board: board.id });
|
|
455
|
+
const item = (r, kind, epic) => ({ uid: r.key, key: r.key, kind, src: 'jira', title: r.summary || r.key, status: B.itemStatus(r.status, r.category), blocked: !!r.flagged, owner: null, ini: row.id, epic, start: null, end: null, ref: null, board: board.id, readAt: snap.fetchedAt || null });
|
|
451
456
|
for (const k of epics) { if (!seen.has(k)) { out.push(item(snap.tickets.get(k), 'Epic', null)); seen.add(k); } }
|
|
452
457
|
for (const r of snap.tickets.values()) {
|
|
453
458
|
if (seen.has(r.key) || (r.parent && !row.epics.includes(r.parent)) || (!r.parent && r.type === 'Epic')) continue; // a reading of an epic no longer linked
|
|
@@ -971,9 +976,10 @@ const WRITES = {
|
|
|
971
976
|
if (!p) return;
|
|
972
977
|
const t = B.taskOf(p.fr.folded, body.task);
|
|
973
978
|
if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
974
|
-
|
|
979
|
+
const state = B.taskState(body.state); // the five task states; an old 'In review' is In progress
|
|
980
|
+
if (!state) return fail(ctx, res, 400, `state is one of ${B.TASK_STATES.join(', ')}`);
|
|
975
981
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
976
|
-
append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, state
|
|
982
|
+
append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, state, why: 'status move' });
|
|
977
983
|
const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
|
|
978
984
|
ctx.json(res, { ok: true, item: B.rollupItems([B.taskItem(t2)])[0] });
|
|
979
985
|
},
|
|
@@ -1000,6 +1006,43 @@ const WRITES = {
|
|
|
1000
1006
|
const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
|
|
1001
1007
|
ctx.json(res, { ok: true, from: t.title, item: B.rollupItems([B.taskItem(t2)])[0] });
|
|
1002
1008
|
},
|
|
1009
|
+
'/api/boards/tasks/edit': (ctx, res, body, g) => {
|
|
1010
|
+
// the task Viewer edits in place (canvas XetX1Rest, XetX1Dates): each change saves at once; Undo sends `from` back
|
|
1011
|
+
const p = postFrame(ctx, res, body);
|
|
1012
|
+
if (!p) return;
|
|
1013
|
+
const t = B.taskOf(p.fr.folded, body.task);
|
|
1014
|
+
if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
|
|
1015
|
+
const ev = {}, from = {};
|
|
1016
|
+
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
|
+
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 || ''; }
|
|
1018
|
+
for (const k of ['start', 'due']) if (body[k] != null) { if (body[k] !== '' && !/^\d{4}-\d{2}-\d{2}$/.test(String(body[k]))) return fail(ctx, res, 400, `${k} is a day, YYYY-MM-DD, or '' for none`); ev[k] = String(body[k]); from[k] = t[k] || ''; }
|
|
1019
|
+
if ((ev.start || t.start) && (ev.due != null ? ev.due : t.due) && (ev.start != null ? ev.start : t.start) > (ev.due != null ? ev.due : t.due)) return fail(ctx, res, 400, 'the start is after the due day');
|
|
1020
|
+
if (body.initiative != null) {
|
|
1021
|
+
if (typeof body.initiative !== 'string' || !body.initiative) return fail(ctx, res, 400, 'initiative is an initiative id');
|
|
1022
|
+
const base = needRows(ctx, res, p.w);
|
|
1023
|
+
if (!base) return;
|
|
1024
|
+
const b0 = base.find((r) => r.id === body.initiative);
|
|
1025
|
+
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
|
+
ev.initiative = body.initiative; from.initiative = t.initiative;
|
|
1027
|
+
}
|
|
1028
|
+
if (!Object.keys(ev).length) return fail(ctx, res, 400, 'nothing to change: send owner, notes, start, due or initiative');
|
|
1029
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1030
|
+
append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, ...ev, why: 'edited ' + Object.keys(ev).join(', ') });
|
|
1031
|
+
const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
|
|
1032
|
+
ctx.json(res, { ok: true, from, item: B.rollupItems([B.taskItem(t2)])[0] });
|
|
1033
|
+
},
|
|
1034
|
+
'/api/boards/tickets/note': (ctx, res, body, g) => {
|
|
1035
|
+
// the PM's own notes on a Jira ticket (canvas XetX1Jira): Jira keeps the title, status, dates and assignee
|
|
1036
|
+
const p = postFrame(ctx, res, body);
|
|
1037
|
+
if (!p) return;
|
|
1038
|
+
if (typeof body.ref !== 'string' || !B.JIRA_KEY_RE.test(body.ref)) return fail(ctx, res, 400, 'ref is a Jira key, like IDPF-2685');
|
|
1039
|
+
if (typeof body.notes !== 'string' || body.notes.length > 4000) return fail(ctx, res, 400, 'notes are text of at most 4000 characters');
|
|
1040
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1041
|
+
const ref = body.ref.toUpperCase(), from = p.fr.folded.ticketNotes.get(p.board.id + '\u0000' + ref) || '';
|
|
1042
|
+
const notes = body.notes.replace(/\s+$/, '');
|
|
1043
|
+
append(p.file, g.actor, { kind: 'ticket-note', board: p.board.id, ref, notes });
|
|
1044
|
+
ctx.json(res, { ok: true, from, notes });
|
|
1045
|
+
},
|
|
1003
1046
|
'/api/boards/tasks/reschedule': (ctx, res, body, g) => {
|
|
1004
1047
|
const p = postFrame(ctx, res, body);
|
|
1005
1048
|
if (!p) return;
|
|
@@ -1131,15 +1174,34 @@ async function handle(req, res, url, ctx) {
|
|
|
1131
1174
|
return true;
|
|
1132
1175
|
}
|
|
1133
1176
|
|
|
1134
|
-
/**
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
function
|
|
1138
|
-
let out = { status: 500, body: { ok: false, error: 'the
|
|
1177
|
+
/** One write route run outside HTTP, by the same function the page's press runs, so its validation, warnings and ledger line are the
|
|
1178
|
+
* route's own. `g` is { ok, actor }: who writes comes from the call path, never from the body. Answers { status, body } with the body the
|
|
1179
|
+
* route would send. */
|
|
1180
|
+
function writeAs(ctx, route, body, g) {
|
|
1181
|
+
let out = { status: 500, body: { ok: false, error: 'the write was not answered' } };
|
|
1139
1182
|
const cap = { ...ctx, json: (_res, obj, code) => { out = { status: code || 200, body: obj }; } };
|
|
1140
|
-
WRITES[
|
|
1183
|
+
WRITES[route](cap, null, body, g);
|
|
1141
1184
|
return out;
|
|
1142
1185
|
}
|
|
1186
|
+
/** The PM's move of one initiative, by the same function POST /api/boards/move runs (initiative initiative-driver: Keep on a
|
|
1187
|
+
* driver proposal). On a library workflow (D99) `to` is a stage key or name of the initiative's own workflow. */
|
|
1188
|
+
function move(ctx, body, g) { return writeAs(ctx, '/api/boards/move', body, g); }
|
|
1189
|
+
/** A switch of the initiative's workflow, by the same function POST /api/boards/ini-wf runs. body: { ws, board, id, wf, to?, why? }. */
|
|
1190
|
+
function switchWorkflow(ctx, body, g) { return writeAs(ctx, '/api/boards/ini-wf', body, g); }
|
|
1191
|
+
|
|
1192
|
+
/** 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
|
|
1193
|
+
* 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
|
|
1194
|
+
* initiative's workflow moved task stages instead). → { ok, board, row } | { ok: false, pending?, status, error } */
|
|
1195
|
+
function initiativeWorkflow(ctx, w, id) {
|
|
1196
|
+
const fr = frameFor(ctx, w);
|
|
1197
|
+
const b = baseRows(w);
|
|
1198
|
+
if (b.pending) return { ok: false, pending: true, status: 202, error: PENDING };
|
|
1199
|
+
if (!b.ok) return { ok: false, status: 500, error: b.error };
|
|
1200
|
+
const b0 = b.rows.find((r) => r.id === id);
|
|
1201
|
+
if (!b0) return { ok: false, status: 404, error: `no initiative ${id} on a board of this workspace` };
|
|
1202
|
+
const board = fr.boards.find((x) => x.id === boardIdOf(b0, fr.boards, fr.folded, w));
|
|
1203
|
+
return { ok: true, board, row: boardRow(board, b0, fr.folded) };
|
|
1204
|
+
}
|
|
1143
1205
|
|
|
1144
1206
|
/** The board of each initiative of a workspace, for other routes (Reports): { boards: [{ id, title }], of(id) → board id }.
|
|
1145
1207
|
* Rows still being read fall back to the ledger's assignment, else the default board. */
|
|
@@ -1205,4 +1267,4 @@ function meetingBoards(ctx) {
|
|
|
1205
1267
|
return { list, detail };
|
|
1206
1268
|
}
|
|
1207
1269
|
|
|
1208
|
-
module.exports = { prefixes: ['/api/boards'], handle, move, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
1270
|
+
module.exports = { prefixes: ['/api/boards'], handle, move, switchWorkflow, initiativeWorkflow, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
@@ -54,9 +54,24 @@ const rootOf = (url, ctx) => {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
/** The PM's own calls (initiative briefing-premium-writes). Each appends one record and answers with the rebuilt model. */
|
|
57
|
+
/** An initiative chat's workflow and stage (lib/initiative-chat.js infoOf), from the Board's own row (lib/routes-boards.js initiativeWorkflow):
|
|
58
|
+
* the chat's workspace first, then the others (Home opens initiatives of other products too). null while the rows are being read. */
|
|
59
|
+
function iniInfoOf(ctx, key, wsId) {
|
|
60
|
+
const id = String(key || '').replace(/^init:/, '').replace(/:\d+$/, '');
|
|
61
|
+
if (!/^init:/.test(String(key || '')) || !id) return null;
|
|
62
|
+
const Boards = require('./routes-boards.js');
|
|
63
|
+
const IniChat = require('./initiative-chat.js');
|
|
64
|
+
const list = ctx.workspaceList ? ctx.workspaceList() : [];
|
|
65
|
+
const first = wsId && ctx.getWs ? ctx.getWs(wsId) : null;
|
|
66
|
+
for (const w of [first, ...list.filter((x) => !first || x.id !== first.id)].filter(Boolean)) {
|
|
67
|
+
let a; try { a = Boards.initiativeWorkflow(ctx, w, id); } catch { a = null; }
|
|
68
|
+
if (a && a.ok) return IniChat.infoOf(a);
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
async function post(req, res, url, ctx) {
|
|
58
74
|
const act = url.pathname.slice('/api/briefing-premium/'.length);
|
|
59
|
-
if (req.headers && req.headers['x-pmos-session']) { ctx.json(res, { ok: false, error: 'an agent session cannot record the PM\'s decision' }, 403); return true; }
|
|
60
75
|
const got = await ctx.readJson(req);
|
|
61
76
|
if (!got.ok) { ctx.json(res, { ok: false, error: 'body must be JSON' }, 400); return true; }
|
|
62
77
|
const b = got.body;
|
|
@@ -95,14 +110,15 @@ async function post(req, res, url, ctx) {
|
|
|
95
110
|
// premium-chat-attach A5: the files a message names must be saved files of its conversation; one closing line names each for Claude
|
|
96
111
|
const att = Files.pathsOf({ runtimeDir, key: b.key, names: b.files });
|
|
97
112
|
if (!att.ok) { ctx.json(res, { ok: false, error: att.error }, att.status); return true; }
|
|
98
|
-
const a = (ctx.chatSessions ? Ag.chat : Ag.ask)({ runtimeDir, key: b.key, text: Files.withFiles(b.text, att.paths), context: b.context, sessions: ctx.chatSessions, model: /^work:/.test(String(b.key || '')) ? WP.peekModel() : /^board:/.test(String(b.key || '')) ? BoardP.peekModel() : /^ins:/.test(String(b.key || '')) ? InsP.peekModel() : /^(init|doc):/.test(String(b.key || '')) ? InitP.peekModel() : sk || (/^src:/.test(String(b.key || '')) && !(b.key === 'src:this-page' && url.searchParams.get('ws'))) ? Prod.peekModel() : BP.peekModel(root), spawnSession: ctx.spawnSession, wsId });
|
|
113
|
+
const a = (ctx.chatSessions ? Ag.chat : Ag.ask)({ runtimeDir, key: b.key, text: Files.withFiles(b.text, att.paths), context: b.context, sessions: ctx.chatSessions, model: /^work:/.test(String(b.key || '')) ? WP.peekModel() : /^board:/.test(String(b.key || '')) ? BoardP.peekModel() : /^ins:/.test(String(b.key || '')) ? InsP.peekModel() : /^(init|doc):/.test(String(b.key || '')) ? InitP.peekModel() : sk || (/^src:/.test(String(b.key || '')) && !(b.key === 'src:this-page' && url.searchParams.get('ws'))) ? Prod.peekModel() : BP.peekModel(root), spawnSession: ctx.spawnSession, wsId, iniInfo: () => iniInfoOf(ctx, b.key, wsId) });
|
|
99
114
|
ctx.json(res, a.body, a.status);
|
|
100
115
|
return true;
|
|
101
116
|
}
|
|
102
117
|
let r;
|
|
118
|
+
const agentBy = actor.isAgent(g.actor) ? actor.pageName(g.actor.by) : undefined; // D98: an agent's decision names it
|
|
103
119
|
try {
|
|
104
|
-
if (act === 'decide') r = Wr.decide({ root, key: sk ? sk.base : b.key, choice: b.choice, why: b.why });
|
|
105
|
-
else if (act === 'put-off') r = Wr.putOff({ runtimeDir, key: b.key, until: b.until });
|
|
120
|
+
if (act === 'decide') r = Wr.decide({ root, key: sk ? sk.base : b.key, choice: b.choice, why: b.why, by: agentBy });
|
|
121
|
+
else if (act === 'put-off') r = Wr.putOff({ runtimeDir, key: b.key, until: b.until, by: agentBy });
|
|
106
122
|
else r = Wr.returnRun({ root, runtimeDir, run: b.run, reason: b.reason, correctionEvent, appendOutbox });
|
|
107
123
|
} catch (e) { r = { ok: false, status: 500, error: 'the record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
108
124
|
if (!r.ok) { ctx.json(res, { ok: false, error: r.error }, r.status || 400); return true; }
|
|
@@ -140,7 +156,6 @@ async function chatFile(req, res, url, ctx) {
|
|
|
140
156
|
return true;
|
|
141
157
|
}
|
|
142
158
|
if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
|
|
143
|
-
if (req.headers && req.headers['x-pmos-session']) { ctx.json(res, { ok: false, error: 'an agent session cannot attach a file to the PM\'s message' }, 403); return true; }
|
|
144
159
|
const g = guard.requirePagePress(req, {});
|
|
145
160
|
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
|
|
146
161
|
if (url.pathname === '/api/chat-file/notes' || url.pathname === '/api/chat-file/notes/remove') { // premium-chat-notes: save or delete one note
|
|
@@ -204,7 +219,6 @@ module.exports = {
|
|
|
204
219
|
if (url.pathname === '/api/briefing-premium/seen') {
|
|
205
220
|
// popup context slice 3b: a popup the PM opened, with what it showed, so the leads session after a refresh writes its lead. Starts nothing.
|
|
206
221
|
if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
|
|
207
|
-
if (req.headers && req.headers['x-pmos-session']) { ctx.json(res, { ok: false, error: 'an agent session cannot record what the PM opened' }, 403); return true; }
|
|
208
222
|
const got = await ctx.readJson(req);
|
|
209
223
|
if (!got.ok || !got.body || typeof got.body !== 'object') { ctx.json(res, { ok: false, error: 'body must be JSON' }, 400); return true; }
|
|
210
224
|
const g = guard.requirePagePress(req, got.body);
|
|
@@ -52,11 +52,13 @@ const isRunning = (ws) => (scope, key) => runs.has(runKey(ws, scope, key));
|
|
|
52
52
|
function resolve(ctx, w, scope, key, now) {
|
|
53
53
|
const p = CD.parseScope(scope);
|
|
54
54
|
if (!p) return { ok: false, status: 400, error: 'scope must be portfolio, board:<id> or initiative:<id>' };
|
|
55
|
-
|
|
55
|
+
let entry = CD.entryOf(p.level, key);
|
|
56
56
|
if (!entry) return { ok: false, status: 400, error: `no core document ${String(key).slice(0, 40)} at the ${p.level} level` };
|
|
57
57
|
const g = CD.gather(ctx, w, { level: p.level, board: p.level === 'board' ? p.id : null, id: p.level === 'initiative' ? p.id : null, now });
|
|
58
58
|
if (g.pending) return { ok: false, status: 202, error: 'The initiatives are being read. Ask again in a few seconds.' };
|
|
59
59
|
if (!g.ok) return g;
|
|
60
|
+
// D99: the initiative's own set holds the full entry (a workflow stage's document carries its name, stage and template)
|
|
61
|
+
if (p.level === 'initiative') { const hit = g.facts.list.find((x) => x.entry.key === key); if (hit) entry = hit.entry; }
|
|
60
62
|
return { ok: true, entry, facts: g.facts, level: p.level, id: p.id };
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -199,7 +201,6 @@ async function handle(req, res, url, ctx) {
|
|
|
199
201
|
const read = await ctx.readJson(req);
|
|
200
202
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
201
203
|
const body = read.body || {};
|
|
202
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot draft, issue or drop a core document. Only a press on the page does'));
|
|
203
204
|
const g = sub === 'draft' ? guard.requirePagePress(req, body) : guard.requirePmPress(req, body, { act: 'issue' });
|
|
204
205
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
205
206
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -44,7 +44,6 @@ async function handle(req, res, url, ctx) {
|
|
|
44
44
|
const read = await ctx.readJson(req);
|
|
45
45
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
46
46
|
const body = read.body || {};
|
|
47
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot add a document. Only a press on the page does'));
|
|
48
47
|
const g = guard.requirePagePress(req, body);
|
|
49
48
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
50
49
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -118,7 +118,6 @@ async function handle(req, res, url, ctx) {
|
|
|
118
118
|
const read = await ctx.readJson(req);
|
|
119
119
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
120
120
|
const body = read.body;
|
|
121
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot keep, send back, drop, pause or change the mode of the driver'));
|
|
122
121
|
const g = guard.requirePagePress(req, body);
|
|
123
122
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
124
123
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* · seen and queued are the PM's per-machine marks, so they are runtime state: <runtime>/home/seen.jsonl, <runtime>/home/queued.jsonl
|
|
16
16
|
* · recipients, sent updates and stakeholders are product records, so they go in the workspace's state folder (stateDirFor):
|
|
17
17
|
* <state>/product-updates.jsonl and <state>/stakeholders.jsonl. The last line for a key wins when read back.
|
|
18
|
-
* Every POST is a page press (pm-guard requirePagePress): an agent session
|
|
18
|
+
* Every POST is a page press (pm-guard requirePagePress): an agent session writes these too, under its own name (D98). Nothing here sends mail, Slack or
|
|
19
19
|
* anything else: Send on the weekly update opens a mail draft in the PM's own mail app, and this route only records that it was opened. */
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const guard = require('./pm-guard.js');
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* FILE MODE ONLY, append-only JSONL (D64/D66): <state>/weekly-review.jsonl in the workspace's state folder (stateDirFor). Nothing is
|
|
14
14
|
* rewritten; the last line for a step or an initiative in a week wins when read back. Every POST is a page press (pm-guard
|
|
15
|
-
* requirePagePress): an agent session
|
|
15
|
+
* requirePagePress): an agent session writes it too, under its own name (D98). Nothing here sends anything to anyone. */
|
|
16
16
|
const path = require('path');
|
|
17
17
|
const guard = require('./pm-guard.js');
|
|
18
18
|
const pmItems = require('./pm-items.js');
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* → the same answer as GET, after the line is written
|
|
10
10
|
*
|
|
11
11
|
* FILE MODE ONLY, append-only JSONL (D64/D66): <state>/initiative-layout.jsonl in the workspace's state folder (stateDirFor).
|
|
12
|
-
* Every POST is a page press (pm-guard requirePagePress): an agent session
|
|
12
|
+
* Every POST is a page press (pm-guard requirePagePress): an agent session writes it too, under its own name (D98). */
|
|
13
13
|
const path = require('path');
|
|
14
14
|
const guard = require('./pm-guard.js');
|
|
15
15
|
const pmItems = require('./pm-items.js');
|
|
@@ -57,7 +57,6 @@ async function handle(req, res, url, ctx) {
|
|
|
57
57
|
const read = await ctx.readJson(req);
|
|
58
58
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
59
59
|
const body = read.body || {};
|
|
60
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change Insights. Only a press on the page does'));
|
|
61
60
|
const g = guard.requirePagePress(req, body);
|
|
62
61
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
63
62
|
const w = dashRoutes.wsOf(ctx, text(body.ws));
|
|
@@ -150,7 +150,6 @@ async function file(req, res, url, ctx) {
|
|
|
150
150
|
return true;
|
|
151
151
|
}
|
|
152
152
|
if (req.method !== 'POST') return respond(ctx, res, fail(405, 'GET or POST only'));
|
|
153
|
-
if (req.headers && req.headers['x-pmos-session']) return respond(ctx, res, fail(403, 'an agent session cannot add material to a meeting'));
|
|
154
153
|
const g = guard.requirePagePress(req, {});
|
|
155
154
|
if (!g.ok) return respond(ctx, res, fail(g.status, g.error));
|
|
156
155
|
const raw = await readRaw(req, files.MAX_BYTES);
|
|
@@ -34,9 +34,11 @@ const today = () => new Date().toISOString().slice(0, 10);
|
|
|
34
34
|
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
35
35
|
const len = (v) => (Array.isArray(v) ? v.length : Number(v) || 0);
|
|
36
36
|
|
|
37
|
-
/** pm:<slug> from the press becomes human:<slug> for the onboarding ledger
|
|
37
|
+
/** pm:<slug> from the press becomes human:<slug> for the onboarding ledger; an agent session keeps its agent:… (D98).
|
|
38
|
+
* Null for anything else. */
|
|
38
39
|
function humanOf(actor) {
|
|
39
40
|
const by = actor && typeof actor.by === 'string' ? actor.by : '';
|
|
41
|
+
if (/^agent:(?:unknown|sess-\d+\.[0-9a-f]{8})$/.test(by)) return { by, via: actor.via || 'ui' };
|
|
40
42
|
return /^pm:[a-z0-9_-]{1,40}$/.test(by) ? { by: 'human:' + by.slice(3), via: actor.via || 'ui' } : null;
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -33,7 +33,6 @@ async function handle(req, res, url, ctx) {
|
|
|
33
33
|
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
34
34
|
const read = await ctx.readJson(req);
|
|
35
35
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
36
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot stop or resume the orchestrator'));
|
|
37
36
|
const g = guard.requirePagePress(req, read.body);
|
|
38
37
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
39
38
|
const r = o.gate.setStopped(sub === 'stop', actorLib.pageName ? actorLib.pageName(g.actor) : 'pm');
|
|
@@ -22,7 +22,6 @@ async function handle(req, res, url, ctx) {
|
|
|
22
22
|
const read = await ctx.readJson(req);
|
|
23
23
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
24
24
|
const body = read.body || {};
|
|
25
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a chart. Only a press on the page does'));
|
|
26
25
|
const g = guard.requirePagePress(req, body);
|
|
27
26
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
28
27
|
const w = wsOf(ctx, typeof body.ws === 'string' ? body.ws : '');
|
|
@@ -42,7 +42,6 @@ async function handle(req, res, url, ctx) {
|
|
|
42
42
|
const read = await ctx.readJson(req);
|
|
43
43
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
44
44
|
const body = read.body || {};
|
|
45
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a dashboard. Only a press on the page does'));
|
|
46
45
|
const g = guard.requirePagePress(req, body);
|
|
47
46
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
48
47
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
* POST /api/programs/check { program, milestone, done } the PM marks a program check (a milestone that waits on no initiative) done or
|
|
12
12
|
* not; the line goes to the workspace the charter is in, whatever `ws` says
|
|
13
13
|
* POST /api/programs/archive { ws, program }
|
|
14
|
+
* POST /api/programs/order { program, order: [initiative id] } the PM's sequence of the program's initiatives (drag, or Claude's order
|
|
15
|
+
* from the dates applied); like a check line it goes to the charter's workspace.
|
|
16
|
+
* The answer holds `was`, the order before, so the page's Undo writes it back
|
|
14
17
|
*
|
|
15
18
|
* FILE MODE ONLY (D64/D66): <state>/programs.jsonl of the workspace named by `ws`, append-only. Every POST is a page press (pm-guard
|
|
16
|
-
* requirePagePress): an agent session
|
|
19
|
+
* requirePagePress): an agent session may make, join or archive a program too (D98). Nothing here writes to Jira. */
|
|
17
20
|
const path = require('path');
|
|
18
21
|
const guard = require('./pm-guard.js');
|
|
19
22
|
const pmItems = require('./pm-items.js');
|
|
@@ -54,7 +57,7 @@ module.exports = {
|
|
|
54
57
|
const g = guard.requirePagePress(req, b);
|
|
55
58
|
if (!g.ok) return bad(g.error, g.status);
|
|
56
59
|
// a check line belongs with the charter, so every workspace's reader applies it to the same milestones
|
|
57
|
-
const home = p === '/api/programs/check' && P.ID_RE.test(String(b.program || '')) ? (all(ctx).find((x) => x.id === b.program) || {}).home : null;
|
|
60
|
+
const home = (p === '/api/programs/check' || p === '/api/programs/order') && P.ID_RE.test(String(b.program || '')) ? (all(ctx).find((x) => x.id === b.program) || {}).home : null;
|
|
58
61
|
const w = ctx.getWs ? ctx.getWs(home || b.ws || null) : null;
|
|
59
62
|
if (!w) return bad('that workspace is not registered', 404);
|
|
60
63
|
const file = fileOf(ctx, w);
|
|
@@ -117,6 +120,14 @@ module.exports = {
|
|
|
117
120
|
ctx.json(res, { ok: true, program: known(pid) });
|
|
118
121
|
return true;
|
|
119
122
|
}
|
|
123
|
+
if (p === '/api/programs/order') {
|
|
124
|
+
const v = P.validOrder(b.order);
|
|
125
|
+
if (v.error) return bad(v.error);
|
|
126
|
+
const was = known(pid).order || [];
|
|
127
|
+
add({ kind: 'order', program: pid, order: v });
|
|
128
|
+
ctx.json(res, { ok: true, was, program: known(pid) });
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
120
131
|
if (p === '/api/programs/archive') {
|
|
121
132
|
add({ kind: 'archive', program: pid });
|
|
122
133
|
ctx.json(res, { ok: true });
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* POST /api/records/kr-metrics/reading { rid, at, value } → { ok } one actual reading of a KR metric
|
|
8
8
|
*
|
|
9
9
|
* STATE: planning/records/<kind>.jsonl, written only through scripts/records (which uses scripts/trust/ledger.js).
|
|
10
|
-
* WHO WRITES: every POST passes pm-guard requirePagePress; an agent session
|
|
10
|
+
* WHO WRITES: every POST passes pm-guard requirePagePress; an agent session adds and edits them too, under its own name (D98).
|
|
11
11
|
*/
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const guard = require('./pm-guard.js');
|
|
@@ -384,6 +384,11 @@ function rememberStudio(ctx, w, id) {
|
|
|
384
384
|
return true;
|
|
385
385
|
} catch { return false; }
|
|
386
386
|
}
|
|
387
|
+
/** Who a note line names: 'pm', or an agent session's page name (D98; never its token). */
|
|
388
|
+
const logBy = (a) => {
|
|
389
|
+
const m = a && typeof a.by === 'string' ? /^(agent:(?:unknown|sess-\d+))/.exec(a.by) : null;
|
|
390
|
+
return m ? m[1] : 'pm';
|
|
391
|
+
};
|
|
387
392
|
function editLog(ctx, row) {
|
|
388
393
|
if (!ctx.runtimeDir) return false;
|
|
389
394
|
try {
|
|
@@ -484,7 +489,6 @@ async function handle(req, res, url, ctx) {
|
|
|
484
489
|
const read = await ctx.readJson(req);
|
|
485
490
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
486
491
|
const body = read.body || {};
|
|
487
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a report design, its cycles or its notes. Only a press on the page does'));
|
|
488
492
|
const g = guard.requirePagePress(req, body);
|
|
489
493
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
490
494
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -500,7 +504,7 @@ async function handle(req, res, url, ctx) {
|
|
|
500
504
|
} else {
|
|
501
505
|
const r = D.pinOp(root, d.c.rel, body, { by: 'you' });
|
|
502
506
|
if (!r.ok) return fail(r);
|
|
503
|
-
editLog(ctx, { event: 'pin', path: d.c.rel, by:
|
|
507
|
+
editLog(ctx, { event: 'pin', path: d.c.rel, by: logBy(g.actor), op: r.op, id: r.pin.id, slide: r.pin.slide, text: r.pin.text, ...(r.pin.section ? { section: r.pin.section } : {}) });
|
|
504
508
|
}
|
|
505
509
|
return send({ status: 200, body: D.notesOf(root, d.c.rel) });
|
|
506
510
|
}
|
|
@@ -534,7 +538,7 @@ async function handle(req, res, url, ctx) {
|
|
|
534
538
|
const r = D.decideCycle(root, c.rel, { diff: diff.id, choice, newVersion });
|
|
535
539
|
if (!r.ok) return fail(r);
|
|
536
540
|
D.append(root, c.cadence, { ev: 'cycle-decision', path: c.rel, slot: c.slot, diff: diff.id, choice }, { actor: g.actor });
|
|
537
|
-
editLog(ctx, { event: 'design', path: c.rel, by:
|
|
541
|
+
editLog(ctx, { event: 'design', path: c.rel, by: logBy(g.actor), choice, diff: diff.id, what: diff.what });
|
|
538
542
|
return send({ status: 200, body: { ...cycleAnswer(w, c), cycle: r.cycle } });
|
|
539
543
|
}
|
|
540
544
|
|
|
@@ -309,7 +309,6 @@ async function handle(req, res, url, ctx) {
|
|
|
309
309
|
const read = await ctx.readJson(req);
|
|
310
310
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
311
311
|
const body = read.body || {};
|
|
312
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot set up, change or dismiss a report. Only a press on the page does'));
|
|
313
312
|
const g = guard.requirePagePress(req, body);
|
|
314
313
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
315
314
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -697,7 +697,6 @@ async function handle(req, res, url, ctx) {
|
|
|
697
697
|
const read = await ctx.readJson(req);
|
|
698
698
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
699
699
|
const body = read.body || {};
|
|
700
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a report structure, add a source, start a check or save a chart. Only a press on the page does'));
|
|
701
700
|
const g = guard.requirePagePress(req, body);
|
|
702
701
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
703
702
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const guard = require('./pm-guard.js');
|
|
14
|
-
const actor = require('./actor.js');
|
|
15
14
|
const runAnswers = require('./run-answers.js');
|
|
16
15
|
const { repoScript } = require('./repo-script.js');
|
|
17
16
|
const { groupSessions } = require(repoScript('sessions-list.js'));
|
|
@@ -126,9 +125,7 @@ async function handle(req, res, url, ctx) {
|
|
|
126
125
|
const got = await ctx.readJson(req);
|
|
127
126
|
if (!got.ok) { ctx.json(res, { ok: false, error: 'body must be JSON' }, 400); return true; }
|
|
128
127
|
const body = got.body;
|
|
129
|
-
const
|
|
130
|
-
if (tok) { ctx.json(res, { ok: false, error: 'an agent session cannot answer a run' }, 403); return true; }
|
|
131
|
-
const g = guard.requirePagePress(req, body);
|
|
128
|
+
const g = guard.requirePagePress(req, body); // D98: an agent session may answer too; g.actor names it
|
|
132
129
|
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
|
|
133
130
|
if (p === '/api/runs/answer') {
|
|
134
131
|
// An answer to the agent's own question must be one of the options it offered (the contract's answerLine).
|
|
@@ -140,7 +137,7 @@ async function handle(req, res, url, ctx) {
|
|
|
140
137
|
if (al.error) { ctx.json(res, { ok: false, error: al.error }, 400); return true; }
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
|
-
const r = runAnswers.recordAnswer(runAnswers.answersFile(ctx.runtimeDir), body, actor
|
|
140
|
+
const r = runAnswers.recordAnswer(runAnswers.answersFile(ctx.runtimeDir), body, g.actor);
|
|
144
141
|
ctx.json(res, r.ok ? { ok: true } : { ok: false, error: r.error }, r.ok ? 200 : r.status);
|
|
145
142
|
return true;
|
|
146
143
|
}
|
|
@@ -190,7 +190,6 @@ async function handle(req, res, url, ctx) {
|
|
|
190
190
|
const read = await ctx.readJson(req);
|
|
191
191
|
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
192
192
|
const body = read.body;
|
|
193
|
-
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change the watch list, the scan setting or a proposal, start a scan or stop one'));
|
|
194
193
|
const g = guard.requirePagePress(req, body);
|
|
195
194
|
if (!g.ok) return send(bad(g.status, g.error));
|
|
196
195
|
const w = wsOf(ctx, text(body.ws));
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Briefing from those reads (briefing-source-flow, slice 3); a press while one runs joins it
|
|
12
12
|
* POST /api/sources/watch { ws, on } → { ok, watch } the change detector on or off for this repository
|
|
13
13
|
*
|
|
14
|
-
* Both POSTs pass pm-guard requirePagePress: the
|
|
14
|
+
* Both POSTs pass pm-guard requirePagePress: the press from the page (an agent session's too, D98), which may start a refresh or
|
|
15
15
|
* switch the detector off. A refresh of `repository` or `initiatives` rebuilds the facts in a child process; a refresh of
|
|
16
16
|
* an external source starts that source's skill as a session in the workspace, with the PM's own connections. The server
|
|
17
17
|
* itself calls nothing outside this machine.
|