ai-agentmanager 1.69.0 → 1.70.1
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 +9 -0
- package/README.md +30 -0
- package/package.json +1 -1
- package/public/app.js +2 -2
- package/public/groups.js +10 -1
- package/public/quality.js +7 -2
- package/src/cli.js +15 -1
- package/src/manager.js +5 -2
- package/src/quality.js +69 -6
- package/src/record.js +51 -1
- package/src/server.js +7 -1
- package/src/standards.js +2 -0
- package/src/weekly.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.70.1 (2026-11-24)
|
|
4
|
+
|
|
5
|
+
- **Split screen: a view no longer starts following itself.** The daemon sent a new terminal size back to every view, including the one that set it. When that view fitted itself twice in a row, the first size came back after the second, was taken for another view's, and the view shrank to follow it. The daemon no longer sends a view its own size, and a view ignores a size it sent a moment ago. Found from the sizes the split screen test now reports when it fails.
|
|
6
|
+
|
|
7
|
+
## 1.70.0 (2026-11-24)
|
|
8
|
+
|
|
9
|
+
- **Production signal: incidents from your monitoring tool.** Any tool, a script or you can report an incident (`agentmgr quality incident "<title>"`, or `POST /api/quality/incident`). It is linked to the merged pull request it belongs to: the one it names, the one that merged as the commit it was seen on, or the latest that changed a file in its stack trace. That pull request then shows **Incident in production** and counts as one that did not hold up in Quality, the track record and the weekly summary. The same id is counted once. An agent cannot report one.
|
|
10
|
+
- **Delegation map.** The track record sorts work by kind (features, bug fixes, tests, documentation, upgrades, refactoring, investigation), read from each request's words, with how it held up and how much ran without you. It names the next kind worth handing over more of, and the kinds worth keeping close. It sees only work given to agents.
|
|
11
|
+
|
|
3
12
|
## 1.69.0 (2026-11-24)
|
|
4
13
|
|
|
5
14
|
- **Read first: where your attention goes.** **Read first** in the top bar, or `agentmgr read-first`, ranks finished work waiting for your review by how much it needs reading: **Read closely**, **Look** or **Skim**, with the reasons and where to start. The ranking adds up facts the app already measured: high-risk files, the scorecard, checks and CI, breaks the tests did not notice, recorded commands that gave a different result, what was left out, risks not checked, the agent's own confidence, size, and questions answered for you. No model decides it.
|
package/README.md
CHANGED
|
@@ -601,6 +601,23 @@ A break the tests fail on is **Caught**. A break they still pass on is **Not not
|
|
|
601
601
|
- The breaks are made on the text of a line, not on a parsed program. They cover JavaScript, TypeScript, Python, Go, Ruby, Java, Kotlin, Rust, C, C++, C#, PHP, Swift and Scala.
|
|
602
602
|
- Each run of the tests may take 5 minutes at most, and a whole run 15 (`"testTheTests"` in config.json: `max`, `timeoutMs`, `budgetMs`). An agent in a container is not covered.
|
|
603
603
|
|
|
604
|
+
## Production signal: incidents from your monitoring tool
|
|
605
|
+
|
|
606
|
+
Quality judges merged work by what GitHub shows. An incident in production says more: users met it. Any monitoring tool, a script, or you can report one, and it is linked to the merged pull request it belongs to:
|
|
607
|
+
|
|
608
|
+
```sh
|
|
609
|
+
agentmgr quality incident "NaN totals at checkout" --files src/total.js:12 --id DD-9 --url https://monitor.example/DD-9
|
|
610
|
+
curl -X POST -H 'x-agentmgr: 1' -H 'content-type: application/json' http://127.0.0.1:<port>/api/quality/incident \
|
|
611
|
+
-d '{"title":"NaN totals at checkout","commit":"feedbeef","id":"DD-9","source":"datadog"}'
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
- **How it is matched.** The pull request it names (`--pr`); else the one that merged as the commit it was seen on (`--commit`: a release is often a commit); else, of the pull requests merged in the watch days before it, the latest that changed a file in its stack trace (`--files`).
|
|
615
|
+
- **What it changes.** That pull request shows **Incident in production** in Quality, with the link and how it was matched. It counts as one that did not hold up in Quality's totals, the [track record](#track-record-was-the-confidence-right) and the [weekly summary](#weekly-summary-the-weeks-work-and-achievements-for-management), and it can become a lesson in [Standards](#standards-what-every-change-in-a-repository-has-to-meet). What you mark yourself still wins.
|
|
616
|
+
- **Reported twice.** The same `--id` is counted once. A wrong match can be taken off (`POST /api/quality/incident/drop` with the pull request and the id).
|
|
617
|
+
- **Who reports it.** You or your tools; an agent's own call is refused.
|
|
618
|
+
|
|
619
|
+
**Limits.** There is no built-in connector to a particular tool: point your tool's webhook, or a small script, at the route above. The daemon listens on this computer, so a tool in the cloud needs a script that forwards to it. Matching by files picks the latest pull request that touched them, which can be the wrong one when several did.
|
|
620
|
+
|
|
604
621
|
## Track record: was the confidence right?
|
|
605
622
|
|
|
606
623
|
An agent writes "Confidence: 85%" and the scorecard says "Ready to approve". The track record shows how much those were worth.
|
|
@@ -625,6 +642,19 @@ An agent writes "Confidence: 85%" and the scorecard says "Ready to approve". The
|
|
|
625
642
|
|
|
626
643
|
A row with fewer than 5 settled pull requests says "too few to say". "Said more than held up" means the average confidence was at least 15 points above the share that held.
|
|
627
644
|
|
|
645
|
+
### Delegation map: what to hand over next
|
|
646
|
+
|
|
647
|
+
The track record also sorts work by kind, read from the words of each request: features, bug fixes, tests, documentation, upgrades and migrations, refactoring, investigation. For each kind it shows how it held up and how much of it ran without you.
|
|
648
|
+
|
|
649
|
+
| Advice | When |
|
|
650
|
+
| --- | --- |
|
|
651
|
+
| **Hand over more** | At least 5 settled pull requests, 9 in 10 held up, and most of it still asked you |
|
|
652
|
+
| **Keep close** | At least 5 settled, and under 7 in 10 held up |
|
|
653
|
+
|
|
654
|
+
The kind that held up best among the "hand over more" ones is named as the next to hand over: set its projects' level, or start that kind of work with "Agree, then run".
|
|
655
|
+
|
|
656
|
+
**Limits.** It sees only work given to agents, not what you do by hand. The kind is read from words with fixed rules, so a request can land in the wrong kind; work it cannot place counts as a feature. Pull requests merged before this version are sorted by their title.
|
|
657
|
+
|
|
628
658
|
### Model fit: which model held up as well for less
|
|
629
659
|
|
|
630
660
|
The track record also compares models. For each engine and model it shows how many settled pieces it did, the share that held up, the average review scorecard and the cost per piece against the most used model's (a ratio, not money).
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -29,7 +29,7 @@ import { initSupport } from '/support.js';
|
|
|
29
29
|
import { initCode } from '/code.js';
|
|
30
30
|
import { initMachine } from '/machine.js';
|
|
31
31
|
import { initWatch } from '/watch.js';
|
|
32
|
-
import { initGroups, followSize, scaleToFit, leadSize, ownFont, newFont } from '/groups.js';
|
|
32
|
+
import { initGroups, followSize, scaleToFit, leadSize, ownFont, newFont, sentSize } from '/groups.js';
|
|
33
33
|
import { termFont } from '/termfont.js';
|
|
34
34
|
import { initTopNav } from '/topnav.js';
|
|
35
35
|
import { initStandup } from '/standup.js';
|
|
@@ -2905,7 +2905,7 @@ const term = {
|
|
|
2905
2905
|
this.send({ t: 'i', d });
|
|
2906
2906
|
});
|
|
2907
2907
|
// Shown in a split-screen group too (or another window): the view typed in sets the size.
|
|
2908
|
-
this.xterm.onResize(({ cols, rows }) => !this.follow && this.send({ t: 'r', cols, rows }));
|
|
2908
|
+
this.xterm.onResize(({ cols, rows }) => !this.follow && (sentSize(this, cols, rows), this.send({ t: 'r', cols, rows })));
|
|
2909
2909
|
new ResizeObserver(() => (this.follow ? scaleToFit(this, $('#terminal')) : this.refit())).observe($('#terminal'));
|
|
2910
2910
|
window.addEventListener('agentmgr-termfont', () => newFont(this, () => this.refit(), $('#terminal')));
|
|
2911
2911
|
touchScroll($('#terminal'), this.xterm);
|
package/public/groups.js
CHANGED
|
@@ -20,9 +20,17 @@ const isShell = (k) => /^shell(:\d+)?$/.test(k ?? '');
|
|
|
20
20
|
// click sets the session's size; the others show it at that size, the font scaled to fit, until
|
|
21
21
|
// you type in or click one of them (a view made much smaller says so). `v` is { xterm, follow }.
|
|
22
22
|
|
|
23
|
+
/** This view sent the session a size (it leads): kept briefly, so its own size coming back is not taken for another view's. */
|
|
24
|
+
export function sentSize(v, cols, rows) {
|
|
25
|
+
const t = Date.now();
|
|
26
|
+
v.sentSizes = [...(v.sentSizes ?? []).filter((x) => t - x.at < 3000), { cols, rows, at: t }];
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
/** Another view resized the session: show it at that size. */
|
|
24
30
|
export function followSize(v, cols, rows, box) {
|
|
25
31
|
if (!(cols > 0 && rows > 0) || (cols === v.xterm.cols && rows === v.xterm.rows)) return;
|
|
32
|
+
// A size this view sent a moment ago, coming back after it fitted again: not another view's.
|
|
33
|
+
if (!v.follow && (v.sentSizes ?? []).some((x) => x.cols === cols && x.rows === rows && Date.now() - x.at < 3000)) return;
|
|
26
34
|
v.follow = true;
|
|
27
35
|
v.xterm.resize(cols, rows);
|
|
28
36
|
fitSoon(v, box);
|
|
@@ -71,6 +79,7 @@ export function leadSize(v, fit, send) {
|
|
|
71
79
|
try {
|
|
72
80
|
fit();
|
|
73
81
|
} catch {}
|
|
82
|
+
sentSize(v, v.xterm.cols, v.xterm.rows);
|
|
74
83
|
send({ t: 'r', cols: v.xterm.cols, rows: v.xterm.rows });
|
|
75
84
|
}
|
|
76
85
|
|
|
@@ -130,7 +139,7 @@ export function initGroups({ $, esc, agents, Terminal, FitAddon, openStream, api
|
|
|
130
139
|
lead(p);
|
|
131
140
|
p.conn?.send({ t: 'i', d });
|
|
132
141
|
});
|
|
133
|
-
xterm.onResize(({ cols, rows }) => !p.follow && p.conn?.send({ t: 'r', cols, rows }));
|
|
142
|
+
xterm.onResize(({ cols, rows }) => !p.follow && (sentSize(p, cols, rows), p.conn?.send({ t: 'r', cols, rows })));
|
|
134
143
|
new ResizeObserver(() => (p.follow ? scaleToFit(p, el.querySelector('.gterm')) : refit(p))).observe(el.querySelector('.gterm'));
|
|
135
144
|
panes.set(id, p);
|
|
136
145
|
if (show.agentId) load(id, show.agentId, show.kind);
|
package/public/quality.js
CHANGED
|
@@ -14,8 +14,8 @@ const PERIODS = [
|
|
|
14
14
|
['year', 'Year'],
|
|
15
15
|
];
|
|
16
16
|
const SAVED = 'agentmgr.qualityPeriod';
|
|
17
|
-
const WORD = { reverted: 'Reverted', fixed: 'Fixed afterwards', broke: 'Checks failed', problem: 'A problem', clean: 'Held up', watching: 'Fine so far', unchecked: 'Not looked at' };
|
|
18
|
-
const BAD = new Set(['reverted', 'fixed', 'broke', 'problem']);
|
|
17
|
+
const WORD = { incident: 'Incident in production', reverted: 'Reverted', fixed: 'Fixed afterwards', broke: 'Checks failed', problem: 'A problem', clean: 'Held up', watching: 'Fine so far', unchecked: 'Not looked at' };
|
|
18
|
+
const BAD = new Set(['incident', 'reverted', 'fixed', 'broke', 'problem']);
|
|
19
19
|
|
|
20
20
|
export function initQuality({ api, $, esc, toast, ago, openAgent }) {
|
|
21
21
|
const dialog = $('#quality-dialog');
|
|
@@ -92,6 +92,7 @@ export function initQuality({ api, $, esc, toast, ago, openAgent }) {
|
|
|
92
92
|
function why(it) {
|
|
93
93
|
const a = it.after;
|
|
94
94
|
if (it.mark) return `You said so${it.mark.note ? `: ${esc(it.mark.note)}` : ''}`;
|
|
95
|
+
if (it.verdict === 'incident') return it.incidents.map((x) => `${x.url ? `<a href="${esc(x.url)}" target="_blank" rel="noopener">${esc(x.title)}</a>` : esc(x.title)} <span class="hint">matched by ${esc(x.by)}${x.source ? ` · ${esc(x.source)}` : ''}</span>`).join('<br>');
|
|
95
96
|
if (it.verdict === 'reverted') return `Reverted by ${link(a.reverted)}`;
|
|
96
97
|
if (it.verdict === 'fixed') return a.fixes.map((f) => `${link(f)}${f.shared.length ? ` <span class="hint">same file${f.shared.length === 1 ? '' : 's'}: ${esc(f.shared.join(', '))}</span>` : ' <span class="hint">names it</span>'}`).join('<br>');
|
|
97
98
|
if (it.verdict === 'broke') return `Failed on the merged commit: ${esc(a.checks.failed.join(', '))}`;
|
|
@@ -145,6 +146,9 @@ export function initQuality({ api, $, esc, toast, ago, openAgent }) {
|
|
|
145
146
|
${table('The review scorecard', 'What the scorecard recommended as it merged.', r.scorecard)}
|
|
146
147
|
${table('Tests tested', 'Whether the tests were tested before the merge (Test the tests), and how that went.', r.tests)}
|
|
147
148
|
${table('Model', 'The engine and model that did the work.', r.models)}
|
|
149
|
+
${r.delegation.rows.length ? `<h3 class="rec-head">Delegation map</h3><p class="hint">By kind of work, read from the words of each request: how it held up and how much of it ran without you. A kind that held up 9 times in 10 over at least 5 settled pull requests while most of it still asked you is worth handing over more of; under 7 in 10 is worth keeping close. It sees only the work given to agents, not what you do by hand.</p>
|
|
150
|
+
<div class="issues-scroll"><table class="issues rec-table"><thead><tr><th>Kind of work</th><th class="num">Held up</th><th class="num">Share</th><th class="num">Without you</th><th></th></tr></thead><tbody>${r.delegation.rows.map((d) => `<tr><td>${esc(d.label)}</td><td class="num">${d.held} of ${d.n}</td><td class="num">${d.heldPct}%</td><td class="num">${d.withoutYou} of ${d.n}</td><td class="${d.advice === 'hand over more' ? 'rec-ok' : d.advice ? 'rec-bad' : 'hint'}">${d.advice ?? (d.n < 5 ? 'too few to say' : 'keep as is')}</td></tr>`).join('')}</tbody></table></div>
|
|
151
|
+
${r.delegation.next ? `<p class="rec-ok">Next to hand over more of: <b>${esc(r.delegation.next.label)}</b> (${r.delegation.next.heldPct}% held up over ${r.delegation.next.n}, most of it still asking you). Set its projects' level above, or start that kind of work with <i>Agree, then run</i>.</p>` : ''}` : ''}
|
|
148
152
|
${r.fit.rows.length > 1 ? `<h3 class="rec-head">Model fit</h3><p class="hint">Which model held up as well as the most used one at a lower cost. Cost is shown against the most used model's, per piece of work. A suggestion needs 5 settled pull requests for both, a share that held up within 5 points of the most used model's, and at most three quarters of its cost.</p>
|
|
149
153
|
<div class="issues-scroll"><table class="issues rec-table"><thead><tr><th>Model</th><th class="num">Held up</th><th class="num">Share</th><th class="num">Scorecard</th><th class="num">Cost</th></tr></thead><tbody>${r.fit.rows.map((m, i) => `<tr><td>${esc(m.model)}</td><td class="num">${m.held} of ${m.n}</td><td class="num">${m.heldPct}%</td><td class="num">${m.score ?? '—'}</td><td class="num">${i === 0 ? 'the most used' : m.costVsMain == null ? '—' : `${m.costVsMain}×`}</td></tr>`).join('')}</tbody></table></div>
|
|
150
154
|
${r.fit.suggestion ? `<p class="rec-ok"><b>${esc(r.fit.suggestion.model)}</b> held up as well as ${esc(r.fit.suggestion.main)} (${r.fit.suggestion.heldPct}% against ${r.fit.suggestion.mainHeldPct}%) at ${r.fit.suggestion.costVsMain}× the cost, over ${r.fit.suggestion.n} settled pull requests: worth trying for more of the work.</p>` : ''}` : ''}
|
|
@@ -216,6 +220,7 @@ export function initQuality({ api, $, esc, toast, ago, openAgent }) {
|
|
|
216
220
|
<div class="value-cards">
|
|
217
221
|
${card('Held up', pct(t.heldPct), `${t.held} of ${t.checked} looked at${t.watching ? `; ${t.watching} still watched` : ''}`, prev && t.heldPct != null ? t.heldPct - prev.heldPct : null, true)}
|
|
218
222
|
${card('Problems after the merge', String(t.problems), `${pct(t.failurePct)} of those looked at`, prev && t.failurePct != null ? t.failurePct - prev.failurePct : null, false)}
|
|
223
|
+
${t.incident ? card('Incidents in production', String(t.incident), 'reported by a monitoring tool or by you', null) : ''}
|
|
219
224
|
${card('Reverted', String(t.reverted), 'taken back out', null)}
|
|
220
225
|
${card('Fixed afterwards', String(t.fixed), `a fix to the same files within ${s.watchDays} days`, null)}
|
|
221
226
|
${card('Checks failed', String(t.broke), 'on the commit it merged as', null)}
|
package/src/cli.js
CHANGED
|
@@ -1641,7 +1641,7 @@ export async function main(argv) {
|
|
|
1641
1641
|
const now = v.periods[0];
|
|
1642
1642
|
const items = v.items.filter((it) => now.items.includes(it.url));
|
|
1643
1643
|
if (items.length) console.log('');
|
|
1644
|
-
const word = { reverted: 'reverted', fixed: 'fixed afterwards', broke: 'failed checks', problem: 'a problem (yours)', clean: 'held up', watching: 'fine so far', unchecked: 'not looked at' };
|
|
1644
|
+
const word = { incident: 'incident in production', reverted: 'reverted', fixed: 'fixed afterwards', broke: 'failed checks', problem: 'a problem (yours)', clean: 'held up', watching: 'fine so far', unchecked: 'not looked at' };
|
|
1645
1645
|
for (const it of items) console.log(` ${truncate(`#${it.number ?? '?'} ${it.title}`, 54).padEnd(54)} ${(['clean', 'watching'].includes(it.verdict) ? green : it.verdict === 'unchecked' ? dim : yellow)(word[it.verdict].padEnd(17))} ${dim(it.url)}`);
|
|
1646
1646
|
if (!v.github) console.log(dim('\nGitHub is not asked here, so nothing is looked at.'));
|
|
1647
1647
|
});
|
|
@@ -1656,6 +1656,20 @@ export async function main(argv) {
|
|
|
1656
1656
|
console.log((await api('GET', '/quality/record?format=md')).markdown);
|
|
1657
1657
|
for (const p of r.projects.filter((x) => x.suggestion)) console.log(dim(`\nSet it: agentmgr autonomy --project "${p.label}" --default ${p.suggestion.level}`));
|
|
1658
1658
|
});
|
|
1659
|
+
qualityCmd
|
|
1660
|
+
.command('incident <title>')
|
|
1661
|
+
.description('Report an incident from production. It is linked to the merged pull request it belongs to (by --pr, the --commit it was seen on, or --files from its stack trace), which then counts as one that did not hold up, in Quality, the track record and the weekly summary. For a monitoring tool or a script: POST /api/quality/incident with the same fields.')
|
|
1662
|
+
.option('--pr <url>', 'the pull request it belongs to')
|
|
1663
|
+
.option('--commit <sha>', 'the commit or release it was seen on')
|
|
1664
|
+
.option('--files <list>', 'files from its stack trace, comma separated')
|
|
1665
|
+
.option('--url <url>', 'a link to the incident in your monitoring tool')
|
|
1666
|
+
.option('--id <id>', 'its id in your monitoring tool: reported again, it is not counted twice')
|
|
1667
|
+
.option('--at <date>', 'when it happened (default: now)')
|
|
1668
|
+
.action(async (title, o) => {
|
|
1669
|
+
await daemon();
|
|
1670
|
+
const it = await api('POST', '/quality/incident', { title, pr: o.pr, commit: o.commit, files: o.files, url: o.url, id: o.id, at: o.at, source: 'cli' });
|
|
1671
|
+
console.log(`${green('✓')} linked to #${it.number ?? '?'} ${bold(it.title)} ${dim(`(matched by ${it.matchedBy})`)}`);
|
|
1672
|
+
});
|
|
1659
1673
|
qualityCmd
|
|
1660
1674
|
.command('mark <pr-url>')
|
|
1661
1675
|
.description('Say what a merged pull request was: not a problem, a problem, or back to what was found')
|
package/src/manager.js
CHANGED
|
@@ -2087,7 +2087,8 @@ export class AgentManager extends EventEmitter {
|
|
|
2087
2087
|
this.termRuntime(id, kind)?.pty?.write(data);
|
|
2088
2088
|
}
|
|
2089
2089
|
|
|
2090
|
-
|
|
2090
|
+
/** Resize a session. `from`: the viewer that asked, which is not sent its own size back. */
|
|
2091
|
+
resize(id, cols, rows, kind = 'claude', from = null) {
|
|
2091
2092
|
const rt = this.termRuntime(id, kind);
|
|
2092
2093
|
if (!rt || !(cols > 0 && rows > 0)) return;
|
|
2093
2094
|
const changed = rt.cols !== cols || rt.rows !== rows;
|
|
@@ -2097,7 +2098,9 @@ export class AgentManager extends EventEmitter {
|
|
|
2097
2098
|
rt.pty?.resize(cols, rows);
|
|
2098
2099
|
} catch {}
|
|
2099
2100
|
// Viewers that don't size the session follow it.
|
|
2100
|
-
|
|
2101
|
+
// (Sent back to the one that asked, a size it has since replaced with a newer one would make it
|
|
2102
|
+
// follow itself.)
|
|
2103
|
+
if (changed) for (const c of rt.clients ?? []) if (c !== from) c.send({ t: 'size', cols, rows });
|
|
2101
2104
|
}
|
|
2102
2105
|
|
|
2103
2106
|
// ------------------------------------------------------- ancillary shells
|
package/src/quality.js
CHANGED
|
@@ -21,8 +21,8 @@ const RETRY_MS = HOUR;
|
|
|
21
21
|
const PER_TICK = 3;
|
|
22
22
|
|
|
23
23
|
export const QUALITY_DEFAULTS = { enabled: true, watchDays: 14 };
|
|
24
|
-
export const VERDICTS = ['reverted', 'fixed', 'broke', 'problem', 'clean', 'watching', 'unchecked'];
|
|
25
|
-
const PROBLEMS = new Set(['reverted', 'fixed', 'broke', 'problem']);
|
|
24
|
+
export const VERDICTS = ['incident', 'reverted', 'fixed', 'broke', 'problem', 'clean', 'watching', 'unchecked'];
|
|
25
|
+
const PROBLEMS = new Set(['incident', 'reverted', 'fixed', 'broke', 'problem']);
|
|
26
26
|
|
|
27
27
|
const err = (status, message) => Object.assign(new Error(message), { status });
|
|
28
28
|
const clip = (s, n) => {
|
|
@@ -94,6 +94,8 @@ export function commitChecks(runs) {
|
|
|
94
94
|
export function verdictOf(it, s = QUALITY_DEFAULTS, t = Date.now()) {
|
|
95
95
|
if (it.mark?.verdict === 'clean') return 'clean';
|
|
96
96
|
if (it.mark?.verdict === 'problem') return 'problem';
|
|
97
|
+
// Seen in production (a monitoring tool reported it): what users met wins over what GitHub shows.
|
|
98
|
+
if (it.incidents?.length) return 'incident';
|
|
97
99
|
if (!it.after) return 'unchecked';
|
|
98
100
|
if (it.after.reverted) return 'reverted';
|
|
99
101
|
if (it.after.fixes?.length) return 'fixed';
|
|
@@ -111,12 +113,12 @@ const round = (n, d = 0) => (Number.isFinite(n) ? Math.round(n * 10 ** d) / 10 *
|
|
|
111
113
|
|
|
112
114
|
/** Totals for a set of merged pull requests. */
|
|
113
115
|
export function totals(items, s = QUALITY_DEFAULTS, t = Date.now()) {
|
|
114
|
-
const out = { prs: items.length, reverted: 0, fixed: 0, broke: 0, problem: 0, clean: 0, watching: 0, unchecked: 0, changesRequested: 0 };
|
|
116
|
+
const out = { prs: items.length, incident: 0, reverted: 0, fixed: 0, broke: 0, problem: 0, clean: 0, watching: 0, unchecked: 0, changesRequested: 0 };
|
|
115
117
|
for (const it of items) {
|
|
116
118
|
out[verdictOf(it, s, t)] += 1;
|
|
117
119
|
if ((it.facts?.changesRequested ?? 0) > 0) out.changesRequested += 1;
|
|
118
120
|
}
|
|
119
|
-
out.problems = out.reverted + out.fixed + out.broke + out.problem;
|
|
121
|
+
out.problems = out.incident + out.reverted + out.fixed + out.broke + out.problem;
|
|
120
122
|
// Of the ones looked at: the share that held up, and the share that didn't.
|
|
121
123
|
out.checked = out.prs - out.unchecked;
|
|
122
124
|
out.held = out.clean + out.watching;
|
|
@@ -147,7 +149,7 @@ export function aggregate(items, s = QUALITY_DEFAULTS, { period = 'week', count,
|
|
|
147
149
|
return out;
|
|
148
150
|
}
|
|
149
151
|
|
|
150
|
-
const VERDICT_TEXT = { reverted: 'reverted', fixed: 'fixed afterwards', broke: 'checks failed after the merge', problem: 'a problem (marked by me)', clean: 'held up', watching: 'no problem so far', unchecked: 'not looked at yet' };
|
|
152
|
+
const VERDICT_TEXT = { incident: 'caused an incident in production', reverted: 'reverted', fixed: 'fixed afterwards', broke: 'checks failed after the merge', problem: 'a problem (marked by me)', clean: 'held up', watching: 'no problem so far', unchecked: 'not looked at yet' };
|
|
151
153
|
|
|
152
154
|
/** A period's report as Markdown. */
|
|
153
155
|
export function qualityMarkdown(p, items, s = QUALITY_DEFAULTS, { who = '', prev = null, t = Date.now() } = {}) {
|
|
@@ -159,7 +161,7 @@ export function qualityMarkdown(p, items, s = QUALITY_DEFAULTS, { who = '', prev
|
|
|
159
161
|
`${x.prs} pull request${x.prs === 1 ? '' : 's'} from AI agents merged.`,
|
|
160
162
|
'',
|
|
161
163
|
`- **Held up**: ${x.heldPct == null ? 'n/a' : `${x.heldPct}%`}${was}: ${x.held} of ${x.checked} looked at${x.watching ? `, ${x.watching} still within the ${s.watchDays} days watched` : ''}`,
|
|
162
|
-
`- **Problems after the merge**: ${x.problems}: ${x.reverted} reverted, ${x.fixed} fixed afterwards, ${x.broke} with failed checks${x.problem ? `, ${x.problem} marked by me` : ''}`,
|
|
164
|
+
`- **Problems after the merge**: ${x.problems}: ${x.incident ? `${x.incident} caused an incident in production, ` : ''}${x.reverted} reverted, ${x.fixed} fixed afterwards, ${x.broke} with failed checks${x.problem ? `, ${x.problem} marked by me` : ''}`,
|
|
163
165
|
`- **Before the merge**: a reviewer asked for changes on ${x.changesRequested}${x.changesPct == null ? '' : ` (${x.changesPct}%)`}; ${x.hoursToMerge == null ? 'n/a' : `${x.hoursToMerge} hours`} from opened to merged (median)`,
|
|
164
166
|
'',
|
|
165
167
|
];
|
|
@@ -220,6 +222,34 @@ export const github = {
|
|
|
220
222
|
},
|
|
221
223
|
};
|
|
222
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Which merged pull request an incident from production belongs to. In order: the pull request it
|
|
227
|
+
* names; the one that merged as the commit it was seen on (a release is often a commit); else, of
|
|
228
|
+
* the ones merged in the watch days before it, the latest that changed a file in its stack trace.
|
|
229
|
+
* { item, by } or null. `items`: Quality's merged pull requests.
|
|
230
|
+
*/
|
|
231
|
+
export function matchIncident(items, { pr = null, commit = null, files = [], at = Date.now() } = {}, s = QUALITY_DEFAULTS) {
|
|
232
|
+
if (pr) {
|
|
233
|
+
const it = items.find((x) => x.url === pr || x.url.replace(/\/+$/, '') === String(pr).replace(/\/+$/, ''));
|
|
234
|
+
return it ? { item: it, by: 'pull request' } : null;
|
|
235
|
+
}
|
|
236
|
+
const sha = String(commit ?? '').trim().toLowerCase();
|
|
237
|
+
if (sha.length >= 7) {
|
|
238
|
+
const it = items.find((x) => x.facts?.mergeCommit && (x.facts.mergeCommit.toLowerCase().startsWith(sha) || sha.startsWith(x.facts.mergeCommit.toLowerCase())));
|
|
239
|
+
if (it) return { item: it, by: 'commit' };
|
|
240
|
+
}
|
|
241
|
+
const want = (files ?? []).map((f) => String(f).replace(/^\.?\//, '').replace(/:\d+(:\d+)?$/, '')).filter(Boolean);
|
|
242
|
+
if (want.length) {
|
|
243
|
+
const t = typeof at === 'number' ? at : Date.parse(at) || Date.now();
|
|
244
|
+
const ends = (a, b) => a === b || a.endsWith(`/${b}`) || b.endsWith(`/${a}`);
|
|
245
|
+
const it = items
|
|
246
|
+
.filter((x) => Date.parse(x.mergedAt) <= t && t - Date.parse(x.mergedAt) <= s.watchDays * DAY && (x.facts?.files ?? []).some((f) => want.some((w) => ends(f, w))))
|
|
247
|
+
.sort((a, b) => b.mergedAt.localeCompare(a.mergedAt))[0];
|
|
248
|
+
if (it) return { item: it, by: 'files' };
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
|
|
223
253
|
export class Quality {
|
|
224
254
|
constructor({ manager, store, config = {}, who = null, gh = github, onChange = () => {}, log = (m) => console.log(`[agentmgr] ${m}`) }) {
|
|
225
255
|
Object.assign(this, { manager, store, config, who, gh, onChange, log });
|
|
@@ -332,6 +362,39 @@ export class Quality {
|
|
|
332
362
|
.sort((a, b) => (a.checkedAt ?? '').localeCompare(b.checkedAt ?? '') || b.mergedAt.localeCompare(a.mergedAt));
|
|
333
363
|
}
|
|
334
364
|
|
|
365
|
+
/**
|
|
366
|
+
* An incident from production (any monitoring tool, a script or you): linked to the merged pull
|
|
367
|
+
* request it belongs to, which then counts as one that did not hold up. Reported again with the
|
|
368
|
+
* same id, it is not counted twice.
|
|
369
|
+
*/
|
|
370
|
+
incident({ title = '', url = null, id = null, at = null, pr = null, commit = null, files = [], source = '' } = {}) {
|
|
371
|
+
this.scan();
|
|
372
|
+
const name = clip(title, 200);
|
|
373
|
+
if (!name) throw err(400, 'An incident needs a title: what went wrong');
|
|
374
|
+
const when = at ? Date.parse(at) : Date.now();
|
|
375
|
+
if (!Number.isFinite(when)) throw err(400, 'at is a date');
|
|
376
|
+
const found = matchIncident(Object.values(this.state.items), { pr, commit, files: Array.isArray(files) ? files : String(files ?? '').split(',').map((f) => f.trim()), at: when }, this.settings);
|
|
377
|
+
if (!found) throw err(404, pr ? 'No merged pull request with that link' : 'No merged pull request matches it: give the pull request, the commit it was seen on, or files from its stack trace');
|
|
378
|
+
const it = found.item;
|
|
379
|
+
const key = String(id ?? url ?? `${name}@${new Date(when).toISOString()}`);
|
|
380
|
+
it.incidents ??= [];
|
|
381
|
+
if (!it.incidents.some((x) => x.key === key)) it.incidents.push({ key, title: name, url: url ? clip(url, 500) : null, at: new Date(when).toISOString(), by: found.by, source: clip(source, 60) || null });
|
|
382
|
+
this.store.save();
|
|
383
|
+
this.onChange();
|
|
384
|
+
return { ...this.itemView(it), matchedBy: found.by };
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Take an incident off a pull request (it was not this one's). */
|
|
388
|
+
dropIncident(url, key) {
|
|
389
|
+
const it = this.state.items[url];
|
|
390
|
+
if (!it) throw err(404, 'No merged pull request with that link');
|
|
391
|
+
it.incidents = (it.incidents ?? []).filter((x) => x.key !== key);
|
|
392
|
+
if (!it.incidents.length) delete it.incidents;
|
|
393
|
+
this.store.save();
|
|
394
|
+
this.onChange();
|
|
395
|
+
return this.itemView(it);
|
|
396
|
+
}
|
|
397
|
+
|
|
335
398
|
/** What you say about a pull request: 'clean' (not a problem), 'problem', or null for what was found. */
|
|
336
399
|
mark(url, { verdict = null, note = '' } = {}) {
|
|
337
400
|
const it = this.state.items[url];
|
package/src/record.js
CHANGED
|
@@ -10,9 +10,27 @@ import { costOf } from './budgets.js';
|
|
|
10
10
|
export const MIN_TO_SAY = 5; // fewer settled pull requests than this say nothing
|
|
11
11
|
const LEVELS = ['ask', 'run', 'pr', 'merge'];
|
|
12
12
|
const LEVEL_LABEL = { ask: 'Ask me', run: 'Agree, then run', pr: 'Run to pull request', merge: 'Run to merge' };
|
|
13
|
-
const PROBLEMS = new Set(['reverted', 'fixed', 'broke', 'problem']);
|
|
13
|
+
const PROBLEMS = new Set(['incident', 'reverted', 'fixed', 'broke', 'problem']);
|
|
14
14
|
const round = (n) => (Number.isFinite(n) ? Math.round(n) : null);
|
|
15
15
|
|
|
16
|
+
// Kinds of work, read from the request's words (first match wins). No model: a rough sort that is
|
|
17
|
+
// stable and can be checked; work it cannot place is a feature.
|
|
18
|
+
export const KINDS = [
|
|
19
|
+
['docs', 'Documentation', /\b(docs?|readme|documentation|changelog|comments?)\b/i],
|
|
20
|
+
['tests', 'Tests', /\b(tests?|test cases?|coverage|e2e|unit tests?)\b/i],
|
|
21
|
+
['upgrade', 'Upgrades and migrations', /\b(upgrade|bump|migrat(e|ion)|dependenc(y|ies)|deprecat)/i],
|
|
22
|
+
['fix', 'Bug fixes', /\b(fix(es|ed)?|bugs?|crash(es)?|errors?|broken|regression|fails?|failing|exception)\b/i],
|
|
23
|
+
['refactor', 'Refactoring', /\b(refactor|clean ?up|rename|simplif(y|ies)|restructure|dedupe)\b/i],
|
|
24
|
+
['investigate', 'Investigation', /\b(investigate|explore|analy[sz]e|research|look into|find out|why)\b/i],
|
|
25
|
+
];
|
|
26
|
+
export const KIND_LABEL = { ...Object.fromEntries(KINDS.map(([k, l]) => [k, l])), feature: 'Features' };
|
|
27
|
+
|
|
28
|
+
/** The kind of a piece of work from its request or title. */
|
|
29
|
+
export function kindOf(text) {
|
|
30
|
+
const t = String(text ?? '').split('\n')[0].replace(/^<?https?:\/\/\S+>?\s*/, '');
|
|
31
|
+
return KINDS.find(([, , re]) => re.test(t))?.[0] ?? 'feature';
|
|
32
|
+
}
|
|
33
|
+
|
|
16
34
|
/** What is said about an agent's work now, kept when its pull request merges. */
|
|
17
35
|
export function saidOf(agent, { engine = null } = {}) {
|
|
18
36
|
const sc = agent.docs?.scorecard?.data;
|
|
@@ -30,6 +48,7 @@ export function saidOf(agent, { engine = null } = {}) {
|
|
|
30
48
|
level: LEVELS.includes(agent.autonomy?.level) ? agent.autonomy.level : 'ask',
|
|
31
49
|
// What the AI work cost as it merged, kept only to compare models with each other (never shown as money).
|
|
32
50
|
cost: costOf(agent) || null,
|
|
51
|
+
kind: kindOf(agent.intent ?? agent.name),
|
|
33
52
|
};
|
|
34
53
|
}
|
|
35
54
|
|
|
@@ -113,6 +132,31 @@ export function modelFit(settled) {
|
|
|
113
132
|
return { rows: out, suggestion };
|
|
114
133
|
}
|
|
115
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Delegation map: by kind of work, how much went to agents, how far it ran without the person,
|
|
137
|
+
* and how it held up. A kind that held up at 9 in 10 over 5 settled pull requests while most of it
|
|
138
|
+
* still asked the person is the next worth handing over more of; one under 7 in 10 is worth
|
|
139
|
+
* keeping close. `settled`: the settled pull requests.
|
|
140
|
+
*/
|
|
141
|
+
export function delegationMap(settled) {
|
|
142
|
+
const kindOfItem = (it) => it.said?.kind ?? kindOf(it.title);
|
|
143
|
+
const rows = Object.keys(KIND_LABEL)
|
|
144
|
+
.map((k) => {
|
|
145
|
+
const list = settled.filter((it) => kindOfItem(it) === k);
|
|
146
|
+
if (!list.length) return null;
|
|
147
|
+
const held = list.filter((it) => it.held).length;
|
|
148
|
+
const asked = list.filter((it) => (it.said?.level ?? 'ask') === 'ask').length;
|
|
149
|
+
const heldPct = round((held / list.length) * 100);
|
|
150
|
+
const advice =
|
|
151
|
+
list.length < MIN_TO_SAY ? null : heldPct >= 90 && asked * 2 > list.length ? 'hand over more' : heldPct < 70 ? 'keep close' : null;
|
|
152
|
+
return { kind: k, label: KIND_LABEL[k], n: list.length, held, heldPct, withoutYou: list.length - asked, advice };
|
|
153
|
+
})
|
|
154
|
+
.filter(Boolean)
|
|
155
|
+
.sort((a, b) => b.n - a.n);
|
|
156
|
+
const next = rows.filter((r) => r.advice === 'hand over more').sort((a, b) => b.heldPct - a.heldPct || b.n - a.n)[0] ?? null;
|
|
157
|
+
return { rows, next: next ? { kind: next.kind, label: next.label, heldPct: next.heldPct, n: next.n } : null };
|
|
158
|
+
}
|
|
159
|
+
|
|
116
160
|
/**
|
|
117
161
|
* The record from Quality's items. `verdict(it)` is quality.js's verdictOf; a pull request counts
|
|
118
162
|
* once it is settled: held up after the watch days, or a problem. `levels`: { default, projects }.
|
|
@@ -152,6 +196,7 @@ export function trackRecord(items, verdict, { levels = {} } = {}) {
|
|
|
152
196
|
models: rowsOf(settled, uniq((it) => `${it.said?.engine ?? 'unknown'}${it.said?.model ? ` · ${it.said.model}` : ''}`).map((k) => [k, k, (it) => `${it.said?.engine ?? 'unknown'}${it.said?.model ? ` · ${it.said.model}` : ''}` === k])),
|
|
153
197
|
levels: rowsOf(settled, LEVELS.map((l) => [l, LEVEL_LABEL[l], (it) => (it.said?.level ?? 'ask') === l])),
|
|
154
198
|
fit: modelFit(settled),
|
|
199
|
+
delegation: delegationMap(settled),
|
|
155
200
|
projects: projects.sort((a, b) => b.n - a.n),
|
|
156
201
|
defaultLevel: levels.default ?? 'ask',
|
|
157
202
|
};
|
|
@@ -172,6 +217,11 @@ export function recordMarkdown(r) {
|
|
|
172
217
|
part('Tests tested', r.tests);
|
|
173
218
|
part('Model', r.models);
|
|
174
219
|
part('Without you', r.levels);
|
|
220
|
+
if (r.delegation.rows.length) {
|
|
221
|
+
out.push('## Delegation map', '', ...r.delegation.rows.map((d) => `- ${d.label}: ${d.held} of ${d.n} held up (${d.heldPct}%), ${d.withoutYou} ran without you${d.advice ? `: ${d.advice}` : ''}`));
|
|
222
|
+
if (r.delegation.next) out.push('', `Next to hand over more of: **${r.delegation.next.label}** (${r.delegation.next.heldPct}% held up over ${r.delegation.next.n}, most of it still asking you).`);
|
|
223
|
+
out.push('');
|
|
224
|
+
}
|
|
175
225
|
if (r.fit.rows.length > 1) {
|
|
176
226
|
out.push('## Model fit', '', ...r.fit.rows.map((m) => `- ${m.model}: ${m.held} of ${m.n} held up (${m.heldPct}%)${m.score != null ? `, scorecard ${m.score} on average` : ''}${m.costVsMain != null && m !== r.fit.rows[0] ? `, ${m.costVsMain} times the cost of ${r.fit.rows[0].model}` : ''}`));
|
|
177
227
|
if (r.fit.suggestion) out.push('', `**${r.fit.suggestion.model}** held up as well as ${r.fit.suggestion.main} (${r.fit.suggestion.heldPct}% against ${r.fit.suggestion.mainHeldPct}%) at ${r.fit.suggestion.costVsMain} times the cost, over ${r.fit.suggestion.n} settled pull requests: worth trying for more of the work.`);
|
package/src/server.js
CHANGED
|
@@ -1421,6 +1421,12 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
1421
1421
|
const r = quality.record();
|
|
1422
1422
|
return req.query.format === 'md' ? { markdown: recordMarkdown(r) } : r;
|
|
1423
1423
|
}));
|
|
1424
|
+
// Production signal: an incident from any monitoring tool, a script or you, linked to the merged pull request it belongs to.
|
|
1425
|
+
api.post('/quality/incident', wrap((req) => {
|
|
1426
|
+
if (req.headers['x-agentmgr-agent']) throw fail(403, 'Incidents are reported by the person or their tools, not by an agent');
|
|
1427
|
+
return quality.incident({ ...(req.body ?? {}), source: req.body?.source ?? 'api' });
|
|
1428
|
+
}));
|
|
1429
|
+
api.post('/quality/incident/drop', wrap((req) => quality.dropIncident(String(req.body?.url ?? ''), String(req.body?.key ?? ''))));
|
|
1424
1430
|
api.post('/quality/mark', wrap((req) => quality.mark(String(req.body?.url ?? ''), { verdict: req.body?.verdict ?? null, note: req.body?.note ?? '' })));
|
|
1425
1431
|
api.post('/quality/check', wrap((req) => quality.check(String(req.body?.url ?? ''), { fresh: true })));
|
|
1426
1432
|
// Standards are the person's to set: an agent's own calls can read them, not change them.
|
|
@@ -2083,7 +2089,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
2083
2089
|
return;
|
|
2084
2090
|
}
|
|
2085
2091
|
if (msg.t === 'i' && typeof msg.d === 'string') manager.write(agent.id, msg.d, kind);
|
|
2086
|
-
else if (msg.t === 'r') manager.resize(agent.id, msg.cols | 0, msg.rows | 0, kind);
|
|
2092
|
+
else if (msg.t === 'r') manager.resize(agent.id, msg.cols | 0, msg.rows | 0, kind, client);
|
|
2087
2093
|
});
|
|
2088
2094
|
ws.on('close', () => session.detach());
|
|
2089
2095
|
} catch (err) {
|
package/src/standards.js
CHANGED
|
@@ -197,6 +197,7 @@ export function builtInChecks(bar, { files = [], diff = '' } = {}) {
|
|
|
197
197
|
// ---------------------------------------------------------------- lessons
|
|
198
198
|
|
|
199
199
|
const SOURCE_TEXT = {
|
|
200
|
+
incident: 'caused an incident in production',
|
|
200
201
|
reverted: 'was reverted',
|
|
201
202
|
fixed: 'needed a fix afterwards',
|
|
202
203
|
broke: 'failed its checks once merged',
|
|
@@ -216,6 +217,7 @@ export function cleanLesson(text) {
|
|
|
216
217
|
export function lessonSource(it) {
|
|
217
218
|
const a = it.after ?? {};
|
|
218
219
|
const name = (x) => clip(`${x?.number ? `#${x.number} ` : ''}${x?.title ?? ''}`, 140);
|
|
220
|
+
if (it.verdict === 'incident') return { kind: 'incident', detail: `Seen in production: ${(it.incidents ?? []).map((x) => clip(x.title, 100)).join('; ')}` };
|
|
219
221
|
if (it.verdict === 'reverted') return { kind: 'reverted', detail: a.reverted ? `Reverted by ${name(a.reverted)}` : 'Reverted' };
|
|
220
222
|
if (it.verdict === 'fixed') return { kind: 'fixed', detail: `Fixed afterwards by ${(a.fixes ?? []).map(name).join('; ')}` };
|
|
221
223
|
if (it.verdict === 'broke') return { kind: 'broke', detail: `Checks failed on the commit it merged as: ${(a.checks?.failed ?? []).join(', ')}` };
|
package/src/weekly.js
CHANGED
|
@@ -229,7 +229,7 @@ export function weeklyFacts({ start, end = start + 7 * DAY, prevStart = start -
|
|
|
229
229
|
technical,
|
|
230
230
|
size,
|
|
231
231
|
quality: held,
|
|
232
|
-
problems: qItems.filter((it) => it.after?.reverted || it.after?.fixes?.length).map((it) => ({ title: hidden.has(it.agentId) ? PRIVATE : clip(it.title), link: hidden.has(it.agentId) ? null : it.url, what: it.after?.reverted ? 'reverted' : 'fixed afterwards' })),
|
|
232
|
+
problems: qItems.filter((it) => it.incidents?.length || it.after?.reverted || it.after?.fixes?.length).map((it) => ({ title: hidden.has(it.agentId) ? PRIVATE : clip(it.title), link: hidden.has(it.agentId) ? null : it.url, what: it.incidents?.length ? `caused ${it.incidents.length === 1 ? 'an incident' : `${it.incidents.length} incidents`} in production` : it.after?.reverted ? 'reverted' : 'fixed afterwards' })),
|
|
233
233
|
blocked: open.filter((o) => o.state === 'blocked'),
|
|
234
234
|
open: open.filter((o) => o.state !== 'blocked'),
|
|
235
235
|
keptPrivate: [...merged, ...finished, ...open].filter((e) => e.private).length,
|