create-pmos 0.423.0 → 0.425.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/board-programs-test.js +41 -26
- package/workspace/briefing-premium-board-test.js +7 -4
- package/workspace/briefing-premium-insights-test.js +31 -15
- package/workspace/briefing-premium-products-test.js +62 -46
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +3 -2
- package/workspace/guide/claude-proposes.md +37 -0
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +2 -0
- package/workspace/guide/notes.md +39 -1
- package/workspace/guide/present-in-a-meeting.md +57 -0
- package/workspace/guide/programs.md +2 -2
- package/workspace/home-pill-test.js +138 -0
- package/workspace/lib/briefing-premium-products.js +18 -4
- package/workspace/lib/headless.js +14 -1
- package/workspace/lib/meeting-focus.js +64 -14
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/proposal-runs.js +148 -0
- package/workspace/lib/proposals.js +370 -0
- package/workspace/lib/propose-cli.js +96 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-board-premium.js +11 -0
- package/workspace/lib/routes-boards.js +1 -1
- package/workspace/lib/routes-briefing-premium.js +19 -0
- package/workspace/lib/routes-meeting-focus.js +28 -6
- package/workspace/lib/routes-proposals.js +325 -0
- package/workspace/lib/routes-task-links.js +35 -28
- package/workspace/lib/settings-store.js +2 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/premium-briefing-depth-test.js +1 -1
- package/workspace/premium-rec-now-test.js +153 -0
- package/workspace/premium-rec-tab-test.js +167 -0
- package/workspace/public/pm/bd-asks.js +3 -0
- package/workspace/public/pm/cozy-aud.css +9 -0
- package/workspace/public/pm/cozy-aud.js +80 -0
- package/workspace/public/pm/cozy-live-pill.js +3 -0
- package/workspace/public/pm/cozy-pick.css +41 -0
- package/workspace/public/pm/cozy-pick.js +134 -0
- package/workspace/public/pm/cozy-rec-bridge.js +32 -0
- package/workspace/public/pm/cozy-rec-now.css +104 -0
- package/workspace/public/pm/cozy-rec-now.js +330 -0
- package/workspace/public/pm/cozy-rec-present.css +69 -0
- package/workspace/public/pm/cozy-rec-present.js +467 -0
- package/workspace/public/pm/cozy-rec-tab.css +90 -0
- package/workspace/public/pm/cozy-rec-tab.js +219 -0
- package/workspace/public/pm/cozy-settings.js +8 -2
- package/workspace/public/pm/cozy-today.css +23 -0
- package/workspace/public/pm/cozy-viewer.js +14 -3
- package/workspace/public/pm/cozy-vw-shell.css +8 -0
- package/workspace/public/pm/home-app.js +56 -27
- package/workspace/public/pm/home-list.js +17 -10
- package/workspace/public/pm/home-more.js +2 -31
- package/workspace/public/pm/home-task.js +2 -1
- package/workspace/public/pm/home-today.js +69 -19
- package/workspace/public/pm/ini-groups.js +30 -5
- package/workspace/public/pm/ini-links.js +6 -48
- package/workspace/public/pm/ini-props.js +218 -0
- package/workspace/public/pm/ini-view-model.js +6 -1
- package/workspace/public/pm/ini-view.css +47 -0
- package/workspace/public/pm/ini-view.js +23 -6
- package/workspace/public/pm/live-model.js +1 -1
- package/workspace/public/pm/premium-board.js +56 -25
- package/workspace/public/pm/premium-insights.js +42 -24
- package/workspace/public/pm/premium-meeting.js +17 -4
- package/workspace/public/pm/premium-mtg-present.js +4 -3
- package/workspace/public/pm/premium-report-read.js +2 -0
- package/workspace/public/pm/premium-vw-item.js +2 -1
- package/workspace/public/pm/premium-vw-mtg.js +15 -7
- package/workspace/public/pm/rec-state.js +13 -5
- package/workspace/public/pm/rec-tab-core.js +92 -0
- package/workspace/public/pm/task-card.css +13 -0
- package/workspace/public/pm/task-card.js +37 -2
- package/workspace/public/pm/view-notes.js +9 -0
- package/workspace/public/premium-aud.html +22 -0
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-insights.html +2 -1
- package/workspace/public/premium-rec.html +30 -0
- package/workspace/public/premium.html +1 -0
- package/workspace/rec-present-test.js +229 -0
- package/workspace/server.js +46 -3
- package/workspace/skills/initiative-propose.skill +45 -0
- package/workspace/stage-card-test.js +1 -1
- package/workspace/task-links-test.js +26 -14
- package/workspace/test-lists/claude-proposes.json +5 -0
- package/workspace/test-lists/home-sessions-pill.json +6 -0
- package/workspace/test-lists/rec-now.json +6 -0
- package/workspace/test-lists/rec-present.json +13 -0
- package/workspace/test-lists/recording-tab.json +13 -0
- package/workspace/tk-tasks-test.js +13 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* routes-meeting-focus.js — the Meeting focus page's server side (initiative c3-meeting-focus; lib/route-modules.js).
|
|
3
3
|
*
|
|
4
4
|
* GET /api/meeting-focus?event=<id>&date=YYYY-MM-DD[&ws=]
|
|
5
|
-
* → { ok, now_ms, event, brief, material, note, topics, current, runs, tail, captured, gist, chips, notes, asks, companion }
|
|
5
|
+
* → { ok, now_ms, event, brief, material, note, topics, current, runs, tail, captured, gist, chips, notes, raise, asks, companion }
|
|
6
6
|
* The meeting (the calendar read for that day), its brief (lib/calendar-layers.js briefOf), the note linked to it, the last
|
|
7
7
|
* minutes of that note's transcript with who said them, the decisions, actions and questions so far, and the companion's state.
|
|
8
8
|
* An unknown meeting is a 404. The read also starts the companion when lib/meeting-focus.js shouldRun says it may: the note
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* (lib/meeting-focus.js pickNow). It reads the same calendar as the read above and writes nothing.
|
|
14
14
|
* POST /api/meeting-focus/topic { event | note, date?, action: 'set'|'add'|'park', topic } page press; the PM's correction, appended to the state
|
|
15
15
|
* POST /api/meeting-focus/ask { event, note?, date?, question } page press; one headless read-only run with the PM's question
|
|
16
|
+
* POST /api/meeting-focus/raise { event | note, date?, id, action: 'raised'|'skip' } page press; the PM's ✓ or ✗ on a Raise now item (the recording tab's Now panel)
|
|
16
17
|
* GET /api/meeting-focus/ask?id= → { ok, id, state: working | answered | failed, error? } the answer itself comes back as a note in GET /api/meeting-focus
|
|
17
18
|
*
|
|
18
19
|
* The companion runs as origin `focus-companion:<key>` (lib/headless.js 'ask': Read, Glob and Grep only). It sends nothing to anyone and
|
|
19
|
-
* writes nothing
|
|
20
|
+
* writes nothing. It reads the talk, the brief and the text of the latest shots of the shared screen (never a private note's). Its answer is parsed here and appended to <runtimeDir>/focus/<note id or event id>.jsonl. Handlers are pure over
|
|
20
21
|
* (req, body, ctx): ctx = { runtimeDir, spawnSession, w, readEvents?, briefFor?, env?, now? }, so a test needs no server.
|
|
21
22
|
*/
|
|
22
23
|
const fs = require('fs');
|
|
@@ -137,11 +138,18 @@ function settleRun(ctx, key, done, now) {
|
|
|
137
138
|
return append(ctx.runtimeDir, key + '.jsonl', F.outLine(parsed, at));
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
/** The shots of the shared screen the companion may read: none for a private note. */
|
|
142
|
+
function framesOf(runtimeDir, note) {
|
|
143
|
+
if (!note || note.private) return [];
|
|
144
|
+
try { return require('./notes-screen.js').list(runtimeDir, note.id); } catch { return []; }
|
|
145
|
+
}
|
|
140
146
|
function inputFor(ctx, ev, brief, note, state, topics, question) {
|
|
141
147
|
const now = ctx.nowMs;
|
|
142
148
|
const names = new Map(state.topics.map((t) => [t.id, t.text]));
|
|
149
|
+
const frames = framesOf(ctx.runtimeDir, note);
|
|
143
150
|
return { event: ev, brief: brief || {}, topics: state.topics.length ? state.topics : topics, current: state.current ? names.get(state.current) : null,
|
|
144
|
-
tail: note ? F.tailOf(note, { now }) : [], earlier: state.notes, question: question || null, now
|
|
151
|
+
tail: note ? F.tailOf(note, { now }) : [], earlier: state.notes, question: question || null, now,
|
|
152
|
+
screen: F.screenOf(frames), shots: frames.length, raised: state.raised || [] };
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
function startRun(ctx, key, ev, brief, note, state, topics, now) {
|
|
@@ -206,7 +214,7 @@ async function read(q, ctx) {
|
|
|
206
214
|
note: note ? { id: note.id, title: note.title || ev.title, state: note.state, recorded_from: note.recorded_from || null, lines: (note.transcript || []).length, sessions } : null,
|
|
207
215
|
topics: fresh.topics, current: fresh.current, runs: fresh.runs,
|
|
208
216
|
tail: note ? F.tailOf(note, { now: nowMs }) : [], captured: F.capturedFrom(note),
|
|
209
|
-
gist: fresh.gist, chips: fresh.chips, notes: fresh.notes, asks: fresh.asks,
|
|
217
|
+
gist: fresh.gist, chips: fresh.chips, notes: fresh.notes, raise: fresh.raise, asks: fresh.asks,
|
|
210
218
|
companion: { on: !F.off(env) && kindOk() && typeof ctx.spawnSession === 'function', running: !!fresh.pending, started, reason: call.reason, last_run_at: fresh.last_run_at || null, error: fresh.error },
|
|
211
219
|
} };
|
|
212
220
|
}
|
|
@@ -235,6 +243,20 @@ async function topic(req, body, ctx) {
|
|
|
235
243
|
append(ctx.runtimeDir, key.key + '.jsonl', F.moveLine(action, text, now));
|
|
236
244
|
return { status: 200, body: { ok: true, key: key.key } };
|
|
237
245
|
}
|
|
246
|
+
/* ── POST /api/meeting-focus/raise ────────────────────────────────────────────────────────────────────────────────── */
|
|
247
|
+
|
|
248
|
+
async function raise(req, body, ctx) {
|
|
249
|
+
const g = guard.requirePagePress(req, body); if (!g.ok) return fail(g.status, g.error);
|
|
250
|
+
const action = String(body.action || '');
|
|
251
|
+
if (!['raised', 'skip'].includes(action)) return fail(400, 'action must be raised or skip');
|
|
252
|
+
const id = F.str(body.id, 80);
|
|
253
|
+
if (!id) return fail(400, 'id is required');
|
|
254
|
+
const key = await keyFromBody(body, ctx); if (key.error) return key.error;
|
|
255
|
+
const now = typeof ctx.now === 'function' ? ctx.now() : Date.now();
|
|
256
|
+
append(ctx.runtimeDir, key.key + '.jsonl', F.raiseLine(id, action, now));
|
|
257
|
+
return { status: 200, body: { ok: true, key: key.key } };
|
|
258
|
+
}
|
|
259
|
+
|
|
238
260
|
/** The state file a body names: its note, else its event. */
|
|
239
261
|
async function keyFromBody(body, ctx) {
|
|
240
262
|
if (body.note) {
|
|
@@ -320,7 +342,7 @@ const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true;
|
|
|
320
342
|
|
|
321
343
|
module.exports = {
|
|
322
344
|
prefixes: ['/api/meeting-focus'],
|
|
323
|
-
read, now: nowRoute, topic, ask, askState, settleAsk, settleRun, findEvent, keyOf, linesOf, noteFor, noteEvent, realBrief,
|
|
345
|
+
read, now: nowRoute, topic, raise, ask, askState, settleAsk, settleRun, findEvent, keyOf, linesOf, noteFor, noteEvent, realBrief,
|
|
324
346
|
handle: async (req, res, url, ctx) => {
|
|
325
347
|
const p = url.pathname;
|
|
326
348
|
const wsId = url.searchParams.get('ws');
|
|
@@ -329,7 +351,7 @@ module.exports = {
|
|
|
329
351
|
if (req.method === 'GET' && p === '/api/meeting-focus') return respond(ctx, res, await read(Object.fromEntries(url.searchParams), base));
|
|
330
352
|
if (req.method === 'GET' && p === '/api/meeting-focus/now') return respond(ctx, res, nowRoute(Object.fromEntries(url.searchParams), base));
|
|
331
353
|
if (req.method === 'GET' && p === '/api/meeting-focus/ask') return respond(ctx, res, askState(Object.fromEntries(url.searchParams), base));
|
|
332
|
-
const fn = req.method === 'POST' && { '/api/meeting-focus/topic': topic, '/api/meeting-focus/ask': ask }[p];
|
|
354
|
+
const fn = req.method === 'POST' && { '/api/meeting-focus/topic': topic, '/api/meeting-focus/raise': raise, '/api/meeting-focus/ask': ask }[p];
|
|
333
355
|
if (!fn) return false;
|
|
334
356
|
const got = await ctx.readJson(req);
|
|
335
357
|
if (!got.ok) return respond(ctx, res, fail(400, 'invalid JSON body'));
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-proposals.js — what Claude proposes on an initiative, under its one blue ✦ (feedback batch 12 items 2, 3 and 4; canvas In
|
|
3
|
+
* development, rows "Populate initiative" and "Task proposals"). The fold and the engines are lib/proposals.js; every write to a task or an
|
|
4
|
+
* initiative goes through the board's own writer (routes-boards writeAs), so its checks and its ledger line are the route's own. A Jira
|
|
5
|
+
* ticket is never written: a proposal for one becomes a drafted comment in the outbox (rule 8). A draft plan is never touched (rule 9).
|
|
6
|
+
*
|
|
7
|
+
* GET /api/proposals?ws&board&initiative → { ok, props, found } props: lib/proposals.js viewOf (null: nothing to show)
|
|
8
|
+
* POST /api/proposals/keep { ws, board, initiative, ids?: [id] | all: true, choices?: { <from>><to>: 'keep' | 'ignore' } }
|
|
9
|
+
* → { ok, batch, said, counts, props } ✓ one proposal, or ✓ in the header (all: every one Claude is sure of;
|
|
10
|
+
* Check these and a Jira ticket's comment never ride on it). One batch, one toast, one Undo.
|
|
11
|
+
* POST /api/proposals/drop { ws, board, initiative, sig } → { ok } ✕ on a proposal or on one item of it, for good (rule 7)
|
|
12
|
+
* POST /api/proposals/undo { ws, board, batch } → { ok, back, kept } the whole batch; a task changed since keeps its change
|
|
13
|
+
* POST /api/proposals/stop { ws, board, initiative } → { ok } ■ Stop: the look ends; what was found so far stays proposed
|
|
14
|
+
* POST /api/proposals/look { ws, board, initiative, why?: 'populate' | 'check' } → { ok, started } Claude looks now (the New initiative
|
|
15
|
+
* panel's Create sends it at once; the server's tick starts the same run for every other way an initiative is made)
|
|
16
|
+
* GET /api/proposals/history?ws&board&task → { ok, history } Claude's approved changes to one task (lib/proposals.js historyOf)
|
|
17
|
+
*
|
|
18
|
+
* viewFor(ctx, w, board, ini) the same view outside HTTP (`pmos propose status`)
|
|
19
|
+
*
|
|
20
|
+
* Every POST passes pm-guard requirePagePress. With no state folder the read answers nothing and every write answers 409. */
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const crypto = require('crypto');
|
|
24
|
+
const guard = require('./pm-guard.js');
|
|
25
|
+
const PR = require('./proposals.js');
|
|
26
|
+
const TL = require('./task-links.js');
|
|
27
|
+
const RB = require('./routes-boards.js');
|
|
28
|
+
const TLR = require('./routes-task-links.js');
|
|
29
|
+
|
|
30
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
31
|
+
const fail = (ctx, res, status, error, extra = {}) => { ctx.json(res, { ok: false, error, ...extra }, status); return true; };
|
|
32
|
+
const NO_STATE = 'This repository has no PMOS state folder (pmos/state, state or .pmos). Nothing is saved until the folder exists.';
|
|
33
|
+
const dirOf = (ctx, w) => (ctx.stateDirFor ? ctx.stateDirFor(w) : null);
|
|
34
|
+
const todayIso = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
35
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
36
|
+
const srcText = (p) => (p.sources || []).map((s) => s.label).join(', ');
|
|
37
|
+
|
|
38
|
+
/* ── the view ── */
|
|
39
|
+
function rowOf(f, ini) { return (f.rows || []).find((r) => r.id === ini) || null; }
|
|
40
|
+
function stagesOf(ctx, p, ini) {
|
|
41
|
+
try { const r = RB.initiativeWorkflow(ctx, p.w, ini); if (r.ok) return (r.row.wfStages || []).map((s) => ({ key: s.key, name: s.name })); } catch { /* none */ }
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
function view(ctx, p, ini, f) {
|
|
45
|
+
const dir = dirOf(ctx, p.w); if (!dir) return null;
|
|
46
|
+
f = f || TLR.frame(ctx, p.w, p.board);
|
|
47
|
+
if (!f) return null;
|
|
48
|
+
const F = PR.read(dir), LF = TL.read(dir);
|
|
49
|
+
const links = TL.linksOf(LF).filter((l) => f.T.has(l.from) && f.T.has(l.to));
|
|
50
|
+
let linkProps = [];
|
|
51
|
+
try { const lv = TL.viewOf(LF, ini, { T: f.T, today: todayIso(), limit: f.limit, src: TLR.sourcesOf(p.w.root, ini, f.items) }); linkProps = lv ? lv.proposals : []; } catch { linkProps = []; }
|
|
52
|
+
const T = new Map(); for (const x of f.items) { if (!x || !(x.uid || x.key)) continue; const t = PR.taskOf(x); T.set(t.uid, t); }
|
|
53
|
+
return PR.viewOf(F, ini, { T, today: todayIso(), stages: stagesOf(ctx, p, ini), links, settle: TL.settle, linkProps });
|
|
54
|
+
}
|
|
55
|
+
function viewFor(ctx, w, boardId, ini) {
|
|
56
|
+
const fr = RB.frameFor(ctx, w), board = fr.boards.find((b) => b.id === boardId);
|
|
57
|
+
return board ? view(ctx, { w, fr, board }, ini) : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* ── the writes, each one remembered with what it was before (Undo, the task's History) ── */
|
|
61
|
+
const W = {
|
|
62
|
+
ok: (r) => !!(r && r.body && r.body.ok),
|
|
63
|
+
dates(ctx, p, g, uid, x, to) {
|
|
64
|
+
const body = { ws: p.w.id, board: p.board.id, task: uid };
|
|
65
|
+
if (to.start !== undefined && (x.start || to.start)) body.start = to.start || '';
|
|
66
|
+
if (to.due !== undefined) body.due = to.due || '';
|
|
67
|
+
return RB.taskEdit(ctx, body, g);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
/** The writes of one proposal. → [write] (each { op, ... } that landed). sk: the item ids the PM left out (✕ on one item). */
|
|
71
|
+
function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
|
|
72
|
+
const wrote = [], why = x.why, source = srcText(x);
|
|
73
|
+
const items = x.items || [];
|
|
74
|
+
const add = (w) => { wrote.push({ why, ...(source ? { source } : {}), ...w }); };
|
|
75
|
+
if (x.group === 'found') {
|
|
76
|
+
if (x.type === 'stage') {
|
|
77
|
+
const row = rowOf(f, ini), stage = x.data && x.data.stage;
|
|
78
|
+
if (stage && row && row.stage !== stage) {
|
|
79
|
+
const r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: ini, to: stage, why: 'Claude found it there: ' + why }, g);
|
|
80
|
+
if (W.ok(r)) add({ op: 'stage', from: row.stage || '', to: stage });
|
|
81
|
+
}
|
|
82
|
+
for (const it of items) add({ op: 'ran', stage: it.stage, from: it.start || null, to: it.due || null, source: it.source || source });
|
|
83
|
+
if (stage && x.data.since) add({ op: 'ran', stage, from: x.data.since, to: null });
|
|
84
|
+
} else if (x.type === 'docs') {
|
|
85
|
+
for (const it of items) add({ op: 'doc', id: 'fd-' + PR.hash(ini + '|' + (it.ref || it.title)), title: it.title, source: it.source || source, at: it.at || '', ref: it.ref || '', kind: it.kind || 'doc' });
|
|
86
|
+
} else if (x.type === 'tasks' || (x.type === 'maybe' && items.some((it) => it.due || it.start || it.owner))) {
|
|
87
|
+
const epics = [];
|
|
88
|
+
for (const it of items) {
|
|
89
|
+
if (it.jira) { epics.push(it.jira.toUpperCase()); continue; }
|
|
90
|
+
const title = (it.wbs && !String(it.title).startsWith(it.wbs) ? it.wbs + ' ' : '') + it.title;
|
|
91
|
+
const r = RB.taskAdd(ctx, { ws: p.w.id, board: p.board.id, initiative: ini, title: title.slice(0, 200), ...(it.start ? { start: it.start } : {}), ...(it.due ? { due: it.due } : {}), ...(it.owner ? { owner: it.owner } : {}),
|
|
92
|
+
notes: ['From ' + (it.source || source || 'your sources') + (it.ref ? ': ' + it.ref : ''), it.notes || ''].filter(Boolean).join('\n').slice(0, 1900) }, g);
|
|
93
|
+
if (!W.ok(r)) continue;
|
|
94
|
+
const uid = r.body.item && (r.body.item.uid || r.body.item.id);
|
|
95
|
+
if (uid && it.stage) {
|
|
96
|
+
const st = stagesOf(ctx, p, ini).find((s) => s.key === it.stage || s.name.toLowerCase() === String(it.stage).toLowerCase());
|
|
97
|
+
if (st) RB.taskEdit(ctx, { ws: p.w.id, board: p.board.id, task: uid, section: st.key }, g);
|
|
98
|
+
}
|
|
99
|
+
add({ op: 'add', task: uid, title, to: { start: it.start || '', due: it.due || '' } });
|
|
100
|
+
}
|
|
101
|
+
if (epics.length) {
|
|
102
|
+
const row = rowOf(f, ini), was = (row && row.epics) || [];
|
|
103
|
+
const next = [...new Set([...was, ...epics])].slice(0, 20);
|
|
104
|
+
const r = RB.writeAs(ctx, '/api/boards/ini-epics', { ws: p.w.id, board: p.board.id, id: ini, epics: next }, g);
|
|
105
|
+
if (W.ok(r)) add({ op: 'epics', from: was, to: next });
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
// a duplicate is linked, never copied (rule 4); a maybe document is linked too; what could not be placed is kept under Linked
|
|
109
|
+
for (const it of items) add({ op: x.type === 'maybe' && it.kind !== 'link' ? 'doc' : 'linked', id: 'fl-' + PR.hash(ini + '|' + (it.ref || it.title)), title: it.title, ref: it.ref || '', at: it.at || '', source: it.source || source,
|
|
110
|
+
...(it.other ? { why: 'Also in ' + it.other.title } : {}) });
|
|
111
|
+
}
|
|
112
|
+
} else if (x.group === 'dates') {
|
|
113
|
+
for (const it of items) {
|
|
114
|
+
const t = f.T.get(it.task), xi = f.byUid.get(it.task) || {};
|
|
115
|
+
if (!t) continue;
|
|
116
|
+
if (t.jira) { outbox.push({ task: it.task, text: 'Could ' + it.task + ' move to ' + PR.md(PR.dn(it.to.due)) + '? ' + why }); continue; }
|
|
117
|
+
const r = W.dates(ctx, p, g, it.task, xi, it.to);
|
|
118
|
+
if (W.ok(r)) add({ op: 'dates', task: it.task, title: t.title, from: { start: xi.start || '', due: xi.end || '' }, to: { start: it.to.start || xi.start || '', due: it.to.due || '' } });
|
|
119
|
+
}
|
|
120
|
+
// rule 11: a link the new date reaches: keep it (the waiting task moves too) or ignore it (it stays; the link is taken off so nothing moves it later)
|
|
121
|
+
for (const l of x.links || []) {
|
|
122
|
+
if (l.clash) continue;
|
|
123
|
+
const pick = (choices && choices[l.key]) || l.rec;
|
|
124
|
+
if (pick === 'keep') {
|
|
125
|
+
for (const m of l.moves) {
|
|
126
|
+
const xi = f.byUid.get(m.task) || {}, t = f.T.get(m.task); if (!t || t.jira) continue;
|
|
127
|
+
const r = W.dates(ctx, p, g, m.task, xi, m.to);
|
|
128
|
+
if (W.ok(r)) add({ op: 'dates', task: m.task, title: t.title, from: { start: xi.start || '', due: xi.end || '' }, to: m.to, why: 'it waits on ' + l.title });
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
const dir = dirOf(ctx, p.w), LF = TL.read(dir), was = LF.links.get(TL.keyOf(l.from, l.to));
|
|
132
|
+
if (was) { TL.append(dir, g.actor, { kind: 'unlink', from: l.from, to: l.to }); add({ op: 'unlink', from: l.from, to: l.to, link: { type: was.type, lag: was.lag, source: was.source } }); }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else if (x.group === 'status') {
|
|
136
|
+
for (const it of items) {
|
|
137
|
+
const t = f.T.get(it.task); if (!t || t.closed) continue;
|
|
138
|
+
if (t.jira) { outbox.push({ task: it.task, text: 'It looks done: ' + why + ' Could you close ' + it.task + '?' }); continue; }
|
|
139
|
+
const r = RB.taskState(ctx, { ws: p.w.id, board: p.board.id, task: it.task, state: 'Done', why: 'Claude ✦: ' + why }, g);
|
|
140
|
+
if (W.ok(r)) add({ op: 'state', task: it.task, title: t.title, from: t.status, to: 'Done' });
|
|
141
|
+
}
|
|
142
|
+
} else if (x.group === 'names') {
|
|
143
|
+
for (const it of items) {
|
|
144
|
+
const t = f.T.get(it.task), xi = f.byUid.get(it.task) || {}; if (!t || t.jira || t.title === it.to) continue;
|
|
145
|
+
const r = RB.writeAs(ctx, '/api/boards/tasks/rename', { ws: p.w.id, board: p.board.id, task: it.task, title: it.to }, g);
|
|
146
|
+
if (!W.ok(r)) continue;
|
|
147
|
+
add({ op: 'rename', task: it.task, title: it.to, from: t.title, to: it.to });
|
|
148
|
+
// the detail cut from the name moves to the notes, so nothing is lost (rule 5)
|
|
149
|
+
const was = xi.notes || '', note = it.notes || ('Old name: ' + t.title);
|
|
150
|
+
if (!was.includes(note)) { const r2 = RB.taskEdit(ctx, { ws: p.w.id, board: p.board.id, task: it.task, notes: (was ? was + '\n' : '') + note }, g); if (W.ok(r2)) add({ op: 'notes', task: it.task, from: was, to: (was ? was + '\n' : '') + note }); }
|
|
151
|
+
// rule 12: where the PRD quotes the old name, the same ✓ changes it
|
|
152
|
+
const pr = prdRename(p.w.root, ini, t.title, it.to); if (pr) add({ op: 'prd', file: pr.file, from: t.title, to: it.to, n: pr.n });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return wrote;
|
|
156
|
+
}
|
|
157
|
+
/** The PRD's own quotes of a task's old name, changed to the new one (rule 12). → { file, n } | null */
|
|
158
|
+
function prdRename(root, ini, from, to) {
|
|
159
|
+
try {
|
|
160
|
+
const JT = require('./jira-tickets.js'), rel = JT.prdOf(JT.recordFm(root, ini));
|
|
161
|
+
if (!rel || !from || from.length < 6) return null;
|
|
162
|
+
const file = path.resolve(root, rel.replace(/^\/+/, ''));
|
|
163
|
+
if (!file.startsWith(path.resolve(root) + path.sep)) return null;
|
|
164
|
+
const text = fs.readFileSync(file, 'utf8'), n = text.split(from).length - 1;
|
|
165
|
+
if (!n) return null;
|
|
166
|
+
fs.writeFileSync(file, text.split(from).join(to));
|
|
167
|
+
return { file: path.relative(root, file), n };
|
|
168
|
+
} catch { return null; }
|
|
169
|
+
}
|
|
170
|
+
/** A drafted Jira comment for a ticket Claude would change: it goes to the outbox, never to Jira (rule 8). */
|
|
171
|
+
function toOutbox(ctx, ask) {
|
|
172
|
+
try {
|
|
173
|
+
const { repoScript } = require('./repo-script.js');
|
|
174
|
+
const outbox = require(repoScript('outbox.js')), store = require('./outbox-store.js');
|
|
175
|
+
const e = outbox.draftOutbox({ channel: 'jira-write', recipient: ask.task, subject: 'About ' + ask.task, body: ask.text, origin: 'pm' });
|
|
176
|
+
const entry = { id: 'out-' + crypto.randomBytes(6).toString('hex'), ...e };
|
|
177
|
+
store.appendEvent(ctx.runtimeDir, { event: 'queued', ...entry }, new Date());
|
|
178
|
+
return entry.id;
|
|
179
|
+
} catch { return null; }
|
|
180
|
+
}
|
|
181
|
+
/** The toast's one line: "Kept the stage, 7 documents and 41 tasks. 2 still ask you." or "Moved 7 tasks and 2 plans, ticked 1 done, renamed 7." */
|
|
182
|
+
function saidOf(wrote, plans, left) {
|
|
183
|
+
const n = (op) => wrote.filter((w) => w.op === op).length;
|
|
184
|
+
const found = [n('stage') ? 'the stage' : '', n('doc') ? plural(n('doc'), 'document', 'documents') : '', n('add') ? plural(n('add'), 'task', 'tasks') : '', n('linked') ? plural(n('linked'), 'link', 'links') : ''].filter(Boolean);
|
|
185
|
+
const bits = [];
|
|
186
|
+
if (found.length) bits.push('Kept ' + (found.length > 1 ? found.slice(0, -1).join(', ') + ' and ' + found[found.length - 1] : found[0]));
|
|
187
|
+
const moved = new Set(wrote.filter((w) => w.op === 'dates').map((w) => w.task)).size;
|
|
188
|
+
if (moved) bits.push((bits.length ? 'moved ' : 'Moved ') + plural(moved, 'task', 'tasks') + (plans ? ' and ' + plural(plans, 'plan', 'plans') : ''));
|
|
189
|
+
if (n('state')) bits.push((bits.length ? 'ticked ' : 'Ticked ') + n('state') + ' done');
|
|
190
|
+
if (n('rename')) bits.push((bits.length ? 'renamed ' : 'Renamed ') + n('rename'));
|
|
191
|
+
if (n('outbox')) bits.push(plural(n('outbox'), 'Jira comment', 'Jira comments') + ' drafted');
|
|
192
|
+
if (!bits.length) bits.push('Nothing changed');
|
|
193
|
+
return bits.join(', ') + '.' + (left ? ' ' + left + ' still ' + (left === 1 ? 'asks' : 'ask') + ' you.' : '');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const READS = {
|
|
197
|
+
'/api/proposals': (ctx, res, url) => {
|
|
198
|
+
const p = RB.postFrame(ctx, res, { ws: url.searchParams.get('ws') || null, board: url.searchParams.get('board') || '' });
|
|
199
|
+
if (!p) return;
|
|
200
|
+
const ini = url.searchParams.get('initiative') || '';
|
|
201
|
+
if (!ini) return fail(ctx, res, 400, 'initiative is required');
|
|
202
|
+
const dir = dirOf(ctx, p.w);
|
|
203
|
+
ctx.json(res, { ok: true, props: dir ? view(ctx, p, ini) : null, found: dir ? PR.foundOf(PR.read(dir), ini) : null });
|
|
204
|
+
},
|
|
205
|
+
'/api/proposals/history': (ctx, res, url) => {
|
|
206
|
+
const p = RB.postFrame(ctx, res, { ws: url.searchParams.get('ws') || null, board: url.searchParams.get('board') || '' });
|
|
207
|
+
if (!p) return;
|
|
208
|
+
const uid = url.searchParams.get('task') || '';
|
|
209
|
+
if (!uid) return fail(ctx, res, 400, 'task is required');
|
|
210
|
+
const dir = dirOf(ctx, p.w);
|
|
211
|
+
ctx.json(res, { ok: true, history: dir ? PR.historyOf(PR.read(dir), uid) : [] });
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const WRITES = {
|
|
216
|
+
'/api/proposals/keep': (ctx, res, body, g, p) => {
|
|
217
|
+
const ini = String(body.initiative || '');
|
|
218
|
+
if (!ini) return fail(ctx, res, 400, 'initiative is required');
|
|
219
|
+
const ids = Array.isArray(body.ids) ? body.ids.filter((x) => typeof x === 'string').slice(0, 60) : [];
|
|
220
|
+
if (!ids.length && body.all !== true) return fail(ctx, res, 400, 'ids names the proposals to keep, or all: true');
|
|
221
|
+
const f = TLR.frame(ctx, p.w, p.board);
|
|
222
|
+
if (!f) return fail(ctx, res, 202, 'The board is still being read. Try again in a moment.');
|
|
223
|
+
const v = view(ctx, p, ini, f), all = v ? v.groups.flatMap((x) => x.props) : [];
|
|
224
|
+
// ✓ in the header keeps all Claude is sure of: Check these, Not placed and Jira-only proposals wait for their own ✓
|
|
225
|
+
const want = body.all === true ? all.filter((x) => x.section === 'sure') : all.filter((x) => ids.includes(x.id));
|
|
226
|
+
if (!want.length) return fail(ctx, res, 409, 'Those proposals are no longer open');
|
|
227
|
+
const dir = dirOf(ctx, p.w), wrote = [], keptIds = [], outbox = [];
|
|
228
|
+
let plans = 0;
|
|
229
|
+
const choices = isObj(body.choices) ? body.choices : {};
|
|
230
|
+
for (const x of want) {
|
|
231
|
+
if (x.group === 'links') {
|
|
232
|
+
const r = TLR.acceptFor ? TLR.acceptFor(ctx, p, g, ini, [x.link.id]) : null;
|
|
233
|
+
if (r && r.linked) for (const l of r.linked) wrote.push({ op: 'link', from: l.from, to: l.to, why: x.why });
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const w = applyOne(ctx, p, g, f, ini, x, choices, outbox);
|
|
237
|
+
wrote.push(...w);
|
|
238
|
+
if (x.group === 'dates' && x.plan && w.some((y) => y.op === 'dates')) plans++;
|
|
239
|
+
keptIds.push(x.group === 'dates' ? x.id + ':' + x.sig : x.id);
|
|
240
|
+
}
|
|
241
|
+
for (const a of outbox) { const id = toOutbox(ctx, a); if (id) wrote.push({ op: 'outbox', task: a.task, entry: id, why: a.text }); }
|
|
242
|
+
const batch = PR.newBatch();
|
|
243
|
+
PR.append(dir, g.actor, { kind: 'keep', ini, board: p.board.id, batch, ids: keptIds, wrote });
|
|
244
|
+
const v2 = view(ctx, p, ini);
|
|
245
|
+
const left = v2 ? v2.groups.flatMap((x) => x.props).filter((x) => x.section === 'check').length : 0;
|
|
246
|
+
ctx.json(res, { ok: true, batch, said: saidOf(wrote, plans, body.all === true ? left : 0), counts: { wrote: wrote.length }, props: v2, found: PR.foundOf(PR.read(dir), ini) });
|
|
247
|
+
},
|
|
248
|
+
'/api/proposals/drop': (ctx, res, body, g, p) => {
|
|
249
|
+
const sig = String(body.sig || ''), ini = String(body.initiative || '');
|
|
250
|
+
if (!/^[sdi]:[0-9a-f]{10}$/.test(sig) || !ini) return fail(ctx, res, 400, 'sig names a proposal or one item of it; initiative is required');
|
|
251
|
+
PR.append(dirOf(ctx, p.w), g.actor, { kind: 'drop', ini, sig });
|
|
252
|
+
ctx.json(res, { ok: true });
|
|
253
|
+
},
|
|
254
|
+
'/api/proposals/undo': (ctx, res, body, g, p) => {
|
|
255
|
+
const dir = dirOf(ctx, p.w), F = PR.read(dir), id = String(body.batch || '');
|
|
256
|
+
const k = F.kept.find((x) => x.batch === id);
|
|
257
|
+
if (!k || F.undone.has(id)) return fail(ctx, res, 409, 'Nothing to undo');
|
|
258
|
+
const f = TLR.frame(ctx, p.w, p.board);
|
|
259
|
+
if (!f) return fail(ctx, res, 202, 'The board is still being read. Try again in a moment.');
|
|
260
|
+
let back = 0, kept = 0;
|
|
261
|
+
for (const w of k.wrote.slice().reverse()) {
|
|
262
|
+
const xi = w.task ? f.byUid.get(w.task) : null, t = w.task ? f.T.get(w.task) : null;
|
|
263
|
+
let r = null;
|
|
264
|
+
if (w.op === 'add') { if (xi && (xi.status || 'To do') === 'To do') r = RB.taskDelete(ctx, { ws: p.w.id, board: p.board.id, task: w.task, why: 'Undo: Claude ✦ added it' }, g); }
|
|
265
|
+
// a task changed since keeps its change: Undo never overwrites a later edit
|
|
266
|
+
else if (w.op === 'dates') { if (xi && (xi.end || '') === (w.to.due || xi.end || '')) r = W.dates(ctx, p, g, w.task, xi, { start: w.from.start, due: w.from.due }); }
|
|
267
|
+
else if (w.op === 'state') { if (t && t.status === w.to) r = RB.taskState(ctx, { ws: p.w.id, board: p.board.id, task: w.task, state: w.from || 'To do', why: 'Undo' }, g); }
|
|
268
|
+
else if (w.op === 'rename') { if (t && t.title === w.to) r = RB.writeAs(ctx, '/api/boards/tasks/rename', { ws: p.w.id, board: p.board.id, task: w.task, title: w.from }, g); }
|
|
269
|
+
else if (w.op === 'notes') { if (xi && (xi.notes || '') === w.to) r = RB.taskEdit(ctx, { ws: p.w.id, board: p.board.id, task: w.task, notes: w.from || '' }, g); }
|
|
270
|
+
else if (w.op === 'stage') { const row = rowOf(f, k.ini); if (row && row.stage === w.to && w.from) r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: k.ini, to: w.from, why: 'Undo: Claude ✦ moved it' }, g); }
|
|
271
|
+
else if (w.op === 'epics') r = RB.writeAs(ctx, '/api/boards/ini-epics', { ws: p.w.id, board: p.board.id, id: k.ini, epics: w.from }, g);
|
|
272
|
+
else if (w.op === 'unlink') { TL.append(dir, g.actor, { kind: 'link', board: p.board.id, ini: k.ini, from: w.from, to: w.to, type: w.link.type, lag: w.link.lag, source: w.link.source }); back++; continue; }
|
|
273
|
+
else if (w.op === 'link') { TL.append(dir, g.actor, { kind: 'unlink', from: w.from, to: w.to }); back++; continue; }
|
|
274
|
+
else if (w.op === 'prd') { try { const file = path.resolve(p.w.root, w.file), text = fs.readFileSync(file, 'utf8'); if (text.includes(w.to)) { fs.writeFileSync(file, text.split(w.to).join(w.from)); back++; } else kept++; } catch { kept++; } continue; }
|
|
275
|
+
else if (w.op === 'doc' || w.op === 'linked' || w.op === 'ran') { back++; continue; } // the fold leaves an undone batch out
|
|
276
|
+
else if (w.op === 'outbox') { kept++; continue; } // a drafted comment waits in the outbox, where the PM drops it
|
|
277
|
+
if (r && r.body && r.body.ok) back++; else kept++;
|
|
278
|
+
}
|
|
279
|
+
PR.append(dir, g.actor, { kind: 'undo', batch: id });
|
|
280
|
+
ctx.json(res, { ok: true, back, kept });
|
|
281
|
+
},
|
|
282
|
+
'/api/proposals/stop': (ctx, res, body, g, p) => {
|
|
283
|
+
const ini = String(body.initiative || '');
|
|
284
|
+
if (!ini) return fail(ctx, res, 400, 'initiative is required');
|
|
285
|
+
const dir = dirOf(ctx, p.w), L = PR.read(dir).looks.get(ini);
|
|
286
|
+
if (!L || L.ended) return fail(ctx, res, 409, 'Claude is not looking now');
|
|
287
|
+
try { if (ctx.proposalRuns) ctx.proposalRuns.stop(L.run); } catch { /* the end line below says it stopped */ }
|
|
288
|
+
PR.append(dir, g.actor, { kind: 'end', ini, run: L.run, ok: true, stopped: true });
|
|
289
|
+
ctx.json(res, { ok: true });
|
|
290
|
+
},
|
|
291
|
+
'/api/proposals/look': (ctx, res, body, g, p) => {
|
|
292
|
+
const ini = String(body.initiative || ''), why = body.why === 'check' ? 'check' : 'populate';
|
|
293
|
+
if (!ini) return fail(ctx, res, 400, 'initiative is required');
|
|
294
|
+
if (!ctx.proposalRuns) return fail(ctx, res, 503, 'Claude\'s runs are off on this server');
|
|
295
|
+
const r = ctx.proposalRuns.start({ ws: p.w.id, board: p.board.id, ini, why });
|
|
296
|
+
if (!r || !r.ok) return fail(ctx, res, 409, (r && r.error) || 'Claude could not start looking');
|
|
297
|
+
ctx.json(res, { ok: true, started: r.run });
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
module.exports = {
|
|
302
|
+
prefixes: ['/api/proposals'],
|
|
303
|
+
viewFor, saidOf, prdRename,
|
|
304
|
+
handle: async (req, res, url, ctx) => {
|
|
305
|
+
const p0 = url.pathname;
|
|
306
|
+
if (req.method === 'GET') {
|
|
307
|
+
const fn = READS[p0];
|
|
308
|
+
if (!fn) return fail(ctx, res, 404, 'not found');
|
|
309
|
+
fn(ctx, res, url);
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
if (req.method !== 'POST') return fail(ctx, res, 405, 'GET or POST only');
|
|
313
|
+
const fn = WRITES[p0];
|
|
314
|
+
if (!fn) return fail(ctx, res, 404, 'not found');
|
|
315
|
+
const got = await ctx.readJson(req);
|
|
316
|
+
if (!got.ok || !isObj(got.body)) return fail(ctx, res, 400, 'the body must be a JSON object');
|
|
317
|
+
const body = got.body, g = guard.requirePagePress(req, body);
|
|
318
|
+
if (!g.ok) return fail(ctx, res, g.status, g.error);
|
|
319
|
+
const p = RB.postFrame(ctx, res, body);
|
|
320
|
+
if (!p) return true;
|
|
321
|
+
if (!p.file || !dirOf(ctx, p.w)) return fail(ctx, res, 409, NO_STATE);
|
|
322
|
+
fn(ctx, res, body, g, p);
|
|
323
|
+
return true;
|
|
324
|
+
},
|
|
325
|
+
};
|
|
@@ -134,6 +134,37 @@ function ownMove(ctx, p, g, seed, ini) {
|
|
|
134
134
|
return { moved: r.done, cant: cantOf(S, f), batch: r.batch };
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/** ✓ or Add all on link proposals, outside the route too (the ✦ Viewer's Keep all, lib/routes-proposals.js). → { linked, moved } | { status, error } */
|
|
138
|
+
function acceptFor(ctx, p, g, ini, ids) {
|
|
139
|
+
const f = frame(ctx, p.w, p.board);
|
|
140
|
+
if (!f) return { status: 202, error: 'The board is still being read. Try again in a moment.' };
|
|
141
|
+
const v = view(ctx, p.w, p.board, ini, f), dir = dirOf(ctx, p.w);
|
|
142
|
+
const want = (v ? v.proposals : []).filter((x) => ids.includes(x.id));
|
|
143
|
+
if (!want.length) return { status: 409, error: 'Those proposals are no longer open' };
|
|
144
|
+
const linked = [], moved = [];
|
|
145
|
+
let F = TL.read(dir);
|
|
146
|
+
for (const x of want) {
|
|
147
|
+
if (x.kind === 'link') {
|
|
148
|
+
if (TL.loops(TL.linksOf(F), x.from, x.to)) continue;
|
|
149
|
+
TL.append(dir, g.actor, { kind: 'link', board: p.board.id, ini, from: x.from, to: x.to, type: x.type, lag: x.lag || 0, source: x.source });
|
|
150
|
+
linked.push({ from: x.from, to: x.to }); F = TL.read(dir);
|
|
151
|
+
} else if (x.kind === 'pull') {
|
|
152
|
+
const f2 = frame(ctx, p.w, p.board);
|
|
153
|
+
const mv = x.tasks.map((u) => { const t = f2.T.get(u); const P = { uid: u, from: { s: t.s, e: t.e }, to: { s: t.s == null ? null : t.s - x.days, e: t.e == null ? null : t.e - x.days }, after: x.after }; return P; });
|
|
154
|
+
const r = apply(ctx, p, g, f2, ini, mv, 'ask', 'pulled in after ' + ((f2.T.get(x.after) || {}).title || x.after));
|
|
155
|
+
moved.push(...r.done); TL.append(dir, g.actor, { kind: 'drop', sig: x.id });
|
|
156
|
+
} else if (x.kind === 'move') {
|
|
157
|
+
const f2 = frame(ctx, p.w, p.board);
|
|
158
|
+
const mv = x.tasks.filter((m) => f2.T.has(m.task)).map((m) => ({ uid: m.task, from: { s: TL.dn(m.from.start), e: TL.dn(m.from.due) }, to: { s: TL.dn(m.to.start), e: TL.dn(m.to.due) } }));
|
|
159
|
+
const r = apply(ctx, p, g, f2, ini, mv, 'ask', 'to keep your links');
|
|
160
|
+
moved.push(...r.done);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// what the new links ask for now moves just enough (the PM's ✓ is the approval)
|
|
164
|
+
for (const l of linked) { const m = ownMove(ctx, p, g, l.from, ini); moved.push(...m.moved); }
|
|
165
|
+
return { linked, moved };
|
|
166
|
+
}
|
|
167
|
+
|
|
137
168
|
const READS = {
|
|
138
169
|
'/api/task-links': (ctx, res, url) => {
|
|
139
170
|
const p = RB.postFrame(ctx, res, { ws: url.searchParams.get('ws') || null, board: url.searchParams.get('board') || '' });
|
|
@@ -200,33 +231,9 @@ const WRITES = {
|
|
|
200
231
|
'/api/task-links/accept': (ctx, res, body, g, p) => {
|
|
201
232
|
const ini = String(body.initiative || ''), ids = Array.isArray(body.ids) ? body.ids.filter((x) => typeof x === 'string').slice(0, 40) : [];
|
|
202
233
|
if (!ini || !ids.length) return fail(ctx, res, 400, 'initiative and ids are required');
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
const want = (v ? v.proposals : []).filter((x) => ids.includes(x.id));
|
|
207
|
-
if (!want.length) return fail(ctx, res, 409, 'Those proposals are no longer open');
|
|
208
|
-
const linked = [], moved = [];
|
|
209
|
-
let F = TL.read(dir);
|
|
210
|
-
for (const x of want) {
|
|
211
|
-
if (x.kind === 'link') {
|
|
212
|
-
if (TL.loops(TL.linksOf(F), x.from, x.to)) continue;
|
|
213
|
-
TL.append(dir, g.actor, { kind: 'link', board: p.board.id, ini, from: x.from, to: x.to, type: x.type, lag: x.lag || 0, source: x.source });
|
|
214
|
-
linked.push({ from: x.from, to: x.to }); F = TL.read(dir);
|
|
215
|
-
} else if (x.kind === 'pull') {
|
|
216
|
-
const f2 = frame(ctx, p.w, p.board);
|
|
217
|
-
const mv = x.tasks.map((u) => { const t = f2.T.get(u); const P = { uid: u, from: { s: t.s, e: t.e }, to: { s: t.s == null ? null : t.s - x.days, e: t.e == null ? null : t.e - x.days }, after: x.after }; return P; });
|
|
218
|
-
const r = apply(ctx, p, g, f2, ini, mv, 'ask', 'pulled in after ' + ((f2.T.get(x.after) || {}).title || x.after));
|
|
219
|
-
moved.push(...r.done); TL.append(dir, g.actor, { kind: 'drop', sig: x.id });
|
|
220
|
-
} else if (x.kind === 'move') {
|
|
221
|
-
const f2 = frame(ctx, p.w, p.board);
|
|
222
|
-
const mv = x.tasks.filter((m) => f2.T.has(m.task)).map((m) => ({ uid: m.task, from: { s: TL.dn(m.from.start), e: TL.dn(m.from.due) }, to: { s: TL.dn(m.to.start), e: TL.dn(m.to.due) } }));
|
|
223
|
-
const r = apply(ctx, p, g, f2, ini, mv, 'ask', 'to keep your links');
|
|
224
|
-
moved.push(...r.done);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
// what the new links ask for now moves just enough (the PM's ✓ is the approval)
|
|
228
|
-
for (const l of linked) { const m = ownMove(ctx, p, g, l.from, ini); moved.push(...m.moved); }
|
|
229
|
-
ctx.json(res, { ok: true, linked, moved, links: view(ctx, p.w, p.board, ini) });
|
|
234
|
+
const r = acceptFor(ctx, p, g, ini, ids);
|
|
235
|
+
if (r.status) return fail(ctx, res, r.status, r.error);
|
|
236
|
+
ctx.json(res, { ok: true, linked: r.linked, moved: r.moved, links: view(ctx, p.w, p.board, ini) });
|
|
230
237
|
},
|
|
231
238
|
'/api/task-links/drop': (ctx, res, body, g, p) => {
|
|
232
239
|
const id = String(body.id || '');
|
|
@@ -304,7 +311,7 @@ const WRITES = {
|
|
|
304
311
|
|
|
305
312
|
module.exports = {
|
|
306
313
|
prefixes: ['/api/task-links'],
|
|
307
|
-
sweepFor, sourcesOf, frame, LOOP,
|
|
314
|
+
sweepFor, sourcesOf, frame, acceptFor, LOOP,
|
|
308
315
|
handle: async (req, res, url, ctx) => {
|
|
309
316
|
const p0 = url.pathname;
|
|
310
317
|
if (req.method === 'GET') {
|
|
@@ -125,7 +125,8 @@ function validate(key, value) {
|
|
|
125
125
|
if (typeof value !== 'string' || value.length > 64) return `${key} must be a time zone such as Asia/Jakarta, or empty for this computer's`;
|
|
126
126
|
try { new Intl.DateTimeFormat('en', { timeZone: value }); return null; } catch { return `${value} is not a time zone this computer knows`; }
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
// ['*'] alone is every workspace (the product picker's All, lib/briefing-premium-products.js)
|
|
129
|
+
case 'ids': return value === null || Array.isArray(value) && (value.length === 1 && value[0] === '*' || value.length <= d.max && value.every((x) => typeof x === 'string' && WS_ID.test(x)) && new Set(value).size === value.length) ? null : `${key} must list at most ${d.max} workspace ids, each once, or ['*'] for every one`;
|
|
129
130
|
case 'templates': {
|
|
130
131
|
if (!value || typeof value !== 'object' || Array.isArray(value)) return `${key} must name the templates`;
|
|
131
132
|
const ids = Object.keys(value);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.425.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.425.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -51,7 +51,7 @@ const lines = (name) => {
|
|
|
51
51
|
/** A press on a choice chip inside the dialog's pane, as a click event on the element (Playwright's pointer check races the dialog's spring). */
|
|
52
52
|
const tap = (pg, sel) => pg.$eval(sel, (b) => b.click());
|
|
53
53
|
// the Board's first questions (board-grill: start, file, answer, later) write only triage-answers.jsonl and the material folder; intake/draft only drafts
|
|
54
|
-
const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive)|lifecycle|briefing-premium\/note|board-grill\/(?:start|file|answer|later)|intake\/draft|initiative-layout)$/; // initiative-layout: the card's Moves on by itself switch (premium-uncovered-features)
|
|
54
|
+
const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive)|lifecycle|briefing-premium\/note|board-grill\/(?:start|file|answer|later)|intake\/draft|initiative-layout|proposals\/look)$/; // initiative-layout: the card's Moves on by itself switch (premium-uncovered-features); proposals/look: Create asks Claude to look for the new initiative elsewhere (batch 12 item 4)
|
|
55
55
|
|
|
56
56
|
(async () => {
|
|
57
57
|
const exe = findBrowser();
|
|
@@ -247,7 +247,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
|
|
|
247
247
|
/* P the POST allow-list and the refusals */
|
|
248
248
|
const all = P.posts.concat(I.posts);
|
|
249
249
|
const other = all.filter((x) => !ALLOWED.test(x.path) && x.path !== '/api/briefing-premium/seen'); // an opened popup's record (popup context slice 11, R1) is not a press
|
|
250
|
-
ok('P1 the pages post only to the asks, move, lifecycle, archive
|
|
250
|
+
ok('P1 the pages post only to the asks, move, lifecycle, archive, initiative-layout and proposals/look routes', all.length > 10 && !other.length, JSON.stringify(other));
|
|
251
251
|
const noNonce = await post('/api/boards/move', { id: 'fx-bare', to: ready.model.board.stages[1] }, { 'Content-Type': 'application/json', Origin: BASE });
|
|
252
252
|
const lifeNo = await post('/api/lifecycle', { initiative_id: 'fx-bare', state: 'on-hold' }, { 'Content-Type': 'application/json', Origin: BASE });
|
|
253
253
|
ok('P2 a press without the launch nonce is refused', noNonce.status === 403 && lifeNo.status === 403, JSON.stringify([noNonce.status, lifeNo.status]));
|
|
@@ -350,7 +350,7 @@ const GANTT = [
|
|
|
350
350
|
await p.unroute('**/api/brief-page*');
|
|
351
351
|
await p.route('**/api/brief-page*', async (r) => { const res = await r.fetch(); const b = await res.json(); json(r, { ...b, today: TODAY.map((m) => ({ ...m, state: 'past' })) }); });
|
|
352
352
|
await p.reload(); await openCard();
|
|
353
|
-
ok('PR2 the ring is not shown when no meeting is left today', await p.evaluate(() => { const c = document.querySelector('#czViewer #prep'); return !!c && c.hidden; }));
|
|
353
|
+
ok('PR2 the ring is not shown when no meeting is left today', !!(await until(() => p.evaluate(() => { const c = document.querySelector('#czViewer #prep'); return !!c && c.hidden; }), 10000)));
|
|
354
354
|
await p.unroute('**/api/brief-page*');
|
|
355
355
|
|
|
356
356
|
/* L: floors */
|