ai-agentmanager 1.25.2 → 1.26.1
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 +11 -0
- package/package.json +1 -1
- package/public/app.js +19 -0
- package/public/index.html +6 -1
- package/public/issues.js +2 -1
- package/public/keys.js +4 -3
- package/public/menu.js +26 -2
- package/public/style.css +15 -0
- package/public/today.js +186 -0
- package/src/issues.js +10 -3
- package/src/jira.js +71 -13
- package/src/manager.js +3 -2
- package/src/server.js +55 -5
- package/src/today.js +114 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.26.1 (2026-11-07)
|
|
4
|
+
|
|
5
|
+
- **Jira says why it isn't working.** When your Jira site can't be used (the token isn't accepted, the site sends a sign-in page, it can't be reached), the Jira list and Today say so in words instead of just showing no summaries or statuses. Settings → Jira has a **Check Jira** button that asks the site for your open issues and says how many it found, or why it couldn't.
|
|
6
|
+
- **Jira Server and Data Center.** With no email, the API token is sent as a personal access token, and the older API those sites have is used when Jira Cloud's isn't there. The site address may have a port and a path (`https://jira.company.com:8443/jira`).
|
|
7
|
+
- **Skip, Done and Remove work on every issue in the list.** Before, an issue listed through its agent, whose request named it after other words rather than starting with its link, could fail with "not on the list".
|
|
8
|
+
- **↻ asks Jira again.** Refreshing the Jira list or Today fetches statuses again rather than using those from the last few minutes.
|
|
9
|
+
|
|
10
|
+
## 1.26.0 (2026-11-07)
|
|
11
|
+
|
|
12
|
+
- **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.
|
|
13
|
+
|
|
3
14
|
## 1.25.2 (2026-11-07)
|
|
4
15
|
|
|
5
16
|
- **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.
|
package/package.json
CHANGED
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/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>
|
|
@@ -869,12 +873,13 @@
|
|
|
869
873
|
</fieldset>
|
|
870
874
|
<fieldset class="local-only">
|
|
871
875
|
<legend>Jira</legend>
|
|
872
|
-
<p class="hint">For an agent created from a Jira link, its description shows the issue's summary. Public issues on Atlassian Cloud need nothing here; for your company's site, add it with your email and an <a href="https://id.atlassian.com/manage-profile/security/api-tokens" target="_blank" rel="noopener">API token</a
|
|
876
|
+
<p class="hint">For an agent created from a Jira link, its description shows the issue's summary. Public issues on Atlassian Cloud need nothing here; for your company's site, add it with your email and an <a href="https://id.atlassian.com/manage-profile/security/api-tokens" target="_blank" rel="noopener">API token</a> (Jira Server or Data Center: leave the email empty and use a personal access token). The token is kept on this computer and sent only to that site.</p>
|
|
873
877
|
<div class="row three">
|
|
874
878
|
<label>Site <input name="jiraSite" placeholder="https://yourcompany.atlassian.net" autocomplete="off" /></label>
|
|
875
879
|
<label>Email <input name="jiraEmail" type="email" autocomplete="off" /></label>
|
|
876
880
|
<label>API token <input name="jiraToken" type="password" autocomplete="new-password" /></label>
|
|
877
881
|
</div>
|
|
882
|
+
<p><button type="button" class="small" data-jira-check title="Ask your Jira site for the open issues assigned to you, with the saved settings">Check Jira</button> <span class="hint" data-jira-result></span></p>
|
|
878
883
|
</fieldset>
|
|
879
884
|
<fieldset>
|
|
880
885
|
<legend>Updates</legend>
|
package/public/issues.js
CHANGED
|
@@ -77,7 +77,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
function aboutIssue(r) {
|
|
80
|
-
const missing = data?.jira?.signedIn ? 'Summary not fetched from Jira yet' : 'Summary shows once your Jira site, email and API token are in Settings → Jira';
|
|
80
|
+
const missing = data?.jira?.problem ? 'No summary: Jira can’t be used (see above)' : data?.jira?.signedIn ? 'Summary not fetched from Jira yet' : 'Summary shows once your Jira site, email and API token are in Settings → Jira';
|
|
81
81
|
return `${r.title ? `<div class="issue-title">${esc(r.title)}</div>` : `<div class="hint issue-title">${esc(missing)}</div>`}${r.synopsis ? `<div class="issue-synopsis" title="${esc(r.synopsis)}">${esc(r.synopsis)}</div>` : ''}`;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -172,6 +172,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
172
172
|
<span class="hint">Tick the issues to start agents for; the rest stay here.</span>
|
|
173
173
|
</div>`
|
|
174
174
|
: ''}
|
|
175
|
+
${data.jira?.problem ? `<p class="issues-problem" role="alert">Jira: ${esc(data.jira.problem)}. Summaries, statuses and the issues assigned to you need it; try <b>Check Jira</b> in Settings → Jira.</p>` : ''}
|
|
175
176
|
${rows.length
|
|
176
177
|
? `<div class="issues-scroll"><table class="issues">
|
|
177
178
|
<thead><tr>${boxes ? `<th class="pick"><input type="checkbox" data-issue-pick-all ${allTicked ? 'checked' : ''} aria-label="Tick all" title="Tick all" /></th>` : ''}<th class="issue-action" title="Your action, kept across restarts and updates">Action</th><th>Issue</th><th>Jira status</th><th>Where it stands</th><th>Plan</th><th>Design</th><th>Pull request</th><th>Agent</th><th class="col-active">Active</th></tr></thead>
|
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/menu.js
CHANGED
|
@@ -107,6 +107,7 @@ export function initMenu({ api, esc, toast, $ }) {
|
|
|
107
107
|
form.jiraEmail.value = jira?.email ?? '';
|
|
108
108
|
form.jiraToken.value = '';
|
|
109
109
|
form.jiraToken.placeholder = jira?.hasToken ? 'saved (type to replace)' : '';
|
|
110
|
+
dialog.querySelector('[data-jira-result]').textContent = '';
|
|
110
111
|
containers = await api('GET', '/isolation').catch(() => null);
|
|
111
112
|
showContainers();
|
|
112
113
|
form.claudeToken.value = '';
|
|
@@ -146,6 +147,29 @@ export function initMenu({ api, esc, toast, $ }) {
|
|
|
146
147
|
dialog.close();
|
|
147
148
|
$(`#${go.dataset.open}`).click();
|
|
148
149
|
});
|
|
150
|
+
// Check Jira: saves what was typed, then asks the site for your open issues.
|
|
151
|
+
dialog.addEventListener('click', async (e) => {
|
|
152
|
+
const b = e.target.closest('[data-jira-check]');
|
|
153
|
+
if (!b) return;
|
|
154
|
+
const out = dialog.querySelector('[data-jira-result]');
|
|
155
|
+
b.disabled = true;
|
|
156
|
+
out.textContent = 'Asking Jira…';
|
|
157
|
+
try {
|
|
158
|
+
const typed = { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined };
|
|
159
|
+
const changed = jira && (typed.site !== (jira.site ?? '') || typed.email !== (jira.email ?? '') || typed.token);
|
|
160
|
+
const r = changed ? await api('PUT', '/jira', typed) : await api('GET', '/jira/check');
|
|
161
|
+
if (changed) {
|
|
162
|
+
jira = { site: r.site, email: r.email, hasToken: r.hasToken };
|
|
163
|
+
form.jiraToken.value = '';
|
|
164
|
+
form.jiraToken.placeholder = r.hasToken ? 'saved (type to replace)' : '';
|
|
165
|
+
}
|
|
166
|
+
out.textContent = r.problem ? `Not working: ${r.problem}` : `Works: ${r.assigned} open issue${r.assigned === 1 ? '' : 's'} assigned to you`;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
out.textContent = err.message;
|
|
169
|
+
} finally {
|
|
170
|
+
b.disabled = false;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
149
173
|
form.addEventListener('submit', async (e) => {
|
|
150
174
|
e.preventDefault();
|
|
151
175
|
try {
|
|
@@ -159,8 +183,8 @@ export function initMenu({ api, esc, toast, $ }) {
|
|
|
159
183
|
}
|
|
160
184
|
}
|
|
161
185
|
if (!remote() && jira && (form.jiraSite.value.trim() !== (jira.site ?? '') || form.jiraEmail.value.trim() !== (jira.email ?? '') || form.jiraToken.value.trim())) {
|
|
162
|
-
await api('PUT', '/jira', { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined });
|
|
163
|
-
toast(
|
|
186
|
+
const j = await api('PUT', '/jira', { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined });
|
|
187
|
+
toast(j.problem ? `Jira saved, but it doesn't work yet: ${j.problem}` : j.assigned !== null && j.assigned !== undefined ? `Jira works: ${j.assigned} open issue${j.assigned === 1 ? '' : 's'} assigned to you` : 'Jira saved', j.problem ? 10_000 : 4000);
|
|
164
188
|
}
|
|
165
189
|
if (!remote() && containers?.available) {
|
|
166
190
|
if (form.claudeToken.value.trim()) await api('PUT', '/isolation/token', { token: form.claudeToken.value.trim() });
|
package/public/style.css
CHANGED
|
@@ -1175,12 +1175,27 @@ table.issues .dot { display: inline-block; width: 7px; height: 7px; border-radiu
|
|
|
1175
1175
|
table.issues .dot.busy { background: var(--green); }
|
|
1176
1176
|
table.issues .dot.idle { background: var(--muted); }
|
|
1177
1177
|
.issues-empty { padding: 24px 4px; }
|
|
1178
|
+
.issues-problem { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--red); color: var(--red); font-size: 13px; }
|
|
1178
1179
|
@media (max-width: 640px) {
|
|
1179
1180
|
.issues-dialog { width: calc(100% - 32px); padding: 12px; }
|
|
1180
1181
|
table.issues .col-active { display: none; }
|
|
1181
1182
|
table.issues .issue-title, table.issues .issue-synopsis { max-width: 200px; }
|
|
1182
1183
|
}
|
|
1183
1184
|
|
|
1185
|
+
/* ---------- Today: what needs you */
|
|
1186
|
+
#today-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
1187
|
+
#today-btn { font-weight: 600; }
|
|
1188
|
+
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); }
|
|
1189
|
+
table.today-table tr.pressing .today-label { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
|
|
1190
|
+
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); }
|
|
1191
|
+
table.today-table .today-title { color: var(--text); }
|
|
1192
|
+
table.today-table .today-why { margin-top: 2px; }
|
|
1193
|
+
table.today-table .today-acts { width: 1%; text-align: right; }
|
|
1194
|
+
table.today-table .small-link { font-size: 12px; margin-left: 4px; }
|
|
1195
|
+
@media (max-width: 640px) {
|
|
1196
|
+
table.today-table .today-acts { white-space: normal; }
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1184
1199
|
/* ---------- Designs: agents' design docs */
|
|
1185
1200
|
.designs-search { width: 180px; }
|
|
1186
1201
|
.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, fresh = false } = {}) {
|
|
22
|
+
if (loading) return;
|
|
23
|
+
loading = true;
|
|
24
|
+
try {
|
|
25
|
+
data = await api('GET', `/today${fresh ? '?fresh=1' : ''}`);
|
|
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 === 'jira' ? 'Jira' : e.source} (${e.error})`).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({ fresh: true }), { 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({ fresh: true });
|
|
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/src/issues.js
CHANGED
|
@@ -282,8 +282,9 @@ export class ProposedIssues {
|
|
|
282
282
|
let p = this.all.find((x) => x.key === key);
|
|
283
283
|
let agent = this.agentFor(key);
|
|
284
284
|
const mine = !p && !agent ? (this.manager.assignedNow ?? []).find((i) => i.key === key) : null;
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
// Skip, done, remove and clear are kept by key, whatever listed the issue; assign needs where to start from.
|
|
286
|
+
if (!p && !agent && !mine && (action === 'assign' || !ISSUE_KEY.test(key))) {
|
|
287
|
+
failed.push({ key, reason: action === 'assign' ? "can't start an agent: no link for it (Jira didn't list it; is Settings → Jira working?)" : 'not an issue key' });
|
|
287
288
|
continue;
|
|
288
289
|
}
|
|
289
290
|
// An issue assigned to you in Jira: assigning it makes the request from its link and summary.
|
|
@@ -319,7 +320,13 @@ export class ProposedIssues {
|
|
|
319
320
|
|
|
320
321
|
agentFor(key) {
|
|
321
322
|
const k = key.toLowerCase();
|
|
322
|
-
|
|
323
|
+
const list = this.store.list();
|
|
324
|
+
return (
|
|
325
|
+
list.find((a) => a.kind === 'task' && (a.name.toLowerCase() === k || leadingJiraKey(a.intent)?.toLowerCase() === k)) ??
|
|
326
|
+
// The agent the Jira list shows on the issue: its request may name the issue later on, not lead with the link.
|
|
327
|
+
list.find((a) => a.kind !== 'assistant' && issueOf({ ...a, bugs: Object.values(a.bugs ?? {}) })?.key.toLowerCase() === k) ??
|
|
328
|
+
null
|
|
329
|
+
);
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
/** Propose an issue: the request starts with its link. */
|
package/src/jira.js
CHANGED
|
@@ -42,7 +42,7 @@ export function saveJira({ site, email, token, clearToken = false } = {}) {
|
|
|
42
42
|
email: email === undefined ? cur.email ?? '' : String(email).trim(),
|
|
43
43
|
token: clearToken ? '' : token ? String(token).trim() : cur.token ?? '',
|
|
44
44
|
};
|
|
45
|
-
if (next.site && !/^https:\/\/[\w.-]
|
|
45
|
+
if (next.site && !/^https:\/\/[\w.-]+(:\d+)?(\/[\w.~-]+)*$/.test(next.site)) throw Object.assign(new Error('The Jira site is an https address, like https://yourcompany.atlassian.net (or https://jira.yourcompany.com:8443/jira)'), { status: 400 });
|
|
46
46
|
fs.mkdirSync(paths.home, { recursive: true });
|
|
47
47
|
fs.writeFileSync(file(), JSON.stringify(next, null, 2) + '\n', { mode: 0o600 });
|
|
48
48
|
return jiraView(loadJira());
|
|
@@ -75,18 +75,67 @@ export function wordsAfterLink(text) {
|
|
|
75
75
|
// Statuses that mean the work is over, whatever category a workflow puts them in.
|
|
76
76
|
const FINISHED = /^(closed|done|resolved|integrated|cancell?ed|won'?t (do|fix)|duplicate|rejected)$/i;
|
|
77
77
|
|
|
78
|
+
// Why the last call to your Jira site failed ({ at, reason }), or null when it worked: shown in
|
|
79
|
+
// the Jira list and Today, since an empty list alone doesn't say whether Jira was reached.
|
|
80
|
+
let problem = null;
|
|
81
|
+
|
|
82
|
+
/** Why your Jira site couldn't be used last time, or null. */
|
|
83
|
+
export const jiraProblem = () => problem;
|
|
84
|
+
|
|
85
|
+
/** Basic with the email and API token (Jira Cloud); a bearer token without an email (Server, Data Center). */
|
|
86
|
+
const authOf = (jira) => (jira.email ? `Basic ${Buffer.from(`${jira.email}:${jira.token}`).toString('base64')}` : `Bearer ${jira.token}`);
|
|
87
|
+
|
|
88
|
+
/** The reason in words for an answer that isn't ok, or a fetch that threw. */
|
|
89
|
+
function reasonOf(site, res, e) {
|
|
90
|
+
if (res) {
|
|
91
|
+
const why = {
|
|
92
|
+
401: 'the email or API token is not accepted (Settings → Jira)',
|
|
93
|
+
403: 'no permission; if you mistyped the token a few times, Jira may want you to sign in once in the browser',
|
|
94
|
+
404: 'no Jira API at that address (is the site right?)',
|
|
95
|
+
429: 'too many requests; trying again later',
|
|
96
|
+
}[res.status];
|
|
97
|
+
return `${site} answered ${res.status}${why ? `: ${why}` : ''}`;
|
|
98
|
+
}
|
|
99
|
+
const m = String(e?.cause?.message ?? e?.message ?? e ?? '');
|
|
100
|
+
if (e?.name === 'TimeoutError' || /abort|timeout/i.test(m)) return `${site} did not answer in time (VPN off?)`;
|
|
101
|
+
if (/redirect/i.test(m)) return `${site} sent a sign-in page instead of an answer (the site address may be wrong, or it needs single sign-on)`;
|
|
102
|
+
return `couldn't reach ${site}: ${m || 'network error'}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Jira Cloud's API (v3), then the older one (v2) that Jira Server and Data Center have when v3
|
|
107
|
+
* isn't there. Returns the response, or throws.
|
|
108
|
+
*/
|
|
109
|
+
async function jiraGet(fetchImpl, site, v3, v2, init) {
|
|
110
|
+
const res = await fetchImpl(`${site}${v3.path}`, { ...init, ...v3.init });
|
|
111
|
+
if (res.status !== 404 || !v2) return res;
|
|
112
|
+
return fetchImpl(`${site}${v2.path}`, { ...init, ...v2.init });
|
|
113
|
+
}
|
|
114
|
+
|
|
78
115
|
/**
|
|
79
116
|
* Open issues assigned to you on your Jira site (epics too): [{ key, url, summary, status,
|
|
80
|
-
* category, type, synopsis, updated }]. Needs the site
|
|
81
|
-
* null without them or when Jira can't be reached
|
|
117
|
+
* category, type, synopsis, updated }]. Needs the site and API token from Settings → Jira (and the
|
|
118
|
+
* email, for Jira Cloud); null without them or when Jira can't be reached (jiraProblem() says why).
|
|
119
|
+
* Closed and integrated ones are left out.
|
|
82
120
|
*/
|
|
83
121
|
export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, timeoutMs = 10_000, max = 100 } = {}) {
|
|
84
|
-
if (!jira.site || !jira.
|
|
85
|
-
const headers = { accept: 'application/json', 'content-type': 'application/json', authorization:
|
|
86
|
-
const
|
|
122
|
+
if (!jira.site || !jira.token) return null;
|
|
123
|
+
const headers = { accept: 'application/json', 'content-type': 'application/json', authorization: authOf(jira) };
|
|
124
|
+
const jql = 'assignee = currentUser() AND statusCategory != Done ORDER BY updated DESC';
|
|
125
|
+
const fields = ['summary', 'status', 'issuetype', 'description', 'updated'];
|
|
126
|
+
const q = new URLSearchParams({ jql, fields: fields.join(','), maxResults: String(max) });
|
|
87
127
|
try {
|
|
88
|
-
const res = await
|
|
89
|
-
|
|
128
|
+
const res = await jiraGet(
|
|
129
|
+
fetchImpl,
|
|
130
|
+
jira.site,
|
|
131
|
+
{ path: '/rest/api/3/search/jql', init: { method: 'POST', body: JSON.stringify({ jql, fields, maxResults: max }) } },
|
|
132
|
+
{ path: `/rest/api/2/search?${q}`, init: { method: 'GET' } },
|
|
133
|
+
{ headers, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) },
|
|
134
|
+
);
|
|
135
|
+
if (!res.ok) {
|
|
136
|
+
problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, res) };
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
90
139
|
const out = [];
|
|
91
140
|
for (const i of (await res.json())?.issues ?? []) {
|
|
92
141
|
const f = i?.fields ?? {};
|
|
@@ -104,8 +153,10 @@ export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, tim
|
|
|
104
153
|
updated: typeof f.updated === 'string' ? f.updated : null,
|
|
105
154
|
});
|
|
106
155
|
}
|
|
156
|
+
problem = null;
|
|
107
157
|
return out;
|
|
108
|
-
} catch {
|
|
158
|
+
} catch (e) {
|
|
159
|
+
problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, null, e) };
|
|
109
160
|
return null;
|
|
110
161
|
}
|
|
111
162
|
}
|
|
@@ -168,17 +219,24 @@ export async function issueFields({ key, site }, { jira = loadJira(), fetchImpl
|
|
|
168
219
|
const allowed = configured || /\.atlassian\.net$/.test(host) || allow?.(site);
|
|
169
220
|
if (!allowed) return null;
|
|
170
221
|
const headers = { accept: 'application/json' };
|
|
171
|
-
if (configured && jira.
|
|
222
|
+
if (configured && jira.token) headers.authorization = authOf(jira);
|
|
223
|
+
const q = `${encodeURIComponent(key)}?fields=summary,status,description`;
|
|
172
224
|
try {
|
|
173
|
-
|
|
174
|
-
|
|
225
|
+
// Your site as saved: it may have a path (https://host/jira) that the link's origin leaves out.
|
|
226
|
+
const res = await jiraGet(fetchImpl, configured ? jira.site : site, { path: `/rest/api/3/issue/${q}` }, configured ? { path: `/rest/api/2/issue/${q}` } : null, { headers, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });
|
|
227
|
+
if (!res.ok) {
|
|
228
|
+
// Your own site refusing (not a missing issue) is worth saying.
|
|
229
|
+
if (configured && res.status !== 404) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, res) };
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
175
232
|
const f = (await res.json())?.fields ?? {};
|
|
176
233
|
const summary = typeof f.summary === 'string' && f.summary.trim() ? f.summary.trim().slice(0, 300) : null;
|
|
177
234
|
const status = typeof f.status?.name === 'string' ? f.status.name.slice(0, 60) : null;
|
|
178
235
|
if (!summary && !status) return null;
|
|
179
236
|
const synopsis = synopsisOf(f.description);
|
|
180
237
|
return { summary, status, category: typeof f.status?.statusCategory?.key === 'string' ? f.status.statusCategory.key : null, ...(synopsis ? { synopsis } : {}) };
|
|
181
|
-
} catch {
|
|
238
|
+
} catch (e) {
|
|
239
|
+
if (configured) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, null, e) };
|
|
182
240
|
return null;
|
|
183
241
|
}
|
|
184
242
|
}
|
package/src/manager.js
CHANGED
|
@@ -107,7 +107,7 @@ import { spawn } from 'node:child_process';
|
|
|
107
107
|
import * as git from './git.js';
|
|
108
108
|
import { buildMap, touchedFiles } from './codemap.js';
|
|
109
109
|
import { parseDiff } from '../public/review.js';
|
|
110
|
-
import { assignedIssues, issueFields, issueSummary, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
|
|
110
|
+
import { assignedIssues, issueFields, issueSummary, jiraProblem, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
|
|
111
111
|
import { issueRows } from './issues.js';
|
|
112
112
|
import { designRows } from './designs.js';
|
|
113
113
|
import { reviewPath, reviewerPrompt } from './reviews.js';
|
|
@@ -869,7 +869,7 @@ export class AgentManager extends EventEmitter {
|
|
|
869
869
|
}
|
|
870
870
|
for (const [k, v] of jira) if (!v) jira.delete(k);
|
|
871
871
|
const j = loadJira();
|
|
872
|
-
return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed, actions, assigned), jira: { site: j.site, signedIn: Boolean(j.site && j.
|
|
872
|
+
return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed, actions, assigned), jira: { site: j.site, signedIn: Boolean(j.site && j.token), problem: j.site && j.token ? jiraProblem()?.reason ?? null : null } };
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
/** Every agent's design doc, for the Designs list. */
|
|
@@ -893,6 +893,7 @@ export class AgentManager extends EventEmitter {
|
|
|
893
893
|
/** Fill in summaries still missing (after Jira settings change); returns how many it found. */
|
|
894
894
|
async refreshSynopses() {
|
|
895
895
|
this.jiraCache?.clear();
|
|
896
|
+
this.assignedAt = 0;
|
|
896
897
|
let found = 0;
|
|
897
898
|
for (const a of this.store.list()) {
|
|
898
899
|
if (a.synopsis?.source === 'jira' || !leadingIssue(a.intent)) continue;
|
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';
|
|
@@ -38,7 +39,7 @@ import { Previews, parseUrl } from './preview.js';
|
|
|
38
39
|
import { LiveBrowser } from './livebrowser.js';
|
|
39
40
|
import * as remote from './remote.js';
|
|
40
41
|
import * as service from './service.js';
|
|
41
|
-
import { jiraView, saveJira } from './jira.js';
|
|
42
|
+
import { assignedIssues, jiraProblem, jiraView, saveJira } from './jira.js';
|
|
42
43
|
import { ProposedIssues, issuesMarkdown } from './issues.js';
|
|
43
44
|
import { MyActions } from './actions.js';
|
|
44
45
|
import { designsMarkdown } from './designs.js';
|
|
@@ -77,7 +78,7 @@ function isAllowedOrigin(origin, port) {
|
|
|
77
78
|
const PUBLIC_REMOTE_API = new Set(['POST /api/login', 'GET /api/session']);
|
|
78
79
|
// Updates are not here: a signed-in device (a phone) can install the newest release too. It only
|
|
79
80
|
// ever installs an official release from where this copy came from (git tag or npm) and restarts.
|
|
80
|
-
const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira
|
|
81
|
+
const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira(\/check)?$|isolation\/|editors$|agentkit\/connect$|agents\/[\w-]+\/open-in$|shutdown$)/;
|
|
81
82
|
const HOOK_PATH = '/api/hooks/agents';
|
|
82
83
|
const REPORT_PATH = '/api/agentkit/report';
|
|
83
84
|
const NO_REPO_KINDS = new Set(['general', 'assistant']);
|
|
@@ -716,13 +717,25 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
716
717
|
);
|
|
717
718
|
// Jira: the site and API token used to show an issue's summary for agents created from its link.
|
|
718
719
|
api.get('/jira', wrap(() => jiraView()));
|
|
720
|
+
// Whether the saved settings work: how many open issues are yours, or why Jira can't be used.
|
|
721
|
+
api.get(
|
|
722
|
+
'/jira/check',
|
|
723
|
+
wrap(async () => {
|
|
724
|
+
const view = jiraView();
|
|
725
|
+
if (!view.site || !view.hasToken) return { assigned: null, problem: 'Add the site and API token first' };
|
|
726
|
+
const mine = await assignedIssues({ timeoutMs: 8000 });
|
|
727
|
+
return { assigned: mine ? mine.length : null, problem: mine ? null : jiraProblem()?.reason ?? 'Jira could not be reached' };
|
|
728
|
+
}),
|
|
729
|
+
);
|
|
719
730
|
api.put(
|
|
720
731
|
'/jira',
|
|
721
732
|
wrap(async (req) => {
|
|
722
733
|
const view = saveJira(req.body ?? {});
|
|
723
734
|
// Agents already created from links get their summaries now (in the background).
|
|
724
735
|
manager.refreshSynopses().catch(() => {});
|
|
725
|
-
|
|
736
|
+
// Tried at once, so Settings can say whether it works: how many issues are yours, or why not.
|
|
737
|
+
const mine = view.site && view.hasToken ? await assignedIssues({ timeoutMs: 8000 }) : null;
|
|
738
|
+
return { ...view, assigned: mine ? mine.length : null, problem: view.site && view.hasToken && !mine ? jiraProblem()?.reason ?? 'Jira could not be reached' : null };
|
|
726
739
|
}),
|
|
727
740
|
);
|
|
728
741
|
// Start at login: the login service (launchd or systemd) that brings the daemon back after a reboot.
|
|
@@ -789,8 +802,11 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
789
802
|
api.get('/codemap', wrap((req) => manager.codeMap(req.query.project ? String(req.query.project) : null)));
|
|
790
803
|
// Issues agents work on, for the summary; ?group=you|agent|done and ?format=markdown to paste.
|
|
791
804
|
api.get('/issues', wrap(async (req) => {
|
|
792
|
-
// ?fresh=1 (the ↻ button) asks Jira again
|
|
793
|
-
if (req.query.fresh === '1')
|
|
805
|
+
// ?fresh=1 (the ↻ button) asks Jira again: the issues assigned to you and each issue's status.
|
|
806
|
+
if (req.query.fresh === '1') {
|
|
807
|
+
manager.assignedAt = 0;
|
|
808
|
+
manager.jiraCache?.clear();
|
|
809
|
+
}
|
|
794
810
|
manager.jiraOff = !featuresOf(config).jira;
|
|
795
811
|
const v = await manager.issues(proposed.listed(), proposed.actions);
|
|
796
812
|
const group = req.query.group ? String(req.query.group) : null;
|
|
@@ -864,6 +880,40 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
864
880
|
res.status(500).json({ error: e.message });
|
|
865
881
|
}
|
|
866
882
|
});
|
|
883
|
+
// Today: what needs you, from every list, most pressing first (today.js). A list that's off or
|
|
884
|
+
// can't be had right now is left out, and said so.
|
|
885
|
+
api.get('/today', wrap(async (req) => {
|
|
886
|
+
const f = featuresOf(config);
|
|
887
|
+
// ?fresh=1 (↻ or r) asks Jira again rather than using what was fetched in the last few minutes.
|
|
888
|
+
if (req.query.fresh === '1') {
|
|
889
|
+
manager.assignedAt = 0;
|
|
890
|
+
manager.jiraCache?.clear();
|
|
891
|
+
}
|
|
892
|
+
manager.jiraOff = !f.jira;
|
|
893
|
+
const errors = [];
|
|
894
|
+
const got = async (name, fn) => {
|
|
895
|
+
try {
|
|
896
|
+
return await fn();
|
|
897
|
+
} catch (e) {
|
|
898
|
+
errors.push({ source: name, error: e.message });
|
|
899
|
+
return [];
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
const [inbox, issues, actions, prs] = await Promise.all([
|
|
903
|
+
got('inbox', () => manager.inbox()),
|
|
904
|
+
f.jira
|
|
905
|
+
? got('jira', async () => {
|
|
906
|
+
const v = await manager.issues(proposed.listed(), proposed.actions);
|
|
907
|
+
if (v.jira.problem) errors.push({ source: 'jira', error: v.jira.problem });
|
|
908
|
+
return v.rows;
|
|
909
|
+
})
|
|
910
|
+
: [],
|
|
911
|
+
f.slack || f.gemini ? got('actions', () => myActions.rows()) : [],
|
|
912
|
+
got('reviews', () => reviews.rows()),
|
|
913
|
+
]);
|
|
914
|
+
const items = todayItems({ inbox, issues, actions, reviews: prs });
|
|
915
|
+
return { items, speech: todaySpeech(items), features: f, errors };
|
|
916
|
+
}));
|
|
867
917
|
api.get('/standup', wrap(() => standup.view()));
|
|
868
918
|
api.post('/standup', wrap(async () => ({ ...standup.view(), latest: await standup.make({ reason: 'asked' }) })));
|
|
869
919
|
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
|
+
}
|