create-pmos 0.558.0 → 0.559.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 +14 -14
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +8 -6
- package/workspace/changelog.json +13 -0
- package/workspace/fixtures/board-premium-facts.js +2 -12
- package/workspace/guide/programs.md +2 -2
- package/workspace/lib/board-premium.js +3 -22
- package/workspace/lib/core-docs-needs.js +12 -16
- package/workspace/lib/core-docs.js +27 -214
- package/workspace/lib/coredoc-cli.js +6 -6
- package/workspace/lib/custom-docs.js +3 -1
- package/workspace/lib/job-graph.js +2 -2
- package/workspace/lib/refresh.js +2 -2
- package/workspace/lib/route-modules.js +0 -1
- package/workspace/lib/routes-board-premium.js +5 -11
- package/workspace/lib/routes-core-docs.js +23 -113
- package/workspace/lib/routes-custom-docs.js +8 -6
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-core-doc-issue-test.js +11 -18
- package/workspace/public/pm/bd-acts.js +5 -77
- package/workspace/public/pm/bd-prog.js +4 -5
- package/workspace/public/pm/bd-views.js +4 -56
- package/workspace/public/pm/cozy-board.css +2 -24
- package/workspace/public/pm/home-app.js +2 -3
- package/workspace/public/pm/premium-board.js +6 -24
- package/workspace/public/pm/premium-shell.js +3 -33
- package/workspace/public/pm/prog-page.js +1 -1
- package/workspace/ready-dash-ui-test.js +1 -1
- package/workspace/server.js +3 -12
- package/workspace/test-lists/uncovered-board.json +1 -1
- package/workspace/lib/routes-board-docs.js +0 -46
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-core-docs.js — the core documents of each level (initiative core-documents, PRD sections 3 to 5).
|
|
3
3
|
*
|
|
4
|
-
* GET /api/core-docs?ws&level=portfolio|board
|
|
4
|
+
* GET /api/core-docs?ws&level=initiative&id (level=portfolio|board: 410, retired)
|
|
5
5
|
* → { ok, level, scope, question, reader, rhythm, build, wfTpl, stage, cat, summary: { draft, due, missing, stale }, docs: [entry + state] }
|
|
6
6
|
* 202 { ok: true, pending: true } while the initiatives are still being read (level=initiative only)
|
|
7
7
|
* POST /api/core-docs/draft { ws, scope, key } → { ok, run } starts a core-doc run; 409 when one runs for that entry
|
|
8
|
+
* Every route answers 410 for a portfolio or board scope (retired, below).
|
|
8
9
|
* POST /api/core-docs/issue { ws, scope, key, slot } → { ok } `state: issued` in the file and one `issue` line
|
|
9
10
|
* POST /api/core-docs/drop { ws, scope, key, slot } → { ok } one `drop` line
|
|
10
11
|
*
|
|
11
12
|
* WHO WRITES. Every POST refuses a request that carries an agent session header (403), as routes-scan.js does. Draft it passes pm-guard
|
|
12
13
|
* requirePagePress; Issue it and Drop pass requirePmPress (act `issue`): only the PM issues or drops a core document. A draft is never sent.
|
|
13
14
|
*
|
|
14
|
-
* THE RUN. A press on Draft it (
|
|
15
|
+
* THE RUN. A press on Draft it (an initiative document) starts ONE headless run, kind `core-doc` (lib/headless.js), origin
|
|
15
16
|
* `core-doc:<scope>:<key>`. Its tools are Read, Glob, Grep and `pmos coredoc write`; the server pins the entry it may write with
|
|
16
17
|
* PMOS_CORE_DOC_SCOPE and PMOS_CORE_DOC_KEY. There is no cap on how many run at once (PM, 2026-10-13: no run limit).
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* run: the refresh log says so and Needs you tells the PM (lib/refresh-run.js). The schedule does not try those documents again until the next
|
|
24
|
-
* day. A batch that wrote some drafts is progress: the documents still missing are tried on the next tick.
|
|
19
|
+
* PORTFOLIO AND BOARD DOCUMENTS ARE RETIRED (feedback batch 29 item 8; Wawan picked option A on 2026-11-10). Under D107 each of them has
|
|
20
|
+
* a home in the seven artefacts (the Narrative is the weekly update, Lessons keep the retro, Intent and Goal keep the charter and the
|
|
21
|
+
* metrics), and on the 3 Nov backup PMOS had drafted 80 of them with none issued. So nothing drafts them any more: every route answers 410
|
|
22
|
+
* for a portfolio or board scope, and the tick drafts nothing. The documents already written stay on disk, untouched, with their ledger
|
|
23
|
+
* lines (lib/core-docs.js; `pmos artefacts` still reads them). Initiative documents are unchanged (Draft it here, the Initiative Driver's doc-due).
|
|
25
24
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
25
|
+
* A FAILURE IS NOT RETRIED IN A LOOP. A run that ends having written no draft (the command could not run, the run was refused) is a failed
|
|
26
|
+
* run: the refresh log says so (lib/refresh-run.js).
|
|
27
|
+
*
|
|
28
|
+
* THERE IS NO TICK. It drafted the due portfolio and board documents (opt-in with PMOS_CORE_DOCS=on since D107); it is gone, and that switch
|
|
29
|
+
* does nothing. The background queue's `coredocs` step (server.js) is a no-op, so the queue and the Sources row keep their shape.
|
|
30
30
|
*/
|
|
31
31
|
const guard = require('./pm-guard.js');
|
|
32
32
|
const CD = require('./core-docs.js');
|
|
@@ -35,11 +35,8 @@ const headless = require('./headless.js');
|
|
|
35
35
|
const text = (v) => (typeof v === 'string' ? v : '');
|
|
36
36
|
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
37
37
|
const POSTS = ['draft', 'issue', 'drop'];
|
|
38
|
-
const TICK_EVERY_MS = 30 * 60 * 1000;
|
|
39
38
|
|
|
40
39
|
const runs = new Map(); // `${ws}|${scope}|${key}` → session id, for the core-doc runs this server started
|
|
41
|
-
const missed = new Map(); // `${ws}|${scope}|${key}` → the local day a scheduled run for it ended with no draft at all: not tried again that day
|
|
42
|
-
let lastTick = null;
|
|
43
40
|
|
|
44
41
|
const runKey = (ws, scope, key) => `${ws}|${scope}|${key}`;
|
|
45
42
|
function wsOf(ctx, id) {
|
|
@@ -51,19 +48,20 @@ const isRunning = (ws) => (scope, key) => runs.has(runKey(ws, scope, key));
|
|
|
51
48
|
/** The entry of a scope in this workspace: the level's facts must find the board or the initiative. → { ok, entry, facts } | refusal */
|
|
52
49
|
function resolve(ctx, w, scope, key, now) {
|
|
53
50
|
const p = CD.parseScope(scope);
|
|
54
|
-
if (!p) return { ok: false, status: 400, error: 'scope must be
|
|
51
|
+
if (!p) return { ok: false, status: 400, error: 'scope must be initiative:<id>' };
|
|
52
|
+
if (CD.RETIRED_LEVELS.includes(p.level)) return { ok: false, status: 410, error: CD.RETIRED };
|
|
55
53
|
let entry = CD.entryOf(p.level, key);
|
|
56
54
|
if (!entry) return { ok: false, status: 400, error: `no core document ${String(key).slice(0, 40)} at the ${p.level} level` };
|
|
57
|
-
const g = CD.gather(ctx, w, { level: p.level,
|
|
55
|
+
const g = CD.gather(ctx, w, { level: p.level, id: p.id, now });
|
|
58
56
|
if (g.pending) return { ok: false, status: 202, error: 'The initiatives are being read. Ask again in a few seconds.' };
|
|
59
57
|
if (!g.ok) return g;
|
|
60
58
|
// D99: the initiative's own set holds the full entry (a workflow stage's document carries its name, stage and template)
|
|
61
|
-
|
|
59
|
+
{ const hit = g.facts.list.find((x) => x.entry.key === key); if (hit) entry = hit.entry; }
|
|
62
60
|
return { ok: true, entry, facts: g.facts, level: p.level, id: p.id };
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
/** Start the run that drafts one entry. → { ok, run } | { ok: false, status, error } */
|
|
66
|
-
function startRun(ctx, w, scope, entry, { label, now
|
|
64
|
+
function startRun(ctx, w, scope, entry, { label, now } = {}) {
|
|
67
65
|
if (typeof ctx.spawnSession !== 'function') return { ok: false, status: 409, error: 'this workspace cannot start sessions' };
|
|
68
66
|
const origin = `core-doc:${scope}:${entry.key}`;
|
|
69
67
|
if (headless.kindFor({ agent: 'claude', origin }) !== 'core-doc') return { ok: false, status: 409, error: 'Background runs are switched off here (PMOS_HEADLESS=off), so PMOS cannot draft this document.' };
|
|
@@ -77,8 +75,7 @@ function startRun(ctx, w, scope, entry, { label, now, scheduled = false } = {})
|
|
|
77
75
|
onDone: () => {
|
|
78
76
|
runs.delete(k); try { if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id); } catch { /* the next poll recounts */ }
|
|
79
77
|
if (!unwritten(w, scope, [entry.key], t0).length) return undefined;
|
|
80
|
-
|
|
81
|
-
return { failed: `the run wrote no draft of the ${entry.title.toLowerCase()}.` + (scheduled ? ' The schedule tries it again tomorrow; Draft it tries now.' : '') };
|
|
78
|
+
return { failed: `the run wrote no draft of the ${entry.title.toLowerCase()}.` };
|
|
82
79
|
} });
|
|
83
80
|
if (!s || s.state === 'exited' || s.headless !== 'core-doc') {
|
|
84
81
|
if (s && s.headless !== 'core-doc' && s.state !== 'exited' && typeof ctx.stopSession === 'function') { try { ctx.stopSession(s.id); } catch { /* best effort */ } }
|
|
@@ -94,93 +91,7 @@ function unwritten(w, scope, keys, t0) {
|
|
|
94
91
|
return keys.filter((key) => { const x = store.get(`${scope}|${key}`); return !(x && x.drafts.some((d) => Date.parse(d.at) >= t0 - 1000)); });
|
|
95
92
|
}
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
function startBatch(ctx, w, scope, entries, { label, now } = {}) {
|
|
99
|
-
if (typeof ctx.spawnSession !== 'function') return { ok: false, status: 409, error: 'this workspace cannot start sessions' };
|
|
100
|
-
const origin = `core-doc:${scope}:batch`;
|
|
101
|
-
if (headless.kindFor({ agent: 'claude', origin }) !== 'core-doc') return { ok: false, status: 409, error: 'Background runs are switched off here (PMOS_HEADLESS=off), so PMOS cannot draft these documents.' };
|
|
102
|
-
const todo = entries.filter((e) => !runs.has(runKey(w.id, scope, e.key)));
|
|
103
|
-
if (!todo.length) return { ok: false, status: 409, error: 'PMOS is drafting these documents already' };
|
|
104
|
-
const t0 = now == null ? Date.now() : now;
|
|
105
|
-
const keys = todo.map((e) => e.key);
|
|
106
|
-
const prompt = CD.batchPrompt(todo, scope, { today: CD.localDay(t0), label });
|
|
107
|
-
let sid = null;
|
|
108
|
-
const s = ctx.spawnSession({ name: `Core documents · ${todo.length} drafts`, agent: 'claude', ws: w.id, origin, initialInput: prompt + '\r',
|
|
109
|
-
extraEnv: { PMOS_CORE_DOC_SCOPE: scope, PMOS_CORE_DOC_KEYS: keys.join(',') },
|
|
110
|
-
onDone: () => {
|
|
111
|
-
for (const key of keys) if (runs.get(runKey(w.id, scope, key)) === sid) runs.delete(runKey(w.id, scope, key));
|
|
112
|
-
try { if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id); } catch { /* the next poll recounts */ }
|
|
113
|
-
const left = unwritten(w, scope, keys, t0);
|
|
114
|
-
if (left.length < keys.length) return undefined; // some drafts came: the rest are tried on the next tick
|
|
115
|
-
const day = CD.localDay(t0); // the day the run started (the tick's clock)
|
|
116
|
-
for (const key of keys) missed.set(runKey(w.id, scope, key), day);
|
|
117
|
-
return { failed: `the run wrote none of its ${keys.length} drafts. The schedule tries them again tomorrow; Draft it tries one now.` };
|
|
118
|
-
} });
|
|
119
|
-
if (!s || s.state === 'exited' || s.headless !== 'core-doc') {
|
|
120
|
-
if (s && s.headless !== 'core-doc' && s.state !== 'exited' && typeof ctx.stopSession === 'function') { try { ctx.stopSession(s.id); } catch { /* best effort */ } }
|
|
121
|
-
return { ok: false, status: 409, error: 'The drafts could not start: ' + ((s && s.note) || 'no background run') };
|
|
122
|
-
}
|
|
123
|
-
sid = s.id;
|
|
124
|
-
for (const key of keys) runs.set(runKey(w.id, scope, key), s.id);
|
|
125
|
-
return { ok: true, run: s.id, keys };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const labelOf = (facts) => (facts.level === 'board' && facts.board ? facts.board.name : facts.level === 'initiative' && facts.row ? `${facts.row.id} ${facts.row.title || ''}`.trim() : null);
|
|
129
|
-
|
|
130
|
-
// ── the tick ─────────────────────────────────────────────────────────────────────────────────────────
|
|
131
|
-
/** Draft the doc entries of the portfolio and the boards that are due, out of date or not started (due first). → [{ ws, scope, key, ok, error? }] */
|
|
132
|
-
function tick(ctx, { now = Date.now(), force = false } = {}) {
|
|
133
|
-
if (!ctx || typeof ctx.getWs !== 'function') return [];
|
|
134
|
-
if (!force && lastTick != null && now - lastTick < TICK_EVERY_MS) return [];
|
|
135
|
-
const settings = (() => { try { return ctx.proSettings ? ctx.proSettings() : null; } catch { return null; } })();
|
|
136
|
-
const open = ctx.deepOpen ? ctx.deepOpen(settings || {}, now) : require('./driver-run.js').dayCheckOpen(settings || {}, now, ctx.inQuiet || (() => false)); // batch 18 item 9: at night or when idle
|
|
137
|
-
if (!open) return [];
|
|
138
|
-
lastTick = now;
|
|
139
|
-
// D107 (seven artefacts): the schedule drafts no portfolio or board document by default; the Narrative is the only report and the
|
|
140
|
-
// Lessons keep what a retro or a review held. PMOS_CORE_DOCS=on brings the old schedule back. Draft it on a card still works.
|
|
141
|
-
if (headless.switchedOff(process.env) || !/^(on|1|true|yes)$/i.test(String(process.env.PMOS_CORE_DOCS || ''))) return [];
|
|
142
|
-
const day = CD.localDay(now);
|
|
143
|
-
const out = [];
|
|
144
|
-
const list = typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : [ctx.getWs(null)].filter(Boolean);
|
|
145
|
-
// Every candidate first, then the most pressing: due (issued, cadence passed), out of date, then not started (the first draft, and the
|
|
146
|
-
// proposed OKRs while no OKR files exist). No cap: every candidate starts; a failed run is tried again on the next tick.
|
|
147
|
-
const RANK = { due: 0, stale: 1, missing: 2 };
|
|
148
|
-
const todo = [];
|
|
149
|
-
for (const w of list) {
|
|
150
|
-
if (!w || !w.root) continue;
|
|
151
|
-
if (typeof ctx.isLead === 'function' && !ctx.isLead(w)) continue;
|
|
152
|
-
const levels = [{ level: 'portfolio' }];
|
|
153
|
-
try { for (const b of require('./routes-boards.js').frameFor(ctx, w).boards) levels.push({ level: 'board', board: b.id }); } catch { /* the portfolio still drafts */ }
|
|
154
|
-
for (const [li, lv] of levels.entries()) {
|
|
155
|
-
let g;
|
|
156
|
-
try { g = CD.gather(ctx, w, { ...lv, now }); } catch { continue; }
|
|
157
|
-
if (!g.ok) continue;
|
|
158
|
-
for (const [ei, entry] of g.facts.entries.entries()) {
|
|
159
|
-
if (!CD.draftable(entry) && !(entry.store && entry.by !== 'you')) continue;
|
|
160
|
-
const st = CD.stateOf(entry, g.facts);
|
|
161
|
-
if (!(st.st in RANK) || st.draft) continue;
|
|
162
|
-
const k = runKey(w.id, g.facts.scope, entry.key);
|
|
163
|
-
if (runs.has(k) || missed.get(k) === day) continue; // a run for it is going, or today's run for it wrote nothing
|
|
164
|
-
const x = g.facts.store.get(`${g.facts.scope}|${entry.key}`);
|
|
165
|
-
if (x && x.drafts.some((d) => x.drops.has(d.slot) && CD.localDay(Date.parse(d.at)) === day)) continue; // the PM dropped today's draft: not again until tomorrow
|
|
166
|
-
todo.push({ w, g, entry, k, order: [RANK[st.st], li, ei] });
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
todo.sort((a, b) => a.order[0] - b.order[0] || a.order[1] - b.order[1] || a.order[2] - b.order[2]);
|
|
171
|
-
// One run per scope: the most pressing scope first, its entries in rank order.
|
|
172
|
-
const groups = new Map();
|
|
173
|
-
for (const t of todo) { const gk = `${t.w.id}|${t.g.facts.scope}`; if (!groups.has(gk)) groups.set(gk, []); groups.get(gk).push(t); }
|
|
174
|
-
for (const list of groups.values()) {
|
|
175
|
-
const { w, g } = list[0];
|
|
176
|
-
const scope = g.facts.scope;
|
|
177
|
-
const r = list.length === 1
|
|
178
|
-
? startRun(ctx, w, scope, list[0].entry, { label: labelOf(g.facts), now, scheduled: true })
|
|
179
|
-
: startBatch(ctx, w, scope, list.map((t) => t.entry), { label: labelOf(g.facts), now });
|
|
180
|
-
for (const t of list) out.push({ ws: w.id, scope, key: t.entry.key, ok: r.ok, ...(r.ok ? { run: r.run } : { error: r.error }) });
|
|
181
|
-
}
|
|
182
|
-
return out;
|
|
183
|
-
}
|
|
94
|
+
const labelOf = (facts) => (facts.row ? `${facts.row.id} ${facts.row.title || ''}`.trim() : null);
|
|
184
95
|
|
|
185
96
|
// ── the handler ──────────────────────────────────────────────────────────────────────────────────────
|
|
186
97
|
async function handle(req, res, url, ctx) {
|
|
@@ -192,7 +103,7 @@ async function handle(req, res, url, ctx) {
|
|
|
192
103
|
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
193
104
|
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
194
105
|
if (!w) return send(bad(404, 'no such workspace'));
|
|
195
|
-
const level = text(url.searchParams.get('level')) || '
|
|
106
|
+
const level = text(url.searchParams.get('level')) || 'initiative';
|
|
196
107
|
const g = CD.gather(ctx, w, { level, board: url.searchParams.get('board') || null, id: url.searchParams.get('id') || null, now: Date.now() });
|
|
197
108
|
if (g.pending) return send({ status: 202, body: { ok: true, pending: true } });
|
|
198
109
|
if (!g.ok) return send(bad(g.status || 400, g.error));
|
|
@@ -217,8 +128,7 @@ async function handle(req, res, url, ctx) {
|
|
|
217
128
|
if (!r.ok) return send(bad(r.status || 400, r.error));
|
|
218
129
|
if (!CD.storable(r.entry)) return send(bad(400, `${r.entry.title} is read from its own source; there is nothing to draft here`));
|
|
219
130
|
if (r.entry.by === 'you') return send(bad(400, `You write the ${r.entry.title.toLowerCase()}. PMOS only checks it`));
|
|
220
|
-
if (r.
|
|
221
|
-
if (r.level === 'initiative' && !r.facts.list.some((x) => x.entry.key === key)) return send(bad(400, `${r.entry.title} is not in this initiative's set`));
|
|
131
|
+
if (!r.facts.list.some((x) => x.entry.key === key)) return send(bad(400, `${r.entry.title} is not in this initiative's set`));
|
|
222
132
|
const s = startRun(ctx, w, scope, r.entry, { label: labelOf(r.facts), now });
|
|
223
133
|
if (!s.ok) return send(bad(s.status, s.error));
|
|
224
134
|
return send({ status: 200, body: { ok: true, run: s.run } });
|
|
@@ -232,4 +142,4 @@ async function handle(req, res, url, ctx) {
|
|
|
232
142
|
return send({ status: 200, body: { ok: true } });
|
|
233
143
|
}
|
|
234
144
|
|
|
235
|
-
module.exports = { prefixes: ['/api/core-docs'], handle,
|
|
145
|
+
module.exports = { prefixes: ['/api/core-docs'], handle, startRun, _runs: runs, _reset: () => { runs.clear(); } };
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* POST /api/custom-docs/add { ws, scope, title, writer, phase, kind, url } → { ok, doc } one `add` line in custom-docs.jsonl
|
|
6
6
|
*
|
|
7
7
|
* WHO WRITES. The POST refuses a request that carries an agent session header (403), as routes-core-docs.js does, and passes pm-guard
|
|
8
|
-
* requirePagePress: the launch nonce and the page's origin. The scope must be
|
|
9
|
-
*
|
|
8
|
+
* requirePagePress: the launch nonce and the page's origin. The scope must be an initiative the workspace knows (lib/core-docs.js gather).
|
|
9
|
+
* A board scope is 410: board documents are retired (feedback batch 29 item 8); the GET still lists the ones added before. The route stores
|
|
10
|
+
* what the PM typed and nothing else: it never reads a linked page. */
|
|
10
11
|
const guard = require('./pm-guard.js');
|
|
11
12
|
const CD = require('./core-docs.js');
|
|
12
13
|
const Custom = require('./custom-docs.js');
|
|
@@ -18,13 +19,14 @@ function wsOf(ctx, id) {
|
|
|
18
19
|
const w = ctx.getWs(id || null);
|
|
19
20
|
return w && (!id || w.id === id) ? w : null;
|
|
20
21
|
}
|
|
21
|
-
/** The scope must name
|
|
22
|
+
/** The scope must name an initiative this workspace holds; a board scope is retired (410). → null | refusal */
|
|
22
23
|
function known(ctx, w, scope) {
|
|
23
24
|
const p = CD.parseScope(scope);
|
|
24
|
-
if (!p
|
|
25
|
-
|
|
25
|
+
if (!p) return bad(400, 'scope must be initiative:<id>');
|
|
26
|
+
if (CD.RETIRED_LEVELS.includes(p.level)) return bad(410, CD.RETIRED);
|
|
27
|
+
const g = CD.gather(ctx, w, { level: p.level, id: p.id, now: Date.now() });
|
|
26
28
|
if (g.pending) return bad(202, 'The initiatives are being read. Ask again in a few seconds.');
|
|
27
|
-
if (!g.ok) return bad(g.status || 404, g.error || 'no such
|
|
29
|
+
if (!g.ok) return bad(g.status || 404, g.error || 'no such initiative');
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.559.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.559.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* premium-core-doc-issue-test.js — Issue it on a core document draft, on the premium Board and the premium initiative page (initiative premium-core-doc-issue;
|
|
4
4
|
* planning/prd/premium-core-doc-issue-prd.md I1 to I7). A real server on a scratch `team` repository, never the PMOS checkout. The drafts are written by the
|
|
5
5
|
* core-docs writer (lib/core-docs.js writeDraft), so the pages read what the agent's run would leave. The real pages press the real route:
|
|
6
|
-
* R reading (slot and path) · B
|
|
6
|
+
* R reading (slot and path) · B a board scope is refused (board documents are retired, batch 29 item 8) · I the initiative (a layout in Home since premium-agreed-design: its Overview, the draft
|
|
7
7
|
* reader in the Viewer), unsaved edits and a refusal · P the POST allow-list · F floors */
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
@@ -47,10 +47,10 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
47
47
|
await T.waitForServer(BASE);
|
|
48
48
|
const ready = await until(async () => { const r = await fetch(BASE + '/api/board-premium'); const j = await r.json().catch(() => null); return r.status === 200 && j && j.ok && j.state === 'ready' && j.model.initiatives.list.rows.length ? j : null; }, 90000, 400);
|
|
49
49
|
if (!ready) { ok('setup the real route reads the scratch board', false); return finish(1); }
|
|
50
|
-
const B = ready.model.board, bscope =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const B = ready.model.board, bscope = 'board:' + B.id;
|
|
51
|
+
// batch 29 item 8: board documents are retired. The board model carries none, and the writer refuses a board scope
|
|
52
|
+
const d1 = CD.writeDraft(team, { scope: bscope, key: 'charter', markdown: BODY, by: 'agent:test', now: Date.now() });
|
|
53
|
+
ok('setup the board model has no documents, and the writer refuses a board scope (410)', !('docs' in ready.model) && d1.status === 410, JSON.stringify(d1));
|
|
54
54
|
const iq = '?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id);
|
|
55
55
|
const ini = await until(async () => { const r = await fetch(BASE + '/api/initiative-premium' + iq); const j = await r.json().catch(() => null); return r.status === 200 && j && j.ok && j.state === 'ready' ? j : null; }, 90000, 400);
|
|
56
56
|
/* the initiative documents PMOS keeps itself are Risks and Outcome review (lib/core-docs.js storable); the others are read from their own source */
|
|
@@ -61,12 +61,9 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
61
61
|
if (!ikey) return finish(1);
|
|
62
62
|
const d2 = CD.writeDraft(team, { scope: iscope, key: ikey, markdown: BODY, by: 'agent:test', now: Date.now() });
|
|
63
63
|
const d3 = CD.writeDraft(team, { scope: iscope, key: free[1], markdown: BODY, by: 'agent:test', now: Date.now() });
|
|
64
|
-
ok('setup the writer left
|
|
64
|
+
ok('setup the writer left two drafts', d2.ok && d3.ok, JSON.stringify([d2, d3]));
|
|
65
65
|
|
|
66
66
|
/* R reading */
|
|
67
|
-
const board2 = await (await fetch(BASE + '/api/board-premium')).json();
|
|
68
|
-
const br = board2.model.docs.rows.find((d) => d.key === bkey);
|
|
69
|
-
ok('R1 the board model carries the draft\'s slot and path from the core-docs answer', br.st === 'draft' && br.slot === d1.slot && br.path === d1.path, JSON.stringify(br));
|
|
70
67
|
const ini2 = await (await fetch(BASE + '/api/initiative-premium' + iq)).json();
|
|
71
68
|
const ir = ini2.model.docs.rows.find((d) => d.key === ikey);
|
|
72
69
|
ok('R2 the initiative model carries the draft\'s slot and path', ir.st === 'draft' && ir.slot === d2.slot && ir.path === d2.path, JSON.stringify(ir));
|
|
@@ -87,14 +84,10 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
87
84
|
const H = await T.pressHeaders(BASE);
|
|
88
85
|
const nonce = H['x-pmos-nonce'];
|
|
89
86
|
|
|
90
|
-
/* B a board's own core document
|
|
91
|
-
issues it; the issue route still takes a board scope */
|
|
87
|
+
/* B a board's own core document: retired (batch 29 item 8). The issue route refuses a board scope */
|
|
92
88
|
const n0 = ledger().filter((l) => l.ev === 'issue').length;
|
|
93
|
-
const bres = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: H, body: JSON.stringify({ ws: B.ws, scope: bscope, key:
|
|
94
|
-
ok('B4 the issue route
|
|
95
|
-
const il = ledger().filter((l) => l.ev === 'issue');
|
|
96
|
-
ok('B5 the ledger has one new issue line for that draft', il.length === n0 + 1 && il[il.length - 1].slot === d1.slot && il[il.length - 1].scope === bscope, JSON.stringify(il));
|
|
97
|
-
ok('B5 the file now says state: issued', /^state: issued$/m.test(fs.readFileSync(path.join(team, d1.path), 'utf8')));
|
|
89
|
+
const bres = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: H, body: JSON.stringify({ ws: B.ws, scope: bscope, key: 'charter', slot: '2026-01-01' }) });
|
|
90
|
+
ok('B4 the issue route refuses a board scope (410) and writes no line', bres.status === 410 && ledger().filter((l) => l.ev === 'issue').length === n0, String(bres.status));
|
|
98
91
|
|
|
99
92
|
/* I the initiative: a layout inside Home (premium-agreed-design). The Board's expand link lands there; the card's Overview lists the core documents (its Documents view),
|
|
100
93
|
and a draft opens a minimal reader in the Viewer (Waiting for design) with the Issue it bar, Read and Edit */
|
|
@@ -154,9 +147,9 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
154
147
|
ok('P1 the pages post only to the issue route (and the conversation note)', all.length >= 2 && !other.length, JSON.stringify(other));
|
|
155
148
|
const sentAll = all.filter((x) => x.path === '/api/core-docs/issue');
|
|
156
149
|
ok('P2 every issue press carried the nonce and no writer field', sentAll.length >= 2 && sentAll.every((x) => x.headers['x-pmos-nonce'] === nonce && !['by', 'via', 'at', 'actor', 'pm', 'nonce'].some((k) => k in x.body)));
|
|
157
|
-
const bare = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: BASE }, body: JSON.stringify({ ws: B.ws, scope:
|
|
150
|
+
const bare = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: BASE }, body: JSON.stringify({ ws: B.ws, scope: iscope, key: ikey, slot: d2.slot }) });
|
|
158
151
|
ok('P3 a press without the launch nonce is refused', bare.status === 403);
|
|
159
|
-
const agent = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body: JSON.stringify({ ws: B.ws, scope:
|
|
152
|
+
const agent = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body: JSON.stringify({ ws: B.ws, scope: iscope, key: free[1], slot: d3.slot }) });
|
|
160
153
|
ok('P4 D98: an agent session is not refused as an agent (the press is checked like the PM\'s)', agent.status !== 403, String(agent.status));
|
|
161
154
|
ok('P5 no script error on any page', !I.errors.length && !J.errors.length, I.errors.concat(J.errors).join(' | '));
|
|
162
155
|
await J.ctx.close();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* pm/bd-acts.js — the Board's presses and the panels and popovers around them (initiative premium-uncovered-features, Board: BdActions, BdFilter,
|
|
2
|
-
* BdSprint, BdPanel
|
|
2
|
+
* BdSprint, BdPanel; built on premium-agreed-design's plain versions, whose function each designed one keeps). The routes are the ones the
|
|
3
3
|
* console presses, behind the launch nonce:
|
|
4
4
|
* a row's actions (BdActions) the stage presses of the initiative's ⋯ (pm/ini-more.js, batch 14 item 5; open.more): Move to a stage (the next
|
|
5
5
|
* with how much of the step is ready), Back to <prev> (asks why), Hold, Resume, Cancel (asks why, the same chips as
|
|
@@ -12,12 +12,10 @@
|
|
|
12
12
|
* Sprints and releases (BdSprint) the chip's popover: the Jira sprints, the releases, the backlog; a release opens its panel (work-items done, days
|
|
13
13
|
* left, the initiatives it carries, your sign-off, the backlog preview). Sprint moves are proposals that go to Home.
|
|
14
14
|
* A metric's trend (BdPanel) a chip's popover: the count week by week where the records allow it, "Show only …" and Insights
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* and its text (GET /api/doc). Add a document POST /api/custom-docs/add; Draft it POST /api/core-docs/draft.
|
|
15
|
+
* (The document panel, BdDocs, with Add a document, Issue it and Draft it on a board document, is gone: board documents are retired,
|
|
16
|
+
* feedback batch 29 item 8.)
|
|
18
17
|
* Metrics, Notifications the board's measures (GET /api/board-metrics-premium) and what waits on you here
|
|
19
18
|
* Nothing here invents a value: what a record does not hold is not drawn. */
|
|
20
|
-
import { followDoc } from './doc-follow.js';
|
|
21
19
|
import { pmPost } from './http.js';
|
|
22
20
|
import { $, $$, esc } from './premium-shell.js';
|
|
23
21
|
import * as Pop from './bd-pop.js';
|
|
@@ -44,7 +42,7 @@ const dayIso = (n) => { const t = new Date(Date.now() + n * 86400000); return t.
|
|
|
44
42
|
const plural = (n, a, b) => (n === 1 ? a : b);
|
|
45
43
|
const cap = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : '');
|
|
46
44
|
|
|
47
|
-
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), redraw(), F, rowOf(key), statusOf(r), openIni(r), openTicket(ini, tk), askHref(r, q), pageHref(r), trail(r),
|
|
45
|
+
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), redraw(), F, rowOf(key), statusOf(r), openIni(r), openTicket(ini, tk), askHref(r, q), pageHref(r), trail(r), viewDoc(path) }
|
|
48
46
|
export function init(api) { A = api; Pins.init(api); }
|
|
49
47
|
const M = () => A.M();
|
|
50
48
|
const post = (p, body) => pmPost(p, { ws: M().board.ws, ...body });
|
|
@@ -274,55 +272,6 @@ function trendHtml(k) {
|
|
|
274
272
|
}
|
|
275
273
|
function openTrend(k, from) { if (TREND[k]) Pop.open(trendHtml(k), from, { label: TREND[k][1] + ' trend', width: 330, cls: 'bd-trend' }); }
|
|
276
274
|
|
|
277
|
-
/* ── Documents (BdDocs) ───────────────────────────────────────────────────────────────────────────────────────── */
|
|
278
|
-
let docOpen = null;
|
|
279
|
-
export const docSel = () => docOpen;
|
|
280
|
-
function docById(id) { return V.docRows().find((x) => V.docId(x) === id) || null; }
|
|
281
|
-
async function openDocPanel(id, from) {
|
|
282
|
-
const x = docById(id); if (!x) return;
|
|
283
|
-
docOpen = id;
|
|
284
|
-
const meta = x.path ? A.docMeta(x.path, x.ws) : null, h = V.healthOf(x), d = x.d || {};
|
|
285
|
-
const eye = (x.src === 'core' ? 'Board document' : x.kind) + ' · ' + (x.src === 'core' ? d.product || M().board.name || 'Board' : x.ini.title);
|
|
286
|
-
const sub = x.src === 'core' ? [d.by, d.cadence].filter(Boolean).join(' · ') : meta ? [meta.by, meta.changed].filter(Boolean).join(' · ') : '';
|
|
287
|
-
const home = x.src === 'ini' ? A.pageHref(x.ini) : null;
|
|
288
|
-
const tools = home ? `<a class="bd-ib" href="${esc(home)}" aria-label="Open in Home" title="Open in Home">${SV(I.ext)}</a>` : '';
|
|
289
|
-
let box = '';
|
|
290
|
-
if (x.parts) { const dn = x.parts.filter((p) => p.done), miss = x.parts.filter((p) => !p.done).map((p) => cap(p.name)); box = `<div class="bd-box"><div class="bd-boxh"><b>${dn.length} of ${x.parts.length} parts</b><span class="bd-amut">Health</span></div>${V.barHtml({ pct: Math.round((dn.length / x.parts.length) * 100), count: true, label: dn.length + ' of ' + x.parts.length + ' parts' })}${miss.length ? `<p class="sm">Missing: ${esc(miss.join(' · '))}</p>` : ''}</div>`; }
|
|
291
|
-
else box = `<div class="bd-box"><div class="bd-boxh"><b>${esc(h.text)}</b><span class="bd-amut">Health</span></div>${x.src === 'core' && d.what ? `<p class="sm">${esc(d.what)}</p>` : ''}</div>`;
|
|
292
|
-
const drift = x.drift && x.drift.length ? `<div class="bd-warn sm">The PRD changed after the tickets were pushed. ${esc(x.drift.join(', '))} may not match.</div>` : '';
|
|
293
|
-
const draft = x.src === 'core' && d.st === 'draft' && d.slot;
|
|
294
|
-
const issue = x.src === 'core' && d.path ? (draft ? `<div class="bd-issue" data-issue-bar="draft"><span>A draft. Nothing is sent: issuing marks it issued and sends nothing to anyone.</span><button type="button" class="bd-btn solid" data-act="issue" data-key="${esc(d.key)}"${d.ws ? ` data-ws="${esc(d.ws)}"` : ''}>Issue it</button></div>` : `<div class="bd-issue done" data-issue-bar="done"><span>${esc(d.state || 'Issued')}. Nothing was sent to anyone.</span></div>`) : '';
|
|
295
|
-
const log = meta && meta.log && meta.log.length ? `<p class="bd-lbl">Edit log</p>${meta.log.map((l) => `<div class="bd-trow sm">${V.avatar(l.by, 'b')}<span class="bd-push0">${esc(l.subject)}</span><span class="bd-amut">${esc(l.at)}</span></div>`).join('')}` : x.path ? '<p class="bd-amut" id="dlogW">Reading the edit log…</p>' : '';
|
|
296
|
-
const cmp = x.drift && x.drift.length ? `<a class="bd-btn" href="${esc(A.askHref(x.ini, 'What changed in the PRD after ' + x.drift.join(', ') + ' ' + (x.drift.length === 1 ? 'was' : 'were') + ' pushed? Compare it with Jira.'))}">Compare with Jira</a>` : '';
|
|
297
|
-
const foot = home || cmp ? `<div class="bd-arow bd-pfoot">${home ? `<a class="bd-btn solid" href="${esc(home)}">Open in Home</a>` : ''}${cmp}</div>` : '';
|
|
298
|
-
const text = x.path ? `<details class="bd-read"${x.src === 'core' ? ' open' : ''}><summary>Read it</summary><p class="bd-amut">${esc(x.path)}</p><pre class="bd-doc" id="cdText">Reading the document…</pre></details>` : '';
|
|
299
|
-
panel(x.title, `${issue}${msg('formM')}${box}${drift}${log}${text}${foot}`, from, { eye, sub, tools, cls: 'pk-doc' });
|
|
300
|
-
A.redraw();
|
|
301
|
-
if (x.path) {
|
|
302
|
-
if (!meta) { await A.loadDocMeta([{ path: x.path, ws: x.ws }]); const m2 = A.docMeta(x.path, x.ws), w = $('#dlogW'); if (w && docOpen === id) w.outerHTML = m2 && m2.log ? `<p class="bd-lbl">Edit log</p>${m2.log.map((l) => `<div class="bd-trow sm">${V.avatar(l.by, 'b')}<span class="bd-push0">${esc(l.subject)}</span><span class="bd-amut">${esc(l.at)}</span></div>`).join('')}` : '<p class="bd-amut">No edit is in the git history yet.</p>'; }
|
|
303
|
-
// the text follows the file: a chat's edit shows within a few seconds, uncommitted, from the initiative's worktree (pm/doc-follow.js)
|
|
304
|
-
const shown = () => { const el = $('#cdText'); return !!el && el.isConnected && docOpen === id; };
|
|
305
|
-
followDoc({ ws: x.ws || M().board.ws || '', ini: x.src === 'ini' && x.ini ? x.ini.id : '', path: x.path, alive: shown,
|
|
306
|
-
onText: (t) => { const el = $('#cdText'); if (el && docOpen === id) el.textContent = t == null ? x.path + ' could not be read.' : t; } });
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
/** A board document by its key; with All products, by its key and its product's workspace (two products can hold the same key). */
|
|
310
|
-
const coreDoc = (key, ws) => { const D = M().docs || {}; return (D.rows || []).find((x) => x.key === key && (!ws || x.ws === ws)) || null; };
|
|
311
|
-
async function issueDoc(key, btn) {
|
|
312
|
-
const D = M().docs || {}, d = coreDoc(key, btn.dataset.ws); if (!d) return;
|
|
313
|
-
const r = await press(btn, $('#formM'), () => post('/api/core-docs/issue', { ...(d.ws ? { ws: d.ws } : {}), scope: d.scope || D.scope, key: d.key, slot: d.slot }));
|
|
314
|
-
if (!r) return;
|
|
315
|
-
A.say('Issued. Nothing was sent to anyone.'); await A.load(); openDocPanel(V.docId({ src: 'core', d }), null);
|
|
316
|
-
}
|
|
317
|
-
/** Add a document: a board document written by you or drafted by PMOS, kept in PMOS or linked to a page elsewhere (POST /api/custom-docs/add).
|
|
318
|
-
* PMOS saves the title and the address on the board's record; it does not read or sync the linked page. */
|
|
319
|
-
const DKINDS = ['In PMOS', 'Confluence', 'Google Docs', 'Google Slides'];
|
|
320
|
-
const radios = (name, L, cur) => `<div class="bd-rad" role="radiogroup">${L.map(([v, l]) => `<label><input type="radio" name="${name}" value="${esc(v)}"${v === cur ? ' checked' : ''}><span>${esc(l)}</span></label>`).join('')}</div>`;
|
|
321
|
-
function openAddDoc(from) {
|
|
322
|
-
panel('Add a document', `<form class="bd-form" data-form="adddoc"><label>Title<input name="title" maxlength="80" placeholder="For example: UAT plan"></label><p class="bd-albl">Who writes it</p>${radios('writer', [['drafts', 'PMOS drafts it'], ['you', 'I write it']], 'drafts')}<label>Where it lives<select name="kind">${DKINDS.map((k) => `<option>${k}</option>`).join('')}</select></label><label>Address<input name="url" maxlength="300" placeholder="https://" disabled></label><p class="bd-amut">It is saved on the board's record. PMOS does not read or sync a linked page.</p>${msg('formM')}<div class="bd-arow"><button type="submit" class="bd-btn solid">Add</button><button type="button" class="bd-btn" data-pk="close">Not now</button></div></form>`, from, { eye: 'Documents' });
|
|
323
|
-
const f = $('#czViewer form[data-form="adddoc"]'); if (f) f.kind.onchange = () => { f.url.disabled = f.kind.value === 'In PMOS'; };
|
|
324
|
-
}
|
|
325
|
-
|
|
326
275
|
/** The Next cell's arrow (pm/bd-next.js): Move to the next stage, as the ⋯ menu's Move to does, with its Undo. */
|
|
327
276
|
export function moveNext(r, btn) { const a = r.acts || {}, cur = (a.stages || []).indexOf(a.stage); if (cur >= 0 && a.stages[cur + 1]) runRow(r, 'mv:' + (cur + 1), btn); }
|
|
328
277
|
/* ── a hold on the timeline (feedback batch 9 item 8, XtiA2Hold): the ⏸ press ─────────────────────────────────────────────── */
|
|
@@ -366,8 +315,7 @@ async function setBack(r, input) {
|
|
|
366
315
|
await done(res, 'On hold · ' + r.title + ' · back ' + md(day(v)), async () => { const u = await lifeBack(r, p); A.say(u && u.ok ? r.title + ' is back as it was.' : errOf(u)); await A.load(); });
|
|
367
316
|
}
|
|
368
317
|
|
|
369
|
-
export const open = { more: moreAct, hold: openHold, new: (from) => Asks.openNew(from), asks: (from) => Asks.openAsks(from), sprint: openSprint, find: openFind, filter: openFilter, gone: (from) => openGone(from, 'all'), trend: openTrend, release: openRelease
|
|
370
|
-
export const closeDoc = () => { docOpen = null; };
|
|
318
|
+
export const open = { more: moreAct, hold: openHold, new: (from) => Asks.openNew(from), asks: (from) => Asks.openAsks(from), sprint: openSprint, find: openFind, filter: openFilter, gone: (from) => openGone(from, 'all'), trend: openTrend, release: openRelease };
|
|
371
319
|
|
|
372
320
|
/* ── the presses ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
373
321
|
document.addEventListener('change', (e) => { const f = e.target.closest && e.target.closest('[data-holdback]'); if (!f || !A || !M()) return; const r = A.rowOf(f.dataset.holdback); if (r) setBack(r, f); });
|
|
@@ -391,29 +339,9 @@ document.addEventListener('click', async (e) => {
|
|
|
391
339
|
const hz = t.closest('[data-hold]'); if (hz) { const r = A.rowOf(hz.dataset.hold); if (r) openHold(r, +hz.dataset.i, hz); return; }
|
|
392
340
|
const hg = t.closest('[data-holdgo]'); if (hg) { const r = A.rowOf(hg.dataset.id); if (r) runHold(r, hg.dataset.holdgo, hg); return; }
|
|
393
341
|
const ra = t.closest('[data-rowact]'); if (ra) { const r = A.rowOf(ra.dataset.id); if (r) runRow(r, ra.dataset.rowact, ra); return; }
|
|
394
|
-
const od = t.closest('[data-opendoc]'); if (od) { openDocPanel(od.dataset.opendoc, od); return; }
|
|
395
342
|
const b = t.closest('[data-act]'); if (!b) return;
|
|
396
343
|
const k = b.dataset.act;
|
|
397
344
|
if (k === 'gone') { openGone(b, 'all'); return; }
|
|
398
345
|
if (k === 'ini') { const r = A.rowOf(b.dataset.id); Pop.close(false); if (r && A.openIni) A.openIni(r); return; }
|
|
399
346
|
if (k === 'asks') { Pop.close(false); Asks.openAsks($('#chAsks') || b); return; }
|
|
400
|
-
if (k === 'adddoc') { openAddDoc(b); return; }
|
|
401
|
-
if (k === 'issue') { issueDoc(b.dataset.key, b); return; }
|
|
402
|
-
if (k === 'draft') {
|
|
403
|
-
b.disabled = true;
|
|
404
|
-
const d = coreDoc(b.dataset.key, b.dataset.ws);
|
|
405
|
-
const r = await pmPost('/api/core-docs/draft', { ws: (d && d.ws) || M().board.ws, scope: (d && d.scope) || M().docs.scope, key: b.dataset.key }).catch(() => null);
|
|
406
|
-
if (r && r.ok) { A.say('The agent is drafting it. It lands as a draft for you to review; nothing is sent.'); await A.load(); } else { b.disabled = false; A.say(errOf(r)); }
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
document.addEventListener('submit', async (e) => {
|
|
410
|
-
const f = e.target.closest('form[data-form="adddoc"]'); if (!f || !A) return;
|
|
411
|
-
e.preventDefault();
|
|
412
|
-
const m = $('#formM'), go = f.querySelector('[type="submit"]'), val = (n) => (f.elements[n] ? String(f.elements[n].value || '').trim() : '');
|
|
413
|
-
const title = val('title'), kd = val('kind'), url = val('url'), writer = (f.querySelector('input[name="writer"]:checked') || {}).value || 'drafts';
|
|
414
|
-
if (!title) { m.textContent = 'Give the document a title.'; return; }
|
|
415
|
-
if (kd !== 'In PMOS' && !url) { m.textContent = 'Paste the address of the ' + kd + ' page, or choose In PMOS.'; return; }
|
|
416
|
-
const body = { scope: M().docs.scope, title, writer, ...(kd !== 'In PMOS' ? { kind: kd, url } : {}) };
|
|
417
|
-
const res = await press(go, m, () => post('/api/custom-docs/add', body));
|
|
418
|
-
if (res) { A.close(); A.say('“' + title + '” is added to the board\'s documents.'); await A.load(); }
|
|
419
347
|
});
|
|
@@ -73,16 +73,15 @@ export function mergeBoards(list) {
|
|
|
73
73
|
const m = b.model, product = (m.board && (m.board.product || m.board.name)) || b.name || b.ws;
|
|
74
74
|
return (r) => ({ ...r, key: b.ws + '/' + r.key, ws: b.ws, boardId: b.id, product });
|
|
75
75
|
};
|
|
76
|
-
const rows = [], list2 = [], gone = { cancelled: [], archived: [] },
|
|
76
|
+
const rows = [], list2 = [], gone = { cancelled: [], archived: [] }, asks = [];
|
|
77
77
|
const sum = (f) => list.reduce((n, b) => n + (Number(f(b.model)) || 0), 0);
|
|
78
78
|
for (const b of list) {
|
|
79
79
|
const m = b.model, tag = tagged(b), I = m.initiatives || {}, G = I.gone || {};
|
|
80
80
|
for (const r of m.rows || []) if (r.id) rows.push(tag(r));
|
|
81
81
|
for (const r of (I.list && I.list.rows) || []) list2.push(tag(r));
|
|
82
82
|
gone.cancelled.push(...(G.cancelled || []).map(tag)); gone.archived.push(...(G.archived || []).map(tag));
|
|
83
|
-
// each product's
|
|
84
|
-
const pn = (m.board && (m.board.product || m.board.name)) || b.name || b.ws
|
|
85
|
-
for (const d of (m.docs && m.docs.rows) || []) docs.push({ ...d, ...own, scope: m.docs.scope || null });
|
|
83
|
+
// each product's new asks, tagged with their product so a press goes to that product's board
|
|
84
|
+
const pn = (m.board && (m.board.product || m.board.name)) || b.name || b.ws;
|
|
86
85
|
for (const a of (m.asks && m.asks.rows) || []) asks.push({ ...a, ws: b.ws, boardId: b.id, forProduct: pn, stages: (m.board && m.board.stages) || [] });
|
|
87
86
|
}
|
|
88
87
|
// Jira: the oldest read of any product, so the chip never says fresher than the stalest board; unread while any product is unread
|
|
@@ -98,7 +97,7 @@ export function mergeBoards(list) {
|
|
|
98
97
|
header: { ...home.header, missing },
|
|
99
98
|
board: { ...home.board, all: true, name: 'All products', product: '', self: false, id: null, ws: null, products: list.map((b) => ({ ws: b.ws, id: b.id, name: (b.model.board && (b.model.board.product || b.model.board.name)) || b.name, self: !!(b.model.board && b.model.board.self), stages: (b.model.board && b.model.board.stages) || [], readAt: (b.model.jira || {}).readAt || null })) },
|
|
100
99
|
initiatives: { ...I, open: n('open'), on: n('on'), risk: n('risk'), late: n('late'), hold: n('hold'), total: n('total'), cap: null, note: '', list: { rows: list2, total: list2.length }, gone, stages: [], timeline: I.timeline },
|
|
101
|
-
sprint: null, release: null,
|
|
100
|
+
sprint: null, release: null,
|
|
102
101
|
steps: steps.map((st, i) => ({ ...st, count: sum((m) => m.steps && m.steps[i] && m.steps[i].count) })),
|
|
103
102
|
workflows: mergeWorkflows(list.map((b) => b.model.workflows || [])),
|
|
104
103
|
jira: { ...(home.jira || {}), readAt, sprint: null, release: null, sprints: [], backlog: [] },
|