ai-agentmanager 1.23.0 → 1.24.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 +12 -0
- package/package.json +1 -1
- package/public/app.js +16 -2
- package/public/diagram.js +38 -0
- package/public/issues.js +65 -28
- package/public/share.js +3 -2
- package/public/speak.js +69 -2
- package/public/standup.js +30 -9
- package/public/style.css +11 -1
- package/src/assistant.js +2 -2
- package/src/cli.js +15 -2
- package/src/issues.js +141 -20
- package/src/jira.js +75 -2
- package/src/manager.js +13 -4
- package/src/server.js +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.24.0 (2026-11-06)
|
|
4
|
+
|
|
5
|
+
- **Your action on each Jira issue: assign, skip, done or remove.** A picker on the left of every issue in the Jira tab. Your choice is kept by the daemon, so a restart or an update doesn't ask again, and you can change it any time (a removed issue is under Removed, to bring back). Assign starts an agent for an issue not started yet. The assistant doesn't propose or start agents for issues you skipped, marked done or removed. Also `agentmgr issues set <assign|skip|done|remove|clear> <keys...>`.
|
|
6
|
+
- **Every open Jira issue assigned to you is listed**, epics too, until it's closed or integrated, with or without an agent. Needs your Jira site, email and API token in Settings → Jira.
|
|
7
|
+
- **A synopsis under each issue**: what it's about in a sentence or two, from its Jira description (or the agent's design doc).
|
|
8
|
+
- **A clearer standup voice.** The standup used a different voice for each agent, picked from every voice installed, and on a Mac that includes the old robotic ones. Now it uses only the clearest on-device voices (Premium, Enhanced and Siri voices first), names are read as words, and you can pick one voice under the player; it's used for everything read aloud. Online voices (Chrome's Google ones) are offered but never picked for you, since they send the text to Google.
|
|
9
|
+
|
|
10
|
+
## 1.23.1 (2026-11-06)
|
|
11
|
+
|
|
12
|
+
- **Diagrams that fail to draw no longer litter the page.** Mermaid's "Syntax error" picture was left at the bottom of the page when an agent's diagram didn't parse. Now the diagram's own spot says it couldn't be drawn and shows its source. A diagram whose node labels have unquoted parentheses or braces (`A[GetView(s)]`, which agents often write) is drawn again with those labels quoted, so most of them now draw.
|
|
13
|
+
- **The page reloads itself after an update.** While restarting, the old daemon keeps serving the old version until its agents are closed, so a reload during that time (even Shift+Reload) still showed the old one. Now any open page, including one on a phone over remote access, reloads by itself as soon as the new version is up.
|
|
14
|
+
|
|
3
15
|
## 1.23.0 (2026-11-06)
|
|
4
16
|
|
|
5
17
|
- **Reviews.** Reviewer agents for other people's pull requests. **Reviews** (or `g`) lists PRs where your review is requested; tick them, or paste any PR link. A reviewer works read-only on the PR's head: a verdict (approve, approve with nits, blocked), the approval blockers with file, line, why and what would resolve them, critical questions for the author, risks, test gaps and nits. Tick what to send and **Post as pending review** (a draft review under your name that you submit on GitHub), or **Copy**. When the author pushes, the reviewer re-checks its blockers. **🔊 Explain** reads it aloud. The assistant's GitHub reviews source starts reviewers, or only lists them when you pick. `agentmgr review <PR>`, `agentmgr reviews` (`show`, `post`, `dismiss`).
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -29,6 +29,7 @@ import { initIssues } from '/issues.js';
|
|
|
29
29
|
import { reviewSpeech } from '/prvoice.js';
|
|
30
30
|
import { initDesigns } from '/designs.js';
|
|
31
31
|
import { initReviews } from '/reviews.js';
|
|
32
|
+
import { drawDiagram } from '/diagram.js';
|
|
32
33
|
import { initValue } from '/value.js';
|
|
33
34
|
import { initCodeMap } from '/codemap.js';
|
|
34
35
|
import { initKeys } from '/keys.js';
|
|
@@ -337,7 +338,8 @@ const isDark = () => {
|
|
|
337
338
|
};
|
|
338
339
|
// SVG text labels rather than HTML ones: a diagram then exports to PNG (the browser won't turn
|
|
339
340
|
// HTML-in-SVG into an image).
|
|
340
|
-
|
|
341
|
+
// suppressErrorRendering: a diagram that fails shows our message, not Mermaid's error picture.
|
|
342
|
+
const mermaidConfig = () => ({ startOnLoad: false, suppressErrorRendering: true, securityLevel: 'strict', theme: isDark() ? 'dark' : 'default', htmlLabels: false, flowchart: { htmlLabels: false } });
|
|
341
343
|
// Diagrams are drawn in the theme's colors: redraw them when it changes.
|
|
342
344
|
window.addEventListener('agentmgr-theme', () => {
|
|
343
345
|
diagrams.clear();
|
|
@@ -372,7 +374,7 @@ async function renderDiagrams(root) {
|
|
|
372
374
|
mermaidLib = (await import('/vendor/mermaid/mermaid.esm.min.mjs')).default;
|
|
373
375
|
mermaidLib.initialize(mermaidConfig());
|
|
374
376
|
}
|
|
375
|
-
const { svg } = await mermaidLib
|
|
377
|
+
const { svg } = await drawDiagram(mermaidLib, `mmd-${diagrams.size}-${Date.now()}`, src);
|
|
376
378
|
diagrams.set(src, { svg });
|
|
377
379
|
} catch (err) {
|
|
378
380
|
diagrams.set(src, { error: String(err?.message || err).split('\n')[0] });
|
|
@@ -4020,6 +4022,17 @@ async function loadAbout() {
|
|
|
4020
4022
|
return aboutInfo;
|
|
4021
4023
|
}
|
|
4022
4024
|
loadAbout().catch(() => {});
|
|
4025
|
+
|
|
4026
|
+
// After an update the old daemon keeps answering (with the old version and old pages) while it
|
|
4027
|
+
// closes its agents, so a reload then still shows the old one. Whenever the event stream
|
|
4028
|
+
// connects again, a daemon running a different version means this page is stale: reload it.
|
|
4029
|
+
async function reloadIfUpdated() {
|
|
4030
|
+
if (!aboutInfo) return;
|
|
4031
|
+
const was = aboutInfo.version;
|
|
4032
|
+
try {
|
|
4033
|
+
if ((await loadAbout()).version !== was) location.reload();
|
|
4034
|
+
} catch {}
|
|
4035
|
+
}
|
|
4023
4036
|
function renderAbout(a) {
|
|
4024
4037
|
const link = (url, text = url.replace(/^https:\/\//, '')) => `<a href="${esc(url)}" target="_blank" rel="noopener">${esc(text)}</a>`;
|
|
4025
4038
|
const when = (iso) => new Date(iso).toLocaleString();
|
|
@@ -4225,6 +4238,7 @@ function connectEvents() {
|
|
|
4225
4238
|
onOpen: () => {
|
|
4226
4239
|
$('#conn').textContent = REMOTE ? 'connected (remote)' : 'daemon connected';
|
|
4227
4240
|
$('#conn').className = 'conn ok';
|
|
4241
|
+
reloadIfUpdated();
|
|
4228
4242
|
},
|
|
4229
4243
|
onMessage: handleEvent,
|
|
4230
4244
|
onClose: async () => {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Drawing a Mermaid diagram an agent wrote. Agents often put parentheses or braces in a node's
|
|
2
|
+
// label without quotes (MV[GetMaintenanceView(s)]), which Mermaid reads as a shape and refuses:
|
|
3
|
+
// when a diagram fails, it's drawn again once with those labels quoted. A failed render never
|
|
4
|
+
// leaves Mermaid's error picture in the page.
|
|
5
|
+
|
|
6
|
+
// A node's label in [ ], unquoted, with ( ) { } inside that aren't one of Mermaid's [( )] shapes.
|
|
7
|
+
const LABEL = /(\b[\w-]+)\[(?!["(/\\[])([^\[\]"\n]*[(){}][^\[\]"\n]*)\]/g;
|
|
8
|
+
|
|
9
|
+
/** The source with such labels quoted ("" inside a label becomes #quot;). Unchanged when none. */
|
|
10
|
+
export function quoteLabels(src) {
|
|
11
|
+
return String(src ?? '').replace(LABEL, (_, id, label) => `${id}["${label.replace(/"/g, '#quot;')}"]`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Mermaid's own leftovers from a failed render: its temporary containers and the error picture. */
|
|
15
|
+
function sweep(id) {
|
|
16
|
+
for (const sel of [`#${id}`, `#d${id}`, `#i${id}`]) {
|
|
17
|
+
try {
|
|
18
|
+
document.querySelector(sel)?.remove();
|
|
19
|
+
} catch {}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Render `src` with the Mermaid library `lib`: { svg }, or throws the first error. */
|
|
24
|
+
export async function drawDiagram(lib, id, src) {
|
|
25
|
+
try {
|
|
26
|
+
return await lib.render(id, src);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
sweep(id);
|
|
29
|
+
const fixed = quoteLabels(src);
|
|
30
|
+
if (fixed === src) throw err;
|
|
31
|
+
try {
|
|
32
|
+
return await lib.render(`${id}-q`, fixed);
|
|
33
|
+
} catch {
|
|
34
|
+
sweep(`${id}-q`);
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/public/issues.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Jira: every issue an agent works on in one table, the ones waiting for your review first: the
|
|
2
2
|
// issue and its Jira status, where the work stands, its plan, design doc and pull request, and a
|
|
3
3
|
// link to the agent. Issues proposed for agents (when you pick) come first, with a box to tick:
|
|
4
|
-
// agents start only for the ticked ones.
|
|
4
|
+
// agents start only for the ticked ones. Each issue has your action on its left (assign, skip, done,
|
|
5
|
+
// remove), kept by the daemon across restarts and updates, and changeable any time.
|
|
5
6
|
|
|
6
7
|
import { listenHtml } from './speak.js';
|
|
7
8
|
|
|
@@ -11,7 +12,15 @@ const FILTERS = [
|
|
|
11
12
|
['you', 'Waiting for you'],
|
|
12
13
|
['agent', 'Agents on it'],
|
|
13
14
|
['done', 'Done'],
|
|
15
|
+
['skipped', 'Skipped'],
|
|
14
16
|
['all', 'All'],
|
|
17
|
+
['removed', 'Removed'],
|
|
18
|
+
];
|
|
19
|
+
const ACTIONS = [
|
|
20
|
+
['assign', 'Assign', 'An agent works on it (assigning one not started yet starts its agent)'],
|
|
21
|
+
['skip', 'Skip', 'Not now: under Skipped, and not proposed or started again'],
|
|
22
|
+
['done', 'Done', 'Handled (by you or elsewhere): under Done'],
|
|
23
|
+
['remove', 'Remove', 'Off the list (under Removed, to bring back)'],
|
|
15
24
|
];
|
|
16
25
|
const CHECKS = { passed: ['✓', 'Checks pass'], failed: ['✗', 'Checks failing'], running: ['●', 'Checks running'] };
|
|
17
26
|
|
|
@@ -32,11 +41,11 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
32
41
|
|
|
33
42
|
let loadedAt = 0;
|
|
34
43
|
|
|
35
|
-
async function load({ quiet = false } = {}) {
|
|
44
|
+
async function load({ quiet = false, fresh = false } = {}) {
|
|
36
45
|
if (loading) return;
|
|
37
46
|
loading = true;
|
|
38
47
|
try {
|
|
39
|
-
data = await api('GET',
|
|
48
|
+
data = await api('GET', `/issues${fresh ? '?fresh=1' : ''}`);
|
|
40
49
|
loadedAt = Date.now();
|
|
41
50
|
} catch (e) {
|
|
42
51
|
if (!quiet) toast?.(e.message, 5000);
|
|
@@ -58,18 +67,30 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
69
|
|
|
70
|
+
/** Your action on the issue, left of it: kept across restarts; change it any time. */
|
|
71
|
+
function actionCell(r) {
|
|
72
|
+
const none = r.agent ? '' : `<option value="" ${r.action ? '' : 'selected'}>—</option>`;
|
|
73
|
+
const opts = ACTIONS.map(([v, label, title]) => `<option value="${v}" title="${esc(title)}" ${r.action === v ? 'selected' : ''}>${label}</option>`).join('');
|
|
74
|
+
return `<td class="issue-action"><select data-issue-action="${esc(r.key)}" class="act-${esc(r.action ?? 'none')}" aria-label="Your action on ${esc(r.key)}" title="Your action: kept across restarts and updates">${none}${opts}</select></td>`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function aboutIssue(r) {
|
|
78
|
+
return `${r.title ? `<div class="issue-title">${esc(r.title)}</div>` : ''}${r.synopsis ? `<div class="issue-synopsis" title="${esc(r.synopsis)}">${esc(r.synopsis)}</div>` : ''}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
61
81
|
function row(r, boxes) {
|
|
62
82
|
const box = !boxes ? '' : r.group === 'new' ? `<td class="pick"><input type="checkbox" data-issue-pick="${esc(r.key)}" ${ticked.has(r.key) ? 'checked' : ''} aria-label="Start an agent for ${esc(r.key)}" /></td>` : '<td></td>';
|
|
63
|
-
const
|
|
83
|
+
const type = r.type && !/^(story|task|bug|sub-?task)$/i.test(r.type) ? ` <span class="issue-type" title="Jira issue type">${esc(r.type)}</span>` : '';
|
|
84
|
+
const issue = (r.url ? `<a href="${esc(r.url)}" target="_blank" rel="noopener" class="issue-key">${esc(r.key)}</a>` : `<span class="issue-key">${esc(r.key)}</span>`) + type;
|
|
64
85
|
const status = r.jira?.status ? `<span class="jira-status ${esc(r.jira.category ?? '')}">${esc(r.jira.status)}</span>` : '<span class="hint">—</span>';
|
|
65
86
|
const check = r.pr?.checks && CHECKS[r.pr.checks] ? ` <span class="checks ${esc(r.pr.checks)}" title="${CHECKS[r.pr.checks][1]}">${CHECKS[r.pr.checks][0]}</span>` : '';
|
|
66
87
|
const pr = r.pr?.url
|
|
67
88
|
? `<a href="${esc(r.pr.url)}" target="_blank" rel="noopener" title="${esc(r.pr.title ?? '')}">#${esc(r.pr.number ?? '?')}</a>${check}${r.aiReview ? `<div class="hint" title="AI review">AI: ${esc(r.aiReview)}</div>` : ''}<div>${listenHtml(`prvoice:${r.agent.id}`, { title: 'Explain the review aloud: the PR, its checks, the AI review, the riskiest changes and what is left', label: 'Explain' })}</div>`
|
|
68
89
|
: '<span class="hint">—</span>';
|
|
69
90
|
if (!r.agent) {
|
|
70
|
-
const by = r.proposal
|
|
71
|
-
return `<tr class="stage-proposed ${ticked.has(r.key) ? 'ticked' : ''}">${box}
|
|
72
|
-
<td>${issue}${
|
|
91
|
+
const by = !r.proposal ? 'assigned to you' : r.proposal.by === 'assistant' ? 'proposed by the assistant' : r.proposal.by === 'jira' ? 'assigned to you' : 'proposed';
|
|
92
|
+
return `<tr class="stage-proposed ${ticked.has(r.key) ? 'ticked' : ''} ${r.action ? `action-${esc(r.action)}` : ''}">${box}${actionCell(r)}
|
|
93
|
+
<td>${issue}${aboutIssue(r)}</td>
|
|
73
94
|
<td>${status}</td>
|
|
74
95
|
<td class="issue-note">${esc(r.note)}</td>
|
|
75
96
|
<td class="hint">—</td>
|
|
@@ -91,8 +112,8 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
91
112
|
const design = d
|
|
92
113
|
? [d.written ? read('designdoc', 'Read', 'Read the design doc here') : '<span class="hint">not yet</span>', d.page && ext('Page', d.page, 'The design page the agent published'), d.google && ext('Doc', d.google, 'Google Doc')].filter(Boolean).join(' · ')
|
|
93
114
|
: '<span class="hint">—</span>';
|
|
94
|
-
return `<tr class="stage-${esc(r.stage)}">${box}
|
|
95
|
-
<td>${issue}${
|
|
115
|
+
return `<tr class="stage-${esc(r.stage)} action-${esc(r.action)}">${box}${actionCell(r)}
|
|
116
|
+
<td>${issue}${aboutIssue(r)}</td>
|
|
96
117
|
<td>${status}</td>
|
|
97
118
|
<td class="issue-note">${esc(r.note)}</td>
|
|
98
119
|
<td class="nowrap">${plan}</td>
|
|
@@ -109,8 +130,9 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
109
130
|
body.innerHTML = '<p class="hint">Loading…</p>';
|
|
110
131
|
return;
|
|
111
132
|
}
|
|
112
|
-
const
|
|
113
|
-
const
|
|
133
|
+
const inGroup = (r, g) => (g === 'all' ? r.group !== 'removed' : r.group === g);
|
|
134
|
+
const count = (g) => data.rows.filter((r) => inGroup(r, g)).length;
|
|
135
|
+
const rows = data.rows.filter((r) => inGroup(r, filter));
|
|
114
136
|
// Ticks only for issues still on the list.
|
|
115
137
|
const fresh = new Set(data.rows.filter((r) => r.group === 'new').map((r) => r.key));
|
|
116
138
|
for (const k of ticked) if (!fresh.has(k)) ticked.delete(k);
|
|
@@ -123,8 +145,12 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
123
145
|
: filter === 'you'
|
|
124
146
|
? 'Nothing is waiting for your review.'
|
|
125
147
|
: filter === 'new'
|
|
126
|
-
? 'No issues waiting to be started. With "Let me pick" on in Assistant, new Jira and Linear issues assigned to you come here instead of getting agents right away (or: agentmgr issues propose).'
|
|
127
|
-
:
|
|
148
|
+
? 'No issues waiting to be started. Open Jira issues assigned to you show here once your Jira site, email and API token are in Settings → Jira. With "Let me pick" on in Assistant, new Jira and Linear issues assigned to you come here instead of getting agents right away (or: agentmgr issues propose).'
|
|
149
|
+
: filter === 'skipped'
|
|
150
|
+
? 'Nothing skipped. Issues you set to Skip wait here, and the assistant leaves them alone.'
|
|
151
|
+
: filter === 'removed'
|
|
152
|
+
? 'Nothing removed. Set an issue back to another action here to bring it back.'
|
|
153
|
+
: 'None here.';
|
|
128
154
|
body.innerHTML = `
|
|
129
155
|
<div class="issues-head">
|
|
130
156
|
<h2>Jira</h2>
|
|
@@ -137,20 +163,38 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
137
163
|
${boxes
|
|
138
164
|
? `<div class="issues-pickbar">
|
|
139
165
|
<button class="primary small" data-issues="start" ${n && !starting ? '' : 'disabled'} title="Start an agent for each ticked issue">${starting ? 'Starting…' : `Start ${n || ''} agent${n === 1 ? '' : 's'}`.replace(' ', ' ')}</button>
|
|
140
|
-
<button class="small" data-issues="
|
|
166
|
+
<button class="small" data-issues="skip" ${n && !starting ? '' : 'disabled'} title="Not now: under Skipped, and not proposed again">Skip</button>
|
|
167
|
+
<button class="small" data-issues="dismiss" ${n && !starting ? '' : 'disabled'} title="Take the ticked issues off the list (under Removed, to bring back); they won't be proposed again">Remove</button>
|
|
141
168
|
<span class="hint">Tick the issues to start agents for; the rest stay here.</span>
|
|
142
169
|
</div>`
|
|
143
170
|
: ''}
|
|
144
171
|
${rows.length
|
|
145
172
|
? `<div class="issues-scroll"><table class="issues">
|
|
146
|
-
<thead><tr>${boxes ? `<th class="pick"><input type="checkbox" data-issue-pick-all ${allTicked ? 'checked' : ''} aria-label="Tick all" title="Tick all" /></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>
|
|
173
|
+
<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>
|
|
147
174
|
<tbody>${rows.map((r) => row(r, boxes)).join('')}</tbody>
|
|
148
175
|
</table></div>`
|
|
149
176
|
: `<p class="hint issues-empty">${esc(empty)}</p>`}
|
|
150
|
-
${data.jira.signedIn || !data.rows.length ? '' : '<p class="hint">Jira status shows for public issues only until you add your Jira site, email and API token in Settings → Jira.</p>'}`;
|
|
177
|
+
${data.jira.signedIn || !data.rows.length ? '' : '<p class="hint">Jira status shows for public issues only, and the issues assigned to you aren\'t listed, until you add your Jira site, email and API token in Settings → Jira.</p>'}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Set your action on issues; assign starts the agents of ones not started yet. */
|
|
181
|
+
async function setAction(keys, action) {
|
|
182
|
+
try {
|
|
183
|
+
const r = await api('POST', '/issues/action', { keys, action: action || null });
|
|
184
|
+
for (const k of r.set) ticked.delete(k);
|
|
185
|
+
const bad = r.failed.map((x) => `${x.key}: ${x.reason}`).join('; ');
|
|
186
|
+
const label = ACTIONS.find(([v]) => v === action)?.[1] ?? 'Cleared';
|
|
187
|
+
const what = r.started.length ? `Started ${r.started.map((x) => `${x.key} (${x.agent.name})`).join(', ')}` : r.set.length ? `${r.set.join(', ')}: ${label}` : 'Nothing changed';
|
|
188
|
+
toast?.(`${what}${bad ? `. Not changed: ${bad}` : ''}`, bad ? 8000 : 3000);
|
|
189
|
+
} catch (err) {
|
|
190
|
+
toast?.(err.message, 6000);
|
|
191
|
+
}
|
|
192
|
+
load();
|
|
151
193
|
}
|
|
152
194
|
|
|
153
195
|
body.addEventListener('change', (e) => {
|
|
196
|
+
const act = e.target.dataset.issueAction;
|
|
197
|
+
if (act) return setAction([act], e.target.value);
|
|
154
198
|
const one = e.target.dataset.issuePick;
|
|
155
199
|
if (one) {
|
|
156
200
|
if (e.target.checked) ticked.add(one);
|
|
@@ -169,7 +213,8 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
169
213
|
starting = true;
|
|
170
214
|
render();
|
|
171
215
|
try {
|
|
172
|
-
|
|
216
|
+
// Assign: starts agents for proposals and for issues assigned to you in Jira alike.
|
|
217
|
+
const r = await api('POST', '/issues/action', { keys, action: 'assign' });
|
|
173
218
|
for (const x of r.started) ticked.delete(x.key);
|
|
174
219
|
const bad = r.failed.map((x) => `${x.key}: ${x.reason}`).join('; ');
|
|
175
220
|
toast?.(`${r.started.length ? `Started ${r.started.length} agent${r.started.length === 1 ? '' : 's'}: ${r.started.map((x) => x.key).join(', ')}` : 'No agents started'}${bad ? `. Not started: ${bad}` : ''}`, bad ? 8000 : 4000);
|
|
@@ -202,18 +247,10 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
202
247
|
}
|
|
203
248
|
const b = e.target.closest('[data-issues]')?.dataset.issues;
|
|
204
249
|
if (b === 'close') return dialog.close();
|
|
205
|
-
if (b === 'refresh') return load();
|
|
250
|
+
if (b === 'refresh') return load({ fresh: true });
|
|
206
251
|
if (b === 'start') return startTicked();
|
|
207
|
-
if (b === 'dismiss')
|
|
208
|
-
|
|
209
|
-
const r = await api('POST', '/issues/dismiss', { keys: [...ticked] });
|
|
210
|
-
ticked.clear();
|
|
211
|
-
toast?.(`${r.dismissed} dismissed`);
|
|
212
|
-
} catch (err) {
|
|
213
|
-
toast?.(err.message, 6000);
|
|
214
|
-
}
|
|
215
|
-
return load();
|
|
216
|
-
}
|
|
252
|
+
if (b === 'dismiss') return setAction([...ticked], 'remove');
|
|
253
|
+
if (b === 'skip') return setAction([...ticked], 'skip');
|
|
217
254
|
if (b === 'copy') {
|
|
218
255
|
try {
|
|
219
256
|
const { markdown } = await api('GET', `/issues?group=${encodeURIComponent(filter)}&format=markdown`);
|
package/public/share.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Print-ready view of one agent document: /share.html#<agent id>/<analysis|design|flow|proposal>
|
|
2
2
|
import { marked } from '/vendor/marked/marked.esm.js';
|
|
3
3
|
import DOMPurify from '/vendor/dompurify/purify.es.mjs';
|
|
4
|
+
import { drawDiagram } from '/diagram.js';
|
|
4
5
|
|
|
5
6
|
const $ = (s) => document.querySelector(s);
|
|
6
7
|
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
@@ -24,10 +25,10 @@ async function main() {
|
|
|
24
25
|
document.title = (d.markdown.match(/^#\s+(.+)$/m)?.[1] ?? `${kind} · ${a.name}`).slice(0, 120);
|
|
25
26
|
if (blocks.length) {
|
|
26
27
|
const mermaid = (await import('/vendor/mermaid/mermaid.esm.min.mjs')).default;
|
|
27
|
-
mermaid.initialize({ startOnLoad: false, securityLevel: 'strict', theme: 'default', htmlLabels: false, flowchart: { htmlLabels: false } });
|
|
28
|
+
mermaid.initialize({ startOnLoad: false, suppressErrorRendering: true, securityLevel: 'strict', theme: 'default', htmlLabels: false, flowchart: { htmlLabels: false } });
|
|
28
29
|
for (const el of document.querySelectorAll('.diagram')) {
|
|
29
30
|
try {
|
|
30
|
-
el.innerHTML = (await mermaid
|
|
31
|
+
el.innerHTML = (await drawDiagram(mermaid, `d${el.dataset.i}`, blocks[Number(el.dataset.i)])).svg;
|
|
31
32
|
} catch {
|
|
32
33
|
el.innerHTML = `<pre>${esc(blocks[Number(el.dataset.i)])}</pre>`;
|
|
33
34
|
}
|
package/public/speak.js
CHANGED
|
@@ -1,9 +1,72 @@
|
|
|
1
1
|
// Listening instead of reading: Explain, the documents and the change walkthrough read aloud with
|
|
2
|
-
// the browser's own speech (
|
|
2
|
+
// the browser's own speech (on-device voices only unless you pick an online one; it works on
|
|
3
|
+
// phones). The clearest voice here is used, never the robotic or novelty ones. Text goes in short
|
|
3
4
|
// pieces, since some browsers stop a long utterance partway. One thing plays at a time.
|
|
4
5
|
|
|
5
6
|
const RATES = [0.85, 1, 1.25, 1.5, 1.75];
|
|
6
7
|
const RATE_KEY = 'agentmgr.speechRate';
|
|
8
|
+
const VOICE_KEY = 'agentmgr.voice';
|
|
9
|
+
|
|
10
|
+
// Voices that sound robotic or are made for fun: macOS's old and Eloquence voices, and its
|
|
11
|
+
// novelty ones. Not used unless chosen by name.
|
|
12
|
+
const ROBOTIC = /^(Albert|Bad News|Bahh|Bells|Boing|Bruce|Bubbles|Cellos|Deranged|Eddy|Flo|Fred|Good News|Grandma|Grandpa|Hysterical|Jester|Junior|Kathy|Organ|Pipe Organ|Princess|Ralph|Reed|Rocko|Sandy|Shelley|Superstar|Trinoids|Vicki|Victoria|Whisper|Wobble|Zarvox)\b/i;
|
|
13
|
+
// Clear, natural voices: the downloadable high-quality ones, Siri's, Edge's neural and Google's.
|
|
14
|
+
const NATURAL = /\b(Premium|Enhanced|Siri|Natural|Neural|Online)\b|^Google /i;
|
|
15
|
+
const CLEAR = /^(Samantha|Alex|Ava|Allison|Susan|Tom|Karen|Daniel|Moira|Tessa|Serena|Zoe|Evan|Nathan|Joelle|Noelle|Aaron|Nicky|Rishi|Veena|Lee)\b/i;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* How good a voice sounds for reading aloud in `lang` ("en-US"); below 0 means don't use it.
|
|
19
|
+
* Online voices (Chrome's Google ones) send the text to their maker, so they count only when
|
|
20
|
+
* `online` (you pick one by name).
|
|
21
|
+
*/
|
|
22
|
+
export function voiceScore(v, lang = 'en-US', { online = false } = {}) {
|
|
23
|
+
const want = String(lang).toLowerCase();
|
|
24
|
+
const have = String(v?.lang ?? '').toLowerCase().replace('_', '-');
|
|
25
|
+
if (!have.startsWith(want.slice(0, 2)) || ROBOTIC.test(v.name ?? '')) return -1;
|
|
26
|
+
if (v.localService === false && !online) return -1;
|
|
27
|
+
return (NATURAL.test(v.name) ? 6 : 0) + (CLEAR.test(v.name) ? 3 : 0) + (have === want ? 2 : 0) + (v.default ? 1 : 0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The voices worth using for `lang`, best first. */
|
|
31
|
+
export function rankVoices(voices = [], lang = 'en-US', opts = {}) {
|
|
32
|
+
return voices
|
|
33
|
+
.map((v) => ({ v, s: voiceScore(v, lang, opts) }))
|
|
34
|
+
.filter((x) => x.s >= 0)
|
|
35
|
+
.sort((a, b) => b.s - a.s || String(a.v.name).localeCompare(String(b.v.name)))
|
|
36
|
+
.map((x) => x.v);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const lang = () => (typeof navigator !== 'undefined' && navigator.language) || 'en-US';
|
|
40
|
+
|
|
41
|
+
/** This browser's good voices for the page's language, best first (`online`: those too). */
|
|
42
|
+
export function goodVoices(opts = {}) {
|
|
43
|
+
return canSpeak() ? rankVoices(speechSynthesis.getVoices(), lang(), opts) : [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The voice you picked (by name), or null for "the best one here". */
|
|
47
|
+
export function chosenVoice() {
|
|
48
|
+
try {
|
|
49
|
+
return localStorage.getItem(VOICE_KEY) || null;
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function setVoice(name) {
|
|
56
|
+
try {
|
|
57
|
+
if (name) localStorage.setItem(VOICE_KEY, name);
|
|
58
|
+
else localStorage.removeItem(VOICE_KEY);
|
|
59
|
+
} catch {}
|
|
60
|
+
notify();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The voice to read with when none is given: yours, else the best one here. */
|
|
64
|
+
export function preferredVoice() {
|
|
65
|
+
if (!canSpeak()) return null;
|
|
66
|
+
const name = chosenVoice();
|
|
67
|
+
const all = speechSynthesis.getVoices();
|
|
68
|
+
return (name && all.find((v) => v.name === name)) || goodVoices()[0] || null;
|
|
69
|
+
}
|
|
7
70
|
|
|
8
71
|
export const canSpeak = () => typeof window !== 'undefined' && 'speechSynthesis' in window && 'SpeechSynthesisUtterance' in window;
|
|
9
72
|
|
|
@@ -60,7 +123,11 @@ function playNext() {
|
|
|
60
123
|
const part = s.parts[s.i];
|
|
61
124
|
const u = new SpeechSynthesisUtterance(part.text);
|
|
62
125
|
u.rate = rate();
|
|
63
|
-
|
|
126
|
+
const voice = part.voice ?? preferredVoice();
|
|
127
|
+
if (voice) {
|
|
128
|
+
u.voice = voice;
|
|
129
|
+
u.lang = voice.lang;
|
|
130
|
+
}
|
|
64
131
|
u.onstart = () => part.onStart?.();
|
|
65
132
|
u.onend = () => {
|
|
66
133
|
if (session !== s || s.paused) return;
|
package/public/standup.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// When an agent needs you it stops on it with its questions beside it, answered by tap (the
|
|
3
3
|
// inbox's own cards) or, when turned on, by voice: what you say is read back and sent on "send".
|
|
4
4
|
|
|
5
|
-
import { canSpeak, cycleRate, pause, play, rateLabel, resume, stop, now as speaking } from '/speak.js';
|
|
5
|
+
import { canSpeak, chosenVoice, cycleRate, goodVoices, voiceScore, pause, play, rateLabel, resume, setVoice, speakable, stop, now as speaking } from '/speak.js';
|
|
6
6
|
import { choiceFor } from '/voice.js';
|
|
7
7
|
|
|
8
8
|
const VOICE_KEY = 'agentmgr.standupVoice';
|
|
9
9
|
const PLAY_ID = 'standup';
|
|
10
10
|
const Recognition = typeof window !== 'undefined' ? window.SpeechRecognition || window.webkitSpeechRecognition : null;
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
const
|
|
12
|
+
// Agents take turns among this many of the best voices (fewer when fewer sound good).
|
|
13
|
+
const MIXED = 4;
|
|
14
14
|
const hash = (s) => [...String(s)].reduce((h, c) => (h * 31 + c.charCodeAt(0)) >>> 0, 7);
|
|
15
15
|
export function initStandup({ api, $, esc, agents, needsFor, needCard, onNeed, toast, openAgent }) {
|
|
16
16
|
const dialog = $('#standup-dialog');
|
|
@@ -26,18 +26,29 @@ export function initStandup({ api, $, esc, agents, needsFor, needCard, onNeed, t
|
|
|
26
26
|
voiceOn = localStorage.getItem(VOICE_KEY) === '1';
|
|
27
27
|
} catch {}
|
|
28
28
|
|
|
29
|
-
// Each agent keeps one
|
|
29
|
+
// Each agent keeps one of the few best voices here, unless you picked one voice for all; robotic
|
|
30
|
+
// and novelty voices are never used. The intro uses the best one (or yours).
|
|
30
31
|
let voices = [];
|
|
32
|
+
let pickable = [];
|
|
31
33
|
const loadVoices = () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
voices = goodVoices();
|
|
35
|
+
pickable = goodVoices({ online: true }).slice(0, 15);
|
|
36
|
+
if (dialog.open) render();
|
|
35
37
|
};
|
|
36
38
|
if (canSpeak()) {
|
|
37
39
|
loadVoices();
|
|
38
40
|
speechSynthesis.addEventListener?.('voiceschanged', loadVoices);
|
|
39
41
|
}
|
|
40
|
-
const voiceFor = (id) =>
|
|
42
|
+
const voiceFor = (id) => {
|
|
43
|
+
if (chosenVoice()) return null;
|
|
44
|
+
// Only voices about as good as the best: a mix that includes a poor one sounds worse than one voice.
|
|
45
|
+
const lang = navigator.language || 'en-US';
|
|
46
|
+
const top = voices[0] ? voiceScore(voices[0], lang) : 0;
|
|
47
|
+
const best = voices.slice(0, MIXED).filter((v) => voiceScore(v, lang) >= top - 2);
|
|
48
|
+
return best.length > 1 ? best[hash(id) % best.length] : null;
|
|
49
|
+
};
|
|
50
|
+
// Names as they'd be said: "WEB-41" → "WEB 41", "fix-login-timeout" → "fix login timeout".
|
|
51
|
+
const sayName = (name) => String(name ?? '').replace(/[-_/]+/g, ' ');
|
|
41
52
|
|
|
42
53
|
const items = () => latest?.items ?? [];
|
|
43
54
|
const current = () => items()[idx] ?? null;
|
|
@@ -106,7 +117,7 @@ export function initStandup({ api, $, esc, agents, needsFor, needCard, onNeed, t
|
|
|
106
117
|
return play(PLAY_ID, ["That's everything."], {});
|
|
107
118
|
}
|
|
108
119
|
const it = current();
|
|
109
|
-
const text = it ? `${it.name}. ${it.text}` : latest?.intro ?? '';
|
|
120
|
+
const text = speakable(it ? `${sayName(it.name)}. ${it.text}` : latest?.intro ?? '');
|
|
110
121
|
state = 'playing';
|
|
111
122
|
render();
|
|
112
123
|
const started = play(PLAY_ID, [{ text, voice: it ? voiceFor(it.agentId) : null }], {
|
|
@@ -268,6 +279,10 @@ export function initStandup({ api, $, esc, agents, needsFor, needCard, onNeed, t
|
|
|
268
279
|
<button class="primary" data-su="play" title="${playingNow ? 'Pause' : 'Play'}" ${canSpeak() ? '' : 'disabled'}>${playingNow ? '⏸' : '▶'}</button>
|
|
269
280
|
<button data-su="next" title="Next" ${idx >= list.length ? 'disabled' : ''}>⏭</button>
|
|
270
281
|
<button class="small" data-su="rate" title="Speed">${esc(rateLabel())}</button>
|
|
282
|
+
${pickable.length ? `<select class="small standup-voice-pick" data-su-voice title="Voice: a mix of the best voices here, or one for everything read aloud" aria-label="Voice">
|
|
283
|
+
<option value="" ${chosenVoice() ? '' : 'selected'}>Best voices</option>
|
|
284
|
+
${pickable.map((v) => `<option value="${esc(v.name)}" ${chosenVoice() === v.name ? 'selected' : ''}>${esc(v.name)}${v.localService === false ? ' · online' : ''}</option>`).join('')}
|
|
285
|
+
</select>` : ''}
|
|
271
286
|
<span class="spacer"></span>
|
|
272
287
|
${Recognition ? `<label class="check" title="Answer agents by speaking. Your browser may send the audio to its maker to turn it into text."><input type="checkbox" data-su="voice" ${voiceOn ? 'checked' : ''}> Answer by voice</label>` : ''}
|
|
273
288
|
</div>
|
|
@@ -309,6 +324,12 @@ export function initStandup({ api, $, esc, agents, needsFor, needCard, onNeed, t
|
|
|
309
324
|
}
|
|
310
325
|
});
|
|
311
326
|
body.addEventListener('change', async (e) => {
|
|
327
|
+
if (e.target.dataset.suVoice !== undefined) {
|
|
328
|
+
setVoice(e.target.value || null);
|
|
329
|
+
// Hear it right away.
|
|
330
|
+
if (state !== 'playing') play(PLAY_ID, [`This is how the standup sounds.`], {});
|
|
331
|
+
return render();
|
|
332
|
+
}
|
|
312
333
|
if (e.target.dataset.su === 'voice') {
|
|
313
334
|
voiceOn = e.target.checked;
|
|
314
335
|
try {
|
package/public/style.css
CHANGED
|
@@ -1067,6 +1067,8 @@ kbd { display: inline-block; min-width: 1.6em; padding: 1px 5px; border: 1px sol
|
|
|
1067
1067
|
.standup-dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 16px; }
|
|
1068
1068
|
.standup-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
|
|
1069
1069
|
.standup-top .spacer, .standup-controls .spacer { flex: 1; }
|
|
1070
|
+
.standup-controls .standup-voice-pick { width: auto; max-width: 170px; flex: none; font-size: 12px; padding: 3px 6px; }
|
|
1071
|
+
.standup-controls label.check input[type="checkbox"] { width: auto; flex: none; }
|
|
1070
1072
|
.standup-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
|
|
1071
1073
|
.standup-chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); cursor: pointer; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1072
1074
|
.standup-chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
|
|
@@ -1144,6 +1146,14 @@ table.issues td { padding: 7px 10px; border-bottom: 1px solid var(--border); ver
|
|
|
1144
1146
|
table.issues tr:last-child td { border-bottom: 0; }
|
|
1145
1147
|
table.issues .issue-key { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
|
|
1146
1148
|
table.issues .issue-title { max-width: 360px; color: var(--text); }
|
|
1149
|
+
table.issues .issue-synopsis { max-width: 420px; margin-top: 2px; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
1150
|
+
table.issues .issue-action { width: 1%; white-space: nowrap; }
|
|
1151
|
+
table.issues .issue-type { font-size: 10px; font-weight: 600; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); white-space: nowrap; }
|
|
1152
|
+
table.issues .issue-action select { width: auto; font-size: 12px; padding: 2px 4px; }
|
|
1153
|
+
table.issues select.act-skip { color: var(--yellow); }
|
|
1154
|
+
table.issues select.act-done { color: var(--green); }
|
|
1155
|
+
table.issues select.act-remove { color: var(--red); }
|
|
1156
|
+
table.issues tr.action-skip td:not(.issue-action), table.issues tr.action-remove td:not(.issue-action) { opacity: 0.65; }
|
|
1147
1157
|
table.issues tr td:first-child { border-left: 3px solid transparent; }
|
|
1148
1158
|
table.issues tr.stage-review td:first-child, table.issues tr.stage-approved td:first-child { border-left-color: var(--green); }
|
|
1149
1159
|
table.issues tr.stage-needs td:first-child, table.issues tr.stage-blocked td:first-child { border-left-color: var(--red); }
|
|
@@ -1163,7 +1173,7 @@ table.issues .dot.idle { background: var(--muted); }
|
|
|
1163
1173
|
@media (max-width: 640px) {
|
|
1164
1174
|
.issues-dialog { width: calc(100% - 32px); padding: 12px; }
|
|
1165
1175
|
table.issues .col-active { display: none; }
|
|
1166
|
-
table.issues .issue-title { max-width: 200px; }
|
|
1176
|
+
table.issues .issue-title, table.issues .issue-synopsis { max-width: 200px; }
|
|
1167
1177
|
}
|
|
1168
1178
|
|
|
1169
1179
|
/* ---------- Designs: agents' design docs */
|
package/src/assistant.js
CHANGED
|
@@ -63,14 +63,14 @@ export function assistantPrompt(s, dir, bin = `node ${BIN}`) {
|
|
|
63
63
|
const pick =
|
|
64
64
|
`Don't start agents for new issues: the person picks which ones get agents. Propose each one you haven't handled instead: ${am} issues propose @<project> "<the issue link> <a one-line summary of what to do>". ` +
|
|
65
65
|
`It is listed for them under Jira, Not started, and an agent starts only if they tick it. Record it as "proposed". ` +
|
|
66
|
-
`A proposal for an issue they
|
|
66
|
+
`A proposal for an issue they skipped, marked done or removed, or one that already has an agent, is refused: record it as skipped and don't propose it again.`;
|
|
67
67
|
if (s.sources.includes('jira')) {
|
|
68
68
|
how.push(
|
|
69
69
|
`Jira, new assignments: with your Jira / Atlassian tools, find unresolved issues assigned to the person that were created or assigned since your last check (on the first check, the last 2 days). ` +
|
|
70
70
|
(s.pickIssues
|
|
71
71
|
? pick
|
|
72
72
|
: `For each one you haven't handled, start an agent: ${am} add @<project> "<the issue link> <a one-line summary of what to do>". ` +
|
|
73
|
-
`Start the request with the issue link: the agent is then named after the issue key, and the daemon refuses a second agent for the same key.`),
|
|
73
|
+
`Start the request with the issue link: the agent is then named after the issue key, and the daemon refuses a second agent for the same key, or one for an issue the person skipped, marked done or removed under Jira (record those as skipped).`),
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
if (s.sources.includes('linear')) {
|
package/src/cli.js
CHANGED
|
@@ -674,16 +674,17 @@ export async function main(argv) {
|
|
|
674
674
|
.action(async (opts) => {
|
|
675
675
|
await daemon();
|
|
676
676
|
const v = await api('GET', '/issues');
|
|
677
|
-
const rows = opts.all ? v.rows : v.rows.filter((r) => r.group === 'you' || r.group === 'new');
|
|
677
|
+
const rows = opts.all ? v.rows.filter((r) => r.group !== 'removed') : v.rows.filter((r) => r.group === 'you' || r.group === 'new');
|
|
678
678
|
if (opts.json) return console.log(JSON.stringify({ ...v, rows }, null, 2));
|
|
679
679
|
if (opts.markdown) return console.log(issuesMarkdown(rows));
|
|
680
680
|
if (!rows.length) return console.log(dim(opts.all ? 'No agents work on Jira or Linear issues.' : 'Nothing to start or review. --all shows the rest.'));
|
|
681
681
|
for (const r of rows) {
|
|
682
682
|
const pr = r.pr ? ` PR #${r.pr.number ?? '?'}` : '';
|
|
683
683
|
console.log(`${bold(r.key.padEnd(10))} ${r.jira?.status ? dim(`[${r.jira.status}] `) : ''}${truncate(r.title ?? '', 60)}`);
|
|
684
|
+
if (r.synopsis) console.log(dim(` ${truncate(r.synopsis, 110)}`));
|
|
684
685
|
console.log(` ${r.group === 'you' || r.group === 'new' ? yellow(r.note) : r.note}${pr} ${dim(r.agent ? `agent ${r.agent.name} (${r.agent.id})` : `start: agentmgr issues start ${r.key}`)}`);
|
|
685
686
|
}
|
|
686
|
-
const others = v.rows.length - rows.length;
|
|
687
|
+
const others = v.rows.filter((r) => r.group !== 'removed').length - rows.length;
|
|
687
688
|
if (others) console.log(dim(`\n${others} more with agents still on them or finished: --all`));
|
|
688
689
|
if (!v.jira.signedIn) console.log(dim('Jira status needs your site, email and API token: Settings → Jira.'));
|
|
689
690
|
});
|
|
@@ -717,6 +718,18 @@ export async function main(argv) {
|
|
|
717
718
|
const r = await api('POST', '/issues/dismiss', { keys });
|
|
718
719
|
console.log(`${r.dismissed} dismissed`);
|
|
719
720
|
});
|
|
721
|
+
issuesCmd
|
|
722
|
+
.command('set')
|
|
723
|
+
.description('Your action on issues, kept across restarts and updates: assign (start an agent), skip, done, remove, or clear')
|
|
724
|
+
.argument('<action>', 'assign | skip | done | remove | clear')
|
|
725
|
+
.argument('<keys...>', 'issue keys, e.g. OPS-7 OPS-9')
|
|
726
|
+
.action(async (action, keys) => {
|
|
727
|
+
await daemon();
|
|
728
|
+
const r = await api('POST', '/issues/action', { keys, action: action === 'clear' ? null : action });
|
|
729
|
+
for (const x of r.started) console.log(`${green('✓')} ${bold(x.key)} → agent ${x.agent.name} (${x.agent.id})`);
|
|
730
|
+
if (r.set.length) console.log(`${green('✓')} ${r.set.join(', ')}: ${action === 'clear' ? 'cleared' : action}`);
|
|
731
|
+
for (const x of r.failed) console.log(`${red('!')} ${bold(x.key)}: ${x.reason}`);
|
|
732
|
+
});
|
|
720
733
|
|
|
721
734
|
program
|
|
722
735
|
.command('designs')
|
package/src/issues.js
CHANGED
|
@@ -9,6 +9,7 @@ import { needsOf } from './standup.js';
|
|
|
9
9
|
|
|
10
10
|
const ISSUE_KEY = /^[A-Z][A-Z0-9_]+-\d+$/;
|
|
11
11
|
const MAX_PROPOSED = 200;
|
|
12
|
+
const MAX_ACTIONS = 1000;
|
|
12
13
|
const err = (status, message) => Object.assign(new Error(message), { status });
|
|
13
14
|
const NEEDS = new Set(['prompt', 'waiting', 'plan', 'question']);
|
|
14
15
|
|
|
@@ -16,6 +17,7 @@ const NEEDS = new Set(['prompt', 'waiting', 'plan', 'question']);
|
|
|
16
17
|
// In the order they're listed.
|
|
17
18
|
export const GROUPS = {
|
|
18
19
|
proposed: 'new',
|
|
20
|
+
assigned: 'new',
|
|
19
21
|
needs: 'you',
|
|
20
22
|
review: 'you',
|
|
21
23
|
blocked: 'you',
|
|
@@ -26,6 +28,16 @@ export const GROUPS = {
|
|
|
26
28
|
closed: 'done',
|
|
27
29
|
};
|
|
28
30
|
|
|
31
|
+
/**
|
|
32
|
+
* What you decided for an issue, kept in state.json so a restart or an update doesn't ask again:
|
|
33
|
+
* assign (an agent works on it), skip (not now), done (handled, by you or elsewhere), remove (off
|
|
34
|
+
* the list). Any of them can be changed later; skipped, done and removed issues aren't proposed or
|
|
35
|
+
* started by the assistant.
|
|
36
|
+
*/
|
|
37
|
+
export const ACTIONS = ['assign', 'skip', 'done', 'remove'];
|
|
38
|
+
const SET_ASIDE = { skip: 'skipped', done: 'done', remove: 'removed' };
|
|
39
|
+
const ACTION_NOTE = { skip: 'Skipped by you', done: 'Marked done by you', remove: 'Removed by you' };
|
|
40
|
+
|
|
29
41
|
/** The issue an agent works on: { key, url }, from the link its request starts with or one in it. */
|
|
30
42
|
export function issueOf(v) {
|
|
31
43
|
const lead = leadingJiraKey(v.intent);
|
|
@@ -90,20 +102,23 @@ function designOf(v, read) {
|
|
|
90
102
|
* The summary's rows from agent views, those waiting for you first.
|
|
91
103
|
* `read(agentId, name)` gives one of the agent's documents ('plan'), or null.
|
|
92
104
|
*/
|
|
93
|
-
export function issueRows(views, jira = new Map(), read = () => null, proposed = []) {
|
|
105
|
+
export function issueRows(views, jira = new Map(), read = () => null, proposed = [], actions = {}, assigned = []) {
|
|
94
106
|
const rank = Object.fromEntries(Object.keys(GROUPS).map((k, i) => [k, i]));
|
|
95
107
|
const rows = [];
|
|
96
108
|
// Issues proposed for agents, not started yet: they wait for you to tick them.
|
|
97
109
|
for (const p of proposed) {
|
|
98
110
|
const j = jira.get(p.key) ?? null;
|
|
111
|
+
const action = actions[p.key]?.action ?? (p.status === 'dismissed' ? 'remove' : null);
|
|
99
112
|
rows.push({
|
|
100
113
|
key: p.key,
|
|
101
114
|
url: p.url,
|
|
102
115
|
title: j?.summary ?? p.title,
|
|
116
|
+
synopsis: synopsisFor(j, p.title, null, j?.summary ?? p.title),
|
|
103
117
|
jira: j ? { status: j.status, category: j.category } : null,
|
|
118
|
+
action,
|
|
104
119
|
stage: 'proposed',
|
|
105
|
-
group: 'new',
|
|
106
|
-
note: `Not started${p.project ? ` (@${p.project})` : ''}: tick it to start an agent`,
|
|
120
|
+
group: SET_ASIDE[action] ?? 'new',
|
|
121
|
+
note: ACTION_NOTE[action] ?? `Not started${p.project ? ` (@${p.project})` : ''}: tick it to start an agent`,
|
|
107
122
|
agent: null,
|
|
108
123
|
proposal: { project: p.project ?? null, repo: p.repo ?? null, by: p.by ?? null, intent: p.intent },
|
|
109
124
|
pr: null,
|
|
@@ -117,27 +132,69 @@ export function issueRows(views, jira = new Map(), read = () => null, proposed =
|
|
|
117
132
|
if (v.kind === 'assistant') continue;
|
|
118
133
|
const issue = issueOf(v);
|
|
119
134
|
if (!issue) continue;
|
|
120
|
-
const { stage, note, pr } = stageOf(v);
|
|
135
|
+
const { stage, note: where, pr } = stageOf(v);
|
|
121
136
|
const j = jira.get(issue.key) ?? null;
|
|
137
|
+
const action = actions[issue.key]?.action ?? 'assign';
|
|
138
|
+
const note = ACTION_NOTE[action] ? `${ACTION_NOTE[action]} (${where.charAt(0).toLowerCase()}${where.slice(1)})` : where;
|
|
139
|
+
const design = designOf(v, read);
|
|
122
140
|
rows.push({
|
|
123
141
|
key: issue.key,
|
|
124
142
|
url: issue.url,
|
|
125
143
|
title: j?.summary ?? issue.title,
|
|
144
|
+
synopsis: synopsisFor(j, wordsAfterLink(v.intent), design?.summary, j?.summary ?? issue.title),
|
|
126
145
|
jira: j ? { status: j.status, category: j.category } : null,
|
|
146
|
+
action,
|
|
127
147
|
stage,
|
|
128
|
-
group: GROUPS[stage],
|
|
148
|
+
group: SET_ASIDE[action] ?? GROUPS[stage],
|
|
129
149
|
note: note.length > 200 ? `${note.slice(0, 199)}…` : note,
|
|
130
150
|
agent: { id: v.id, name: v.name, project: v.projectInfo?.name ?? null, running: Boolean(v.runtime?.running), busy: Boolean(v.runtime?.busy), from: v.startedBy ? 'assistant' : v.trigger?.source ?? null },
|
|
131
151
|
pr: pr ? { url: pr.url, number: pr.number ?? null, title: pr.title ?? null, state: pr.state, checks: pr.checks?.state ?? null, review: pr.review ?? null } : null,
|
|
132
152
|
aiReview: v.aiReview?.verdict ?? null,
|
|
133
153
|
plan: planOf(v, read),
|
|
134
|
-
design
|
|
154
|
+
design,
|
|
135
155
|
updatedAt: v.activeAt ?? v.createdAt ?? null,
|
|
136
156
|
});
|
|
137
157
|
}
|
|
158
|
+
// Open issues assigned to you in Jira (epics too) that no agent or proposal covers yet.
|
|
159
|
+
const listed = new Set(rows.map((r) => r.key));
|
|
160
|
+
for (const i of assigned) {
|
|
161
|
+
if (listed.has(i.key)) continue;
|
|
162
|
+
listed.add(i.key);
|
|
163
|
+
const action = actions[i.key]?.action ?? null;
|
|
164
|
+
rows.push({
|
|
165
|
+
key: i.key,
|
|
166
|
+
url: i.url,
|
|
167
|
+
title: i.summary,
|
|
168
|
+
synopsis: i.synopsis ?? null,
|
|
169
|
+
type: i.type ?? null,
|
|
170
|
+
jira: { status: i.status, category: i.category },
|
|
171
|
+
action,
|
|
172
|
+
stage: 'assigned',
|
|
173
|
+
group: SET_ASIDE[action] ?? 'new',
|
|
174
|
+
note: ACTION_NOTE[action] ?? 'Assigned to you in Jira; no agent yet',
|
|
175
|
+
agent: null,
|
|
176
|
+
proposal: null,
|
|
177
|
+
pr: null,
|
|
178
|
+
aiReview: null,
|
|
179
|
+
plan: null,
|
|
180
|
+
design: null,
|
|
181
|
+
updatedAt: i.updated,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
138
184
|
return rows.sort((a, b) => rank[a.stage] - rank[b.stage] || String(b.updatedAt ?? '').localeCompare(String(a.updatedAt ?? '')));
|
|
139
185
|
}
|
|
140
186
|
|
|
187
|
+
/**
|
|
188
|
+
* What the issue is about in a sentence or two: from its Jira description, else the agent's
|
|
189
|
+
* design doc summary, else the words the request had after the link (when they say more than
|
|
190
|
+
* the title).
|
|
191
|
+
*/
|
|
192
|
+
function synopsisFor(j, words, designSummary, title) {
|
|
193
|
+
if (j?.synopsis) return j.synopsis;
|
|
194
|
+
if (designSummary) return designSummary.length > 280 ? `${designSummary.slice(0, 279)}…` : designSummary;
|
|
195
|
+
return words && words !== title ? words : null;
|
|
196
|
+
}
|
|
197
|
+
|
|
141
198
|
const REVIEW = { writing: 'being written', review: 'waiting for your approval', approved: 'approved', changes: 'changes asked' };
|
|
142
199
|
|
|
143
200
|
/** A plan in a few words: "3/5 steps, approved". */
|
|
@@ -180,9 +237,82 @@ export class ProposedIssues {
|
|
|
180
237
|
return (this.store.data.proposedIssues ??= []);
|
|
181
238
|
}
|
|
182
239
|
|
|
240
|
+
/** Your action per issue key: { action, at }. */
|
|
241
|
+
get actions() {
|
|
242
|
+
return (this.store.data.issueActions ??= {});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Skip, done or remove when you set one; dismissed before actions existed counts as remove. */
|
|
246
|
+
setAside(key) {
|
|
247
|
+
const a = this.actions[key]?.action ?? (this.all.find((p) => p.key === key)?.status === 'dismissed' ? 'remove' : null);
|
|
248
|
+
return SET_ASIDE[a] ? a : null;
|
|
249
|
+
}
|
|
250
|
+
|
|
183
251
|
/** The ones waiting for you, without those an agent has taken up meanwhile. */
|
|
184
252
|
waiting() {
|
|
185
|
-
return this.all.filter((p) => p.status === 'waiting' && !this.agentFor(p.key));
|
|
253
|
+
return this.all.filter((p) => p.status === 'waiting' && !this.setAside(p.key) && !this.agentFor(p.key));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Every proposal no agent works on: waiting, skipped, done or removed (for the table). */
|
|
257
|
+
listed() {
|
|
258
|
+
return this.all.filter((p) => p.status !== 'started' && !this.agentFor(p.key));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The assistant doesn't start agents for issues you skipped, marked done or removed. */
|
|
262
|
+
refuseSetAside(intents = []) {
|
|
263
|
+
for (const text of intents) {
|
|
264
|
+
const key = leadingJiraKey(text);
|
|
265
|
+
const a = key && this.setAside(key);
|
|
266
|
+
if (a) throw err(409, `${key}: ${ACTION_NOTE[a].toLowerCase()}; no agent is started for it unless they change that under Jira`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Set your action on issues (null clears it). Assign starts an agent from the proposal when none
|
|
272
|
+
* works on the issue yet. Returns { set: [keys], started: [{ key, agent }], failed: [{ key, reason }] }.
|
|
273
|
+
*/
|
|
274
|
+
setAction(keys = [], action = null) {
|
|
275
|
+
if (action !== null && !ACTIONS.includes(action)) throw err(400, `The action is one of ${ACTIONS.join(', ')}, or none to clear it`);
|
|
276
|
+
const set = [];
|
|
277
|
+
const started = [];
|
|
278
|
+
const failed = [];
|
|
279
|
+
for (const key of new Set(keys)) {
|
|
280
|
+
let p = this.all.find((x) => x.key === key);
|
|
281
|
+
let agent = this.agentFor(key);
|
|
282
|
+
const mine = !p && !agent ? (this.manager.assignedNow ?? []).find((i) => i.key === key) : null;
|
|
283
|
+
if (!p && !agent && !mine) {
|
|
284
|
+
failed.push({ key, reason: 'not on the list' });
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
// An issue assigned to you in Jira: assigning it makes the request from its link and summary.
|
|
288
|
+
if (action === 'assign' && mine) {
|
|
289
|
+
p = { key, url: mine.url, title: mine.summary, intent: `${mine.url} ${mine.summary ?? ''}`.trim().slice(0, 4000), project: null, repo: null, by: 'jira', status: 'waiting', at: new Date().toISOString() };
|
|
290
|
+
this.all.push(p);
|
|
291
|
+
}
|
|
292
|
+
if (action === 'assign' && !agent) {
|
|
293
|
+
p.status = 'waiting';
|
|
294
|
+
delete this.actions[key];
|
|
295
|
+
const r = this.start([key]);
|
|
296
|
+
if (r.failed.length) {
|
|
297
|
+
failed.push(...r.failed);
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
started.push(...r.started);
|
|
301
|
+
agent = r.started[0].agent;
|
|
302
|
+
}
|
|
303
|
+
// Assign is what an agent on it means anyway; only the others are kept.
|
|
304
|
+
if (SET_ASIDE[action]) this.actions[key] = { action, at: new Date().toISOString() };
|
|
305
|
+
else delete this.actions[key];
|
|
306
|
+
if (p?.status === 'dismissed') p.status = 'waiting';
|
|
307
|
+
set.push(key);
|
|
308
|
+
}
|
|
309
|
+
// Old decisions go first when the list grows long.
|
|
310
|
+
const keys_ = Object.keys(this.actions);
|
|
311
|
+
if (keys_.length > MAX_ACTIONS) {
|
|
312
|
+
for (const k of keys_.sort((a, b) => this.actions[a].at.localeCompare(this.actions[b].at)).slice(0, keys_.length - MAX_ACTIONS)) delete this.actions[k];
|
|
313
|
+
}
|
|
314
|
+
this.store.save();
|
|
315
|
+
return { set, started, failed };
|
|
186
316
|
}
|
|
187
317
|
|
|
188
318
|
agentFor(key) {
|
|
@@ -198,7 +328,8 @@ export class ProposedIssues {
|
|
|
198
328
|
const agent = this.agentFor(key);
|
|
199
329
|
if (agent) throw err(409, `An agent for ${key} already exists: ${agent.name} (${agent.id})`);
|
|
200
330
|
const prev = this.all.find((p) => p.key === key);
|
|
201
|
-
|
|
331
|
+
const aside = this.setAside(key);
|
|
332
|
+
if (aside) throw err(409, `${key}: ${ACTION_NOTE[aside].toLowerCase()}; not proposed again`);
|
|
202
333
|
if (prev?.status === 'started') throw err(409, `${key} was started already`);
|
|
203
334
|
project = project ? String(project).trim().replace(/^@/, '') || null : null;
|
|
204
335
|
if (project && !this.manager.resolveProject(project)) throw err(400, `No project @${project}; see agentmgr project ls`);
|
|
@@ -255,18 +386,8 @@ export class ProposedIssues {
|
|
|
255
386
|
return { started, failed };
|
|
256
387
|
}
|
|
257
388
|
|
|
258
|
-
/** Not for an agent: off the list, and not proposed again. */
|
|
389
|
+
/** Not for an agent: off the list, and not proposed again (the remove action). */
|
|
259
390
|
dismiss(keys = []) {
|
|
260
|
-
|
|
261
|
-
let n = 0;
|
|
262
|
-
for (const p of this.all) {
|
|
263
|
-
if (want.has(p.key) && p.status === 'waiting') {
|
|
264
|
-
p.status = 'dismissed';
|
|
265
|
-
p.dismissedAt = new Date().toISOString();
|
|
266
|
-
n++;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
this.store.save();
|
|
270
|
-
return { dismissed: n };
|
|
391
|
+
return { dismissed: this.setAction(keys, 'remove').set.length };
|
|
271
392
|
}
|
|
272
393
|
}
|
package/src/jira.js
CHANGED
|
@@ -72,6 +72,78 @@ export function wordsAfterLink(text) {
|
|
|
72
72
|
return rest.replace(/^[-:–—,\s]+/, '').split('\n')[0].trim().slice(0, 200) || null;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// Statuses that mean the work is over, whatever category a workflow puts them in.
|
|
76
|
+
const FINISHED = /^(closed|done|resolved|integrated|cancell?ed|won'?t (do|fix)|duplicate|rejected)$/i;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Open issues assigned to you on your Jira site (epics too): [{ key, url, summary, status,
|
|
80
|
+
* category, type, synopsis, updated }]. Needs the site, email and API token from Settings → Jira;
|
|
81
|
+
* null without them or when Jira can't be reached. Closed and integrated ones are left out.
|
|
82
|
+
*/
|
|
83
|
+
export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, timeoutMs = 10_000, max = 100 } = {}) {
|
|
84
|
+
if (!jira.site || !jira.email || !jira.token) return null;
|
|
85
|
+
const headers = { accept: 'application/json', 'content-type': 'application/json', authorization: `Basic ${Buffer.from(`${jira.email}:${jira.token}`).toString('base64')}` };
|
|
86
|
+
const body = JSON.stringify({ jql: 'assignee = currentUser() AND statusCategory != Done ORDER BY updated DESC', fields: ['summary', 'status', 'issuetype', 'description', 'updated'], maxResults: max });
|
|
87
|
+
try {
|
|
88
|
+
const res = await fetchImpl(`${jira.site}/rest/api/3/search/jql`, { method: 'POST', headers, body, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });
|
|
89
|
+
if (!res.ok) return null;
|
|
90
|
+
const out = [];
|
|
91
|
+
for (const i of (await res.json())?.issues ?? []) {
|
|
92
|
+
const f = i?.fields ?? {};
|
|
93
|
+
const status = typeof f.status?.name === 'string' ? f.status.name.slice(0, 60) : null;
|
|
94
|
+
if (typeof i.key !== 'string' || !/^[A-Z][A-Z0-9_]+-\d+$/.test(i.key) || (status && FINISHED.test(status))) continue;
|
|
95
|
+
const synopsis = synopsisOf(f.description);
|
|
96
|
+
out.push({
|
|
97
|
+
key: i.key,
|
|
98
|
+
url: `${jira.site}/browse/${i.key}`,
|
|
99
|
+
summary: typeof f.summary === 'string' ? f.summary.trim().slice(0, 300) : null,
|
|
100
|
+
status,
|
|
101
|
+
category: typeof f.status?.statusCategory?.key === 'string' ? f.status.statusCategory.key : null,
|
|
102
|
+
type: typeof f.issuetype?.name === 'string' ? f.issuetype.name.slice(0, 40) : null,
|
|
103
|
+
...(synopsis ? { synopsis } : {}),
|
|
104
|
+
updated: typeof f.updated === 'string' ? f.updated : null,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
} catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The text of a Jira description: Atlassian document format (API v3), or plain text. */
|
|
114
|
+
export function descriptionText(d) {
|
|
115
|
+
if (typeof d === 'string') return d;
|
|
116
|
+
const out = [];
|
|
117
|
+
const walk = (n) => {
|
|
118
|
+
if (!n || typeof n !== 'object') return;
|
|
119
|
+
if (n.type === 'text' && typeof n.text === 'string') out.push(n.text);
|
|
120
|
+
else if (n.type === 'hardBreak') out.push(' ');
|
|
121
|
+
// Code is how, not what: left out of the synopsis.
|
|
122
|
+
if (n.type === 'codeBlock') return;
|
|
123
|
+
for (const c of Array.isArray(n.content) ? n.content : []) walk(c);
|
|
124
|
+
if (/^(paragraph|heading|listItem|blockquote|tableCell)$/.test(n.type)) out.push('\n');
|
|
125
|
+
};
|
|
126
|
+
walk(d);
|
|
127
|
+
return out.join('');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** What an issue is about in a sentence or two, from its description; null when it has none. */
|
|
131
|
+
export function synopsisOf(description, max = 280) {
|
|
132
|
+
const text = descriptionText(description)
|
|
133
|
+
.split('\n')
|
|
134
|
+
.map((l) => l.trim())
|
|
135
|
+
// Jira's wiki markup and template headings carry no meaning on their own.
|
|
136
|
+
.filter((l) => l && !/^(h\d\.|\{code|\*?(description|summary|acceptance criteria|steps to reproduce)\*?:?$)/i.test(l))
|
|
137
|
+
.join(' ')
|
|
138
|
+
.replace(/\s+/g, ' ')
|
|
139
|
+
.trim();
|
|
140
|
+
if (!text) return null;
|
|
141
|
+
if (text.length <= max) return text;
|
|
142
|
+
const cut = text.slice(0, max);
|
|
143
|
+
const end = Math.max(cut.lastIndexOf('. '), cut.lastIndexOf('? '), cut.lastIndexOf('! '));
|
|
144
|
+
return end > max / 3 ? cut.slice(0, end + 1) : `${cut.slice(0, cut.lastIndexOf(' ') > 0 ? cut.lastIndexOf(' ') : max).trim()}…`;
|
|
145
|
+
}
|
|
146
|
+
|
|
75
147
|
/**
|
|
76
148
|
* The issue's summary, or null when it can't be had (not a site we contact, no access, offline).
|
|
77
149
|
* `fetchImpl` and `allow` are for tests.
|
|
@@ -98,13 +170,14 @@ export async function issueFields({ key, site }, { jira = loadJira(), fetchImpl
|
|
|
98
170
|
const headers = { accept: 'application/json' };
|
|
99
171
|
if (configured && jira.email && jira.token) headers.authorization = `Basic ${Buffer.from(`${jira.email}:${jira.token}`).toString('base64')}`;
|
|
100
172
|
try {
|
|
101
|
-
const res = await fetchImpl(`${site}/rest/api/3/issue/${encodeURIComponent(key)}?fields=summary,status`, { headers, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });
|
|
173
|
+
const res = await fetchImpl(`${site}/rest/api/3/issue/${encodeURIComponent(key)}?fields=summary,status,description`, { headers, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });
|
|
102
174
|
if (!res.ok) return null;
|
|
103
175
|
const f = (await res.json())?.fields ?? {};
|
|
104
176
|
const summary = typeof f.summary === 'string' && f.summary.trim() ? f.summary.trim().slice(0, 300) : null;
|
|
105
177
|
const status = typeof f.status?.name === 'string' ? f.status.name.slice(0, 60) : null;
|
|
106
178
|
if (!summary && !status) return null;
|
|
107
|
-
|
|
179
|
+
const synopsis = synopsisOf(f.description);
|
|
180
|
+
return { summary, status, category: typeof f.status?.statusCategory?.key === 'string' ? f.status.statusCategory.key : null, ...(synopsis ? { synopsis } : {}) };
|
|
108
181
|
} catch {
|
|
109
182
|
return null;
|
|
110
183
|
}
|
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 { issueFields, issueSummary, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
|
|
110
|
+
import { assignedIssues, issueFields, issueSummary, 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';
|
|
@@ -828,10 +828,19 @@ export class AgentManager extends EventEmitter {
|
|
|
828
828
|
* The issues agents work on, for the summary: one row per agent, with each issue's Jira status
|
|
829
829
|
* (fetched a few at a time, kept five minutes).
|
|
830
830
|
*/
|
|
831
|
-
async issues(proposed = []) {
|
|
831
|
+
async issues(proposed = [], actions = {}) {
|
|
832
832
|
const views = this.store.list().map((a) => this.view(a));
|
|
833
|
-
const rows = issueRows(views, new Map(), () => null, proposed);
|
|
834
833
|
this.jiraCache ??= new Map();
|
|
834
|
+
// Open issues assigned to you (kept two minutes); their fields stand in for a fetch each.
|
|
835
|
+
if (!this.assignedAt || Date.now() - this.assignedAt > 2 * 60_000) {
|
|
836
|
+
const got = await (this.assignedFetch ?? assignedIssues)().catch(() => null);
|
|
837
|
+
this.assignedAt = Date.now();
|
|
838
|
+
if (got) this.assignedNow = got;
|
|
839
|
+
else if (!loadJira().token) this.assignedNow = [];
|
|
840
|
+
for (const i of got ?? []) this.jiraCache.set(i.key, { at: Date.now(), fields: { summary: i.summary, status: i.status, category: i.category, ...(i.synopsis ? { synopsis: i.synopsis } : {}) } });
|
|
841
|
+
}
|
|
842
|
+
const assigned = this.assignedNow ?? [];
|
|
843
|
+
const rows = issueRows(views, new Map(), () => null, proposed, actions, assigned);
|
|
835
844
|
const jira = new Map();
|
|
836
845
|
const want = [];
|
|
837
846
|
for (const r of rows) {
|
|
@@ -859,7 +868,7 @@ export class AgentManager extends EventEmitter {
|
|
|
859
868
|
}
|
|
860
869
|
for (const [k, v] of jira) if (!v) jira.delete(k);
|
|
861
870
|
const j = loadJira();
|
|
862
|
-
return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed), jira: { site: j.site, signedIn: Boolean(j.site && j.email && j.token) } };
|
|
871
|
+
return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed, actions, assigned), jira: { site: j.site, signedIn: Boolean(j.site && j.email && j.token) } };
|
|
863
872
|
}
|
|
864
873
|
|
|
865
874
|
/** Every agent's design doc, for the Designs list. */
|
package/src/server.js
CHANGED
|
@@ -297,6 +297,7 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
297
297
|
const list = (Array.isArray(intents) ? intents : [intent]).map((i) => String(i ?? '').trim()).filter(Boolean);
|
|
298
298
|
// Agents the assistant's own session starts: its limits apply, and they are marked as its.
|
|
299
299
|
const extra = assistant.admit(req.headers['x-agentmgr-agent'], list, opts);
|
|
300
|
+
if (extra.startedBy) proposed.refuseSetAside(list);
|
|
300
301
|
const created = manager.createMany(list, { ...opts, ...extra });
|
|
301
302
|
if (!extra.startedBy) repeats.record(created.map((a) => ({ text: a.intent, projectKey: projectOf(store.get(a.id) ?? a).key })));
|
|
302
303
|
if (extra.startedBy) {
|
|
@@ -786,15 +787,20 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
786
787
|
api.get('/codemap', wrap((req) => manager.codeMap(req.query.project ? String(req.query.project) : null)));
|
|
787
788
|
// Issues agents work on, for the summary; ?group=you|agent|done and ?format=markdown to paste.
|
|
788
789
|
api.get('/issues', wrap(async (req) => {
|
|
789
|
-
|
|
790
|
+
// ?fresh=1 (the ↻ button) asks Jira again for the issues assigned to you.
|
|
791
|
+
if (req.query.fresh === '1') manager.assignedAt = 0;
|
|
792
|
+
const v = await manager.issues(proposed.listed(), proposed.actions);
|
|
790
793
|
const group = req.query.group ? String(req.query.group) : null;
|
|
791
|
-
|
|
794
|
+
// "all" is everything still on the list: removed ones only when asked for.
|
|
795
|
+
const rows = !group ? v.rows : group === 'all' ? v.rows.filter((r) => r.group !== 'removed') : v.rows.filter((r) => r.group === group);
|
|
792
796
|
return req.query.format === 'markdown' ? { markdown: issuesMarkdown(rows) } : { ...v, rows };
|
|
793
797
|
}));
|
|
794
798
|
// Issues proposed for agents (the assistant, when you pick): start the ticked ones, or dismiss them.
|
|
795
799
|
api.post('/issues/proposed', wrap((req) => proposed.add({ ...req.body, by: req.headers['x-agentmgr-agent'] ? 'assistant' : 'you' })));
|
|
796
800
|
api.post('/issues/start', wrap((req) => proposed.start(Array.isArray(req.body?.keys) ? req.body.keys.map(String) : [])));
|
|
797
801
|
api.post('/issues/dismiss', wrap((req) => proposed.dismiss(Array.isArray(req.body?.keys) ? req.body.keys.map(String) : [])));
|
|
802
|
+
// Your action on issues: assign (starts an agent from the proposal), skip, done, remove, or null to clear.
|
|
803
|
+
api.post('/issues/action', wrap((req) => proposed.setAction(Array.isArray(req.body?.keys) ? req.body.keys.map(String) : [], req.body?.action ?? null)));
|
|
798
804
|
// Design docs of all agents; the same ?group= and ?format=markdown.
|
|
799
805
|
api.get('/designs', wrap((req) => {
|
|
800
806
|
const v = manager.designs();
|