ai-agentmanager 1.43.0 → 1.46.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/side.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // The split view: the terminal (Claude, a shell or a browser tab) stays on the left, and the right
2
- // pane shows the same agent's Code, its Docs (Diagrams by default) or its Changes explained one by
3
- // one. On, the tab and the document are remembered in this browser.
2
+ // pane shows the same agent's Code, its Docs (Diagrams by default), its Changes explained one by
3
+ // one, or Debug: you say what to debug, the agent investigates in its session on the left and its
4
+ // report (animated code path and data flow, findings, fixes) grows here. On, the tab and the
5
+ // document are remembered in this browser.
4
6
  import { parseDiff } from '/review.js';
5
7
  import { cardHtml, explainButton, listenParts as walkParts, walkthroughOf } from '/walkthrough.js';
6
8
 
@@ -63,10 +65,100 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
63
65
  if (!on) return refit();
64
66
  if (st.tab === 'code') codeUi.open(st.agentId);
65
67
  else if (st.tab === 'docs') renderDocs(true);
68
+ else if (st.tab === 'debug') renderDebug(true);
66
69
  else renderChanges(true);
67
70
  refit();
68
71
  }
69
72
 
73
+ // ------------------------------------------------------------ Debug
74
+ const DEBUG_IDEAS = ['E2E tests unstable at max scale', 'Slow or failing under load', 'A flaky test', 'A memory or connection leak', 'Wrong data end to end'];
75
+ const drafts = new Map(); // agent id -> what's typed and not sent
76
+ /** Read the report; `want` is the change time the agent's record names, so each version is read once. */
77
+ async function loadDebug(want) {
78
+ const id = st.agentId;
79
+ const key = `${id}:debug`;
80
+ files.set(key, { ...files.get(key), loading: true });
81
+ const r = await api('GET', `/agents/${id}/specs/debug`).catch(() => null);
82
+ files.set(key, { markdown: r?.markdown ?? null, at: r?.updatedAt ?? null, want, loaded: true });
83
+ if (st.agentId === id && st.on && st.tab === 'debug') renderDebug(false);
84
+ }
85
+
86
+ function renderDebug(force) {
87
+ const a = agents.get(st.agentId);
88
+ const d = files.get(`${st.agentId}:debug`);
89
+ const want = a?.specDocs?.debug ?? null;
90
+ if ((!d || (d.loaded && d.want !== want)) && !d?.loading) loadDebug(want);
91
+ const asks = a?.debug?.asks ?? [];
92
+ const working = Boolean(a?.runtime?.busy || a?.outbox);
93
+ const has = Boolean(d?.markdown);
94
+ const sig = `debug|${st.agentId}|${d?.at}|${Boolean(d?.loaded)}|${asks.length}|${working}|${Boolean(a?.workdir)}`;
95
+ if (!force && sig === st.sig) return;
96
+ st.sig = sig;
97
+ // What's being typed, and where the caret is, survive the redraw.
98
+ const old = body.querySelector('[data-debug-text]');
99
+ if (old) drafts.set(st.agentId, old.value);
100
+ const typing = old && document.activeElement === old ? [old.selectionStart, old.selectionEnd] : null;
101
+ const top = body.querySelector('.side-scroll')?.scrollTop ?? 0;
102
+ const draft = drafts.get(st.agentId) ?? '';
103
+ const ideas = has || asks.length ? '' : `<div class="debug-ideas">${DEBUG_IDEAS.map((t) => `<button type="button" class="chip" data-debug-idea>${esc(t)}</button>`).join('')}</div>`;
104
+ const status = !asks.length
105
+ ? ''
106
+ : working
107
+ ? `<p class="hint debug-status"><span class="debug-dot"></span> The agent is investigating in its session${has ? '; the report below updates as it writes' : '; the report shows here once it has the code path'}.</p>`
108
+ : has
109
+ ? ''
110
+ : '<p class="hint debug-status">Asked. The report shows here when the agent has written it; its session on the left has what it is doing or asking.</p>';
111
+ const asked = asks.length
112
+ ? `<details class="debug-asked"><summary>Asked (${asks.length})</summary><ol>${asks.map((x) => `<li>${x.kind === 'fix' ? '<span class="tag">fix</span> ' : ''}${esc(x.text)}</li>`).join('')}</ol></details>`
113
+ : '';
114
+ const report = has
115
+ ? `<div class="md debug-report">${docHtml(d.markdown)}</div>`
116
+ : d?.loaded
117
+ ? asks.length
118
+ ? ''
119
+ : `<p class="hint">Say what is going wrong: a failure, instability at scale, slowness under load. The agent investigates in its session (it reads the code and logs, reproduces and measures where it can) and writes a report here: animated diagrams of the code path and the data flow with where it breaks, what it found with evidence, the likely causes, and the fixes it recommends. It changes no code until you press <b>Apply fixes</b>.</p>`
120
+ : '<p class="hint">Loading…</p>';
121
+ body.innerHTML = `<div class="side-scroll debug-view">
122
+ <form class="debug-ask" data-debug-form>
123
+ <textarea data-debug-text rows="2" ${a?.workdir ? '' : 'disabled'} placeholder="${has ? 'A follow-up: what you know, what to look at next, or which fixes to apply' : 'What should it debug? For example: E2E tests fail at max scale after about 20 minutes'}">${esc(draft)}</textarea>
124
+ ${ideas}
125
+ <div class="debug-actions">
126
+ <span class="hint">${has && d.at ? `Report updated ${esc(new Date(d.at).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }))}` : ''}</span>
127
+ <span class="spacer"></span>
128
+ ${has ? `<button type="button" class="small" data-debug-fix title="Ask the agent to make the report's fixes, verify each and record the result. Name the ones you want in the box (for example: 1 and 3), or leave it empty for the ones it recommends">Apply fixes</button>` : ''}
129
+ <button class="small primary" ${a?.workdir ? '' : 'disabled'}>${has ? 'Ask' : 'Debug'}</button>
130
+ </div>
131
+ </form>
132
+ ${status}${asked}${report}
133
+ </div>`;
134
+ const text = body.querySelector('[data-debug-text]');
135
+ if (typing) {
136
+ text.focus();
137
+ text.setSelectionRange(...typing);
138
+ }
139
+ body.querySelector('.side-scroll').scrollTop = top;
140
+ renderDiagrams(body);
141
+ }
142
+
143
+ async function sendDebug(payload) {
144
+ const id = st.agentId;
145
+ try {
146
+ agents.set(id, await api('POST', `/agents/${id}/debug`, payload));
147
+ drafts.delete(id);
148
+ const text = body.querySelector('[data-debug-text]');
149
+ if (text) text.value = '';
150
+ toast(payload.fix ? 'Asked the agent to apply the fixes' : 'Sent to the agent: it investigates in its session', 3000);
151
+ } catch (err) {
152
+ toast(`Error: ${err.message}`, 5000);
153
+ }
154
+ if (st.agentId === id && st.tab === 'debug') renderDebug(true);
155
+ }
156
+ // While the agent works, the report is read again now and then: it writes it as it goes.
157
+ setInterval(() => {
158
+ const a = agents.get(st.agentId);
159
+ if (st.on && st.tab === 'debug' && a?.debug && (a.runtime?.busy || a.outbox) && !files.get(`${a.id}:debug`)?.loading) loadDebug(a.specDocs?.debug ?? null);
160
+ }, 5000);
161
+
70
162
  // ------------------------------------------------------------ Docs
