ai-agentmanager 1.49.0 → 1.50.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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.50.0 (2026-11-14)
4
+
5
+ - **Reverse engineer.** **🔍 Reverse engineer** in an agent's detail (or the **Reverse** tab of the split, or `agentmgr reverse`) puts the agent's session on the left and a pane on the right. Name a target (an app's folder, a binary's path, a website's address) and what you want to understand; the agent investigates in its own session with the tools of [REA](https://github.com/morluto/rea), the "Reverse Engineer Anything" MCP server, and changes nothing.
6
+ - **The report.** Drawn beside the session as the agent writes it: what the target is, how the feature works as an animated diagram, the data and interfaces, findings with their evidence marked confirmed or inferred, what could not be determined, and a plan for building your own version.
7
+ - **Build it in my project.** The agent writes your own version from the behaviour the report describes, with tests: its own code, nothing copied from the target.
8
+ - **REA is set up by you.** The pane says whether REA is registered with Claude Code for the agent's folder; if it isn't, run `npx rea-agents setup` in a terminal and restart the agent's session. The app installs nothing. Native binaries also need Hopper, Ghidra, IDA or Kuna.
9
+ - **What it is for.** Software you own or are allowed to analyse. The agent is told to analyse only, not to work on getting around licence checks, copy protection or sign-in, and not to collect credentials or personal data.
10
+
3
11
  ## 1.49.0 (2026-11-14)
4
12
 
5
13
  - **Decide.** **Decide** in the top bar (or `q`, `#decide`, `agentmgr decide`) helps with the decisions, not only the tasks. A plan waiting for review or an agent's question comes with its options, the one recommended, why, the evidence, the risk, how sure it is, and whether it is hard to undo; one click carries out any option, and the same recommendation is on the item's Inbox card. The reasoning is the AI judge's, on your own plan, within its daily budget; with the judge off nothing is recommended or decided.
package/README.md CHANGED
@@ -30,6 +30,7 @@ Run one background [Claude Code](https://claude.com/claude-code) agent per inten
30
30
  - **Plan.** A project's commitment dates (code complete, release candidate, GA) with a checklist of what is still open for each, reminders as they come near, and an at-risk or late flag. A **decision log** gathered from plan reviews, your answers and design docs. A **tech debt radar** from git history and the code. What is open can be handed to an agent.
31
31
  - **Your day.** Connect your calendar and Today lays the day out around your meetings: the free time between them with what needs you placed in it, and what each meeting is about.
32
32
  - **Debug.** Say what to debug (a failure, E2E instability at max scale, slowness under load) in the **Debug** tab beside an agent's session. The agent investigates there and writes a report next to it: animated diagrams of the code path and the data flow with where it breaks, findings with evidence, likely causes and recommended fixes. It changes no code until you press **Apply fixes**.
33
+ - **Reverse engineer.** Name a target (an app's folder, a binary, a website) and what you want to understand, in the **Reverse** tab beside an agent's session: the agent investigates with [REA](https://github.com/morluto/rea)'s tools and keeps a report with animated diagrams of how it works, the evidence, what could not be determined, and a plan to build your own version.
33
34
  - **Runbooks for support.** A runbook for the support team written from a release ticket, every ticket of an epic, or a project's code changes in a time frame: what changed, what customers may see, how to check it, troubleshooting, rollback, when to escalate, and what to confirm with engineering.
34
35
  - **Decide.** Help with the decisions, not only the tasks: a plan to review or an agent's question arrives with its options, the one recommended, why, and the risk; calls you keep making become standing decisions that are handled for you and reported; the backlog is ranked by impact; a date at risk is laid out as choices; and past decisions are looked back on.
35
36
  - **OS.** The computer the agents run on and how loaded it is right now: processor, load average, memory, swap and disks with the last ten minutes, what each open agent session takes, and the busiest processes.
@@ -189,6 +190,7 @@ agentmgr remote on | off | status | rotate # phone / remote access (see below
189
190
  agentmgr backlog add "ask" -r <repo> [-p 1] # queue work; also: ls, start, accept, reopen, move, limit, pause
190
191
  agentmgr notify slack --webhook <url> # Slack alerts; also: test, status, on, off, event <name> on|off
191
192
  agentmgr debug <agent> "what goes wrong" # debug with an agent; no question prints its report; --fix applies the fixes
193
+ agentmgr reverse <agent> -t /path/to/app "how does search work" # reverse engineer with an agent and REA; no question prints the report; --build builds your own
192
194
  agentmgr dates <project> --cc 2026-12-01 --rc 2026-12-10 --ga 2026-12-20 # commitment dates; no dates: where each stands
193
195
  agentmgr decisions [project] [--md] # the decision log; --add "<question>" --decision "<what>" adds one
194
196
  agentmgr debt <project> --scan # the tech debt radar: files that change often and are hard to read
@@ -1219,6 +1221,17 @@ With it, Today opens with **Your day**:
1219
1221
 
1220
1222
  Repeating meetings, time zones, moved or cancelled occurrences and events marked *free* are understood. Several calendars can be added; **Disconnect** forgets them. In config.json: `"calendar": { "ics": ["https://…"], "workStart": "09:00", "workEnd": "18:00" }`.
1221
1223
 
1224
+ ## Reverse engineer
1225
+
1226
+ **🔍 Reverse engineer** in an agent's detail (or the **Reverse** tab of the split) puts the agent's session on the left and a pane on the right. Name a **target** (an app's folder or `.asar`, a binary's path, a website's address) and what you want to understand ("how does search work in this app"). The agent investigates in its own session with the tools of [REA](https://github.com/morluto/rea), the "Reverse Engineer Anything" MCP server, and changes nothing.
1227
+
1228
+ - **The report**, drawn beside the session as the agent writes it: what the target is, how the feature works as an animated diagram, the data and interfaces (storage, formats, calls between processes, network requests), findings with their evidence marked confirmed or inferred, what could not be determined, and a plan for building your own version in this project.
1229
+ - **Follow-ups and building.** **Ask** continues the investigation. **Build it in my project** has the agent write your own version from the behaviour the report describes, with tests: its own code, nothing copied from the target.
1230
+ - **REA is set up by you.** The pane says whether REA is registered with Claude Code for the agent's folder (read from Claude Code's settings and the project's `.mcp.json`; a plugin that brings REA is not seen there). If it isn't, run `npx rea-agents setup` in a terminal and restart the agent's session: the app installs nothing. Native binaries also need Hopper, Ghidra, IDA or Kuna; JavaScript, Electron and websites need nothing more.
1231
+ - **What it is for.** Software you own or are allowed to analyse: a licence or the law may restrict reverse engineering someone else's product. The agent is told to analyse only, not to work on getting around licence checks, copy protection or sign-in, not to collect credentials or personal data, and to build from behaviour without copying code or assets.
1232
+
1233
+ `agentmgr reverse <agent> -t <target> "<what to understand>"` asks from the terminal, `agentmgr reverse <agent>` prints the report, and `--build` builds your own.
1234
+
1222
1235
  ## Debug
1223
1236
 
1224
1237
  **🐞 Debug** in an agent's detail (or the **Debug** tab of the split, **◫ Split** in the terminal bar) puts the agent's session on the left and the debug pane on the right. Type what is going wrong, for example *E2E tests fail at max scale after about 20 minutes* or *p99 latency triples under load*, and press **Debug** (or Enter).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.49.0",
3
+ "version": "1.50.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
@@ -2362,6 +2362,7 @@ function renderDetail() {
2362
2362
  ${a.questions?.length ? `<button data-act="questions" title="What the agent asked you, and your answers">Questions${openQuestions(a) ? ` <span class="count">${openQuestions(a)}</span>` : ''}</button>` : ''}
2363
2363
  ${a.conflicts?.length ? `<button data-act="overlaps" title="Other agents changing the same files: which, who should merge first, and what to do">⚔ Overlaps <span class="count">${a.conflicts.length}</span></button>` : ''}
2364
2364
  <button data-act="debug" class="desk-only" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="Debug with this agent: say what to debug (a failure, instability at scale, slowness under load). It investigates in its session and writes a report beside it: animated diagrams of the code path and data flow, findings and recommended fixes">🐞 Debug${a.specDocs?.debug ? ' <span class="count">report</span>' : ''}</button>
2365
+ <button data-act="reverse" class="desk-only" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="Reverse engineer with this agent and REA's tools: name a target (an app's folder, a binary, a website) and what you want to understand. It investigates in its session and writes a report beside it: how it works with animated diagrams, the evidence, what could not be determined, and a plan to build your own version">🔍 Reverse engineer${a.specDocs?.reverse ? ' <span class="count">report</span>' : ''}</button>
2365
2366
  <button data-act="mcp" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="The MCP servers and tools Claude Code has in this agent's folder; run one in its session or once in the workspace">MCP tools</button>
2366
2367
  <button data-act="fork" ${a.workdir && a.git?.branch ? '' : 'disabled'} title="A new agent with this one's code and conversation, in its own worktree, to try another approach">Fork</button>
2367
2368
  <button data-act="edit" title="Change its name, request, project, priority, permission mode or model">Edit</button>
@@ -3967,6 +3968,9 @@ $('#detail-body').addEventListener('click', async (e) => {
3967
3968
  case 'debug':
3968
3969
  term.open(a.id);
3969
3970
  return sidePane.open('debug');
3971
+ case 'reverse':
3972
+ term.open(a.id);
3973
+ return sidePane.open('reverse');
3970
3974
  case 'mcp':
3971
3975
  return mcpUi.open(a.id);
3972
3976
  case 'memory':
package/public/index.html CHANGED
@@ -199,6 +199,7 @@
199
199
  <button class="term-tab" data-side="docs" role="tab" title="Diagrams and the other documents">Docs</button>
200
200
  <button class="term-tab" data-side="changes" role="tab" title="Its changes, explained one by one">Changes</button>
201
201
  <button class="term-tab" data-side="debug" role="tab" title="Debug: say what to debug; the agent investigates in its session and its report shows here, with animated diagrams of the code path and data flow, findings and recommended fixes">Debug</button>
202
+ <button class="term-tab" data-side="reverse" role="tab" title="Reverse engineer: name a target (an app, a binary, a website) and what to understand; the agent investigates with REA's tools and its report shows here, with diagrams, evidence, what could not be determined, and a plan to build your own">Reverse</button>
202
203
  </div>
203
204
  <span class="spacer"></span>
204
205
  <button type="button" class="ghost small" id="side-close" title="Close the split">✕</button>
package/public/side.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // The split view: the terminal (Claude, a shell or a browser tab) stays on the left, and the right
2
2
  // pane shows the same agent's Code, its Docs (Diagrams by default), its Changes explained one by
3
- // one, or Debug: you say what to debug, the agent investigates in its session on the left and its
4
- // report (animated code path and data flow, findings, fixes) grows here. On, the tab and the
3
+ // one, Debug: you say what to debug, the agent investigates in its session on the left and its
4
+ // report (animated code path and data flow, findings, fixes) grows here; or Reverse engineer: the
5
+ // same for how something in an app, a binary or a website works, with REA's tools. On, the tab and the
5
6
  // document are remembered in this browser.
6
7
  import { parseDiff } from '/review.js';
7
8
  import { cardHtml, explainButton, listenParts as walkParts, walkthroughOf } from '/walkthrough.js';
@@ -66,97 +67,150 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
66
67
  if (st.tab === 'code') codeUi.open(st.agentId);
67
68
  else if (st.tab === 'docs') renderDocs(true);
68
69
  else if (st.tab === 'debug') renderDebug(true);
70
+ else if (st.tab === 'reverse') renderReverse(true);
69
71
  else renderChanges(true);
70
72
  refit();
71
73
  }
72
74
 
73
- // ------------------------------------------------------------ Debug
74
- const DEBUG_IDEAS = ['E2E tests unstable at max scale', 'Slow or failing under load', 'A flaky test', 'A memory or connection leak', 'Wrong data end to end'];
75
- const drafts = new Map(); // agent id -> what's typed and not sent
75
+ // ------------------------------------------------------------ Debug and Reverse engineer
76
+ // Two investigations of the same shape: you ask, the agent investigates in its session, and its
77
+ // report grows here. They differ in their words, in what follows the report (fixes, or building
78
+ // your own), and Reverse engineer also names a target and needs REA's tools.
79
+ const ASK = {
80
+ debug: {
81
+ ideas: ['E2E tests unstable at max scale', 'Slow or failing under load', 'A flaky test', 'A memory or connection leak', 'Wrong data end to end'],
82
+ first: 'What should it debug? For example: E2E tests fail at max scale after about 20 minutes',
83
+ more: 'A follow-up: what you know, what to look at next, or which fixes to apply',
84
+ go: 'Debug',
85
+ short: 'Say what to debug',
86
+ sent: 'Sent to the agent: it investigates in its session',
87
+ then: { key: 'fix', label: 'Apply fixes', sent: 'Asked the agent to apply the fixes', title: "Ask the agent to make the report's fixes, verify each and record the result. Name the ones you want in the box (for example: 1 and 3), or leave it empty for the ones it recommends" },
88
+ waiting: 'the report shows here once it has the code path',
89
+ empty: 'Say what is going wrong: a failure, instability at scale, slowness under load. The agent investigates in its session (it reads the code and logs, reproduces and measures where it can) and writes a report here: animated diagrams of the code path and the data flow with where it breaks, what it found with evidence, the likely causes, and the fixes it recommends. It changes no code until you ask for a fix.',
90
+ },
91
+ reverse: {
92
+ ideas: ['How does search work?', 'How is data stored and synced?', 'What does it send over the network?', 'How does the plugin system load code?', 'What file format does it save?'],
93
+ first: 'What do you want to understand? For example: how does search work in this app',
94
+ more: 'A follow-up: where to look next, or which part to build',
95
+ go: 'Investigate',
96
+ short: 'Say what you want to understand',
97
+ sent: 'Sent to the agent: it investigates in its session',
98
+ then: { key: 'build', label: 'Build it in my project', sent: 'Asked the agent to build it from the report', title: 'Ask the agent to build your own version in this project from what the report describes: its own code, nothing copied from the target, with tests. Name the part you want in the box, or leave it empty for the plan under "Build it"' },
99
+ waiting: 'the report shows here once it knows the shape of the target',
100
+ empty: "Name a target (an app's folder, a binary, a website) and what you want to understand about it. The agent investigates in its session with REA's tools and writes a report here: how it works with animated diagrams, the evidence behind each claim, what is confirmed and what is inferred, what could not be determined, and a plan for building your own version. It changes nothing until you ask it to build.",
101
+ },
102
+ };
103
+ const drafts = new Map(); // "<agent>:<kind>" -> what's typed and not sent
104
+ const rea = new Map(); // agent id -> whether REA is registered for its folder
76
105
  /** Read the report; `want` is the change time the agent's record names, so each version is read once. */
77
- async function loadDebug(want) {
106
+ async function loadAsk(kind, want) {
78
107
  const id = st.agentId;
79
- const key = `${id}:debug`;
108
+ const key = `${id}:${kind}`;
80
109
  files.set(key, { ...files.get(key), loading: true });
81
- const r = await api('GET', `/agents/${id}/specs/debug`).catch(() => null);
110
+ const r = await api('GET', `/agents/${id}/specs/${kind}`).catch(() => null);
82
111
  files.set(key, { markdown: r?.markdown ?? null, at: r?.updatedAt ?? null, want, loaded: true });
83
- if (st.agentId === id && st.on && st.tab === 'debug') renderDebug(false);
112
+ if (st.agentId === id && st.on && st.tab === kind) renderAsk(kind, false);
113
+ }
114
+ async function loadRea() {
115
+ const id = st.agentId;
116
+ rea.set(id, { loading: true });
117
+ rea.set(id, (await api('GET', `/agents/${id}/reverse/rea`).catch(() => null)) ?? { unknown: true });
118
+ if (st.agentId === id && st.on && st.tab === 'reverse') renderAsk('reverse', true);
119
+ }
120
+
121
+ /** What Reverse engineer needs said above its box: whether REA is there, and what it is for. */
122
+ function reverseNotes(a) {
123
+ const r = rea.get(a?.id);
124
+ if (!r && a?.workdir) loadRea();
125
+ const setup = r?.registered
126
+ ? `<p class="hint reverse-rea ok">REA is registered in ${esc(r.where)}. Native binaries also need Hopper, Ghidra, IDA or Kuna; JavaScript, Electron and websites need nothing more.</p>`
127
+ : r && !r.loading && !r.unknown
128
+ ? `<p class="hint reverse-rea missing"><b>REA was not found</b> in Claude Code's settings for this agent. Set it up in a terminal with <code>${esc(r.setup)}</code>, then restart this agent's session. (If REA came with a plugin, it is not seen here and will still work.) <button type="button" class="link" data-reverse-recheck>Check again</button></p>`
129
+ : '';
130
+ return `${setup}<p class="hint reverse-note">For software you own or are allowed to analyse: a licence or the law may restrict reverse engineering someone else's product. The agent is told to analyse only, not to get around licence checks or sign-in, and to build from behaviour without copying code or assets.</p>`;
84
131
  }
85
132
 
86
- function renderDebug(force) {
133
+ function renderAsk(kind, force) {
134
+ const w = ASK[kind];
87
135
  const a = agents.get(st.agentId);
88
- const d = files.get(`${st.agentId}:debug`);
89
- const want = a?.specDocs?.debug ?? null;
90
- if ((!d || (d.loaded && d.want !== want)) && !d?.loading) loadDebug(want);
91
- const asks = a?.debug?.asks ?? [];
136
+ const d = files.get(`${st.agentId}:${kind}`);
137
+ const want = a?.specDocs?.[kind] ?? null;
138
+ if ((!d || (d.loaded && d.want !== want)) && !d?.loading) loadAsk(kind, want);
139
+ const asks = a?.[kind]?.asks ?? [];
92
140
  const working = Boolean(a?.runtime?.busy || a?.outbox);
93
141
  const has = Boolean(d?.markdown);
94
- const sig = `debug|${st.agentId}|${d?.at}|${Boolean(d?.loaded)}|${asks.length}|${working}|${Boolean(a?.workdir)}`;
142
+ const r = rea.get(st.agentId);
143
+ const sig = `${kind}|${st.agentId}|${d?.at}|${Boolean(d?.loaded)}|${asks.length}|${working}|${Boolean(a?.workdir)}|${kind === 'reverse' ? `${r?.registered}|${Boolean(r?.loading)}|${a?.reverse?.target ?? ''}` : ''}`;
95
144
  if (!force && sig === st.sig) return;
96
145
  st.sig = sig;
97
146
  // What's being typed, and where the caret is, survive the redraw.
98
- const old = body.querySelector('[data-debug-text]');
99
- if (old) drafts.set(st.agentId, old.value);
100
- const typing = old && document.activeElement === old ? [old.selectionStart, old.selectionEnd] : null;
147
+ const old = body.querySelector(`[data-${kind}-text]`);
148
+ const key = `${st.agentId}:${kind}`;
149
+ if (old) drafts.set(key, old.value);
150
+ const oldTarget = body.querySelector('[data-reverse-target]');
151
+ if (kind === 'reverse' && oldTarget) drafts.set(`${key}:target`, oldTarget.value);
152
+ const focused = [old, oldTarget].find((el) => el && document.activeElement === el);
153
+ const typing = focused ? [focused === old ? `[data-${kind}-text]` : '[data-reverse-target]', focused.selectionStart, focused.selectionEnd] : null;
101
154
  const top = body.querySelector('.side-scroll')?.scrollTop ?? 0;
102
- const draft = drafts.get(st.agentId) ?? '';
103
- const ideas = has || asks.length ? '' : `<div class="debug-ideas">${DEBUG_IDEAS.map((t) => `<button type="button" class="chip" data-debug-idea>${esc(t)}</button>`).join('')}</div>`;
155
+ const draft = drafts.get(key) ?? '';
156
+ const ideas = has || asks.length ? '' : `<div class="debug-ideas">${w.ideas.map((t) => `<button type="button" class="chip" data-ask-idea data-${kind}-idea>${esc(t)}</button>`).join('')}</div>`;
104
157
  const status = !asks.length
105
158
  ? ''
106
159
  : working
107
- ? `<p class="hint debug-status"><span class="debug-dot"></span> The agent is investigating in its session${has ? '; the report below updates as it writes' : '; the report shows here once it has the code path'}.</p>`
160
+ ? `<p class="hint debug-status"><span class="debug-dot"></span> The agent is investigating in its session${has ? '; the report below updates as it writes' : `; ${w.waiting}`}.</p>`
108
161
  : has
109
162
  ? ''
110
163
  : '<p class="hint debug-status">Asked. The report shows here when the agent has written it; its session on the left has what it is doing or asking.</p>';
111
164
  const asked = asks.length
112
- ? `<details class="debug-asked"><summary>Asked (${asks.length})</summary><ol>${asks.map((x) => `<li>${x.kind === 'fix' ? '<span class="tag">fix</span> ' : ''}${esc(x.text)}</li>`).join('')}</ol></details>`
165
+ ? `<details class="debug-asked"><summary>Asked (${asks.length})</summary><ol>${asks.map((x) => `<li>${x.kind === w.then.key ? `<span class="tag">${w.then.key}</span> ` : ''}${esc(x.text)}</li>`).join('')}</ol></details>`
113
166
  : '';
114
- const report = has
115
- ? `<div class="md debug-report">${docHtml(d.markdown)}</div>`
116
- : d?.loaded
117
- ? asks.length
118
- ? ''
119
- : `<p class="hint">Say what is going wrong: a failure, instability at scale, slowness under load. The agent investigates in its session (it reads the code and logs, reproduces and measures where it can) and writes a report here: animated diagrams of the code path and the data flow with where it breaks, what it found with evidence, the likely causes, and the fixes it recommends. It changes no code until you press <b>Apply fixes</b>.</p>`
120
- : '<p class="hint">Loading…</p>';
121
- body.innerHTML = `<div class="side-scroll debug-view">
122
- <form class="debug-ask" data-debug-form>
123
- <textarea data-debug-text rows="2" ${a?.workdir ? '' : 'disabled'} placeholder="${has ? 'A follow-up: what you know, what to look at next, or which fixes to apply' : 'What should it debug? For example: E2E tests fail at max scale after about 20 minutes'}">${esc(draft)}</textarea>
167
+ const report = has ? `<div class="md debug-report">${docHtml(d.markdown)}</div>` : d?.loaded ? (asks.length ? '' : `<p class="hint">${esc(w.empty)}</p>`) : '<p class="hint">Loading…</p>';
168
+ const target = kind === 'reverse' ? `<input data-reverse-target ${a?.workdir ? '' : 'disabled'} value="${esc(drafts.get(`${key}:target`) ?? a?.reverse?.target ?? '')}" placeholder="The target: /Applications/Notes.app, ~/Downloads/app.asar, a binary's path, or https://example.com" aria-label="The target" />` : '';
169
+ body.innerHTML = `<div class="side-scroll debug-view ${kind}-view">
170
+ <form class="debug-ask" data-ask-form="${kind}" data-${kind}-form>
171
+ ${target}
172
+ <textarea data-${kind}-text rows="2" ${a?.workdir ? '' : 'disabled'} placeholder="${esc(has ? w.more : w.first)}">${esc(draft)}</textarea>
124
173
  ${ideas}
125
174
  <div class="debug-actions">
126
175
  <span class="hint">${has && d.at ? `Report updated ${esc(new Date(d.at).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }))}` : ''}</span>
127
176
  <span class="spacer"></span>
128
- ${has ? `<button type="button" class="small" data-debug-fix title="Ask the agent to make the report's fixes, verify each and record the result. Name the ones you want in the box (for example: 1 and 3), or leave it empty for the ones it recommends">Apply fixes</button>` : ''}
129
- <button class="small primary" ${a?.workdir ? '' : 'disabled'}>${has ? 'Ask' : 'Debug'}</button>
177
+ ${has ? `<button type="button" class="small" data-${kind}-${w.then.key} title="${esc(w.then.title)}">${esc(w.then.label)}</button>` : ''}
178
+ <button class="small primary" ${a?.workdir ? '' : 'disabled'}>${has ? 'Ask' : w.go}</button>
130
179
  </div>
131
180
  </form>
181
+ ${kind === 'reverse' ? reverseNotes(a) : ''}
132
182
  ${status}${asked}${report}
133
183
  </div>`;
134
- const text = body.querySelector('[data-debug-text]');
135
184
  if (typing) {
136
- text.focus();
137
- text.setSelectionRange(...typing);
185
+ const el = body.querySelector(typing[0]);
186
+ el.focus();
187
+ el.setSelectionRange(typing[1], typing[2]);
138
188
  }
139
189
  body.querySelector('.side-scroll').scrollTop = top;
140
190
  renderDiagrams(body);
141
191
  }
192
+ const renderDebug = (force) => renderAsk('debug', force);
193
+ const renderReverse = (force) => renderAsk('reverse', force);
142
194
 
143
- async function sendDebug(payload) {
195
+ async function sendAsk(kind, payload) {
144
196
  const id = st.agentId;
197
+ const w = ASK[kind];
145
198
  try {
146
- agents.set(id, await api('POST', `/agents/${id}/debug`, payload));
147
- drafts.delete(id);
148
- const text = body.querySelector('[data-debug-text]');
199
+ agents.set(id, await api('POST', `/agents/${id}/${kind}`, payload));
200
+ drafts.delete(`${id}:${kind}`);
201
+ const text = body.querySelector(`[data-${kind}-text]`);
149
202
  if (text) text.value = '';
150
- toast(payload.fix ? 'Asked the agent to apply the fixes' : 'Sent to the agent: it investigates in its session', 3000);
203
+ toast(payload[w.then.key] ? w.then.sent : w.sent, 3000);
151
204
  } catch (err) {
152
205
  toast(`Error: ${err.message}`, 5000);
153
206
  }
154
- if (st.agentId === id && st.tab === 'debug') renderDebug(true);
207
+ if (st.agentId === id && st.tab === kind) renderAsk(kind, true);
155
208
  }
156
209
  // While the agent works, the report is read again now and then: it writes it as it goes.
157
210
  setInterval(() => {
158
211
  const a = agents.get(st.agentId);
159
- if (st.on && st.tab === 'debug' && a?.debug && (a.runtime?.busy || a.outbox) && !files.get(`${a.id}:debug`)?.loading) loadDebug(a.specDocs?.debug ?? null);
212
+ const kind = st.tab;
213
+ if (st.on && ASK[kind] && a?.[kind] && (a.runtime?.busy || a.outbox) && !files.get(`${a.id}:${kind}`)?.loading) loadAsk(kind, a.specDocs?.[kind] ?? null);
160
214
  }, 5000);
161
215
 
162
216
  // ------------------------------------------------------------ Docs
@@ -248,13 +302,15 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
248
302
  if (tab) return setTab(tab.dataset.side);
249
303
  if (e.target.closest('#side-close')) return toggle(false);
250
304
  if (e.target.closest('[data-side-reload]')) return loadChanges();
251
- const idea = e.target.closest('[data-debug-idea]');
305
+ const idea = e.target.closest('[data-ask-idea]');
252
306
  if (idea) {
253
- const text = body.querySelector('[data-debug-text]');
307
+ const text = body.querySelector(`[data-${st.tab}-text]`);
254
308
  text.value = idea.textContent;
255
309
  return text.focus();
256
310
  }
257
- if (e.target.closest('[data-debug-fix]')) return sendDebug({ fix: body.querySelector('[data-debug-text]').value.trim() || true });
311
+ if (e.target.closest('[data-debug-fix]')) return sendAsk('debug', { fix: body.querySelector('[data-debug-text]').value.trim() || true });
312
+ if (e.target.closest('[data-reverse-build]')) return sendAsk('reverse', { build: body.querySelector('[data-reverse-text]').value.trim() || true });
313
+ if (e.target.closest('[data-reverse-recheck]')) return loadRea();
258
314
  try {
259
315
  if (e.target.closest('[data-side-explain]')) {
260
316
  agents.set(st.agentId, await api('POST', `/agents/${st.agentId}/docs/walkthrough?background=1`));
@@ -270,15 +326,19 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
270
326
  }
271
327
  });
272
328
  pane.addEventListener('submit', (e) => {
273
- if (!e.target.matches('[data-debug-form]')) return;
329
+ const kind = e.target.dataset.askForm;
330
+ if (!ASK[kind]) return;
274
331
  e.preventDefault();
275
- const question = body.querySelector('[data-debug-text]').value.trim();
276
- if (question.length < 3) return toast('Say what to debug', 3000);
277
- sendDebug({ question });
332
+ const question = body.querySelector(`[data-${kind}-text]`).value.trim();
333
+ if (question.length < 3) return toast(ASK[kind].short, 3000);
334
+ if (kind === 'debug') return sendAsk('debug', { question });
335
+ const target = body.querySelector('[data-reverse-target]').value.trim();
336
+ if (!target) return toast("Name the target: an app's folder, a binary's path, or a website's address", 4000);
337
+ sendAsk('reverse', { question, target });
278
338
  });
279
339
  // Enter sends; Shift+Enter is a new line.
280
340
  pane.addEventListener('keydown', (e) => {
281
- if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.target.matches('[data-debug-text]')) {
341
+ if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.target.matches('[data-debug-text], [data-reverse-text]')) {
282
342
  e.preventDefault();
283
343
  e.target.form.requestSubmit();
284
344
  }
@@ -345,6 +405,7 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
345
405
  if (!st.on || a.id !== st.agentId) return;
346
406
  if (st.tab === 'docs') renderDocs(false);
347
407
  else if (st.tab === 'debug') renderDebug(false);
408
+ else if (st.tab === 'reverse') renderReverse(false);
348
409
  else if (st.tab === 'changes') renderChanges(false);
349
410
  },
350
411
  };
package/public/style.css CHANGED
@@ -999,6 +999,10 @@ form.dropping { outline: 2px dashed var(--accent, #6b8cff); outline-offset: 4px;
999
999
  .debug-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: debug-pulse 1.2s ease-in-out infinite; }
1000
1000
  @keyframes debug-pulse { 50% { opacity: .25; } }
1001
1001
  @media (prefers-reduced-motion: reduce) { .debug-dot { animation: none; } }
1002
+ .reverse-view input[data-reverse-target] { width: 100%; box-sizing: border-box; }
1003
+ .reverse-rea, .reverse-note { margin: 0; }
1004
+ .reverse-rea.missing { padding: 6px 10px; border-left: 3px solid var(--yellow); }
1005
+ .reverse-rea.ok { color: var(--green); }
1002
1006
  .debug-asked summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
1003
1007
  .debug-asked ol { margin: 6px 0 0; padding-left: 22px; }
1004
1008
  .side-pane { flex: none; width: var(--pane-w, 45%); display: flex; flex-direction: column; min-height: 0; border-left: 1px solid #30363d; background: var(--bg); color: var(--text); }
package/src/brief.js CHANGED
@@ -721,7 +721,9 @@ export const BENCH_FILE = 'BENCHMARK.md';
721
721
  export const benchPath = (agentId) => path.join(briefDir(agentId), BENCH_FILE);
722
722
  export const DEBUG_FILE = 'DEBUG.md';
723
723
  export const debugPath = (agentId) => path.join(briefDir(agentId), DEBUG_FILE);
724
- export const SPEC_DOCS = { intent: intentPath, spec: specPath, plan: planPath, designdoc: designPath, benchmark: benchPath, demo: demoPath, debug: debugPath };
724
+ export const REVERSE_FILE = 'REVERSE.md';
725
+ export const reversePath = (agentId) => path.join(briefDir(agentId), REVERSE_FILE);
726
+ export const SPEC_DOCS = { intent: intentPath, spec: specPath, plan: planPath, designdoc: designPath, benchmark: benchPath, demo: demoPath, debug: debugPath, reverse: reversePath };
725
727
 
726
728
  // ------------------------------------------------------------------ debug
727
729
 
@@ -788,6 +790,79 @@ export function debugFixPrompt(file, which) {
788
790
  );
789
791
  }
790
792
 
793
+ // ------------------------------------------------------------------ reverse engineering
794
+
795
+ // Reverse engineer: you name a target (an app's folder, a binary, a website) and what you want to
796
+ // understand about it; the agent investigates in its own session with REA's tools (the "Reverse
797
+ // Engineer Anything" MCP server, github.com/morluto/rea) and keeps a report at REVERSE.md: how the
798
+ // feature works with animated diagrams, the evidence behind each claim, what could not be
799
+ // determined, and a plan for building your own version. It changes nothing until you ask it to build.
800
+
801
+ const REVERSE_SHAPE = [
802
+ '# Reverse engineering: <the feature> in <the target>',
803
+ '## Summary',
804
+ 'Two or three sentences: how it works, and how sure you are.',
805
+ '## Target',
806
+ 'What it is (name, version, platform), what kind (Electron or JavaScript app, native binary, .NET assembly, website), and which tools and providers you used on it.',
807
+ '## How it works',
808
+ 'One ```mermaid flowchart of the path the feature takes through the real modules, functions or components you found, from what the user does to the result.',
809
+ '## Data and interfaces',
810
+ 'One ```mermaid flowchart LR or sequenceDiagram of the data on that path: what is stored and where, formats, the calls between processes, and the network requests. Then a short list of the formats and endpoints by name.',
811
+ '## Findings',
812
+ 'Numbered. Each with its evidence (a module or file path, a function or symbol, an address, a string, a request) and "confirmed" (seen directly) or "inferred" (reasoned from what was seen).',
813
+ '## What could not be determined',
814
+ 'What is obfuscated, missing, server-side or out of reach of the tools you had, and what would be needed to find out.',
815
+ '## Build it',
816
+ 'A plan for our own version in this project, from the behaviour described above: the pieces, where they go in this codebase, the order, effort (S, M, L) for each, and what to do differently or better. No code, text or assets taken from the target.',
817
+ '## Next checks',
818
+ 'What to look at next, and what you need from the user (another build of the app, a sample file, an account).',
819
+ ].join('\n');
820
+
821
+ const REVERSE_DIAGRAMS =
822
+ 'Diagrams: valid Mermaid, at most about 15 nodes each, labels of five words or fewer (quote labels with punctuation, e.g. A["Parse (JSON)"]), no HTML in labels, real names from the target. ' +
823
+ 'Animate the path in every flowchart: give its edges ids and animate them, e.g.\n' +
824
+ ' A e1@--> B\n B e2@-->|"rows"| C\n e1@{ animate: true }\n e2@{ animate: true }\n' +
825
+ 'Mark what is only inferred: `classDef inferred stroke:#f59e0b,stroke-width:3px,stroke-dasharray:4`, then `class Y inferred`; and what could not be seen: `classDef unknown stroke:#9ca3af,stroke-dasharray:2`, then `class Z unknown`.';
826
+
827
+ const REVERSE_RULES =
828
+ 'Rules: this is for understanding how something works so we can build our own. Analyse only: do not modify, patch or redistribute the target, and do not change this repository yet. ' +
829
+ 'Do not work on getting around licence checks, copy protection, sign-in or other access controls, and do not collect credentials, keys or personal data you come across: if that is what is asked, or the only way forward, stop and tell me. ' +
830
+ 'Say what you saw, not what you assume: every claim in the report names its evidence.';
831
+
832
+ /** The message that starts (or continues) a reverse-engineering investigation in the agent's session. */
833
+ export function reversePrompt(file, { target = '', question = '', again = false } = {}) {
834
+ const q = String(question ?? '').trim();
835
+ const t = String(target ?? '').trim();
836
+ if (again) {
837
+ return (
838
+ `Reverse engineering, continued: ${q}${t ? `\nTarget: ${t}` : ''}\n` +
839
+ `Carry on and bring the report at ${file} up to date: same sections, diagrams redrawn where the picture changed, findings re-marked confirmed or inferred. ` +
840
+ 'Still analysis only, and no changes to this repository unless I ask you to build. Answer me here in a few lines, and say what changed in the report.'
841
+ );
842
+ }
843
+ return (
844
+ `Reverse engineer this: ${q}\nTarget: ${t}\n` +
845
+ "Use REA's tools (the \"Reverse Engineer Anything\" MCP server) to inspect the target: start with what kind of target it is, then follow the feature from what the user does down to the code and data behind it. " +
846
+ "If REA's tools are not available in this session, say so in one line and stop: it is set up with `npx rea-agents setup` (which I run myself, then restart this session); do not install it or anything else yourself. " +
847
+ 'For a native binary REA needs a provider (Hopper, Ghidra, IDA or Kuna): if none is configured, say which is missing rather than guessing from strings alone.\n' +
848
+ `${REVERSE_RULES}\n` +
849
+ `Keep a report at ${file} (Markdown; the file is outside the repository: never copy it in or commit it). Write a first version as soon as you know the shape of the target, and update it as you learn. Short and specific, in these sections:\n` +
850
+ `${REVERSE_SHAPE}\n${REVERSE_DIAGRAMS}\n` +
851
+ 'When the report is written, tell me in a few lines how it works and what you could not determine.'
852
+ );
853
+ }
854
+
855
+ /** The message that asks for our own version to be built from the report. */
856
+ export function reverseBuildPrompt(file, what) {
857
+ const w = String(what ?? '').trim();
858
+ return (
859
+ `Build our own version from your reverse-engineering report at ${file}: ${w || 'the plan under "Build it", the smallest useful piece first'}.\n` +
860
+ 'Write it from the behaviour the report describes, in this project\'s own style: copy no code, text, names of internal symbols or assets from the target, and add no dependency on it. ' +
861
+ 'Add tests for the behaviour, run them, and where the report says the target does something badly, do it better. ' +
862
+ 'Then update the report: add a "## Built" section (what was built, where, how it was verified, and what differs from the target on purpose).'
863
+ );
864
+ }
865
+
791
866
  /** INTENT.md: the request as given, and where it came from. */
792
867
  export function intentMarkdown(agent) {
793
868
  const by = agent.startedBy ? 'the assistant' : agent.trigger ? (agent.trigger.source === 'github' ? 'a labeled GitHub issue' : 'a webhook') : agent.playbook ? `the playbook ${agent.playbook.name}` : agent.team ? `team ${agent.team.id} (${agent.team.role})` : agent.raceId ? `race ${agent.raceId}` : 'you';
package/src/cli.js CHANGED
@@ -1698,6 +1698,33 @@ export async function main(argv) {
1698
1698
  console.log(dim(`\n(updated ${new Date(r.updatedAt).toLocaleString()})`));
1699
1699
  });
1700
1700
 
1701
+ program
1702
+ .command('reverse')
1703
+ .description("Reverse engineer with an agent and REA's tools: name a target and what to understand; it keeps a report with diagrams, the evidence, what could not be determined and a plan to build your own. With no question: print the report")
1704
+ .argument('<agent>')
1705
+ .argument('[question...]', 'what to understand, or a follow-up once there is a report')
1706
+ .option('-t, --target <target>', "the app's folder, the binary's path or the website's address (needed the first time)")
1707
+ .option('--build [what]', 'build your own version from the report: which part in words, or its plan')
1708
+ .action(async (ref, question, opts) => {
1709
+ await daemon();
1710
+ const a = await resolveAgent(ref);
1711
+ const q = question.join(' ').trim();
1712
+ if (opts.build) {
1713
+ await api('POST', `/agents/${a.id}/reverse`, { build: opts.build === true ? q || true : opts.build });
1714
+ return console.log(`${green('✓')} asked ${a.name} to build it from the report, in this project's own code`);
1715
+ }
1716
+ if (q) {
1717
+ const rea = await api('GET', `/agents/${a.id}/reverse/rea`);
1718
+ if (!rea.registered) console.log(yellow(`REA was not found in Claude Code's settings for this agent. If it isn't set up: ${rea.setup} (then restart the agent's session).`));
1719
+ await api('POST', `/agents/${a.id}/reverse`, { question: q, target: opts.target });
1720
+ return console.log(`${green('✓')} sent to ${a.name}; it investigates in its session. The report: agentmgr reverse ${ref}`);
1721
+ }
1722
+ const r = await api('GET', `/agents/${a.id}/specs/reverse`);
1723
+ if (!r.markdown) return console.log(dim(`No report yet. Start one: agentmgr reverse ${ref} -t /path/to/app "how does search work"`));
1724
+ console.log(r.markdown.trimEnd());
1725
+ console.log(dim(`\n(updated ${new Date(r.updatedAt).toLocaleString()})`));
1726
+ });
1727
+
1701
1728
  program
1702
1729
  .command('fork')
1703
1730
  .description("A new agent with this one's code and conversation, in its own worktree")
package/src/manager.js CHANGED
@@ -35,6 +35,9 @@ import {
35
35
  debugPath,
36
36
  debugPrompt,
37
37
  debugFixPrompt,
38
+ reversePath,
39
+ reversePrompt,
40
+ reverseBuildPrompt,
38
41
  specDocsInfo,
39
42
  specPath,
40
43
  specPrompt,
@@ -833,7 +836,7 @@ export class AgentManager extends EventEmitter {
833
836
  /** One of an agent's intent, spec and plan files. */
834
837
  specDoc(ref, name) {
835
838
  const agent = this.mustGet(ref);
836
- if (!['intent', 'spec', 'plan', 'designdoc', 'benchmark', 'debug'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec, plan, designdoc, benchmark or debug)'), { status: 400 });
839
+ if (!['intent', 'spec', 'plan', 'designdoc', 'benchmark', 'debug', 'reverse'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec, plan, designdoc, benchmark, debug or reverse)'), { status: 400 });
837
840
  return readSpecDoc(agent.id, name) ?? { name, markdown: null };
838
841
  }
839
842
 
@@ -859,6 +862,31 @@ export class AgentManager extends EventEmitter {
859
862
  return this.view(this.patch(agent.id, { debug: { asks, startedAt: agent.debug?.startedAt ?? now() } }));
860
863
  }
861
864
 
865
+ /**
866
+ * Reverse engineer: ask the agent to work out how something in a target (an app's folder, a
867
+ * binary, a website) works, with REA's tools, and keep a report (REVERSE.md) with diagrams, the
868
+ * evidence, what could not be determined and a plan to build our own. `question`: what to
869
+ * understand, or a follow-up once there is a report. `build`: build our own version from the
870
+ * report (which part, in words; true for its plan). The message waits in the agent's queue.
871
+ */
872
+ reverse(ref, { target = '', question = '', build = null } = {}) {
873
+ const agent = this.mustGet(ref);
874
+ if (!agent.workdir || agent.status === 'preparing') throw Object.assign(new Error('The agent has no folder to work in yet'), { status: 409 });
875
+ const q = String(question ?? '').replace(/\s+/g, ' ').trim().slice(0, 2000);
876
+ const has = Boolean(readSpecDoc(agent.id, 'reverse')?.markdown?.trim());
877
+ // The target as given the first time stands for the follow-ups.
878
+ const t = String(target ?? '').replace(/\s+/g, ' ').trim().slice(0, 500) || agent.reverse?.target || '';
879
+ if (build && !has) throw Object.assign(new Error('There is no report yet: say what to reverse engineer first'), { status: 409 });
880
+ if (!build && q.length < 3) throw Object.assign(new Error('Say what you want to understand'), { status: 400 });
881
+ if (!build && !t) throw Object.assign(new Error("Name the target: an app's folder, a binary's path, or a website's address"), { status: 400 });
882
+ fs.mkdirSync(briefDir(agent.id), { recursive: true });
883
+ const file = path.join(fs.realpathSync(briefDir(agent.id)), path.basename(reversePath(agent.id)));
884
+ const which = build === true ? '' : String(build ?? '').replace(/\s+/g, ' ').trim().slice(0, 500);
885
+ this.tell(agent.id, build ? reverseBuildPrompt(file, which) : reversePrompt(file, { target: t, question: q, again: has }), { source: 'reverse' });
886
+ const asks = [...(agent.reverse?.asks ?? []), { text: build ? `Build it${which ? `: ${which}` : ''}` : q, kind: build ? 'build' : has ? 'follow-up' : 'reverse', at: now() }].slice(-20);
887
+ return this.view(this.patch(agent.id, { reverse: { ...agent.reverse, target: t, asks, startedAt: agent.reverse?.startedAt ?? now() } }));
888
+ }
889
+
862
890
  /** The agent's sample demo page (HTML), once it has written one. */
863
891
  demoPage(ref) {
864
892
  const agent = this.mustGet(ref);
@@ -2357,6 +2385,14 @@ export class AgentManager extends EventEmitter {
2357
2385
  } catch {}
2358
2386
  if (at !== (agent.debug.reportAt ?? null)) this.patch(id, { debug: { ...this.store.get(id).debug, reportAt: at } });
2359
2387
  }
2388
+ // The same for a reverse-engineering report.
2389
+ if (agent.reverse) {
2390
+ let at = null;
2391
+ try {
2392
+ at = fs.statSync(reversePath(id)).mtime.toISOString();
2393
+ } catch {}
2394
+ if (at !== (agent.reverse.reportAt ?? null)) this.patch(id, { reverse: { ...this.store.get(id).reverse, reportAt: at } });
2395
+ }
2360
2396
  }
2361
2397
 
2362
2398
  // -------------------------------------------------------------- plan review
package/src/rea.js ADDED
@@ -0,0 +1,47 @@
1
+ // Whether REA (the "Reverse Engineer Anything" MCP server, github.com/morluto/rea) is registered
2
+ // with Claude Code, read from Claude Code's own files: your settings (~/.claude.json, for every
3
+ // folder and for one), and a project's .mcp.json. Nothing is run and nothing is installed here:
4
+ // setup is `npx rea-agents setup`, which you run yourself. A plugin that brings REA is not seen
5
+ // here, so "not found" is said as that, not as "not installed".
6
+
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+ import { claudeConfigFile } from './trust.js';
10
+
11
+ export const REA_SETUP = 'npx rea-agents setup';
12
+ const read = (file) => {
13
+ try {
14
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
15
+ } catch {
16
+ return null;
17
+ }
18
+ };
19
+
20
+ /** A registered MCP server that is REA: by its name, or by the package it runs. */
21
+ export function isRea(name, server) {
22
+ if (/^rea([-_]agents)?$/i.test(String(name))) return true;
23
+ const words = [server?.command, ...(Array.isArray(server?.args) ? server.args : [])].filter((x) => typeof x === 'string').join(' ');
24
+ return /(^|[\s/\\@])rea-agents(\b|@)/.test(words);
25
+ }
26
+
27
+ /** { registered, where, name } for a folder (an agent's workspace): where REA is registered, if it is. */
28
+ export function reaStatus(dir = null, { config = claudeConfigFile() } = {}) {
29
+ const c = read(config) ?? {};
30
+ const real = (() => {
31
+ try {
32
+ return dir ? fs.realpathSync(dir) : null;
33
+ } catch {
34
+ return dir;
35
+ }
36
+ })();
37
+ const places = [
38
+ ['your Claude Code settings', c.mcpServers],
39
+ ...(real ? [['this folder, in your Claude Code settings', c.projects?.[real]?.mcpServers ?? c.projects?.[dir]?.mcpServers], ["the project's .mcp.json", read(path.join(real, '.mcp.json'))?.mcpServers]] : []),
40
+ ];
41
+ for (const [where, servers] of places) {
42
+ for (const [name, server] of Object.entries(servers && typeof servers === 'object' ? servers : {})) {
43
+ if (isRea(name, server)) return { registered: true, where, name, setup: REA_SETUP };
44
+ }
45
+ }
46
+ return { registered: false, where: null, name: null, setup: REA_SETUP };
47
+ }
package/src/server.js CHANGED
@@ -53,6 +53,7 @@ import { News } from './news.js';
53
53
  import { System } from './system.js';
54
54
  import { Advisor } from './advisor.js';
55
55
  import { Runbooks } from './runbooks.js';
56
+ import { reaStatus } from './rea.js';
56
57
  import { Milestones } from './milestones.js';
57
58
  import { Decisions } from './decisions.js';
58
59
  import { Debt } from './debt.js';
@@ -743,6 +744,10 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
743
744
  api.post('/rules/dismiss', wrap((req) => (manager.rules.dismiss(...ruleArgs(req)), manager.rules.view())));
744
745
  api.post('/rules/remove', wrap((req) => (manager.rules.remove(...ruleArgs(req)), manager.rules.view())));
745
746
  api.post('/agents/:id/tell', wrap((req) => manager.tell(req.params.id, req.body?.text)));
747
+ // Reverse engineer: a target and what to understand (or a follow-up), or `build` to build our own from the report; the report is /specs/reverse.
748
+ api.post('/agents/:id/reverse', wrap((req) => manager.reverse(req.params.id, { target: req.body?.target, question: req.body?.question, build: req.body?.build ?? null })));
749
+ // Whether REA is registered with Claude Code for this agent's folder (read from Claude Code's files; nothing is run).
750
+ api.get('/agents/:id/reverse/rea', wrap((req) => reaStatus(manager.mustGet(req.params.id).workdir ?? null)));
746
751
  // Debug: what to debug (or a follow-up), or `fix` to apply the report's fixes; the report is /specs/debug.
747
752
  api.post('/agents/:id/debug', wrap((req) => manager.debug(req.params.id, { question: req.body?.question, fix: req.body?.fix ?? null })));
748
753
  api.post('/agents/:id/answer', wrap((req) => manager.answerQuestion(req.params.id, req.body?.question, req.body?.text)));