ai-agentmanager 1.22.0 → 1.23.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.23.0 (2026-11-06)
4
+
5
+ - **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`).
6
+
3
7
  ## 1.22.0 (2026-11-06)
4
8
 
5
9
  - **Value.** A **Value** button (or `v`) shows what the delivered work is worth, by day, week, month and quarter: engineering hours saved (valued at your loaded hourly rate), other savings, potential revenue and strategic weight, against the AI cost and your own time (leverage, value per AI dollar). Each delivered item (its pull request merged, or done without one) gets an estimate from one short model call, with reasons; correct any figure and yours win, marked ✎ in reports. Weekly, monthly and quarterly reports (daily if you like) go to Slack and, if you choose, a Google Doc, and are saved in `~/.agentmanager/value` with `value.csv`. `agentmgr value` (`edit`, `estimate`, `report`, `set`).
package/README.md CHANGED
@@ -963,6 +963,28 @@ agentmgr designs --waiting # only the ones waiting for your review
963
963
  agentmgr designs --markdown # a list to paste
964
964
  ```
965
965
 
966
+ ### Reviews: other people's pull requests
967
+
968
+ When you're a reviewer on someone else's pull request, a reviewer agent does the first careful pass for you. **Reviews** in the top bar (or `g`) lists pull requests where GitHub has your review requested; tick some and **Review with agents**, or paste any PR link and **Review**. The project is the one whose repository the PR is in.
969
+
970
+ A reviewer is read-only. It checks out the PR's head, reads the description, discussion and diff and as much of the surrounding code as it needs, and may run the tests; it never commits, pushes, approves or comments. It writes:
971
+
972
+ - **A verdict:** approve, approve with nits, or **blocked**, with the reason. Any open blocker means blocked.
973
+ - **Approval blockers:** each with its file and line, why it fails (correctness, security, data loss, a breaking change, missing tests for risky logic, not doing what the PR says), and what would resolve it. Style is never a blocker.
974
+ - **Critical questions for the author:** what the code and description don't answer, such as intent, edge cases, rollout and rollback.
975
+ - **Risks, test gaps and nits**, kept apart from the blockers.
976
+
977
+ Open a review to read it, ask the reviewer about it in its session, or hear it with **🔊 Explain**. Tick what to send (open blockers and questions are ticked to start with) and **Post as pending review**: it becomes a draft review on GitHub under your name, with each item on its line, that only you see until you submit it there. A line outside the diff goes in the review's text instead. **Copy** gives the ticked items as Markdown. When the author pushes, the review is marked **New commits** and the reviewer re-checks each blocker, marking the fixed ones resolved.
978
+
979
+ With **GitHub reviews** on in **Assistant**, it starts reviewers for new requests by itself, unless **Let me pick** is on; then they wait in **Reviews** for you to tick.
980
+
981
+ ```bash
982
+ agentmgr review https://github.com/acme/api/pull/42 # start a reviewer (--project, --notes)
983
+ agentmgr reviews # the list, with verdicts
984
+ agentmgr reviews show <agent> # blockers, questions, risks
985
+ agentmgr reviews post <agent> b1 q2 # a pending review with those items
986
+ ```
987
+
966
988
  ## Triggers
967
989
 
968
990
  Start agents from where the work lives, with no session watching and no tokens spent on it. **Assistant → Triggers…**, or `agentmgr triggers`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "Run background coding agents (Claude Code, Codex) per intent, and keep track of them from a web UI, your phone or the CLI",