71
163
  function renderDocs(force) {
72
164
  const a = agents.get(st.agentId);
@@ -156,6 +248,13 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
156
248
  if (tab) return setTab(tab.dataset.side);
157
249
  if (e.target.closest('#side-close')) return toggle(false);
158
250
  if (e.target.closest('[data-side-reload]')) return loadChanges();
251
+ const idea = e.target.closest('[data-debug-idea]');
252
+ if (idea) {
253
+ const text = body.querySelector('[data-debug-text]');
254
+ text.value = idea.textContent;
255
+ return text.focus();
256
+ }
257
+ if (e.target.closest('[data-debug-fix]')) return sendDebug({ fix: body.querySelector('[data-debug-text]').value.trim() || true });
159
258
  try {
160
259
  if (e.target.closest('[data-side-explain]')) {
161
260
  agents.set(st.agentId, await api('POST', `/agents/${st.agentId}/docs/walkthrough?background=1`));
@@ -170,6 +269,20 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
170
269
  toast(`Error: ${err.message}`, 5000);
171
270
  }
172
271
  });
272
+ pane.addEventListener('submit', (e) => {
273
+ if (!e.target.matches('[data-debug-form]')) return;
274
+ e.preventDefault();
275
+ const question = body.querySelector('[data-debug-text]').value.trim();
276
+ if (question.length < 3) return toast('Say what to debug', 3000);
277
+ sendDebug({ question });
278
+ });
279
+ // Enter sends; Shift+Enter is a new line.
280
+ pane.addEventListener('keydown', (e) => {
281
+ if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.target.matches('[data-debug-text]')) {
282
+ e.preventDefault();
283
+ e.target.form.requestSubmit();
284
+ }
285
+ });
173
286
  pane.addEventListener('change', (e) => {
174
287
  if (!e.target.matches('[data-side-doc]')) return;
175
288
  st.doc = e.target.value;
@@ -211,6 +324,12 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
211
324
  }
212
325
  },
213
326
  showing: (tab) => st.on && Boolean(st.agentId) && st.tab === tab,
