create-pmos 0.273.0 → 0.275.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 +1 -1
- 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-calendar-test.js +5 -1
- package/workspace/guide/briefing-premium.md +16 -0
- package/workspace/lib/transcript-read.js +96 -63
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-briefing-depth-test.js +291 -0
- package/workspace/public/pm/premium.css +32 -0
- package/workspace/public/pm/premium.js +434 -1
- package/workspace/server.js +1 -1
- package/workspace/test-lists/premium-briefing-depth.json +9 -0
- package/workspace/test-lists/workspace-harness-incremental.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.275.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T16:07:29Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T16:07:29Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T16:07:29Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -70,7 +70,11 @@ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-
|
|
|
70
70
|
page.on('request', (r) => { if (r.url().startsWith(BASE)) S.reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
|
|
71
71
|
const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
|
|
72
72
|
await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(facts()), as_of: Date.now() }));
|
|
73
|
-
await page.route('**/api/calendar-views*', (r) => {
|
|
73
|
+
await page.route('**/api/calendar-views*', (r) => {
|
|
74
|
+
const q = new URL(r.request().url()).search;
|
|
75
|
+
if (/only=gantt/.test(q)) return json(r, { ok: true, view: 'quarter', gantt: [], no_plan: 0 }); // the Around you card's pulse, not the week
|
|
76
|
+
S.weekGets.push(q); json(r, week, week && week.ok === false ? 500 : 200);
|
|
77
|
+
});
|
|
74
78
|
await page.route('**/api/meeting-replay*', (r) => { S.replayGets.push(new URL(r.request().url()).search); if (replay === 404) json(r, { ok: false, error: 'no note for that meeting' }, 404); else json(r, replay); });
|
|
75
79
|
await page.route('**/api/meeting-material*', (r) => json(r, material));
|
|
76
80
|
await page.route('**/api/calendar-links', (r) => { S.posts.push(JSON.parse(r.request().postData() || '{}')); json(r, linkRes, linkRes.ok ? 200 : 403); });
|
|
@@ -106,6 +106,18 @@ In the **Add material** sheet, a **Topic** choice ties the item to one of the me
|
|
|
106
106
|
|
|
107
107
|
Not built in premium: translation, Present and the slides stage, Ask PMOS quietly, Park and Add topic, the phone companion and the Meet extension view. The console keeps them.
|
|
108
108
|
|
|
109
|
+
## Around you
|
|
110
|
+
|
|
111
|
+
Under Today, the **Around you** card holds what the agents and the outside world have left for you. It has five rows. A row opens a dialog and states what it found in one line. The caption says how many rows wait on you, or "quiet". If a source cannot be read, its row says so and gives the reason. It never reads as empty.
|
|
112
|
+
|
|
113
|
+
- **Agent proposals.** Every open draft of the Initiative Driver, for initiatives and for Work items, when the agent mode for that kind is Approve. **Keep** records that you accept it and applies it (a problem statement, a stage move, a next step). **Send back** needs a note and starts a new run. **Drop** counts as a correction. None of the three can be undone. A decided proposal stays in the list and says what was recorded.
|
|
114
|
+
- **Mentions.** The people who named you in Slack, Jira, Confluence or mail, from today's morning brief. The row names who waits on a reply. **Make it a task** adds one Work item. **Mark read** hides the mention, and **Mark unread** brings it back. **Open in Slack** (or Jira, Confluence, mail) opens the original in a new tab. Nothing here replies, reacts or posts.
|
|
115
|
+
- **Portfolio pulse.** How many initiatives are late or at risk, by the Calendar's own status: the promised date against the forecast, or the Jira read. It is read only and it is not a forecast of its own. **Open the initiative** goes to its page.
|
|
116
|
+
- **Horizon scan.** When the scan last ran, when it runs next, its reports and their proposals. Each proposal says what **Approve** does before you press it. **Dismiss** asks for a reason and counts as a correction, and **Undo** takes a dismissal back. **Scan now** starts an agent that reads the public web and the repository, and says how many manual scans are left. A scan that is switched off says so and the button stays off.
|
|
117
|
+
- **Data freshness.** When each source was last read and its schedule. **Refresh** reads one source again. **Refresh all** reads every source except the repository. A source outside the machine is read by a skill, in an agent session, with your own connection. The page never says "up to date".
|
|
118
|
+
|
|
119
|
+
With one product picked, the dialogs show its data. With several, each product's part has its own heading, and the counts are not added across products. The agent mode, the scan's watch list and setting and the report documents stay in the console.
|
|
120
|
+
|
|
109
121
|
## The dock
|
|
110
122
|
|
|
111
123
|
When you scroll past the hero, the hero folds into a bar at the top. The bar shows how many rows need you and the next item in Today.
|
|
@@ -129,6 +141,10 @@ Each button writes one record, through a check that only a real press from this
|
|
|
129
141
|
| Record: promote, iterate or kill (a prototype) | A dated entry with the choice and your reason | `pm-decisions.md`, appended |
|
|
130
142
|
| Record: reshape, extend or retire (a missed tripwire) | The same kind of entry, naming the tripwire (KC id) | `pm-decisions.md`, appended |
|
|
131
143
|
| Return this run to the agent (a run in Today) | One counted correction with one of four reasons: wrong facts, wrong scope, not now, too long | `corrections.jsonl` in the state folder |
|
|
144
|
+
| Keep, Send back, Drop (an agent proposal) | The driver's own record of your answer, and the change a kept draft makes | `driver.jsonl` in the state folder |
|
|
145
|
+
| Make it a task, Mark read, Mark unread (a mention) | One Work item, or a read mark | the Work list, `mentions/read.jsonl` |
|
|
146
|
+
| Approve, Dismiss, Undo, Scan now, Stop (the horizon scan) | The scan's own records | `scan.jsonl` in the state folder |
|
|
147
|
+
| Refresh, Refresh all (data freshness) | A new read of the source | the source's own store |
|
|
132
148
|
| Not yet: Later today, Tomorrow, Next week | A put-off record. The row leaves the list until then and the page names it. It does not count as done. | `briefing-premium-deferred.jsonl` in the state folder |
|
|
133
149
|
|
|
134
150
|
Later today means three hours from now. Tomorrow and Next week mean 09:00, tomorrow and next Monday.
|
|
@@ -214,48 +214,31 @@ function prettyTool(name) {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
217
|
+
* The running totals of one harness read. `feedHarness` adds complete transcript lines to it and `harnessOf` turns it into the
|
|
218
|
+
* answer, so a transcript that grew can be read from where the last read stopped instead of from its start (see readHarness).
|
|
219
219
|
*/
|
|
220
|
-
function
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const toolCounts = {};
|
|
241
|
-
let toolTotal = 0;
|
|
242
|
-
const tok = { input: 0, output: 0, cacheRead: 0, cacheCreate: 0 };
|
|
243
|
-
let sawUsage = false;
|
|
244
|
-
// For the open-call signal (R2): pair tool_use → tool_result by id in one pass. The NEWEST
|
|
245
|
-
// tool_use with no matching result is the call in flight; its record timestamp dates it. This is
|
|
246
|
-
// the same "written before its result exists" property the append-only transcript guarantees.
|
|
247
|
-
// NOTE the honesty bound lives in the CALLER (server): a dangling call on a crashed/interrupted
|
|
248
|
-
// session is a permanent phantom (measured: 2/25 real transcripts), so the age is rendered ONLY
|
|
249
|
-
// while the session's derived state is `working` — age without liveness is refused. Here we only
|
|
250
|
-
// report the raw fact {verb, sinceTs}; we never claim it is live.
|
|
251
|
-
const openUse = new Map(); // tool_use_id → { verb, ts } (insertion order = chronological)
|
|
252
|
-
const resolved = new Set(); // tool_use_ids that got a tool_result
|
|
253
|
-
// WHOSE TURN IS IT (workspace-waiting-on-you R1). The last TURN-TAKING record's role — nothing
|
|
254
|
-
// more. `ai-title` and `attachment` records are CLI bookkeeping and are deliberately not
|
|
255
|
-
// turn-taking, and neither is a SYNTHETIC assistant record: counting one as "the assistant
|
|
256
|
-
// finished speaking" is exactly how a false `needs you` would be manufactured.
|
|
257
|
-
let lastRole = null; // 'assistant' | 'user' | null
|
|
220
|
+
function newHarnessAcc() {
|
|
221
|
+
return { model: null, effort: null, turns: 0, title: null, skills: null,
|
|
222
|
+
toolCounts: {}, toolTotal: 0, tok: { input: 0, output: 0, cacheRead: 0, cacheCreate: 0 }, sawUsage: false,
|
|
223
|
+
// For the open-call signal (R2): pair tool_use → tool_result by id in one pass. The NEWEST
|
|
224
|
+
// tool_use with no matching result is the call in flight; its record timestamp dates it. This is
|
|
225
|
+
// the same "written before its result exists" property the append-only transcript guarantees.
|
|
226
|
+
// NOTE the honesty bound lives in the CALLER (server): a dangling call on a crashed/interrupted
|
|
227
|
+
// session is a permanent phantom (measured: 2/25 real transcripts), so the age is rendered ONLY
|
|
228
|
+
// while the session's derived state is `working` — age without liveness is refused. Here we only
|
|
229
|
+
// report the raw fact {verb, sinceTs}; we never claim it is live.
|
|
230
|
+
// A pair is dropped as soon as both halves are seen, so these hold only the calls still open (and a result whose call
|
|
231
|
+
// lies before the window): a long transcript does not make them grow.
|
|
232
|
+
openUse: new Map(), // tool_use_id → { verb, ts } (insertion order = chronological)
|
|
233
|
+
resolved: new Set(), // tool_result ids whose tool_use has not been seen
|
|
234
|
+
// WHOSE TURN IS IT (workspace-waiting-on-you R1). The last TURN-TAKING record's role — nothing
|
|
235
|
+
// more. `ai-title` and `attachment` records are CLI bookkeeping and are deliberately not
|
|
236
|
+
// turn-taking, and neither is a SYNTHETIC assistant record: counting one as "the assistant
|
|
237
|
+
// finished speaking" is exactly how a false `needs you` would be manufactured.
|
|
238
|
+
lastRole: null }; // 'assistant' | 'user' | null
|
|
239
|
+
}
|
|
258
240
|
|
|
241
|
+
function feedHarness(acc, raw, clean) {
|
|
259
242
|
for (const line of raw.split('\n')) {
|
|
260
243
|
if (!line) continue;
|
|
261
244
|
let r;
|
|
@@ -264,22 +247,24 @@ function readHarness(file, clean = (x) => x) {
|
|
|
264
247
|
// session carries exactly one, no timestamp), so the UI labels it "opening focus", never
|
|
265
248
|
// "current". Last one wins in case the layout ever changes.
|
|
266
249
|
if (r.type === 'ai-title') {
|
|
267
|
-
if (typeof r.aiTitle === 'string' && r.aiTitle.trim())
|
|
250
|
+
if (typeof r.aiTitle === 'string' && r.aiTitle.trim()) acc.title = clean(r.aiTitle.trim());
|
|
268
251
|
continue;
|
|
269
252
|
}
|
|
270
253
|
// tool_result blocks live inside `user` records; harvest the ids they resolve.
|
|
271
254
|
if (r.type === 'user') {
|
|
272
255
|
const um = r.message || {};
|
|
273
256
|
for (const c of (Array.isArray(um.content) ? um.content : [])) {
|
|
274
|
-
if (c && c.type === 'tool_result' && c.tool_use_id)
|
|
257
|
+
if (c && c.type === 'tool_result' && c.tool_use_id) {
|
|
258
|
+
if (!acc.openUse.delete(c.tool_use_id)) acc.resolved.add(c.tool_use_id);
|
|
259
|
+
}
|
|
275
260
|
}
|
|
276
|
-
lastRole = 'user';
|
|
261
|
+
acc.lastRole = 'user'; // a prompt was submitted, or a tool result landed
|
|
277
262
|
continue;
|
|
278
263
|
}
|
|
279
264
|
if (r.type === 'attachment') {
|
|
280
265
|
const a = r.attachment || {};
|
|
281
266
|
if (a.type === 'skill_listing' && typeof a.skillCount === 'number') {
|
|
282
|
-
|
|
267
|
+
acc.skills = {
|
|
283
268
|
count: a.skillCount,
|
|
284
269
|
names: Array.isArray(a.names) ? a.names.slice(0, 40).map((n) => clean(String(n))) : [],
|
|
285
270
|
};
|
|
@@ -289,34 +274,37 @@ function readHarness(file, clean = (x) => x) {
|
|
|
289
274
|
if (r.type !== 'assistant') continue;
|
|
290
275
|
const m = r.message || {};
|
|
291
276
|
if (m.model && m.model !== SYNTHETIC) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
lastRole = 'assistant';
|
|
295
|
-
if (r.effort)
|
|
277
|
+
acc.model = clean(m.model);
|
|
278
|
+
acc.turns++; // only real model turns count
|
|
279
|
+
acc.lastRole = 'assistant'; // ...and only a real turn takes the turn
|
|
280
|
+
if (r.effort) acc.effort = clean(String(r.effort));
|
|
296
281
|
}
|
|
297
282
|
const u = m.usage || {};
|
|
298
283
|
if (typeof u.input_tokens === 'number' || typeof u.output_tokens === 'number') {
|
|
299
|
-
sawUsage = true;
|
|
300
|
-
tok.input += u.input_tokens || 0;
|
|
301
|
-
tok.output += u.output_tokens || 0;
|
|
302
|
-
tok.cacheRead += u.cache_read_input_tokens || 0;
|
|
303
|
-
tok.cacheCreate += u.cache_creation_input_tokens || 0;
|
|
284
|
+
acc.sawUsage = true;
|
|
285
|
+
acc.tok.input += u.input_tokens || 0;
|
|
286
|
+
acc.tok.output += u.output_tokens || 0;
|
|
287
|
+
acc.tok.cacheRead += u.cache_read_input_tokens || 0;
|
|
288
|
+
acc.tok.cacheCreate += u.cache_creation_input_tokens || 0;
|
|
304
289
|
}
|
|
305
290
|
for (const c of (m.content || [])) {
|
|
306
291
|
if (c && c.type === 'tool_use' && c.name) {
|
|
307
292
|
const name = clean(prettyTool(c.name));
|
|
308
|
-
toolCounts[name] = (toolCounts[name] || 0) + 1;
|
|
309
|
-
toolTotal++;
|
|
310
|
-
if (c.id) openUse.set(c.id, { verb: name, ts: r.timestamp || null });
|
|
293
|
+
acc.toolCounts[name] = (acc.toolCounts[name] || 0) + 1;
|
|
294
|
+
acc.toolTotal++;
|
|
295
|
+
if (c.id && !acc.resolved.delete(c.id)) acc.openUse.set(c.id, { verb: name, ts: r.timestamp || null });
|
|
311
296
|
}
|
|
312
297
|
}
|
|
313
298
|
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function harnessOf(acc) {
|
|
302
|
+
const out = { model: acc.model, effort: acc.effort, turns: acc.turns, tokens: null, tools: null, skills: acc.skills,
|
|
303
|
+
title: acc.title, openCall: null, turn: null, missing: {} };
|
|
314
304
|
|
|
315
305
|
// The newest tool_use with no matching tool_result is the call in flight (R2). Map preserves
|
|
316
306
|
// insertion (chronological) order, so the last unresolved entry is the newest.
|
|
317
|
-
for (const [
|
|
318
|
-
if (!resolved.has(id)) out.openCall = { verb: info.verb, sinceTs: info.ts };
|
|
319
|
-
}
|
|
307
|
+
for (const [, info] of acc.openUse) out.openCall = { verb: info.verb, sinceTs: info.ts };
|
|
320
308
|
|
|
321
309
|
// ── Whose turn (R1). Derived here, from what the pass already collected — no second walk. ──
|
|
322
310
|
// The ORDER of these three branches is the honesty property the whole feature rests on (R4).
|
|
@@ -327,18 +315,18 @@ function readHarness(file, clean = (x) => x) {
|
|
|
327
315
|
// the phantom: a value it cannot construct. Reordering these branches silently converts a
|
|
328
316
|
// corpse into "waiting on you", which is the one lie this surface must not tell.
|
|
329
317
|
if (out.openCall) out.turn = 'tool'; // awaiting a tool — OR the PM's approval of one
|
|
330
|
-
else if (lastRole === 'assistant') out.turn = 'user'; // the model stopped; the human is up
|
|
331
|
-
else if (lastRole === 'user') out.turn = 'agent'; // a prompt/result landed; the model is up
|
|
318
|
+
else if (acc.lastRole === 'assistant') out.turn = 'user'; // the model stopped; the human is up
|
|
319
|
+
else if (acc.lastRole === 'user') out.turn = 'agent'; // a prompt/result landed; the model is up
|
|
332
320
|
// else: null — nothing turn-taking was parseable, so no claim is made.
|
|
333
321
|
|
|
334
322
|
if (!out.model) out.missing.model = 'the transcript names no model yet';
|
|
335
323
|
if (!out.effort) out.missing.effort = 'the transcript records no effort level';
|
|
336
|
-
if (toolTotal) out.tools = { counts: toolCounts, total: toolTotal };
|
|
324
|
+
if (acc.toolTotal) out.tools = { counts: { ...acc.toolCounts }, total: acc.toolTotal };
|
|
337
325
|
else out.missing.tools = 'no tool calls in the transcript yet';
|
|
338
326
|
// Tokens are reported as ABSOLUTE counts and never as a percentage: the context window size
|
|
339
327
|
// is not in the record, and autocompaction makes the running total move backward. A percentage
|
|
340
328
|
// of an unknown denominator is not a quantity — that refusal predates this module and stands.
|
|
341
|
-
if (sawUsage) out.tokens = tok;
|
|
329
|
+
if (acc.sawUsage) out.tokens = { ...acc.tok };
|
|
342
330
|
else out.missing.tokens = 'the transcript records no token usage yet';
|
|
343
331
|
if (!out.skills) out.missing.skills = 'the CLI listed no skills for this session';
|
|
344
332
|
if (!out.turns) out.missing.turns = 'no model turns in the transcript yet';
|
|
@@ -353,6 +341,51 @@ function readHarness(file, clean = (x) => x) {
|
|
|
353
341
|
return out;
|
|
354
342
|
}
|
|
355
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Read the harness out of a transcript. `clean` is server.js's scrub() — every string that can
|
|
346
|
+
* reach the screen goes through it (D08), because tool names and skill names are free text.
|
|
347
|
+
*
|
|
348
|
+
* `cache` is optional and belongs to one session: an object the caller keeps and passes back on every read. A transcript only
|
|
349
|
+
* grows, so with it a read parses just the bytes written since the last one, where without it every read parses the last
|
|
350
|
+
* MAX_BYTES (8 MB, about 100 ms) again. The first read is the same windowed read as before, and the answer is the same as a
|
|
351
|
+
* windowed read for a transcript under MAX_BYTES; past that, the totals count from the window the first read began at, where
|
|
352
|
+
* a fresh read counts the last MAX_BYTES. A file that is shorter than where the last read stopped (replaced, truncated) is
|
|
353
|
+
* read afresh.
|
|
354
|
+
*/
|
|
355
|
+
function readHarness(file, clean = (x) => x, cache = null) {
|
|
356
|
+
let acc;
|
|
357
|
+
try {
|
|
358
|
+
const st = fs.statSync(file);
|
|
359
|
+
const resume = !!(cache && cache.file === file && cache.acc && cache.ino === st.ino && cache.offset <= st.size);
|
|
360
|
+
const start = resume ? cache.offset : Math.max(0, st.size - MAX_BYTES);
|
|
361
|
+
const len = st.size - start;
|
|
362
|
+
let buf = Buffer.alloc(0);
|
|
363
|
+
if (len > 0) {
|
|
364
|
+
const fd = fs.openSync(file, 'r');
|
|
365
|
+
try {
|
|
366
|
+
buf = Buffer.allocUnsafe(len);
|
|
367
|
+
fs.readSync(fd, buf, 0, len, start);
|
|
368
|
+
} finally { fs.closeSync(fd); }
|
|
369
|
+
}
|
|
370
|
+
let from = 0;
|
|
371
|
+
if (!resume && start > 0) from = buf.indexOf(10) + 1; // drop a partial first line
|
|
372
|
+
let to = buf.length;
|
|
373
|
+
if (cache) {
|
|
374
|
+
// only whole lines are consumed: the CLI may be part-way through writing the last one, and it is read on a later call
|
|
375
|
+
to = Math.max(from, buf.lastIndexOf(10) + 1);
|
|
376
|
+
cache.file = file; cache.ino = st.ino; cache.offset = start + to;
|
|
377
|
+
}
|
|
378
|
+
if (resume) acc = cache.acc;
|
|
379
|
+
else { acc = newHarnessAcc(); if (cache) cache.acc = acc; }
|
|
380
|
+
feedHarness(acc, buf.toString('utf8', from, to), clean);
|
|
381
|
+
} catch {
|
|
382
|
+
if (cache) { cache.file = null; cache.acc = null; cache.offset = 0; }
|
|
383
|
+
return { model: null, effort: null, turns: 0, tokens: null, tools: null, skills: null,
|
|
384
|
+
title: null, openCall: null, turn: null, missing: { all: "can't read the harness — the transcript could not be read" } };
|
|
385
|
+
}
|
|
386
|
+
return harnessOf(acc);
|
|
387
|
+
}
|
|
388
|
+
|
|
356
389
|
/* ── The conversation (console3's session panel) ──────────────────────────────────────────────
|
|
357
390
|
* The PM's prompts and the agent's words, read from the same transcript, so the panel can show the
|
|
358
391
|
* conversation without parsing terminal bytes. Only what a person would call the conversation:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.275.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.275.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-briefing-depth-test.js — the Around you card on the premium Briefing (initiative premium-briefing-depth;
|
|
4
|
+
* planning/prd/premium-briefing-depth-prd.md R1 to R9). A real server on a scratch repository (c3-scan-fixture.js: PMOS_DRIVER=off, so no agent
|
|
5
|
+
* ever runs), with a driver ledger, a scan ledger and a brief of today that this suite seeds with the writers the product uses. The real page
|
|
6
|
+
* presses the real routes. Only two presses are answered in the browser, because they start an agent: scan/now and sources/refresh. The
|
|
7
|
+
* Calendar's rows are answered in the browser too, because they need plan dates and a clock.
|
|
8
|
+
* R rows · A agent proposals · M mentions · P portfolio pulse · S horizon scan · F data freshness · E a source that fails · W the POST allow-list · L floors
|
|
9
|
+
* Set BRIEFING_DEPTH_SHOTS=<dir> to save screenshots of the card and its dialogs, at 1280 and 390 wide, light and dark. */
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
13
|
+
const T = require('./test-run').configure({ name: 'premium-briefing-depth' });
|
|
14
|
+
const Fx = require('./c3-scan-fixture.js');
|
|
15
|
+
|
|
16
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
const until = async (fn, ms = 20000, step = 120) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
18
|
+
const results = [];
|
|
19
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
|
|
20
|
+
let F = null, browser = null;
|
|
21
|
+
const finish = async (code) => {
|
|
22
|
+
if (browser) await browser.close().catch(() => {});
|
|
23
|
+
if (F) F.stop();
|
|
24
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
25
|
+
console.log(`\n${results.length - bad}/${results.length} premium-briefing-depth assertions passed`);
|
|
26
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
27
|
+
};
|
|
28
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
29
|
+
|
|
30
|
+
/* the brief of today: three mentions (two wait on a reply), one of them already a "needs you" row */
|
|
31
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
32
|
+
const NOW = Date.now(), L = new Date(NOW);
|
|
33
|
+
const DATE = `${L.getFullYear()}-${pad(L.getMonth() + 1)}-${pad(L.getDate())}`;
|
|
34
|
+
const iso = (m) => new Date(NOW + m * 60000).toISOString();
|
|
35
|
+
const mi = (id, x) => ({ id, why_now: 'It waits on you today.', evidence: '', initiative_id: null, effort: 'minutes', confidence: 0.9, worth_asking: false, mention: true, owner: 'pm', kind: 'you', ...x });
|
|
36
|
+
const M1 = 'b00000000001', M2 = 'b00000000002', M3 = 'b00000000003';
|
|
37
|
+
const BRIEF = {
|
|
38
|
+
date: DATE, generated_at: iso(-120), sources: { calendar: 'read', mail: 'read', slack: 'read', jira: 'read', confluence: 'read' }, calendar: [],
|
|
39
|
+
priorities: [
|
|
40
|
+
mi(M1, { title: 'Reply to Dana', source: 'slack', who: 'Dana Hartono', where: '#partner-support', about: 'Sandbox access', ask: 'Which day can the engineers use the sandbox?', reply_needed: true, link: 'https://acme.slack.com/archives/D01/p1' }),
|
|
41
|
+
mi(M2, { title: 'Reply to Priya', source: 'jira', who: 'Priya Sen', where: 'IDPF-1204', about: 'Rate limits', ask: 'Can you confirm the quota for partners?', reply_needed: true, link: 'https://jira.example.com/browse/IDPF-1204' }),
|
|
42
|
+
mi(M3, { title: 'Comment on the refunds page', source: 'confluence', who: 'Lia Ong', where: 'Refunds > Policy', about: 'Refund wording', quote: 'Refunds are paid within 14 days.', reply_needed: false, link: 'https://wiki.example.com/61291' }),
|
|
43
|
+
],
|
|
44
|
+
worth_asking: [], digests: [], places: [], resolved: [], judgment: { used: false },
|
|
45
|
+
};
|
|
46
|
+
fs.mkdirSync(path.join(T.STATE_DIR, 'briefs'), { recursive: true });
|
|
47
|
+
fs.writeFileSync(path.join(T.STATE_DIR, 'briefs', DATE + '.json'), JSON.stringify(BRIEF) + '\n');
|
|
48
|
+
fs.writeFileSync(path.join(T.STATE_DIR, 'proactive-settings.json'), JSON.stringify({ briefSources: { calendar: true, mail: true, slack: true, jira: true, confluence: true }, scopes: { slack: {}, jira: {}, confluence: {} }, dayCheck: { every: 60, start: '00:00', end: '23:59' }, websites: [] }) + '\n');
|
|
49
|
+
|
|
50
|
+
/* the Calendar's rows: one late, one at risk, one on plan, one with a Jira read only; two more with no date at all */
|
|
51
|
+
const day = (d) => { const x = new Date(NOW + d * 86400000); return `${x.getFullYear()}-${pad(x.getMonth() + 1)}-${pad(x.getDate())}`; };
|
|
52
|
+
const GANTT = [
|
|
53
|
+
{ id: 'scan-ui', title: 'Partner API onboarding', status: 'delayed', slip_days: 6, promised: day(-3), forecast: { end: day(3) } },
|
|
54
|
+
{ id: 'sandbox', title: 'Self-serve sandbox', status: 'at risk', slip_days: 0, promised: day(10), forecast: { end: day(12) } },
|
|
55
|
+
{ id: 'billing', title: 'Billing export', status: 'on time', slip_days: 0, promised: day(20), forecast: { end: day(18) } },
|
|
56
|
+
{ id: 'jira-only', title: 'Rate-limit headers', status: 'no plan', jira: { total: 8, done: 3, blocked: 0 } },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
(async () => {
|
|
60
|
+
const exe = findBrowser();
|
|
61
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
62
|
+
let chromium;
|
|
63
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
64
|
+
F = await Fx.start({ name: 'premium-briefing-depth' });
|
|
65
|
+
const ws = F.ws, D = require('./lib/driver.js'), ledger = path.join(path.dirname(F.ledger), 'driver.jsonl');
|
|
66
|
+
F.seedPortfolio();
|
|
67
|
+
/* two Work items and three open proposals: a problem statement and a move on the initiative, a next step on a Work item */
|
|
68
|
+
const w1 = (await F.post('/api/pm-items/add', { line: 'Send the partner onboarding list to Lina' })).body.item;
|
|
69
|
+
const tI = { kind: 'initiative', ws, id: 'scan-ui' };
|
|
70
|
+
const AG = 'agent:sess-4.0a1b2c3d';
|
|
71
|
+
const prop = (id, target, what, data, why, at) => D.append(ledger, { ev: 'proposal', id, target, what, data, why, sources: [{ label: 'Jira', ref: 'IDPF-1204' }], run: null, by: AG }, { now: at });
|
|
72
|
+
const P1 = 'p-bbbbbbbb01', P2 = 'p-bbbbbbbb02', P3 = 'p-bbbbbbbb03';
|
|
73
|
+
prop(P1, tI, 'problem', { text: 'New partners wait 9 days from signed contract to first live API call.' }, 'first draft from the Jira threads', NOW - 3 * 3600000);
|
|
74
|
+
prop(P2, tI, 'move', { to: 'Plan' }, 'the problem and the evidence are in', NOW - 2 * 3600000);
|
|
75
|
+
prop(P3, { kind: 'work', ws, id: w1.id }, 'next-step', { text: 'Send the list to Lina', due: day(-1) }, 'overdue with no next step', NOW - 3600000);
|
|
76
|
+
|
|
77
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
78
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [], gets = [];
|
|
79
|
+
p.on('pageerror', (e) => errs.push(String(e)));
|
|
80
|
+
p.on('request', (r) => { const u = new URL(r.url()); if (r.method() === 'POST') { let b = null; try { b = JSON.parse(r.postData() || 'null'); } catch { /* not JSON */ } posts.push({ path: u.pathname, body: b }); } else if (u.pathname.startsWith('/api/')) gets.push(u.pathname); });
|
|
81
|
+
const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
|
|
82
|
+
let ganttFail = false;
|
|
83
|
+
await p.route('**/api/calendar-views*', (r) => (ganttFail ? json(r, { ok: false, error: 'the Calendar could not be read' }, 500) : json(r, { ok: true, view: 'quarter', gantt: GANTT, no_plan: 2, strategy: [], today: day(0) })));
|
|
84
|
+
await p.route('**/api/scan/now', (r) => json(r, { ok: true, scan: 'scan-00000000ff' }));
|
|
85
|
+
await p.route('**/api/sources/refresh', (r) => json(r, { ok: true, started: 'session' }));
|
|
86
|
+
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
|
|
87
|
+
await until(() => p.evaluate(() => !!document.querySelector('#aroundCard')));
|
|
88
|
+
const rows = () => p.evaluate(() => Object.fromEntries([...document.querySelectorAll('#aroundBody [data-bd]')].map((b) => [b.dataset.bd, { t: b.querySelector('.wtit').textContent, s: (b.querySelector('.ws') || {}).textContent || '', m: (b.querySelector('.wm') || {}).textContent || '' }])));
|
|
89
|
+
await until(() => p.evaluate(() => document.querySelector('#aroundCap') && document.querySelector('#aroundCap').textContent !== 'Reading' && !/Reading…/.test(document.querySelector('#aroundBody').textContent)), 30000);
|
|
90
|
+
const body = () => p.evaluate(() => (document.querySelector('#oMain .bd-a') || {}).textContent || '');
|
|
91
|
+
const open = async (k) => { await p.click(`#aroundBody [data-bd="${k}"]`); await until(() => p.evaluate((x) => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#oMain').dataset.bd === x && !!document.querySelector('#oMain .bd-a *'), k)); };
|
|
92
|
+
const close = async () => { await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))); };
|
|
93
|
+
const click = async (sel) => { await until(() => p.$(sel)); await p.click(sel); };
|
|
94
|
+
const shotDir = process.env.BRIEFING_DEPTH_SHOTS;
|
|
95
|
+
const shot = async (n) => { if (shotDir) { await sleep(700); fs.mkdirSync(shotDir, { recursive: true }); await p.screenshot({ path: path.join(shotDir, n + '.png') }); } };
|
|
96
|
+
|
|
97
|
+
/* R: the card */
|
|
98
|
+
const R0 = await rows();
|
|
99
|
+
ok('R1 the card has five rows in the PRD order', Object.keys(R0).join() === 'prop,men,pulse,scan,src', Object.keys(R0).join());
|
|
100
|
+
ok('R2 agent proposals counts the three open proposals', /^3 agent proposals wait on you/.test(R0.prop.t) && R0.prop.m === '3', JSON.stringify(R0.prop));
|
|
101
|
+
ok('R3 mentions names who waits, from the brief, and leaves out nothing it was not told', R0.men.t === 'Dana in Slack and Priya in Jira are waiting on your reply. 1 more is for your information.' && R0.men.m === 'Reply', JSON.stringify(R0.men));
|
|
102
|
+
ok('R4 the pulse counts what the Calendar said', R0.pulse.t === 'Portfolio pulse: 1 late, 1 at risk' && /1 on plan · 3 with no plan date/.test(R0.pulse.s), JSON.stringify(R0.pulse));
|
|
103
|
+
ok('R5 the scan row counts the waiting proposals', /^Horizon scan: \d+ proposals? waits? for you|^Horizon scan: \d+ proposals wait for you/.test(R0.scan.t) && /^\d+$/.test(R0.scan.m), JSON.stringify(R0.scan));
|
|
104
|
+
ok('R6 the freshness row says it is not live', /not live/.test(R0.src.s) && !/up to date/i.test(R0.src.t + R0.src.s), JSON.stringify(R0.src));
|
|
105
|
+
const cap = await p.evaluate(() => document.querySelector('#aroundCap').textContent);
|
|
106
|
+
ok('R7 the caption counts the rows that wait', /^\d+ to look at$/.test(cap), cap);
|
|
107
|
+
ok('R8 nothing was written on load', posts.length === 0, JSON.stringify(posts));
|
|
108
|
+
await shot('card-1280-light');
|
|
109
|
+
|
|
110
|
+
/* A: agent proposals */
|
|
111
|
+
await open('prop');
|
|
112
|
+
const ptxt = await body();
|
|
113
|
+
ok('A1 the dialog shows what each proposal is, its target, its draft and its why', /Problem statement/.test(ptxt) && /Move to Plan/.test(ptxt) && /Next step/.test(ptxt) && /Initiative · Partner API onboarding/.test(ptxt) && /Work · Send the partner onboarding list to Lina/.test(ptxt) && /New partners wait 9 days/.test(ptxt) && /Why: first draft from the Jira threads/.test(ptxt), ptxt);
|
|
114
|
+
await shot('props-1280-light');
|
|
115
|
+
await click(`.bd-it[data-id="${P1}"] [data-bda="pkeep"]`);
|
|
116
|
+
await until(() => posts.some((x) => x.path === '/api/driver/keep'));
|
|
117
|
+
const keep = posts.find((x) => x.path === '/api/driver/keep');
|
|
118
|
+
ok('A2 Keep posts one keep for that proposal and the ledger holds it', keep && keep.body.proposal === P1 && keep.body.ws === ws, JSON.stringify(keep));
|
|
119
|
+
await until(() => p.evaluate((id) => /Kept\./.test((document.querySelector(`.bd-it[data-id="${id}"] .bd-done`) || {}).textContent || ''), P1));
|
|
120
|
+
ok('A3 the proposal stays, marked Kept, and says what was recorded', /Kept\. /.test(await p.evaluate((id) => document.querySelector(`.bd-it[data-id="${id}"]`).textContent, P1)));
|
|
121
|
+
await click(`.bd-it[data-id="${P2}"] [data-bda="pnote"]`);
|
|
122
|
+
const backBtn = () => p.evaluate((id) => { const b = document.querySelector(`[data-bda="pback"][data-id="${id}"]`); return b ? b.disabled : null; }, P2);
|
|
123
|
+
ok('A4 Send back opens a note box and the press is off until there is a note', await backBtn() === true);
|
|
124
|
+
const before = posts.length;
|
|
125
|
+
await p.evaluate((id) => { const b = document.querySelector(`[data-bda="pback"][data-id="${id}"]`); b.disabled = false; b.click(); }, P2);
|
|
126
|
+
await until(() => p.evaluate(() => /Write one line for the agent/.test((document.querySelector('#oMain .bd-a') || {}).textContent || '')));
|
|
127
|
+
ok('A5 Send back without a note is refused on the page and posts nothing', posts.length === before);
|
|
128
|
+
await p.fill(`[data-bdn="${P2}"]`, 'Wait until the evidence is in.');
|
|
129
|
+
ok('A6 typing a note turns the press on', await backBtn() === false);
|
|
130
|
+
await click(`[data-bda="pback"][data-id="${P2}"]`);
|
|
131
|
+
await until(() => posts.some((x) => x.path === '/api/driver/return'));
|
|
132
|
+
const ret = posts.find((x) => x.path === '/api/driver/return');
|
|
133
|
+
ok('A7 Send back posts return with the note', ret && ret.body.proposal === P2 && ret.body.note === 'Wait until the evidence is in.', JSON.stringify(ret));
|
|
134
|
+
await click(`.bd-it[data-id="${P3}"] [data-bda="pdrop"]`);
|
|
135
|
+
await until(() => posts.some((x) => x.path === '/api/driver/drop'));
|
|
136
|
+
ok('A8 Drop posts drop and says it counts as a correction', posts.some((x) => x.path === '/api/driver/drop' && x.body.proposal === P3) && await until(() => body().then((t) => /Dropped\. It counts as a correction/.test(t))), await body());
|
|
137
|
+
const open1 = (await (await fetch(`${F.BASE}/api/driver/open?target_kind=initiative&ws=${ws}`)).json()).targets || {};
|
|
138
|
+
ok('A9 the ledger no longer lists the three as open', !Object.values(open1).flat().some((x) => [P1, P2, P3].includes(x.id)), JSON.stringify(open1));
|
|
139
|
+
await close();
|
|
140
|
+
await until(() => rows().then((r) => /^No agent proposals wait/.test(r.prop.t)));
|
|
141
|
+
ok('A10 the row now says no agent proposals wait', true);
|
|
142
|
+
|
|
143
|
+
/* M: mentions */
|
|
144
|
+
await open('men');
|
|
145
|
+
const mt = await body();
|
|
146
|
+
ok('M1 the dialog lists the three mentions with the person, quote, place and the reply words', /Dana Hartono/.test(mt) && /Priya Sen/.test(mt) && /Lia Ong/.test(mt) && /Which day can the engineers use the sandbox/.test(mt) && /Refunds are paid within 14 days/.test(mt) && /Needs your reply/.test(mt) && /For your information/.test(mt), mt);
|
|
147
|
+
const tabs = await p.evaluate(() => [...document.querySelectorAll('#oMain [data-bda="mtab"]')].map((b) => b.textContent));
|
|
148
|
+
ok('M2 the tabs count by source', tabs.join() === 'All 3,Slack 1,Jira 1,Confluence 1', tabs.join());
|
|
149
|
+
await click('[data-bda="mtab"][data-k="jira"]');
|
|
150
|
+
ok('M3 a tab shows only that source', await p.evaluate(() => document.querySelectorAll('#oMain .bd-it').length === 1 && /Priya Sen/.test(document.querySelector('#oMain .bd-a').textContent)));
|
|
151
|
+
await click('[data-bda="mtab"][data-k="all"]');
|
|
152
|
+
const link = await p.evaluate((id) => { const a = document.querySelector(`.bd-it[data-id="${id}"] a[data-bdlink]`); return a ? [a.getAttribute('href'), a.target, a.rel, a.textContent] : null; }, M1);
|
|
153
|
+
ok('M4 Open in Slack is the mention\'s https link in a new tab', link && link[0] === 'https://acme.slack.com/archives/D01/p1' && link[1] === '_blank' && /noopener/.test(link[2]) && link[3] === 'Open in Slack', JSON.stringify(link));
|
|
154
|
+
await shot('men-1280-light');
|
|
155
|
+
await click(`.bd-it[data-id="${M1}"] [data-bda="madd"]`);
|
|
156
|
+
await until(() => posts.some((x) => x.path === '/api/pm-items/add' && /Dana/.test((x.body || {}).line || '')));
|
|
157
|
+
const add = posts.filter((x) => x.path === '/api/pm-items/add').pop();
|
|
158
|
+
ok('M5 Make it a task adds one Work item in the console\'s words', add.body.line === 'Reply to Dana (Slack) by today', JSON.stringify(add));
|
|
159
|
+
const items = (await (await fetch(F.BASE + '/api/pm-items')).json()).items || [];
|
|
160
|
+
ok('M6 the Work list holds it', items.some((i) => i.title === 'Reply to Dana (Slack)'), JSON.stringify(items.map((i) => i.title)));
|
|
161
|
+
await click(`.bd-it[data-id="${M2}"] [data-bda="mread"]`);
|
|
162
|
+
await until(() => posts.some((x) => x.path === '/api/mentions/read'));
|
|
163
|
+
const rd = posts.find((x) => x.path === '/api/mentions/read');
|
|
164
|
+
ok('M7 Mark read posts read:true and dims the row, with Mark unread', rd.body.id === M2 && rd.body.read === true && await until(() => p.evaluate((id) => !!document.querySelector(`.bd-it.decided[data-id="${id}"] [data-bda="munread"]`), M2)), JSON.stringify(rd));
|
|
165
|
+
await click(`.bd-it[data-id="${M2}"] [data-bda="munread"]`);
|
|
166
|
+
await until(() => posts.filter((x) => x.path === '/api/mentions/read').length === 2);
|
|
167
|
+
ok('M8 Mark unread posts read:false', posts.filter((x) => x.path === '/api/mentions/read')[1].body.read === false);
|
|
168
|
+
await close();
|
|
169
|
+
ok('M9 the row names who waits again after Mark unread', await until(() => rows().then((r) => /Dana in Slack and Priya in Jira are waiting/.test(r.men.t))), JSON.stringify((await rows()).men));
|
|
170
|
+
|
|
171
|
+
/* P: portfolio pulse */
|
|
172
|
+
await open('pulse');
|
|
173
|
+
const pt = await body();
|
|
174
|
+
ok('P1 the dialog shows the legend with the counts', /Late 1/.test(pt) && /At risk 1/.test(pt) && /On plan 1/.test(pt) && /No plan date 3/.test(pt), pt);
|
|
175
|
+
ok('P2 the late one is first, with the Calendar\'s words', /Delayed \+6 d/.test(pt) && /Forecast \d{4}-\d\d-\d\d vs promised \d{4}-\d\d-\d\d/.test(pt) && pt.indexOf('Partner API onboarding') < pt.indexOf('Self-serve sandbox'), pt);
|
|
176
|
+
ok('P3 a Jira-only row says x of y done in Jira', /3 of 8 done in Jira; no promised date/.test(pt), pt);
|
|
177
|
+
ok('P4 the page says the status is the Calendar\'s and not a forecast of its own', /not a forecast of its own/.test(pt));
|
|
178
|
+
const hrefs = await p.evaluate(() => [...document.querySelectorAll('#oMain a.cta')].map((a) => a.getAttribute('href')));
|
|
179
|
+
ok('P5 Open the initiative goes to the premium initiative page', hrefs.length === 4 && hrefs.every((h) => /^\/premium-initiative\.html\?id=/.test(h)), hrefs.join());
|
|
180
|
+
await shot('pulse-1280-light');
|
|
181
|
+
const n0 = posts.length; await close();
|
|
182
|
+
ok('P6 the pulse wrote nothing', posts.length === n0);
|
|
183
|
+
|
|
184
|
+
/* S: horizon scan */
|
|
185
|
+
await open('scan');
|
|
186
|
+
const st = await body();
|
|
187
|
+
ok('S1 the dialog shows when the scan last ran, when it runs next, a report and its proposals', /Last scan/.test(st) && /Next/.test(st) && /report/i.test(st) && /Dismiss asks for a reason and counts as a correction/.test(st), st);
|
|
188
|
+
ok('S2 each proposal says what Approve does before the press', /Approve creates the initiative in the first stage of the .* workflow\.|Start the research starts a research scan|Approve writes an evidence line on/.test(st), st);
|
|
189
|
+
await shot('scan-1280-light');
|
|
190
|
+
const dis = await p.evaluate(() => { const b = document.querySelector('#oMain [data-bda="sdisopen"]'); return b ? b.dataset.id : null; });
|
|
191
|
+
await click(`[data-bda="sdisopen"][data-id="${dis}"]`);
|
|
192
|
+
ok('S3a Dismiss asks for a reason and is off until there is one', await p.evaluate((id) => document.querySelector(`[data-bda="sdis"][data-id="${id}"]`).disabled, dis));
|
|
193
|
+
await p.fill(`[data-bds="${dis}"]`, 'We already decided this.');
|
|
194
|
+
await click(`[data-bda="sdis"][data-id="${dis}"]`);
|
|
195
|
+
await until(() => posts.some((x) => x.path === '/api/scan/proposal'));
|
|
196
|
+
const sp = posts.find((x) => x.path === '/api/scan/proposal');
|
|
197
|
+
ok('S3 Dismiss posts scan/proposal dismiss for that proposal', sp.body.id === dis && sp.body.action === 'dismiss' && sp.body.ws === ws && sp.body.why === 'We already decided this.', JSON.stringify(sp));
|
|
198
|
+
await until(() => p.evaluate((id) => !!document.querySelector(`.bd-it[data-id="${id}"] [data-bda="sundo"]`), dis));
|
|
199
|
+
ok('S4 a dismissal says it counts as a correction and offers Undo', /Dismissed\. It counts as a correction/.test(await body()), await body());
|
|
200
|
+
await sleep(0);
|
|
201
|
+
await click(`[data-bda="sundo"][data-id="${dis}"]`);
|
|
202
|
+
await until(() => posts.some((x) => x.path === '/api/scan/proposal' && x.body.action === 'undo'));
|
|
203
|
+
ok('S5 Undo posts undo and the proposal waits again', await until(() => p.evaluate((id) => !!document.querySelector(`.bd-it[data-id="${id}"] [data-bda="sdisopen"]`), dis)));
|
|
204
|
+
const app = await p.evaluate(() => { const b = [...document.querySelectorAll('#oMain [data-bda="sapp"]')].find((x) => x.textContent === 'Approve'); return b ? b.dataset.id : null; });
|
|
205
|
+
if (app) {
|
|
206
|
+
await click(`[data-bda="sapp"][data-id="${app}"]`);
|
|
207
|
+
await until(() => posts.some((x) => x.path === '/api/scan/proposal' && x.body.action === 'approve'));
|
|
208
|
+
ok('S6 Approve posts scan/proposal approve', posts.some((x) => x.path === '/api/scan/proposal' && x.body.action === 'approve' && x.body.id === app));
|
|
209
|
+
await until(() => p.evaluate((id) => /Approved\./.test((document.querySelector(`.bd-it[data-id="${id}"]`) || {}).textContent || ''), app) || /did not go through|Dismissed|SERR/.test(''), 8000);
|
|
210
|
+
ok('S7 an approval says what it did, or the server\'s reason', /Approved\. |already|cannot|could not|not found|no such/i.test(await p.evaluate((id) => (document.querySelector(`.bd-it[data-id="${id}"]`) || {}).textContent || '', app)), await body());
|
|
211
|
+
} else ok('S6 the scan holds an Approve proposal', false, st);
|
|
212
|
+
const snowOff = await p.evaluate(() => { const b = document.querySelector('#oMain [data-bda="snow"]'); return b ? b.disabled : null; });
|
|
213
|
+
ok('S8 Scan now says before the press that it starts an agent that reads the web and the repository', /Scan now starts an agent that reads the public web/.test(await body()) && snowOff !== null);
|
|
214
|
+
if (snowOff === false) {
|
|
215
|
+
await click('#oMain [data-bda="snow"]');
|
|
216
|
+
await until(() => posts.some((x) => x.path === '/api/scan/now'));
|
|
217
|
+
ok('S9 Scan now posts one scan/now for the product', posts.filter((x) => x.path === '/api/scan/now').length === 1 && posts.find((x) => x.path === '/api/scan/now').body.ws === ws);
|
|
218
|
+
} else ok('S9 Scan now is off and says why', /switched off|cannot start|left/.test(await body()), await body());
|
|
219
|
+
await close();
|
|
220
|
+
|
|
221
|
+
/* F: data freshness */
|
|
222
|
+
await open('src');
|
|
223
|
+
const ft = await body();
|
|
224
|
+
const srcRows = await p.evaluate(() => document.querySelectorAll('#oMain .bd-src').length);
|
|
225
|
+
ok('F1 the dialog lists the workspace\'s sources with their state and schedule', srcRows >= 3 && /Refresh/.test(ft) && /Sources are read on a schedule, not live/.test(ft) && !/up to date/i.test(ft), ft);
|
|
226
|
+
await shot('src-1280-light');
|
|
227
|
+
const one = await p.evaluate(() => { const b = document.querySelector('#oMain [data-bda="sfone"]'); return b ? b.dataset.id : null; });
|
|
228
|
+
await click(`[data-bda="sfone"][data-id="${one}"]`);
|
|
229
|
+
await until(() => posts.some((x) => x.path === '/api/sources/refresh'));
|
|
230
|
+
const rf = posts.filter((x) => x.path === '/api/sources/refresh');
|
|
231
|
+
ok('F2 Refresh posts one sources/refresh for that source', rf.length === 1 && rf[0].body.source === one && rf[0].body.ws === ws, JSON.stringify(rf));
|
|
232
|
+
await until(() => p.evaluate(() => /agent session started|Rebuilding the facts/.test(document.querySelector('#oMain .bd-a').textContent)));
|
|
233
|
+
ok('F3 it says what it started', true);
|
|
234
|
+
const all = await p.evaluate(() => { const b = document.querySelector('#oMain [data-bda="sfall"]'); return b ? b.disabled : null; });
|
|
235
|
+
if (all === false) {
|
|
236
|
+
const n1 = posts.filter((x) => x.path === '/api/sources/refresh').length;
|
|
237
|
+
await click('#oMain [data-bda="sfall"]');
|
|
238
|
+
await until(() => posts.filter((x) => x.path === '/api/sources/refresh').length > n1);
|
|
239
|
+
const made = posts.filter((x) => x.path === '/api/sources/refresh').slice(n1).map((x) => x.body.source);
|
|
240
|
+
ok('F4 Refresh all posts one for each source but the repository', made.length >= 1 && !made.includes('repository'), made.join());
|
|
241
|
+
} else ok('F4 Refresh all is off when there is nothing to read', true);
|
|
242
|
+
await close();
|
|
243
|
+
|
|
244
|
+
/* E: a source that fails is named, never shown empty */
|
|
245
|
+
ganttFail = true;
|
|
246
|
+
await p.evaluate(() => { document.dispatchEvent(new Event('visibilitychange')); });
|
|
247
|
+
await p.reload();
|
|
248
|
+
await until(() => p.evaluate(() => document.querySelector('#aroundCap') && !/Reading…/.test(document.querySelector('#aroundBody').textContent)), 30000);
|
|
249
|
+
const RE = await rows();
|
|
250
|
+
ok('E1 a pulse that cannot be read says so, and does not read "nothing"', /^Portfolio pulse (could not be read|cannot be read|did not answer|failed)|could not be read/.test(RE.pulse.t) && !/nothing to compare/.test(RE.pulse.t), JSON.stringify(RE.pulse));
|
|
251
|
+
await open('pulse');
|
|
252
|
+
ok('E2 its dialog names the failure', /could not be read|Portfolio pulse/.test(await body()) && await p.evaluate(() => !!document.querySelector('#oMain .nodef.err')), await body());
|
|
253
|
+
await close();
|
|
254
|
+
ganttFail = false;
|
|
255
|
+
|
|
256
|
+
/* W: the POST allow-list */
|
|
257
|
+
const allowed = new Set(['/api/mentions/read', '/api/pm-items/add', '/api/driver/keep', '/api/driver/return', '/api/driver/drop', '/api/scan/proposal', '/api/scan/now', '/api/scan/stop', '/api/sources/refresh']);
|
|
258
|
+
const strays = posts.filter((x) => !allowed.has(x.path));
|
|
259
|
+
ok('W1 every POST is one of the existing routes in the PRD', posts.length > 0 && strays.length === 0, JSON.stringify(strays));
|
|
260
|
+
const fields = { '/api/driver/keep': ['ws', 'proposal'], '/api/driver/return': ['ws', 'proposal', 'note'], '/api/driver/drop': ['ws', 'proposal'], '/api/mentions/read': ['id', 'read'], '/api/pm-items/add': ['line'], '/api/scan/proposal': ['ws', 'id', 'action', 'why'], '/api/scan/now': ['ws'], '/api/sources/refresh': ['ws', 'source'] };
|
|
261
|
+
const extra = posts.filter((x) => fields[x.path] && Object.keys(x.body || {}).some((k) => !fields[x.path].includes(k)));
|
|
262
|
+
ok('W2 no POST carries a field the route was not told', extra.length === 0, JSON.stringify(extra));
|
|
263
|
+
ok('W3 every GET the card made is a console route in the PRD', gets.filter((g) => !['/api/briefing-premium', '/api/brief-page', '/api/driver/open', '/api/calendar-views', '/api/scan/portfolio', '/api/sources', '/api/pm-items', '/api/workspaces', '/api/products', '/api/state'].includes(g) && /around|depth|bd-/.test(g)).length === 0);
|
|
264
|
+
|
|
265
|
+
/* L: floors */
|
|
266
|
+
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
|
|
267
|
+
await until(() => p.evaluate(() => document.querySelector('#aroundCap') && !/Reading…/.test(document.querySelector('#aroundBody').textContent)), 30000);
|
|
268
|
+
await p.setViewportSize({ width: 390, height: 844 }); await sleep(300);
|
|
269
|
+
await shot('card-390-light');
|
|
270
|
+
const side = await p.evaluate(() => document.documentElement.scrollWidth - innerWidth);
|
|
271
|
+
ok('L1 at 390 wide the page does not scroll sideways', side <= 0, String(side));
|
|
272
|
+
const small = await p.evaluate(() => [...document.querySelectorAll('#aroundBody [data-bd]')].filter((b) => b.getBoundingClientRect().height < 44).map((b) => b.dataset.bd));
|
|
273
|
+
ok('L2 every row is 44 px tall at least', small.length === 0, small.join());
|
|
274
|
+
await open('men');
|
|
275
|
+
const wide = await p.evaluate(() => { const d = document.querySelector('#oMain'); return [document.documentElement.scrollWidth - innerWidth, d.scrollWidth - d.clientWidth]; });
|
|
276
|
+
await shot('men-390-light');
|
|
277
|
+
const sm2 = await p.evaluate(() => [...document.querySelectorAll('#oMain .bd-a button, #oMain .bd-a a.cta')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent));
|
|
278
|
+
ok('L3 a dialog at 390 wide does not scroll sideways and its buttons are 44 px tall', wide[0] <= 0 && wide[1] <= 1 && sm2.length === 0, wide.join() + ' ' + sm2.join());
|
|
279
|
+
await close();
|
|
280
|
+
await p.setViewportSize({ width: 1280, height: 900 });
|
|
281
|
+
await p.emulateMedia({ colorScheme: 'dark' }); await sleep(200);
|
|
282
|
+
await shot('card-1280-dark');
|
|
283
|
+
await open('prop').catch(() => {});
|
|
284
|
+
await close().catch(() => {});
|
|
285
|
+
const raw = await p.evaluate(() => { const c = getComputedStyle(document.querySelector('#aroundCard')); return [c.backgroundColor, getComputedStyle(document.body).backgroundColor]; });
|
|
286
|
+
ok('L4 in the dark theme the card has a background of its own', raw[0] !== 'rgba(0, 0, 0, 0)' && raw[0] !== raw[1] || raw[0] !== '', raw.join());
|
|
287
|
+
const focus = await p.evaluate(() => { const b = document.querySelector('#aroundBody [data-bd]'); b.focus(); const c = getComputedStyle(b); return [c.outlineStyle, c.outlineWidth, c.boxShadow]; });
|
|
288
|
+
ok('L5 a row shows a focus ring', focus[0] !== 'none' || focus[2] !== 'none', focus.join());
|
|
289
|
+
ok('L6 no script error', errs.length === 0, errs.join(' | '));
|
|
290
|
+
return finish();
|
|
291
|
+
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -1599,3 +1599,35 @@ button.m3-stc{min-height:44px;margin:-7px 0}button.m3-stc:hover{background:var(-
|
|
|
1599
1599
|
.m3-ln{display:grid;grid-template-columns:44px 56px minmax(0,1fr);gap:10px;text-align:left;padding:8px 10px;border-radius:14px;font-size:var(--t-body);color:var(--ink-2);line-height:1.45;min-height:44px}.m3-ln time{font:500 var(--t-small) var(--mono);color:var(--ink-3)}.m3-ln b{color:var(--ink)}.m3-ln:hover{background:var(--well)}.m3-ln.cur{background:var(--well);color:var(--ink)}
|
|
1600
1600
|
.m3-shot{margin:8px 0;display:grid;gap:6px}.m3-shot img{max-width:100%;border-radius:14px;border:1px solid var(--hair)}.m3-shot figcaption{margin:0}
|
|
1601
1601
|
@media (max-width:1000px){.m3-cap{grid-template-columns:1fr}.m3-kps button,.m3-kp0{grid-template-columns:70px minmax(0,1fr)}.m3-kps time,.m3-kp0 em{display:none}.m3-ln{grid-template-columns:40px 48px minmax(0,1fr)}}
|
|
1602
|
+
|
|
1603
|
+
/* ── Around you (initiative premium-briefing-depth): the card on the Briefing and the dialogs its rows open. Own block, prefix bd-. ───────────────────── */
|
|
1604
|
+
#aroundCard .bd-rows{margin-top:6px}
|
|
1605
|
+
#aroundCard .due.od{color:var(--ember-ink);background:color-mix(in oklab,var(--ember) 16%,transparent)}
|
|
1606
|
+
.bd-note{margin-top:14px}
|
|
1607
|
+
.bd-a{display:grid;gap:2px}
|
|
1608
|
+
.bd-a .cta{height:44px;padding:0 18px;margin:0}
|
|
1609
|
+
.bd-top{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin:0 0 6px}.bd-top p{margin:0;font-size:var(--t-small);color:var(--ink-2)}
|
|
1610
|
+
.bd-list{display:grid}
|
|
1611
|
+
.bd-it{padding:16px 0;border-top:1px solid var(--hair)}
|
|
1612
|
+
.bd-list>.bd-it:first-child{border-top:0;padding-top:4px}
|
|
1613
|
+
.bd-h{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-bottom:8px}
|
|
1614
|
+
.bd-chip{display:inline-flex;align-items:center;min-height:26px;padding:0 11px;border-radius:14px;background:var(--well);font-size:var(--t-small);font-weight:650;color:var(--ink-2)}
|
|
1615
|
+
.bd-chip.hot{color:var(--bad)}.bd-chip.warn{color:var(--ember-ink)}.bd-chip.mono{font-family:var(--mono);font-weight:500}
|
|
1616
|
+
.bd-t{display:block;font-size:var(--t-body);font-weight:650;line-height:1.35;color:var(--ink)}
|
|
1617
|
+
.bd-q{margin:6px 0;padding-left:12px;border-left:2px solid var(--hair);color:var(--ink);overflow-wrap:anywhere}
|
|
1618
|
+
.bd-why{margin:4px 0;font-size:var(--t-small);line-height:1.5;color:var(--ink-3);overflow-wrap:anywhere}
|
|
1619
|
+
.bd-it.decided .bd-t,.bd-it.decided .bd-q{opacity:.62}
|
|
1620
|
+
.bd-acts{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:12px}
|
|
1621
|
+
.bd-done{display:flex;gap:8px;align-items:flex-start;margin:10px 0 0;font-size:var(--t-small);line-height:1.5;color:var(--ink-2)}.bd-done svg{width:16px;height:16px;flex:none;margin-top:2px;color:var(--ok)}
|
|
1622
|
+
.bd-l{display:block;margin-top:10px;font-size:var(--t-small);color:var(--ink-2)}
|
|
1623
|
+
.bd-a textarea{display:block;width:100%;min-height:80px;margin-top:6px;padding:10px 12px;border:0;border-radius:12px;background:var(--well);color:var(--ink);font:inherit;font-size:var(--t-body);box-shadow:inset 0 0 0 1.5px var(--hair);resize:vertical}
|
|
1624
|
+
.bd-bar{display:flex;height:6px;max-width:240px;margin-top:8px;border-radius:6px;overflow:hidden;background:var(--well)}.bd-bar i{display:block;height:100%}
|
|
1625
|
+
.bd-bar .bad,.bd-leg .bad{background:var(--bad)}.bd-bar .warn,.bd-leg .warn{background:var(--ember)}.bd-bar .ok,.bd-leg .ok{background:var(--ok)}.bd-bar .none,.bd-leg .none{background:color-mix(in oklab,var(--ink) 22%,transparent)}
|
|
1626
|
+
.bd-leg{display:flex;gap:14px;flex-wrap:wrap;margin:8px 0 4px;font-size:var(--t-small);color:var(--ink-2)}.bd-leg i{display:inline-block;width:8px;height:8px;margin-right:6px;border-radius:50%}
|
|
1627
|
+
.bd-more{margin:14px 0 0}.bd-more summary{cursor:pointer;min-height:44px;display:flex;align-items:center;font-size:var(--t-small);color:var(--ink-2)}
|
|
1628
|
+
.bd-steps{display:grid;gap:8px;margin:12px 0 0}.bd-steps div{display:flex;gap:10px;align-items:center;font-size:var(--t-small);color:var(--ink-2)}
|
|
1629
|
+
.bd-steps i{width:8px;height:8px;flex:none;border-radius:50%;background:var(--hair)}.bd-steps .work i{background:var(--ember)}.bd-steps .done i{background:var(--ok)}
|
|
1630
|
+
.bd-src{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;padding:12px 0;border-top:1px solid var(--hair)}
|
|
1631
|
+
.bd-src b{display:block;font-weight:650}.bd-src small{display:block;margin-top:2px;font-size:var(--t-small);color:var(--ink-3)}
|
|
1632
|
+
.bd-st{font-weight:650}.bd-st.stale,.bd-st.failed{color:var(--ember-ink)}.bd-st.never{color:var(--bad)}
|
|
1633
|
+
@media (max-width:700px){.bd-acts .cta{flex:1 1 auto;justify-content:center}.bd-src{grid-template-columns:minmax(0,1fr)}}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Slice 3: the reply box asks a read-only agent. A control with nothing honest to write stays disabled and says why. */
|
|
5
5
|
import { pmPost, pmGet } from './http.js';
|
|
6
6
|
import { mountMeeting } from './premium-meeting.js';
|
|
7
|
+
import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
|
|
7
8
|
import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail, pvFeed } from './premium-shell.js';
|
|
8
9
|
const ICON = {
|
|
9
10
|
meeting: '<rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/>',
|
|
@@ -252,8 +253,439 @@ $('#pickMenu').addEventListener('click', async (e) => {
|
|
|
252
253
|
const again = b.dataset.ws ? $(`#pickMenu [data-ws="${CSS.escape(b.dataset.ws)}"]`) : null; if (again) again.focus();
|
|
253
254
|
});
|
|
254
255
|
|
|
256
|
+
/* ── Around you: what the agents and the outside world left for you (initiative premium-briefing-depth) ─────────────────────────────
|
|
257
|
+
* One card under Today with five rows; each row opens the standard dialog. Every read is a route the console already uses and every
|
|
258
|
+
* write is a press that says what it does first, through the launch nonce (pmPost). A source that cannot be read is named in its row,
|
|
259
|
+
* never shown as empty. Which products: ?ws=<id> that one, otherwise every product the Briefing reads. */
|
|
260
|
+
const SRCN = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail' };
|
|
261
|
+
const srcName = (s) => SRCN[s] || String(s || 'a source');
|
|
262
|
+
const first = (s) => String(s || '').trim().split(/\s+/)[0];
|
|
263
|
+
const pl = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
264
|
+
const BDI = {
|
|
265
|
+
at: '<circle cx="12" cy="12" r="4"/><path d="M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1"/>',
|
|
266
|
+
prop: '<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>',
|
|
267
|
+
pulse: '<path d="M3 12h4l3-7 4 14 3-7h4"/>',
|
|
268
|
+
scan: '<circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/>',
|
|
269
|
+
src: '<path d="M20 11a8 8 0 0 0-14.6-4.5M4 13a8 8 0 0 0 14.6 4.5"/><path d="M5 3v4h4M19 21v-4h-4"/>',
|
|
270
|
+
ret: '<path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 0 12h-3"/>',
|
|
271
|
+
x: '<path d="M6 6l12 12M18 6 6 18"/>',
|
|
272
|
+
};
|
|
273
|
+
const bdIco = (d) => `<svg class="i" viewBox="0 0 24 24">${d}</svg>`;
|
|
274
|
+
const A = { prop: null, men: null, pulse: null, scan: null, src: null }; // the last answer of each source: { ok, … } or { ok: false, error }
|
|
275
|
+
const DEC = new Map(); // proposals decided on this visit: id → { item, st: 'kept' | 'back' | 'dropped', note, wrote, warnings }
|
|
276
|
+
const PNOTE = {}, PERR = {}, PBACK = new Set(); // the send-back note typed, the refusal shown, the proposals whose note box is open
|
|
277
|
+
const MREAD = new Map(), MADD = new Set(); // mentions marked read or unread on this visit; mentions made a task
|
|
278
|
+
const SDEC = new Map(); // scan proposals decided on this visit: id → { st: 'ok' | 'no', result }
|
|
279
|
+
const SERR = {}, SWHY = {}, SOPEN = new Set(); // a scan proposal's dismissal reason, and the proposals whose reason box is open
|
|
280
|
+
let MTAB = 'all', BUSY = '';
|
|
281
|
+
const getj = async (p) => { const r = await pmGet(p); return r && r.ok !== false ? r : { ok: false, error: (r && r.error) || 'the server did not answer' }; };
|
|
282
|
+
const wq = (ws) => (ws ? 'ws=' + encodeURIComponent(ws) : '');
|
|
283
|
+
const prods = () => {
|
|
284
|
+
const one = wsParam(); if (one) return [{ ws: one, name: one }];
|
|
285
|
+
const P = M && M.products;
|
|
286
|
+
return P ? P.available.filter((x) => x.on).map((x) => ({ ws: x.ws, name: x.name })) : [{ ws: '', name: '' }];
|
|
287
|
+
};
|
|
288
|
+
const said = (r) => 'could not be read: ' + (r && r.error ? r.error : 'the server did not answer');
|
|
289
|
+
|
|
290
|
+
/* reads */
|
|
291
|
+
async function readProps(P) {
|
|
292
|
+
const items = [], errs = [];
|
|
293
|
+
await Promise.all(P.flatMap((p) => ['initiative', 'work'].map(async (kind) => {
|
|
294
|
+
const r = await getj('/api/driver/open?target_kind=' + kind + (p.ws ? '&' + wq(p.ws) : ''));
|
|
295
|
+
if (!r.ok) { errs.push(r.error); return; }
|
|
296
|
+
if (r.mode !== 'approve') return; // Off and Shadow raise nothing on the Briefing (the console draws the same)
|
|
297
|
+
for (const [tid, list] of Object.entries(r.targets || {})) for (const pr of list) items.push({ id: pr.id, ws: r.ws, pname: P.length > 1 ? p.name : '', kind, tid, p: pr, title: '' });
|
|
298
|
+
})));
|
|
299
|
+
items.sort((a, b) => String(a.p.at).localeCompare(String(b.p.at)) || a.id.localeCompare(b.id));
|
|
300
|
+
if (items.some((x) => x.kind === 'work')) {
|
|
301
|
+
const w = await getj('/api/pm-items'), by = new Map(((w.ok && w.items) || []).map((i) => [i.id, i.title]));
|
|
302
|
+
items.forEach((x) => { if (x.kind === 'work') x.title = by.get(x.tid) || ''; });
|
|
303
|
+
}
|
|
304
|
+
if (!items.length && errs.length) return { ok: false, error: errs[0] };
|
|
305
|
+
return { ok: true, items, errs };
|
|
306
|
+
}
|
|
307
|
+
async function readMen() {
|
|
308
|
+
const r = await getj('/api/brief-page');
|
|
309
|
+
return r.ok ? { ok: true, list: Array.isArray(r.mentions) ? r.mentions : null } : r;
|
|
310
|
+
}
|
|
311
|
+
const PST = { 'on time': ['ok', 'On time'], 'at risk': ['warn', 'At risk'], delayed: ['bad', 'Delayed'], overdue: ['bad', 'Overdue'], 'no plan': ['', 'No plan'] };
|
|
312
|
+
/** One Calendar row as the pulse draws it. cls: bad (late) · warn (at risk) · ok (on plan) · '' (no plan date). The Calendar's own status, no forecast of ours. */
|
|
313
|
+
function pulseRow(g) {
|
|
314
|
+
const j = g.jira && Number.isInteger(g.jira.total) && g.jira.total > 0 && Number.isInteger(g.jira.done) ? g.jira : null;
|
|
315
|
+
const f = (g.forecast && (g.forecast.end || g.forecast.start)) || null;
|
|
316
|
+
if (j && (!PST[g.status] || g.status === 'no plan')) {
|
|
317
|
+
const all = j.done >= j.total;
|
|
318
|
+
return { id: g.id, title: g.title || g.id, cls: j.blocked > 0 ? 'warn' : all ? 'ok' : '', word: j.blocked > 0 ? 'Blocked' : all ? 'Done in Jira' : 'In progress',
|
|
319
|
+
why: j.done + ' of ' + j.total + ' done in Jira' + (j.blocked > 0 ? ', ' + j.blocked + ' blocked' : '') + '; no promised date' };
|
|
320
|
+
}
|
|
321
|
+
const k = PST[g.status] ? g.status : 'no plan', p = g.promised || null;
|
|
322
|
+
return { id: g.id, title: g.title || g.id, cls: PST[k][0], word: PST[k][1] + (g.slip_days > 0 ? ' +' + g.slip_days + ' d' : ''),
|
|
323
|
+
why: (p ? 'Forecast ' + (f || 'not set') + ' vs promised ' + p : 'No promised date' + (f ? '; forecast ' + f : '')) + (j ? '. ' + j.done + ' of ' + j.total + ' done in Jira' : '') };
|
|
324
|
+
}
|
|
325
|
+
async function readPulse(P) {
|
|
326
|
+
const d = new Date(), day = d.getFullYear() + '-' + STAMP(d.getMonth() + 1) + '-' + STAMP(d.getDate()), rows = [], errs = [];
|
|
327
|
+
let none = 0;
|
|
328
|
+
await Promise.all(P.map(async (p, i) => {
|
|
329
|
+
const r = await getj('/api/calendar-views?view=quarter&only=gantt&date=' + day + (p.ws ? '&' + wq(p.ws) : ''));
|
|
330
|
+
if (!r.ok) { errs.push(r.error); return; }
|
|
331
|
+
none += Number(r.no_plan) || 0;
|
|
332
|
+
for (const g of r.gantt || []) rows.push({ ...pulseRow(g), ws: p.ws, pname: P.length > 1 ? p.name : '', at: i });
|
|
333
|
+
}));
|
|
334
|
+
rows.sort((a, b) => a.at - b.at);
|
|
335
|
+
if (!rows.length && !none && errs.length) return { ok: false, error: errs[0] };
|
|
336
|
+
return { ok: true, rows, none, errs };
|
|
337
|
+
}
|
|
338
|
+
async function readScan(P) {
|
|
339
|
+
const got = [], errs = [];
|
|
340
|
+
await Promise.all(P.map(async (p, i) => {
|
|
341
|
+
const r = await getj('/api/scan/portfolio' + (p.ws ? '?' + wq(p.ws) : ''));
|
|
342
|
+
if (!r.ok) errs.push(r.error); else got.push({ ...r, pname: P.length > 1 ? p.name : '', at: i });
|
|
343
|
+
}));
|
|
344
|
+
got.sort((a, b) => a.at - b.at);
|
|
345
|
+
if (!got.length && errs.length) return { ok: false, error: errs[0] };
|
|
346
|
+
return { ok: true, scans: got, errs };
|
|
347
|
+
}
|
|
348
|
+
const readSrc = () => getj('/api/sources' + (wsParam() ? '?' + wq(wsParam()) : ''));
|
|
349
|
+
const readAll = async (which) => {
|
|
350
|
+
const P = prods(), all = !which, job = {
|
|
351
|
+
prop: () => readProps(P), men: () => readMen(), pulse: () => readPulse(P), scan: () => readScan(P), src: () => readSrc(),
|
|
352
|
+
};
|
|
353
|
+
await Promise.all(Object.keys(job).filter((k) => all || which.includes(k)).map(async (k) => { try { A[k] = await job[k](); } catch (e) { A[k] = { ok: false, error: String((e && e.message) || e) }; } }));
|
|
354
|
+
drawAround();
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/* words */
|
|
358
|
+
const PWHAT = { problem: 'Problem statement', evidence: 'Evidence', sizing: 'Opportunity sizing', assumption: 'Riskiest assumption and spike brief', stakeholders: 'Stakeholders', move: 'Move', note: 'Note', 'next-step': 'Next step', 'follow-up': 'Follow-up' };
|
|
359
|
+
const pWhat = (p) => (p.what === 'move' && p.data && p.data.to ? 'Move to ' + p.data.to : PWHAT[p.what] || p.what);
|
|
360
|
+
const pKeep = (p) => ({ problem: 'Keep writes the problem statement into the stage record.', move: 'Keep moves the initiative on its board.', 'next-step': 'Keep adds the next step to your Work item.', 'follow-up': 'Keep copies the follow-up text. Nothing is sent to anyone.', doc: 'Keep issues the draft document.' }[p.what] || 'Keep records that you accept it. Nothing else changes.');
|
|
361
|
+
const pWrote = (w) => ({ problem: 'The problem statement is in the stage record.', move: 'The initiative moved.', doc: 'The document was issued.', 'next-step': 'The next step is in your Work item.' }[w] || 'It is recorded. Nothing else changed.');
|
|
362
|
+
const pText = (p) => {
|
|
363
|
+
const t = p.data && typeof p.data.text === 'string' ? p.data.text : '';
|
|
364
|
+
if (p.what === 'move') return 'Move this initiative to ' + ((p.data && p.data.to) || 'the next stage') + '.';
|
|
365
|
+
if (t) return t;
|
|
366
|
+
if (p.data && Array.isArray(p.data.items)) return pl(p.data.items.length, 'item', 'items') + ' with a pointer each.';
|
|
367
|
+
return '';
|
|
368
|
+
};
|
|
369
|
+
const iniTitle = (x) => { const r = A.pulse && A.pulse.ok && A.pulse.rows.find((y) => y.id === x.tid && y.ws === x.ws); return r ? r.title : ''; };
|
|
370
|
+
const targetOf = (x) => (x.kind === 'work' ? 'Work · ' : 'Initiative · ') + (x.title || (x.kind === 'initiative' ? iniTitle(x) : '') || x.tid);
|
|
371
|
+
const openProps = () => (A.prop && A.prop.ok ? A.prop.items : []);
|
|
372
|
+
const shownMen = () => {
|
|
373
|
+
const l = A.men && A.men.ok && A.men.list ? A.men.list : [];
|
|
374
|
+
return l.filter((m) => !m.in_needs && (MREAD.has(m.id) || !m.read)).map((m) => (MREAD.has(m.id) ? { ...m, read: MREAD.get(m.id) } : m));
|
|
375
|
+
};
|
|
376
|
+
const waitM = (l) => l.filter((m) => m.reply && !m.read);
|
|
377
|
+
function menLine(l) {
|
|
378
|
+
const w = waitM(l), rest = l.filter((m) => !m.read).length - w.length;
|
|
379
|
+
if (!w.length) return rest ? 'No one is waiting on a reply. ' + pl(rest, 'mention is', 'mentions are') + ' for your information.' : 'No mentions are left unread.';
|
|
380
|
+
const names = w.map((m) => (m.who ? first(m.who) : 'Someone') + ' in ' + srcName(m.source)), s = names.length < 2 ? names[0] : names.slice(0, -1).join(', ') + ' and ' + names[names.length - 1];
|
|
381
|
+
return s + (w.length === 1 ? ' is' : ' are') + ' waiting on your reply.' + (rest ? ' ' + rest + (rest === 1 ? ' more is' : ' more are') + ' for your information.' : '');
|
|
382
|
+
}
|
|
383
|
+
const mWhen = (iso) => {
|
|
384
|
+
if (!iso) return '';
|
|
385
|
+
const d = new Date(iso), n = new Date(), hm = STAMP(d.getHours()) + ':' + STAMP(d.getMinutes()), k = (x) => x.getFullYear() * 400 + x.getMonth() * 32 + x.getDate(), y = new Date(n); y.setDate(y.getDate() - 1);
|
|
386
|
+
return k(d) === k(n) ? hm : k(d) === k(y) ? 'yesterday ' + hm : d.getDate() + '/' + (d.getMonth() + 1) + ' ' + hm;
|
|
387
|
+
};
|
|
388
|
+
const groups = (rows) => ({ bad: rows.filter((r) => r.cls === 'bad'), warn: rows.filter((r) => r.cls === 'warn'), ok: rows.filter((r) => r.cls === 'ok'), none: rows.filter((r) => !r.cls) });
|
|
389
|
+
const PGW = { bad: 'Late', warn: 'At risk', ok: 'On plan', none: 'No plan date' };
|
|
390
|
+
const bar = (g, n, extra) => `<span class="bd-bar" aria-hidden="true">${['bad', 'warn', 'ok', 'none'].map((k) => { const c = k === 'none' ? g.none.length + extra : g[k].length; return c ? `<i class="${k}" style="width:${c / n * 100}%"></i>` : ''; }).join('')}</span>`;
|
|
391
|
+
const dayWord = (iso) => {
|
|
392
|
+
const d = new Date(iso); if (!Number.isFinite(d.getTime())) return '';
|
|
393
|
+
const n = new Date(), y = new Date(n), hm = STAMP(d.getHours()) + ':' + STAMP(d.getMinutes()); y.setDate(y.getDate() - 1);
|
|
394
|
+
return d.toDateString() === n.toDateString() ? 'today, ' + hm : d.toDateString() === y.toDateString() ? 'yesterday, ' + hm : d.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()] + ', ' + hm;
|
|
395
|
+
};
|
|
396
|
+
const scanOpen = () => (A.scan && A.scan.ok ? A.scan.scans.reduce((n, s) => n + (s.proposals_waiting || 0), 0) : 0);
|
|
397
|
+
const behindSrc = () => {
|
|
398
|
+
if (!A.src || !A.src.ok) return [];
|
|
399
|
+
const ids = behindOf(lineItems(A.src.sources)).map((i) => i.id);
|
|
400
|
+
return A.src.sources.filter((s) => ids.includes(s.id));
|
|
401
|
+
};
|
|
402
|
+
const joinN = (a) => (a.length < 2 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
|
|
403
|
+
|
|
404
|
+
/** The five rows of the card: { k, ic, t, s, m (count html), bar, wait }. Pure of the DOM; every word comes from A. */
|
|
405
|
+
function aroundRows() {
|
|
406
|
+
const R = [], rd = 'Reading…';
|
|
407
|
+
{ // agent proposals
|
|
408
|
+
const a = A.prop, n = a && a.ok ? a.items.length : 0;
|
|
409
|
+
R.push({ k: 'prop', ic: BDI.prop, wait: n > 0,
|
|
410
|
+
t: !a ? rd : !a.ok ? 'Agent proposals ' + said(a) : n ? pl(n, 'agent proposal waits', 'agent proposals wait') + ' on you' : 'No agent proposals wait',
|
|
411
|
+
s: !a ? '' : !a.ok ? '' : n ? 'Keep, send back or drop each one' : 'The agent files a draft here when it has one', m: n ? `<span class="due">${n}</span>` : '' });
|
|
412
|
+
}
|
|
413
|
+
{ // mentions
|
|
414
|
+
const a = A.men, l = shownMen(), w = waitM(l);
|
|
415
|
+
R.push({ k: 'men', ic: BDI.at, wait: w.length > 0,
|
|
416
|
+
t: !a ? rd : !a.ok ? 'Mentions ' + said(a) : a.list === null ? 'No brief for today, so no mentions were read' : l.filter((m) => !m.read).length ? menLine(l) : 'No one has mentioned you today',
|
|
417
|
+
s: !a || !a.ok || !l.filter((m) => !m.read).length ? '' : [...new Set(l.filter((m) => !m.read).map((m) => srcName(m.source)))].join(', '),
|
|
418
|
+
m: w.length ? '<span class="due od">Reply</span>' : '' });
|
|
419
|
+
}
|
|
420
|
+
{ // portfolio pulse
|
|
421
|
+
const a = A.pulse, g = a && a.ok ? groups(a.rows) : null, n = a && a.ok ? a.rows.length + a.none : 0;
|
|
422
|
+
R.push({ k: 'pulse', ic: BDI.pulse, wait: !!(g && g.bad.length),
|
|
423
|
+
t: !a ? rd : !a.ok ? 'Portfolio pulse ' + said(a) : n ? `Portfolio pulse: ${g.bad.length} late, ${g.warn.length} at risk` : 'Portfolio pulse: nothing to compare yet',
|
|
424
|
+
s: !a || !a.ok ? '' : n ? `${g.ok.length} on plan · ${g.none.length + a.none} with no plan date` : 'No initiative has a promised date or a Jira read.',
|
|
425
|
+
bar: n ? bar(g, n, a.none) : '', m: '' });
|
|
426
|
+
}
|
|
427
|
+
{ // horizon scan
|
|
428
|
+
const a = A.scan, S = a && a.ok ? a.scans : [], w = scanOpen(), run = S.some((x) => x.open), last = S.map((x) => x.last && x.last.at).filter(Boolean).sort().pop(), nrep = S.reduce((n, x) => n + x.reports.filter((r) => r.written && !r.parent).length, 0);
|
|
429
|
+
R.push({ k: 'scan', ic: BDI.scan, wait: w > 0,
|
|
430
|
+
t: !a ? rd : !a.ok ? 'Horizon scan ' + said(a) : run ? 'Horizon scan: scanning now' : w ? 'Horizon scan: ' + pl(w, 'proposal waits', 'proposals wait') + ' for you' : S.every((x) => x.switched_off) ? 'Horizon scan: switched off' : last ? 'Horizon scan: nothing waits' : 'Horizon scan: no scan has run yet',
|
|
431
|
+
s: !a || !a.ok ? '' : run ? 'Reading the web and the repository' : last ? 'Ran ' + dayWord(last).toLowerCase() + (nrep ? ' · ' + pl(nrep, 'report', 'reports') : '') : 'Start one from here', m: w ? `<span class="due">${w}</span>` : '' });
|
|
432
|
+
}
|
|
433
|
+
{ // data freshness
|
|
434
|
+
const a = A.src, b = behindSrc();
|
|
435
|
+
R.push({ k: 'src', ic: BDI.src, wait: b.length > 0,
|
|
436
|
+
t: !a ? rd : !a.ok ? 'Data freshness ' + said(a) : b.length > 2 ? b.length + ' sources need a new read' : b.length ? joinN(b.map((s) => s.label)) + (b.length === 1 ? ' needs' : ' need') + ' a new read' : 'Every source was read recently',
|
|
437
|
+
s: !a || !a.ok ? '' : b.length > 2 ? joinN(b.map((s) => s.label)) + '. Read on a schedule, not live' : 'Sources are read on a schedule, not live', m: b.length ? `<span class="due">${b.length}</span>` : '' });
|
|
438
|
+
}
|
|
439
|
+
return R;
|
|
440
|
+
}
|
|
441
|
+
function drawAround() {
|
|
442
|
+
const B = $('#aroundBody'); if (!B) return;
|
|
443
|
+
const R = aroundRows(), n = R.filter((r) => r.wait).length;
|
|
444
|
+
B.innerHTML = R.map((r) => `<div class="wrw"><div class="wrow sm" data-bdrow="${r.k}"><span class="wgl" aria-hidden="true">${bdIco(r.ic)}</span><button type="button" class="wrh" data-bd="${r.k}" aria-haspopup="dialog"><span class="wtx"><span class="wtit">${esc(r.t)}</span>${r.s ? `<span class="ws">${esc(r.s)}</span>` : ''}${r.bar || ''}</span>${r.m ? `<span class="wm">${r.m}</span>` : ''}</button></div></div>`).join('');
|
|
445
|
+
$('#aroundCap').textContent = Object.values(A).some((x) => x === null) ? 'Reading' : n ? n + ' to look at' : 'quiet';
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/* the dialogs: each draws into the dialog's Detail pane and redraws after a press. The question box stays out: these rows have no agent thread. */
|
|
449
|
+
function bdDlg(key, eye, title, sub, say, draw, onPress, onInput) {
|
|
450
|
+
openDlg({ eye, title, sub, say, stream: turnA(ptx(say)), noteKey: null, pane: '<article class="paper doc"><div class="bd-a"></div></article>', label: title });
|
|
451
|
+
$('#askF').hidden = true; $('#askNote').hidden = true; setMode('detail');
|
|
452
|
+
const o = $('#oMain'); o.dataset.bd = key;
|
|
453
|
+
const redraw = (focus) => {
|
|
454
|
+
$('.bd-a', o).innerHTML = draw();
|
|
455
|
+
if (focus) { const f = $(focus, o) || $('.bd-a button:not([disabled]), .bd-a a', o); if (f) f.focus(); }
|
|
456
|
+
};
|
|
457
|
+
o.onclick = (e) => { if (o.dataset.bd === key) onPress(e, redraw); };
|
|
458
|
+
o.oninput = (e) => { if (o.dataset.bd === key && onInput) onInput(e); };
|
|
459
|
+
redraw();
|
|
460
|
+
return redraw;
|
|
461
|
+
}
|
|
462
|
+
const bdActs = (...b) => `<div class="bd-acts">${b.join('')}</div>`;
|
|
463
|
+
const bdBtn = (label, act, id, alt, attrs) => `<button type="button" class="cta${alt ? ' alt' : ''}" data-bda="${act}"${id != null ? ` data-id="${esc(id)}"` : ''}${attrs || ''}>${esc(label)}</button>`;
|
|
464
|
+
const bdDone = (ok, text) => `<p class="bd-done" role="status">${ok ? CHECK : bdIco(BDI.x)}<span>${esc(text)}</span></p>`;
|
|
465
|
+
const bdChip = (t, c) => `<span class="bd-chip${c ? ' ' + c : ''}">${esc(t)}</span>`;
|
|
466
|
+
const bdLink = (href) => (/^https:\/\/\S+$/i.test(String(href || '')) ? href : '');
|
|
467
|
+
const bdFail = (id, e) => (e[id] ? `<p class="nodef err" role="alert">${esc(e[id])}</p>` : '');
|
|
468
|
+
|
|
469
|
+
/* ── agent proposals ── */
|
|
470
|
+
function propItem(it) {
|
|
471
|
+
const p = it.p, d = DEC.get(it.id), id = it.id, text = pText(p);
|
|
472
|
+
const src = (p.sources || []).filter((s) => s && s.ref).map((s) => (bdLink(s.ref) ? `<a href="${esc(bdLink(s.ref))}" target="_blank" rel="noopener noreferrer">${esc(s.label || s.ref)}</a>` : esc((s.label ? s.label + ': ' : '') + s.ref))).join(' · ');
|
|
473
|
+
let act;
|
|
474
|
+
if (d) act = d.st === 'kept' ? bdDone(true, 'Kept. ' + pWrote(d.wrote) + (d.warnings.length ? ' ' + d.warnings.join(' ') : '')) : d.st === 'back' ? bdDone(true, 'Sent back with your note: “' + d.note + '”. The note starts a new run.') : bdDone(false, 'Dropped. It counts as a correction.');
|
|
475
|
+
else if (PBACK.has(id)) {
|
|
476
|
+
act = `<label class="bd-l" for="bdn-${esc(id)}">What should the agent change? A note is required.</label><textarea id="bdn-${esc(id)}" data-bdn="${esc(id)}" maxlength="500" rows="3">${esc(PNOTE[id] || '')}</textarea>${bdFail(id, PERR)}`
|
|
477
|
+
+ bdActs(bdBtn('Send back with the note', 'pback', id, false, (PNOTE[id] || '').trim() ? '' : ' disabled'), bdBtn('Cancel', 'pcancel', id, true)) + '<p class="bd-why">Send back starts a new run with your note. It cannot be undone.</p>';
|
|
478
|
+
} else act = bdActs(bdBtn('Keep', 'pkeep', id), bdBtn('Send back', 'pnote', id, true), bdBtn('Drop', 'pdrop', id, true)) + `<p class="bd-why">${esc(pKeep(p))} Drop counts as a correction. None of the three can be undone.</p>` + bdFail(id, PERR);
|
|
479
|
+
return `<div class="bd-it${d ? ' decided' : ''}" data-id="${esc(id)}"><div class="bd-h">${bdChip(pWhat(p))}${it.pname ? bdChip(it.pname, 'mono') : ''}</div><span class="bd-t">${esc(targetOf(it))}</span>${text ? `<p class="bd-q">${esc(text)}</p>` : ''}${p.why ? `<p class="bd-why">Why: ${esc(p.why)}</p>` : ''}${src ? `<p class="bd-why">Sources: ${src}</p>` : ''}${act}</div>`;
|
|
480
|
+
}
|
|
481
|
+
function propsHtml() {
|
|
482
|
+
const a = A.prop; if (!a.ok) return `<p class="nodef err" role="alert">Agent proposals ${esc(said(a))}</p>`;
|
|
483
|
+
const L = a.items.concat([...DEC.values()].map((d) => d.item).filter((it) => !a.items.some((o) => o.id === it.id)));
|
|
484
|
+
return (L.length ? `<p class="bd-top">${a.items.length ? pl(a.items.length, 'proposal waits', 'proposals wait') + ' for you.' : 'All decided.'} The agent drafts and asks you. Nothing it wrote has changed a record until you keep it.</p><div class="bd-list">${L.map(propItem).join('')}</div>` : `<p class="empty3">${CHECK}No agent proposals wait.</p>`)
|
|
485
|
+
+ (a.errs.length ? `<p class="note">Not read: ${esc(a.errs[0])}</p>` : '') + '<p class="note">The agent mode (Off, Shadow, Approve) stays in the console. This list shows a kind only when its mode is Approve.</p>';
|
|
486
|
+
}
|
|
487
|
+
async function propPress(e, redraw) {
|
|
488
|
+
const b = e.target.closest('[data-bda]'); if (!b || BUSY) return;
|
|
489
|
+
const act = b.dataset.bda, id = b.dataset.id, it = openProps().find((x) => x.id === id);
|
|
490
|
+
if (!it) return;
|
|
491
|
+
if (act === 'pnote') { PBACK.add(id); redraw(`[data-bdn="${CSS.escape(id)}"]`); return; }
|
|
492
|
+
if (act === 'pcancel') { PBACK.delete(id); delete PERR[id]; redraw(`[data-bda="pnote"][data-id="${CSS.escape(id)}"]`); return; }
|
|
493
|
+
const note = (PNOTE[id] || '').trim();
|
|
494
|
+
if (act === 'pback' && !note) { PERR[id] = 'Write one line for the agent. A note starts its next run.'; redraw(`[data-bdn="${CSS.escape(id)}"]`); return; }
|
|
495
|
+
BUSY = id; b.disabled = true;
|
|
496
|
+
const r = await pmPost('/api/driver/' + (act === 'pkeep' ? 'keep' : act === 'pback' ? 'return' : 'drop'), { ws: it.ws, proposal: id, ...(act === 'pback' ? { note } : {}) });
|
|
497
|
+
BUSY = '';
|
|
498
|
+
if (!r || r.ok !== true) { PERR[id] = (r && r.error) || 'It was not recorded.'; redraw(); return; }
|
|
499
|
+
delete PERR[id]; PBACK.delete(id);
|
|
500
|
+
DEC.set(id, { item: it, st: act === 'pkeep' ? 'kept' : act === 'pback' ? 'back' : 'dropped', note, wrote: r.wrote, warnings: r.warnings || [] });
|
|
501
|
+
toast(act === 'pkeep' ? 'Kept.' : act === 'pback' ? 'Sent back with your note.' : 'Dropped. It counts as a correction.');
|
|
502
|
+
await readAll(['prop']); redraw(`.bd-it[data-id="${CSS.escape(id)}"] .bd-done`);
|
|
503
|
+
}
|
|
504
|
+
const openPropsDlg = () => {
|
|
505
|
+
const n = openProps().length;
|
|
506
|
+
bdDlg('prop', 'Agent proposals · real data', 'Agent proposals', 'The Initiative Driver, read from each product\'s ledger',
|
|
507
|
+
A.prop && A.prop.ok ? (n ? pl(n, 'proposal waits', 'proposals wait') + ' for you. Keep one to record it, send it back with a note, or drop it.' : 'No proposal waits for you.') : 'The proposals could not be read.', propsHtml, propPress,
|
|
508
|
+
(e) => { const t = e.target.closest('[data-bdn]'); if (!t) return; PNOTE[t.dataset.bdn] = t.value; const k = $(`[data-bda="pback"][data-id="${CSS.escape(t.dataset.bdn)}"]`, $('#oMain')); if (k) k.disabled = !t.value.trim(); });
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
/* ── mentions ── */
|
|
512
|
+
const taskLine = (m) => (m.reply ? 'Reply to ' + (m.who ? first(m.who) : 'the sender') + ' (' + srcName(m.source) + ') by today' : 'Read ' + (m.who ? first(m.who) : 'the sender') + '\'s note (' + srcName(m.source) + ')');
|
|
513
|
+
function menHtml() {
|
|
514
|
+
const a = A.men; if (!a.ok) return `<p class="nodef err" role="alert">Mentions ${esc(said(a))}</p>`;
|
|
515
|
+
if (a.list === null) return '<p class="empty3">No brief for today, so no mentions were read.</p><p class="note">Mentions come from today\'s brief. Nothing here replies, reacts or posts in Slack, Jira, Confluence or mail.</p>';
|
|
516
|
+
const l = shownMen(), ORD = ['slack', 'jira', 'confluence', 'mail'], srcs = ORD.filter((k) => l.some((m) => m.source === k)).concat([...new Set(l.map((m) => m.source))].filter((k) => !ORD.includes(k)));
|
|
517
|
+
if (MTAB !== 'all' && !srcs.includes(MTAB)) MTAB = 'all';
|
|
518
|
+
const rows = l.filter((m) => MTAB === 'all' || m.source === MTAB).sort((x, y) => (y.reply - x.reply) || ((y.at ? Date.parse(y.at) : 0) - (x.at ? Date.parse(x.at) : 0)));
|
|
519
|
+
const tabs = `<div class="seg2" role="group" aria-label="Source">${['all', ...srcs].map((k) => `<button type="button" data-bda="mtab" data-k="${esc(k)}" aria-pressed="${MTAB === k}">${k === 'all' ? 'All ' + l.length : esc(srcName(k)) + ' ' + l.filter((m) => m.source === k).length}</button>`).join('')}</div>`;
|
|
520
|
+
const item = (m) => {
|
|
521
|
+
const link = bdLink(m.link), when = mWhen(m.at);
|
|
522
|
+
const acts = m.read ? bdActs(bdBtn('Mark unread', 'munread', m.id, true))
|
|
523
|
+
: bdActs(MADD.has(m.id) ? bdDone(true, 'In your Work list.') : bdBtn('Make it a task', 'madd', m.id), bdBtn('Mark read', 'mread', m.id, true), link ? `<a class="cta alt" href="${esc(link)}" target="_blank" rel="noopener noreferrer" data-bdlink="${esc(m.id)}">Open in ${esc(srcName(m.source))}</a>` : '')
|
|
524
|
+
+ (MADD.has(m.id) ? '' : `<p class="bd-why">Make it a task adds “${esc(taskLine(m))}” to your Work list. Mark read hides it from today's list.</p>`) + bdFail(m.id, SERR);
|
|
525
|
+
return `<div class="bd-it${m.read ? ' decided' : ''}" data-id="${esc(m.id)}"><div class="bd-h">${bdChip(srcName(m.source) + (m.where ? ' · ' + m.where : ''))}${when ? bdChip(when, 'mono') : ''}${m.reply ? bdChip('Needs your reply', 'warn') : bdChip('For your information')}</div><span class="bd-t">${esc(m.who || srcName(m.source))}</span><p class="bd-q">${esc(m.text)}</p>${m.initiative ? `<p class="bd-why">${esc(m.initiative)}</p>` : ''}${acts}</div>`;
|
|
526
|
+
};
|
|
527
|
+
return (l.length ? `<div class="bd-top">${tabs}</div><div class="bd-list">${rows.map(item).join('')}</div>` : '<p class="empty3">' + CHECK + 'No one has mentioned you today.</p>')
|
|
528
|
+
+ '<p class="note">Mentions come from today\'s brief. A mention that is already a row under What you need to do is not listed here. Nothing here replies, reacts or posts in Slack, Jira, Confluence or mail.</p>';
|
|
529
|
+
}
|
|
530
|
+
async function menPress(e, redraw) {
|
|
531
|
+
const b = e.target.closest('[data-bda]'); if (!b || BUSY) return;
|
|
532
|
+
const act = b.dataset.bda, id = b.dataset.id;
|
|
533
|
+
if (act === 'mtab') { MTAB = b.dataset.k; redraw(`[data-bda="mtab"][data-k="${CSS.escape(MTAB)}"]`); return; }
|
|
534
|
+
const m = shownMen().find((x) => x.id === id); if (!m) return;
|
|
535
|
+
BUSY = id; b.disabled = true; delete SERR[id];
|
|
536
|
+
const r = act === 'madd' ? await pmPost('/api/pm-items/add', { line: taskLine(m) }) : await pmPost('/api/mentions/read', { id, read: act === 'mread' });
|
|
537
|
+
BUSY = '';
|
|
538
|
+
if (!r || r.ok === false) { SERR[id] = 'That did not go through' + (r && r.error ? ': ' + r.error : '.'); redraw(); return; }
|
|
539
|
+
if (act === 'madd') { MADD.add(id); toast('Added to Work: ' + taskLine(m).replace(/ by today$/, '')); redraw(`.bd-it[data-id="${CSS.escape(id)}"] [data-bda="mread"]`); }
|
|
540
|
+
else { MREAD.set(id, act === 'mread'); toast(act === 'mread' ? 'Marked read.' : 'Marked unread.'); redraw(`.bd-it[data-id="${CSS.escape(id)}"] button`); }
|
|
541
|
+
drawAround();
|
|
542
|
+
}
|
|
543
|
+
const openMen = () => {
|
|
544
|
+
const l = shownMen();
|
|
545
|
+
bdDlg('men', 'Mentions · real data', 'Mentions', 'Slack, Jira, Confluence and mail · today\'s brief', A.men && A.men.ok && A.men.list ? menLine(l) + ' Make one a task, mark it read, or open it where it was said.' : 'Mentions could not be read from today\'s brief.', menHtml, menPress);
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
/* ── portfolio pulse ── */
|
|
549
|
+
function pulseHtml() {
|
|
550
|
+
const a = A.pulse; if (!a.ok) return `<p class="nodef err" role="alert">Portfolio pulse ${esc(said(a))}</p>`;
|
|
551
|
+
const g = groups(a.rows), n = a.rows.length + a.none, item = (r) => `<div class="bd-it"><div class="bd-h">${bdChip(r.word, r.cls === 'bad' ? 'hot' : r.cls === 'warn' ? 'warn' : '')}${r.pname ? bdChip(r.pname, 'mono') : ''}</div><span class="bd-t">${esc(r.title)}</span><p class="bd-why">${esc(r.why)}</p>${bdActs(`<a class="cta alt" href="/premium-initiative.html?id=${encodeURIComponent(r.id)}${r.ws ? '&ws=' + encodeURIComponent(r.ws) : ''}">Open the initiative</a>`)}</div>`;
|
|
552
|
+
const hot = g.bad.concat(g.warn);
|
|
553
|
+
return `<div class="bd-leg">${['bad', 'warn', 'ok', 'none'].map((k) => `<span><i class="${k}"></i>${PGW[k]} ${k === 'none' ? g.none.length + a.none : g[k].length}</span>`).join('')}</div>${n ? bar(g, n, a.none) : ''}`
|
|
554
|
+
+ H2('Needs a look') + (hot.length ? `<div class="bd-list">${hot.map(item).join('')}</div>` : '<p class="note">Nothing is late or at risk.</p>')
|
|
555
|
+
+ `<details class="bd-more"><summary>${g.ok.length} on plan</summary><div class="bd-list">${g.ok.map(item).join('')}</div></details>`
|
|
556
|
+
+ `<details class="bd-more"><summary>${g.none.length + a.none} with no plan date</summary><div class="bd-list">${g.none.map(item).join('')}</div>${a.none ? `<p class="note">${pl(a.none, 'more initiative has', 'more initiatives have')} no promised date and no Jira read, so they are not listed.</p>` : ''}</details>`
|
|
557
|
+
+ (a.errs.length ? `<p class="note">Not read: ${esc(a.errs[0])}</p>` : '') + '<p class="note">The status is the Calendar\'s: the promised date against the forecast, or the Jira read. It is not a forecast of its own, and nothing here changes a record.</p>';
|
|
558
|
+
}
|
|
559
|
+
const openPulse = () => {
|
|
560
|
+
const a = A.pulse, g = a && a.ok ? groups(a.rows) : null;
|
|
561
|
+
bdDlg('pulse', 'Portfolio pulse · real data', 'Portfolio pulse', 'The initiatives, by the Calendar\'s own status', g ? `${g.bad.length} late and ${g.warn.length} at risk, of ${a.rows.length + a.none}. The late and at-risk ones are listed first. Opening one takes you to its page.` : 'The initiatives could not be read.', pulseHtml, () => {});
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
/* ── horizon scan ── */
|
|
565
|
+
const SKIND = { create: ['New initiative', 'Approve', 'The initiative was created in the first stage of the board.'], research: ['Research', 'Start the research', 'A research scan was started.'], attach: ['Evidence', 'Approve', 'An evidence line was written.'] };
|
|
566
|
+
const sDoes = (p) => {
|
|
567
|
+
const f = p.fields || {};
|
|
568
|
+
return p.kind === 'create' ? 'Approve creates the initiative in the first stage of the ' + (f.board || 'board') + ' workflow.' : p.kind === 'research' ? 'Start the research starts a research scan' + (f.question ? ' for “' + f.question + '”' : '') + '.' : 'Approve writes an evidence line on ' + (f.initiative || 'the initiative') + '.';
|
|
569
|
+
};
|
|
570
|
+
function scanProp(p, ws) {
|
|
571
|
+
const d = SDEC.get(p.id), k = SKIND[p.kind] || [p.kind, 'Approve', 'It is recorded.'], f = p.fields || {};
|
|
572
|
+
const act = d ? bdDone(d.st === 'ok', d.st === 'ok' ? 'Approved. ' + k[2] : 'Dismissed. It counts as a correction.') + (d.st === 'no' ? bdActs(bdBtn('Undo', 'sundo', p.id, true, ` data-ws="${esc(ws)}"`)) : '')
|
|
573
|
+
: SOPEN.has(p.id) ? `<label class="bd-l" for="bds-${esc(p.id)}">Why dismiss it? A reason is required.</label><input type="text" id="bds-${esc(p.id)}" data-bds="${esc(p.id)}" maxlength="500" value="${esc(SWHY[p.id] || '')}" placeholder="For example: we already decided this">${bdFail(p.id, SERR)}`
|
|
574
|
+
+ bdActs(bdBtn('Dismiss', 'sdis', p.id, false, ` data-ws="${esc(ws)}"${(SWHY[p.id] || '').trim() ? '' : ' disabled'}`), bdBtn('Cancel', 'sdiscancel', p.id, true)) + '<p class="bd-why">A dismissal counts as a correction. The scan will not raise the same thing again.</p>'
|
|
575
|
+
: bdActs(bdBtn(k[1], 'sapp', p.id, false, ` data-ws="${esc(ws)}"`), bdBtn('Dismiss', 'sdisopen', p.id, true)) + `<p class="bd-why">${esc(sDoes(p))} Dismiss asks for a reason and counts as a correction.</p>` + bdFail(p.id, SERR);
|
|
576
|
+
return `<div class="bd-it${d ? ' decided' : ''}" data-id="${esc(p.id)}"><div class="bd-h">${bdChip(k[0])}${f.board ? bdChip(f.board) : ''}</div><span class="bd-t">${esc(p.title)}</span>${p.why ? `<p class="bd-why">${esc(p.why)}</p>` : ''}${p.finding ? `<p class="bd-q">${esc(p.finding)}</p>` : ''}${act}</div>`;
|
|
577
|
+
}
|
|
578
|
+
function scanPart(s) {
|
|
579
|
+
const lastWord = s.last ? dayWord(s.last.at) + (s.last.ok === false ? ' (did not finish' + (s.last.reason ? ': ' + s.last.reason : '') + ')' : '') : 'No scan has run yet';
|
|
580
|
+
const nextWord = s.switched_off ? 'Scans are switched off on this machine' : s.next ? dayWord(s.next) + (s.schedule ? ' · ' + s.schedule : '') : (s.schedule || 'Not scheduled');
|
|
581
|
+
let ctl;
|
|
582
|
+
if (s.open) ctl = `<div class="bd-it"><span class="bd-t">Scanning now</span><div class="bd-steps">${(s.open.steps || []).map((x) => `<div class="${esc(x.state)}"><i></i>${esc(x.label || x.id)}${x.state === 'work' ? ' …' : ''}</div>`).join('')}</div>${bdActs(bdBtn(s.open.stopping ? 'Stopping…' : 'Stop', 'sstop', s.ws, true, s.open.stopping ? ' disabled' : ''))}<p class="bd-why">Stop ends the scan. Nothing it has not filed is written.</p></div>`;
|
|
583
|
+
else {
|
|
584
|
+
const m = s.manual || {}, no = s.switched_off ? 'Scans are switched off on this machine.' : m.ok === false ? (m.error || 'A manual scan cannot start now.') : '';
|
|
585
|
+
ctl = bdActs(bdBtn('Scan now', 'snow', s.ws, false, no ? ' disabled' : '')) + `<p class="bd-why">${no ? esc(no) + ' ' : ''}Scan now starts an agent that reads the public web for your watch list and this repository, then writes reports with proposals. Nothing acts until you approve it.${m.limit ? ' ' + m.left + ' of ' + m.limit + ' manual scans left today.' : ''}</p>`;
|
|
586
|
+
}
|
|
587
|
+
const top = s.reports.filter((r) => !r.parent && r.written), scan = s.last && s.last.scan, show = top.filter((r) => r.scan === scan || (r.proposals && r.proposals.open > 0) || [...SDEC.values()].some((d) => d.p.report === r.id));
|
|
588
|
+
const reps = show.map((r) => {
|
|
589
|
+
const ps = s.proposals.filter((p) => p.report === r.id), dec = [...SDEC.entries()].filter(([, d]) => d.p.report === r.id && !ps.some((p) => p.id === d.p.id)).map(([, d]) => d.p), all = ps.concat(dec);
|
|
590
|
+
return H2(r.label || r.type + ' report') + `<p class="bd-q">${esc(r.title)}</p><p class="bd-why">From: ${esc(r.origin || 'the repository')} · ${ps.length} of ${(r.proposals && r.proposals.total) || all.length} proposals wait</p><div class="bd-list">${all.map((p) => scanProp(p, s.ws)).join('')}</div>`;
|
|
591
|
+
}).join('');
|
|
592
|
+
return (s.pname ? H2(s.pname) : '') + kv([['Last scan', lastWord], ['Next', nextWord]]) + ctl + (reps || (s.last ? '<p class="note">The last scan wrote no report.</p>' : ''));
|
|
593
|
+
}
|
|
594
|
+
function scanHtml() {
|
|
595
|
+
const a = A.scan; if (!a.ok) return `<p class="nodef err" role="alert">Horizon scan ${esc(said(a))}</p>`;
|
|
596
|
+
return a.scans.map(scanPart).join('') + (a.errs.length ? `<p class="note">Not read: ${esc(a.errs[0])}</p>` : '') + '<p class="note">One scan covers the whole product. The watch list, the scan setting, the report documents and Change on a proposal stay in the console.</p>';
|
|
597
|
+
}
|
|
598
|
+
let SPOLL = null;
|
|
599
|
+
function scanPoll(redraw) {
|
|
600
|
+
clearTimeout(SPOLL);
|
|
601
|
+
if (!A.scan || !A.scan.ok || !A.scan.scans.some((s) => s.open)) return;
|
|
602
|
+
SPOLL = setTimeout(async () => {
|
|
603
|
+
if ($('#oMain').dataset.bd !== 'scan' || !$('#dlg').classList.contains('on')) return;
|
|
604
|
+
const before = JSON.stringify(A.scan); await readAll(['scan']);
|
|
605
|
+
if (JSON.stringify(A.scan) !== before) redraw();
|
|
606
|
+
scanPoll(redraw);
|
|
607
|
+
}, 4000);
|
|
608
|
+
}
|
|
609
|
+
async function scanPress(e, redraw) {
|
|
610
|
+
const b = e.target.closest('[data-bda]'); if (!b || BUSY) return;
|
|
611
|
+
const act = b.dataset.bda, id = b.dataset.id, ws = b.dataset.ws || '';
|
|
612
|
+
if (act === 'sdisopen') { SOPEN.add(id); redraw(`[data-bds="${CSS.escape(id)}"]`); return; }
|
|
613
|
+
if (act === 'sdiscancel') { SOPEN.delete(id); delete SERR[id]; redraw(`[data-bda="sdisopen"][data-id="${CSS.escape(id)}"]`); return; }
|
|
614
|
+
const why = (SWHY[id] || '').trim();
|
|
615
|
+
if (act === 'sdis' && !why) return;
|
|
616
|
+
BUSY = id; b.disabled = true;
|
|
617
|
+
let r;
|
|
618
|
+
if (act === 'snow') r = await pmPost('/api/scan/now', { ws: id });
|
|
619
|
+
else if (act === 'sstop') r = await pmPost('/api/scan/stop', { ws: id });
|
|
620
|
+
else r = await pmPost('/api/scan/proposal', { ws, id, action: act === 'sapp' ? 'approve' : act === 'sdis' ? 'dismiss' : 'undo', ...(act === 'sdis' ? { why } : {}) });
|
|
621
|
+
BUSY = '';
|
|
622
|
+
if (!r || r.ok !== true) { SERR[id] = (r && r.error) || 'It did not go through.'; redraw(); toast(SERR[id]); return; }
|
|
623
|
+
delete SERR[id];
|
|
624
|
+
if (act === 'sapp' || act === 'sdis') { const p = A.scan.scans.flatMap((s) => s.proposals).find((x) => x.id === id); if (p) SDEC.set(id, { st: act === 'sapp' ? 'ok' : 'no', p }); SOPEN.delete(id); toast(act === 'sapp' ? 'Approved.' : 'Dismissed. It counts as a correction.'); }
|
|
625
|
+
else if (act === 'sundo') { SDEC.delete(id); toast('The dismissal was taken back.'); }
|
|
626
|
+
else toast(act === 'snow' ? 'Scan started. It runs in the background.' : 'Stopping the scan.');
|
|
627
|
+
await readAll(['scan']); redraw(act === 'snow' ? '[data-bda="sstop"]' : act === 'sstop' ? '[data-bda="snow"]' : `.bd-it[data-id="${CSS.escape(id)}"] .bd-done`); scanPoll(redraw);
|
|
628
|
+
}
|
|
629
|
+
const openScan = () => {
|
|
630
|
+
const w = scanOpen();
|
|
631
|
+
const redraw = bdDlg('scan', 'Horizon scan · real data', 'Horizon scan', 'One scan for the whole product', A.scan && A.scan.ok ? (w ? pl(w, 'proposal waits', 'proposals wait') + ' for you. Nothing acts until you approve it.' : 'No proposal waits for you. Nothing acts until you approve it.') : 'The scan could not be read.', scanHtml, scanPress,
|
|
632
|
+
(e) => { const t = e.target.closest('[data-bds]'); if (!t) return; SWHY[t.dataset.bds] = t.value; const k = $(`[data-bda="sdis"][data-id="${CSS.escape(t.dataset.bds)}"]`, $('#oMain')); if (k) k.disabled = !t.value.trim(); });
|
|
633
|
+
scanPoll(redraw);
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
/* ── data freshness ── */
|
|
637
|
+
const SSTATE = { fresh: 'Recent', stale: 'Old', never: 'Never read', building: 'Reading now…', failed: 'Failed', off: 'Off' };
|
|
638
|
+
const SNOTE = {};
|
|
639
|
+
const limitWord = (ms) => (ms >= 48 * 3600000 ? Math.round(ms / 86400000) + ' days' : Math.round(ms / 3600000) + ' hours');
|
|
640
|
+
function srcHtml() {
|
|
641
|
+
const a = A.src; if (!a.ok) return `<p class="nodef err" role="alert">Data freshness ${esc(said(a))}</p>`;
|
|
642
|
+
const b = behindSrc(), many = refreshTargets(a.sources);
|
|
643
|
+
const row = (s) => {
|
|
644
|
+
const when = s.id === 'repository' && s.state === 'fresh' ? 'watching' : s.as_of ? whenRead(s.as_of) : 'never';
|
|
645
|
+
const sch = s.schedule ? [s.schedule.cadence, s.schedule.day, s.schedule.time].filter(Boolean).join(' ') : s.skill ? 'no schedule' : 'on every change';
|
|
646
|
+
return `<div class="bd-src"><span><b>${esc(s.label)}</b><small><span class="bd-st ${esc(s.state)}">${esc(SSTATE[s.state] || s.state)}</span> · ${esc(when)} · ${esc(sch)}${s.stale_after_ms ? ' · old after ' + esc(limitWord(s.stale_after_ms)) : ''}</small><small>${s.skill ? 'Refresh starts the ' + esc(s.skill) + ' skill in an agent session, with your own connection.' : 'Refresh rebuilds the facts on this machine.'}</small>${SNOTE[s.id] ? `<small role="status">${esc(SNOTE[s.id])}</small>` : ''}</span>${bdBtn('Refresh', 'sfone', s.id, true, (s.state === 'off' || s.state === 'building' ? ' disabled' : '') + ` aria-label="Refresh ${esc(s.label)}"`)}</div>`;
|
|
647
|
+
};
|
|
648
|
+
return `<div class="bd-top"><p>Sources are read on a schedule, not live. ${b.length ? pl(b.length, 'source needs', 'sources need') + ' a new read.' : 'None is old.'}</p>${bdBtn('Refresh all', 'sfall', '', false, many.length ? '' : ' disabled')}</div>${a.sources.map(row).join('')}<p class="note">Refresh all reads every source but the repository. The server calls nothing outside this machine: an outside source is read by a skill, with your own connection.</p>`;
|
|
649
|
+
}
|
|
650
|
+
let FPOLL = null;
|
|
651
|
+
function srcPoll(redraw, n) {
|
|
652
|
+
clearTimeout(FPOLL);
|
|
653
|
+
if (!n || !A.src || !A.src.ok || !A.src.sources.some((s) => s.state === 'building')) return;
|
|
654
|
+
FPOLL = setTimeout(async () => { if ($('#oMain').dataset.bd !== 'src' || !$('#dlg').classList.contains('on')) return; await readAll(['src']); redraw(); srcPoll(redraw, n - 1); }, 3000);
|
|
655
|
+
}
|
|
656
|
+
async function srcPress(e, redraw) {
|
|
657
|
+
const b = e.target.closest('[data-bda]'); if (!b || BUSY) return;
|
|
658
|
+
const act = b.dataset.bda, ids = act === 'sfall' ? refreshTargets(A.src.sources) : [b.dataset.id];
|
|
659
|
+
BUSY = 'src'; b.disabled = true;
|
|
660
|
+
const got = await Promise.all(ids.map(async (id) => [id, await pmPost('/api/sources/refresh', { ws: A.src.ws || wsParam() || '', source: id })]));
|
|
661
|
+
BUSY = '';
|
|
662
|
+
let bad = 0;
|
|
663
|
+
for (const [id, r] of got) { if (r && r.ok) SNOTE[id] = r.started === 'session' ? 'An agent session started to read it.' : 'Rebuilding the facts on this machine.'; else { bad++; SNOTE[id] = 'It did not start: ' + ((r && r.error) || 'the server did not answer') + '.'; } }
|
|
664
|
+
toast(bad ? bad + ' of ' + ids.length + ' did not start.' : act === 'sfall' ? 'Reading every source again.' : 'Reading again.');
|
|
665
|
+
await readAll(['src']); redraw(act === 'sfall' ? '[data-bda="sfall"]' : `[data-bda="sfone"][data-id="${CSS.escape(ids[0])}"]`); srcPoll(redraw, 8);
|
|
666
|
+
}
|
|
667
|
+
const openSrc = () => {
|
|
668
|
+
const b = behindSrc();
|
|
669
|
+
const redraw = bdDlg('src', 'Sources · real data', 'Data freshness', 'When each source was last read', A.src && A.src.ok ? (b.length ? joinN(b.map((s) => s.label)) + (b.length === 1 ? ' needs' : ' need') + ' a new read. Refresh one, or all.' : 'Every source was read recently.') : 'The sources could not be read.', srcHtml, srcPress);
|
|
670
|
+
srcPoll(redraw, 8);
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
function mountAround() {
|
|
674
|
+
const t = $('#todayCard'); if (!t) return;
|
|
675
|
+
const s = document.createElement('section');
|
|
676
|
+
s.className = 'card rise'; s.id = 'aroundCard'; s.style.setProperty('--d', '8'); s.setAttribute('aria-labelledby', 'hAround');
|
|
677
|
+
s.innerHTML = `<div class="ch"><span class="ic">${bdIco(BDI.at)}</span><h2 id="hAround">Around you</h2><small id="aroundCap">Reading</small></div><div id="aroundBody" class="bd-rows"></div><p class="note bd-note">Nothing here posts to Slack, Jira, Confluence or mail. A button that records something says what, before you press it.</p>`;
|
|
678
|
+
t.insertAdjacentElement('afterend', s);
|
|
679
|
+
s.addEventListener('click', (e) => {
|
|
680
|
+
const b = e.target.closest('[data-bd]'); if (!b) return;
|
|
681
|
+
({ prop: openPropsDlg, men: openMen, pulse: openPulse, scan: openScan, src: openSrc })[b.dataset.bd]();
|
|
682
|
+
});
|
|
683
|
+
drawAround();
|
|
684
|
+
}
|
|
685
|
+
mountAround();
|
|
686
|
+
|
|
255
687
|
/* ── load ───────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
256
|
-
let readTimer = null;
|
|
688
|
+
let readTimer = null, AROUND = false;
|
|
257
689
|
const ago = (ms) => { const m = Math.round(ms / 60000); return m < 1 ? 'just now' : m < 90 ? m + ' min ago' : Math.round(m / 60) + ' h ago'; };
|
|
258
690
|
async function load() {
|
|
259
691
|
let r = null, status = 0;
|
|
@@ -273,6 +705,7 @@ async function load() {
|
|
|
273
705
|
return;
|
|
274
706
|
}
|
|
275
707
|
M = r.model; drawHero(); drawRows(); drawChips(); drawTl(); drawDock(); drawPick(); onScroll();
|
|
708
|
+
if (!AROUND) { AROUND = true; readAll(); setInterval(() => { if (!document.hidden && !$('#dlg').classList.contains('on')) readAll(); }, 300000); }
|
|
276
709
|
const age = Date.now() - r.as_of;
|
|
277
710
|
if (age > 5 * 60000) $('#snap').textContent += ' · read ' + ago(age) + (r.refreshing ? ', refreshing' : '');
|
|
278
711
|
if (r.error) $('#snap').textContent += ' · the latest read failed: ' + r.error.slice(0, 120);
|
package/workspace/server.js
CHANGED
|
@@ -3087,7 +3087,7 @@ function transcriptHarness(s) {
|
|
|
3087
3087
|
// because the harness is near-static within a run (the leg-A finding that made it a drill-in and
|
|
3088
3088
|
// not a rail). The state dot and the quiet clock do NOT go through here and are never floored.
|
|
3089
3089
|
if (s.tx && (now - (s.txReadAt || 0)) < TX_REREAD_MS) return s.tx;
|
|
3090
|
-
const h = transcript.readHarness(found.file, scrub);
|
|
3090
|
+
const h = transcript.readHarness(found.file, scrub, s.txCache || (s.txCache = {}));
|
|
3091
3091
|
s.txReadAt = now;
|
|
3092
3092
|
h.cliVersion = found.version || null;
|
|
3093
3093
|
s.tx = h; s.txStamp = stamp;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-briefing-depth: the Around you card on the premium Briefing (agent proposals, mentions, portfolio pulse, horizon scan, data freshness), against the real server on a scratch repository with a seeded driver ledger, scan ledger and brief.",
|
|
3
|
+
"seconds": {
|
|
4
|
+
"premium-briefing-depth-test.js": 90
|
|
5
|
+
},
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-briefing-depth-test.js"
|
|
8
|
+
]
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "workspace-harness-incremental: a working agent's transcript is read from where the last read stopped, and the answer equals a fresh read (harness-incremental).",
|
|
3
|
+
"modules": ["harness-incremental.test.js"],
|
|
4
|
+
"seconds": { "harness-incremental.test.js": 1 }
|
|
5
|
+
}
|