ai-agentmanager 1.27.0 → 1.29.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/public/issues.js CHANGED
@@ -15,18 +15,20 @@ const FILTERS = [
15
15
  ['agent', 'Agents on it'],
16
16
  ['done', 'Done'],
17
17
  ['skipped', 'Skipped'],
18
+ ['snoozed', 'Snoozed'],
18
19
  ['all', 'All'],
19
20
  ['removed', 'Removed'],
20
21
  ];
21
22
  const ACTIONS = [
22
23
  ['assign', 'Assign', 'An agent works on it (assigning one not started yet starts its agent)'],
23
24
  ['skip', 'Skip', 'Not now: under Skipped, and not proposed or started again'],
25
+ ['snooze', 'Snooze', 'Until tomorrow 9am: then back on the list'],
24
26
  ['done', 'Done', 'Handled (by you or elsewhere): under Done'],
25
27
  ['remove', 'Remove', 'Off the list (under Removed, to bring back)'],
26
28
  ];
27
29
  const CHECKS = { passed: ['✓', 'Checks pass'], failed: ['✗', 'Checks failing'], running: ['●', 'Checks running'] };
28
30
 
29
- export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
31
+ export function initIssues({ api, $, esc, ago, openAgent, openDoc, openChanges, toast }) {
30
32
  const dialog = $('#issues-dialog');
31
33
  const ext = (label, url, title = '') => `<a href="${esc(url)}" target="_blank" rel="noopener" title="${esc(title)}">${esc(label)} ↗</a>`;
32
34
  const body = $('#issues-body');
@@ -118,7 +120,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
118
120
  return `<tr data-row-id="${esc(r.key)}" class="stage-${esc(r.stage)} action-${esc(r.action)}">${box}${actionCell(r)}
119
121
  <td>${issue}${aboutIssue(r)}</td>
120
122
  <td>${status}</td>
121
- <td class="issue-note">${esc(r.note)}</td>
123
+ <td class="issue-note">${esc(r.note)}${r.snoozeUntil ? `<div class="hint">until ${esc(new Date(r.snoozeUntil).toLocaleString([], { weekday: 'short', hour: 'numeric', minute: '2-digit' }))}</div>` : ''}${r.stage === 'review' && !r.pr ? `<div class="issue-ship"><button class="small" data-issue-ship="changes" data-agent="${esc(r.agent.id)}" title="The diff, to look over first">See changes</button> <button class="small primary" data-issue-ship="pr" data-agent="${esc(r.agent.id)}" title="Commit what is left, push and open the pull request">Open PR</button></div>` : ''}</td>
122
124
  <td class="nowrap">${plan}</td>
123
125
  <td class="nowrap">${design}</td>
124
126
  <td>${pr}</td>
@@ -154,7 +156,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
154
156
  : filter === 'removed'
155
157
  ? 'Nothing removed. Set an issue back to another action here to bring it back.'
156
158
  : 'None here.';
157
- const backAll = ['skipped', 'done', 'removed'].includes(filter) ? setAsideShown().length : 0;
159
+ const backAll = ['skipped', 'snoozed', 'done', 'removed'].includes(filter) ? setAsideShown().length : 0;
158
160
  body.innerHTML = `
159
161
  <div class="issues-head">
160
162
  <h2>Jira</h2>
@@ -189,7 +191,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
189
191
 
190
192
  /** The issues shown that you skipped, marked done or removed (not those done in Jira). */
191
193
  function setAsideShown() {
192
- const g = { skipped: 'skip', done: 'done', removed: 'remove' }[filter];
194
+ const g = { skipped: 'skip', snoozed: 'snooze', done: 'done', removed: 'remove' }[filter];
193
195
  return (data?.rows ?? []).filter((r) => r.group === filter && r.action === g).map((r) => r.key);
194
196
  }
195
197
  expandable(dialog, draw);
@@ -199,7 +201,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
199
201
  // What each was before, to take the change back.
200
202
  const before = new Map(keys.map((k) => [k, data?.rows.find((x) => x.key === k)?.action ?? null]));
201
203
  try {
202
- const r = await api('POST', '/issues/action', { keys, action: action || null });
204
+ const r = await api('POST', '/issues/action', { keys, action: action || null, ...(action === 'snooze' ? { until: tomorrow9() } : {}) });
203
205
  for (const k of r.set) ticked.delete(k);
204
206
  const bad = r.failed.map((x) => `${x.key}: ${x.reason}`).join('; ');
205
207
  const label = ACTIONS.find(([v]) => v === action)?.[1] ?? 'Cleared';
@@ -217,6 +219,30 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
217
219
  load();
218
220
  }
219
221
 
222
+ /** Tomorrow at 9 in the morning. */
223
+ function tomorrow9() {
224
+ const t = new Date();
225
+ t.setDate(t.getDate() + 1);
226
+ t.setHours(9, 0, 0, 0);
227
+ return t.toISOString();
228
+ }
229
+
230
+ /** Done with no pull request: look at the changes, or open one. */
231
+ async function ship(agentId, what) {
232
+ if (what === 'changes') {
233
+ dialog.close();
234
+ return openChanges?.(agentId);
235
+ }
236
+ try {
237
+ toast?.('Opening its pull request…', 3000);
238
+ const r = await api('POST', `/agents/${agentId}/ship`, {});
239
+ toast?.(r.url ? 'Pull request opened' : 'Pushed', 6000, r.url ? { label: 'Open it', run: () => window.open(r.url, '_blank', 'noopener') } : undefined);
240
+ } catch (e) {
241
+ toast?.(e.message, 8000);
242
+ }
243
+ load();
244
+ }
245
+
220
246
  /** Set each issue back to what it was: [[key, action]]. */
221
247
  async function undoTo(pairs) {
222
248
  for (const action of new Set(pairs.map(([, a]) => a))) {
@@ -232,6 +258,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
232
258
  s: (r) => setAction([r.dataset.rowId], 'skip'),
233
259
  d: (r) => setAction([r.dataset.rowId], 'done'),
234
260
  x: (r) => setAction([r.dataset.rowId], 'remove'),
261
+ z: (r) => setAction([r.dataset.rowId], 'snooze'),
235
262
  o: (r) => setAction([r.dataset.rowId], null),
236
263
  Enter: (r) => r.querySelector('a.issue-key')?.click(),
237
264
  r: Object.assign(() => load({ fresh: true }), { needsRow: false }),
@@ -277,6 +304,8 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
277
304
  }
278
305
 
279
306
  body.addEventListener('click', async (e) => {
307
+ const sh = e.target.closest('[data-issue-ship]');
308
+ if (sh) return ship(sh.dataset.agent, sh.dataset.issueShip);
280
309
  const o = e.target.closest('[data-issue-open]');
281
310
  if (o) {
282
311
  dialog.close();
package/public/keys.js CHANGED
@@ -13,6 +13,7 @@ export const SHORTCUTS = [
13
13
  ]],
14
14
  ['Anywhere', [
15
15
  [['y'], 'Today: what needs you, most pressing first', 'today'],
16
+ [['b'], 'Bugs: what bug hunts found, and the hunts', 'bugs'],
16
17
  [['n'], 'New agents', 'new'],
17
18
  [['a'], 'Ask Agent (a general session)', 'ask'],
18
19
  [['/'], 'Filter agents', 'filter'],
@@ -40,6 +41,8 @@ export const SHORTCUTS = [
40
41
  [['s'], 'Skip', null],
41
42
  [['d'], 'Done', null],
42
43
  [['x'], 'Remove', null],
44
+ [['z'], 'Snooze until tomorrow 9am', null],
45
+ [['1–6'], "Pick one of an agent's answers (Today)", null],
43
46
  [['o'], 'Undecided again (Actions) or clear (Jira)', null],
44
47
  [['c'], 'Discuss it with Claude (Actions)', null],
45
48
  [['Enter'], 'Open the issue or where it was asked', null],
@@ -61,11 +64,11 @@ export const SHORTCUTS = [
61
64
  // A single key, as an event names it, to its action.
62
65
  export const SINGLE = {
63
66
  j: 'next', k: 'prev', Enter: 'terminal', t: 'terminal',
64
- 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',
67
+ 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', b: 'bugs', '?': 'help',
65
68
  1: 'tab:agents', 2: 'tab:inbox', 3: 'tab:backlog', 4: 'tab:land', 5: 'tab:built',
66
69
  };
67
70
  // While Watch is open: only what makes sense there.
68
- const ON_WATCH = new Set(['today', 'new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'help']);
71
+ const ON_WATCH = new Set(['today', 'new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'bugs', 'help']);
69
72
 
70
73
  /** Typing somewhere: a field, an editor or a terminal (xterm types through a textarea). */
71
74
  const typing = (el) => Boolean(el?.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"], .xterm, .cm-editor'));
package/public/rowkeys.js CHANGED
@@ -82,7 +82,8 @@ export function holdWhilePicking(body, render) {
82
82
  let waiting = false;
83
83
  const picking = () => {
84
84
  const f = document.activeElement;
85
- return f?.tagName === 'SELECT' && body.contains(f);
85
+ // A menu open, or a box being typed in: drawing again would close it or lose the place.
86
+ return (f?.tagName === 'SELECT' || f?.tagName === 'TEXTAREA' || (f?.tagName === 'INPUT' && !['checkbox', 'radio', 'button', 'submit'].includes(f.type))) && body.contains(f);
86
87
  };
87
88
  body.addEventListener('focusout', () => {
88
89
  if (!waiting) return;
package/public/style.css CHANGED
@@ -1321,3 +1321,32 @@ table.issues tr.kb-on td:first-child { box-shadow: inset 3px 0 0 var(--accent);
1321
1321
  .support-shot-acts { display: flex; justify-content: flex-end; margin-top: 6px; }
1322
1322
  #support-earlier ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
1323
1323
  #support-earlier summary { cursor: pointer; font-size: 13px; }
1324
+
1325
+ /* Bugs */
1326
+ .bug-sev { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; border: 1px solid currentColor; }
1327
+ .bug-sev.critical, .bug-sev.high { color: var(--red); }
1328
+ .bug-sev.medium { color: var(--amber, #c98a12); }
1329
+ .bug-sev.low { color: var(--muted); }
1330
+ tr.bug-detail td { padding: 4px 12px 14px; font-size: 13px; }
1331
+ tr.bug-detail pre { white-space: pre-wrap; max-height: 280px; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
1332
+ .hunt-running { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--accent, currentColor); font-size: 13px; }
1333
+ .hunt-form { padding: 8px 0; }
1334
+ .hunt-form h3 { margin: 0; font-size: 15px; }
1335
+ .hunt-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
1336
+ #bugs-btn.hunting::after { content: ' ●'; color: var(--accent, currentColor); }
1337
+ .today-bug .today-label { color: var(--red); }
1338
+ #bugs-dialog td.today-acts { white-space: normal; text-align: right; }
1339
+ #bugs-dialog td.today-acts > * { margin: 2px 0; }
1340
+
1341
+ /* Answering from the lists */
1342
+ .today-answer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
1343
+ .today-reply { display: flex; gap: 6px; flex: 1 1 260px; }
1344
+ .today-reply input { flex: 1; min-width: 0; }
1345
+ .today-draft { margin-top: 6px; }
1346
+ .today-draft-text { white-space: pre-wrap; padding: 6px 10px; border-left: 3px solid var(--accent, currentColor); font-size: 13px; }
1347
+ .today-draft-edit { margin-top: 6px; display: grid; gap: 6px; }
1348
+ .today-draft-edit textarea { width: 100%; font: inherit; font-size: 13px; resize: vertical; }
1349
+ .issue-ship { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
1350
+ .today-ask .today-label { color: var(--accent, currentColor); }
1351
+ table.today-table td.today-acts { white-space: normal; text-align: right; width: 34%; }
1352
+ table.today-table td.today-acts > * { margin: 2px 0; }
package/public/today.js CHANGED
@@ -10,7 +10,7 @@ import { expandButton, expandable } from './expand.js';
10
10
  // Up to this score an item is pressing: it counts on the button.
11
11
  const PRESSING = 32;
12
12
 
13
- export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions, openIssues, openReviews, toast }) {
13
+ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions, openIssues, openReviews, openBugs, openChanges, toast }) {
14
14
  const dialog = $('#today-dialog');
15
15
  const body = $('#today-body');
16
16
  let data = null;
@@ -19,6 +19,9 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
19
19
  let loadedAt = 0;
20
20
  let undo = null; // { label, run }: the last change made here, to take back (u)
21
21
  let asideOpen = false;
22
+ let editing = null; // the question whose draft answer is being edited
23
+ let replying = null; // the item a reply or send-back box is open on
24
+ const drafts = new Map(); // typed text per item, kept across redraws
22
25
 
23
26
  async function load({ quiet = false, fresh = false } = {}) {
24
27
  if (loading) return;
@@ -47,20 +50,42 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
47
50
  const link = (url, label) => (url ? `<a href="${esc(url)}" target="_blank" rel="noopener" class="small-link">${esc(label)} ↗</a>` : '');
48
51
  const btn = (act, label, title, primary = false) => `<button class="small ${primary ? 'primary' : ''}" data-today="${act}" title="${esc(title)}">${esc(label)}</button>`;
49
52
 
53
+ const snoozeBtn = btn('snooze', 'Snooze', 'Until tomorrow 9am (z)');
54
+
50
55
  /** The buttons for an item: the decision it asks for, then where to look. */
51
56
  function buttons(it) {
52
- 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(' ');
53
- 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(' ');
57
+ if (it.kind === 'ask') return [it.draft ? btn('copy', 'Copy answer', 'Copy the drafted answer, to paste in the thread', true) : btn('draft', 'Draft answer', 'A session reads the thread, finds the answer and drafts it for you', true), btn('done', 'Answered', 'You answered it: off the list (d)'), snoozeBtn, link(it.url, 'Thread')].join(' ');
58
+ if (it.kind === 'action') return [btn('done', 'Done', 'Handled: off the list (d)'), btn('skip', 'Skip', 'Not now (s)'), snoozeBtn, btn('discuss', 'Discuss', 'Talk it through with Claude (c)'), link(it.url, 'Source')].join(' ');
59
+ if (it.kind === 'issue-new') return [btn('assign', 'Assign', 'Start an agent on it (a)', true), btn('skip', 'Skip', 'Not now (s)'), snoozeBtn, link(it.url, 'Jira')].join(' ');
60
+ if (it.ship) return [btn('changes', 'See changes', 'The diff, to look over first'), btn('ship', 'Open PR', 'Commit what is left, push and open the pull request', true), btn('send-back', 'Send back', 'Tell the agent what is still missing'), btn('open', 'Open', "Open the agent's session (Enter)"), link(it.url, 'Jira')].join(' ');
54
61
  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(' ');
55
62
  if (it.kind === 'pr-ready') return [btn('open-reviews', 'Open review', 'Pick what to post (Enter)', true), link(it.url, 'PR')].join(' ');
56
63
  if (it.kind === 'rule') return btn('inbox', 'Inbox', 'Decide in the inbox (Enter)', true);
64
+ if (it.kind === 'bug') return [btn('fix', 'Fix', 'Start an agent on it, with the failing test (a)', true), btn('skip', 'Snooze', 'Until tomorrow 9am (s)'), btn('notbug', 'Not a bug', "It won't be reported again"), btn('bugs', 'Evidence', 'See it in Bugs (Enter)')].join(' ');
57
65
  return [it.agentId ? btn('open', 'Open', "Open the agent's session (Enter)", it.score < 20) : '', link(it.url, it.issueKey ? 'Jira' : 'Link')].join(' ');
58
66
  }
59
67
 
68
+ /** Under an item: the agent's choices and a reply box, a drafted answer, or a send-back box. */
69
+ function extra(it) {
70
+ const box = (placeholder, send) => `<form class="today-reply" data-today-form="${esc(it.id)}"><input data-today-text="${esc(it.id)}" placeholder="${esc(placeholder)}" value="${esc(drafts.get(it.id) ?? '')}" autocomplete="off" /><button class="small primary">${esc(send)}</button></form>`;
71
+ if (it.answer) {
72
+ const a = it.answer;
73
+ const choices = a.via === 'key' ? a.choices.map((c, i) => `<button class="small ${i === 0 ? 'primary' : ''}" data-today-pick="${i}" title="Press ${esc(c.key)}">${esc(c.key)}. ${esc(c.label)}</button>`) : a.choices.map((c, i) => `<button class="small" data-today-pick="${i}" title="Answer this (${i + 1})">${esc(c)}</button>`);
74
+ return `<div class="today-answer">${choices.join(' ')}${a.default ? ` <span class="hint">Going ahead with “${esc(String(a.default).replace(/[.!\s]+$/, ''))}” until you answer.</span>` : ''}${a.reply ? box('Or type an answer…', 'Send') : ''}</div>`;
75
+ }
76
+ if (it.kind === 'ask') {
77
+ if (editing === it.id) return `<form class="today-draft-edit" data-today-edit="${esc(it.id)}"><textarea rows="4" data-today-edit-text>${esc(it.draft?.text ?? '')}</textarea><div><button class="small primary">Save</button> <button type="button" class="small" data-today="cancel-edit">Cancel</button></div></form>`;
78
+ if (it.draft) return `<div class="today-draft"><div class="today-draft-text">${esc(it.draft.text)}</div><div class="hint">${it.draft.by === 'you' ? 'Your edit' : 'Drafted by the assistant'}${it.draft.sources ? ` · from ${esc(it.draft.sources)}` : ''} · <button class="link" data-today="edit">Edit</button> · <button class="link" data-today="draft">Draft again</button></div></div>`;
79
+ return '';
80
+ }
81
+ if (it.ship && replying === it.id) return box('What is still missing?', 'Send back');
82
+ return '';
83
+ }
84
+
60
85
  function row(it) {
61
86
  return `<tr data-row-id="${esc(it.id)}" class="today-${esc(it.kind)} ${it.score <= PRESSING ? 'pressing' : ''}">
62
87
  <td class="nowrap"><span class="today-label">${esc(it.label)}</span></td>
63
- <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>
88
+ <td><div class="today-title">${esc(it.title)}</div><div class="hint today-why">${esc(it.why ?? '')}${it.at ? ` · ${esc(ago(it.at))}` : ''}</div>${extra(it)}</td>
64
89
  <td class="nowrap today-acts">${buttons(it)}</td>
65
90
  </tr>`;
66
91
  }
@@ -88,7 +113,7 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
88
113
  ? `<div class="issues-scroll"><table class="issues today-table"><tbody>${items.map(row).join('')}</tbody></table></div>`
89
114
  : '<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>'}
90
115
  ${asideHtml()}
91
- <p class="hint">Keys: j/k move (or click a row), Enter opens, a assign or review, d done, s skip, c discuss, u undo, 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>`;
116
+ <p class="hint">Keys: j/k move (or click a row), Enter opens, 1–6 pick an answer, a assign or review, d done, s skip, z snooze, c discuss, u undo, 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>`;
92
117
  keys.redraw();
93
118
  }
94
119
  const render = holdWhilePicking(body, draw);
@@ -98,7 +123,7 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
98
123
  const aside = data?.aside ?? [];
99
124
  if (!aside.length) return '';
100
125
  const rows = aside
101
- .map((a) => `<tr data-aside-id="${esc(a.id)}"><td class="nowrap"><span class="today-label">${esc(a.label)}</span></td><td><div class="today-title">${esc(a.title)}</div>${a.at ? `<div class="hint">${esc(ago(a.at))}</div>` : ''}</td><td class="nowrap today-acts"><button class="small" data-today-back="${esc(a.id)}" title="Back on the list, undecided">Bring back</button></td></tr>`)
126
+ .map((a) => `<tr data-aside-id="${esc(a.id)}"><td class="nowrap"><span class="today-label">${esc(a.label)}</span></td><td><div class="today-title">${esc(a.title)}</div><div class="hint">${a.until ? `until ${esc(new Date(a.until).toLocaleString([], { weekday: 'short', hour: 'numeric', minute: '2-digit' }))}` : a.at ? esc(ago(a.at)) : ''}</div></td><td class="nowrap today-acts"><button class="small" data-today-back="${esc(a.id)}" title="Back on the list, undecided">Bring back</button></td></tr>`)
102
127
  .join('');
103
128
  return `<details class="today-aside" ${asideOpen ? 'open' : ''}><summary>Set aside: skipped, done or removed (${aside.length})</summary>
104
129
  <div class="today-aside-head"><span class="hint">Brought back, an item is undecided again and shows in Today and its own list.</span><button class="small" data-today-back="all" title="Bring every one back">Bring all ${aside.length} back</button></div>
@@ -116,12 +141,38 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
116
141
  const same = list.filter((a) => a.state === state);
117
142
  const keys = same.filter((a) => a.kind === 'issue').map((a) => a.issueKey);
118
143
  const ids = same.filter((a) => a.kind === 'action').map((a) => a.actionId);
119
- if (keys.length) await api('POST', '/issues/action', { keys, action: state });
120
- if (ids.length) await api('POST', '/actions/set', { ids, state });
144
+ // A snooze goes back to its own time, or tomorrow when that has passed.
145
+ const until = state === 'snooze' ? (same.map((a) => a.until).find((u) => Date.parse(u) > Date.now()) ?? tomorrow9()) : undefined;
146
+ if (keys.length) await api('POST', '/issues/action', { keys, action: state, until });
147
+ if (ids.length) await api('POST', '/actions/set', { ids, state, until });
121
148
  }
122
149
  };
123
150
  }
124
151
 
152
+ /** Tomorrow at 9 in the morning. */
153
+ function tomorrow9() {
154
+ const t = new Date();
155
+ t.setDate(t.getDate() + 1);
156
+ t.setHours(9, 0, 0, 0);
157
+ return t.toISOString();
158
+ }
159
+
160
+ /** Answer an agent's question: a choice (by its index) or typed text. */
161
+ async function answer(it, { pick = null, text = null }) {
162
+ const a = it.answer;
163
+ if (a.via === 'key') {
164
+ const c = a.choices[pick];
165
+ if (!c) return;
166
+ await api('POST', `/agents/${it.agentId}/prompt-key`, { key: c.key });
167
+ return `Pressed ${c.key}. ${c.label}`;
168
+ }
169
+ const t = text ?? a.choices[pick];
170
+ if (!t) return;
171
+ if (a.via === 'waiting') await api('POST', `/agents/${it.agentId}/waiting/answer`, { text: t });
172
+ else await api('POST', `/agents/${it.agentId}/answer`, { question: a.qid, text: t });
173
+ return `Answered: ${t.length > 60 ? `${t.slice(0, 59)}…` : t}`;
174
+ }
175
+
125
176
  /** Remember how to take back a change, and offer it on the toast. */
126
177
  function changedWith(msg, label, run) {
127
178
  undo = { label, run };
@@ -161,6 +212,10 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
161
212
  dialog.close();
162
213
  return openReviews();
163
214
  }
215
+ if (what === 'bugs' || (what === 'enter' && it.kind === 'bug')) {
216
+ dialog.close();
217
+ return openBugs?.();
218
+ }
164
219
  if (what === 'enter') {
165
220
  if (it.kind === 'action') {
166
221
  dialog.close();
@@ -173,7 +228,38 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
173
228
  if (it.url) window.open(it.url, '_blank', 'noopener');
174
229
  return;
175
230
  }
176
- if (it.kind === 'action' && ['done', 'skip'].includes(what)) {
231
+ if (what === 'snooze' && ['action', 'ask', 'issue-new'].includes(it.kind)) {
232
+ const until = tomorrow9();
233
+ if (it.kind === 'issue-new') await api('POST', '/issues/action', { keys: [it.issueKey], action: 'snooze', until });
234
+ else await api('POST', '/actions/set', { ids: [it.actionId], state: 'snooze', until });
235
+ changedWith('Snoozed until tomorrow 9am', 'snoozed', () => (it.kind === 'issue-new' ? api('POST', '/issues/action', { keys: [it.issueKey], action: null }) : api('POST', '/actions/set', { ids: [it.actionId], state: 'open' })));
236
+ } else if (it.kind === 'ask' && what === 'copy' && it.draft) {
237
+ const ok = await navigator.clipboard?.writeText(it.draft.text).then(() => true, () => false);
238
+ return toast?.(ok ? `Copied${it.url ? ': paste it in the thread' : ''}` : "Couldn't copy: select the text instead", 3000, it.url ? { label: 'Open thread', run: () => window.open(it.url, '_blank', 'noopener') } : undefined);
239
+ } else if (it.kind === 'ask' && what === 'draft') {
240
+ const r = await api('POST', `/actions/${it.actionId}/draft`, {});
241
+ toast?.(r.existing ? 'A session is drafting it already' : 'Drafting: a session reads the thread and finds the answer', 5000, { label: 'Watch', run: () => (dialog.close(), openAgent(r.agent.id)) });
242
+ } else if (it.kind === 'ask' && what === 'edit') {
243
+ editing = it.id;
244
+ return render();
245
+ } else if (what === 'cancel-edit') {
246
+ editing = null;
247
+ return render();
248
+ } else if (it.kind === 'ask' && what === 'done') {
249
+ await api('POST', '/actions/set', { ids: [it.actionId], state: 'done' });
250
+ changedWith('Answered: off the list', 'answered', () => api('POST', '/actions/set', { ids: [it.actionId], state: 'open' }));
251
+ } else if (it.ship && what === 'changes') {
252
+ dialog.close();
253
+ return openChanges?.(it.agentId);
254
+ } else if (it.ship && what === 'ship') {
255
+ toast?.('Opening its pull request…', 3000);
256
+ const r = await api('POST', `/agents/${it.agentId}/ship`, {});
257
+ toast?.(r.url ? 'Pull request opened' : 'Pushed', 6000, r.url ? { label: 'Open it', run: () => window.open(r.url, '_blank', 'noopener') } : undefined);
258
+ } else if (it.ship && what === 'send-back') {
259
+ replying = replying === it.id ? null : it.id;
260
+ render();
261
+ return body.querySelector(`[data-today-text="${CSS.escape(it.id)}"]`)?.focus();
262
+ } else if (it.kind === 'action' && ['done', 'skip'].includes(what)) {
177
263
  const r = await api('POST', '/actions/set', { ids: [it.actionId], state: what });
178
264
  if (r.failed.length) toast?.(`Not changed: ${r.failed.map((x) => x.reason).join('; ')}`, 6000);
179
265
  else changedWith(what === 'done' ? 'Done' : 'Skipped', `${what === 'done' ? 'done' : 'skipped'} "${it.title}"`, () => api('POST', '/actions/set', { ids: [it.actionId], state: 'open' }));
@@ -186,6 +272,15 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
186
272
  const bad = r.failed.map((x) => x.reason).join('; ');
187
273
  if (bad || r.started.length) toast?.(bad ? `Not changed: ${bad}` : `Started an agent on ${it.title}`, bad ? 6000 : 3000);
188
274
  else changedWith(`${it.title}: skipped`, `skipped ${it.issueKey}`, () => api('POST', '/issues/action', { keys: [it.issueKey], action: null }));
275
+ } else if (it.kind === 'bug' && (what === 'fix' || what === 'assign')) {
276
+ const r = await api('POST', `/findings/${it.findingId}/fix`, {});
277
+ toast?.(r.existing ? `${r.agent.name} is on it already` : `Agent ${r.agent.name} started on it`, 4000);
278
+ } else if (it.kind === 'bug' && ['skip', 'notbug'].includes(what)) {
279
+ const t = new Date();
280
+ t.setDate(t.getDate() + 1);
281
+ t.setHours(9, 0, 0, 0);
282
+ await api('POST', '/findings/set', { ids: [it.findingId], status: what === 'skip' ? 'snoozed' : 'notbug', until: what === 'skip' ? t.toISOString() : null });
283
+ changedWith(what === 'skip' ? 'Snoozed until tomorrow 9am' : "Not a bug: it won't be reported again", what === 'skip' ? 'snoozed' : 'not a bug', () => api('POST', '/findings/set', { ids: [it.findingId], status: 'open' }));
189
284
  } else if (it.kind === 'pr-requested' && (what === 'review' || what === 'assign')) {
190
285
  const a = await api('POST', '/reviews', { url: it.reviewUrl });
191
286
  toast?.(`Reviewer ${a.name ?? 'agent'} started`, 3000);
@@ -206,9 +301,56 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
206
301
  c: (r) => act(itemOf(r.dataset.rowId), 'discuss'),
207
302
  r: Object.assign(() => load({ fresh: true }), { needsRow: false }),
208
303
  u: Object.assign(() => takeBack(), { needsRow: false }),
304
+ z: (r) => act(itemOf(r.dataset.rowId), 'snooze'),
305
+ ...Object.fromEntries([1, 2, 3, 4, 5, 6].map((n) => [String(n), (r) => pickAt(itemOf(r.dataset.rowId), n - 1)])),
209
306
  },
210
307
  });
211
308
 
309
+ /** A choice by its place: keys 1–6 on the selected row. */
310
+ async function pickAt(it, i) {
311
+ if (!it?.answer) return;
312
+ try {
313
+ const done = await answer(it, { pick: it.answer.via === 'key' ? i : i });
314
+ if (done) toast?.(done, 3000);
315
+ } catch (e) {
316
+ toast?.(e.message, 6000);
317
+ }
318
+ load();
319
+ }
320
+
321
+ body.addEventListener('input', (e) => {
322
+ const id = e.target.dataset?.todayText;
323
+ if (id) drafts.set(id, e.target.value);
324
+ });
325
+ body.addEventListener('submit', async (e) => {
326
+ e.preventDefault();
327
+ // Done typing: the list may be drawn again.
328
+ document.activeElement?.blur?.();
329
+ const f = e.target.closest('[data-today-form]');
330
+ const ed = e.target.closest('[data-today-edit]');
331
+ try {
332
+ if (ed) {
333
+ const it = itemOf(ed.dataset.todayEdit);
334
+ await api('PUT', `/actions/${it.actionId}/answer`, { text: ed.querySelector('[data-today-edit-text]').value });
335
+ editing = null;
336
+ toast?.('Draft saved', 2000);
337
+ } else if (f) {
338
+ const it = itemOf(f.dataset.todayForm);
339
+ const text = f.querySelector('input').value.trim();
340
+ if (!it || !text) return;
341
+ if (it.answer) toast?.(await answer(it, { text }), 3000);
342
+ else if (it.ship) {
343
+ await api('POST', `/agents/${it.agentId}/tell`, { text });
344
+ replying = null;
345
+ toast?.('Sent back to the agent', 3000);
346
+ }
347
+ drafts.delete(it.id);
348
+ }
349
+ } catch (err) {
350
+ return toast?.(err.message, 6000);
351
+ }
352
+ load();
353
+ });
212
354
  body.addEventListener('toggle', (e) => {
213
355
  if (e.target.matches?.('.today-aside')) asideOpen = e.target.open;
214
356
  }, true);
@@ -225,6 +367,8 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
225
367
  }
226
368
  return load();
227
369
  }
370
+ const pick = e.target.closest('[data-today-pick]');
371
+ if (pick) return pickAt(itemOf(e.target.closest('tr[data-row-id]')?.dataset.rowId), Number(pick.dataset.todayPick));
228
372
  const b = e.target.closest('[data-today]')?.dataset.today;
229
373
  if (!b) return;
230
374
  if (b === 'close') return dialog.close();
package/src/actions.js CHANGED
@@ -2,13 +2,15 @@
2
2
  // found by the assistant on its checks and kept in one list, so nothing is missed or has to be
3
3
  // remembered. Each one has your decision on it, as for Jira issues: assign (an agent does it),
4
4
  // skip, done or remove, kept in state.json and changeable any time; Discuss opens a conversation
5
- // about it. Nothing is ever sent to Slack or anywhere else from here.
5
+ // about it. Questions put to you (or that you're CC'd on) come with an answer the assistant drafted
6
+ // from your code, Jira and docs, to edit and send yourself; Snooze hides one until a time. Nothing
7
+ // is ever sent to Slack or anywhere else from here.
6
8
 
7
9
  import crypto from 'node:crypto';
8
10
 
9
11
  export const ACTION_SOURCES = { slack: 'Slack', gemini: 'Meeting notes', other: 'Other' };
10
- export const ACTION_STATES = ['open', 'assign', 'skip', 'done', 'remove'];
11
- const GROUP = { open: 'open', assign: 'assigned', skip: 'skipped', done: 'done', remove: 'removed' };
12
+ export const ACTION_STATES = ['open', 'assign', 'skip', 'snooze', 'done', 'remove'];
13
+ const GROUP = { open: 'open', assign: 'assigned', snooze: 'snoozed', skip: 'skipped', done: 'done', remove: 'removed' };
12
14
  const MAX = 500;
13
15
  const err = (status, message) => Object.assign(new Error(message), { status });
14
16
  const clip = (s, n) => {
@@ -30,6 +32,25 @@ export function actionIntent(a) {
30
32
  .trim();
31
33
  }
32
34
 
35
+ /** What "Draft an answer" starts with: research the question, record a draft, never send it. */
36
+ export function draftPrompt(a, bin = 'agentmgr', projects = []) {
37
+ return [
38
+ `Prepare an answer for me to a question I was ${a.cc ? 'copied on' : 'asked'}. Don't send anything: I'll edit and send it myself.`,
39
+ '',
40
+ `The question: ${a.question || a.text}`,
41
+ a.from ? `Asked by: ${a.from}` : '',
42
+ a.link ? `Where: ${ACTION_SOURCES[a.source] ?? a.source}, ${a.link}` : '',
43
+ a.context ? `Context: ${a.context}` : '',
44
+ '',
45
+ 'Read the thread first (your Slack, Gmail or Google Drive tools) for the whole picture. Then find the answer from the sources: ' +
46
+ `${projects.length ? `the code in my projects (${projects.map((p) => `${p.name} at ${p.dir ?? p.repo}`).join('; ')}), ` : ''}Jira, docs and earlier messages. ` +
47
+ 'Check facts against the code or docs rather than guessing, and say how sure you are. When something can only be answered by someone else, say who and what to ask.',
48
+ `Record the draft, in my voice, short and ready to paste: ${bin} actions answer ${a.id} --sources "<links or files you used>" "<the answer>". Then tell me here what you found and anything I should check before sending.`,
49
+ ]
50
+ .filter((l) => l !== '')
51
+ .join('\n');
52
+ }
53
+
33
54
  /** What Discuss starts with: a conversation to decide what to do about the action. */
34
55
  export function discussPrompt(a, bin = 'agentmgr') {
35
56
  return [
@@ -65,7 +86,7 @@ export class MyActions {
65
86
  }
66
87
 
67
88
  /** Add one (the assistant does, on its checks). The same action from the same place is kept once. */
68
- add({ text, source = 'other', link = null, from = null, when = null, due = null, context = null, by = null } = {}) {
89
+ add({ text, source = 'other', link = null, from = null, when = null, due = null, context = null, by = null, question = null, cc = false, answer = null, sources = null } = {}) {
69
90
  const t = clip(text, 400);
70
91
  if (t.length < 3) throw err(400, 'Say what the action is');
71
92
  if (!ACTION_SOURCES[source]) throw err(400, `The source is one of ${Object.keys(ACTION_SOURCES).join(', ')}`);
@@ -84,6 +105,9 @@ export class MyActions {
84
105
  when: when && !Number.isNaN(Date.parse(when)) ? new Date(when).toISOString() : new Date().toISOString(),
85
106
  due: due ? clip(due, 40) : null,
86
107
  context: context ? clip(context, 1000) : null,
108
+ // A question put to you (cc: you're copied or mentioned, not asked): its words, and a draft answer.
109
+ ...(question || cc ? { kind: 'question', question: question ? clip(question, 1000) : t, cc: Boolean(cc) } : {}),
110
+ ...(answer ? { answer: { text: String(answer).trim().slice(0, 4000), sources: sources ? clip(sources, 600) : null, by: by ?? 'you', at: new Date().toISOString() } } : {}),
87
111
  by: by ?? null,
88
112
  status: 'open',
89
113
  at: new Date().toISOString(),
@@ -101,6 +125,7 @@ export class MyActions {
101
125
  /** The list, open ones first, newest first within: rows with their group and agents. */
102
126
  rows() {
103
127
  const order = Object.fromEntries(Object.values(GROUP).map((g, i) => [g, i]));
128
+ this.wake();
104
129
  return this.all
105
130
  .map((a) => {
106
131
  const agent = a.agentId ? this.manager.store?.get?.(a.agentId) ?? null : null;
@@ -117,6 +142,11 @@ export class MyActions {
117
142
  context: a.context,
118
143
  status: a.status,
119
144
  group: GROUP[a.status] ?? 'open',
145
+ kind: a.kind ?? 'task',
146
+ question: a.question ?? null,
147
+ cc: Boolean(a.cc),
148
+ answer: a.answer ?? null,
149
+ snoozeUntil: a.status === 'snooze' ? a.snoozeUntil ?? null : null,
120
150
  agent: agent ? { id: agent.id, name: agent.name } : null,
121
151
  discussion: talk ? { id: talk.id, name: talk.name } : null,
122
152
  updatedAt: a.updatedAt ?? a.at,
@@ -129,8 +159,10 @@ export class MyActions {
129
159
  * Your decision on actions: open (undecided again), assign (starts an agent; `project` picks
130
160
  * where), skip, done or remove. { set: [ids], started: [{ id, agent }], failed: [{ id, reason }] }.
131
161
  */
132
- set(ids = [], state, { project = null } = {}) {
162
+ set(ids = [], state, { project = null, until = null } = {}) {
133
163
  if (!ACTION_STATES.includes(state)) throw err(400, `The decision is one of ${ACTION_STATES.join(', ')}`);
164
+ const wakeAt = state === 'snooze' ? Date.parse(until ?? '') : null;
165
+ if (state === 'snooze' && !(Number.isFinite(wakeAt) && wakeAt > Date.now())) throw err(400, 'Snooze until a time to come');
134
166
  const set = [];
135
167
  const started = [];
136
168
  const failed = [];
@@ -152,6 +184,7 @@ export class MyActions {
152
184
  }
153
185
  }
154
186
  a.status = state;
187
+ a.snoozeUntil = state === 'snooze' ? new Date(wakeAt).toISOString() : null;
155
188
  a.updatedAt = new Date().toISOString();
156
189
  set.push(id);
157
190
  }
@@ -159,6 +192,44 @@ export class MyActions {
159
192
  return { set, started, failed };
160
193
  }
161
194
 
195
+ /** Snoozed ones whose time has come are open again. */
196
+ wake(t = Date.now()) {
197
+ let n = 0;
198
+ for (const a of this.all) {
199
+ if (a.status === 'snooze' && (!a.snoozeUntil || Date.parse(a.snoozeUntil) <= t)) {
200
+ a.status = 'open';
201
+ a.snoozeUntil = null;
202
+ n += 1;
203
+ }
204
+ }
205
+ if (n) this.store.save();
206
+ return n;
207
+ }
208
+
209
+ /** The draft answer to a question (the assistant's, or yours edited); empty text clears it. */
210
+ answer(id, { text, sources = null, by = 'you' } = {}) {
211
+ const a = this.find(id);
212
+ const t = String(text ?? '').trim().slice(0, 4000);
213
+ if (!t) delete a.answer;
214
+ else a.answer = { text: t, sources: sources ? clip(sources, 600) : a.answer?.sources ?? null, by, at: new Date().toISOString() };
215
+ // An answer makes it a question, if it wasn't one.
216
+ if (t && !a.kind) Object.assign(a, { kind: 'question', question: a.text, cc: false });
217
+ a.updatedAt = new Date().toISOString();
218
+ this.store.save();
219
+ return a;
220
+ }
221
+
222
+ /** A session that researches the question and records a draft answer (or the one already started). */
223
+ draft(id, bin, projects = []) {
224
+ const a = this.find(id);
225
+ const prev = a.draftId ? this.manager.store?.get?.(a.draftId) : null;
226
+ if (prev) return { agent: { id: prev.id, name: prev.name }, existing: true };
227
+ const agent = this.manager.createGeneral({ question: draftPrompt(a, bin, projects), name: `Answer: ${clip(a.question || a.text, 40)}` });
228
+ a.draftId = agent.id;
229
+ this.store.save();
230
+ return { agent: { id: agent.id, name: agent.name }, existing: false };
231
+ }
232
+
162
233
  /** A conversation about the action (a general session), or the one already started. */
163
234
  discuss(id, bin) {
164
235
  const a = this.find(id);
package/src/assistant.js CHANGED
@@ -18,7 +18,7 @@ export const SOURCES = {
18
18
  comments: 'new comments and mentions on Jira issues the person owns',
19
19
  slack: 'Slack messages to the person (direct messages and mentions) that ask for work',
20
20
  linear: 'Linear issues newly assigned to the person',
21
- actions: 'things asked of the person in Slack and in meeting notes (Notes by Gemini), for their Actions list',
21
+ actions: 'things asked of the person in Slack and in meeting notes (Notes by Gemini), and questions put to them or that they are copied on, with draft answers, for their Actions list',
22
22
  };
23
23
 
24
24
  /**
@@ -149,6 +149,10 @@ export function assistantPrompt(s, dir, bin = `node ${BIN}`, features = features
149
149
  `Find what is asked of ${who}, or what they agreed to do: in Gemini's notes, the action items and suggested next steps that name them. ` +
150
150
  `For each one, add it to their list: ${am} actions add --source <${[features.slack && 'slack', features.gemini && 'gemini'].filter(Boolean).join('|')}> --link "<the message or doc link>" --from "<who asked>" [--due "<when, if said>"] --context "<one or two sentences of background>" "<the action in one line, starting with a verb>". ` +
151
151
  `Adding the same one twice is harmless. Don't act on them, start agents for them or reply: the person decides under Actions.`,
152
+ `Questions for them: also find questions put to ${who} that are still unanswered: asked of them directly, or in a thread, email or document where they are mentioned, copied (CC) or tagged. ` +
153
+ `Add each one with its exact words: ${am} actions add --source <${[features.slack && 'slack', features.gemini && 'gemini'].filter(Boolean).join('|')}> --link "<link>" --from "<who asked>" --question "<the question, in their words>" [--cc when they are only copied or mentioned] "Answer <who>: <the question in a few words>". ` +
154
+ `Then prepare an answer they can send: read the whole thread, and find the answer in the code of their projects, Jira, docs and earlier messages, checking facts rather than guessing. ` +
155
+ `Record it, short, in their voice and ready to paste: ${am} actions answer <id> --sources "<links or files you used>" "<the answer>". When only someone else can answer, say so in the draft (who, and what to ask). Never send it yourself.`,
152
156
  );
153
157
  }
154
158
  if (s.sources.includes('slack')) {