ai-agentmanager 1.63.0 → 1.64.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,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.64.0 (2026-11-22)
4
+
5
+ - **Proof: what the agent ran, kept so you can check it.** Next to its brief each agent keeps `PROOF.md`: for every check it ticked and every agreed point of what done means, the exact command, its exit code and the last lines of real output. The agent's Results show a **Proof** row; **Open** lists each check with its command and output. `agentmgr proof <agent>` prints it.
6
+ - **Run it again.** **Run these again here**, or `agentmgr proof <agent> --run`, runs the recorded commands in the agent's folder and marks each "Same result" or "Different result" by its exit code (the command exits with 1 when one differs). Only you can ask for it; an agent's own call is refused. A command that changes things (deleting, committing, pushing, installing, publishing, deploying, reaching the network, writing to a file) is not run and is listed with the reason.
7
+ - **Not done: what the agent left out.** Under Results the agent lists what the request asked or implied that it skipped, stubbed, left untested or only assumed, or says there is nothing. It is shown above what was delivered.
8
+ - **Reviews use it.** The scorecard and the review when an agent finishes are given the proof and what the app saw when it ran the commands again. A command that gave a different result caps the tests score at 40. A merge without you (Run to merge, autopilot) is left to you when something is listed as not done or a recorded command gave a different result.
9
+ - **Limits.** The record is the agent's own until you run it again. Running again uses your rights on your computer, without the agent's permission prompts; the list of what is not run is a filter on the command's text, not a sandbox. `"proof": false` in config.json turns the instructions off.
10
+
11
+ Found by running real agents at "Agree, then run":
12
+
13
+ - **A message sent while the agent shows a question menu is no longer lost.** Claude Code's current question menu was not recognised as a prompt, so text sent to the agent (your agreement on what done means, an answer, a nudge) was typed into the menu and Enter picked its highlighted option. The menu now counts as **Needs input**: the inbox shows the question with its options as buttons, and messages wait until it is answered.
14
+ - **Without you: a menu question is answered by picking an option.** For an agent that runs without you, the option is chosen from what is already decided and picked with its key. A menu where several can be ticked, or where no option is right, is left for you.
15
+ - **Without you: a permission prompt is never sent to a model.** When the screen reader took a permission prompt for a question, the answering model was asked about it (it left it for you, but that was its judgment). The app now recognises these itself and leaves them for you without asking.
16
+ - **Without you: nothing is answered while your agreement is pending.** While what done means or a plan waited for you, the agent's "do these look right?" was looked at by a model twice and listed as "left for you". It is now skipped.
17
+ - **Without you: permission prompts still stop it, and the app says so.** New agent shows a hint with **Use Auto** when a level past "Ask me" is chosen in a mode that asks for each command; the agent's "Without you" dialog and `agentmgr add --autonomy` say the same.
18
+ - **`agentmgr restart` with a second daemon.** For a daemon on another home or port than the login service's (a trial, a test), restart asked the login service to start it and then reported "Daemon did not come back". It now starts that daemon itself.
19
+ - **`agentmgr inbox`** labels answers given for you as "done for you" with the answer and the commands to accept or change it (it printed "undefined"), and shows a menu's question instead of the word "Question".
20
+ - **Open Terminal on a phone: a swipe scrolls.** The terminal on this computer (Open Terminal) and the terminals in groups did not move under a finger, so what had scrolled off could not be read from a phone or tablet. They now scroll like an agent's terminal: a swipe moves through what was printed, a flick keeps going, and in a full-screen program the swipe scrolls the program.
21
+
3
22
  ## 1.63.0 (2026-11-21)
4
23
 
5
24
  - **Acceptance: agree on what done means.** Tick **Agree on what done means first** in New agent or the backlog (or `agentmgr add --acceptance`). The agent reads the code, writes three to six points you could check, and stops before changing anything. The points wait in the inbox as **Done means**, with a notification.
package/README.md CHANGED
@@ -483,6 +483,7 @@ Each agent has a level for how far it goes before it needs you. Choose it in New
483
483
 
