ai-agentmanager 1.25.1 → 1.26.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/CHANGELOG.md +10 -0
- package/package.json +2 -2
- package/public/app.js +19 -0
- package/public/designs.js +4 -0
- package/public/expand.js +1 -1
- package/public/index.html +4 -0
- package/public/keys.js +4 -3
- package/public/reviews.js +3 -0
- package/public/style.css +18 -4
- package/public/today.js +186 -0
- package/public/value.js +4 -0
- package/src/manager.js +4 -3
- package/src/server.js +24 -0
- package/src/today.js +114 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.26.0 (2026-11-07)
|
|
4
|
+
|
|
5
|
+
- **Today: what needs you, in one list.** The Today button (or `y`) gathers what the other lists know and puts the most pressing first: agents stopped at a prompt or waiting for your answer, overdue and due-today action items, issues and pull requests ready for your review, review requests, then the rest (actions due later, new Jira issues, stuck agents, follow-ups). Each says why it's there ("due today · asked by Pat · in Slack", "Blocked: staging credentials"), and the usual decision is a click or a key away: Done, Skip and Discuss for actions, Assign for new issues, Review it for a requested pull request, Open for the rest. Listen reads the top of it aloud. Lists turned off in Settings are left out. The button's count is the pressing ones.
|
|
6
|
+
|
|
7
|
+
## 1.25.2 (2026-11-07)
|
|
8
|
+
|
|
9
|
+
- **Designs, Reviews and Value: bigger too.** Drag the corner to any size, or fill the window with ⤢ (or `f`), as in the Jira and Actions lists.
|
|
10
|
+
- **Fixed: Close all could leave an agent open without saying so.** An agent busy when you clicked, which finished while the others closed, was neither closed nor listed as left working; it's now listed as left open.
|
|
11
|
+
- For contributors: `npm test` runs the end-to-end tests in parallel slices, each with its own daemon (`E2E_PARTS=1` for one), about three times faster; several timing-dependent tests no longer fail now and then.
|
|
12
|
+
|
|
3
13
|
## 1.25.1 (2026-11-06)
|
|
4
14
|
|
|
5
15
|
- **Jira and Actions lists: bigger.** Drag the corner to any size, or fill the window with ⤢ (or `f`); it's remembered. Filled, an issue's summary and synopsis show in full.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-agentmanager",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Run background coding agents (Claude Code, Codex) per intent, and keep track of them from a web UI, your phone or the CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"scripts": {
|
|
43
43
|
"start": "node bin/agentmgr.js serve",
|
|
44
|
-
"test": "node
|
|
44
|
+
"test": "node test/run.js",
|
|
45
45
|
"postinstall": "node scripts/fix-pty.js"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
package/public/app.js
CHANGED
|
@@ -27,6 +27,7 @@ import { initWatch } from '/watch.js';
|
|
|
27
27
|
import { initStandup } from '/standup.js';
|
|
28
28
|
import { initIssues } from '/issues.js';
|
|
29
29
|
import { initActions } from '/actions.js';
|
|
30
|
+
import { initToday } from '/today.js';
|
|
30
31
|
import { reviewSpeech } from '/prvoice.js';
|
|
31
32
|
import { initDesigns } from '/designs.js';
|
|
32
33
|
import { initReviews } from '/reviews.js';
|
|
@@ -243,7 +244,22 @@ api('GET', '/features').then((r) => applyFeatures(r.features)).catch(() => {});
|
|
|
243
244
|
document.addEventListener('agentmgr:features', (e) => {
|
|
244
245
|
applyFeatures(e.detail);
|
|
245
246
|
actionsUi.load();
|
|
247
|
+
todayUi.load();
|
|
246
248
|
});
|
|
249
|
+
// Today: what needs you, from every list, most pressing first.
|
|
250
|
+
const todayUi = initToday({
|
|
251
|
+
api,
|
|
252
|
+
$,
|
|
253
|
+
esc,
|
|
254
|
+
ago,
|
|
255
|
+
toast: (m, ms) => toast(m, ms),
|
|
256
|
+
openAgent: (id) => (showTab('agents'), select(id)),
|
|
257
|
+
showInbox: () => showTab('inbox'),
|
|
258
|
+
openActions: () => actionsUi.open(),
|
|
259
|
+
openIssues: () => issuesUi.open(),
|
|
260
|
+
openReviews: () => reviewsUi.open(),
|
|
261
|
+
});
|
|
262
|
+
$('#today-btn').onclick = () => todayUi.open();
|
|
247
263
|
// Designs: every agent's design doc, the ones waiting for your review first.
|
|
248
264
|
const designsUi = initDesigns({
|
|
249
265
|
api,
|
|
@@ -310,6 +326,7 @@ function shortcut(act) {
|
|
|
310
326
|
if (act === 'designs') return designsUi.open();
|
|
311
327
|
if (act === 'reviews') return reviewsUi.open();
|
|
312
328
|
if (act === 'value') return valueUi.open();
|
|
329
|
+
if (act === 'today') return todayUi.open();
|
|
313
330
|
if (act.startsWith('tab:')) return showTab(act.slice(4));
|
|
314
331
|
return false;
|
|
315
332
|
}
|
|
@@ -765,6 +782,7 @@ bindListen((id) => {
|
|
|
765
782
|
else if (what === 'sidewalk') parts = sidePane?.listenParts();
|
|
766
783
|
else if (what === 'prvoice') parts = reviewSpeech(a, issuesUi.about(agentId));
|
|
767
784
|
else if (what === 'reviewer') parts = reviewsUi.speech(agentId);
|
|
785
|
+
else if (what === 'today') parts = todayUi.speech();
|
|
768
786
|
if (!parts?.length || !play(id, parts)) toast('Nothing to read aloud here (or this browser has no speech)');
|
|
769
787
|
});
|
|
770
788
|
|
|
@@ -4213,6 +4231,7 @@ function handleEvent(msg) {
|
|
|
4213
4231
|
agentChanged(msg.agent);
|
|
4214
4232
|
if (msg.agent.builds) builtUi.sessionChanged(msg.agent);
|
|
4215
4233
|
issuesUi.changed();
|
|
4234
|
+
todayUi.changed();
|
|
4216
4235
|
designsUi.changed();
|
|
4217
4236
|
if (msg.agent.reviewing) reviewsUi.changed();
|
|
4218
4237
|
// The detail, terminal and document views show one agent; another agent's update leaves them be.
|
package/public/designs.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Designs: every agent's design doc in one list, the ones waiting for your review first: its name
|
|
2
2
|
// and summary, where it's published, the specs it builds on, and the agent and its issue.
|
|
3
3
|
|
|
4
|
+
import { expandButton, expandable } from './expand.js';
|
|
5
|
+
|
|
4
6
|
const SAVED = 'agentmgr.designsFilter';
|
|
5
7
|
const FILTERS = [
|
|
6
8
|
['you', 'Waiting for you'],
|
|
@@ -100,6 +102,7 @@ export function initDesigns({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
100
102
|
<span class="spacer"></span>
|
|
101
103
|
<button class="small" data-designs="copy" title="Copy this list as Markdown, to paste into Slack, Jira or a doc" ${shown.length ? '' : 'disabled'}>Copy</button>
|
|
102
104
|
<button class="small" data-designs="refresh" title="Look again now">↻</button>
|
|
105
|
+
${expandButton(dialog)}
|
|
103
106
|
<button class="small" data-designs="close" title="Close (Esc)">Close</button>
|
|
104
107
|
</div>
|
|
105
108
|
${shown.length ? `<div class="designs-list">${shown.map(card).join('')}</div>` : `<p class="hint issues-empty">${esc(empty)}</p>`}`;
|
|
@@ -168,5 +171,6 @@ export function initDesigns({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
load({ quiet: true });
|
|
174
|
+
expandable(dialog, render);
|
|
171
175
|
return { open, changed, isOpen: () => dialog.open };
|
|
172
176
|
}
|
package/public/expand.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Making a list dialog (Jira, Actions) bigger: a button in its header, or f, fills the window,
|
|
1
|
+
// Making a list dialog (Jira, Actions, Designs, Reviews, Value) bigger: a button in its header, or f, fills the window,
|
|
2
2
|
// remembered per list. The dialog's corner can also be dragged to any size.
|
|
3
3
|
|
|
4
4
|
const saved = (id) => `agentmgr.expanded.${id}`;
|
package/public/index.html
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
</div>
|
|
30
30
|
<div class="top-actions">
|
|
31
31
|
<input id="filter" type="search" placeholder="Filter agents" aria-label="Filter agents" />
|
|
32
|
+
<button id="today-btn" title="Today: what needs you, from every list, most pressing first, and why (y)">Today <span id="today-count" class="badge ready"></span></button>
|
|
32
33
|
<button id="assistant-btn" title="An always-on session that finds new work and starts agents for it">Assistant <span id="assistant-dot" class="assistant-dot" hidden></span></button>
|
|
33
34
|
<button id="spend-btn" title="Results across agents (merge rate, time to PR, cost per merged PR), what they cost, and spending limits">Results <span id="spend-today" class="spend-today"></span></button>
|
|
34
35
|
<button id="standup-btn" title="Today's standup: each agent's news read aloud, and what they need from you">Standup <span id="standup-dot" class="assistant-dot" hidden></span></button>
|
|
@@ -381,6 +382,9 @@
|
|
|
381
382
|
</form>
|
|
382
383
|
</dialog>
|
|
383
384
|
|
|
385
|
+
<dialog id="today-dialog" class="issues-dialog" aria-label="Today">
|
|
386
|
+
<div id="today-body"></div>
|
|
387
|
+
</dialog>
|
|
384
388
|
<dialog id="actions-dialog" class="issues-dialog" aria-label="Your action items">
|
|
385
389
|
<div id="actions-body"></div>
|
|
386
390
|
</dialog>
|
package/public/keys.js
CHANGED
|
@@ -12,6 +12,7 @@ export const SHORTCUTS = [
|
|
|
12
12
|
[['e'], 'Edit it', 'edit'],
|
|
13
13
|
]],
|
|
14
14
|
['Anywhere', [
|
|
15
|
+
[['y'], 'Today: what needs you, most pressing first', 'today'],
|
|
15
16
|
[['n'], 'New agents', 'new'],
|
|
16
17
|
[['a'], 'Ask Agent (a general session)', 'ask'],
|
|
17
18
|
[['/'], 'Filter agents', 'filter'],
|
|
@@ -32,7 +33,7 @@ export const SHORTCUTS = [
|
|
|
32
33
|
[['5'], 'Built agents', 'tab:built'],
|
|
33
34
|
[['?'], 'These shortcuts', 'help'],
|
|
34
35
|
]],
|
|
35
|
-
['In the Jira and Actions lists', [
|
|
36
|
+
['In the Today, Jira and Actions lists', [
|
|
36
37
|
[['j', 'k'], 'Next / previous row', null],
|
|
37
38
|
[['[', ']'], 'Previous / next filter', null],
|
|
38
39
|
[['a'], 'Assign (starts an agent)', null],
|
|
@@ -59,11 +60,11 @@ export const SHORTCUTS = [
|
|
|
59
60
|
// A single key, as an event names it, to its action.
|
|
60
61
|
export const SINGLE = {
|
|
61
62
|
j: 'next', k: 'prev', Enter: 'terminal', t: 'terminal',
|
|
62
|
-
r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', o: 'actions', h: 'assistant', ',': 'settings', d: 'designs', g: 'reviews', v: 'value', '?': 'help',
|
|
63
|
+
r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', o: 'actions', h: 'assistant', ',': 'settings', d: 'designs', g: 'reviews', v: 'value', y: 'today', '?': 'help',
|
|
63
64
|
1: 'tab:agents', 2: 'tab:inbox', 3: 'tab:backlog', 4: 'tab:land', 5: 'tab:built',
|
|
64
65
|
};
|
|
65
66
|
// While Watch is open: only what makes sense there.
|
|
66
|
-
const ON_WATCH = new Set(['new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'help']);
|
|
67
|
+
const ON_WATCH = new Set(['today', 'new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'help']);
|
|
67
68
|
|
|
68
69
|
/** Typing somewhere: a field, an editor or a terminal (xterm types through a textarea). */
|
|
69
70
|
const typing = (el) => Boolean(el?.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"], .xterm, .cm-editor'));
|
package/public/reviews.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// under your name (or copy it). PRs where your review is requested and no reviewer has started
|
|
4
4
|
// come first, with a box to tick.
|
|
5
5
|
|
|
6
|
+
import { expandButton, expandable } from './expand.js';
|
|
6
7
|
import { listenHtml, speakable } from './speak.js';
|
|
7
8
|
|
|
8
9
|
const VERDICT = { approve: ['Approve', 'ok'], approve_with_nits: ['Approve with nits', 'ok'], blocked: ['Blocked', 'bad'] };
|
|
@@ -165,6 +166,7 @@ export function initReviews({ api, $, esc, ago, openAgent, toast }) {
|
|
|
165
166
|
</form>
|
|
166
167
|
<span class="spacer"></span>
|
|
167
168
|
<button class="small" data-rv="refresh" title="Look again now, including GitHub">↻</button>
|
|
169
|
+
${expandButton(dialog)}
|
|
168
170
|
<button class="small" data-rv="close" title="Close (Esc)">Close</button>
|
|
169
171
|
</div>
|
|
170
172
|
${requested.length ? `<div class="issues-pickbar"><span>${requested.length} pull request${requested.length === 1 ? '' : 's'} where your review is requested.</span>
|
|
@@ -314,5 +316,6 @@ export function initReviews({ api, $, esc, ago, openAgent, toast }) {
|
|
|
314
316
|
}
|
|
315
317
|
|
|
316
318
|
load({ quiet: true });
|
|
319
|
+
expandable(dialog, render);
|
|
317
320
|
return { open, changed, isOpen: () => dialog.open, speech: (id) => reviewerSpeech(rowOf(id)), show: (id) => ((openId = id), dialog.open ? render() : open()) };
|
|
318
321
|
}
|
package/public/style.css
CHANGED
|
@@ -1131,10 +1131,10 @@ body.mapping .layout, body.mapping .watch-view { display: none; }
|
|
|
1131
1131
|
.issues-dialog { width: min(1100px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 16px; }
|
|
1132
1132
|
/* Only while open: a display on the dialog itself would keep a closed one on screen. */
|
|
1133
1133
|
.issues-dialog[open] { display: flex; flex-direction: column; }
|
|
1134
|
-
#issues-body, #actions-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
1135
|
-
/*
|
|
1136
|
-
|
|
1137
|
-
|
|
1134
|
+
#issues-body, #actions-body, #designs-body, #reviews-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
1135
|
+
/* The lists: drag the corner to any size, or fill the window (⤢ or f). */
|
|
1136
|
+
.issues-dialog { resize: both; overflow: hidden; min-width: min(520px, calc(100% - 32px)); min-height: 240px; max-width: calc(100% - 16px); max-height: calc(100% - 16px); }
|
|
1137
|
+
.issues-dialog.expanded { width: calc(100% - 16px); height: calc(100% - 16px); }
|
|
1138
1138
|
.issues-dialog.expanded table.issues .issue-title, .issues-dialog.expanded table.issues .issue-synopsis { max-width: none; }
|
|
1139
1139
|
.issues-dialog.expanded table.issues .issue-synopsis { -webkit-line-clamp: 6; }
|
|
1140
1140
|
.issues-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
|
|
@@ -1181,6 +1181,20 @@ table.issues .dot.idle { background: var(--muted); }
|
|
|
1181
1181
|
table.issues .issue-title, table.issues .issue-synopsis { max-width: 200px; }
|
|
1182
1182
|
}
|
|
1183
1183
|
|
|
1184
|
+
/* ---------- Today: what needs you */
|
|
1185
|
+
#today-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
1186
|
+
#today-btn { font-weight: 600; }
|
|
1187
|
+
table.today-table .today-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; padding: 2px 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); }
|
|
1188
|
+
table.today-table tr.pressing .today-label { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
|
|
1189
|
+
table.today-table tr.today-prompt .today-label, table.today-table tr.today-waiting .today-label, table.today-table tr.today-question .today-label { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
|
|
1190
|
+
table.today-table .today-title { color: var(--text); }
|
|
1191
|
+
table.today-table .today-why { margin-top: 2px; }
|
|
1192
|
+
table.today-table .today-acts { width: 1%; text-align: right; }
|
|
1193
|
+
table.today-table .small-link { font-size: 12px; margin-left: 4px; }
|
|
1194
|
+
@media (max-width: 640px) {
|
|
1195
|
+
table.today-table .today-acts { white-space: normal; }
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1184
1198
|
/* ---------- Designs: agents' design docs */
|
|
1185
1199
|
.designs-search { width: 180px; }
|
|
1186
1200
|
.designs-list { overflow: auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; }
|
package/public/today.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Today: what needs you, from every list, most pressing first: agents stopped at a prompt or
|
|
2
|
+
// waiting for an answer, issues and pull requests ready for your review, what's asked of you
|
|
3
|
+
// (by due date), new Jira issues, and the rest. Each says why it's here, and the common
|
|
4
|
+
// decisions are a click (or a key) away. Listen reads the top of it aloud.
|
|
5
|
+
|
|
6
|
+
import { listenHtml } from './speak.js';
|
|
7
|
+
import { holdWhilePicking, rowKeys } from './rowkeys.js';
|
|
8
|
+
import { expandButton, expandable } from './expand.js';
|
|
9
|
+
|
|
10
|
+
// Up to this score an item is pressing: it counts on the button.
|
|
11
|
+
const PRESSING = 32;
|
|
12
|
+
|
|
13
|
+
export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions, openIssues, openReviews, toast }) {
|
|
14
|
+
const dialog = $('#today-dialog');
|
|
15
|
+
const body = $('#today-body');
|
|
16
|
+
let data = null;
|
|
17
|
+
let loading = false;
|
|
18
|
+
let again = null;
|
|
19
|
+
let loadedAt = 0;
|
|
20
|
+
|
|
21
|
+
async function load({ quiet = false } = {}) {
|
|
22
|
+
if (loading) return;
|
|
23
|
+
loading = true;
|
|
24
|
+
try {
|
|
25
|
+
data = await api('GET', '/today');
|
|
26
|
+
loadedAt = Date.now();
|
|
27
|
+
} catch (e) {
|
|
28
|
+
if (!quiet) toast?.(e.message, 5000);
|
|
29
|
+
} finally {
|
|
30
|
+
loading = false;
|
|
31
|
+
}
|
|
32
|
+
badge();
|
|
33
|
+
render();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function badge() {
|
|
37
|
+
const n = data ? data.items.filter((i) => i.score <= PRESSING).length : 0;
|
|
38
|
+
const el = $('#today-count');
|
|
39
|
+
if (el) {
|
|
40
|
+
el.textContent = n ? String(n) : '';
|
|
41
|
+
el.title = n ? `${n} pressing: agents waiting on you, overdue or due-today actions, reviews` : '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const link = (url, label) => (url ? `<a href="${esc(url)}" target="_blank" rel="noopener" class="small-link">${esc(label)} ↗</a>` : '');
|
|
46
|
+
const btn = (act, label, title, primary = false) => `<button class="small ${primary ? 'primary' : ''}" data-today="${act}" title="${esc(title)}">${esc(label)}</button>`;
|
|
47
|
+
|
|
48
|
+
/** The buttons for an item: the decision it asks for, then where to look. */
|
|
49
|
+
function buttons(it) {
|
|
50
|
+
if (it.kind === 'action') return [btn('done', 'Done', 'Handled: off the list (d)'), btn('skip', 'Skip', 'Not now (s)'), btn('discuss', 'Discuss', 'Talk it through with Claude (c)'), link(it.url, 'Source')].join(' ');
|
|
51
|
+
if (it.kind === 'issue-new') return [btn('assign', 'Assign', 'Start an agent on it (a)', true), btn('skip', 'Skip', 'Not now (s)'), link(it.url, 'Jira')].join(' ');
|
|
52
|
+
if (it.kind === 'pr-requested') return [btn('review', 'Review it', 'A reviewer agent reads it and finds what blocks approval (a)', true), link(it.url, 'PR')].join(' ');
|
|
53
|
+
if (it.kind === 'pr-ready') return [btn('open-reviews', 'Open review', 'Pick what to post (Enter)', true), link(it.url, 'PR')].join(' ');
|
|
54
|
+
if (it.kind === 'rule') return btn('inbox', 'Inbox', 'Decide in the inbox (Enter)', true);
|
|
55
|
+
return [it.agentId ? btn('open', 'Open', "Open the agent's session (Enter)", it.score < 20) : '', link(it.url, it.issueKey ? 'Jira' : 'Link')].join(' ');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function row(it) {
|
|
59
|
+
return `<tr data-row-id="${esc(it.id)}" class="today-${esc(it.kind)} ${it.score <= PRESSING ? 'pressing' : ''}">
|
|
60
|
+
<td class="nowrap"><span class="today-label">${esc(it.label)}</span></td>
|
|
61
|
+
<td><div class="today-title">${esc(it.title)}</div><div class="hint today-why">${esc(it.why ?? '')}${it.at ? ` · ${esc(ago(it.at))}` : ''}</div></td>
|
|
62
|
+
<td class="nowrap today-acts">${buttons(it)}</td>
|
|
63
|
+
</tr>`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function draw() {
|
|
67
|
+
if (!dialog.open) return;
|
|
68
|
+
if (!data) {
|
|
69
|
+
body.innerHTML = '<p class="hint">Loading…</p>';
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const items = data.items;
|
|
73
|
+
const pressing = items.filter((i) => i.score <= PRESSING).length;
|
|
74
|
+
const off = [!data.features?.jira && 'Jira', !data.features?.slack && !data.features?.gemini && 'Actions'].filter(Boolean);
|
|
75
|
+
body.innerHTML = `
|
|
76
|
+
<div class="issues-head">
|
|
77
|
+
<h2>Today</h2>
|
|
78
|
+
<span class="hint">${items.length ? `${pressing} pressing · ${items.length} in all` : ''}</span>
|
|
79
|
+
<span class="spacer"></span>
|
|
80
|
+
${listenHtml('today', { title: 'Read the top of the list aloud', label: 'Listen' })}
|
|
81
|
+
<button class="small" data-today="refresh" title="Look again (r)">↻</button>
|
|
82
|
+
${expandButton(dialog)}
|
|
83
|
+
<button class="small" data-today="close" title="Close (Esc)">Close</button>
|
|
84
|
+
</div>
|
|
85
|
+
${items.length
|
|
86
|
+
? `<div class="issues-scroll"><table class="issues today-table"><tbody>${items.map(row).join('')}</tbody></table></div>`
|
|
87
|
+
: '<p class="hint issues-empty">Nothing needs you right now: no agent is waiting on you, nothing is due, and no review is waiting.</p>'}
|
|
88
|
+
<p class="hint">Keys: j/k move (or click a row), Enter opens, a assign or review, d done, s skip, c discuss, r look again, f bigger.${off.length ? ` Not included (off in Settings → What you use): ${esc(off.join(', '))}.` : ''}${data.errors?.length ? ` Couldn't get: ${esc(data.errors.map((e) => e.source).join(', '))}.` : ''}</p>`;
|
|
89
|
+
keys.redraw();
|
|
90
|
+
}
|
|
91
|
+
const render = holdWhilePicking(body, draw);
|
|
92
|
+
expandable(dialog, draw);
|
|
93
|
+
|
|
94
|
+
const itemOf = (id) => data?.items.find((i) => i.id === id) ?? null;
|
|
95
|
+
|
|
96
|
+
/** Do `act` for the item; the list is looked at again after anything that changes it. */
|
|
97
|
+
async function act(it, what) {
|
|
98
|
+
if (!it) return;
|
|
99
|
+
try {
|
|
100
|
+
if (what === 'open' || (what === 'enter' && it.agentId && !['pr-ready', 'rule'].includes(it.kind))) {
|
|
101
|
+
if (!it.agentId) return;
|
|
102
|
+
dialog.close();
|
|
103
|
+
return openAgent(it.agentId);
|
|
104
|
+
}
|
|
105
|
+
if (what === 'inbox' || (what === 'enter' && it.kind === 'rule')) {
|
|
106
|
+
dialog.close();
|
|
107
|
+
return showInbox();
|
|
108
|
+
}
|
|
109
|
+
if (what === 'open-reviews' || (what === 'enter' && it.kind.startsWith('pr-'))) {
|
|
110
|
+
dialog.close();
|
|
111
|
+
return openReviews();
|
|
112
|
+
}
|
|
113
|
+
if (what === 'enter') {
|
|
114
|
+
if (it.kind === 'action') {
|
|
115
|
+
dialog.close();
|
|
116
|
+
return openActions();
|
|
117
|
+
}
|
|
118
|
+
if (it.kind === 'issue-new') {
|
|
119
|
+
dialog.close();
|
|
120
|
+
return openIssues();
|
|
121
|
+
}
|
|
122
|
+
if (it.url) window.open(it.url, '_blank', 'noopener');
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (it.kind === 'action' && ['done', 'skip'].includes(what)) {
|
|
126
|
+
const r = await api('POST', '/actions/set', { ids: [it.actionId], state: what });
|
|
127
|
+
toast?.(r.failed.length ? `Not changed: ${r.failed.map((x) => x.reason).join('; ')}` : what === 'done' ? 'Done' : 'Skipped', 2500);
|
|
128
|
+
} else if (it.kind === 'action' && what === 'discuss') {
|
|
129
|
+
const r = await api('POST', `/actions/${it.actionId}/discuss`, {});
|
|
130
|
+
dialog.close();
|
|
131
|
+
return openAgent(r.agent.id);
|
|
132
|
+
} else if (it.kind === 'issue-new' && ['assign', 'skip'].includes(what)) {
|
|
133
|
+
const r = await api('POST', '/issues/action', { keys: [it.issueKey], action: what });
|
|
134
|
+
const bad = r.failed.map((x) => x.reason).join('; ');
|
|
135
|
+
toast?.(bad ? `Not changed: ${bad}` : r.started.length ? `Started an agent on ${it.title}` : `${it.title}: skipped`, bad ? 6000 : 3000);
|
|
136
|
+
} else if (it.kind === 'pr-requested' && (what === 'review' || what === 'assign')) {
|
|
137
|
+
const a = await api('POST', '/reviews', { url: it.reviewUrl });
|
|
138
|
+
toast?.(`Reviewer ${a.name ?? 'agent'} started`, 3000);
|
|
139
|
+
} else return;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
return toast?.(err.message, 6000);
|
|
142
|
+
}
|
|
143
|
+
load();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const keys = rowKeys(dialog, {
|
|
147
|
+
rows: () => [...body.querySelectorAll('tbody tr[data-row-id]')],
|
|
148
|
+
keys: {
|
|
149
|
+
Enter: (r) => act(itemOf(r.dataset.rowId), 'enter'),
|
|
150
|
+
a: (r) => act(itemOf(r.dataset.rowId), 'assign'),
|
|
151
|
+
d: (r) => act(itemOf(r.dataset.rowId), 'done'),
|
|
152
|
+
s: (r) => act(itemOf(r.dataset.rowId), 'skip'),
|
|
153
|
+
c: (r) => act(itemOf(r.dataset.rowId), 'discuss'),
|
|
154
|
+
r: Object.assign(() => load(), { needsRow: false }),
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
body.addEventListener('click', (e) => {
|
|
159
|
+
const b = e.target.closest('[data-today]')?.dataset.today;
|
|
160
|
+
if (!b) return;
|
|
161
|
+
if (b === 'close') return dialog.close();
|
|
162
|
+
if (b === 'refresh') return load();
|
|
163
|
+
act(itemOf(e.target.closest('tr[data-row-id]')?.dataset.rowId), b);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
function open() {
|
|
167
|
+
if (dialog.open) return dialog.close();
|
|
168
|
+
dialog.showModal();
|
|
169
|
+
render();
|
|
170
|
+
load();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Something changed (an agent, an action): look again shortly while open, now and then for the count. */
|
|
174
|
+
function changed() {
|
|
175
|
+
if (!dialog.open && again) return;
|
|
176
|
+
clearTimeout(again);
|
|
177
|
+
const wait = dialog.open ? 1500 : Math.max(5000, 30_000 - (Date.now() - loadedAt));
|
|
178
|
+
again = setTimeout(() => {
|
|
179
|
+
again = null;
|
|
180
|
+
load({ quiet: true });
|
|
181
|
+
}, wait);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
load({ quiet: true });
|
|
185
|
+
return { open, changed, load, isOpen: () => dialog.open, speech: () => data?.speech ?? null };
|
|
186
|
+
}
|
package/public/value.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// saved, other savings, potential revenue and strategic weight, against the AI cost and your own
|
|
3
3
|
// time. Each item's figures are AI estimates you can correct; reports go out on a schedule.
|
|
4
4
|
|
|
5
|
+
import { expandButton, expandable } from './expand.js';
|
|
6
|
+
|
|
5
7
|
const PERIODS = [
|
|
6
8
|
['day', 'Day'],
|
|
7
9
|
['week', 'Week'],
|
|
@@ -159,6 +161,7 @@ export function initValue({ api, $, esc, toast, openAgent }) {
|
|
|
159
161
|
<button class="small" data-value="copy" title="Copy this period's report as Markdown, for an email, doc or review">Copy report</button>
|
|
160
162
|
<button class="small" data-value="send" title="Send this period's report now, to Slack and Google Drive as set below">Send</button>
|
|
161
163
|
<button class="small" data-value="csv" title="Every item with its figures, for a spreadsheet">CSV</button>
|
|
164
|
+
${expandButton(dialog)}
|
|
162
165
|
<button class="small" data-value="close" title="Close (Esc)">Close</button>
|
|
163
166
|
</div>
|
|
164
167
|
<p class="value-period"><b>${esc(p.label)}</b>${p.current ? ' <span class="hint">so far</span>' : ''} · ${t.items} item${t.items === 1 ? '' : 's'} delivered${data.pending ? ` · <span class="hint">${data.pending} waiting for an estimate</span>` : ''}</p>
|
|
@@ -295,5 +298,6 @@ export function initValue({ api, $, esc, toast, openAgent }) {
|
|
|
295
298
|
again = setTimeout(load, 800);
|
|
296
299
|
}
|
|
297
300
|
|
|
301
|
+
expandable(dialog, render);
|
|
298
302
|
return { open, changed, isOpen: () => dialog.open };
|
|
299
303
|
}
|
package/src/manager.js
CHANGED
|
@@ -1473,14 +1473,15 @@ export class AgentManager extends EventEmitter {
|
|
|
1473
1473
|
*/
|
|
1474
1474
|
async closeAll({ working = false } = {}) {
|
|
1475
1475
|
const open = this.store.list().filter((a) => a.kind !== 'assistant' && this.runtimes.get(a.id)?.pty);
|
|
1476
|
-
|
|
1477
|
-
const
|
|
1476
|
+
// Busy as of the click: one that finishes while the others close is still reported as left open.
|
|
1477
|
+
const left = working ? [] : open.filter((a) => this.runtimes.get(a.id)?.busy);
|
|
1478
|
+
const close = open.filter((a) => !left.includes(a));
|
|
1478
1479
|
const results = await Promise.allSettled(close.map((a) => this.stop(a.id)));
|
|
1479
1480
|
const failed = close.filter((a, i) => results[i].status === 'rejected').map((a) => ({ id: a.id, name: a.name }));
|
|
1480
1481
|
return {
|
|
1481
1482
|
closed: close.filter((a, i) => results[i].status === 'fulfilled').map((a) => ({ id: a.id, name: a.name })),
|
|
1482
1483
|
failed,
|
|
1483
|
-
working:
|
|
1484
|
+
working: left.map((a) => ({ id: a.id, name: a.name })),
|
|
1484
1485
|
};
|
|
1485
1486
|
}
|
|
1486
1487
|
|
package/src/server.js
CHANGED
|
@@ -26,6 +26,7 @@ import { Repeats } from './repeats.js';
|
|
|
26
26
|
import { Updates } from './update.js';
|
|
27
27
|
import { identity } from './identity.js';
|
|
28
28
|
import { WorkLog, summaryMarkdown } from './worklog.js';
|
|
29
|
+
import { todayItems, todaySpeech } from './today.js';
|
|
29
30
|
import { Studio } from './studio.js';
|
|
30
31
|
import { Memory } from './memory.js';
|
|
31
32
|
import { doctor } from './doctor.js';
|
|
@@ -864,6 +865,29 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
864
865
|
res.status(500).json({ error: e.message });
|
|
865
866
|
}
|
|
866
867
|
});
|
|
868
|
+
// Today: what needs you, from every list, most pressing first (today.js). A list that's off or
|
|
869
|
+
// can't be had right now is left out, and said so.
|
|
870
|
+
api.get('/today', wrap(async () => {
|
|
871
|
+
const f = featuresOf(config);
|
|
872
|
+
manager.jiraOff = !f.jira;
|
|
873
|
+
const errors = [];
|
|
874
|
+
const got = async (name, fn) => {
|
|
875
|
+
try {
|
|
876
|
+
return await fn();
|
|
877
|
+
} catch (e) {
|
|
878
|
+
errors.push({ source: name, error: e.message });
|
|
879
|
+
return [];
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
const [inbox, issues, actions, prs] = await Promise.all([
|
|
883
|
+
got('inbox', () => manager.inbox()),
|
|
884
|
+
f.jira ? got('jira', async () => (await manager.issues(proposed.listed(), proposed.actions)).rows) : [],
|
|
885
|
+
f.slack || f.gemini ? got('actions', () => myActions.rows()) : [],
|
|
886
|
+
got('reviews', () => reviews.rows()),
|
|
887
|
+
]);
|
|
888
|
+
const items = todayItems({ inbox, issues, actions, reviews: prs });
|
|
889
|
+
return { items, speech: todaySpeech(items), features: f, errors };
|
|
890
|
+
}));
|
|
867
891
|
api.get('/standup', wrap(() => standup.view()));
|
|
868
892
|
api.post('/standup', wrap(async () => ({ ...standup.view(), latest: await standup.make({ reason: 'asked' }) })));
|
|
869
893
|
api.put('/standup', wrap((req) => {
|
package/src/today.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Today: what needs you, in one list, most pressing first. It gathers what the other lists already
|
|
2
|
+
// know (agents' questions and prompts from the inbox, issues waiting for your review or not started
|
|
3
|
+
// in Jira, what's asked of you in Slack and meeting notes, pull requests to review) and says, for
|
|
4
|
+
// each, why it's here: "blocks OPS-7", "due today", "assigned to you".
|
|
5
|
+
|
|
6
|
+
const DAY = 86_400_000;
|
|
7
|
+
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* When a due date said in words falls ("today", "EOD", "tomorrow", "Friday", "2026-11-09",
|
|
11
|
+
* "Nov 9"): the end of that day, or null when it can't be told. `now` is a Date.
|
|
12
|
+
*/
|
|
13
|
+
export function dueAt(due, now = new Date()) {
|
|
14
|
+
const s = String(due ?? '').trim().toLowerCase().replace(/(\d)(st|nd|rd|th)\b/g, '$1');
|
|
15
|
+
if (!s) return null;
|
|
16
|
+
const endOf = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59);
|
|
17
|
+
if (/\b(today|tonight|eod|end of (the )?day|asap|now|urgent)\b/.test(s)) return endOf(now);
|
|
18
|
+
if (/\btomorrow\b/.test(s)) return endOf(new Date(now.getTime() + DAY));
|
|
19
|
+
if (/\b(eow|end of (the )?week|this week)\b/.test(s)) return endOf(new Date(now.getTime() + ((5 - now.getDay() + 7) % 7) * DAY));
|
|
20
|
+
if (/\bnext week\b/.test(s)) return endOf(new Date(now.getTime() + ((8 - now.getDay()) % 7 || 7) * DAY + 4 * DAY));
|
|
21
|
+
const wd = WEEKDAYS.findIndex((w) => new RegExp(`\\b${w.slice(0, 3)}(${w.slice(3)})?\\b`).test(s));
|
|
22
|
+
if (wd >= 0) return endOf(new Date(now.getTime() + ((wd - now.getDay() + 7) % 7) * DAY));
|
|
23
|
+
// A date: ISO, or a month and day (this year; next year when that's long past).
|
|
24
|
+
const iso = s.match(/\b(\d{4})-(\d{2})-(\d{2})\b/);
|
|
25
|
+
if (iso) return endOf(new Date(Number(iso[1]), Number(iso[2]) - 1, Number(iso[3])));
|
|
26
|
+
if (!/\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+\d{1,2}\b|\b\d{1,2}\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/.test(s)) return null;
|
|
27
|
+
const t = Date.parse(`${s.replace(/\b(by|on|before|due)\b/g, '').trim()} ${now.getFullYear()}`);
|
|
28
|
+
if (Number.isFinite(t)) {
|
|
29
|
+
const d = new Date(t);
|
|
30
|
+
return endOf(d.getTime() < now.getTime() - 180 * DAY ? new Date(d.getFullYear() + 1, d.getMonth(), d.getDate()) : d);
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** "overdue 2 days", "due today", "due tomorrow", "due Friday", or null. */
|
|
36
|
+
export function dueWords(at, now = new Date()) {
|
|
37
|
+
if (!at) return null;
|
|
38
|
+
const day = (d) => Math.floor(new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime() / DAY);
|
|
39
|
+
const n = day(at) - day(now);
|
|
40
|
+
if (n < 0) return `overdue ${-n === 1 ? 'a day' : `${-n} days`}`;
|
|
41
|
+
if (n === 0) return 'due today';
|
|
42
|
+
if (n === 1) return 'due tomorrow';
|
|
43
|
+
if (n < 7) return `due ${WEEKDAYS[at.getDay()].replace(/^./, (c) => c.toUpperCase())}`;
|
|
44
|
+
return `due ${at.getFullYear()}-${String(at.getMonth() + 1).padStart(2, '0')}-${String(at.getDate()).padStart(2, '0')}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const INBOX = {
|
|
48
|
+
prompt: { score: 0, label: 'Prompt', why: (i) => `${i.agentName} is stopped until you answer` },
|
|
49
|
+
waiting: { score: 10, label: 'Question', why: (i) => `${i.agentName} waits for your answer` },
|
|
50
|
+
question: { score: 10, label: 'Question', why: (i) => `${i.agentName} asked` },
|
|
51
|
+
review: { score: 35, label: 'AI review', why: (i) => `The AI review of ${i.agentName}'s work is in` },
|
|
52
|
+
stuck: { score: 55, label: 'Stuck', why: (i) => `${i.agentName} looks stuck` },
|
|
53
|
+
conflict: { score: 60, label: 'Overlap', why: (i) => `${i.agentName} and another agent change the same code` },
|
|
54
|
+
rule: { score: 65, label: 'Rule', why: () => 'You keep allowing this' },
|
|
55
|
+
reminder: { score: 70, label: 'Follow-up', why: (i) => `${i.agentName} finished and wasn't looked at` },
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The list: [{ id, kind, label, title, why, score, at, agentId?, url?, actionId?, issueKey?, reviewUrl? }],
|
|
60
|
+
* most pressing first. Each source may be missing (turned off, or it couldn't be had).
|
|
61
|
+
*/
|
|
62
|
+
export function todayItems({ inbox = [], issues = [], actions = [], reviews = [], now = new Date() } = {}) {
|
|
63
|
+
const items = [];
|
|
64
|
+
// The issue each agent works on: named on its questions, and not listed twice.
|
|
65
|
+
const issueOfAgent = new Map(issues.filter((r) => r.agent?.id).map((r) => [r.agent.id, r]));
|
|
66
|
+
const asking = new Set();
|
|
67
|
+
for (const i of inbox) {
|
|
68
|
+
const k = INBOX[i.kind];
|
|
69
|
+
if (!k) continue;
|
|
70
|
+
const r = i.agentId ? issueOfAgent.get(i.agentId) : null;
|
|
71
|
+
if (r && ['prompt', 'waiting', 'question'].includes(i.kind)) asking.add(r.key);
|
|
72
|
+
const about = !r?.title ? '' : i.agentName === r.key ? ` · ${r.title}` : ` · ${r.key}: ${r.title}`;
|
|
73
|
+
items.push({ id: i.key, kind: i.kind, label: k.label, title: String(i.title ?? '').slice(0, 300), why: k.why(i) + about, score: k.score + (i.priority ?? 2) / 10, at: i.at ?? null, agentId: i.agentId ?? null, ...(r ? { url: r.url ?? null, issueKey: r.key } : {}) });
|
|
74
|
+
}
|
|
75
|
+
for (const r of issues) {
|
|
76
|
+
if (asking.has(r.key)) continue;
|
|
77
|
+
const title = r.title ? `${r.key}: ${r.title}` : r.key;
|
|
78
|
+
if (r.group === 'you') {
|
|
79
|
+
items.push({ id: `issue:${r.key}`, kind: 'issue-review', label: 'Jira', title, why: r.note, score: 25, at: r.updatedAt ?? null, agentId: r.agent?.id ?? null, url: r.url ?? null, issueKey: r.key });
|
|
80
|
+
} else if (r.group === 'new') {
|
|
81
|
+
items.push({ id: `issue:${r.key}`, kind: 'issue-new', label: r.type && !/^(story|task|bug|sub-?task)$/i.test(r.type) ? r.type : 'Jira', title, why: r.stage === 'assigned' ? 'Assigned to you in Jira, not started' : 'Proposed for an agent, not started', score: 50, at: r.updatedAt ?? null, url: r.url ?? null, issueKey: r.key });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
for (const a of actions) {
|
|
85
|
+
if (a.group !== 'open') continue;
|
|
86
|
+
const at = dueAt(a.due, now);
|
|
87
|
+
const words = dueWords(at, now);
|
|
88
|
+
const late = at && at.getTime() < now.getTime();
|
|
89
|
+
const soon = at && !late && at.getTime() - now.getTime() < DAY;
|
|
90
|
+
const score = late ? 15 : soon ? 20 : at ? 40 + Math.min(9, (at.getTime() - now.getTime()) / DAY) : 45;
|
|
91
|
+
const why = [words ?? (a.due ? `due ${a.due}` : null), a.from && `asked by ${a.from}`, a.sourceLabel && `in ${a.sourceLabel}`].filter(Boolean).join(' · ');
|
|
92
|
+
items.push({ id: `action:${a.id}`, kind: 'action', label: 'Action', title: a.text, why: why || 'Asked of you', score, at: a.when ?? null, url: a.link ?? null, actionId: a.id, due: at?.toISOString() ?? null });
|
|
93
|
+
}
|
|
94
|
+
for (const r of reviews) {
|
|
95
|
+
const title = `${r.pr.repo ?? ''}#${r.pr.number ?? '?'} ${r.pr.title ?? ''}`.trim();
|
|
96
|
+
if (r.status === 'requested') {
|
|
97
|
+
items.push({ id: `pr:${r.pr.url}`, kind: 'pr-requested', label: 'Review', title, why: `Your review was requested${r.pr.author ? ` by ${r.pr.author}` : ''}`, score: 30, at: r.updatedAt ?? null, url: r.pr.url, reviewUrl: r.pr.url });
|
|
98
|
+
} else if (r.agent && r.review && !r.posted && r.pr.state !== 'MERGED' && r.pr.state !== 'CLOSED') {
|
|
99
|
+
const verdict = { blocked: 'blocks approval', approve_with_nits: 'approve with nits', approve: 'approve' }[r.status] ?? r.status;
|
|
100
|
+
items.push({ id: `pr:${r.pr.url}`, kind: 'pr-ready', label: 'Review', title, why: `${r.agent.name}'s review is ready to post: ${verdict}${r.stale ? ' (the author pushed since)' : ''}`, score: 32, at: r.updatedAt ?? null, agentId: r.agent.id, url: r.pr.url, reviewUrl: r.pr.url });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return items.sort((x, y) => x.score - y.score || String(y.at ?? '').localeCompare(String(x.at ?? '')));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** What the list says aloud: a count, then the first `max` items one by one. */
|
|
107
|
+
export function todaySpeech(items, max = 8) {
|
|
108
|
+
if (!items.length) return ['Nothing needs you right now.'];
|
|
109
|
+
const parts = [`${items.length} thing${items.length === 1 ? '' : 's'} for you today.${items.length > max ? ` The first ${max}:` : ''}`];
|
|
110
|
+
// Read as sentences: a link is "a link", "·" a comma, and no doubled stops ("?.").
|
|
111
|
+
const say = (t) => String(t ?? '').replace(/https?:\/\/\S+/g, 'a link').replace(/\s+·\s+/g, ', ').trim().replace(/[.?!:;,]*$/, (m) => m || '.');
|
|
112
|
+
items.slice(0, max).forEach((it, i) => parts.push(`${i + 1}. ${it.label}. ${say(it.title)} ${say(it.why)}`));
|
|
113
|
+
return parts;
|
|
114
|
+
}
|