create-pmos 0.423.0 → 0.424.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/briefing-premium-products-test.js +16 -3
- package/workspace/changelog.json +12 -0
- package/workspace/guide/claude-proposes.md +37 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/home-pill-test.js +138 -0
- package/workspace/lib/headless.js +14 -1
- 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-proposals.js +325 -0
- package/workspace/lib/routes-task-links.js +35 -28
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/public/pm/bd-asks.js +3 -0
- 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 +20 -6
- package/workspace/public/pm/home-task.js +2 -1
- package/workspace/public/pm/home-today.js +66 -16
- 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/premium-vw-item.js +2 -1
- package/workspace/public/pm/task-card.css +13 -0
- package/workspace/public/pm/task-card.js +37 -2
- package/workspace/server.js +37 -2
- 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/tk-tasks-test.js +13 -0
|
@@ -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') {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.424.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.424.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]));
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* New initiative (BdNew) the side panel: name, why, material (links and files), no lane field (PMOS leans on the intake draft and names the
|
|
7
7
|
* kind in Triage), what it counts toward, the product. A name close to an earlier rejection or to an open initiative
|
|
8
8
|
* says so. Create: POST /api/boards/asks/add then /asks/accept (it starts in the first stage), then POST /api/board-grill/start
|
|
9
|
+
* and POST /api/proposals/look (Claude looks for it elsewhere; batch 12 item 4)
|
|
9
10
|
* and /file for the material.
|
|
10
11
|
* First questions (BdGrill) the same panel, right after: what PMOS took from the Why and the material, then only the open questions, one at a
|
|
11
12
|
* time (POST /api/board-grill/answer). Later (POST /api/board-grill/later) keeps them as the initiative's next step.
|
|
@@ -231,6 +232,8 @@ document.addEventListener('submit', async (e) => {
|
|
|
231
232
|
if (id) {
|
|
232
233
|
await post('/api/board-grill/start', { ws: B.ws, id, why, links: N.links }).catch(() => null);
|
|
233
234
|
for (const file of N.files) { if (file.size > 4 * 1024 * 1024) continue; await post('/api/board-grill/file', { ws: B.ws, id, name: file.name, type: file.type, data: await b64(file) }).catch(() => null); }
|
|
235
|
+
// it most likely lives somewhere already: Claude looks for it in every connected source at once (batch 12 item 4); nothing is kept until the PM's ✓
|
|
236
|
+
post('/api/proposals/look', { ws: B.ws, board: B.board, initiative: id, why: 'populate' }).catch(() => null);
|
|
234
237
|
}
|
|
235
238
|
N = null;
|
|
236
239
|
A.say('“' + title + '” is ' + (askId ? 'accepted' : 'created') + ' in ' + stage + ', anchored to ' + anchor + '.');
|
|
@@ -365,6 +365,29 @@ body.cz-home .hv-r.two .hm-rt b { font-size: 15px; }
|
|
|
365
365
|
.hv-r.two .hm-rt em { font-style: normal; display: block; font-size: 13px; color: var(--cz-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
366
366
|
.hv-r.two .hm-rt em svg { width: 13px; height: 13px; vertical-align: -2px; }
|
|
367
367
|
.hv-r.two .hv-mk { align-self: center; }
|
|
368
|
+
/* what sits in an initiative: the pill on its row and the list behind it (batch 12 item 6, canvas HsA1Desk, HsA2Phone, HsA3Sheet) */
|
|
369
|
+
.hv-sp { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px 0 8px; margin: 0 2px 0 4px; border: 0; border-radius: 999px; background: var(--cz-well); color: var(--cz-ink2); font-family: var(--cz-sans); font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; cursor: pointer; }
|
|
370
|
+
.hv-sp svg { width: 13px; height: 13px; color: var(--cz-ink3); }
|
|
371
|
+
.hv-sp.needs, .hv-sp.blocked { color: var(--cz-blueink); }
|
|
372
|
+
.hv-sp.on { background: var(--cz-bluebg); box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
|
|
373
|
+
.hv-sp:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
374
|
+
@media (hover: hover) { .hv-sp:hover { background: var(--cz-well2); } .hv-sp.on:hover { background: var(--cz-bluebg); } }
|
|
375
|
+
.hv-pm { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--cz-c-a9aeb6); flex: none; }
|
|
376
|
+
.hv-pm.needs { width: 8px; height: 8px; background: var(--cz-blue); }
|
|
377
|
+
.hv-pm.blocked { width: 8px; height: 8px; background: var(--cz-dot-late); }
|
|
378
|
+
.hv-pm.working { width: 9px; height: 9px; background: transparent; box-shadow: inset 0 0 0 2px var(--cz-blue); box-sizing: border-box; }
|
|
379
|
+
.hv-tk { display: inline-flex; align-items: center; flex: none; align-self: stretch; padding: 0 10px 0 2px; border: 0; background: none; cursor: pointer; border-radius: 0 14px 14px 0; }
|
|
380
|
+
.hv-tk .hv-mt { margin-left: 2px; }
|
|
381
|
+
.hv-spp { position: absolute; z-index: 20; top: calc(100% - 4px); right: 8px; width: min(340px, calc(100% - 16px)); background: var(--cz-card); border-radius: 18px; padding: 6px; box-shadow: 0 24px 50px -20px rgba(42,46,53,.4), 0 0 0 1px var(--cz-hair); box-sizing: border-box; }
|
|
382
|
+
.hv-spp .hv-r::before, .hv-sps .hv-r::before { display: none; }
|
|
383
|
+
.hv-spf { display: flex; padding: 2px 2px 0; margin-top: 4px; border-top: 1px solid var(--cz-hair); }
|
|
384
|
+
body.cz-home .hv-r.sp-on { background: var(--cz-well2); z-index: 5; }
|
|
385
|
+
body.cz-home .hv-r.sp-on + .hv-r::before { display: none; }
|
|
386
|
+
.hv-sheet.hv-sps { top: auto; max-height: 72%; }
|
|
387
|
+
.hv-sps .hv-sbar { gap: 8px; }
|
|
388
|
+
.hv-sps .hv-sbar b { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
389
|
+
.hv-sps .hv-sc { padding-bottom: 16px; }
|
|
390
|
+
@media (max-width: 760px) { .hv-scrim:has(+ .hv-sps) { position: fixed; z-index: 60; border-radius: 0; } .hv-sheet.hv-sps { position: fixed; z-index: 61; } }
|
|
368
391
|
|
|
369
392
|
/* motion = importance (cozy.css levels, Board v62): an info ripple on what waits on you, a warn ripple on what is late; nothing for running */
|
|
370
393
|
.hv-d:not(.run), .hv-ck.late, .hv-lt, .hv-nd { position: relative; }
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
* check { state: 'todo'|'prog'|'done'|'wont'|'arch', label, title?, disabled? }: a task's check box in the tile's place (canvas XetX1Rest);
|
|
35
35
|
* a press runs onPress('check', button). setCheck(id, check) changes it while the item is shown.
|
|
36
36
|
* sub one quiet line under the title: what the item is when the title is its parent's name (a program's "Charter", canvas MsBCharter)
|
|
37
|
+
* chip { n, label, on(button) }: the blue ✦ with its count right after the title (what Claude proposes on an initiative, batch 12
|
|
38
|
+
* items 2, 3 and 4, canvas In development PiA0/TpA1). Hidden at zero. setChip(id, chip) changes it while the item is shown.
|
|
37
39
|
* presses [{ act, label, icon, text?, solid? }]: the item's own presses before ⋯ (a program's charter icon, canvas MsB0Entry; the
|
|
38
40
|
* charter's Save, MsBCharter). text draws the word beside the icon (not on a phone); solid is the one dark primary.
|
|
39
41
|
* onPress(act, button) runs them. setPresses(id, list) changes them while the item is shown (Save shows only after a change).
|
|
@@ -125,10 +127,11 @@ export function headHtml(it) {
|
|
|
125
127
|
? `<button type="button" class="cz-vw-pri${x.text && !phone ? '' : ' i'}" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 15, 2.2)}${x.text && !phone ? `<span>${esc(x.text)}</span>` : ''}</button>`
|
|
126
128
|
: `<button type="button" class="cz-vw-ib" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 18)}</button>`).join('');
|
|
127
129
|
const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
|
|
130
|
+
const chip = o.chip && (o.chip.n > 0 || o.chip.looking) ? `<button type="button" class="cz-vw-chip${o.chip.looking ? ' live' : ''}" data-cz-vw="chip" aria-haspopup="dialog" aria-label="${esc(o.chip.label || 'Claude proposes ' + o.chip.n + '. Open')}" title="${esc(o.chip.label || 'Claude proposes')}">${svg(ICONS.spark, 13, 2)}${o.chip.n > 0 ? `<b>${esc(o.chip.n)}</b>` : ''}</button>` : '';
|
|
128
131
|
return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
|
|
129
132
|
+ (o.check ? `<button type="button" class="cz-vw-tile cz-vw-chk s-${esc(o.check.state || 'todo')}" data-cz-vw="press" data-cz-vw-p="check" aria-label="${esc(o.check.label || 'Mark done')}" title="${esc(o.check.title || o.check.label || 'Mark done')}"${o.check.disabled ? ' disabled' : ''}><span class="bx"></span></button>`
|
|
130
133
|
: `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
|
|
131
|
-
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : esc(o.title || '')}</h3>${sub}</div>`)
|
|
134
|
+
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
|
|
132
135
|
+ disc + own + add + more
|
|
133
136
|
+ (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
|
|
134
137
|
+ (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
|
|
@@ -362,6 +365,7 @@ function mount() {
|
|
|
362
365
|
else if (a === 'back') guarded(() => { if (V.stack.length) back(); else close(); }, b);
|
|
363
366
|
else if (a === 'press') { if (V.cur && typeof V.cur.onPress === 'function') V.cur.onPress(b.dataset.czVwP, b); }
|
|
364
367
|
else if (a === 'more') moreMenu(b);
|
|
368
|
+
else if (a === 'chip') { if (V.cur && V.cur.chip && typeof V.cur.chip.on === 'function') V.cur.chip.on(b); }
|
|
365
369
|
else if (a === 'add') { if (V.cur && V.cur.add && typeof V.cur.add.on === 'function') V.cur.add.on(b); }
|
|
366
370
|
else if (a === 'wide') wide();
|
|
367
371
|
else if (a === 'discuss') discuss();
|
|
@@ -435,6 +439,13 @@ async function saveRename() {
|
|
|
435
439
|
endRename(); emit();
|
|
436
440
|
}
|
|
437
441
|
/** The item's own presses change while it is shown (the charter's Save shows only after a change). */
|
|
442
|
+
export function setChip(id, chip) {
|
|
443
|
+
if (!V.cur || V.cur.id !== String(id)) return;
|
|
444
|
+
const was = V.cur.chip, on = !!(chip && (chip.n > 0 || chip.looking)), n = on ? chip.n || 0 : -1;
|
|
445
|
+
V.cur.chip = on ? chip : null;
|
|
446
|
+
if (V.cur.args) V.cur.args = { ...V.cur.args, chip: V.cur.chip };
|
|
447
|
+
if ((was ? was.n || 0 : -1) !== n || (was && chip && (was.label !== chip.label || !!was.looking !== !!chip.looking))) { if (!V.cur.renaming) redraw(); }
|
|
448
|
+
}
|
|
438
449
|
export function setPresses(id, list) { if (V.cur && V.cur.id === String(id)) { V.cur.presses = list || null; if (V.cur.args) V.cur.args = { ...V.cur.args, presses: list || null }; if (!V.cur.renaming) redraw(); } }
|
|
439
450
|
/** A task's check box changes while it is shown (a status move from the card, canvas XetX1Done). */
|
|
440
451
|
export function setCheck(id, check) { if (V.cur && V.cur.id === String(id)) { V.cur.check = check || null; if (V.cur.args) V.cur.args = { ...V.cur.args, check: check || null }; if (!V.cur.renaming) redraw(); } }
|
|
@@ -457,7 +468,7 @@ export function open(it) {
|
|
|
457
468
|
V.drill = false;
|
|
458
469
|
const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
|
|
459
470
|
leave();
|
|
460
|
-
V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
|
|
471
|
+
V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
|
|
461
472
|
el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
|
|
462
473
|
redraw();
|
|
463
474
|
const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
|
|
@@ -512,4 +523,4 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
|
|
|
512
523
|
e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
|
|
513
524
|
}, true);
|
|
514
525
|
}
|
|
515
|
-
if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, setPresses, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
|
|
526
|
+
if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
|
|
@@ -152,3 +152,11 @@ body.cz-vw-rail [data-cz-vw-list] > :not(.cz-vw-railbar), body.cz-vw-rail #hmLis
|
|
|
152
152
|
.czs-ib { width: 44px; }
|
|
153
153
|
}
|
|
154
154
|
@media (prefers-reduced-motion: reduce) { .cz-vw * { transition: none !important; } }
|
|
155
|
+
|
|
156
|
+
/* the blue ✦ after an initiative's title: what Claude proposes (batch 12 items 2, 3 and 4, canvas PiA0/TpA1); hidden at zero */
|
|
157
|
+
.cz-vw-title.has-chip { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
158
|
+
.cz-vw-title.has-chip > .cz-vw-tt, .cz-vw-title.has-chip > .cz-vw-rn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
159
|
+
.cz-vw-chip { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 8px 0 6px; border-radius: 999px; border: 0; background: var(--cz-bluebg); color: var(--cz-blueink); font: inherit; font-size: 12px; font-weight: 800; flex: none; cursor: pointer; }
|
|
160
|
+
.cz-vw-chip:not(:has(b)) { padding: 0 6px; }
|
|
161
|
+
.cz-vw-chip:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
|
|
162
|
+
@media (max-width: 760px) { .cz-vw-chip { min-height: 32px; } }
|