327
+ /** Open the split on a tab (Debug, from the agent's detail). */
328
+ open(tab) {
329
+ st.on = true;
330
+ pref.set('on', '1');
331
+ setTab(tab);
332
+ },
214
333
  /** What Listen reads in Changes: each change, scrolled to and marked as it is read. */
215
334
  listenParts() {
216
335
  const w = walkthroughOf(agents.get(st.agentId), st.changes?.diffHash);
@@ -225,6 +344,7 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
225
344
  agentChanged(a) {
226
345
  if (!st.on || a.id !== st.agentId) return;
227
346
  if (st.tab === 'docs') renderDocs(false);
347
+ else if (st.tab === 'debug') renderDebug(false);
228
348
  else if (st.tab === 'changes') renderChanges(false);
229
349
  },
230
350
  };
package/public/style.css CHANGED
@@ -181,6 +181,10 @@ body.term-max .topbar, body.term-max .sidebar, body.term-max .split-side,
181
181
  body.term-max #detail-body, body.term-max .split-term, body.term-max #placeholder { display: none !important; }
182
182
  body.term-max .layout { grid-template-columns: 1fr; }
183
183
  .term-wrap:fullscreen { width: 100vw; height: 100vh; }
184
+ /* The agent's name in the terminal bar, only when the detail with its name is out of view. */
185
+ .term-agent { display: none; flex-shrink: 0; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: #e6edf3; padding-right: 8px; border-right: 1px solid #30363d; }
186
+ body.term-max .term-agent, .term-wrap:fullscreen .term-agent { display: inline-block; }
187
+ .term-agent:empty { display: none !important; }
184
188
  .term-bar button.on { background: #262c38; border-color: #58a6ff; }
185
189
  .sidebar { border-right: 1px solid var(--border); overflow-y: auto; background: var(--panel); }
186
190
  .side-tabs { display: flex; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
@@ -545,6 +549,7 @@ dialog::backdrop { background: rgba(0, 0, 0, .45); }
545
549
  /* On a phone the terminal takes the whole screen; "Hide terminal" goes back. */
546
550
  .detail.with-term .term-wrap { position: fixed; inset: 0; z-index: 5; min-height: 0; padding-top: env(safe-area-inset-top); }
547
551
  .term-bar #term-title { display: none; }
552
+ .detail.with-term .term-agent { display: inline-block; max-width: 45vw; }
548
553
  /* The tabs get a row of their own, so + Shell and + Browser aren't squeezed out of view. */
549
554
  .term-bar { flex-wrap: wrap; row-gap: 6px; }
550
555
  .term-bar > .term-tabs { flex: 1 0 100%; }
@@ -983,6 +988,19 @@ form.dropping { outline: 2px dashed var(--accent, #6b8cff); outline-offset: 4px;
983
988
  .split-pane { flex: none; width: 0; }
984
989
  .split-pane::after { top: 0; bottom: 0; left: -4px; width: 8px; cursor: col-resize; }
985
990
  .split-pane[hidden], .side-pane[hidden] { display: none !important; }
991
+ /* Debug in the split: the question box, what was asked, then the agent's report. */
992
+ .debug-view { display: flex; flex-direction: column; gap: 10px; }
993
+ .debug-ask { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; z-index: 2; background: var(--bg); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
994
+ .debug-ask textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 44px; }
995
+ .debug-ideas { display: flex; flex-wrap: wrap; gap: 6px; }
996
+ .debug-ideas .chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: inherit; cursor: pointer; }
997
+ .debug-actions { display: flex; align-items: center; gap: 6px; }
998
+ .debug-status { margin: 0; }
999
+ .debug-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: debug-pulse 1.2s ease-in-out infinite; }
1000
+ @keyframes debug-pulse { 50% { opacity: .25; } }
1001
+ @media (prefers-reduced-motion: reduce) { .debug-dot { animation: none; } }
1002
+ .debug-asked summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
1003
+ .debug-asked ol { margin: 6px 0 0; padding-left: 22px; }
986
1004
  .side-pane { flex: none; width: var(--pane-w, 45%); display: flex; flex-direction: column; min-height: 0; border-left: 1px solid #30363d; background: var(--bg); color: var(--text); }
987
1005
  .side-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: #161a22; color: #c9d1d9; font-size: 12.5px; }
988
1006
  .side-bar button { color: #c9d1d9; border-color: #30363d; }
@@ -1370,6 +1388,26 @@ table.issues tr.stage-proposed.ticked { background: color-mix(in srgb, var(--acc
1370
1388
  table.issues tr.stage-proposed .issue-note { color: var(--accent); }
1371
1389
 
1372
1390
  /* ---------- Value */
1391
+ /* AI News: a day heading, then each release with its lab, summary and links. */
1392
+ .news-dialog { width: min(980px, calc(100% - 32px)); }
1393
+ .news-find { width: 150px; }
1394
+ .news-source.failed, .news-source.failed a { color: var(--red); }
1395
+ .news-day { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
1396
+ .news-list .news-day:first-child { margin-top: 4px; }
1397
+ .news-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
1398
+ .news-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--panel); }
1399
+ .news-item.new { border-left: 3px solid var(--accent); }
1400
+ .news-meta { font-size: 12px; margin-bottom: 4px; }
1401
+ .news-lab { font-weight: 600; }
1402
+ .news-lab[data-lab="Anthropic"] { color: #c15f3c; }
1403
+ .news-lab[data-lab="OpenAI"] { color: var(--green); }
1404
+ .news-lab[data-lab="Google"] { color: var(--accent); }
1405
+ .news-new { color: var(--accent); }
1406
+ .news-title { font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
1407
+ .news-title:hover { text-decoration: underline; }
1408
+ .news-summary { margin: 4px 0 0; line-height: 1.45; }
1409
+ .news-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12px; }
1410
+ .news-links a { overflow-wrap: anywhere; }
1373
1411
  .value-dialog { width: min(1180px, calc(100% - 32px)); }
1374
1412
  .value-dialog[open] { overflow: auto; }
1375
1413
  .value-period { margin: 0 0 8px; }
@@ -1447,6 +1485,8 @@ table.issues tr.kb-on td:first-child { box-shadow: inset 3px 0 0 var(--accent);
1447
1485
  .actions-table .action-text { font-weight: 600; color: var(--text); }
1448
1486
  .actions-table .action-meta { margin-top: 3px; }
1449
1487
  .actions-table .action-due { color: var(--yellow); font-weight: 600; }
1488
+ .actions-table .action-due.late { color: var(--red); }
1489
+ .issues-head .chip.late:not(.active) { border-color: var(--red); color: var(--red); }
1450
1490
  .actions-table tr.action-skip td:not(.issue-action), .actions-table tr.action-remove td:not(.issue-action), .actions-table tr.action-done td:not(.issue-action) { opacity: 0.65; }
1451
1491
 
1452
1492
  /* Report a problem or idea */
package/src/actions.js CHANGED
@@ -7,6 +7,7 @@
7
7
  // is ever sent to Slack or anywhere else from here.
8
8
 
9
9
  import crypto from 'node:crypto';
10
+ import { actionDue, dueWords } from './today.js';
10
11
 
11
12
  export const ACTION_SOURCES = { slack: 'Slack', gemini: 'Meeting notes', other: 'Other' };
12
13
  export const ACTION_STATES = ['open', 'assign', 'skip', 'snooze', 'done', 'remove'];
@@ -126,8 +127,10 @@ export class MyActions {
126
127
  rows() {
127
128
  const order = Object.fromEntries(Object.values(GROUP).map((g, i) => [g, i]));
128
129
  this.wake();
130
+ const now = new Date();
129
131
  return this.all
130
132
  .map((a) => {
133
+ const due = actionDue(a, now);
131
134
  const agent = a.agentId ? this.manager.store?.get?.(a.agentId) ?? null : null;
132
135
  const talk = a.discussId ? this.manager.store?.get?.(a.discussId) ?? null : null;
133
136
  return {
@@ -139,6 +142,9 @@ export class MyActions {
139
142
  from: a.from,
140
143
  when: a.when,
141
144
  due: a.due,
145
+ // The due date as a time, and in words ("overdue 2 days", "due Friday"), when it can be told.
146
+ dueAt: due?.toISOString() ?? null,
147
+ dueWords: dueWords(due, now),
142
148
  context: a.context,
143
149
  status: a.status,
144
150
  group: GROUP[a.status] ?? 'open',
package/src/brief.js CHANGED
@@ -719,7 +719,74 @@ export const DEMO_FILE = 'DEMO.html';
719
719
  export const demoPath = (agentId) => path.join(briefDir(agentId), DEMO_FILE);
720
720
  export const BENCH_FILE = 'BENCHMARK.md';
721
721
  export const benchPath = (agentId) => path.join(briefDir(agentId), BENCH_FILE);
722
- export const SPEC_DOCS = { intent: intentPath, spec: specPath, plan: planPath, designdoc: designPath, benchmark: benchPath, demo: demoPath };
722
+ export const DEBUG_FILE = 'DEBUG.md';
723
+ export const debugPath = (agentId) => path.join(briefDir(agentId), DEBUG_FILE);
724
+ export const SPEC_DOCS = { intent: intentPath, spec: specPath, plan: planPath, designdoc: designPath, benchmark: benchPath, demo: demoPath, debug: debugPath };
725
+
726
+ // ------------------------------------------------------------------ debug
727
+
728
+ // Debug: you say what to debug (a failure, instability at scale, slowness under load); the agent
729
+ // investigates in its own session and keeps a report at DEBUG.md with animated diagrams of the code
730
+ // path and the data flow, what it found with evidence, the likely causes and the fixes it
731
+ // recommends. It changes no code until you ask for a fix. The Debug tab shows the report as it grows.
732
+
733
+ const DEBUG_SHAPE = [
734
+ '# Debug: <short name of the problem>',
735
+ '## Summary',
736
+ 'Two or three sentences: what goes wrong, the most likely cause, and how sure you are.',
737
+ '## Symptoms',
738
+ 'What is seen and when (scale, load, timing, environment), and how to reproduce it. Only numbers that were measured or given.',
739
+ '## Code path',
740
+ 'One ```mermaid flowchart of the path the failing request, job or test takes through the real files and functions, where it breaks marked.',
741
+ '## Data flow',
742
+ 'One ```mermaid flowchart LR or sequenceDiagram of the data on that path (payloads, queues, caches, connections, stores): where it grows, waits, is dropped or goes wrong.',
743
+ '## Findings',
744
+ 'Numbered. Each with its evidence (file:line, a log line, a metric, or a command and its output) and "confirmed" (reproduced or measured) or "suspected".',
745
+ '## Root cause',
746
+ 'The causes, most likely first, each with a confidence (high, medium, low) and what would confirm or rule it out.',
747
+ '## Recommended fixes',
748
+ 'Numbered. Each: the change, where (file and function), effort (S, M, L), the risk, and how to verify it worked.',
749
+ '## Next checks',
750
+ 'What to measure or try next, and what you need from the user (logs, numbers, access).',
751
+ ].join('\n');
752
+
753
+ const DEBUG_DIAGRAMS =
754
+ 'Diagrams: valid Mermaid, at most about 15 nodes each, labels of five words or fewer (quote labels with punctuation, e.g. A["Parse (JSON)"]), no HTML in labels, real names from the code. ' +
755
+ 'Animate the path in every flowchart: give its edges ids and animate them, e.g.\n' +
756
+ ' A e1@--> B\n B e2@-->|"rows"| C\n e1@{ animate: true }\n e2@{ animate: true }\n' +
757
+ 'Mark where it breaks and what is only suspected: `classDef fault stroke:#ef4444,stroke-width:3px` and `classDef suspect stroke:#f59e0b,stroke-width:3px,stroke-dasharray:4`, then `class X fault` and `class Y suspect`. ' +
758
+ 'When timing, concurrency or load is the issue, add a "## Interleaving" section after Data flow with a sequenceDiagram of the order of events that breaks.';
759
+
760
+ /** The message that starts (or continues) a debug investigation in the agent's session. */
761
+ export function debugPrompt(file, question, { again = false } = {}) {
762
+ const q = String(question ?? '').trim();
763
+ if (again) {
764
+ return (
765
+ `Debug, continued: ${q}\n` +
766
+ `Carry on the investigation and bring the report at ${file} up to date: same sections, diagrams redrawn where the picture changed, findings re-marked confirmed or suspected. ` +
767
+ 'Still no changes to the repository code unless I ask for a fix. Answer me here in a few lines, and say what changed in the report.'
768
+ );
769
+ }
770
+ return (
771
+ `Debug this: ${q}\n` +
772
+ 'Investigate before proposing anything: read the code on the path, the logs and the tests; reproduce it if you can (run the failing test, a small load or a script), and measure instead of guessing. ' +
773
+ 'Do not change the repository code yet: instrumentation or reproduction scripts go outside the repository or are reverted when you are done. ' +
774
+ 'If you need facts only I have (the environment, the scale it fails at, logs), ask me here in a line or two, but first write what you can.\n' +
775
+ `Keep a report at ${file} (Markdown; the file is outside the repository: never copy it in or commit it). Write a first version as soon as you have the code path, and update it as you learn. Short and specific, in these sections:\n` +
776
+ `${DEBUG_SHAPE}\n${DEBUG_DIAGRAMS}\n` +
777
+ 'When the report is written, tell me in a few lines what you found and which fix you recommend first.'
778
+ );
779
+ }
780
+
781
+ /** The message that asks for the report's fixes to be made. */
782
+ export function debugFixPrompt(file, which) {
783
+ const w = String(which ?? '').trim();
784
+ return (
785
+ `Apply the fixes from your debug report at ${file}: ${w || 'the ones you recommend, the safest first'}.\n` +
786
+ 'Make each change, then verify it the way the report says (run the test, the reproduction or the load again) and compare with what you measured before. ' +
787
+ 'Then update the report: add a "## Fixes applied" section (what changed, where, and the result before and after), and re-mark the findings. If a fix does not hold up, revert it and say why.'
788
+ );
789
+ }
723
790
 
724
791
  /** INTENT.md: the request as given, and where it came from. */
725
792
  export function intentMarkdown(agent) {
package/src/cli.js CHANGED
@@ -731,21 +731,58 @@ export async function main(argv) {
731
731
  for (const x of r.failed) console.log(`${red('!')} ${bold(x.key)}: ${x.reason}`);
732
732
  });
733
733
 
734
+ program
735
+ .command('news')
736
+ .description("AI News: the frontier labs' latest releases, each summarized, with links")
737
+ .option('-r, --refresh', 'read the release notes again now (and summarize what is new), then print')
738
+ .option('-s, --search', 'with --refresh: also search the web for the top 10 labs now')
739
+ .option('--lab <lab>', 'only this lab (Anthropic, OpenAI, Google, …)')
740
+ .option('--days <n>', 'only the last n days', '7')
741
+ .option('--json', 'print JSON')
742
+ .action(async (opts) => {
743
+ await daemon();
744
+ let v = await api('GET', '/news');
745
+ if (!v.enabled) return console.log(dim('AI News is off: "news": { "enabled": true } in config.json'));
746
+ if (opts.refresh) {
747
+ v = await api('POST', '/news/refresh', opts.search ? { search: true } : {});
748
+ process.stderr.write(dim(opts.search ? 'Reading the release notes and searching the web (a few minutes)…\n' : 'Reading the release notes…\n'));
749
+ for (let i = 0; v.refreshing && i < 900; i++) {
750
+ await new Promise((r) => setTimeout(r, 2000));
751
+ v = await api('GET', '/news');
752
+ }
753
+ }
754
+ const since = new Date(Date.now() - Number(opts.days || 7) * 86_400_000).toISOString().slice(0, 10);
755
+ const items = v.items.filter((i) => i.date >= since && (!opts.lab || i.lab.toLowerCase() === String(opts.lab).toLowerCase()));
756
+ if (opts.json) return console.log(JSON.stringify({ ...v, items }, null, 2));
757
+ for (const s of v.sources.filter((x) => x.error)) console.log(yellow(`! ${s.label}: ${s.error}`));
758
+ if (!items.length) return console.log(dim(v.items.length ? 'Nothing in that range. --days 30 looks further back.' : 'No news yet. agentmgr news --refresh reads the release notes now.'));
759
+ let day = null;
760
+ for (const i of items) {
761
+ if (i.date !== day) console.log(`\n${bold((day = i.date))}`);
762
+ console.log(`${i.isNew ? green('● ') : ' '}${bold(i.lab)} ${dim(i.label)} ${i.title}`);
763
+ console.log(` ${i.summary ?? dim(i.lead ?? '')}`);
764
+ console.log(dim(` ${i.url}`));
765
+ }
766
+ });
767
+
734
768
  const actionsCmd = program.command('actions').description("Your action items from Slack and meeting notes (the assistant finds them): decide on each one");
735
769
  actionsCmd
736
770
  .command('ls', { isDefault: true })
737
- .description('The open ones (--all for the decided ones too)')
771
+ .description('The open ones (--all for the decided ones too, --due for the dues)')
738
772
  .option('--all', 'also assigned, skipped, done and removed')
773
+ .option('--due', 'the ones with a due date not done yet, soonest first (overdue at the top)')
739
774
  .option('--json', 'print JSON')
740
775
  .action(async (opts) => {
741
776
  await daemon();
742
777
  const v = await api('GET', '/actions');
743
- const rows = opts.all ? v.rows : v.rows.filter((r) => r.group === 'open');
778
+ const rows = opts.due
779
+ ? v.rows.filter((r) => r.due && ['open', 'assigned', 'skipped', 'snoozed'].includes(r.group)).sort((x, y) => (x.dueAt ? 0 : 1) - (y.dueAt ? 0 : 1) || String(x.dueAt ?? '').localeCompare(String(y.dueAt ?? '')))
780
+ : opts.all ? v.rows : v.rows.filter((r) => r.group === 'open');
744
781
  if (opts.json) return console.log(JSON.stringify({ ...v, rows }, null, 2));
745
- if (!rows.length) return console.log(dim(opts.all ? 'No action items yet.' : 'Nothing open. --all shows the decided ones.'));
782
+ if (!rows.length) return console.log(dim(opts.due ? 'Nothing with a due date is waiting on you.' : opts.all ? 'No action items yet.' : 'Nothing open. --all shows the decided ones.'));
746
783
  for (const r of rows) {
747
784
  console.log(`${bold(r.id)} ${r.group === 'open' ? yellow(r.text) : r.text}${r.group === 'open' ? '' : dim(` [${r.status}]`)}`);
748
- console.log(dim(` ${[r.sourceLabel, r.from && `from ${r.from}`, r.due && `due ${r.due}`, r.link].filter(Boolean).join(' · ')}`));
785
+ console.log(dim(` ${[r.sourceLabel, r.from && `from ${r.from}`, r.due && (/^overdue/.test(r.dueWords ?? '') ? red(r.dueWords) : (r.dueWords ?? `due ${r.due}`)), r.link].filter(Boolean).join(' · ')}`));
749
786
  }
750
787
  });
751
788
  actionsCmd
@@ -1418,6 +1455,30 @@ export async function main(argv) {
1418
1455
  console.log(`${green('✓')} queued for ${a.name}`);
1419
1456
  });
1420
1457
 
1458
+ program
1459
+ .command('debug')
1460
+ .description("Debug with an agent: say what to debug and it investigates in its session, keeping a report with diagrams of the code path and data flow, findings and recommended fixes. With no question: print the report")
1461
+ .argument('<agent>')
1462
+ .argument('[question...]', 'what to debug, or a follow-up once there is a report')
1463
+ .option('--fix [which]', "apply the report's fixes: which ones in words (\"1 and 3\"), or the ones it recommends")
1464
+ .action(async (ref, question, opts) => {
1465
+ await daemon();
1466
+ const a = await resolveAgent(ref);
1467
+ const q = question.join(' ').trim();
1468
+ if (opts.fix) {
1469
+ await api('POST', `/agents/${a.id}/debug`, { fix: opts.fix === true ? q || true : opts.fix });
1470
+ return console.log(`${green('✓')} asked ${a.name} to apply the fixes; it verifies each and records the result in the report`);
1471
+ }
1472
+ if (q) {
1473
+ await api('POST', `/agents/${a.id}/debug`, { question: q });
1474
+ return console.log(`${green('✓')} sent to ${a.name}; it investigates in its session. The report: agentmgr debug ${ref}`);
1475
+ }
1476
+ const r = await api('GET', `/agents/${a.id}/specs/debug`);
1477
+ if (!r.markdown) return console.log(dim(`No debug report yet. Start one: agentmgr debug ${ref} "what goes wrong"`));
1478
+ console.log(r.markdown.trimEnd());
1479
+ console.log(dim(`\n(updated ${new Date(r.updatedAt).toLocaleString()})`));
1480
+ });
1481
+
1421
1482
  program
1422
1483
  .command('fork')
1423
1484
  .description("A new agent with this one's code and conversation, in its own worktree")
package/src/config.js CHANGED
@@ -72,6 +72,8 @@ const DEFAULTS = {
72
72
  // and micro benchmarks of the code it changed, before and after. Per agent: demoPage, benchmarks.
73
73
  // Each morning (weekdays), a spoken standup of the agents' news; see standup.js.
74
74
  standup: { enabled: true, at: '09:00', weekends: false, ai: true, notify: true },
75
+ // AI News: the frontier labs' latest releases, summarized; see NEWS_DEFAULTS in news.js for every field.
76
+ news: { enabled: true },
75
77
  demoPage: false,
76
78
  benchmarks: false,
77
79
  // The AI judge (stuck, idle screens, reviews); see JUDGE_DEFAULTS in judge.js for every field.
@@ -119,6 +119,13 @@ export default {
119
119
  return args;
120
120
  },
121
121
 
122
+ /** A one-shot call that may use only these of Claude Code's own tools (WebSearch, WebFetch), no MCP servers. */
123
+ webArgs: (config, { model, tools } = {}) => {
124
+ const args = ['-p', '--tools', tools.join(','), '--allowedTools', tools.join(','), '--strict-mcp-config', '--no-session-persistence', '--output-format', 'text'];
125
+ if (model) args.push('--model', model);
126
+ return args;
127
+ },
128
+
122
129
  /** Variables a nested Claude session would otherwise inherit from a parent one. */
123
130
  stripEnv: ['CLAUDECODE', 'CLAUDE_CODE_CHILD_SESSION', 'CLAUDE_CODE_ENTRYPOINT'],
124
131
  };
package/src/manager.js CHANGED
@@ -32,6 +32,9 @@ import {
32
32
  intentMarkdown,
33
33
  intentPath,
34
34
  readSpecDoc,
35
+ debugPath,
36
+ debugPrompt,
37
+ debugFixPrompt,
35
38
  specDocsInfo,
36
39
  specPath,
37
40
  specPrompt,
@@ -830,10 +833,32 @@ export class AgentManager extends EventEmitter {
830
833
  /** One of an agent's intent, spec and plan files. */
831
834
  specDoc(ref, name) {
832
835
  const agent = this.mustGet(ref);
833
- if (!['intent', 'spec', 'plan', 'designdoc', 'benchmark'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec, plan, designdoc or benchmark)'), { status: 400 });
836
+ if (!['intent', 'spec', 'plan', 'designdoc', 'benchmark', 'debug'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec, plan, designdoc, benchmark or debug)'), { status: 400 });
834
837
  return readSpecDoc(agent.id, name) ?? { name, markdown: null };
835
838
  }
836
839
 
840
+ /**
841
+ * Debug: ask the agent to investigate something in its session and keep a report (DEBUG.md) with
842
+ * diagrams of the code path and data flow, findings and recommended fixes. `question`: what to
843
+ * debug, or a follow-up once there is a report. `fix`: apply the report's fixes (which ones, in
844
+ * words; true for the ones it recommends). The message waits in the agent's queue like any other.
845
+ */
846
+ debug(ref, { question = '', fix = null } = {}) {
847
+ const agent = this.mustGet(ref);
848
+ if (!agent.workdir || agent.status === 'preparing') throw Object.assign(new Error('The agent has no folder to debug in yet'), { status: 409 });
849
+ const q = String(question ?? '').replace(/\s+/g, ' ').trim().slice(0, 2000);
850
+ const has = Boolean(readSpecDoc(agent.id, 'debug')?.markdown?.trim());
851
+ if (fix && !has) throw Object.assign(new Error('There is no debug report yet: say what to debug first'), { status: 409 });
852
+ if (!fix && q.length < 3) throw Object.assign(new Error('Say what to debug'), { status: 400 });
853
+ fs.mkdirSync(briefDir(agent.id), { recursive: true });
854
+ const file = path.join(fs.realpathSync(briefDir(agent.id)), path.basename(debugPath(agent.id)));
855
+ const which = fix === true ? '' : String(fix ?? '').replace(/\s+/g, ' ').trim().slice(0, 500);
856
+ this.tell(agent.id, fix ? debugFixPrompt(file, which) : debugPrompt(file, q, { again: has }), { source: 'debug' });
857
+ // What was asked, newest last, for the Debug tab.
858
+ const asks = [...(agent.debug?.asks ?? []), { text: fix ? `Apply fixes${which ? `: ${which}` : ''}` : q, kind: fix ? 'fix' : has ? 'follow-up' : 'debug', at: now() }].slice(-20);
859
+ return this.view(this.patch(agent.id, { debug: { asks, startedAt: agent.debug?.startedAt ?? now() } }));
860
+ }
861
+
837
862
  /** The agent's sample demo page (HTML), once it has written one. */
838
863
  demoPage(ref) {
839
864
  const agent = this.mustGet(ref);
@@ -2324,6 +2349,14 @@ export class AgentManager extends EventEmitter {
2324
2349
  // A new or revised plan waits for review again, unless it was already approved (then it's a progress update).
2325
2350
  if (file) this.patch(id, { planReview: { ...agent.planReview, ...file, status: agent.planReview.status === 'approved' ? 'approved' : 'review' } });
2326
2351
  }
2352
+ // A debug report written or updated: the page hears, and draws it.
2353
+ if (agent.debug) {
2354
+ let at = null;
2355
+ try {
2356
+ at = fs.statSync(debugPath(id)).mtime.toISOString();
2357
+ } catch {}
2358
+ if (at !== (agent.debug.reportAt ?? null)) this.patch(id, { debug: { ...this.store.get(id).debug, reportAt: at } });
2359
+ }
2327
2360
  }
2328
2361
 
2329
2362
  // -------------------------------------------------------------- plan review
@@ -2522,13 +2555,17 @@ export class AgentManager extends EventEmitter {
2522
2555
  }
2523
2556
 
2524
2557
  /** One tool-less, read-only call to an engine; resolves to its text output. */
2525
- oneShot(agent, text, { engine, model, timeoutMs = 300_000, tools, cwd = paths.home }) {
2558
+ oneShot(agent, text, { engine, model, timeoutMs = 300_000, tools, web, cwd = paths.home }) {
2526
2559
  // Some engines take the prompt as an argument instead of on stdin, and some need their extra
2527
2560
  // arguments after a subcommand (oneShotExtra: they place them). `tools`: Claude Code only, a
2528
2561
  // call that may use just these connector tools (and none of its own). `cwd`: where it runs, which
2529
- // decides the project MCP servers it loads.
2562
+ // decides the project MCP servers it loads. `web`: Claude Code only, a call that may use just
2563
+ // these of its own tools (WebSearch, WebFetch).
2564
+ if (web && !engine.webArgs) return Promise.reject(new Error(`${engine.label} can't search the web here; Claude Code can`));
2530
2565
  const extra = engine.extraArgs(this.config);
2531
- const args = tools
2566
+ const args = web
2567
+ ? [...extra, ...engine.webArgs(this.config, { model, tools: web })]
2568
+ : tools
2532
2569
  ? [...extra, ...engine.connectorArgs(this.config, { model, tools })]
2533
2570
  : engine.oneShotExtra ? engine.oneShotArgs(this.config, { model, prompt: text, extra }) : [...extra, ...engine.oneShotArgs(this.config, { model, prompt: text })];
2534
2571
  return new Promise((resolve, reject) => {