ai-agentmanager 1.33.0 → 1.34.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.34.0 (2026-11-08)
4
+
5
+ - **Merge on the Eval.** A pull request is *sure to merge* when its agent's Eval is 100%, the app's own test run passed on the very commit the pull request is at with nothing left uncommitted, a reviewer approved it, and GitHub has it ready. The Land tab lists these first, marked **Sure to merge** with the Eval's percentage; a ready pull request that isn't sure says why (for example "The tests ran on a different commit than the pull request is at"). Turn on **Merge on the Eval** in the Land tab's settings and these merge on their own: each commit is tried once, your policies and branch protection still apply, and a merge that fails says why on the pull request's row. Off by default; the approval requirement can be turned off.
6
+
3
7
  ## 1.33.0 (2026-11-08)
4
8
 
5
9
  - **Eval for each Jira change, with a confidence.** When an agent on a Jira issue says it's done, the app runs the project's tests again itself, on the change as it is (the test command is found in the project's files, or set once per project), and works out an *Eval* from evidence, not from the agent's word. It covers:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.33.0",
3
+ "version": "1.34.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/land.js CHANGED
@@ -1,7 +1,10 @@
1
1
  // Land tab: every agent's open pull request, grouped by what it needs to get merged, with
2
- // Review, Update, Ask to fix and Merge. Settings for sending failures back to agents at the bottom.
2
+ // Review, Update, Ask to fix and Merge. Ones whose Eval is 100% on their latest commit come first.
3
+ // Settings for sending failures back to agents, and for merging on the Eval, at the bottom.
3
4
 
4
5
  import { listenHtml } from './speak.js';
6
+ import { evalChip } from './eval.js';
7
+ import { sureToMerge } from './sure.js';
5
8
  const SHORT = { ready: 'ready', fix: 'to fix', behind: 'behind', waiting: 'waiting', draft: 'draft' };
6
9
  const GROUPS = [
7
10
  ['ready', 'Ready to merge'],
@@ -35,10 +38,10 @@ export function initLand({ api, esc, toast, agents, $, scoreBadge = () => '', se
35
38
  for (const a of agents.values()) {
36
39
  for (const pr of a.prs ?? []) {
37
40
  if (pr.state !== 'OPEN' || pr.source === 'mentioned') continue;
38
- out.push({ a, pr, land: pr.land ?? 'waiting' });
41
+ out.push({ a, pr, land: pr.land ?? 'waiting', sure: sureToMerge(a, pr, { needApproval: settings?.sureNeedsApproval ?? true }) });
39
42
  }
40
43
  }
41
- return out.sort((x, y) => (x.a.priority ?? 2) - (y.a.priority ?? 2));
44
+ return out.sort((x, y) => Number(y.sure.sure) - Number(x.sure.sure) || (x.a.priority ?? 2) - (y.a.priority ?? 2));
42
45
  };
43
46
 
44
47
  // Review comments sent to the agent so far, and when last.
@@ -47,13 +50,21 @@ export function initLand({ api, esc, toast, agents, $, scoreBadge = () => '', se
47
50
  return ` <span class="hint" title="Last sent ${esc(new Date(c.lastAt).toLocaleString())}">${c.count} review comment${c.count === 1 ? '' : 's'} sent</span>`;
48
51
  }
49
52
 
50
- function rowHtml({ a, pr, land }) {
53
+ // Why a ready pull request isn't sure, or why merging it on its own didn't work.
54
+ function sureHint(a, pr, land, sure) {
55
+ const tried = a.landing?.sure?.[`${pr.url}@${pr.head}`];
56
+ if (tried?.error) return ` <span class="hint fail" title="${esc(tried.error)}">Couldn't merge on its own</span>`;
57
+ if (land === 'ready' && !sure.sure && a.eval?.items) return ` <span class="hint" title="Why it isn't merged on its Eval">${esc(sure.why)}</span>`;
58
+ return '';
59
+ }
60
+
61
+ function rowHtml({ a, pr, land, sure }) {
51
62
  const canFix = land === 'fix' || land === 'behind';
52
63
  return `<li class="agent land-row" data-agent="${a.id}" data-url="${esc(pr.url)}">
53
64
  <div class="line1"><span class="prio p${a.priority ?? 2}">P${a.priority ?? 2}</span>
54
65
  <a class="name" href="${esc(pr.url)}" target="_blank" rel="noopener" title="${esc(pr.title ?? pr.url)}">#${esc(pr.number ?? '')} ${esc(pr.title ?? pr.url)}</a></div>
55
- <div class="line2"><button class="link" data-land="goto">${esc(a.name)}</button>${a.runtime?.busy ? ' <span class="hint">working</span>' : ''}${commentsHint(a.landing?.comments?.[pr.url])}</div>
56
- <div class="land-chips">${scoreBadge(a.docs?.scorecard, esc)} ${prChips(pr, esc)}</div>
66
+ <div class="line2"><button class="link" data-land="goto">${esc(a.name)}</button>${a.runtime?.busy ? ' <span class="hint">working</span>' : ''}${commentsHint(a.landing?.comments?.[pr.url])}${sureHint(a, pr, land, sure)}</div>
67
+ <div class="land-chips">${scoreBadge(a.docs?.scorecard, esc)} ${evalChip(a.eval, esc)} ${sure.sure ? `<span class="tag open" title="${esc(sure.why)}">Sure to merge</span>` : ''} ${prChips(pr, esc)}</div>
57
68
  <div class="bl-actions">
58
69
  <button class="small" data-land="review" title="Its diff, line comments for the agent, commit and push">Review</button>
59
70
  ${listenHtml(`prvoice:${a.id}`, { title: 'Explain the review aloud: the PR, its checks, the AI review, the riskiest changes and what is left', label: 'Explain' })}
@@ -91,6 +102,11 @@ export function initLand({ api, esc, toast, agents, $, scoreBadge = () => '', se
91
102
  <label>At most <input type="number" min="0" max="20" data-set="maxFixes" value="${s.maxFixes}"> times per pull request</label>
92
103
  <label>Merge with <select data-set="mergeMethod">${['squash', 'merge', 'rebase'].map((m) => `<option ${m === s.mergeMethod ? 'selected' : ''}>${m}</option>`).join('')}</select></label>
93
104
  <label class="check"><input type="checkbox" data-set="deleteBranch" ${s.deleteBranch ? 'checked' : ''}> Delete the branch on GitHub after merging</label>
105
+ </details>
106
+ <details class="land-settings"><summary>Merge on the Eval</summary>
107
+ <label class="check"><input type="checkbox" data-set="mergeWhenSure" ${s.mergeWhenSure ? 'checked' : ''}> Merge a pull request on its own when its Eval is 100%, the app's own test run passed on the commit the pull request is at, and GitHub has it ready</label>
108
+ <label class="check"><input type="checkbox" data-set="sureNeedsApproval" ${s.sureNeedsApproval ? 'checked' : ''}> Only once a reviewer has approved it</label>
109
+ <p class="hint">Each commit is tried once, and your policies and branch protection still apply. When this is off, these pull requests are only listed first, marked <b>Sure to merge</b>.</p>
94
110
  </details>` : ''}`;
95
111
  }
96
112
 
package/public/sure.js ADDED
@@ -0,0 +1,21 @@
1
+ // Sure to merge: a pull request whose agent's Eval backs it all the way. The daemon merges on it
2
+ // (when that is turned on) and the Land tab lists these first, so both use this one rule.
3
+
4
+ /**
5
+ * Whether a pull request can be merged on the strength of its agent's Eval: { sure, why }. Sure
6
+ * means 100%, with the tests run by the app on the very commit the PR is at and nothing left
7
+ * uncommitted, a reviewer's approval (unless that's turned off), and GitHub ready to merge it.
8
+ */
9
+ export function sureToMerge(agent, pr, { needApproval = true, land = pr?.land } = {}) {
10
+ const ev = agent?.eval;
11
+ const no = (why) => ({ sure: false, why });
12
+ if (!ev?.items) return no('No Eval yet');
13
+ if (ev.rerun?.running) return no('Its tests are running');
14
+ if (ev.confidence !== 100) return no(`The Eval is ${ev.confidence}%`);
15
+ if (!ev.rerun?.passed) return no("The app's own test run didn't pass");
16
+ if (!pr?.head || ev.rerun.head !== pr.head) return no('The tests ran on a different commit than the pull request is at');
17
+ if (ev.rerun.clean === false) return no('There were uncommitted changes when the tests ran');
18
+ if (needApproval && pr.review !== 'APPROVED') return no('No reviewer has approved it');
19
+ if (land !== 'ready') return no(`GitHub doesn't have it ready to merge (${land ?? 'unknown'})`);
20
+ return { sure: true, why: needApproval ? '100% on its latest commit, approved and ready' : '100% on its latest commit and ready' };
21
+ }
package/src/eval.js CHANGED
@@ -264,11 +264,13 @@ export class Evals {
264
264
  * `state(agent)` → a hash of its code as it is; `changes(agent)` → { files: [{ path }] };
265
265
  * `transcript(agent)` → its session's text (Claude Code), or null when it can't be read.
266
266
  */
267
- constructor({ manager, store, run, state, changes = async () => ({ files: [] }), transcript, benches = null, log = () => {} }) {
267
+ constructor({ manager, store, run, state, commit = async () => null, changes = async () => ({ files: [] }), transcript, benches = null, log = () => {} }) {
268
268
  this.manager = manager;
269
269
  this.store = store;
270
270
  this.run = run;
271
271
  this.state = state;
272
+ // The commit the tests ran on, and whether nothing was left uncommitted: merging relies on it.
273
+ this.commit = commit;
272
274
  this.changes = changes;
273
275
  this.transcript = transcript;
274
276
  this.benches = benches;
@@ -334,8 +336,9 @@ export class Evals {
334
336
  try {
335
337
  const started = Date.now();
336
338
  const st = await this.state(agent).catch(() => null);
339
+ const at = await this.commit(agent).catch(() => null);
337
340
  const res = await this.run(agent, command);
338
- rerun = { command, passed: Boolean(res.passed), counts: countsOf(res.output), tail: clip(String(res.output ?? '').split('\n').slice(-15).join('\n'), 2000), timedOut: Boolean(res.timedOut), state: st, at: now(), ms: Date.now() - started };
341
+ rerun = { command, passed: Boolean(res.passed), counts: countsOf(res.output), tail: clip(String(res.output ?? '').split('\n').slice(-15).join('\n'), 2000), timedOut: Boolean(res.timedOut), state: st, head: at?.head ?? null, clean: at?.clean ?? null, at: now(), ms: Date.now() - started };
339
342
  } catch (e) {
340
343
  rerun = { command, passed: false, counts: null, tail: clip(String(e?.message ?? e), 2000), timedOut: false, state: null, at: now(), ms: 0 };
341
344
  } finally {
@@ -389,6 +392,7 @@ export class Evals {
389
392
  // A test run ended while this was worked out: the one it ended with has the newer answer.
390
393
  if (!rerun && (cur.eval?.rerun?.at ?? null) !== (agent.eval?.rerun?.at ?? null)) return this.view(id);
391
394
  this.manager.patch(id, { eval: { ...ev, rerun: rerun ?? cur.eval?.rerun ?? null, postedTo: cur.eval?.postedTo ?? null } });
395
+ this.manager.emit?.('evaluated', this.store.get(id));
392
396
  return this.view(id);
393
397
  }
394
398
 
package/src/landing.js CHANGED
@@ -1,16 +1,18 @@
1
1
  // Landing: getting agents' pull requests merged. Failing checks and requested changes are sent
2
2
  // back to the agent that owns the PR (a few times per PR at most), new review comments are sent
3
3
  // to it for as long as the PR is open, a branch that fell behind is brought up to date with the
4
- // branch it targets, and ready PRs are merged with one click.
4
+ // branch it targets, and ready PRs are merged with one click. A PR whose Eval is 100% on its latest
5
+ // commit is "sure": listed first, and merged on its own when that is turned on.
5
6
  import os from 'node:os';
6
7
  import * as git from './git.js';
7
8
  import { NO_REPO } from './manager.js';
8
- import { AGENT_MARK, ghBin, newFeedback, prFeedback } from './tracker.js';
9
+ import { AGENT_MARK, ghBin, landState, newFeedback, prFeedback } from './tracker.js';
9
10
  import { triggerSettings } from './triggers.js';
10
11
  import { parseBaseRef } from './review.js';
12
+ import { sureToMerge as sureOf } from '../public/sure.js';
11
13
 
12
14
  export const MERGE_METHODS = ['squash', 'merge', 'rebase'];
13
- export const LANDING_DEFAULTS = { fixChecks: true, fixReviews: true, fixComments: true, maxFixes: 3, mergeMethod: 'squash', deleteBranch: true };
15
+ export const LANDING_DEFAULTS = { fixChecks: true, fixReviews: true, fixComments: true, maxFixes: 3, mergeMethod: 'squash', deleteBranch: true, mergeWhenSure: false, sureNeedsApproval: true };
14
16
  // Rounds of review comments sent per PR: a stop in case an agent's own replies keep coming back.
15
17
  const COMMENT_ROUNDS = 30;
16
18
  const QUOTE_MAX = 1500;
@@ -30,9 +32,12 @@ export function landingSettings(config = {}) {
30
32
  maxFixes: Number.isFinite(n) && n >= 0 ? Math.min(20, Math.floor(n)) : LANDING_DEFAULTS.maxFixes,
31
33
  mergeMethod: MERGE_METHODS.includes(c.mergeMethod) ? c.mergeMethod : LANDING_DEFAULTS.mergeMethod,
32
34
  deleteBranch: c.deleteBranch !== false,
35
+ mergeWhenSure: c.mergeWhenSure === true,
36
+ sureNeedsApproval: c.sureNeedsApproval !== false,
33
37
  };
34
38
  }
35
39
 
40
+
36
41
  export function checksMessage(pr) {
37
42
  const names = pr.checks?.failed?.length ? pr.checks.failed.join(', ') : 'some checks';
38
43
  return [
@@ -84,6 +89,9 @@ export function updateMessage(base) {
84
89
  return `Your branch is behind ${base}. Merge ${base} into it (git fetch, then git merge ${base}), resolve any conflicts keeping both sides' intent, run the tests, then commit and push.`;
85
90
  }
86
91
 
92
+ /** sureToMerge with where the pull request stands worked out here. */
93
+ export const sureToMerge = (agent, pr, opts = {}) => sureOf(agent, pr, { ...opts, land: landState(pr) });
94
+
87
95
  export class Landing {
88
96
  constructor({ manager, store, config = {}, log = (m) => console.log(`[agentmgr] ${m}`) }) {
89
97
  this.manager = manager;
@@ -92,6 +100,8 @@ export class Landing {
92
100
  this.log = log;
93
101
  this.onPrs = (agent) => this.react(agent).catch((e) => this.log(`landing: ${e.message}`));
94
102
  manager.on('prs', this.onPrs);
103
+ this.onEvaluated = (agent) => agent && this.mergeIfSure(agent).catch((e) => this.log(`landing: ${e.message}`));
104
+ manager.on('evaluated', this.onEvaluated);
95
105
  // Running agents' PRs are refreshed by the manager; closed agents with an open PR every few minutes.
96
106
  this.timer = setInterval(() => this.refreshClosed().catch(() => {}), (config.landingRefreshMin ?? 6) * 60_000);
97
107
  this.timer.unref?.();
@@ -100,6 +110,7 @@ export class Landing {
100
110
  close() {
101
111
  clearInterval(this.timer);
102
112
  this.manager.off('prs', this.onPrs);
113
+ this.manager.off('evaluated', this.onEvaluated);
103
114
  }
104
115
 
105
116
  get settings() {
@@ -109,8 +120,11 @@ export class Landing {
109
120
  update(patch = {}) {
110
121
  if (patch.mergeMethod !== undefined && !MERGE_METHODS.includes(patch.mergeMethod)) throw err(400, `mergeMethod must be one of ${MERGE_METHODS.join(', ')}`);
111
122
  if (patch.maxFixes !== undefined && !(Number(patch.maxFixes) >= 0)) throw err(400, 'maxFixes must be 0 or more');
123
+ const was = this.settings.mergeWhenSure;
112
124
  const next = landingSettings({ landing: { ...this.config.landing, ...patch } });
113
125
  this.config.landing = next;
126
+ // Just turned on: what is already sure merges now, not on its next change.
127
+ if (next.mergeWhenSure && !was) for (const a of this.store.list()) this.mergeIfSure(a).catch((e) => this.log(`landing: ${e.message}`));
114
128
  return next;
115
129
  }
116
130
 
@@ -147,6 +161,36 @@ export class Landing {
147
161
  else if (s.fixReviews && pr.review === 'CHANGES_REQUESTED' && !watched?.changesRequested) send('review', reviewMessage(pr));
148
162
  }
149
163
  if (sent) this.store.save();
164
+ await this.mergeIfSure(agent);
165
+ }
166
+
167
+ /**
168
+ * Merge the agent's pull requests that are sure to merge, when that is turned on. Tried once per
169
+ * commit: a failure (a policy, branch protection) is kept and shown, not retried until it changes.
170
+ */
171
+ async mergeIfSure(agent) {
172
+ const s = this.settings;
173
+ if (!s.mergeWhenSure || NO_REPO.has(agent.kind)) return;
174
+ for (const pr of this.openPrs(agent)) {
175
+ if (!sureToMerge(agent, pr, { needApproval: s.sureNeedsApproval }).sure) continue;
176
+ const cur = this.store.get(agent.id);
177
+ if (!cur) return;
178
+ const tried = ((cur.landing ??= { sent: {} }).sure ??= {});
179
+ const key = `${pr.url}@${pr.head}`;
180
+ if (tried[key]) continue;
181
+ tried[key] = { at: new Date().toISOString() };
182
+ this.store.save();
183
+ try {
184
+ await this.merge(agent.id, { url: pr.url });
185
+ tried[key].merged = true;
186
+ this.log(`landing: merged ${pr.url}: its Eval is 100% on its latest commit`);
187
+ } catch (e) {
188
+ tried[key].error = e.message;
189
+ this.log(`landing: couldn't merge ${pr.url} on its Eval: ${e.message}`);
190
+ }
191
+ // Through patch, so open screens show the merge or why it didn't happen.
192
+ if (this.store.get(agent.id)) this.manager.patch(agent.id, { landing: this.store.get(agent.id).landing });
193
+ }
150
194
  }
151
195
 
152
196
  /**
@@ -198,11 +242,13 @@ export class Landing {
198
242
  for (const pr of view.prs.filter((p) => p.state === 'OPEN' && p.source !== 'mentioned')) {
199
243
  const fixes = Object.keys(agent.landing?.sent ?? {}).filter((k) => k.startsWith(`${pr.url}#`)).length;
200
244
  const comments = agent.landing?.comments?.[pr.url]?.count ?? 0;
201
- rows.push({ agent: { id: agent.id, name: agent.name, priority: view.priority, busy: view.runtime.busy, running: view.runtime.running }, pr, land: pr.land ?? 'waiting', fixes, comments });
245
+ const sure = sureToMerge(agent, pr, { needApproval: this.settings.sureNeedsApproval });
246
+ const tried = agent.landing?.sure?.[`${pr.url}@${pr.head}`] ?? null;
247
+ rows.push({ agent: { id: agent.id, name: agent.name, priority: view.priority, busy: view.runtime.busy, running: view.runtime.running }, pr, land: pr.land ?? 'waiting', fixes, comments, confidence: agent.eval?.confidence ?? null, sure, tried });
202
248
  }
203
249
  }
204
250
  const rank = (r) => (LAND_ORDER.includes(r.land) ? LAND_ORDER.indexOf(r.land) : LAND_ORDER.length);
205
- return { settings: this.settings, rows: rows.sort((a, b) => rank(a) - rank(b) || a.agent.priority - b.agent.priority) };
251
+ return { settings: this.settings, rows: rows.sort((a, b) => rank(a) - rank(b) || Number(b.sure.sure) - Number(a.sure.sure) || a.agent.priority - b.agent.priority) };
206
252
  }
207
253
 
208
254
  agentPr(ref, url) {
package/src/server.js CHANGED
@@ -166,6 +166,11 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
166
166
  const [head, status, diff] = await Promise.all([git.run('git', ['rev-parse', 'HEAD'], opts), git.run('git', ['status', '--porcelain'], opts), git.run('git', ['diff', 'HEAD'], opts)]);
167
167
  return stateHash(head.trim(), status, diff);
168
168
  },
169
+ commit: async (a) => {
170
+ const opts = { cwd: a.workdir, timeout: 30_000 };
171
+ const [head, status] = await Promise.all([git.run('git', ['rev-parse', 'HEAD'], opts), git.run('git', ['status', '--porcelain'], opts)]);
172
+ return { head: head.trim(), clean: !status.trim() };
173
+ },
169
174
  changes: (a) => review.get(a.id),
170
175
  // Claude Code's session: the test runs in it. Other engines keep theirs differently.
171
176
  transcript: (a) => (engineOf(a).id === 'claude' && a.workdir ? readTail(engineOf(a).sessionFile(a.workdir, a.sessionId)) : null),