5
5
  "keywords": [
6
6
  "claude",
package/public/app.js CHANGED
@@ -28,6 +28,7 @@ import { initStandup } from '/standup.js';
28
28
  import { initIssues } from '/issues.js';
29
29
  import { reviewSpeech } from '/prvoice.js';
30
30
  import { initDesigns } from '/designs.js';
31
+ import { initReviews } from '/reviews.js';
31
32
  import { initValue } from '/value.js';
32
33
  import { initCodeMap } from '/codemap.js';
33
34
  import { initKeys } from '/keys.js';
@@ -56,8 +57,9 @@ const watchOnLoad = hashId === 'watch';
56
57
  const standupOnLoad = hashId === 'standup';
57
58
  const mapOnLoad = hashId === 'map';
58
59
  const valueOnLoad = hashId === 'value';
60
+ const reviewsOnLoad = hashId === 'reviews';
59
61
  let watchShown = false;
60
- let selectedId = (watchOnLoad || standupOnLoad || mapOnLoad || valueOnLoad ? null : hashId) || null;
62
+ let selectedId = (watchOnLoad || standupOnLoad || mapOnLoad || valueOnLoad || reviewsOnLoad ? null : hashId) || null;
61
63
  let openTermOnLoad = hashView === 'term' || hashView === 'code' || isShell(hashView) || isBrowser(hashView);
62
64
  let filterText = '';
63
65
  // "Only agents created in the last N days": remembered in this browser.
@@ -229,6 +231,9 @@ const designsUi = initDesigns({
229
231
  openDoc: (id) => (showTab('agents'), select(id), openDoc(id, 'designdoc')),
230
232
  });
231
233
  $('#designs-btn').onclick = () => designsUi.open();
234
+ // Reviews: other people's pull requests, reviewed by agents for you.
235
+ const reviewsUi = initReviews({ api, $, esc, ago, toast: (m, ms) => toast(m, ms), openAgent: (id) => (showTab('agents'), select(id)) });
236
+ $('#reviews-btn').onclick = () => reviewsUi.open();
232
237
  // Value: what the delivered work is worth, for you and for management.
233
238
  const valueUi = initValue({ api, $, esc, toast: (m, ms) => toast(m, ms), openAgent: (id) => (showTab('agents'), select(id)) });
234
239
  $('#value-btn').onclick = () => valueUi.open();
@@ -275,6 +280,7 @@ function shortcut(act) {
275
280
  if (act === 'map') return $('#map-btn').click();
276
281
  if (act === 'issues') return issuesUi.open();
277
282
  if (act === 'designs') return designsUi.open();
283
+ if (act === 'reviews') return reviewsUi.open();
278
284
  if (act === 'value') return valueUi.open();
279
285
  if (act.startsWith('tab:')) return showTab(act.slice(4));
280
286
  return false;
@@ -729,6 +735,7 @@ bindListen((id) => {
729
735
  else if (what === 'score') parts = a?.docs?.scorecard?.data ? scorecardSpeech(a.docs.scorecard) : null;
730
736
  else if (what === 'sidewalk') parts = sidePane?.listenParts();
731
737
  else if (what === 'prvoice') parts = reviewSpeech(a, issuesUi.about(agentId));
738
+ else if (what === 'reviewer') parts = reviewsUi.speech(agentId);
732
739
  if (!parts?.length || !play(id, parts)) toast('Nothing to read aloud here (or this browser has no speech)');
733
740
  });
734
741
 
@@ -4140,6 +4147,11 @@ function handleEvent(msg) {
4140
4147
  watchShown = true;
4141
4148
  mapUi.show(true);
4142
4149
  }
4150
+ if (reviewsOnLoad && !watchShown) {
4151
+ watchShown = true;
4152
+ history.replaceState(null, '', '#');
4153
+ reviewsUi.open();
4154
+ }
4143
4155
  if (valueOnLoad && !watchShown) {
4144
4156
  watchShown = true;
4145
4157
  history.replaceState(null, '', '#');
@@ -4162,6 +4174,7 @@ function handleEvent(msg) {
4162
4174
  if (msg.agent.builds) builtUi.sessionChanged(msg.agent);
4163
4175
  issuesUi.changed();
4164
4176
  designsUi.changed();
4177
+ if (msg.agent.reviewing) reviewsUi.changed();
4165
4178
  // The detail, terminal and document views show one agent; another agent's update leaves them be.
4166
4179
  return invalidate([
4167
4180
  'list', 'backlog', 'land', 'inbox', 'race', 'team',
package/public/index.html CHANGED
@@ -34,6 +34,7 @@
34
34
  <button id="standup-btn" title="Today's standup: each agent's news read aloud, and what they need from you">Standup <span id="standup-dot" class="assistant-dot" hidden></span></button>
35
35
  <button id="issues-btn" title="Jira: every issue an agent works on, with its Jira status, pull request and agent, the ones waiting for your review first">Jira <span id="issues-count" class="badge ready"></span></button>
36
36
  <button id="designs-btn" title="Designs: every agent's design doc with its summary and links, the ones waiting for your review first">Designs <span id="designs-count" class="badge ready"></span></button>
37
+ <button id="reviews-btn" title="Reviews: pull requests you review. Reviewer agents ask the critical questions and find what blocks approval; you post what you pick">Reviews <span id="reviews-count" class="badge ready"></span></button>
37
38
  <button id="value-btn" title="Value: what the delivered work is worth, by day, week, month and quarter, against the AI cost and your time; reports for management">Value</button>
38
39
  <button id="map-btn" title="The codebase map: where each agent is changing and reading code, and who is about to collide">Map</button>
39
40
  <button id="watch-btn" title="Running agents' sessions side by side, live: follow them all without clicking from one to the next">Watch</button>
@@ -385,6 +386,9 @@
385
386
  <dialog id="designs-dialog" class="issues-dialog" aria-label="Design docs">
386
387
  <div id="designs-body"></div>
387
388
  </dialog>
389
+ <dialog id="reviews-dialog" class="issues-dialog" aria-label="Reviews">
390
+ <div id="reviews-body"></div>
391
+ </dialog>
388
392
  <dialog id="value-dialog" class="issues-dialog value-dialog" aria-label="Value">
389
393
  <div id="value-body"></div>
390
394
  </dialog>
package/public/keys.js CHANGED
@@ -20,6 +20,7 @@ export const SHORTCUTS = [
20
20
  [['m'], 'Map: where agents are in the code', 'map'],
21
21
  [['i'], 'Jira: issues waiting for your review', 'issues'],
22
22
  [['d'], 'Designs: agents\' design docs', 'designs'],
23
+ [['g'], 'Reviews: pull requests you review', 'reviews'],
23
24
  [['v'], 'Value: what the work is worth', 'value'],
24
25
  [['1'], 'Agents tab', 'tab:agents'],
25
26
  [['2'], 'Inbox: what needs you', 'tab:inbox'],
@@ -39,11 +40,11 @@ export const SHORTCUTS = [
39
40
  // A single key, as an event names it, to its action.
40
41
  export const SINGLE = {
41
42
  j: 'next', k: 'prev', Enter: 'terminal', t: 'terminal',
42
- r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', d: 'designs', v: 'value', '?': 'help',
43
+ r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', d: 'designs', g: 'reviews', v: 'value', '?': 'help',
43
44
  1: 'tab:agents', 2: 'tab:inbox', 3: 'tab:backlog', 4: 'tab:land', 5: 'tab:built',
44
45
  };
45
46
  // While Watch is open: only what makes sense there.
46
- const ON_WATCH = new Set(['new', 'ask', 'watch', 'standup', 'map', 'issues', 'designs', 'value', 'help']);
47
+ const ON_WATCH = new Set(['new', 'ask', 'watch', 'standup', 'map', 'issues', 'designs', 'reviews', 'value', 'help']);
47
48
 
48
49
  /** Typing somewhere: a field, an editor or a terminal (xterm types through a textarea). */
49
50
  const typing = (el) => Boolean(el?.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"], .xterm, .cm-editor'));
@@ -0,0 +1,318 @@
1
+ // Reviews: pull requests you review. Reviewer agents read someone else's change, ask the critical
2
+ // questions and find what blocks approval; you pick what to send and post it as a pending review
3
+ // under your name (or copy it). PRs where your review is requested and no reviewer has started
4
+ // come first, with a box to tick.
5
+
6
+ import { listenHtml, speakable } from './speak.js';
7
+
8
+ const VERDICT = { approve: ['Approve', 'ok'], approve_with_nits: ['Approve with nits', 'ok'], blocked: ['Blocked', 'bad'] };
9
+ const CHECKS = { passed: ['✓', 'Checks pass'], failed: ['✗', 'Checks failing'], running: ['●', 'Checks running'] };
10
+ const CATEGORY = { correctness: 'Correctness', security: 'Security', data: 'Data', breaking: 'Breaking change', tests: 'Tests', performance: 'Performance', design: 'Design', other: 'Other' };
11
+
12
+ /** The verdict, blockers and questions as parts to read aloud. */
13
+ export function reviewerSpeech(row) {
14
+ const r = row?.review;
15
+ if (!r) return [];
16
+ const said = (s) => speakable(String(s ?? '')).replace(/\s+/g, ' ').trim();
17
+ const open = r.blockers.filter((b) => b.status === 'open');
18
+ const parts = [said(`Review of pull request ${row.pr.number}${row.pr.title ? `, ${row.pr.title}` : ''}. Verdict: ${VERDICT[r.verdict]?.[0] ?? 'none yet'}. ${r.why}`)];
19
+ if (r.summary) parts.push(said(`What it does: ${r.summary}`));
20
+ if (open.length) parts.push(said(`${open.length} blocker${open.length === 1 ? '' : 's'}.`), ...open.slice(0, 5).map((b, i) => said(`${i + 1}: ${b.title}. ${b.why}`)));
21
+ const resolved = r.blockers.length - open.length;
22
+ if (resolved) parts.push(`${resolved} earlier blocker${resolved === 1 ? ' is' : 's are'} resolved.`);
23
+ if (r.questions.length) parts.push(said(`Questions for the author: ${r.questions.slice(0, 4).map((q) => q.question).join(' ')}`));
24
+ if (row.stale) parts.push('The author pushed since this review; the reviewer is checking again.');
25
+ return parts.filter(Boolean);
26
+ }
27
+
28
+ export function initReviews({ api, $, esc, ago, openAgent, toast }) {
29
+ const dialog = $('#reviews-dialog');
30
+ const body = $('#reviews-body');
31
+ const ext = (label, url, title = '') => `<a href="${esc(url)}" target="_blank" rel="noopener" title="${esc(title)}">${esc(label)} ↗</a>`;
32
+ let rows = null;
33
+ let loading = false;
34
+ let loadedAt = 0;
35
+ let again = null;
36
+ let openId = null;
37
+ // The open review's items picked to send, by agent id.
38
+ const picks = new Map();
39
+ // Requested PRs ticked to start a reviewer, by URL.
40
+ const ticked = new Set();
41
+ let busy = false;
42
+
43
+ async function load({ quiet = false, fresh = false } = {}) {
44
+ if (loading) return;
45
+ loading = true;
46
+ try {
47
+ rows = (await api('GET', `/reviews${fresh ? '?fresh=1' : ''}`)).rows;
48
+ loadedAt = Date.now();
49
+ } catch (e) {
50
+ if (!quiet) toast?.(e.message, 5000);
51
+ } finally {
52
+ loading = false;
53
+ }
54
+ badge();
55
+ render();
56
+ }
57
+
58
+ /** The button's count: requests with no reviewer, blocked reviews, and ones the author pushed to. */
59
+ function badge() {
60
+ const n = rows ? rows.filter((r) => !r.agent || r.stale || r.review?.verdict).filter((r) => !r.posted || r.stale).length : 0;
61
+ const el = $('#reviews-count');
62
+ if (el) {
63
+ el.textContent = n ? String(n) : '';
64
+ el.title = n ? `${n} pull request${n === 1 ? '' : 's'} to look at` : '';
65
+ }
66
+ }
67
+
68
+ const prLabel = (r) => `${r.pr.repo ? `${esc(r.pr.repo)}` : ''}#${esc(r.pr.number)}`;
69
+
70
+ function verdictHtml(r) {
71
+ if (!r.agent) return '<span class="verdict new">Requested</span>';
72
+ const v = r.review?.verdict;
73
+ if (!v) return `<span class="verdict wait">${r.agent.busy || r.status === 'reviewing' ? 'Reviewing…' : 'No review yet'}</span>`;
74
+ const n = r.review.openBlockers;
75
+ return `<span class="verdict ${VERDICT[v][1]}">${VERDICT[v][0]}${n ? `: ${n} blocker${n === 1 ? '' : 's'}` : ''}</span>`;
76
+ }
77
+
78
+ function defaults(r) {
79
+ if (!picks.has(r.agent.id)) picks.set(r.agent.id, new Set([...r.review.blockers.filter((b) => b.status === 'open').map((b) => b.id), ...r.review.questions.map((q) => q.id)]));
80
+ return picks.get(r.agent.id);
81
+ }
82
+
83
+ const where = (x) => (x.file ? `<code class="rv-where">${esc(x.file)}${x.line ? `:${esc(x.line)}` : ''}</code>` : '');
84
+ const box = (id, picked, label) => `<input type="checkbox" data-rv-pick="${esc(id)}" ${picked.has(id) ? 'checked' : ''} aria-label="Send: ${esc(label)}" />`;
85
+
86
+ function detail(r) {
87
+ const rv = r.review;
88
+ if (!rv) return `<p class="hint">The reviewer is reading the change. Its blockers and questions show here when it has written them.</p>`;
89
+ const picked = defaults(r);
90
+ const blockers = rv.blockers.map(
91
+ (b) => `<li class="rv-item ${b.status}">
92
+ ${b.status === 'open' ? box(b.id, picked, b.title) : '<span class="rv-done" title="Resolved">✓</span>'}
93
+ <div><strong>${esc(b.title)}</strong> <span class="rv-cat">${esc(CATEGORY[b.category] ?? b.category)}</span> ${where(b)}${b.status === 'resolved' ? ' <span class="hint">resolved</span>' : ''}
94
+ <p>${esc(b.why)}</p>${b.unblock ? `<p class="hint">To resolve: ${esc(b.unblock)}</p>` : ''}</div></li>`,
95
+ );
96
+ const questions = rv.questions.map((q) => `<li class="rv-item">${box(q.id, picked, q.question)}<div>${esc(q.question)} ${where(q)}${q.why ? `<p class="hint">${esc(q.why)}</p>` : ''}</div></li>`);
97
+ const nits = rv.nits.map((n) => `<li class="rv-item">${box(n.id, picked, n.text)}<div>${esc(n.text)} ${where(n)}</div></li>`);
98
+ const plain = (title, xs) => (xs.length ? `<h4>${title}</h4><ul class="rv-plain">${xs.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` : '');
99
+ const posted = r.posted ? `<p class="hint">Posted ${esc(ago(r.posted.at))} as a pending review: ${ext('finish it on GitHub', r.posted.url)}${r.posted.moved ? ` (${r.posted.moved} line comment(s) went in the body)` : ''}</p>` : '';
100
+ return `
101
+ <p class="rv-why"><strong>${esc(VERDICT[rv.verdict]?.[0] ?? 'No verdict yet')}.</strong> ${esc(rv.why)}</p>
102
+ ${rv.summary ? `<p>${esc(rv.summary)}</p>` : ''}
103
+ ${r.stale ? '<p class="rv-stale">The author pushed since this review. The reviewer has been told to check again.</p>' : ''}
104
+ ${blockers.length ? `<h4>Blockers</h4><ul class="rv-list">${blockers.join('')}</ul>` : '<h4>Blockers</h4><p class="hint">None found.</p>'}
105
+ ${questions.length ? `<h4>Questions for the author</h4><ul class="rv-list">${questions.join('')}</ul>` : ''}
106
+ ${plain('Risks', rv.risks)}
107
+ ${plain('Test gaps', rv.testGaps)}
108
+ ${nits.length ? `<h4>Nits</h4><ul class="rv-list">${nits.join('')}</ul>` : ''}
109
+ ${rv.tests ? `<h4>Tests</h4><p>${esc(rv.tests)}</p>` : ''}
110
+ ${posted}
111
+ <div class="rv-actions">
112
+ <button class="primary small" data-rv="post" ${picked.size && !busy ? '' : 'disabled'} title="Create a pending review on GitHub, under your name, with the ticked items. Nothing is visible to the author until you submit it there.">Post ${picked.size} as pending review</button>
113
+ <button class="small" data-rv="copy" title="Copy the ticked items as Markdown">Copy</button>
114
+ ${listenHtml(`reviewer:${r.agent.id}`, { title: 'Read the verdict, blockers and questions aloud', label: 'Explain' })}
115
+ </div>`;
116
+ }
117
+
118
+ function card(r) {
119
+ const check = r.pr.checks?.state && CHECKS[r.pr.checks.state] ? ` <span class="checks ${esc(r.pr.checks.state)}" title="${CHECKS[r.pr.checks.state][1]}">${CHECKS[r.pr.checks.state][0]}</span>` : '';
120
+ const state = r.pr.state && r.pr.state !== 'OPEN' ? ` <span class="hint">${esc(r.pr.state.toLowerCase())}</span>` : r.pr.isDraft ? ' <span class="hint">draft</span>' : '';
121
+ if (!r.agent) {
122
+ return `<article class="rv-card requested ${ticked.has(r.pr.url) ? 'ticked' : ''}">
123
+ <header>
124
+ <input type="checkbox" data-rv-start="${esc(r.pr.url)}" ${ticked.has(r.pr.url) ? 'checked' : ''} aria-label="Start a reviewer for ${esc(r.pr.title ?? r.pr.url)}" />
125
+ <h3>${ext(`${r.pr.repo ?? ''}#${r.pr.number}`, r.pr.url)} ${esc(r.pr.title ?? '')}</h3>
126
+ ${verdictHtml(r)}
127
+ </header>
128
+ <div class="design-meta"><span class="hint">${r.pr.author ? `by ${esc(r.pr.author)} · ` : ''}your review is requested · ${esc(ago(r.updatedAt))}</span></div>
129
+ </article>`;
130
+ }
131
+ const isOpen = openId === r.agent.id;
132
+ const dot = r.agent.busy ? '<span class="dot busy" title="Working"></span>' : r.agent.running ? '<span class="dot idle" title="Session open"></span>' : '';
133
+ return `<article class="rv-card ${esc(r.review?.verdict ?? 'pending')} ${r.stale ? 'stale' : ''}">
134
+ <header data-rv-toggle="${esc(r.agent.id)}" role="button" tabindex="0" aria-expanded="${isOpen}">
135
+ <span class="rv-caret">${isOpen ? '▾' : '▸'}</span>
136
+ <h3>${prLabel(r)} ${esc(r.pr.title ?? '')}${check}${state}</h3>
137
+ ${r.stale ? '<span class="verdict wait" title="The author pushed since this review">New commits</span>' : ''}
138
+ ${r.posted ? '<span class="hint">posted</span>' : ''}
139
+ ${verdictHtml(r)}
140
+ </header>
141
+ <div class="design-meta">
142
+ ${ext('Pull request', r.pr.url)}
143
+ <button class="link" data-rv-open="${esc(r.agent.id)}" title="Open the reviewer's session: ask it about the change">${dot}${esc(r.agent.name)}</button>
144
+ ${r.review ? `<span class="hint">${r.review.questions.length} question${r.review.questions.length === 1 ? '' : 's'} · ${esc(ago(r.updatedAt))}</span>` : ''}
145
+ </div>
146
+ ${isOpen ? `<div class="rv-detail">${detail(r)}</div>` : ''}
147
+ </article>`;
148
+ }
149
+
150
+ function render() {
151
+ if (!dialog.open) return;
152
+ if (!rows) {
153
+ body.innerHTML = '<p class="hint">Loading…</p>';
154
+ return;
155
+ }
156
+ const requested = rows.filter((r) => !r.agent);
157
+ const mine = rows.filter((r) => r.agent);
158
+ const focused = document.activeElement?.dataset?.rv === 'url' ? document.activeElement.value : null;
159
+ body.innerHTML = `
160
+ <div class="issues-head">
161
+ <h2>Reviews</h2>
162
+ <form class="rv-new" data-rv-form>
163
+ <input type="url" data-rv="url" placeholder="Pull request link to review" aria-label="Pull request link" required />
164
+ <button class="small primary" type="submit" title="Start a reviewer agent: it reads the change and finds what blocks approval; nothing is posted">Review</button>
165
+ </form>
166
+ <span class="spacer"></span>
167
+ <button class="small" data-rv="refresh" title="Look again now, including GitHub">↻</button>
168
+ <button class="small" data-rv="close" title="Close (Esc)">Close</button>
169
+ </div>
170
+ ${requested.length ? `<div class="issues-pickbar"><span>${requested.length} pull request${requested.length === 1 ? '' : 's'} where your review is requested.</span>
171
+ <button class="small primary" data-rv="start" ${ticked.size && !busy ? '' : 'disabled'}>Review ${ticked.size || ''} with agents</button>
172
+ <button class="small" data-rv="dismiss" ${ticked.size && !busy ? '' : 'disabled'} title="Take the ticked ones off this list">Dismiss</button></div>` : ''}
173
+ ${rows.length ? `<div class="designs-list">${[...requested, ...mine].map(card).join('')}</div>` : '<p class="hint issues-empty">No reviews yet. Paste a pull request link above, or turn on "GitHub reviews" in Assistant to find the ones where your review is requested.</p>'}`;
174
+ if (focused !== null) {
175
+ const u = body.querySelector('[data-rv="url"]');
176
+ u.value = focused;
177
+ u.focus();
178
+ }
179
+ }
180
+
181
+ const rowOf = (id) => rows?.find((r) => r.agent?.id === id) ?? null;
182
+
183
+ async function copy(r) {
184
+ const picked = picks.get(r.agent.id) ?? new Set();
185
+ const rv = r.review;
186
+ const lines = [`Review of ${r.pr.url}`, `${VERDICT[rv.verdict]?.[0] ?? ''}: ${rv.why}`];
187
+ for (const b of rv.blockers.filter((x) => picked.has(x.id))) lines.push(`- **Blocker: ${b.title}**${b.file ? ` (\`${b.file}${b.line ? `:${b.line}` : ''}\`)` : ''}: ${b.why}${b.unblock ? ` To resolve: ${b.unblock}` : ''}`);
188
+ for (const q of rv.questions.filter((x) => picked.has(x.id))) lines.push(`- **Question:** ${q.question}${q.file ? ` (\`${q.file}${q.line ? `:${q.line}` : ''}\`)` : ''}`);
189
+ for (const n of rv.nits.filter((x) => picked.has(x.id))) lines.push(`- Nit: ${n.text}${n.file ? ` (\`${n.file}${n.line ? `:${n.line}` : ''}\`)` : ''}`);
190
+ try {
191
+ await navigator.clipboard.writeText(lines.join('\n'));
192
+ toast?.('Copied as Markdown');
193
+ } catch (e) {
194
+ toast?.(`Couldn't copy: ${e.message}`, 5000);
195
+ }
196
+ }
197
+
198
+ body.addEventListener('submit', async (e) => {
199
+ if (!e.target.matches('[data-rv-form]')) return;
200
+ e.preventDefault();
201
+ const url = body.querySelector('[data-rv="url"]').value.trim();
202
+ try {
203
+ const a = await api('POST', '/reviews', { url });
204
+ toast?.(`Reviewer ${a.name} started`);
205
+ openId = a.id;
206
+ await load();
207
+ } catch (err) {
208
+ toast?.(err.message, 6000);
209
+ }
210
+ });
211
+
212
+ body.addEventListener('change', (e) => {
213
+ const s = e.target.closest('[data-rv-start]');
214
+ if (s) {
215
+ if (s.checked) ticked.add(s.dataset.rvStart);
216
+ else ticked.delete(s.dataset.rvStart);
217
+ return render();
218
+ }
219
+ const p = e.target.closest('[data-rv-pick]');
220
+ if (p && openId) {
221
+ const set = picks.get(openId) ?? new Set();
222
+ if (p.checked) set.add(p.dataset.rvPick);
223
+ else set.delete(p.dataset.rvPick);
224
+ picks.set(openId, set);
225
+ render();
226
+ }
227
+ });
228
+
229
+ const toggle = (id) => {
230
+ openId = openId === id ? null : id;
231
+ render();
232
+ };
233
+ body.addEventListener('keydown', (e) => {
234
+ const t = e.target.closest('[data-rv-toggle]');
235
+ if (t && (e.key === 'Enter' || e.key === ' ')) {
236
+ e.preventDefault();
237
+ toggle(t.dataset.rvToggle);
238
+ }
239
+ });
240
+
241
+ body.addEventListener('click', async (e) => {
242
+ const o = e.target.closest('[data-rv-open]');
243
+ if (o) {
244
+ dialog.close();
245
+ return openAgent(o.dataset.rvOpen);
246
+ }
247
+ // Links, boxes and Listen do their own thing.
248
+ if (e.target.closest('a, input, [data-say]')) return;
249
+ const t = e.target.closest('[data-rv-toggle]');
250
+ if (t) return toggle(t.dataset.rvToggle);
251
+ const b = e.target.closest('[data-rv]')?.dataset.rv;
252
+ if (b === 'close') return dialog.close();
253
+ if (b === 'refresh') return load({ fresh: true });
254
+ if (b === 'start' || b === 'dismiss') {
255
+ busy = true;
256
+ render();
257
+ const urls = [...ticked];
258
+ try {
259
+ if (b === 'dismiss') {
260
+ await api('POST', '/reviews/dismiss', { urls });
261
+ } else {
262
+ const failed = [];
263
+ for (const url of urls) {
264
+ try {
265
+ await api('POST', '/reviews', { url });
266
+ } catch (err) {
267
+ failed.push(err.message);
268
+ }
269
+ }
270
+ toast?.(failed.length ? `Started ${urls.length - failed.length}; ${failed.join('; ')}` : `Started ${urls.length} reviewer${urls.length === 1 ? '' : 's'}`, failed.length ? 7000 : 3000);
271
+ }
272
+ ticked.clear();
273
+ } finally {
274
+ busy = false;
275
+ await load();
276
+ }
277
+ return;
278
+ }
279
+ const r = rowOf(openId);
280
+ if (!r?.review) return;
281
+ if (b === 'copy') return copy(r);
282
+ if (b === 'post') {
283
+ busy = true;
284
+ render();
285
+ try {
286
+ const res = await api('POST', `/reviews/${r.agent.id}/post`, { ids: [...(picks.get(r.agent.id) ?? [])] });
287
+ toast?.(`Pending review created with ${res.ids.length} item${res.ids.length === 1 ? '' : 's'}: submit it on GitHub`, 6000);
288
+ window.open(res.url, '_blank', 'noopener');
289
+ } catch (err) {
290
+ toast?.(err.message, 7000);
291
+ } finally {
292
+ busy = false;
293
+ await load();
294
+ }
295
+ }
296
+ });
297
+
298
+ function open() {
299
+ if (dialog.open) return dialog.close();
300
+ dialog.showModal();
301
+ render();
302
+ load();
303
+ }
304
+
305
+ /** An agent changed: look again shortly while open, and now and then for the count. */
306
+ function changed() {
307
+ if (!dialog.open && again) return;
308
+ clearTimeout(again);
309
+ const wait = dialog.open ? 1500 : Math.max(5000, 60_000 - (Date.now() - loadedAt));
310
+ again = setTimeout(() => {
311
+ again = null;
312
+ load({ quiet: true });
313
+ }, wait);
314
+ }
315
+
316
+ load({ quiet: true });
317
+ return { open, changed, isOpen: () => dialog.open, speech: (id) => reviewerSpeech(rowOf(id)), show: (id) => ((openId = id), dialog.open ? render() : open()) };
318
+ }
package/public/style.css CHANGED
@@ -1230,3 +1230,41 @@ table.value-items tr.value-edit td { background: var(--panel-2); }
1230
1230
  .value-report-kinds { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
1231
1231
  .value-report-kinds input[type="time"] { width: auto; }
1232
1232
  input.inline { width: 64px; display: inline-block; padding: 2px 4px; }
1233
+
1234
+ /* ---------- Reviews: other people's pull requests, reviewed by agents */
1235
+ .rv-new { display: flex; gap: 6px; flex: 1; min-width: 220px; max-width: 460px; }
1236
+ .rv-new input { flex: 1; min-width: 0; }
1237
+ .rv-card { border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--radius); padding: 10px 14px; background: var(--panel); }
1238
+ .rv-card.blocked { border-left-color: var(--red); }
1239
+ .rv-card.approve, .rv-card.approve_with_nits { border-left-color: var(--green); }
1240
+ .rv-card.requested, .rv-card.stale { border-left-color: var(--yellow); }
1241
+ .rv-card.ticked { background: color-mix(in srgb, var(--yellow) 8%, var(--panel)); }
1242
+ .rv-card header { display: flex; align-items: baseline; gap: 10px; }
1243
+ .rv-card header[data-rv-toggle] { cursor: pointer; }
1244
+ .rv-card h3 { margin: 0; font-size: 15px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
1245
+ .rv-caret { color: var(--muted); width: 10px; }
1246
+ .verdict { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap; border: 1px solid currentColor; }
1247
+ .verdict.ok { color: var(--green); }
1248
+ .verdict.bad { color: var(--red); }
1249
+ .verdict.wait, .verdict.new { color: var(--yellow); }
1250
+ .rv-detail { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; font-size: 14px; line-height: 1.45; }
1251
+ .rv-detail h4 { margin: 12px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
1252
+ .rv-detail p { margin: 4px 0; }
1253
+ .rv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
1254
+ .rv-item { display: flex; gap: 8px; align-items: flex-start; }
1255
+ .rv-item input { margin-top: 4px; }
1256
+ .rv-item.resolved { opacity: .65; }
1257
+ .rv-item.resolved strong { text-decoration: line-through; }
1258
+ .rv-done { color: var(--green); width: 13px; }
1259
+ .rv-cat { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 0 6px; }
1260
+ .rv-where { font-size: 12px; }
1261
+ .rv-plain { margin: 0; padding-left: 20px; }
1262
+ .rv-stale { color: var(--yellow); font-weight: 600; }
1263
+ .rv-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
1264
+ @media (max-width: 640px) {
1265
+ .rv-new { max-width: none; order: 10; flex-basis: 100%; }
1266
+ .rv-card header { flex-wrap: wrap; }
1267
+ .rv-card.requested header { flex-wrap: nowrap; }
1268
+ }
1269
+ .rv-card input[type="checkbox"] { width: auto; flex: none; margin: 0; }
1270
+ .rv-item input[type="checkbox"] { margin-top: 4px; }
package/src/assistant.js CHANGED
@@ -93,7 +93,10 @@ export function assistantPrompt(s, dir, bin = `node ${BIN}`) {
93
93
  if (s.sources.includes('reviews')) {
94
94
  how.push(
95
95
  `GitHub reviews: gh search prs --review-requested=@me --state=open --json url,title,repository,updatedAt. ` +
96
- `For each pull request you haven't handled, start a review agent in its project: ${am} add @<project> "Review <the PR link>: read the change, check out the branch if needed, and write the review as comments for the person to post. Don't approve, request changes or post anything yourself."`,
96
+ (s.pickIssues
97
+ ? `Don't start reviewers: the person picks. These pull requests are listed for them under Reviews, where they start a reviewer with one click. Record them as "listed".`
98
+ : `For each pull request you haven't handled, start a reviewer agent: ${am} review <the PR link>. It reviews the change read-only, writes its blockers and questions for the person, and never posts on GitHub. ` +
99
+ `A second reviewer for the same pull request is refused: record it as skipped.`),
97
100
  );
98
101
  }
99
102
  if (s.sources.includes('ci')) {
package/src/cli.js CHANGED
@@ -8,6 +8,7 @@ import { api, BASE, ensureDaemon, health, isRunning, waitForExit } from './clien
8
8
  import { about, latestRelease } from './about.js';
9
9
  import { issuesMarkdown } from './issues.js';
10
10
  import { designsMarkdown } from './designs.js';
11
+ import { VERDICT_LABEL } from './reviews.js';
11
12
 
12
13
  const tty = process.stdout.isTTY;
13
14
  const c = (code) => (s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : String(s));
@@ -738,6 +739,73 @@ export async function main(argv) {
738
739
  }
739
740
  });
740
741
 
742
+ program
743
+ .command('review')
744
+ .description("Start a reviewer agent on someone else's pull request: it asks the critical questions and finds what blocks approval; nothing is posted")
745
+ .argument('<pr>', 'the pull request link')
746
+ .option('-p, --project <project>', 'the project to check it out in (default: the one whose repository it is)')
747
+ .option('--notes <text>', 'what to look at closely')
748
+ .action(async (url, o) => {
749
+ await daemon();
750
+ const a = await api('POST', '/reviews', { url, project: o.project, notes: o.notes });
751
+ console.log(`${green('✓')} reviewer ${bold(a.name)} (${a.id}) started; see it with agentmgr reviews show ${a.id}`);
752
+ });
753
+ const reviewsCmd = program.command('reviews').description('Pull requests you review: reviewer agents and their verdicts, and requests with no reviewer yet');
754
+ const verdictText = (r) => {
755
+ if (!r.agent) return yellow('requested, no reviewer');
756
+ if (!r.review?.verdict) return dim(r.status);
757
+ const label = VERDICT_LABEL[r.review.verdict];
758
+ const text = r.review.openBlockers ? `${label}: ${r.review.openBlockers} blocker${r.review.openBlockers === 1 ? '' : 's'}` : label;
759
+ return r.review.verdict === 'blocked' ? red(text) : green(text);
760
+ };
761
+ reviewsCmd
762
+ .command('ls', { isDefault: true })
763
+ .description('The list, stale and blocked ones first')
764
+ .option('--markdown', 'print every review as Markdown')
765
+ .option('--json', 'print JSON')
766
+ .action(async (opts) => {
767
+ await daemon();
768
+ if (opts.markdown) return console.log((await api('GET', '/reviews?format=markdown')).markdown);
769
+ const { rows } = await api('GET', '/reviews');
770
+ if (opts.json) return console.log(JSON.stringify(rows, null, 2));
771
+ if (!rows.length) return console.log(dim('No reviews, and no pull requests waiting for your review.'));
772
+ for (const r of rows) {
773
+ console.log(`${bold(`${r.pr.repo ?? ''}#${r.pr.number}`)} ${truncate(r.pr.title ?? '', 60)} ${verdictText(r)}${r.stale ? yellow(' (author pushed since)') : ''}${r.posted ? dim(' posted') : ''}`);
774
+ console.log(dim(` ${r.pr.url}${r.agent ? ` agent ${r.agent.name} (${r.agent.id})` : ''}`));
775
+ }
776
+ });
777
+ reviewsCmd
778
+ .command('show')
779
+ .description("A reviewer's review: verdict, blockers, questions for the author, risks")
780
+ .argument('<agent>')
781
+ .action(async (ref) => {
782
+ await daemon();
783
+ const a = await resolveAgent(ref);
784
+ const r = await api('GET', `/reviews/${a.id}`);
785
+ console.log(r.markdown);
786
+ if (r.review) console.log(dim(`\nIds to post: ${[...r.review.blockers.filter((b) => b.status === 'open'), ...r.review.questions, ...r.review.nits].map((x) => x.id).join(' ') || 'none'}`));
787
+ });
788
+ reviewsCmd
789
+ .command('post')
790
+ .description('Post a pending review on GitHub, under your name, with the picked items (default: open blockers and questions); you submit it there')
791
+ .argument('<agent>')
792
+ .argument('[ids...]', 'items to send, e.g. b1 q2 n1')
793
+ .action(async (ref, ids) => {
794
+ await daemon();
795
+ const a = await resolveAgent(ref);
796
+ const r = await api('POST', `/reviews/${a.id}/post`, { ids: ids.length ? ids : null });
797
+ console.log(`${green('✓')} pending review with ${r.ids.length} item${r.ids.length === 1 ? '' : 's'}: finish and submit it at ${r.url}${r.moved ? dim(`\n ${r.moved} line comment(s) went in the body: their lines aren't in the diff`) : ''}`);
798
+ });
799
+ reviewsCmd
800
+ .command('dismiss')
801
+ .description("Take requested pull requests off the list (you won't have an agent review them)")
802
+ .argument('<prs...>')
803
+ .action(async (urls) => {
804
+ await daemon();
805
+ const r = await api('POST', '/reviews/dismiss', { urls });
806
+ console.log(`${r.dismissed} dismissed`);
807
+ });
808
+
741
809
  const valueCmd = program.command('value').description('What the delivered work is worth (AI estimates you can correct), by day, week, month and quarter, with reports for management');
742
810
  const money = (n, cur = 'USD') => (n == null ? '—' : new Intl.NumberFormat('en-US', { style: 'currency', currency: cur, maximumFractionDigits: 0 }).format(n));
743
811
  valueCmd
package/src/manager.js CHANGED
@@ -110,6 +110,7 @@ import { parseDiff } from '../public/review.js';
110
110
  import { issueFields, issueSummary, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
111
111
  import { issueRows } from './issues.js';
112
112
  import { designRows } from './designs.js';
113
+ import { reviewPath, reviewerPrompt } from './reviews.js';
113
114
  import { reminderFor, reminderSettings } from './reminders.js';
114
115
  import { combine, facts as scoreFacts, improveMessage, scorecardMarkdown, scorecardPrompt } from './scorecard.js';
115
116
  import { CONTAINER_ENGINES, claudeToken, containerName, containerRunning, engineMounts, gitCommonDir, removeContainer, runArgs, stopContainer } from './container.js';
@@ -622,6 +623,7 @@ export class AgentManager extends EventEmitter {
622
623
  attachments,
623
624
  isolation,
624
625
  builds,
626
+ reviewing,
625
627
  }) {
626
628
  intent = (intent ?? '').trim();
627
629
  const staged = stagedFiles(attachments);
@@ -676,6 +678,8 @@ export class AgentManager extends EventEmitter {
676
678
  ...(isolation ? { isolation } : {}),
677
679
  // A session that develops an agent built here (builder.js): { name, engine }.
678
680
  ...(builds ? { builds: { name: String(builds.name), engine: String(builds.engine ?? 'claude') } } : {}),
681
+ // Reviews someone else's pull request (reviews.js): { url, slug, number, title }.
682
+ ...(!general && reviewing ? { reviewing } : {}),
679
683
  name: name?.trim() || jiraKey || slug,
680
684
  slug,
681
685
  intent,
@@ -692,11 +696,11 @@ export class AgentManager extends EventEmitter {
692
696
  model: model || null,
693
697
  // Review the implementation plan before the agent implements it: null = no review.
694
698
  // Team members get their review from the team instead.
695
- planReview: !general && !team && !builds && (planReview ?? this.config.planReview ?? false) ? { status: 'writing' } : null,
699
+ planReview: !general && !team && !builds && !reviewing && (planReview ?? this.config.planReview ?? false) ? { status: 'writing' } : null,
696
700
  // Write and publish a design doc (Google Doc + Artifact) after the plan, updated at the end.
697
- designDoc: !general && !team && !builds && Boolean(designDoc ?? this.config.designDoc ?? true),
698
- demoPage: !general && !team && !builds && Boolean(demoPage ?? this.config.demoPage ?? false),
699
- benchmarks: !general && !team && !builds && Boolean(benchmarks ?? this.config.benchmarks ?? false),
701
+ designDoc: !general && !team && !builds && !reviewing && Boolean(designDoc ?? this.config.designDoc ?? true),
702
+ demoPage: !general && !team && !builds && !reviewing && Boolean(demoPage ?? this.config.demoPage ?? false),
703
+ benchmarks: !general && !team && !builds && !reviewing && Boolean(benchmarks ?? this.config.benchmarks ?? false),
700
704
  status: 'preparing',
701
705
  desired: start ? 'running' : 'stopped',
702
706
  error: null,
@@ -717,7 +721,8 @@ export class AgentManager extends EventEmitter {
717
721
  ...(team ? { team } : {}),
718
722
  ...(imported ? { imported } : {}),
719
723
  };
720
- for (const pr of refs.prs) agent.prs[pr.url] = { ...pr, source: 'intent' };
724
+ // The PR a reviewer reviews isn't its own: it stays "mentioned", so landing and the rest leave it alone.
725
+ for (const pr of refs.prs) agent.prs[pr.url] = { ...pr, source: pr.url === agent.reviewing?.url ? 'mentioned' : 'intent' };
721
726
  for (const bug of refs.bugs) agent.bugs[bug.key] = { ...bug, source: 'intent' };
722
727
  // A request that starts with an issue link: describe it by the issue's summary (fetched below),
723
728
  // and until then by the words after the link.
@@ -1178,7 +1183,7 @@ export class AgentManager extends EventEmitter {
1178
1183
  }
1179
1184
  // SPEC.md before changing code, and PLAN.md kept as it goes (unless the plan review asks for the plan).
1180
1185
  // A session building an agent keeps its analysis in the agent's folder instead.
1181
- if (task && this.config.specs !== false && !agent.builds) {
1186
+ if (task && this.config.specs !== false && !agent.builds && !agent.reviewing) {
1182
1187
  fs.mkdirSync(briefDir(agent.id), { recursive: true });
1183
1188
  const dir = fs.realpathSync(briefDir(agent.id));
1184
1189
  writableDir ??= dir;
@@ -1203,6 +1208,12 @@ export class AgentManager extends EventEmitter {
1203
1208
  if (agent.demoPage) prompts.push(demoPagePrompt(path.join(dir, path.basename(demoPath(agent.id)))));
1204
1209
  if (agent.benchmarks) prompts.push(benchmarksPrompt(path.join(dir, path.basename(benchPath(agent.id))), path.join(dir, 'bench')));
1205
1210
  }
1211
+ if (agent.reviewing && task) {
1212
+ fs.mkdirSync(briefDir(agent.id), { recursive: true });
1213
+ const file = path.join(fs.realpathSync(briefDir(agent.id)), path.basename(reviewPath(agent.id)));
1214
+ writableDir ??= path.dirname(file);
1215
+ prompts.push(reviewerPrompt(file, agent.reviewing));
1216
+ }
1206
1217
  if (planning) prompts.push(planningPrompt(agent));
1207
1218
  // What earlier agents learned in this repo, and the one command to add to it.
1208
1219
  let allowedTools = null;
@@ -2121,7 +2132,7 @@ export class AgentManager extends EventEmitter {
2121
2132
  if (k === 'source') continue;
2122
2133
  if (v != null && merged[k] !== v) merged[k] = v;
2123
2134
  }
2124
- if ((SOURCE_RANK[item.source] ?? 0) > (SOURCE_RANK[cur.source] ?? 0)) merged.source = item.source;
2135
+ if ((SOURCE_RANK[item.source] ?? 0) > (SOURCE_RANK[cur.source] ?? 0) && key !== agent.reviewing?.url) merged.source = item.source;
2125
2136
  if (JSON.stringify(merged) !== JSON.stringify(cur)) {
2126
2137
  bag[key] = merged;
2127
2138
  changed = true;
package/src/reviews.js ADDED
@@ -0,0 +1,359 @@
1
+ // Reviews: agents that review other people's pull requests for you. A reviewer agent reads the
2
+ // change, checks out its head, asks the critical questions the code doesn't answer and decides
3
+ // whether anything blocks approval. It writes REVIEW.json next to its brief; nothing goes to
4
+ // GitHub until you tick what to send and post it as a pending review under your name. When the
5
+ // author pushes, the reviewer re-checks its earlier blockers.
6
+
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+ import { briefDir } from './brief.js';
10
+ import { run } from './git.js';
11
+ import { ghBin } from './tracker.js';
12
+
13
+ export const REVIEW_FILE = 'REVIEW.json';
14
+ export const reviewPath = (agentId) => path.join(briefDir(agentId), REVIEW_FILE);
15
+
16
+ const PR_URL = /^<?(https?:\/\/[\w.-]+\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+))/;
17
+ const VERDICTS = ['approve', 'approve_with_nits', 'blocked'];
18
+ export const VERDICT_LABEL = { approve: 'Approve', approve_with_nits: 'Approve with nits', blocked: 'Blocked' };
19
+ const CATEGORIES = ['correctness', 'security', 'data', 'breaking', 'tests', 'performance', 'design', 'other'];
20
+ const err = (status, message) => Object.assign(new Error(message), { status });
21
+ const clip = (s, n) => {
22
+ const t = String(s ?? '').trim();
23
+ return t.length > n ? `${t.slice(0, n - 1)}…` : t;
24
+ };
25
+
26
+ /** A pull request link -> { url, owner, repo, number, slug: "owner/repo" }, or null. */
27
+ export function parsePrUrl(text) {
28
+ const m = String(text ?? '').trim().match(PR_URL);
29
+ if (!m) return null;
30
+ return { url: m[1], owner: m[2], repo: m[3], number: Number(m[4]), slug: `${m[2]}/${m[3]}` };
31
+ }
32
+
33
+ /** The reviewer's instructions: read-only, the review in `file` as JSON. */
34
+ export function reviewerPrompt(file, pr) {
35
+ return [
36
+ `You are reviewing someone else's pull request for the user, who is a requested reviewer on it: ${pr.url}. You don't change it.`,
37
+ `Getting the code: in your folder, run "git fetch origin pull/${pr.number}/head:review/pr-${pr.number}" and "git checkout review/pr-${pr.number}" (fetch again after new pushes). ` +
38
+ `Read the description and discussion (gh pr view ${pr.url} --comments), the diff (gh pr diff ${pr.url}), and as much of the surrounding code as you need to understand what the change touches: callers, tests, config, migrations. ` +
39
+ 'Read the linked issue or design doc if there is one. You may build and run the tests.',
40
+ 'Never commit, push, edit the pull request, approve, request changes or comment on GitHub: the user decides and posts. Don\'t change files in the repository except to run the tests.',
41
+ 'Be critical, like a careful senior reviewer. For each concern, reason it through against the code before you write it down: is it real, how would it fail, who would notice? ' +
42
+ 'A blocker is something that should stop approval: a bug, a security or data-loss risk, a breaking change without a migration, a missing test for risky logic, or a change that doesn\'t do what the PR says. Style and taste are nits, never blockers. ' +
43
+ 'Questions are what the code and description don\'t answer and the author should: intent, edge cases, rollout and rollback, why this approach.',
44
+ `Write the review to ${file} as JSON, and keep it current:\n` +
45
+ '{\n' +
46
+ ` "pr": "${pr.url}",\n` +
47
+ ' "headSha": "<the commit you reviewed: git rev-parse HEAD>",\n' +
48
+ ' "verdict": "approve" | "approve_with_nits" | "blocked",\n' +
49
+ ' "why": "<one or two sentences: why that verdict>",\n' +
50
+ ' "summary": "<what the change does, in two or three sentences>",\n' +
51
+ ' "blockers": [{ "id": "b1", "title": "<short>", "file": "<path>", "line": <line in the new file, or null>, "category": "correctness|security|data|breaking|tests|performance|design|other", "why": "<how it fails, with evidence from the code>", "unblock": "<what would resolve it>", "status": "open" | "resolved" }],\n' +
52
+ ' "questions": [{ "id": "q1", "question": "<for the author>", "why": "<why it matters>", "file": "<path or null>", "line": <line or null> }],\n' +
53
+ ' "risks": ["<risk that isn\'t a blocker>"],\n' +
54
+ ' "testGaps": ["<behaviour with no test>"],\n' +
55
+ ' "nits": [{ "id": "n1", "text": "<minor>", "file": "<path or null>", "line": <line or null> }],\n' +
56
+ ' "tests": "<what you ran and the result, or why you didn\'t>"\n' +
57
+ '}\n' +
58
+ 'Every blocker has a verdict of "blocked" behind it; with no open blockers the verdict is approve or approve_with_nits. Lines are lines of the new file that the diff touches, so they can carry a comment.',
59
+ `When a message says the author pushed, fetch again, re-check each blocker (mark it "resolved" when the new code fixes it, and say how in "why"), review what changed, update headSha and the verdict, and rewrite ${file}.`,
60
+ 'Finish each pass with your status as done in the brief and the verdict in one line.',
61
+ ].join('\n\n');
62
+ }
63
+
64
+ const list = (xs, n, f) => (Array.isArray(xs) ? xs : []).slice(0, n).map(f).filter(Boolean);
65
+ const lineOf = (v) => (Number.isInteger(v) && v > 0 ? v : null);
66
+
67
+ /** REVIEW.json, cleaned up: unknown values dropped, ids filled in, lengths capped. */
68
+ export function normalizeReview(raw) {
69
+ if (!raw || typeof raw !== 'object') return null;
70
+ const blockers = list(raw.blockers, 30, (b, i) =>
71
+ b?.title || b?.why
72
+ ? {
73
+ id: String(b.id || `b${i + 1}`),
74
+ title: clip(b.title || b.why, 200),
75
+ file: b.file ? clip(b.file, 300) : null,
76
+ line: lineOf(b.line),
77
+ category: CATEGORIES.includes(b.category) ? b.category : 'other',
78
+ why: clip(b.why, 2000),
79
+ unblock: clip(b.unblock, 1000),
80
+ status: b.status === 'resolved' ? 'resolved' : 'open',
81
+ }
82
+ : null,
83
+ );
84
+ const open = blockers.filter((b) => b.status === 'open').length;
85
+ let verdict = VERDICTS.includes(raw.verdict) ? raw.verdict : open ? 'blocked' : null;
86
+ // An open blocker always blocks, whatever the verdict says.
87
+ if (open && verdict !== 'blocked') verdict = 'blocked';
88
+ return {
89
+ pr: raw.pr ? String(raw.pr) : null,
90
+ headSha: /^[0-9a-f]{7,40}$/i.test(raw.headSha ?? '') ? raw.headSha : null,
91
+ verdict,
92
+ why: clip(raw.why, 1000),
93
+ summary: clip(raw.summary, 1500),
94
+ blockers,
95
+ questions: list(raw.questions, 30, (q, i) =>
96
+ q?.question ? { id: String(q.id || `q${i + 1}`), question: clip(q.question, 1000), why: clip(q.why, 1000), file: q.file ? clip(q.file, 300) : null, line: lineOf(q.line) } : null,
97
+ ),
98
+ risks: list(raw.risks, 20, (r) => (r ? clip(r, 600) : null)),
99
+ testGaps: list(raw.testGaps, 20, (r) => (r ? clip(r, 600) : null)),
100
+ nits: list(raw.nits, 40, (n, i) => (n?.text ? { id: String(n.id || `n${i + 1}`), text: clip(n.text, 600), file: n.file ? clip(n.file, 300) : null, line: lineOf(n.line) } : null)),
101
+ tests: clip(raw.tests, 1000),
102
+ openBlockers: open,
103
+ };
104
+ }
105
+
106
+ /** The reviewer's REVIEW.json: { review, updatedAt } or null (missing or not JSON yet). */
107
+ export function readReview(agentId) {
108
+ try {
109
+ const file = reviewPath(agentId);
110
+ const st = fs.statSync(file);
111
+ const text = fs.readFileSync(file, 'utf8');
112
+ // Tolerate a fenced block or text around the object.
113
+ const json = text.slice(text.indexOf('{'), text.lastIndexOf('}') + 1);
114
+ const review = normalizeReview(JSON.parse(json));
115
+ return review ? { review, updatedAt: st.mtime.toISOString() } : null;
116
+ } catch {
117
+ return null;
118
+ }
119
+ }
120
+
121
+ /** What to tell a reviewer when the author pushed. */
122
+ export const recheckMessage = (pr, head) =>
123
+ `The author pushed new commits to ${pr.url} (head ${String(head).slice(0, 12)}). Fetch them, re-check each blocker (resolved or still open), review what changed, and update the review.`;
124
+
125
+ const where = (x) => (x.file ? `\`${x.file}${x.line ? `:${x.line}` : ''}\`` : '');
126
+
127
+ /** Each item you can send, by id: what it says as a comment. */
128
+ function items(review) {
129
+ const out = [];
130
+ for (const b of review.blockers.filter((x) => x.status === 'open')) {
131
+ out.push({ id: b.id, kind: 'blocker', file: b.file, line: b.line, text: `**Blocker: ${b.title}**\n\n${b.why}${b.unblock ? `\n\nTo resolve: ${b.unblock}` : ''}` });
132
+ }
133
+ for (const q of review.questions) out.push({ id: q.id, kind: 'question', file: q.file, line: q.line, text: `**Question:** ${q.question}${q.why ? `\n\n${q.why}` : ''}` });
134
+ for (const n of review.nits) out.push({ id: n.id, kind: 'nit', file: n.file, line: n.line, text: `Nit: ${n.text}` });
135
+ return out;
136
+ }
137
+
138
+ /**
139
+ * The review as you'd send it: the picked items (all open blockers and questions when `ids` is
140
+ * not given). Comments with a file and line go on those lines; the rest go in the body.
141
+ */
142
+ export function reviewDraft(review, ids = null) {
143
+ const all = items(review);
144
+ const want = ids ? new Set(ids) : null;
145
+ const picked = all.filter((i) => (want ? want.has(i.id) : i.kind !== 'nit'));
146
+ const inline = picked.filter((i) => i.file && i.line);
147
+ const general = picked.filter((i) => !(i.file && i.line));
148
+ const head = review.openBlockers ? `${review.openBlockers} thing${review.openBlockers === 1 ? '' : 's'} to resolve before this can be approved.` : '';
149
+ const body = [head, ...general.map((i) => `${i.text.replace(/\n\n/g, '\n')}${i.file ? `\n(${where(i)})` : ''}`)].filter(Boolean).join('\n\n');
150
+ return { body, comments: inline.map((i) => ({ path: i.file, line: i.line, side: 'RIGHT', body: i.text })), picked: picked.map((i) => i.id) };
151
+ }
152
+
153
+ /** The whole review as Markdown, to read or paste. */
154
+ export function reviewMarkdown(row) {
155
+ const r = row.review;
156
+ const head = `## Review of ${row.pr.title ? `${row.pr.title} ` : ''}(${row.pr.url})`;
157
+ if (!r) return `${head}\n\nThe reviewer is still reading the change.`;
158
+ const sec = (title, xs) => (xs.length ? `### ${title}\n${xs.join('\n')}` : null);
159
+ return [
160
+ head,
161
+ `**${VERDICT_LABEL[r.verdict] ?? 'No verdict yet'}**${r.why ? `: ${r.why}` : ''}`,
162
+ r.summary,
163
+ sec('Blockers', r.blockers.map((b) => `- ${b.status === 'resolved' ? '~~' : ''}**${b.title}**${b.status === 'resolved' ? '~~ (resolved)' : ''} ${where(b)} (${b.category})\n ${b.why}${b.unblock ? `\n To resolve: ${b.unblock}` : ''}`)),
164
+ sec('Questions for the author', r.questions.map((q) => `- ${q.question} ${where(q)}${q.why ? `\n ${q.why}` : ''}`)),
165
+ sec('Risks', r.risks.map((x) => `- ${x}`)),
166
+ sec('Test gaps', r.testGaps.map((x) => `- ${x}`)),
167
+ sec('Nits', r.nits.map((n) => `- ${n.text} ${where(n)}`)),
168
+ r.tests ? `### Tests\n${r.tests}` : null,
169
+ ]
170
+ .filter(Boolean)
171
+ .join('\n\n');
172
+ }
173
+
174
+ /** One row per reviewer agent, then requested PRs that have none (newest first). */
175
+ export function reviewRows(views, requested = [], read = readReview) {
176
+ const rows = [];
177
+ const taken = new Set();
178
+ for (const v of views) {
179
+ if (!v.reviewing) continue;
180
+ const pr = (v.prs ?? []).find((p) => p.url === v.reviewing.url) ?? {};
181
+ const got = read(v.id);
182
+ const review = got?.review ?? null;
183
+ taken.add(v.reviewing.url);
184
+ const head = pr.head ?? null;
185
+ rows.push({
186
+ pr: { url: v.reviewing.url, repo: v.reviewing.slug, number: v.reviewing.number, title: pr.title ?? v.reviewing.title ?? null, state: pr.state ?? null, isDraft: Boolean(pr.isDraft), checks: pr.checks ?? null, head },
187
+ agent: { id: v.id, name: v.name, running: Boolean(v.runtime?.running), busy: Boolean(v.runtime?.busy) },
188
+ review,
189
+ updatedAt: got?.updatedAt ?? v.createdAt ?? null,
190
+ // The author pushed since this review was written.
191
+ stale: Boolean(review?.headSha && head && !head.startsWith(review.headSha) && !review.headSha.startsWith(head)),
192
+ posted: v.reviewing.posted ?? null,
193
+ status: !review ? (v.runtime?.busy || v.status === 'preparing' ? 'reviewing' : 'no review') : review.verdict ?? 'reviewing',
194
+ });
195
+ }
196
+ for (const p of requested) {
197
+ if (taken.has(p.url)) continue;
198
+ rows.push({ pr: { url: p.url, repo: p.repo, number: p.number, title: p.title ?? null, state: 'OPEN', author: p.author ?? null }, agent: null, review: null, updatedAt: p.updatedAt ?? null, stale: false, posted: null, status: 'requested' });
199
+ }
200
+ const rank = { requested: 0, blocked: 1, approve_with_nits: 2, approve: 3, reviewing: 4, 'no review': 5 };
201
+ return rows.sort((a, b) => Number(b.stale) - Number(a.stale) || (rank[a.status] ?? 9) - (rank[b.status] ?? 9) || String(b.updatedAt ?? '').localeCompare(String(a.updatedAt ?? '')));
202
+ }
203
+
204
+ /** PRs where your review is requested, from GitHub: [{ url, repo, number, title, author, updatedAt }]. */
205
+ export async function requestedReviews() {
206
+ if (process.env.AGENTMGR_NO_GH) return [];
207
+ try {
208
+ const out = await run(ghBin(), ['search', 'prs', '--review-requested=@me', '--state=open', '--limit', '50', '--json', 'url,title,repository,author,updatedAt,number'], { timeout: 30_000 });
209
+ return JSON.parse(out || '[]').map((p) => ({ url: p.url, repo: p.repository?.nameWithOwner ?? parsePrUrl(p.url)?.slug ?? null, number: p.number, title: p.title, author: p.author?.login ?? null, updatedAt: p.updatedAt }));
210
+ } catch {
211
+ return [];
212
+ }
213
+ }
214
+
215
+ export class Reviews {
216
+ constructor({ manager, store, log = () => {} }) {
217
+ this.manager = manager;
218
+ this.store = store;
219
+ this.log = log;
220
+ this.requested = { at: 0, list: [] };
221
+ this.onPrs = (agent) => this.recheck(agent);
222
+ manager.on('prs', this.onPrs);
223
+ }
224
+
225
+ close() {
226
+ this.manager.off('prs', this.onPrs);
227
+ }
228
+
229
+ /** The reviewer agent for a PR, if there is one. */
230
+ agentFor(url) {
231
+ return this.store.list().find((a) => a.reviewing?.url === url) ?? null;
232
+ }
233
+
234
+ /** The project whose repository is the PR's, else its GitHub URL. */
235
+ where(pr, project) {
236
+ if (project) {
237
+ const p = String(project).replace(/^@/, '');
238
+ if (!this.manager.resolveProject(p)) throw err(400, `No project @${p}; see agentmgr project ls`);
239
+ return { project: p };
240
+ }
241
+ const slug = pr.slug.toLowerCase();
242
+ const match = this.manager.listProjects().find((p) => {
243
+ const repo = String(p.repo ?? '').toLowerCase().replace(/\.git$/, '');
244
+ return repo.endsWith(`/${slug}`) || repo.endsWith(`:${slug}`) || String(p.key ?? '').endsWith(`/${slug}`);
245
+ });
246
+ return match ? { project: match.shortcut } : { repo: `https://github.com/${pr.slug}.git` };
247
+ }
248
+
249
+ /** Start a reviewer for a PR link. */
250
+ start({ url, project = null, startedBy = null, notes = '' } = {}) {
251
+ const pr = parsePrUrl(url);
252
+ if (!pr) throw err(400, 'Give a pull request link (https://github.com/<owner>/<repo>/pull/<number>)');
253
+ const prev = this.agentFor(pr.url);
254
+ if (prev) throw err(409, `${prev.name} (${prev.id}) already reviews ${pr.url}`);
255
+ const title = this.requested.list.find((p) => p.url === pr.url)?.title ?? null;
256
+ const intent = `Review ${pr.url}${title ? `: ${title}` : ''}${notes ? `\n\n${String(notes).trim()}` : ''}`;
257
+ return this.manager.create({
258
+ ...this.where(pr, project),
259
+ intent,
260
+ name: `review-${pr.repo}-${pr.number}`.toLowerCase(),
261
+ reviewing: { url: pr.url, slug: pr.slug, number: pr.number, title },
262
+ ...(startedBy ? { startedBy } : {}),
263
+ });
264
+ }
265
+
266
+ /** Requested PRs, refreshed at most once a minute. */
267
+ async requestedList({ fresh = false } = {}) {
268
+ if (fresh || Date.now() - this.requested.at > 60_000) this.requested = { at: Date.now(), list: await requestedReviews() };
269
+ return this.requested.list;
270
+ }
271
+
272
+ async rows({ fresh = false } = {}) {
273
+ const views = this.store.list().filter((a) => a.reviewing).map((a) => this.manager.view(a));
274
+ const skip = new Set(this.store.data.reviewsDismissed ?? []);
275
+ return reviewRows(views, (await this.requestedList({ fresh })).filter((p) => !skip.has(p.url)));
276
+ }
277
+
278
+ /** Requested PRs you won't have an agent review: off the list. */
279
+ dismiss(urls = []) {
280
+ const list = (this.store.data.reviewsDismissed ??= []);
281
+ let n = 0;
282
+ for (const u of urls.map((x) => parsePrUrl(x)?.url).filter(Boolean)) {
283
+ if (!list.includes(u)) {
284
+ list.push(u);
285
+ n += 1;
286
+ }
287
+ }
288
+ if (list.length > 300) list.splice(0, list.length - 300);
289
+ this.store.save();
290
+ return { dismissed: n };
291
+ }
292
+
293
+ row(ref) {
294
+ const a = this.manager.mustGet(ref);
295
+ if (!a.reviewing) throw err(400, `${a.name} isn't reviewing a pull request`);
296
+ return reviewRows([this.manager.view(a)])[0];
297
+ }
298
+
299
+ /** After the author pushes: tell the reviewer once per new head. */
300
+ recheck(agent) {
301
+ if (!agent?.reviewing) return;
302
+ const pr = agent.prs?.[agent.reviewing.url];
303
+ const got = readReview(agent.id);
304
+ if (!pr?.head || pr.state !== 'OPEN' || !got?.review?.headSha) return;
305
+ const reviewed = got.review.headSha;
306
+ if (pr.head.startsWith(reviewed) || reviewed.startsWith(pr.head)) return;
307
+ if (agent.reviewing.recheckedFor === pr.head) return;
308
+ this.manager.patch(agent.id, { reviewing: { ...agent.reviewing, recheckedFor: pr.head } });
309
+ try {
310
+ this.manager.tell(agent.id, recheckMessage(pr, pr.head), { source: 'reviews' });
311
+ this.log(`review: ${agent.name}: author pushed ${pr.head.slice(0, 7)}, re-checking`);
312
+ } catch {}
313
+ }
314
+
315
+ /**
316
+ * Post the picked items as a pending review on GitHub, under your name: you finish and submit it
317
+ * there. A line GitHub can't comment on goes in the body instead.
318
+ */
319
+ async post(ref, { ids = null } = {}) {
320
+ const a = this.manager.mustGet(ref);
321
+ if (!a.reviewing) throw err(400, `${a.name} isn't reviewing a pull request`);
322
+ const got = readReview(a.id);
323
+ if (!got) throw err(409, 'No review written yet');
324
+ const draft = reviewDraft(got.review, ids);
325
+ if (!draft.picked.length) throw err(400, 'Pick at least one blocker, question or nit to send');
326
+ if (process.env.AGENTMGR_NO_GH) throw err(503, 'GitHub is off (AGENTMGR_NO_GH)');
327
+ const { slug, number } = a.reviewing;
328
+ // gh reads the payload from a file: comments with lines need real JSON, not -f fields.
329
+ const file = path.join(briefDir(a.id), 'review-post.json');
330
+ const send = async (payload) => {
331
+ fs.writeFileSync(file, JSON.stringify(payload));
332
+ try {
333
+ const out = await run(ghBin(), ['api', '-X', 'POST', `repos/${slug}/pulls/${number}/reviews`, '--input', file], { timeout: 30_000 });
334
+ return JSON.parse(out || '{}');
335
+ } finally {
336
+ fs.rmSync(file, { force: true });
337
+ }
338
+ };
339
+ const base = { ...(got.review.headSha ? { commit_id: got.review.headSha } : {}), body: draft.body || ' ' };
340
+ let res;
341
+ let moved = 0;
342
+ try {
343
+ res = await send({ ...base, comments: draft.comments });
344
+ } catch (e) {
345
+ // 422: a line outside the diff. Put those comments in the body instead.
346
+ if (!/422|Unprocessable|line/i.test(e.message) || !draft.comments.length) throw err(502, `GitHub refused the review: ${clip(e.message, 300)}`);
347
+ moved = draft.comments.length;
348
+ const extra = draft.comments.map((c) => `${c.body.replace(/\n\n/g, '\n')}\n(\`${c.path}:${c.line}\`)`);
349
+ try {
350
+ res = await send({ ...base, body: [draft.body, ...extra].filter(Boolean).join('\n\n') });
351
+ } catch (e2) {
352
+ throw err(502, `GitHub refused the review: ${clip(e2.message, 300)}`);
353
+ }
354
+ }
355
+ const posted = { at: new Date().toISOString(), url: res.html_url ?? `${a.reviewing.url}/files`, ids: draft.picked, moved };
356
+ this.manager.patch(a.id, { reviewing: { ...a.reviewing, posted } });
357
+ return posted;
358
+ }
359
+ }
package/src/server.js CHANGED
@@ -41,6 +41,7 @@ import * as service from './service.js';
41
41
  import { jiraView, saveJira } from './jira.js';
42
42
  import { ProposedIssues, issuesMarkdown } from './issues.js';
43
43
  import { designsMarkdown } from './designs.js';
44
+ import { Reviews, reviewDraft, reviewMarkdown } from './reviews.js';
44
45
  import { CONTAINER_ENGINES, buildImage, claudeToken, dockerStatus, isBuilding, saveSecrets } from './container.js';
45
46
  import { AgentkitReports } from './agentkit-reports.js';
46
47
  import { Builder } from './builder.js';
@@ -91,6 +92,7 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
91
92
  const manager = new AgentManager({ store, config, plugins });
92
93
  const backlog = new Backlog({ manager, store, config });
93
94
  const proposed = new ProposedIssues({ store, manager });
95
+ const reviews = new Reviews({ manager, store, log: (m) => console.log(`[agentmgr] ${m}`) });
94
96
  const races = new Races({ manager, store });
95
97
  const review = new Review({ manager });
96
98
  // The walkthrough explains the same diff the review screen shows.
@@ -803,6 +805,22 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
803
805
  .filter((r) => !q || [r.title, r.summary, r.agent.name, r.agent.project, r.issue?.key].some((s) => String(s ?? '').toLowerCase().includes(q)));
804
806
  return req.query.format === 'markdown' ? { markdown: designsMarkdown(rows) } : { rows };
805
807
  }));
808
+ // Reviews: reviewer agents on other people's PRs, and PRs where your review is requested.
809
+ api.get('/reviews', wrap(async (req) => {
810
+ const rows = await reviews.rows({ fresh: req.query.fresh === '1' });
811
+ return req.query.format === 'markdown' ? { markdown: rows.filter((r) => r.agent).map(reviewMarkdown).join('\n\n---\n\n') || 'No reviews.' } : { rows };
812
+ }));
813
+ api.post('/reviews', wrap((req) => {
814
+ // Started by the assistant's own session: its limits apply, and it's marked as its.
815
+ const extra = assistant.admit(req.headers['x-agentmgr-agent'], [String(req.body?.url ?? '')]);
816
+ return reviews.start({ url: req.body?.url, project: req.body?.project, notes: req.body?.notes, startedBy: extra.startedBy ?? null });
817
+ }));
818
+ api.post('/reviews/dismiss', wrap((req) => reviews.dismiss(Array.isArray(req.body?.urls) ? req.body.urls.map(String) : [])));
819
+ api.get('/reviews/:id', wrap((req) => {
820
+ const row = reviews.row(req.params.id);
821
+ return { ...row, markdown: reviewMarkdown(row), draft: row.review ? reviewDraft(row.review) : null };
822
+ }));
823
+ api.post('/reviews/:id/post', wrap((req) => reviews.post(req.params.id, { ids: Array.isArray(req.body?.ids) ? req.body.ids.map(String) : null })));
806
824
  // Value: totals by period, items with estimates you can correct, reports.
807
825
  api.get('/value', wrap((req) => value.view({ period: String(req.query.period ?? 'week') })));
808
826
  api.put('/value', wrap((req) => {
@@ -1230,6 +1248,7 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
1230
1248
  landing.close();
1231
1249
  standup.close();
1232
1250
  value.close();
1251
+ reviews.close();
1233
1252
  autopilot.close();
1234
1253
  goals.close();
1235
1254
  worklog.close();