484
484
  - **A question it asks without stopping, or a plan waiting for review**, is decided by [Decide](#decide) at its "Most things; ask when unsure" level, whatever the project's own level is: carried out when the recommendation is at least 70% sure and easy to undo. Its recommendation now also knows the agreed points, your ground rules and the repository's lessons.
485
485
  - **A question it stopped on in its terminal** (read from its screen by the AI judge) is answered from what is already decided: your request, the agreed points, your ground rules, the repository's lessons and your earlier answers, or the agent's own default when it is a routine detail that is cheap to change. The agent is told the answer came from the app while you were away, and to note it as an assumption.
486
+ - **A question it shows as a menu** (Claude Code's own question menu) is answered the same way, by picking one of its options with its key. A menu where several options can be ticked, and one where none of the options is right, is left for you.
486
487
  - **A stuck agent** gets the judge's nudge when the judge is at least 70% sure, three times at most.
487
488
  - **A quiet, unfinished agent** is told to carry on, twice at most, unless it is blocked on you.
488
489
  - **At "Run to merge"**, its pull request is merged when the checks pass, the review rounds (when they ran) approved it, the scorecard says "Ready to approve", no high-risk path is touched, and the agent's own confidence is not low. Otherwise it is held, and the inbox says why. (A backlog item is shipped by [autopilot](#autopilot) at the item's level.)
@@ -491,7 +492,9 @@ Each agent has a level for how far it goes before it needs you. Choose it in New
491
492
 
492
493
  **Never done for you:**
493
494
 
494
- - A permission prompt is never answered by a model (your [approval rules](#decision-inbox) still apply).
495
+ - A permission prompt is never answered by a model (your [approval rules](#decision-inbox) still apply). This is checked by the app, not left to the model: a prompt the screen reader took for a question is left for you without asking one.
496
+ - While what done means, or a plan, waits for your agreement, nothing is answered or nudged for you.
497
+ - A choice your request says to ask you about: the answering model is told to leave it for you (in the trial it did, each time).
495
498
  - A question about deleting or overwriting, rewriting history, publishing, deploying or merging, credentials, money or licences, personal data, messages to other people, or the scope of the task is left for you whatever a model would say.
496
499
  - An agent cannot set or raise its own level, and cannot change your ground rules: its own calls are refused.
497
500
 
@@ -508,7 +511,7 @@ agentmgr autonomy add-a-csv-export --change 3fa2c1d0="Use Postgres"
508
511
 
509
512
  In config.json: `"autonomy": { "level": "ask", "models": ["fable", "opus", "sonnet"], "answers": true, "nudges": true, "followUps": true, "minConfidence": 0.7, "minBuildConfidence": 70, "maxAnswers": 12, "maxNudges": 3, "maxFollowUps": 2, "dailyCalls": 80 }`.
510
513
 
511
- **Limits.** It needs the AI judge on (it reads the screen and finds stuck agents) and Decide on (for questions and plans). An answer is a model's reading of what you decided before, and can be wrong: that is why each one is shown to you. The level does not change the permission mode, so an agent can still stop at a permission prompt. Each answer, nudge and judgment is a model call on your own plan.
514
+ **Limits.** It needs the AI judge on (it reads the screen and finds stuck agents) and Decide on (for questions and plans). An answer is a model's reading of what you decided before, and can be wrong: that is why each one is shown to you. The level does not change the permission mode, so in the default mode an agent stops at each permission prompt (running a command, reading outside the project) and waits for you. New agent says so and offers Permission mode **Auto**, where Claude Code approves what it judges safe; `agentmgr add --autonomy run -p auto` does the same. Each answer, nudge and judgment is a model call on your own plan.
512
515
 
513
516
  ## Ground rules: your own rules for every agent
514
517
 
@@ -533,6 +536,20 @@ Every agent now ends its Results with its own confidence: `Confidence: 85% - wha
533
536
 
534
537
  The number is the agent's own statement, not a measurement.
535
538
 
539
+ ## Proof: what it ran, and what it did not do
540
+
541
+ "All checks pass" in a brief is the agent's word. With proof, you can check it.
542
+
543
+ - **What it ran.** Next to its brief the agent keeps `PROOF.md`: for each check it ticked, and each agreed point of [what done means](#acceptance-agree-on-what-done-means), the exact command, its exit code and the last lines of real output. A check it made by reading says so.
544
+ - **What it did not do.** Under Results the agent lists each thing the request asked or implied that it skipped, stubbed, left untested or only assumed, as **Not done**, or says there is nothing. A finished agent that has not said is shown as such.
545
+ - **Where you see it.** The agent's Results show **Not done** and a **Proof** row ("3 recorded runs, 1 by reading"). **Open** lists each check with its command and output. `agentmgr proof <agent>` prints the same.
546
+ - **Run it again.** **Run these again here** (or `agentmgr proof <agent> --run`) runs the recorded commands in the agent's folder, one after the other, and marks each **Same result** or **Different result** by its exit code. The command exits with 1 when one differs. If the agent changes its proof afterwards, the earlier run no longer counts.
547
+ - **What it feeds.** The review scorecard and the review when an agent finishes are given the proof as the agent's own record, and what the app saw when it ran the commands. A command that gave a different result caps the scorecard's tests score at 40. At "Run to merge" and on autopilot, a merge is left to you when the agent lists something as not done, or a recorded command gave a different result.
548
+
549
+ **What is not run again:** a command that changes things: deleting or moving files, committing or pushing, installing or publishing, deploying, reaching the network, writing to a file, or running as administrator. It is listed as "Not run again" with the reason. At most 12 commands are run, each for two minutes at most.
550
+
551
+ **Limits.** The record is written by the agent: until you run the commands again, it is still its word, now in a form you can check. Running them again happens on your computer with your rights and without the agent's permission prompts, which is why only you can ask for it (an agent's own call is refused) and why the commands are shown first; the list of what is not run is a filter on the command's text, not a sandbox, so read the commands. The same exit code does not prove the same output (durations and dates differ between runs; the page says when the last recorded line was not printed). An agent in a container cannot be run again from here. `"proof": false` in `config.json` stops asking agents for it.
552
+
536
553
  ## Insights
537
554
 
538
555
  **Insights** in the Brief panel, or `agentmgr insights <agent>`, shows the agent's work as four cards built from its ask and live context:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.63.0",
3
+ "version": "1.64.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
@@ -58,7 +58,8 @@ import { initFiles } from '/files.js';
58
58
  import { initUpdateView, updateHtml, updateWaits } from '/announce.js';
59
59
  import { morph } from '/morph.js';
60
60
  import { acceptanceRow, acceptanceWaits, initAcceptance } from '/acceptance.js';
61
- import { autoNeedHtml, autonomyNeeds, autonomyRow, initAutonomy } from '/autonomy.js';
61
+ import { autoNeedHtml, autonomyNeeds, autonomyRow, initAutonomy, needsPermissionHint } from '/autonomy.js';
62
+ import { initProof, proofRows } from '/proof.js';
62
63
 
63
64
  const $ = (sel) => document.querySelector(sel);
64
65
  const agents = new Map();
@@ -193,10 +194,27 @@ async function act(fn, okMsg) {
193
194
 
194
195
  const reviewUi = initReview({ api, esc, toast, agents, $ });
195
196
  const acceptUi = initAcceptance({ dialog: $('#accept-dialog'), api, esc, toast, ago, agentOf: (id) => agents.get(id), upsert: (a) => upsert(a) });
197
+ const proofUi = initProof({ dialog: $('#proof-dialog'), api, esc, toast, ago, agentOf: (id) => agents.get(id) });
196
198
  const autoUi = initAutonomy({ dialog: $('#auto-dialog'), api, esc, toast, ago, agentOf: (id) => agents.get(id), upsert: (a) => upsert(a) });
197
199
  // Past "Ask me", what done means is agreed first: that is what the answers given for you are checked against.
200
+ // And a permission prompt is never answered for you: say so where the mode would stop it at each one.
201
+ function syncAutonomyPerm() {
202
+ const f = $('#new-autonomy')?.form;
203
+ const hint = $('#new-autonomy-perm');
204
+ if (!f || !hint) return;
205
+ hint.hidden = !needsPermissionHint(f.autonomy.value, f.permissionMode?.value);
206
+ }
198
207
  $('#new-autonomy')?.addEventListener('change', (e) => {
199
208
  if (['run', 'pr', 'merge'].includes(e.target.value) && e.target.form?.acceptance) e.target.form.acceptance.checked = true;
209
+ syncAutonomyPerm();
210
+ });
211
+ $('#new-autonomy')?.form?.permissionMode?.addEventListener('change', syncAutonomyPerm);
212
+ $('#new-autonomy')?.form?.addEventListener('reset', () => setTimeout(syncAutonomyPerm));
213
+ $('#new-autonomy-auto')?.addEventListener('click', () => {
214
+ const f = $('#new-autonomy').form;
215
+ f.permissionMode.value = 'auto';
216
+ syncAutonomyPerm();
217
+ toast('Permission mode: Auto');
200
218
  });
201
219
  const triggersUi = initTriggers({ api, esc, toast, $ });
202
220
  initSpend({ api, esc, toast, $ });
@@ -1085,6 +1103,7 @@ function resultsCard(a) {
1085
1103
  ${scoreStrip(a)}
1086
1104
  ${r.confidence ? `<p class="own-conf"><span class="tag conf-${esc(r.confidence.level)}" title="The agent's own confidence in what it built, as it wrote it in its brief. The review scorecard is the separate check.">Its own confidence: ${r.confidence.percent}%</span> ${esc(r.confidence.why)}</p>` : r.fromAgent && ['done', 'partial'].includes(r.outcome) ? '<p class="hint own-conf">The agent has not said how confident it is in this.</p>' : ''}
1087
1105
  ${r.blockers.length ? `<ul class="blockers">${r.blockers.map((x) => item(x, 'blocker')).join('')}</ul>` : ''}
1106
+ ${proofRows(a, esc)}
1088
1107
  ${r.delivered.length ? `<ul class="delivered">${r.delivered.map((x) => item(x, 'delivered')).join('')}</ul>` : '<p class="hint">Nothing delivered yet.</p>'}
1089
1108
  ${r.notes ? `<div class="md">${md(r.notes)}</div>` : ''}
1090
1109
  </div>`;
@@ -1698,7 +1717,7 @@ function needCard(it, { inDetail = false } = {}) {
1698
1717
  const p = a.runtime.prompt;
1699
1718
  body = `${p?.tool ? `<p class="need-title">${toolLine(p.tool)}</p><p class="hint">${esc(p.question || a.runtime.attention)}</p>` : `<p class="need-title">${esc(p?.question || a.runtime.attention)}</p>`}
1700
1719
  <div class="need-actions">
1701
- ${(p?.choices ?? []).map((c) => `<button class="small ${c.key === '1' ? 'primary' : ''}" data-ib="key" data-key="${c.key}">${c.key}. ${esc(c.label)}</button>`).join('')}
1720
+ ${(p?.choices ?? []).map((c) => `<button class="small ${c.key === '1' ? 'primary' : ''}" data-ib="key" data-key="${c.key}"${c.hint ? ` title="${esc(c.hint)}"` : ''}>${c.key}. ${esc(c.label)}</button>`).join('')}
1702
1721
  <button class="small" data-ib="key" data-key="esc" title="Escape">Esc</button>
1703
1722
  <button class="small ghost" data-ib="terminal">Open terminal</button>
1704
1723
  </div>`;
@@ -3986,6 +4005,7 @@ function agentChanged(a) {
3986
4005
  reviewUi.agentChanged(a);
3987
4006
  acceptUi.agentChanged(a);
3988
4007
  autoUi.agentChanged(a);
4008
+ proofUi.agentChanged(a);
3989
4009
  sidePane?.agentChanged(a);
3990
4010
  }
3991
4011
 
@@ -4179,6 +4199,8 @@ $('#detail-body').addEventListener('click', async (e) => {
4179
4199
  return openPlan(a.id);
4180
4200
  case 'accept-open':
4181
4201
  return acceptUi.open(a.id);
4202
+ case 'proof-open':
4203
+ return proofUi.open(a.id);
4182
4204
  case 'auto-open':
4183
4205
  return autoUi.open(a.id);
4184
4206
  case 'accept-skip':
@@ -12,6 +12,9 @@ export const LEVEL_HINT = {
12
12
  };
13
13
  const KIND = { answer: 'Answered', left: 'Left for you', nudge: 'Nudged', followup: 'Told to carry on', plan: 'Plan decided', merge: 'Merged' };
14
14
 
15
+ /** Whether to say that permission prompts still stop it: past "Ask me", in a mode that asks for each one. */
16
+ export const needsPermissionHint = (level, mode) => ['run', 'pr', 'merge'].includes(level) && !['auto', 'bypassPermissions'].includes(mode || '');
17
+
15
18
  export const levelOf = (a) => (LEVELS.includes(a.autonomy?.level) ? a.autonomy.level : 'ask');
16
19
 
17
20
  /** "2 answered, 1 nudge, 1 left for you". */
@@ -85,6 +88,7 @@ export function initAutonomy({ dialog, api, esc, toast, ago, agentOf, upsert })
85
88
  </label>
86
89
  <p class="hint">${LEVEL_HINT[level]}</p>
87
90
  <p class="hint">Never done for you: answering a permission prompt, or a question about deleting, publishing, money, credentials or the scope of the task.</p>
91
+ ${needsPermissionHint(level, a.permissionMode) ? '<p class="hint auto-perm">It still stops at each permission prompt, and waits for you in the inbox. To be stopped less, set its Permission mode to Auto (Edit agent; from its next launch), where Claude Code approves what it judges safe.</p>' : ''}
88
92
  ${st.hold && !st.hold.ack && level === 'merge' ? `<p class="auto-hold"><b>Not merged:</b> ${esc(st.hold.note)} <button type="button" class="small" data-auto="ok" data-entry="hold">OK</button></p>` : ''}
89
93
  ${log.length ? `<h4>Done for you</h4><ul class="auto-log">${log.map(entry).join('')}</ul>` : level === 'ask' ? '' : '<p class="hint">Nothing was done for you yet.</p>'}`;
90
94
  }
package/public/groups.js CHANGED
@@ -7,6 +7,7 @@
7
7
  // The layout and what each group shows are kept per browser.
8
8
 
9
9
  import { termFont } from '/termfont.js';
10
+ import { touchScroll } from '/touchscroll.js';
10
11
 
11
12
  const SAVED = 'agentmgr.groups';
12
13
  const MAX_GROUPS = 6;
@@ -157,6 +158,7 @@ export function initGroups({ $, esc, agents, Terminal, FitAddon, openStream, api
157
158
  if (!p.el.isConnected) return;
158
159
  if (!p.opened) {
159
160
  p.xterm.open(p.el.querySelector('.gterm'));
161
+ touchScroll(p.el.querySelector('.gterm'), p.xterm);
160
162
  p.opened = true;
161
163
  }
162
164
  p.failed = false;
package/public/index.html CHANGED
@@ -335,6 +335,7 @@
335
335
  <option value="merge">Run to merge</option>
336
336
  </select>
337
337
  </label>
338
+ <p class="hint auto-perm" id="new-autonomy-perm" hidden>It still stops at each permission prompt (running a command, reading outside the project): those are never answered for you. To be stopped less, choose Permission mode <b>Auto</b> under More options, where Claude Code approves what it judges safe. <button type="button" class="small" id="new-autonomy-auto">Use Auto</button></p>
338
339
  <label class="check">
339
340
  <input type="checkbox" name="planReview" />
340
341
  Review the implementation plan first <span class="hint">(the agent writes a plan and waits for your approval before changing anything)</span>
@@ -950,6 +951,12 @@
950
951
  <div class="dialog-actions"><button type="button" class="small primary" data-auto="close">Close</button></div>
951
952
  </dialog>
952
953
 
954
+ <dialog id="proof-dialog" class="update-dialog proof-dialog" aria-label="Proof">
955
+ <h2 id="proof-title">Proof</h2>
956
+ <div id="proof-body"></div>
957
+ <div class="dialog-actions"><button type="button" class="small" data-proof="run" hidden>Run again here</button><span class="spacer"></span><button type="button" class="small primary" data-proof="close">Close</button></div>
958
+ </dialog>
959
+
953
960
  <dialog id="update-dialog" class="update-dialog" aria-label="Update">
954
961
  <h2 id="update-title">Update</h2>
955
962
  <div id="update-body"></div>
package/public/machine.js CHANGED
@@ -4,6 +4,7 @@
4
4
  import { openStream } from '/transport.js';
5
5
  import { openCopy, pasteInto } from '/termclip.js';
6
6
  import { termFont } from '/termfont.js';
7
+ import { touchScroll } from '/touchscroll.js';
7
8
 
8
9
  const MACHINE = '__machine__';
9
10
 
@@ -22,6 +23,7 @@ export function initMachine({ api, esc, toast, $, Terminal, FitAddon }) {
22
23
  fit = new FitAddon();
23
24
  xterm.loadAddon(fit);
24
25
  xterm.open($('#machine-term'));
26
+ touchScroll($('#machine-term'), xterm);
25
27
  // Answers xterm gives to queries in the replayed backlog are stale; don't send them as typing.
26
28
  xterm.onData((d) => !replaying && conn?.send({ t: 'i', d }));
27
29
  xterm.onResize(({ cols, rows }) => conn?.send({ t: 'r', cols, rows }));
@@ -0,0 +1,114 @@
1
+ // Proof on the page: what the agent recorded of its checks (the command, its exit code, the last
2
+ // lines of output), what it says it did not do, and the commands run again here when you ask.
3
+
4
+ /** "3 recorded runs, 1 by reading" for the results card. */
5
+ export function proofLine(doc) {
6
+ if (!doc?.entries) return '';
7
+ return `${doc.commands} recorded run${doc.commands === 1 ? '' : 's'}${doc.entries > doc.commands ? `, ${doc.entries - doc.commands} by reading` : ''}`;
8
+ }
9
+
10
+ /** The last run by the app, when it still speaks for the proof as it is now. */
11
+ export function rerunOf(a) {
12
+ const r = a.proof;
13
+ if (!r?.results?.length || r.proofAt !== (a.proofDoc?.updatedAt ?? null)) return null;
14
+ const n = (s) => r.results.filter((x) => x.status === s).length;
15
+ return { at: r.at, same: n('same'), differs: n('differs'), skipped: n('skipped') };
16
+ }
17
+
18
+ /** The rows in the results card: what was left out, and the proof with the way in. */
19
+ export function proofRows(a, esc) {
20
+ const r = a.results;
21
+ if (!r?.fromAgent) return '';
22
+ const finished = ['done', 'partial'].includes(r.outcome);
23
+ const passed = (a.brief?.checks ?? []).filter((c) => c.state === 'passed').length;
24
+ const doc = a.proofDoc;
25
+ const rr = rerunOf(a);
26
+ const notDone = r.notDone?.length
27
+ ? `<div class="not-done"><b>Not done, as the agent says</b><ul>${r.notDone.map((t) => `<li>${esc(t)}</li>`).join('')}</ul></div>`
28
+ : finished && !r.notDoneSaid
29
+ ? '<p class="hint not-done-none">The agent has not said what it left out.</p>'
30
+ : '';
31
+ const proof = doc?.entries
32
+ ? `<p class="proof-row"><b>Proof</b> <span class="hint">${esc(proofLine(doc))}</span>${rr ? ` <span class="tag ${rr.differs ? 'proof-bad' : 'proof-ok'}" title="The recorded commands, run again on this computer">${rr.differs ? `${rr.differs} different when run again` : `${rr.same} same when run again`}</span>` : ''} <button class="small" data-act="proof-open">Open</button></p>`
33
+ : finished && passed
34
+ ? `<p class="hint proof-row">No proof recorded for its ${passed} passed check${passed === 1 ? '' : 's'}: they are its word.</p>`
35
+ : '';
36
+ return notDone + proof;
37
+ }
38
+
39
+ export function initProof({ dialog, api, esc, toast, ago, agentOf }) {
40
+ let id = null;
41
+ let view = null;
42
+ let stamp = '';
43
+ const stampOf = (a) => `${a.proofDoc?.updatedAt ?? ''}|${a.proof?.at ?? ''}`;
44
+
45
+ function render() {
46
+ const a = id && agentOf(id);
47
+ if (!a || !view) return;
48
+ dialog.querySelector('#proof-title').textContent = `Proof: ${a.name}`;
49
+ const mark = { same: ['proof-ok', 'Same result'], differs: ['proof-bad', 'Different result'], skipped: ['', 'Not run again'] };
50
+ const entry = (e) => `<li>
51
+ <div class="proof-title">${esc(e.title)}${e.rerun ? ` <span class="tag ${mark[e.rerun.status][0]}">${mark[e.rerun.status][1]}</span>` : ''}</div>
52
+ ${e.command ? `<code class="proof-cmd">${esc(e.command)}</code>${e.exit === null ? '' : ` <span class="hint">exit ${e.exit}</span>`}` : `<span class="hint">Verified by reading${e.note ? `: ${esc(e.note)}` : ''}</span>`}
53
+ ${e.output ? `<pre class="proof-out">${esc(e.output)}</pre>` : ''}
54
+ ${e.rerun?.status === 'differs' ? `<p class="hint">Run again: exit ${e.rerun.code ?? 'none (stopped)'}${e.rerun.output === 'differs' ? ', and its last recorded line was not printed' : ''}</p><pre class="proof-out bad">${esc(e.rerun.tail ?? '')}</pre>` : ''}
55
+ ${e.rerun?.status === 'same' && e.rerun.output === 'differs' ? '<p class="hint">The same exit code; its last recorded line was not printed this time (durations and dates differ between runs).</p>' : ''}
56
+ ${e.command && !e.runnable ? `<p class="hint">Not run again by the app: ${esc(e.why)}.</p>` : ''}
57
+ </li>`;
58
+ const n = view.entries.filter((e) => e.runnable).length;
59
+ dialog.querySelector('#proof-body').innerHTML = `
60
+ <p class="hint">The agent's own record of what it ran. ${view.passed ? `Its brief ticks ${view.passed} check${view.passed === 1 ? '' : 's'} as passed; ` : ''}${view.counts.commands} ${view.counts.commands === 1 ? 'has' : 'have'} a command and output here.</p>
61
+ ${view.notDone.length ? `<div class="not-done"><b>Not done, as the agent says</b><ul>${view.notDone.map((t) => `<li>${esc(t)}</li>`).join('')}</ul></div>` : ''}
62
+ ${view.entries.length ? `<ul class="proof-list">${view.entries.map(entry).join('')}</ul>` : '<p class="hint">Nothing recorded yet.</p>'}
63
+ ${view.rerun ? `<p class="hint">${view.rerun.stale ? 'The last run here was before the agent changed its proof.' : `Run again here ${ago(view.rerun.at)}: ${view.rerun.same} same, ${view.rerun.differs} different${view.rerun.skipped ? `, ${view.rerun.skipped} not run` : ''}.`}</p>` : ''}
64
+ ${!view.canRun && view.counts.commands ? `<p class="hint">${esc(view.whyNot)}</p>` : ''}`;
65
+ const btn = dialog.querySelector('[data-proof="run"]');
66
+ btn.hidden = !view.canRun || !n;
67
+ btn.disabled = view.running;
68
+ btn.textContent = view.running ? 'Running…' : `Run ${n === 1 ? 'it' : `these ${n}`} again here`;
69
+ btn.title = 'Runs the commands above in the agent\'s folder on this computer, without its permission prompts. Read them first.';
70
+ }
71
+
72
+ async function load() {
73
+ stamp = stampOf(agentOf(id) ?? {});
74
+ try {
75
+ view = await api('GET', `/agents/${id}/proof`);
76
+ } catch (e) {
77
+ toast(`Error: ${e.message}`, 5000);
78
+ }
79
+ render();
80
+ }
81
+
82
+ dialog.addEventListener('click', async (e) => {
83
+ const act = e.target.closest('[data-proof]')?.dataset.proof;
84
+ if (act === 'close') return dialog.close();
85
+ if (act !== 'run' || !id || !view) return;
86
+ view.running = true;
87
+ render();
88
+ try {
89
+ view = await api('POST', `/agents/${id}/proof/run`);
90
+ toast(view.rerun.differs ? `${view.rerun.differs} gave a different result` : 'All gave the same result');
91
+ } catch (err) {
92
+ view.running = false;
93
+ toast(`Error: ${err.message}`, 5000);
94
+ }
95
+ render();
96
+ });
97
+ dialog.addEventListener('close', () => ((id = null), (view = null)));
98
+
99
+ return {
100
+ open(agentId) {
101
+ id = agentId;
102
+ view = null;
103
+ dialog.querySelector('#proof-title').textContent = 'Proof';
104
+ dialog.querySelector('#proof-body').innerHTML = '<p class="hint">Loading…</p>';
105
+ dialog.querySelector('[data-proof="run"]').hidden = true;
106
+ if (!dialog.open) dialog.showModal();
107
+ return load();
108
+ },
109
+ /** The agent changed its proof while the dialog is open. */
110
+ agentChanged(a) {
111
+ if (id === a.id && view && !view.running && stampOf(a) !== stamp) load();
112
+ },
113
+ };
114
+ }
package/public/style.css CHANGED
@@ -444,7 +444,7 @@ body.term-max .term-agent, .term-wrap:fullscreen .term-agent { display: inline-b
444
444
  .browser-frames { flex: 1; min-height: 0; position: relative; }
445
445
  .browser-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
446
446
  /* Swipes scroll the terminal (handled in app.js), not the page. */
447
- .terminal .xterm { touch-action: none; }
447
+ .terminal .xterm, .gterm .xterm { touch-action: none; }
448
448
  .term-overlay {
449
449
  position: absolute; inset: 36px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
450
450
  gap: 8px; background: rgba(15, 17, 23, .78); color: #e5e8ef;
@@ -1929,6 +1929,19 @@ table.eval-items tr.eval-na td { color: var(--muted); }
1929
1929
  .tag.auto-on { border-color: var(--accent, #4c8dff); color: var(--accent, #4c8dff); }
1930
1930
  .auto-answer { margin: 4px 0; font-size: 14px; overflow-wrap: anywhere; }
1931
1931
  .auto-hold { margin: 8px 0; font-size: 13px; }
1932
+ .auto-perm { margin: 4px 0 8px; }
1933
+ .auto-perm button { margin-left: 4px; }
1934
+ .not-done { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--warn, #d9a441); font-size: 13px; overflow-wrap: anywhere; }
1935
+ .not-done ul { margin: 4px 0 0; padding-left: 18px; }
1936
+ .proof-row { margin: 6px 0; font-size: 13px; }
1937
+ .tag.proof-ok { color: var(--green); }
1938
+ .tag.proof-bad { color: var(--red); font-weight: 600; }
1939
+ .proof-list { list-style: none; margin: 8px 0; padding: 0; }
1940
+ .proof-list li { margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
1941
+ .proof-title { font-weight: 600; margin-bottom: 4px; }
1942
+ .proof-cmd { display: inline-block; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
1943
+ .proof-out { margin: 6px 0 0; padding: 6px 8px; max-height: 180px; overflow: auto; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-2, rgba(127, 127, 127, 0.12)); border-radius: 6px; }
1944
+ .proof-out.bad { border: 1px solid var(--danger, #d9534f); }
1932
1945
  .auto-log { list-style: none; margin: 8px 0; padding: 0; }
1933
1946
  .auto-log li { margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
1934
1947
  .auto-dialog select, #settings-autonomy select, #settings-autonomy input, #settings-ground textarea, #new-autonomy { width: 100%; font: inherit; font-size: 16px; }
package/src/autonomy.js CHANGED
@@ -21,6 +21,7 @@
21
21
  import crypto from 'node:crypto';
22
22
  import fs from 'node:fs';
23
23
  import { parseJsonReply, specPath } from './brief.js';
24
+ import { FREE_CHOICE } from './inbox.js';
24
25
  import { memoryKey, memoryText } from './memory.js';
25
26
  import { landState } from './tracker.js';
26
27
 
@@ -147,6 +148,21 @@ export function sensitive(text) {
147
148
  return SENSITIVE.find(([re]) => re.test(t))?.[1] ?? null;
148
149
  }
149
150
 
151
+ const PERMISSION_ASK = /\bdo you want to (?:proceed|allow|make this edit|create|run|overwrite)\b|\b(?:allow|grant|approve)\b.{0,60}\b(?:access|permission|command|tool|edit|read|write)|\bpermission (?:prompt|request|to)\b|\bwaiting for (?:approval|permission)\b|\btrust (?:the files in )?this folder\b/i;
152
+ const PERMISSION_CHOICE = /don'?t ask again|switch to auto mode|\ballow (?:reading|writing|all edits|this|it)\b|\balways allow\b|\bfor this (?:session|project)\b/i;
153
+
154
+ /**
155
+ * Whether what the screen judge read as a question is the engine's own permission prompt (run this
156
+ * command? allow this read?). Those are never answered for the person, and no model is asked: a
157
+ * numbered Yes/No menu counts, so does the wording of the prompt or of what the judge saw.
158
+ */
159
+ export function permissionPrompt({ question, options = [], summary } = {}) {
160
+ const opts = options.map((o) => String(o).replace(/^\s*\d+[.)]\s*/, ''));
161
+ if (opts.some((o) => /^yes\b/i.test(o)) && opts.some((o) => /^no\b/i.test(o))) return true;
162
+ if (opts.some((o) => PERMISSION_CHOICE.test(o))) return true;
163
+ return PERMISSION_ASK.test(`${question ?? ''}\n${summary ?? ''}`);
164
+ }
165
+
150
166
  const block = (tag, body) => (String(body ?? '').trim() ? [`<${tag}>`, String(body).trim(), `</${tag}>`] : []);
151
167
 
152
168
  /**
@@ -161,14 +177,16 @@ export function answerPrompt(ctx) {
161
177
  '- the answer is already decided by what the person wrote or agreed: the request, the agreed points for what done means, their ground rules, the lessons of the repository, or an earlier answer of theirs;',
162
178
  '- it is a routine implementation detail the request leaves to the implementer and that is cheap to change later (a name, where a file goes, which existing helper to use, a default the agent itself proposes).',
163
179
  'Leave it for the person ("ask": true) when it changes what is built or how much; when it trades off cost, security, privacy, data or compatibility;',
164
- 'when it would delete, overwrite, publish, deploy, merge, spend money, touch credentials or reach outside the repository; when the sources disagree or do not cover it; or when you are not sure.',
180
+ 'when it would delete, overwrite, publish, deploy, merge, spend money, touch credentials or reach outside the repository; when the request itself says to ask the person about this choice;',
181
+ 'when the sources disagree or do not cover it; or when you are not sure.',
165
182
  'Never invent a preference the person has not shown. When nothing decides it and the choice is cheap to change, the agent\'s own stated default is the answer.',
166
183
  'Reply with one JSON object only, no prose around it. confidence is a number from 0 to 1.',
167
184
  'Shape: {"ask": true|false, "answer": "what to tell the agent, one to three sentences, or empty", "basis": "the source that decides it, quoted briefly, or: routine detail, cheap to change", "confidence": 0.0}',
168
185
  '',
169
186
  '<question>',
170
187
  ctx.question,
171
- ctx.options?.length ? `Options: ${ctx.options.join(' | ')}` : '',
188
+ ctx.menu?.length ? `The agent shows a menu and takes one of these, by its number:\n${ctx.menu.map((c) => `${c.key}. ${c.label}${c.hint ? ` (${c.hint})` : ''}`).join('\n')}` : ctx.options?.length ? `Options: ${ctx.options.join(' | ')}` : '',
189
+ ctx.menu?.length ? 'When you answer, add "option": the number of the one to pick, and give its label as the answer. If none of them is right, leave it for the person.' : '',
172
190
  ctx.default ? `The agent's default until answered: ${ctx.default}` : '',
173
191
  ctx.context ? `Context from the agent: ${ctx.context}` : '',
174
192
  '</question>',
@@ -197,7 +215,8 @@ export function parseAnswer(text) {
197
215
  }
198
216
  if (!d || typeof d !== 'object' || typeof d.ask !== 'boolean') return null;
199
217
  const answer = clip(d.answer, 600);
200
- return { ask: d.ask || !answer, answer, basis: clip(d.basis, 300), confidence: Math.max(0, Math.min(1, Number(d.confidence) || 0)) };
218
+ const option = /^\d$/.test(String(d.option ?? '')) ? String(d.option) : null;
219
+ return { ask: d.ask || !answer, answer, option, basis: clip(d.basis, 300), confidence: Math.max(0, Math.min(1, Number(d.confidence) || 0)) };
201
220
  }
202
221
 
203
222
  /** What the agent is told: the answer, and that it was given for the person, not by them. */
@@ -227,6 +246,26 @@ export function logLine(log = []) {
227
246
  }
228
247
 
229
248
  /** An agent this can work for: a task with changes of its own, not a team member, reviewer, hunter or builder. */
249
+ /**
250
+ * The agent's own question shown as a menu (not a permission prompt, not one that takes several
251
+ * ticks): { key, question, options, menu: [{ key, label, hint }] }, or null.
252
+ */
253
+ export function menuOf(view) {
254
+ const p = view?.runtime?.attention === 'Question' ? view.runtime.prompt : null;
255
+ const menu = (p?.choices ?? []).filter((c) => !FREE_CHOICE.test(c.label));
256
+ if (!p?.question || menu.length < 2 || p.multi) return null;
257
+ return { key: `m:${hash(`${p.question}\n${menu.map((c) => c.label).join('\n')}`)}`, question: p.question, options: menu.map((c) => c.label), menu };
258
+ }
259
+
260
+ /** Why a merge is the person's: the agent says it left something out, or its proof did not hold when run again. */
261
+ export function leftOut(agent, view) {
262
+ const nd = view?.results?.notDone ?? [];
263
+ if (nd.length) return `The agent lists as not done: ${clip(nd.join('; '), 240)}.`;
264
+ const rerun = agent.proof && agent.proof.proofAt === (agent.proofDoc?.updatedAt ?? null) ? agent.proof.results.filter((r) => r.status === 'differs') : [];
265
+ if (rerun.length) return `${rerun.length} of its recorded commands gave a different result when run again: ${clip(rerun.map((r) => r.title).join('; '), 200)}.`;
266
+ return null;
267
+ }
268
+
230
269
  export const eligible = (agent) => agent?.kind === 'task' && !agent.team && !agent.builds && !agent.reviewing && !agent.hunting && !agent.fixing && !agent.raceId;
231
270
 
232
271
  export class Autonomy {
@@ -366,15 +405,23 @@ export class Autonomy {
366
405
  const v = this.manager.view(agent);
367
406
  const st = this.state(agent);
368
407
  const count = (k) => st.log.filter((e) => e.kind === k).length;
408
+ // While what done means or the plan waits for the person, the agent is asking for exactly that:
409
+ // nothing is answered or nudged for them.
410
+ const theirs = this.manager.acceptanceWaits(agent) || Boolean(agent.planReview && agent.planReview.status !== 'approved');
369
411
 
370
- if (s.answers) {
412
+ if (s.answers && !theirs) {
371
413
  // Questions in QUESTIONS.md and plans are Decide's (advisor.js); the one it stopped on in its terminal is ours.
372
414
  const w = v.runtime?.waiting;
373
415
  const asked = w?.state === 'question' ? w.question || w.summary : null;
374
- if (asked && !st.seen[`w:${hash(asked)}`]) return this.answer(agent, { key: `w:${hash(asked)}`, question: asked, options: w.choices ?? [] });
416
+ // A permission prompt the app itself sees is in the inbox already, as a prompt.
417
+ const prompted = v.runtime?.prompt || v.runtime?.attention;
418
+ if (asked && !prompted && !st.seen[`w:${hash(asked)}`]) return this.answer(agent, { key: `w:${hash(asked)}`, question: asked, options: w.choices ?? [], summary: w.summary });
419
+ // Its question as a menu: one option is picked by its key (a typed message would not be read).
420
+ const menu = menuOf(v);
421
+ if (menu && !st.seen[menu.key]) return this.answer(agent, menu);
375
422
  }
376
423
 
377
- if (s.nudges) {
424
+ if (s.nudges && !theirs) {
378
425
  for (const f of v.stuck ?? []) {
379
426
  const key = `s:${f.key}:${f.since}`;
380
427
  if (st.seen[key] || f.ai?.verdict !== 'stuck' || !(f.ai.confidence >= s.minConfidence) || !f.nudge) continue;
@@ -393,7 +440,7 @@ export class Autonomy {
393
440
 
394
441
  const fu = v.followUp;
395
442
  if (s.followUps && fu?.kind === 'followup' && !st.seen[`f:${fu.since}`]) {
396
- const waitsOnPerson = this.manager.acceptanceWaits(agent) || (agent.planReview && agent.planReview.status !== 'approved') || v.results?.outcome === 'blocked';
443
+ const waitsOnPerson = theirs || v.results?.outcome === 'blocked';
397
444
  if (!waitsOnPerson) {
398
445
  this.put(id, (x) => (x.seen[`f:${fu.since}`] = now()));
399
446
  if (count('followup') < s.maxFollowUps) {
@@ -451,6 +498,7 @@ export class Autonomy {
451
498
  this.put(id, (x) => (x.seen[q.key] = now()));
452
499
  this.record(id, { kind: 'left', key: q.key, question: clip(q.question, 300), why });
453
500
  };
501
+ if (permissionPrompt(q)) return left('It is a permission prompt: only you answer those.');
454
502
  const touchy = sensitive([q.question, ...(q.options ?? []), q.default, q.context].filter(Boolean).join('\n'));
455
503
  if (touchy) return left(`It is about ${touchy}: yours to answer.`);
456
504
  if (st.log.filter((e) => e.kind === 'answer').length >= s.maxAnswers) return left(`${s.maxAnswers} questions were already answered for you on this agent.`);
@@ -481,6 +529,16 @@ export class Autonomy {
481
529
  if (q.qid) {
482
530
  if (cur.answers?.[q.qid]) return;
483
531
  this.manager.patch(id, { answers: { ...cur.answers, [q.qid]: { text: d.answer, at: now(), by: 'autonomy', model: r.by, basis: d.basis } } });
532
+ } else if (q.menu) {
533
+ const c = q.menu.find((x) => x.key === d.option);
534
+ if (!c || menuOf(this.manager.view(cur))?.key !== q.key) {
535
+ if (!c) this.record(id, { kind: 'left', key: q.key, question: clip(q.question, 300), why: 'The reply did not pick one of the choices.' });
536
+ return; // or the menu was answered, or changed, meanwhile
537
+ }
538
+ const e = this.record(id, { kind: 'answer', key: q.key, qid: null, question: clip(q.question, 300), answer: c.label, basis: d.basis, confidence: d.confidence, model: r.by, ack: false });
539
+ this.manager.answerPrompt(id, c.key);
540
+ this.log(`autonomy: picked "${c.label}" for ${agent.name} (${r.by}): ${clip(q.question, 80)}`);
541
+ return e;
484
542
  } else {
485
543
  const rt = this.manager.runtimes.get(id);
486
544
  const w = rt?.waiting;
@@ -581,6 +639,8 @@ export class Autonomy {
581
639
  if (this.manager.acceptanceWaits(agent)) return this.hold(id, key, 'What done means is not agreed yet.');
582
640
  const own = v.results?.confidence;
583
641
  if (own && own.percent < s.minBuildConfidence) return this.hold(id, key, `The agent's own confidence in this is ${own.percent}%${own.why ? `: ${own.why}` : ''}.`);
642
+ const left = leftOut(agent, v);
643
+ if (left) return this.hold(id, key, left);
584
644
  const changes = this.review ? await this.review.get(id) : null;
585
645
  const risk = changes ? this.manager.standards?.riskIn(agent, changes.files ?? []) ?? [] : [];
586
646
  if (risk.length) return this.hold(id, key, `It changes high-risk paths (${risk.slice(0, 3).map((r) => r.path).join(', ')}${risk.length > 3 ? ` and ${risk.length - 3} more` : ''}): yours to merge.`);
package/src/autopilot.js CHANGED
@@ -10,7 +10,7 @@
10
10
  // and stops early once a round no longer raises the score. Anything else ("look at these first"
11
11
  // without a target, a failed step, a closed pull request) waits for you in the inbox, with Ship it to
12
12
  // go ahead anyway. An item whose pull request merges is done.
13
- import { autonomySettings } from './autonomy.js';
13
+ import { autonomySettings, leftOut } from './autonomy.js';
14
14
  import { landState } from './tracker.js';
15
15
 
16
16
  export const AUTOPILOT_LEVELS = ['off', 'pr', 'merge'];
@@ -173,6 +173,8 @@ export class Autopilot {
173
173
  const own = this.manager.view(agent).results?.confidence;
174
174
  const min = autonomySettings(this.config).minBuildConfidence;
175
175
  if (own && own.percent < min) return this.hold(it, `The agent's own confidence in this is ${own.percent}%${own.why ? `: ${own.why}` : ''}. Its pull request is open; merging it is yours.`);
176
+ const left = leftOut(agent, this.manager.view(agent));
177
+ if (left) return this.hold(it, `${left} Its pull request is open; merging it is yours.`);
176
178
  this.note(it, { state: 'merging' });
177
179
  await this.landing.merge(agent.id, { url: pr.url });
178
180
  this.log(`autopilot: merged ${pr.url}`);
package/src/brief.js CHANGED
@@ -112,10 +112,13 @@ export function parseBrief(markdown) {
112
112
  delivered: pick(/^\s*[-*]\s+\**\s*delivered\s*\**\s*:\s*\**\s*(.+)$/i),
113
113
  blockers: pick(/^\s*[-*]\s+\**\s*blocked by\s*\**\s*:\s*\**\s*(.+)$/i),
114
114
  filed: pick(/^\s*[-*]\s+\**\s*filed\s*\**\s*:\s*\**\s*(.+)$/i),
115
+ // "- Not done: ..." (proof.js): what the request asked that the agent says it left out. "nothing" is none.
116
+ notDone: pick(/^\s*[-*]\s+\**\s*not done\s*\**\s*:\s*\**\s*(.+)$/i).filter((t) => !/^(nothing|none|n\/a|-)\b\.?\**$/i.test(t)),
117
+ notDoneSaid: lines.some((l) => /^\s*[-*]\s+\**\s*not done\s*\**\s*:/i.test(l)),
115
118
  // "Confidence: 85% - why": the agent's own, in what it built (null until it says).
116
119
  confidence: parseConfidence(body),
117
120
  notes: lines
118
- .filter((l) => !/^\s*\**\s*outcome\s*\**\s*:/i.test(l) && !CONFIDENCE_LINE.test(l) && !/^\s*[-*]\s+\**\s*(delivered|blocked by|filed)\s*\**\s*:/i.test(l))
121
+ .filter((l) => !/^\s*\**\s*outcome\s*\**\s*:/i.test(l) && !CONFIDENCE_LINE.test(l) && !/^\s*[-*]\s+\**\s*(delivered|blocked by|filed|not done)\s*\**\s*:/i.test(l))
119
122
  .join('\n')
120
123
  .trim(),
121
124
  };
package/src/cli.js CHANGED
@@ -388,6 +388,9 @@ export async function main(argv) {
388
388
  });
389
389
  for (const a of created) console.log(`${green('+')} ${bold(a.name)} ${dim(a.id)} session ${cyan(a.sessionId)}`);
390
390
  console.log(dim(`Workspace setup and launch continue in the background. "agentmgr ls" shows status.`));
391
+ if (created.some((a) => a.autonomy && !['auto', 'bypassPermissions'].includes(a.permissionMode ?? ''))) {
392
+ console.log(dim('Without you: it still stops at each permission prompt, which is never answered for you ("agentmgr inbox"). With -p auto, Claude Code approves what it judges safe.'));
393
+ }
391
394
  if (opts.attach && created.length === 1) {
392
395
  let a = created[0];
393
396
  for (let i = 0; i < 600 && a.status === 'preparing' && !a.runtime.running; i++) {
@@ -582,6 +585,31 @@ export async function main(argv) {
582
585
  if (d.data.verdict === 'wrong') process.exitCode = 1;
583
586
  });
584
587
 
588
+ program
589
+ .command('proof')
590
+ .description('What an agent ran to verify its work: each check with its command, exit code and output, as the agent recorded them, and what it says it did not do. --run runs the commands again here and says which gave the same result (exit 1 when one differs).')
591
+ .argument('<agent>')
592
+ .option('--run', 'run the recorded commands again in the agent\'s folder (ones that change things are not run)')
593
+ .option('--json', 'print it as JSON')
594
+ .action(async (ref, opts) => {
595
+ await daemon();
596
+ const a = await resolveAgent(ref);
597
+ let v = await api('GET', `/agents/${a.id}/proof`);
598
+ if (opts.run) {
599
+ const n = v.entries.filter((e) => e.runnable).length;
600
+ process.stderr.write(dim(`Running ${n} command${n === 1 ? '' : 's'} again in ${a.workdir ?? 'its folder'}…\n`));
601
+ v = await api('POST', `/agents/${a.id}/proof/run`);
602
+ }
603
+ if (opts.json) console.log(JSON.stringify(v, null, 2));
604
+ else {
605
+ console.log((await api('GET', `/agents/${a.id}/proof?format=md`)).markdown);
606
+ if (v.notDone.length) console.log(`${bold('Not done, as the agent says:')}\n${v.notDone.map((t) => `- ${t}`).join('\n')}\n`);
607
+ if (v.rerun && !v.rerun.stale) console.log(`Run again ${v.rerun.at}: ${green(`${v.rerun.same} same`)}${v.rerun.differs ? `, ${red(`${v.rerun.differs} different`)}` : ''}${v.rerun.skipped ? dim(`, ${v.rerun.skipped} not run`) : ''}`);
608
+ else if (v.counts.commands) console.log(dim(`Run them again: agentmgr proof ${a.id} --run${v.rerun?.stale ? ' (the last run was before the agent changed its proof)' : ''}`));
609
+ }
610
+ if (v.rerun && !v.rerun.stale && v.rerun.differs) process.exitCode = 1;
611
+ });
612
+
585
613
  program
586
614
  .command('acceptance')
587
615
  .description('What done means for an agent: the points its work is checked against. The agent drafts them in its spec; you edit and agree; the review scorecard then reports each one as met, not met or not verified')
@@ -2057,7 +2085,13 @@ export async function main(argv) {
2057
2085
  console.log(dim(' agentmgr rules'));
2058
2086
  continue;
2059
2087
  }
2060
- console.log(`${label[it.kind]} ${bold(it.agentName)} ${dim(it.agentId)} ${it.title}`);
2088
+ if (it.kind === 'auto') {
2089
+ console.log(`${cyan('done for you')} ${bold(it.agentName)} ${dim(it.agentId)} ${it.title}`);
2090
+ if (it.entry?.answer) console.log(dim(` → ${it.entry.answer}\n agentmgr autonomy ${it.agentId} --ok · agentmgr autonomy ${it.agentId} --change ${it.entry.id}="your answer"`));
2091
+ else console.log(dim(` agentmgr autonomy ${it.agentId} --ok`));
2092
+ continue;
2093
+ }
2094
+ console.log(`${label[it.kind] ?? cyan(it.kind)} ${bold(it.agentName)} ${dim(it.agentId)} ${(it.kind === 'prompt' && it.title === 'Question' && it.prompt?.question) || it.title}`);
2061
2095
  if (it.kind === 'prompt') console.log(dim(` ${(it.prompt?.choices ?? []).map((c) => `${c.key}. ${c.label}`).join(' ')} → agentmgr attach ${it.agentId}`));
2062
2096
  if (it.kind === 'question') {
2063
2097
  if (it.question.options.length) console.log(dim(` options: ${it.question.options.join(' | ')}`));
@@ -3627,7 +3661,9 @@ export async function main(argv) {
3627
3661
  if (!gone) throw new Error(`The daemon (pid ${before.pid}) is still shutting down after 5 minutes; check the log`);
3628
3662
  }
3629
3663
  const st = await svc.status();
3630
- if (st.loaded) await svc.kickstart();
3664
+ // The login service starts its own daemon: for another home or port, this one is started here.
3665
+ const viaService = st.loaded && st.ours;
3666
+ if (viaService) await svc.kickstart();
3631
3667
  else await ensureDaemon({ quiet: true });
3632
3668
  const back = async () => {
3633
3669
  const h = await health();
@@ -3636,7 +3672,7 @@ export async function main(argv) {
3636
3672
  for (let i = 0; i < 150 && !(await back()); i++) await new Promise((res) => setTimeout(res, 200));
3637
3673
  if (!(await back())) throw new Error('Daemon did not come back; check the log');
3638
3674
  const agents = await api('GET', '/agents');
3639
- console.log(`${green('✓')} restarted${st.loaded ? ' (login service)' : ''}; ${agents.filter((a) => a.desired === 'running').length} agents set to resume`);
3675
+ console.log(`${green('✓')} restarted${viaService ? ' (login service)' : ''}; ${agents.filter((a) => a.desired === 'running').length} agents set to resume`);
3640
3676
  });
3641
3677
 
3642
3678
  program
package/src/config.js CHANGED
@@ -51,6 +51,8 @@ const DEFAULTS = {
51
51
  flushSec: 30,
52
52
  // Ask task agents to keep a brief (Problem / Solution / Diagram / Checks) for the UI.
53
53
  brief: true,
54
+ // With the brief: ask for the proof of its checks (PROOF.md: command, exit code, output) and what it did not do.
55
+ proof: true,
54
56
  // Backlog: items worked on at once per project (overridable per project), and overall.
55
57
  backlogParallel: 2,
56
58
  backlogMaxActive: 4,
@@ -2,7 +2,7 @@
2
2
  // and how to read them. Other engines implement the same shape (see docs/engines.md).
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
- import { promptChoices } from '../inbox.js';
5
+ import { promptChoices, questionMenu } from '../inbox.js';
6
6
  import { scanActivity } from '../stuck.js';
7
7
  import { recentSessionFiles, scanTranscript, sessionDigest, subagentTranscripts, transcriptPath } from '../tracker.js';
8
8
  import { trustFolder } from '../trust.js';
@@ -107,8 +107,10 @@ export default {
107
107
  attention: [
108
108
  [/trustthisfolder/i, 'Folder trust prompt'],
109
109
  [/Doyouwantto(proceed|make|create|allow|run|overwrite)/i, 'Permission prompt'],
110
+ // The agent's own question, as a menu: a message typed now would pick the highlighted option.
111
+ [/Entertoselect.{0,40}Esctocancel/i, 'Question'],
110
112
  ],
111
- promptChoices: (screen) => promptChoices(screen),
113
+ promptChoices: (screen, attention) => (attention === 'Question' && questionMenu(screen)) || promptChoices(screen),
112
114
 
113
115
  /** Lines of Claude Code's own frame (input box, mode and status bar): never a question to the person. */
114
116
  screenChrome: [
package/src/inbox.js CHANGED
@@ -64,6 +64,54 @@ export function loadQuestions(agentId) {
64
64
 
65
65
  export const answerMessage = (q, text) => `Answer to your question "${q.question}": ${text}`;
66
66
 
67
+ /** Menu entries that are not an answer: free text, or talking it over. */
68
+ export const FREE_CHOICE = /^(?:type something|chat about this|other)\b/i;
69
+
70
+ /**
71
+ * Claude Code's question menu (the agent asking the person to pick): the question, its numbered
72
+ * options with the line under each, and which one is highlighted. Text sent to the terminal while
73
+ * it is open is not read as a message (Enter picks the highlighted option), so it counts as a
74
+ * prompt. Returns { question, choices: [{ key, label, hint }], selected, multi } or null.
75
+ */
76
+ export function questionMenu(screen) {
77
+ const text = String(screen ?? '')
78
+ .replace(/\x1b\[(\d*)C/g, (_, n) => ' '.repeat(Math.min(Number(n || 1), 8)))
79
+ .replace(/\x1b\[\d*G/g, ' ')
80
+ .replace(/\x1b\[[0-9;]*[ABEFHJf]/g, '\n')
81
+ .replace(/\x1b\[[0-9;?<>=]*[ -\/]*[@-~]|\x1b\][^\x07\x1b]*(\x07|\x1b\\)/g, '')
82
+ .replace(/\r/g, '\n');
83
+ const lines = text.split('\n').map((l) => l.replace(/\s+/g, ' ').trim());
84
+ const end = lines.findLastIndex((l) => /Enter to select/i.test(l));
85
+ if (end < 0) return null;
86
+ const choices = [];
87
+ let hint = [];
88
+ let selected = null;
89
+ let multi = false;
90
+ let top = -1;
91
+ for (let i = end - 1; i >= 0 && top < 0; i--) {
92
+ const l = lines[i];
93
+ if (!l || /^[─━╌-]+$/.test(l)) continue;
94
+ const m = /^([❯>›]\s*)?(\[[ x✔✓]?\]\s*|[☐☑◻◼]\s*)?(\d)[.)]\s+(.{1,120})$/.exec(l);
95
+ if (!m) {
96
+ if (choices.length) hint.unshift(l);
97
+ else if (!/^(?:\d[.)])?$/.test(l)) hint = [];
98
+ continue;
99
+ }
100
+ if (choices.some((c) => c.key === m[3])) break; // an older menu above this one
101
+ choices.unshift({ key: m[3], label: m[4].trim(), hint: hint.join(' ').slice(0, 200) });
102
+ hint = [];
103
+ if (m[1]) selected = m[3];
104
+ if (m[2]) multi = true;
105
+ if (m[3] === '1') top = i;
106
+ }
107
+ if (top < 0 || choices.length < 2) return null;
108
+ let question = '';
109
+ for (let i = top - 1; i >= 0 && !question; i--) {
110
+ if (lines[i] && !/^[─━╌-]+$/.test(lines[i])) question = lines[i].slice(0, 300);
111
+ }
112
+ return { question, choices, selected, multi };
113
+ }
114
+
67
115
  /**
68
116
  * Answer choices visible in a live prompt: numbered menu lines ("❯ 1. Yes", "2. No").
69
117
  * `screen` is recent terminal output; cursor moves become spaces before matching.
package/src/manager.js CHANGED
@@ -136,6 +136,7 @@ import { CLAIM_TEXTS, claimsMarkdown, claimsPrompt, combineClaims, parseClaims,
136
136
  import { CONTAINER_ENGINES, claudeToken, containerName, containerRunning, engineMounts, gitCommonDir, removeContainer, runArgs, stopContainer } from './container.js';
137
137
  import { conflictMessage, findConflicts, related, repoKey, summarize as summarizeConflicts } from './conflicts.js';
138
138
  import { answerMessage, loadQuestions, questionsPath, questionsPrompt } from './inbox.js';
139
+ import { PROOF_FILE, proofBlock, proofFacts, proofPrompt } from './proof.js';
139
140
  import { GroundRules, groundRulesMessage } from './groundrules.js';
140
141
  import { autonomySettings, callLadder, eligible as autonomyEligible, levelOf, modelName, parseLevel } from './autonomy.js';
141
142
  import { STUCK_DEFAULTS, detectStuck } from './stuck.js';
@@ -482,7 +483,7 @@ export class AgentManager extends EventEmitter {
482
483
  else if (agent.brief?.status || rt?.pty || agent.status === 'preparing') outcome = 'in progress';
483
484
  }
484
485
  if (!outcome && !delivered.length && !blockers.length) return null;
485
- return { outcome: outcome ?? 'in progress', delivered, blockers, notes: r?.notes ?? '', confidence: r?.confidence ?? null, fromAgent: Boolean(r) };
486
+ return { outcome: outcome ?? 'in progress', delivered, blockers, notes: r?.notes ?? '', confidence: r?.confidence ?? null, notDone: r?.notDone ?? [], notDoneSaid: Boolean(r?.notDoneSaid), fromAgent: Boolean(r) };
486
487
  }
487
488
 
488
489
  changed(agent) {
@@ -1394,6 +1395,8 @@ export class AgentManager extends EventEmitter {
1394
1395
  const dir = fs.realpathSync(briefDir(agent.id));
1395
1396
  writableDir = dir;
1396
1397
  prompts.push(briefPrompt(path.join(dir, path.basename(briefPath(agent.id)))));
1398
+ // What it ran to verify, kept so it can be checked, and what it left out (proof.js).
1399
+ if (this.config.proof !== false) prompts.push(proofPrompt(path.join(dir, PROOF_FILE)));
1397
1400
  if (this.config.inbox !== false) prompts.push(questionsPrompt(path.join(dir, path.basename(questionsPath(agent.id)))));
1398
1401
  }
1399
1402
  // SPEC.md before changing code, and PLAN.md kept as it goes (unless the plan review asks for the plan).
@@ -2534,6 +2537,7 @@ export class AgentManager extends EventEmitter {
2534
2537
  const agent = this.store.get(id);
2535
2538
  if (!agent) return;
2536
2539
  const before = agent.brief; // patch() below changes agent.brief in place
2540
+ this.proof?.reload(id);
2537
2541
  const brief = loadBrief(id, before);
2538
2542
  if (brief) {
2539
2543
  this.patch(id, { brief });
@@ -2845,6 +2849,9 @@ export class AgentManager extends EventEmitter {
2845
2849
  }
2846
2850
  // The spec and plan go along with the brief: what done means, and how it gets there.
2847
2851
  const extra = ['spec', 'plan'].map((n) => readSpecDoc(agent.id, n)?.markdown.trim()).filter(Boolean);
2852
+ // And its proof (proof.js): what it recorded of its checks, and what the app saw when it ran them again.
2853
+ const proof = this.proof?.forScore(agent);
2854
+ if (proof?.entries.length) extra.push(['# Proof of its checks, as the agent recorded it', ...proofFacts(proof.doc, proof.rerun), '', proofBlock(proof.entries, 4000)].join('\n'));
2848
2855
  return { intent: agent.intent, status, digest, repo, briefMarkdown: [briefMarkdown, ...extra].filter(Boolean).join('\n\n') };
2849
2856
  }
2850
2857
 
@@ -2958,9 +2965,10 @@ export class AgentManager extends EventEmitter {
2958
2965
  const doc = (n) => readSpecDoc(agent.id, n)?.markdown ?? '';
2959
2966
  // The repository's standards: its bar is run here, by the app, before the model is asked.
2960
2967
  const standards = (await this.standards?.assess(agent.id, data)) ?? null;
2961
- const f = scoreFacts({ files: data.files, prs: Object.values(cur0.prs ?? {}), brief: cur0.brief, plan: doc('plan'), spec: doc('spec'), standards, agreed: cur0.acceptance?.status === 'agreed' ? cur0.acceptance.points : null });
2968
+ const proof = this.proof?.forScore(cur0) ?? null;
2969
+ const f = scoreFacts({ files: data.files, prs: Object.values(cur0.prs ?? {}), brief: cur0.brief, plan: doc('plan'), spec: doc('spec'), standards, agreed: cur0.acceptance?.status === 'agreed' ? cur0.acceptance.points : null, proof });
2962
2970
  const writer = this.writerFor(agent);
2963
- const prompt = scorecardPrompt({ ...ctx, briefMarkdown: this.briefFile(agent.id).markdown ?? '', intentDoc: doc('intent'), specDoc: doc('spec'), planDoc: doc('plan'), hunks, facts: f, lessons: standards?.lessons ?? [] });
2971
+ const prompt = scorecardPrompt({ ...ctx, briefMarkdown: this.briefFile(agent.id).markdown ?? '', intentDoc: doc('intent'), specDoc: doc('spec'), planDoc: doc('plan'), proofDoc: proof?.entries?.length ? proofBlock(proof.entries) : '', hunks, facts: f, lessons: standards?.lessons ?? [] });
2964
2972
  const sc = combine(parseJsonReply(await this.oneShot(agent, prompt, writer)), f, hunks, { lessons: standards?.lessons ?? [], bar: standards?.bar ?? null });
2965
2973
  const cur = this.store.get(agent.id);
2966
2974
  if (!cur) return null;
@@ -3884,7 +3892,7 @@ export class AgentManager extends EventEmitter {
3884
3892
 
3885
3893
  /** A live prompt's question and choices, and the tool call it asks about when the transcript says. */
3886
3894
  promptView(agent, rt) {
3887
- const p = engineOf(agent).promptChoices(rt.tail);
3895
+ const p = engineOf(agent).promptChoices(rt.tail, rt.attention);
3888
3896
  const call = rt.attention === PERMISSION ? this.pendingCall(agent) : null;
3889
3897
  return call ? { ...p, tool: describeTool(call) } : p;
3890
3898
  }
package/src/proof.js ADDED
@@ -0,0 +1,255 @@
1
+ // Proof: what the agent ran to verify its work, kept so it can be checked. Next to its brief the
2
+ // agent keeps PROOF.md: for each check it ticked (or each agreed point of what done means), the
3
+ // exact command, its exit code and the last lines of real output. The app shows it, gives it to
4
+ // the review scorecard as the agent's own record, and, when the person asks, runs the commands
5
+ // again in the agent's folder and says which gave the same result.
6
+ //
7
+ // Running them again is the person's call only (an agent's own request is refused in server.js):
8
+ // the commands were written by the agent, and here they run without its permission prompts. A
9
+ // command that changes things (deleting, committing, pushing, publishing, installing) is not run.
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import { briefDir } from './brief.js';
13
+
14
+ export const PROOF_FILE = 'PROOF.md';
15
+ export const proofPath = (agentId) => path.join(briefDir(agentId), PROOF_FILE);
16
+ export const MAX_ENTRIES = 30;
17
+ export const MAX_RERUN = 12;
18
+ const RERUN_TIMEOUT_MS = 120_000;
19
+
20
+ export const proofPrompt = (file) =>
21
+ `Keep the proof of your checks in ${file} (Markdown), next to the brief, so the user can verify them without ` +
22
+ 'taking your word. One section for each check you tick as passed, and for each agreed acceptance point:\n' +
23
+ '## <the check, starting with the acceptance point id when there is one, e.g. "A2 output is plain text">\n' +
24
+ 'Command: <the exact command you ran, on one line, runnable from the repository root; "none" when you verified by reading>\n' +
25
+ 'Exit: <its exit code>\n' +
26
+ 'then a fenced code block with the last lines of its real output (15 at most), or one line on what you read when there was no command.\n' +
27
+ 'Record only commands you really ran, with the output you really got: never write output from memory or as you expect it to be. ' +
28
+ 'Prefer commands that only look (tests, a build, a run of the program): the user may run them again. ' +
29
+ 'Update a section when you run its check again. The file is outside the repository: never commit it.\n' +
30
+ 'In the Results section of the brief, also list what you did not do: one "- Not done: ..." line for each thing the request asked or ' +
31
+ 'clearly implied that you skipped, stubbed, left untested or only assumed, and "- Not done: nothing" when there is none.';
32
+
33
+ const clip = (s, n) => {
34
+ const t = String(s ?? '').trim();
35
+ return t.length > n ? `${t.slice(0, n - 1)}…` : t;
36
+ };
37
+ const lastLines = (s, n = 15, max = 1500) => String(s ?? '').replace(/\s+$/, '').split('\n').slice(-n).join('\n').slice(-max);
38
+
39
+ /**
40
+ * PROOF.md as entries: [{ title, point, command, exit, output, note }]. `point` is the agreed
41
+ * acceptance point a title starts with ("A2"), `command` null when it was verified by reading.
42
+ */
43
+ export function parseProof(markdown) {
44
+ const parts = String(markdown ?? '').split(/^##\s+(.+?)\s*#*\s*$/m);
45
+ const out = [];
46
+ for (let i = 1; i < parts.length && out.length < MAX_ENTRIES; i += 2) {
47
+ const title = clip(parts[i].replace(/[*_`]/g, ''), 200);
48
+ const body = parts[i + 1] ?? '';
49
+ if (!title) continue;
50
+ const fence = /```[^\n]*\n([\s\S]*?)```/.exec(body);
51
+ const rest = fence ? body.replace(fence[0], '') : body;
52
+ const field = (name) => new RegExp(`^\\s*[-*]?\\s*\\**${name}\\**\\s*:\\s*\\**\\s*(.*)$`, 'im').exec(rest)?.[1]?.trim() ?? '';
53
+ const raw = field('command').replace(/^`+|`+$/g, '').trim();
54
+ const command = raw && !/^(none|n\/a|-|—)\b/i.test(raw) ? raw.slice(0, 500) : null;
55
+ const code = /^-?\d+/.exec(field('exit'))?.[0];
56
+ const note = rest
57
+ .split('\n')
58
+ .filter((l) => l.trim() && !/^\s*[-*]?\s*\**(command|exit)\**\s*:/i.test(l))
59
+ .join(' ')
60
+ .trim();
61
+ out.push({ title, point: /^(A\d+)\b/i.exec(title)?.[1].toUpperCase() ?? null, command, exit: code === undefined ? null : Number(code), output: lastLines(fence?.[1] ?? ''), note: clip(note, 300) });
62
+ }
63
+ return out;
64
+ }
65
+
66
+ const CHANGES = [
67
+ [/(^|[;&|(]\s*)(sudo|doas)\b/, 'it runs as administrator'],
68
+ [/(^|[;&|(]\s*)(rm|rmdir|mv|dd|chmod|chown|kill|pkill|killall|truncate|shred)\b/, 'it deletes, moves or stops things'],
69
+ [/\bgit\s+(?:-\S+\s+)*(push|commit|reset|clean|checkout|switch|restore|rebase|merge|tag|stash|rm|mv|apply|am|cherry-pick|revert|pull|fetch|gc|branch\s+-[dDmM])\b/, 'it changes the repository'],
70
+ [/\bgh\s+\w+\s+(create|merge|close|delete|edit|comment|review|reopen|ready)\b|\bgh\s+release\b|\bgh\s+api\b.*(-X|--method)/i, 'it changes things on GitHub'],
71
+ [/\b(npm|pnpm|yarn|bun)\s+(publish|install|i|add|remove|uninstall|update|upgrade|link|login|ci)\b|\b(pip3?|uv|poetry|cargo|gem|brew|apt|apt-get|go)\s+(install|add|remove|uninstall|publish|upgrade|get)\b/, 'it installs or publishes'],
72
+ [/\b(deploy|kubectl|helm|terraform|pulumi|ansible|docker\s+(push|rm|rmi|run|compose|kill|stop)|vercel|netlify|fly|railway|heroku|aws|gcloud|az)\b/, 'it deploys or reaches a service'],
73
+ [/\b(curl|wget|nc|ssh|scp|rsync|ftp)\b/, 'it reaches the network'],
74
+ [/(^|[^0-9&>])>{1,2}(?!\s*(\/dev\/null|&\d))/, 'it writes to a file'],
75
+ [/\b(drop|truncate)\s+(table|database)\b|\bdelete\s+from\b/i, 'it changes data'],
76
+ [/\$\(|`/, 'it runs a command inside the command'],
77
+ ];
78
+
79
+ /** Why a recorded command is not run again by the app (a short phrase), or null when it only looks. */
80
+ export function changesThings(command) {
81
+ const c = String(command ?? '');
82
+ return CHANGES.find(([re]) => re.test(c))?.[1] ?? null;
83
+ }
84
+
85
+ const squash = (s) => String(s ?? '').replace(/\s+/g, ' ').trim();
86
+
87
+ /**
88
+ * A run by the app against what the agent recorded: "same" when the exit code is the one it wrote
89
+ * (or success when it wrote none), "differs" otherwise. `output` says whether the last line it
90
+ * recorded was printed again (durations and dates make output differ without anything being wrong).
91
+ */
92
+ export function compareRun(entry, run) {
93
+ const want = entry.exit ?? 0;
94
+ const last = squash(entry.output.split('\n').filter((l) => l.trim()).at(-1));
95
+ return {
96
+ status: run.code === want ? 'same' : 'differs',
97
+ output: !last ? null : squash(run.tail).includes(last) ? 'same' : 'differs',
98
+ };
99
+ }
100
+
101
+ /** Counts for the agent's view: { entries, commands, points }. */
102
+ export const proofCounts = (entries) => ({ entries: entries.length, commands: entries.filter((e) => e.command).length, points: entries.filter((e) => e.point).length });
103
+
104
+ /** "3 of 4 checks with a recorded run" for a brief with `passed` ticked checks. */
105
+ export function proofLine(doc, passed = 0) {
106
+ if (!doc?.entries) return passed ? `none recorded for ${passed} passed check${passed === 1 ? '' : 's'}` : 'none recorded';
107
+ return `${doc.commands} recorded run${doc.commands === 1 ? '' : 's'}${doc.entries > doc.commands ? `, ${doc.entries - doc.commands} by reading` : ''}`;
108
+ }
109
+
110
+ /** The lines the review scorecard is given (facts the app measured). */
111
+ export function proofFacts(doc, rerun) {
112
+ if (!doc?.entries) return ["the agent's proof of its checks: none recorded"];
113
+ const lines = [`the agent's proof of its checks (its own record, not run by the app): ${doc.commands} with a command and output, ${doc.entries - doc.commands} verified by reading`];
114
+ if (rerun?.results?.length && !rerun.stale) {
115
+ const same = rerun.results.filter((r) => r.status === 'same').length;
116
+ const differs = rerun.results.filter((r) => r.status === 'differs');
117
+ const skipped = rerun.results.filter((r) => r.status === 'skipped').length;
118
+ lines.push(
119
+ `those commands run again by the app, at the person's request: ${same} gave the recorded exit code, ${differs.length} did not${differs.length ? ` (${differs.map((r) => r.title).join('; ')})` : ''}${skipped ? `, ${skipped} not run (they change things)` : ''}`,
120
+ );
121
+ }
122
+ return lines;
123
+ }
124
+
125
+ /** PROOF.md for the scorecard prompt, cut to size. */
126
+ export function proofBlock(entries, max = 6000) {
127
+ const out = [];
128
+ let used = 0;
129
+ for (const e of entries) {
130
+ const text = [`## ${e.title}`, `Command: ${e.command ?? 'none (verified by reading)'}`, e.exit === null ? '' : `Exit: ${e.exit}`, e.output ? lastLines(e.output, 8, 600) : e.note].filter(Boolean).join('\n');
131
+ if (used + text.length > max) {
132
+ out.push(`(${entries.length - out.length} more not shown)`);
133
+ break;
134
+ }
135
+ used += text.length;
136
+ out.push(text);
137
+ }
138
+ return out.join('\n\n');
139
+ }
140
+
141
+ export function proofMarkdown(view) {
142
+ const out = [`# Proof: ${view.name}`, ''];
143
+ if (!view.entries.length) return [...out, 'The agent recorded no proof of its checks.'].join('\n');
144
+ const mark = { same: '✅ same result when run again', differs: '❌ a different result when run again', skipped: '➖ not run again' };
145
+ for (const e of view.entries) {
146
+ out.push(`## ${e.title}`, '', e.command ? `Command: \`${e.command}\`${e.exit === null ? '' : ` (exit ${e.exit})`}` : `Verified by reading${e.note ? `: ${e.note}` : ''}`);
147
+ if (e.output) out.push('', '```', e.output, '```');
148
+ if (e.rerun) out.push('', `${mark[e.rerun.status]}${e.rerun.status === 'differs' ? `: exit ${e.rerun.code ?? 'none (stopped)'}` : e.rerun.status === 'skipped' ? `: ${e.rerun.why}` : ''}`);
149
+ out.push('');
150
+ }
151
+ return out.join('\n');
152
+ }
153
+
154
+ export class Proof {
155
+ /** `run(command, { cwd, timeoutMs })` resolves { ok, code, ms, tail } (standards.js runCheck). */
156
+ constructor({ manager, store, run, log = () => {}, timeoutMs = RERUN_TIMEOUT_MS }) {
157
+ Object.assign(this, { manager, store, run, log, timeoutMs });
158
+ this.running = new Map(); // agentId -> the run in progress
159
+ }
160
+
161
+ read(agentId) {
162
+ try {
163
+ return parseProof(fs.readFileSync(proofPath(agentId), 'utf8'));
164
+ } catch {
165
+ return [];
166
+ }
167
+ }
168
+
169
+ /** Pick up changes to PROOF.md: the counts go on the agent (for the list and the results card). */
170
+ reload(agentId) {
171
+ const agent = this.store.get(agentId);
172
+ if (!agent) return;
173
+ let st;
174
+ try {
175
+ st = fs.statSync(proofPath(agentId));
176
+ } catch {
177
+ return;
178
+ }
179
+ if (agent.proofDoc?.mtimeMs === st.mtimeMs) return;
180
+ this.manager.patch(agentId, { proofDoc: { ...proofCounts(this.read(agentId)), mtimeMs: st.mtimeMs, updatedAt: st.mtime.toISOString() } });
181
+ }
182
+
183
+ /** What an agent recorded, with the last run by the app beside each entry. */
184
+ view(ref) {
185
+ const agent = this.manager.mustGet(ref);
186
+ const entries = this.read(agent.id);
187
+ const rerun = agent.proof ?? null;
188
+ // A run made before the agent changed its proof no longer speaks for it.
189
+ const stale = Boolean(rerun) && rerun.proofAt !== (agent.proofDoc?.updatedAt ?? null);
190
+ const by = new Map((stale ? [] : rerun?.results ?? []).map((r) => [`${r.title}\n${r.command}`, r]));
191
+ return {
192
+ id: agent.id,
193
+ name: agent.name,
194
+ entries: entries.map((e) => ({ ...e, runnable: e.command ? !changesThings(e.command) : false, why: e.command ? changesThings(e.command) : null, rerun: by.get(`${e.title}\n${e.command}`) ?? null })),
195
+ counts: proofCounts(entries),
196
+ passed: (agent.brief?.checks ?? []).filter((c) => c.state === 'passed').length,
197
+ notDone: agent.brief?.results?.notDone ?? [],
198
+ rerun: rerun ? { at: rerun.at, stale, same: rerun.results.filter((r) => r.status === 'same').length, differs: rerun.results.filter((r) => r.status === 'differs').length, skipped: rerun.results.filter((r) => r.status === 'skipped').length } : null,
199
+ running: this.running.has(agent.id),
200
+ canRun: this.cannotRun(agent) === null,
201
+ whyNot: this.cannotRun(agent),
202
+ };
203
+ }
204
+
205
+ cannotRun(agent) {
206
+ if (agent.container) return 'It works in a container: its commands are not run on this computer.';
207
+ if (!agent.workdir || !fs.existsSync(agent.workdir)) return "The agent's folder is not on this computer.";
208
+ return null;
209
+ }
210
+
211
+ /** For the scorecard: the counts, the entries and the last run, or null when nothing is recorded. */
212
+ forScore(agent) {
213
+ const entries = this.read(agent.id);
214
+ const rerun = agent.proof ? { ...agent.proof, stale: agent.proof.proofAt !== (agent.proofDoc?.updatedAt ?? null) } : null;
215
+ return { doc: proofCounts(entries), entries, rerun };
216
+ }
217
+
218
+ /** Run the recorded commands again, one after the other, in the agent's folder. The person's call. */
219
+ async run_(agent) {
220
+ const entries = this.read(agent.id).filter((e) => e.command);
221
+ const results = [];
222
+ let ran = 0;
223
+ for (const e of entries) {
224
+ const why = changesThings(e.command) ?? (ran >= MAX_RERUN ? `only the first ${MAX_RERUN} are run` : null);
225
+ if (why) {
226
+ results.push({ title: e.title, command: e.command, status: 'skipped', why });
227
+ continue;
228
+ }
229
+ ran++;
230
+ this.log(`proof: ${agent.name}: ${e.command}`);
231
+ const r = await this.run(e.command, { cwd: agent.workdir, timeoutMs: this.timeoutMs });
232
+ results.push({ title: e.title, command: e.command, code: r.code, ms: r.ms, tail: lastLines(r.tail, 12, 1000), ...compareRun(e, r) });
233
+ }
234
+ return results;
235
+ }
236
+
237
+ async rerun(ref) {
238
+ const agent = this.manager.mustGet(ref);
239
+ const no = this.cannotRun(agent);
240
+ if (no) throw Object.assign(new Error(no), { status: 400 });
241
+ if (!this.read(agent.id).some((e) => e.command)) throw Object.assign(new Error('The agent recorded no commands to run again'), { status: 400 });
242
+ if (!this.running.has(agent.id)) {
243
+ const proofAt = agent.proofDoc?.updatedAt ?? null;
244
+ const p = this.run_(agent)
245
+ .then((results) => {
246
+ if (this.store.get(agent.id)) this.manager.patch(agent.id, { proof: { at: new Date().toISOString(), proofAt, results } });
247
+ })
248
+ .finally(() => this.running.delete(agent.id));
249
+ this.running.set(agent.id, p);
250
+ this.manager.changed?.(agent);
251
+ }
252
+ await this.running.get(agent.id);
253
+ return this.view(agent.id);
254
+ }
255
+ }
package/src/scorecard.js CHANGED
@@ -4,6 +4,8 @@
4
4
  // plan ticks, the spec's criteria) cap and correct it, and the recommendation follows fixed rules,
5
5
  // so a confident-sounding model can't talk a change into "ready".
6
6
 
7
+ import { proofFacts } from './proof.js';
8
+
7
9
  export const DIMENSIONS = [
8
10
  ['intent', 'Intent', 'Does it do what was asked?'],
9
11
  ['spec', 'Spec', 'Are the acceptance criteria met?'],
@@ -16,7 +18,7 @@ const WEIGHTS = { intent: 25, spec: 20, tests: 20, safety: 15, scope: 10, plan:
16
18
  const TEST_FILE = /(^|\/)(tests?|__tests__|spec|specs)\/|[._-](test|spec)\.[a-z]+$|_test\.go$|Test\.java$/i;
17
19
 
18
20
  /** Facts the app knows without a model: CI, test files touched, the agent's checks, plan and spec progress. */
19
- export function facts({ files = [], prs = [], brief = null, plan = '', spec = '', standards = null, agreed = null }) {
21
+ export function facts({ files = [], prs = [], brief = null, plan = '', spec = '', standards = null, agreed = null, proof = null }) {
20
22
  const paths = files.map((f) => f.path);
21
23
  const tests = paths.filter((p) => TEST_FILE.test(p));
22
24
  const code = paths.filter((p) => !TEST_FILE.test(p) && !/\.(md|txt|rst|adoc)$/i.test(p) && !/(^|\/)docs?\//i.test(p));
@@ -37,6 +39,9 @@ export function facts({ files = [], prs = [], brief = null, plan = '', spec = ''
37
39
  plan: steps.length ? { steps: steps.length, done: steps.filter((s) => s === 'x').length } : null,
38
40
  criteria: criteriaBlock.split('\n').filter((l) => /^\s*[-*\d]/.test(l) && /\w/.test(l)).length,
39
41
  hasSpec: Boolean(String(spec).trim()),
42
+ // Its proof (proof.js): what it recorded, what the app ran again, and what it says it left out.
43
+ proof: proof ? { doc: proof.doc, rerun: proof.rerun ?? null } : null,
44
+ notDone: brief?.results?.notDone ?? [],
40
45
  // What done means, agreed with the person (acceptance.js): these are checked, whatever the spec says now.
41
46
  agreed: agreed?.length ? agreed.map((p) => ({ id: p.id, text: p.text })) : null,
42
47
  // The repository's standards (standards.js): high-risk files touched, and the bar the app ran.
@@ -55,9 +60,11 @@ export const factLines = (f) =>
55
60
  ...(f.agreed ? [`acceptance agreed with the person: ${f.agreed.length} point${f.agreed.length === 1 ? '' : 's'}`] : []),
56
61
  ...(f.bar ? [`the repository's quality bar, run by the app: ${f.bar.passed} passed, ${f.bar.failed.length} failed${f.bar.failed.length ? ` (${f.bar.failed.join(', ')})` : ''}`] : []),
57
62
  ...(f.risk?.length ? [`files under paths the person marked high risk: ${f.risk.join(', ')}`] : []),
63
+ ...(f.proof ? proofFacts(f.proof.doc, f.proof.rerun) : []),
64
+ ...(f.notDone?.length ? [`the agent lists as not done: ${f.notDone.join('; ')}`] : []),
58
65
  ].join('\n');
59
66
 
60
- export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentDoc, specDoc, planDoc, hunks, facts: f, lessons = [] }) {
67
+ export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentDoc, specDoc, planDoc, proofDoc = '', hunks, facts: f, lessons = [] }) {
61
68
  return [
62
69
  "You score an AI coding agent's changes for a reviewer who wants to approve with confidence and read as little as possible.",
63
70
  'Be skeptical: a claim without evidence in the diff, the tests or the checks counts as unverified. Base everything on the material below.',
@@ -106,6 +113,8 @@ export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentD
106
113
  '<brief>',
107
114
  briefMarkdown || '(none)',
108
115
  '</brief>',
116
+ // Its own record of what it ran: evidence for a check when the output shown fits the claim, but not run by the app unless the facts say so.
117
+ ...(proofDoc ? ['<proof_recorded_by_the_agent>', proofDoc, '</proof_recorded_by_the_agent>'] : []),
109
118
  '<hunks>',
110
119
  ...hunks.map((h) => `<hunk id="${h.id}" file="${h.file}">\n${h.head}\n${h.text}\n</hunk>`),
111
120
  '</hunks>',
@@ -137,6 +146,10 @@ export function combine(reply, f, hunks, { lessons = [], bar = null } = {}) {
137
146
  // The repository's quality bar, run by the app: a failed check is not verified, whatever else passed.
138
147
  const barFailed = (bar?.results ?? []).filter((r) => !r.ok);
139
148
  if (barFailed.length) cap('tests', 30, `the quality bar is not met (${barFailed.map((r) => r.name).join(', ')})`);
149
+ // Its recorded commands, run again by the app at the person's request: one that now gives another result is not verified.
150
+ const differs = f.proof?.rerun && !f.proof.rerun.stale ? f.proof.rerun.results.filter((r) => r.status === 'differs') : [];
151
+ if (differs.length) cap('tests', 40, `${differs.length} of its recorded commands gave a different result when run again (${differs.map((r) => r.title).join('; ').slice(0, 200)})`);
152
+ if (f.notDone?.length && out.intent) out.intent.notes.push(`the agent lists ${f.notDone.length} thing${f.notDone.length === 1 ? '' : 's'} as not done`);
140
153
  // Plan: bounded by the steps ticked.
141
154
  if (f.plan && out.plan) cap('plan', Math.round(40 + (60 * f.plan.done) / f.plan.steps), `${f.plan.done} of ${f.plan.steps} plan steps ticked`);
142
155
  if (!f.plan && out.plan) out.plan.notes.push('no plan written');
package/src/server.js CHANGED
@@ -57,7 +57,8 @@ import { Builder } from './builder.js';
57
57
  import { Standup } from './standup.js';
58
58
  import { Value, valueSlack } from './value.js';
59
59
  import { Quality } from './quality.js';
60
- import { Standards } from './standards.js';
60
+ import { Standards, runCheck } from './standards.js';
61
+ import { Proof, proofMarkdown } from './proof.js';
61
62
  import { News } from './news.js';
62
63
  import { System } from './system.js';
63
64
  import { Advisor } from './advisor.js';
@@ -245,6 +246,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
245
246
  // Agents that run without you (autonomy.js): routine questions answered from what is decided,
246
247
  // nudges and follow-ups sent, and at "merge" the pull request merged when everything says ready.
247
248
  const autonomy = new Autonomy({ manager, store, config, review, landing, backlog });
249
+ manager.proof = new Proof({ manager, store, run: runCheck, log: (m) => console.log(`[agentmgr] ${m}`) });
248
250
  manager.inboxSources.push(() => autonomy.inbox());
249
251
  // How far an agent goes without the person is the person's to set: never an agent's own call.
250
252
  const yourLevel = (req) => {
@@ -696,6 +698,16 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
696
698
  };
697
699
  api.post('/agents/:id/acceptance/agree', wrap((req) => (person(req), manager.agreeAcceptance(req.params.id, req.body?.points))));
698
700
  api.post('/agents/:id/acceptance/skip', wrap((req) => (person(req), manager.skipAcceptance(req.params.id))));
701
+ // Proof (proof.js): what the agent recorded of its checks. Running the commands again is the
702
+ // person's call: they were written by the agent, and here they run without its permission prompts.
703
+ api.get('/agents/:id/proof', wrap((req) => {
704
+ const v = manager.proof.view(req.params.id);
705
+ return req.query.format === 'md' ? { markdown: proofMarkdown(v) } : v;
706
+ }));
707
+ api.post('/agents/:id/proof/run', wrap((req) => {
708
+ if (req.headers['x-agentmgr-agent']) throw fail(403, 'Running the proof again is asked by the person, not by an agent');
709
+ return manager.proof.rerun(req.params.id);
710
+ }));
699
711
  // Autonomy (autonomy.js): the default level and the models its calls run on; one agent's level;
700
712
  // and what was done for the person: seen ("ack"), or an answer changed to their own ("correct").
701
713
  api.get('/autonomy', wrap(() => autonomy.status()));
package/src/service.js CHANGED
@@ -43,6 +43,19 @@ export function passEnv(source = process.env) {
43
43
  return env;
44
44
  }
45
45
 
46
+ /**
47
+ * Whether the service file's daemon is the one this process talks to: the same home and port. A
48
+ * second daemon (another home or port, as in a trial or a test) is not the login service's.
49
+ */
50
+ export function serviceIsOurs(text, source = process.env) {
51
+ const of = (key) => new RegExp(`<key>${key}</key><string>([^<]*)</string>|^Environment=${key}=(.*)$`, 'm').exec(String(text ?? ''));
52
+ const unxml = (v) => v.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
53
+ return ['AGENTMGR_HOME', 'AGENTMGR_PORT'].every((key) => {
54
+ const m = of(key);
55
+ return (m ? unxml(m[1] ?? m[2]) : '') === (source[key] ?? '');
56
+ });
57
+ }
58
+
46
59
  const xml = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
47
60
 
48
61
  export function plist() {
@@ -128,18 +141,26 @@ export async function uninstall() {
128
141
  throw new Error(`Login service is not supported on ${process.platform}`);
129
142
  }
130
143
 
144
+ const ours = (file) => {
145
+ try {
146
+ return serviceIsOurs(fs.readFileSync(file, 'utf8'));
147
+ } catch {
148
+ return true; // loaded without a file we can read: as before
149
+ }
150
+ };
151
+
131
152
  export async function status() {
132
153
  if (process.platform === 'darwin') {
133
154
  const installed = fs.existsSync(PLIST);
134
155
  const loaded = await run('launchctl', ['print', `gui/${uid()}/${LABEL}`]).then(() => true, () => false);
135
- return { installed, loaded, file: PLIST };
156
+ return { installed, loaded, ours: ours(PLIST), file: PLIST };
136
157
  }
137
158
  if (process.platform === 'linux') {
138
159
  const installed = fs.existsSync(UNIT);
139
160
  const loaded = await run('systemctl', ['--user', 'is-active', UNIT_NAME]).then(() => true, () => false);
140
- return { installed, loaded, file: UNIT };
161
+ return { installed, loaded, ours: ours(UNIT), file: UNIT };
141
162
  }
142
- return { installed: false, loaded: false, file: null };
163
+ return { installed: false, loaded: false, ours: false, file: null };
143
164
  }
144
165
 
145
166
  /** Start the service-managed daemon now (after "agentmgr shutdown", launchd won't on its own). */