ai-agentmanager 1.40.0 → 1.42.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 +11 -0
- package/README.md +20 -3
- package/docs/plugins.md +2 -1
- package/package.json +1 -1
- package/public/app.js +26 -3
- package/public/index.html +12 -0
- package/public/mcp.js +185 -0
- package/public/side.js +2 -0
- package/public/style.css +17 -0
- package/src/brief.js +47 -2
- package/src/cli.js +41 -4
- package/src/drive.js +2 -0
- package/src/manager.js +13 -4
- package/src/mcp.js +208 -0
- package/src/server.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.42.0 (2026-11-11)
|
|
4
|
+
|
|
5
|
+
- **MCP servers and tools.** **MCP** in the top bar (or **MCP tools** in an agent's detail, or `agentmgr mcp [agent]`) lists the MCP servers Claude Code has in your home folder or an agent's workspace: your own, the project's `.mcp.json`, claude.ai connectors and plugins' servers. Each shows its status, where it comes from and its tools. Listing makes no model call, and secrets are never shown.
|
|
6
|
+
- **Run a tool.** **Run in session** tells the agent to use it, with its conversation and context. **Run once in workspace** (or `agentmgr mcp run`) is a separate one-off call that may use only that tool and shows what it returned, without interrupting the agent. Destructive tools need a second click, and plugins can refuse one-off runs with the `mcp.run` policy.
|
|
7
|
+
|
|
8
|
+
## 1.41.0 (2026-11-11)
|
|
9
|
+
|
|
10
|
+
- **Estimate.** A human time estimate for planning any Jira fix or feature: how long one experienced developer would take to do it by hand, without an AI agent. It's split into tasks of a day or less, each with optimistic, likely, pessimistic and expected hours and a total. Work over about 3 days gets a suggested split into tickets, and it lists the roles, assumptions and risks.
|
|
11
|
+
- **Documentation.** The docs for the change, written from the actual diff: what's new, how to use it, configuration, upgrade notes and which docs to add or update. When the change touches an HTTP API, it includes an OpenAPI 3.0 spec of the changed endpoints; **Download OpenAPI** saves it as a .yaml file.
|
|
12
|
+
- Both sit with the other documents (Analysis, Design and the rest), and are included in **Write all**, `agentmgr doc`, Google Drive publishing and the side pane.
|
|
13
|
+
|
|
3
14
|
## 1.40.0 (2026-11-11)
|
|
4
15
|
|
|
5
16
|
- **A calmer agent list.** No summary line under each name (it's the name's tooltip, and search still finds it); the engine, container, assistant and playbook tags move to the line below. The project name shows where the branch was (the branch is in its tooltip).
|
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@ Run one background [Claude Code](https://claude.com/claude-code) agent per inten
|
|
|
26
26
|
- **Backlog.** Queue asks as work orders. Agents pick them up one by one, up to N in parallel per project, until each is done. You accept or reopen each one.
|
|
27
27
|
- **Slack alerts.** A message in your channel when an agent needs input, finishes a backlog item, or fails.
|
|
28
28
|
- **Priority.** Mark agents P0–P3. P0 and P1 are highlighted, and lists sort by priority.
|
|
29
|
-
- **Share for review.** One click writes an **Analysis**, **Design**, **Flow** or **Proposal** document from the agent's work. Copy it as Markdown, download it, or print it to PDF with diagrams.
|
|
29
|
+
- **Share for review.** One click writes an **Analysis**, **Design**, **Flow** or **Proposal** document from the agent's work, a human time **Estimate** for planning, or the change's **Documentation** with an OpenAPI spec of any API changes. Copy it as Markdown, download it, or print it to PDF with diagrams.
|
|
30
|
+
- **MCP servers and tools.** See every MCP server Claude Code has in a folder (yours, the project's, claude.ai connectors and plugins) with its tools, and run any tool in an agent's session or once in its workspace.
|
|
30
31
|
- **Human vs AI.** It splits the open questions about the work into the top 5 that need your judgment and the ones a model can answer from the evidence. It answers those, then a second model double-checks every answer.
|
|
31
32
|
- **Review changes.** Each agent's diff file by file, line comments sent back to the agent as one message, then **Commit all** and **Push & open PR**, without leaving the page.
|
|
32
33
|
- **Standup.** Each weekday at 9:00 (or whenever you press **Standup**, or `p`), each agent with news since the last one is read aloud in a sentence or two, each in its own voice: what it did, what it's on, what it needs from you. Agents that need you go first and quiet ones are left out. It stops on an agent that needs you, with its questions beside it to answer by tap, or by voice when **Answer by voice** is on (what you say is read back, then sent when you say "send"). The wording comes from one short tool-less model call, plain wording if that fails. A Slack alert says when it's ready (Alerts). Change the time, weekends and wording in the player, or in config.json: `"standup": { "at": "09:00", "weekends": false, "ai": true, "notify": true }`. Speech is your browser's own; voice answers may be sent to your browser's maker to be turned into text.
|
|
@@ -173,8 +174,8 @@ agentmgr attach <agent> # live terminal here; Ctrl-] detac
|
|
|
173
174
|
agentmgr shell <agent> [-n 2] # a shell in the agent's folder (-n picks another one); Ctrl-] detaches
|
|
174
175
|
agentmgr brief <agent> # print the agent's brief (Markdown)
|
|
175
176
|
agentmgr priority <agent> P0 # P0 urgent, P1 high, P2 normal (default), P3 low
|
|
176
|
-
agentmgr doc <agent> proposal -o p.md # analysis | design | flow | proposal
|
|
177
|
-
agentmgr doc <agent> all --background # write all
|
|
177
|
+
agentmgr doc <agent> proposal -o p.md # analysis | design | flow | proposal | estimate | documentation
|
|
178
|
+
agentmgr doc <agent> all --background # write them all (and Human vs AI) in the background
|
|
178
179
|
agentmgr insights <agent> # Why / What / How / Now, three points each
|
|
179
180
|
agentmgr explain <agent> # full briefing: ask, status, plan, solution, conclusions, needs
|
|
180
181
|
agentmgr remote on | off | status | rotate # phone / remote access (see below)
|
|
@@ -340,6 +341,8 @@ The Brief panel's **Share for review** buttons, or `agentmgr doc <agent> <kind>`
|
|
|
340
341
|
| **Flow** | Summary, end-to-end flowchart with a step-by-step walk-through, key interactions as a sequence diagram, failure and edge cases |
|
|
341
342
|
| **Proposal** | Summary, problem, recommendation, scope, plan, effort and dependencies, risks, decisions needed |
|
|
342
343
|
| **Human vs AI** | Your top 5 decisions, each with why it needs you, the stakes, options and what the work suggests, plus a box for your answer. Up to 5 questions the AI answers, each with its confidence, evidence and how to check it. A second model's verdict on each. |
|
|
344
|
+
| **Estimate** | Human time estimate for planning: summary with a range and confidence, a task breakdown with optimistic, likely, pessimistic and expected hours, a suggested split into tickets, roles and skills, assumptions, risks and unknowns |
|
|
345
|
+
| **Documentation** | Summary, what's new or changed, how to use it, configuration, upgrade and operations notes, docs to add or update, and API changes with an OpenAPI 3.0 spec of the changed endpoints |
|
|
343
346
|
| **Diagrams** | Diagrams only, for a quick grasp: the problem, the architecture (with what changes highlighted), the design, the data flow (animated) and the key interaction, plus the plan. Drawn from the documents already written and the agent's work. Optional: **Write all** leaves it out. |
|
|
344
347
|
|
|
345
348
|
Each drawn diagram has **Copy image** (paste it into Slack, a PR comment or a doc), **PNG** and **SVG**, and a document with diagrams also downloads as one **.html** file. **🔊 Listen** reads Explain, documents and the change walkthrough aloud with the browser's own voices; the walkthrough is read change by change, showing each as it goes.
|
|
@@ -352,6 +355,10 @@ The second model is another installed engine by default (Codex or Antigravity fo
|
|
|
352
355
|
|
|
353
356
|
Type your answers in the viewer, or tap an option to fill one in. **Send my answers to the agent** passes them on, together with any AI conclusions the second model doubted, so the agent re-checks those.
|
|
354
357
|
|
|
358
|
+
**Estimate.** A human time estimate for planning: how long one experienced developer who knows the codebase would take to do the ticket by hand, without an AI agent. It's split into tasks of a day or less (understanding, design, each part of the implementation, tests, docs, review, QA, release), each with optimistic, likely and pessimistic hours and the expected (PERT) figure, and a total. Larger work also gets a suggested split into tickets that can ship on their own, with their dependencies. Then come the roles needed, the assumptions, and the risks that could move the number. It's sized from the ticket, the brief and the changes so far.
|
|
359
|
+
|
|
360
|
+
**Documentation.** The docs for the change: what's new, how to use it, configuration, upgrade and operations notes, and which docs in the repository to add or update. It's written from the actual diff. When the change touches an HTTP API, it adds a table of the changed endpoints and an OpenAPI 3.0 spec covering only those endpoints. **Download OpenAPI** saves the spec as a .yaml file for Swagger, Postman or your API portal.
|
|
361
|
+
|
|
355
362
|
**How they're written.** Documents name the real files, tickets and docs, separate facts from proposals, and say "To be confirmed" where the context doesn't. They're written for reviewers: no mention of the agent or its tools.
|
|
356
363
|
|
|
357
364
|
**Sharing.** Each document opens in a viewer:
|
|
@@ -1121,6 +1128,16 @@ Usage comes from the session transcripts and is refreshed every few seconds whil
|
|
|
1121
1128
|
- If a tab stays blank on a device, open it once with **↗** and accept the certificate there.
|
|
1122
1129
|
- **Ask Agent** (or `agentmgr ask`, with `--engine` for another engine) creates a `general` agent. All general sessions share `~/.agentmanager/general`, so Claude's folder-trust prompt only appears the first time.
|
|
1123
1130
|
|
|
1131
|
+
## MCP servers and tools
|
|
1132
|
+
|
|
1133
|
+
**MCP** in the top bar (or **MCP tools** in an agent's detail, or `agentmgr mcp [agent]`) lists the MCP servers Claude Code has in a folder: your own servers, the project's `.mcp.json`, local ones, claude.ai connectors and plugins' servers. Each shows its status, where it comes from, where it runs and its tools, marked *read-only* or *destructive* when the server says so. Pick the home folder or any agent's workspace at the top, since a workspace adds its project's servers. The app asks Claude Code itself through its control protocol, which connects to each server but makes no model call. The list is kept for 5 minutes, and **Refresh** asks again. Environment variables, headers, URL queries and secret-looking arguments are never shown.
|
|
1134
|
+
|
|
1135
|
+
**Run…** on a tool takes an optional request in plain words, then runs it in one of two ways:
|
|
1136
|
+
- **Run in session** tells the agent to use the tool, with its conversation and context. The answer is in the session. This works for Claude Code agents.
|
|
1137
|
+
- **Run once in workspace** (or `agentmgr mcp run <agent|home> <server> <tool> [request]`) is a separate one-off Claude Code call in that folder. It may use only that one tool, works out the arguments from your request, and shows what the tool returned. The agent isn't interrupted.
|
|
1138
|
+
|
|
1139
|
+
A destructive tool needs a second click. Plugins can refuse one-off runs with the `mcp.run` policy.
|
|
1140
|
+
|
|
1124
1141
|
## Configuration
|
|
1125
1142
|
|
|
1126
1143
|
State lives in `~/.agentmanager/` (`state.json`, `daemon.log`, `repos/` for shared clones, `workspaces/` for worktrees). Set `AGENTMGR_HOME` or `AGENTMGR_PORT` to change the location or port. Optional `~/.agentmanager/config.json`:
|
package/docs/plugins.md
CHANGED
|
@@ -53,6 +53,7 @@ Policies are synchronous so every code path can call them. Keep them fast; do sl
|
|
|
53
53
|
| `agent.start` | Before an agent's engine is launched or resumed (including after a restart) | `agent`, `fresh` |
|
|
54
54
|
| `agent.message` | Before a message is typed into an agent (`tell`, inbox replies) | `agent`, `text`, `source` |
|
|
55
55
|
| `agent.remove` | Before an agent is deleted | `agent`, `deleteWorkspace` |
|
|
56
|
+
| `mcp.run` | Before an MCP tool runs once in a folder (the MCP panel's **Run once**, `agentmgr mcp run`); running it in a session goes through `agent.message` | `agent` (or null for the home folder), `dir`, `tool`, `input` |
|
|
56
57
|
| `agent.commit` | Before Commit in the review screen commits an agent's worktree | `agent`, `message` |
|
|
57
58
|
| `agent.pr` | Before the review screen pushes an agent's branch and opens a pull request | `agent`, `title`, `draft` |
|
|
58
59
|
| `agent.merge` | Before Merge (or auto-merge) in the Land tab merges an agent's pull request | `agent`, `url`, `method`, `auto` |
|
|
@@ -64,7 +65,7 @@ Policies are synchronous so every code path can call them. Keep them fast; do sl
|
|
|
64
65
|
|
|
65
66
|
## Daemon events (listeners)
|
|
66
67
|
|
|
67
|
-
`agent.created`, `agent.starting`, `agent.stopping`, `agent.message`, `agent.removed`, `agent.commit` (with `sha`), `agent.pr` (with `url`), `agent.merge`, `hub.action`, each with the same `agent` summary and an `at` timestamp.
|
|
68
|
+
`agent.created`, `agent.starting`, `agent.stopping`, `agent.message`, `agent.removed`, `agent.commit` (with `sha`), `agent.pr` (with `url`), `agent.merge`, `hub.action`, `mcp.run`, each with the same `agent` summary and an `at` timestamp.
|
|
68
69
|
|
|
69
70
|
## Engines
|
|
70
71
|
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -38,6 +38,7 @@ import { initReviews } from '/reviews.js';
|
|
|
38
38
|
import { initBugHunt } from '/bughunt.js';
|
|
39
39
|
import { drawDiagram } from '/diagram.js';
|
|
40
40
|
import { initValue } from '/value.js';
|
|
41
|
+
import { initMcp } from '/mcp.js';
|
|
41
42
|
import { initCodeMap } from '/codemap.js';
|
|
42
43
|
import { initKeys } from '/keys.js';
|
|
43
44
|
import { morph } from '/morph.js';
|
|
@@ -296,6 +297,9 @@ $('#bugs-btn').onclick = () => bugsUi.open();
|
|
|
296
297
|
// Value: what the delivered work is worth, for you and for management.
|
|
297
298
|
const valueUi = initValue({ api, $, esc, toast: (m, ms) => toast(m, ms), openAgent: (id) => (showTab('agents'), select(id)) });
|
|
298
299
|
$('#value-btn').onclick = () => valueUi.open();
|
|
300
|
+
// MCP: the MCP servers and tools Claude Code has in a folder, and running one.
|
|
301
|
+
const mcpUi = initMcp({ api, $, esc, ago, md: (t) => md(t), toast: (m, ms) => toast(m, ms), agents: () => [...agents.values()] });
|
|
302
|
+
$('#mcp-btn').onclick = () => mcpUi.open(selectedId && agents.get(selectedId)?.workdir ? selectedId : null);
|
|
299
303
|
// Keyboard shortcuts (keys.js): the same actions as the buttons.
|
|
300
304
|
const keysUi = initKeys({ $, esc, run: (act) => shortcut(act) });
|
|
301
305
|
$('#keys-btn').onclick = () => keysUi.help();
|
|
@@ -501,10 +505,17 @@ const INSIGHT_ICONS = { why: '🎯', what: '📦', how: '🛠', now: '📍' };
|
|
|
501
505
|
|
|
502
506
|
// ------------------------------------------------------------------ stakeholder documents
|
|
503
507
|
|
|
504
|
-
const DOCS = { analysis: 'Analysis', design: 'Design', flow: 'Flow', proposal: 'Proposal', humanai: 'Human vs AI', diagrams: 'Diagrams', scorecard: 'Scorecard' };
|
|
508
|
+
const DOCS = { analysis: 'Analysis', design: 'Design', flow: 'Flow', proposal: 'Proposal', humanai: 'Human vs AI', estimate: 'Estimate', documentation: 'Documentation', diagrams: 'Diagrams', scorecard: 'Scorecard' };
|
|
509
|
+
// What a document is before it's written, where "Write a … document for stakeholders" doesn't say it.
|
|
510
|
+
const DOC_HINTS = {
|
|
511
|
+
estimate: 'For planning: how long a person would take to do this work by hand, split into tasks with optimistic, likely and pessimistic hours, a suggested split into tickets, the roles needed and the risks',
|
|
512
|
+
documentation: 'The documentation for this change: what is new, how to use it, configuration, upgrade notes, which docs to add or update, and an OpenAPI spec of any API changes',
|
|
513
|
+
};
|
|
514
|
+
/** The OpenAPI spec in a Documentation document (its ```yaml block), if the change has API changes. */
|
|
515
|
+
const openApiOf = (markdown) => (markdown ?? '').match(/```ya?ml\s*\n((?:#.*\n|\s*\n)*openapi:[\s\S]*?)```/)?.[1] ?? null;
|
|
505
516
|
// Optional extras that "Write all" leaves out.
|
|
506
517
|
const DOC_EXTRAS = new Set(['diagrams', 'scorecard']);
|
|
507
|
-
const DOC_TITLES = { ...DOCS, eval: 'Eval', plan: 'Plan', intent: 'Intent', spec: 'Spec', designdoc: 'Design doc', benchmark: 'Benchmark' };
|
|
518
|
+
const DOC_TITLES = { ...DOCS, estimate: 'Human time estimate', eval: 'Eval', plan: 'Plan', intent: 'Intent', spec: 'Spec', designdoc: 'Design doc', benchmark: 'Benchmark' };
|
|
508
519
|
// The agent's intent, spec and plan files (read from the daemon when opened; kept here by agent and kind).
|
|
509
520
|
const SPEC_KINDS = { intent: 'Intent', spec: 'Spec', plan: 'Plan', designdoc: 'Design doc', benchmark: 'Benchmark' };
|
|
510
521
|
// What each optional file is, for its button before it's written.
|
|
@@ -589,7 +600,7 @@ function docButtons(a) {
|
|
|
589
600
|
const d = a.docs?.[k];
|
|
590
601
|
const stale = d?.markdown && a.brief?.updatedAt && d.briefUpdatedAt !== a.brief.updatedAt;
|
|
591
602
|
return `<button class="small doc-btn ${d?.markdown ? 'has' : ''}" data-doc="${k}" ${d?.pending ? 'disabled' : ''}
|
|
592
|
-
title="${k === 'scorecard' ? (d?.markdown ? `Open the review scorecard: ${d.data?.overall ?? '—'}/100` : 'Score the changes for review: intent, spec, scope, plan, tests and safety, with an overall readiness and where to look') : k === 'diagrams' ? (d?.markdown ? `Open the diagrams${stale ? ' (the brief changed since)' : ''}` : 'Draw the problem and its solution for a quick grasp: architecture, design, data flow (animated) and the key interaction, diagrams only. Built from the documents already written and the agent\'s work') : d?.markdown ? `Open the ${label.toLowerCase()} document${stale ? ' (the brief changed since)' : ''}` : `Write a ${label.toLowerCase()} document for stakeholders`}">${d?.pending ? `${label}…` : label}${d?.markdown ? (stale ? ' •' : ' ✓') : ''}</button>`;
|
|
603
|
+
title="${k === 'scorecard' ? (d?.markdown ? `Open the review scorecard: ${d.data?.overall ?? '—'}/100` : 'Score the changes for review: intent, spec, scope, plan, tests and safety, with an overall readiness and where to look') : k === 'diagrams' ? (d?.markdown ? `Open the diagrams${stale ? ' (the brief changed since)' : ''}` : 'Draw the problem and its solution for a quick grasp: architecture, design, data flow (animated) and the key interaction, diagrams only. Built from the documents already written and the agent\'s work') : d?.markdown ? `Open the ${label.toLowerCase()} document${stale ? ' (the brief changed since)' : ''}` : DOC_HINTS[k] ?? `Write a ${label.toLowerCase()} document for stakeholders`}">${d?.pending ? `${label}…` : label}${d?.markdown ? (stale ? ' •' : ' ✓') : ''}</button>`;
|
|
593
604
|
})
|
|
594
605
|
.join('')}</span>${specButtons(a)}${driveButton(a)}`;
|
|
595
606
|
}
|
|
@@ -660,6 +671,7 @@ function renderDocDialog() {
|
|
|
660
671
|
for (const id of ['doc-copy', 'doc-download', 'doc-print']) $(`#${id}`).disabled = !d?.markdown;
|
|
661
672
|
// Diagrams: the whole document as one HTML file with every diagram (each also has Copy / PNG / SVG).
|
|
662
673
|
$('#doc-html').hidden = !/```mermaid/.test(d?.markdown ?? '');
|
|
674
|
+
$('#doc-openapi').hidden = docView.kind !== 'documentation' || !openApiOf(d?.markdown);
|
|
663
675
|
$('#doc-listen').innerHTML = d?.markdown && docView.kind !== 'diagrams' ? listenHtml(docView.kind === 'scorecard' ? `score:${docView.agentId}` : `doc:${docView.agentId}:${docView.kind}`, { title: 'Read the document aloud' }) : '';
|
|
664
676
|
$('#doc-print').hidden = plan || specKind;
|
|
665
677
|
$('#doc-regen').hidden = plan || specKind;
|
|
@@ -704,6 +716,7 @@ function renderEval(a, body, d) {
|
|
|
704
716
|
$('#doc-meta').textContent = ev?.at ? `Worked out ${ago(ev.at)}${ev.postedTo ? ' · posted on the pull request' : ''}` : '';
|
|
705
717
|
for (const id of ['doc-copy', 'doc-download', 'doc-print']) $(`#${id}`).disabled = !d?.markdown;
|
|
706
718
|
$('#doc-html').hidden = true;
|
|
719
|
+
$('#doc-openapi').hidden = true;
|
|
707
720
|
$('#doc-listen').innerHTML = '';
|
|
708
721
|
$('#doc-print').hidden = true;
|
|
709
722
|
$('#doc-regen').hidden = true;
|
|
@@ -784,6 +797,13 @@ $('#doc-download').onclick = () => {
|
|
|
784
797
|
link.click();
|
|
785
798
|
setTimeout(() => URL.revokeObjectURL(link.href), 1000);
|
|
786
799
|
};
|
|
800
|
+
$('#doc-openapi').onclick = () => {
|
|
801
|
+
const a = agents.get(docView.agentId);
|
|
802
|
+
const blob = new Blob([openApiOf(docOf(a, docView.kind)?.markdown)], { type: 'application/yaml' });
|
|
803
|
+
const link = Object.assign(document.createElement('a'), { href: URL.createObjectURL(blob), download: `${a.slug}-openapi.yaml` });
|
|
804
|
+
link.click();
|
|
805
|
+
setTimeout(() => URL.revokeObjectURL(link.href), 1000);
|
|
806
|
+
};
|
|
787
807
|
const haAnswers = () => Object.fromEntries([...document.querySelectorAll('#doc-body [data-ha]')].map((t) => [t.dataset.ha, t.value]));
|
|
788
808
|
$('#doc-body').addEventListener('click', (e) => {
|
|
789
809
|
const pick = e.target.closest('[data-ha-pick]');
|
|
@@ -2272,6 +2292,7 @@ function renderDetail() {
|
|
|
2272
2292
|
${noRepo(a) ? '' : `<button data-act="changes" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="Read its changes, comment on lines for the agent, commit and open a pull request">Review changes${a.git?.dirtyFiles ? ` <span class="count">${a.git.dirtyFiles}</span>` : ''}</button>`}
|
|
2273
2293
|
${a.aiReview?.verdict ? `<button data-act="overview" title="The AI review: what's done, what's missing, the risks">Overview${a.aiReview.seen ? '' : ' <span class="count">new</span>'}</button>` : ''}
|
|
2274
2294
|
${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>` : ''}
|
|
2295
|
+
<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>
|
|
2275
2296
|
<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>
|
|
2276
2297
|
<button data-act="edit" title="Change its name, request, project, priority, permission mode or model">Edit</button>
|
|
2277
2298
|
<button data-act="refresh" title="Re-scan git, PRs and transcripts">Refresh</button>
|
|
@@ -3866,6 +3887,8 @@ $('#detail-body').addEventListener('click', async (e) => {
|
|
|
3866
3887
|
case 'overview':
|
|
3867
3888
|
case 'questions':
|
|
3868
3889
|
return openNeeds(a.id, btn.dataset.act);
|
|
3890
|
+
case 'mcp':
|
|
3891
|
+
return mcpUi.open(a.id);
|
|
3869
3892
|
case 'memory':
|
|
3870
3893
|
return openMemory(a);
|
|
3871
3894
|
case 'fork':
|
package/public/index.html
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
<button id="value-btn" title="Value: what the delivered work is worth, by day, week, month and quarter, against the AI cost and your time; reports for management">Value</button>
|
|
43
43
|
<button id="map-btn" title="The codebase map: where each agent is changing and reading code, and who is about to collide">Map</button>
|
|
44
44
|
<button id="watch-btn" title="Running agents' sessions side by side, live: follow them all without clicking from one to the next">Watch</button>
|
|
45
|
+
<button id="mcp-btn" title="MCP: the MCP servers Claude Code has (yours, projects', claude.ai connectors and plugins), their tools, and running one in an agent's session or workspace">MCP</button>
|
|
45
46
|
<button id="machine-btn" title="A terminal on this computer (your home folder), from any device you're signed in on">Terminal</button>
|
|
46
47
|
<button id="ask-btn" title="A general session with no repo or folder, on Claude Code or another engine you have (Codex, Muse Code, …)">Ask Agent</button>
|
|
47
48
|
<div class="menu-wrap top-more" id="top-more" hidden>
|
|
@@ -483,6 +484,7 @@
|
|
|
483
484
|
<button type="button" id="doc-copy" class="small" title="Copy as Markdown">Copy Markdown</button>
|
|
484
485
|
<span id="doc-listen"></span>
|
|
485
486
|
<button type="button" id="doc-download" class="small">Download .md</button>
|
|
487
|
+
<button type="button" id="doc-openapi" class="small" hidden title="The OpenAPI 3 spec of the API changes, as a YAML file for Swagger, Postman or your API docs">Download OpenAPI</button>
|
|
486
488
|
<button type="button" id="doc-html" class="small" hidden title="One HTML file with every diagram: open it anywhere, attach it, or print it">Download .html</button>
|
|
487
489
|
<button type="button" id="doc-print" class="small primary" title="Open a print-ready page (Save as PDF)">Print / PDF</button>
|
|
488
490
|
<button type="button" id="doc-close" class="small ghost">Close</button>
|
|
@@ -526,6 +528,16 @@
|
|
|
526
528
|
<div id="team-body" class="race-body team-body"></div>
|
|
527
529
|
</dialog>
|
|
528
530
|
|
|
531
|
+
<dialog id="mcp-dialog" class="doc-dialog" aria-label="MCP servers and tools">
|
|
532
|
+
<div class="doc-head">
|
|
533
|
+
<h2>MCP servers and tools</h2>
|
|
534
|
+
<span class="spacer"></span>
|
|
535
|
+
<span id="mcp-head" class="mcp-head"></span>
|
|
536
|
+
<button type="button" id="mcp-close" class="small ghost">Close</button>
|
|
537
|
+
</div>
|
|
538
|
+
<div id="mcp-body" class="needs-body mcp-body"></div>
|
|
539
|
+
</dialog>
|
|
540
|
+
|
|
529
541
|
<dialog id="needs-dialog" class="doc-dialog">
|
|
530
542
|
<div class="doc-head">
|
|
531
543
|
<h2 id="needs-title">Overview</h2>
|
package/public/mcp.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// MCP: the MCP servers Claude Code has in an agent's folder (or the home folder), each with its
|
|
2
|
+
// status, where it comes from and its tools; any tool runs in the agent's session, or once in the
|
|
3
|
+
// workspace with only that tool allowed.
|
|
4
|
+
|
|
5
|
+
const SOURCE = { project: 'Project (.mcp.json)', user: 'User', local: 'Local', claudeai: 'claude.ai connector', dynamic: 'Added at launch', enterprise: 'Managed' };
|
|
6
|
+
const STATUS = { connected: 'mcp-ok', pending: 'mcp-wait', failed: 'fail', 'needs-auth': 'mcp-wait', disabled: '' };
|
|
7
|
+
|
|
8
|
+
export function initMcp({ api, $, esc, ago, md, toast, agents }) {
|
|
9
|
+
const dialog = $('#mcp-dialog');
|
|
10
|
+
const body = $('#mcp-body');
|
|
11
|
+
let where = 'home';
|
|
12
|
+
let data = null;
|
|
13
|
+
let loading = false;
|
|
14
|
+
let query = '';
|
|
15
|
+
const results = new Map(); // "<where>:<tool id>" -> { text, ms, at } | { error } | { running }
|
|
16
|
+
const forms = new Set(); // tool ids with their run form open
|
|
17
|
+
const sure = new Set(); // destructive tools waiting for a second click
|
|
18
|
+
|
|
19
|
+
const sourceOf = (s) => SOURCE[s.source] ?? (String(s.source ?? '').startsWith('plugin') ? `Plugin${s.source.includes(':') ? `: ${s.source.split(':').slice(1).join(':')}` : ''}` : s.source ?? s.scope ?? '');
|
|
20
|
+
|
|
21
|
+
async function load(refresh = false) {
|
|
22
|
+
loading = true;
|
|
23
|
+
render();
|
|
24
|
+
try {
|
|
25
|
+
data = await api('GET', `/mcp?agent=${encodeURIComponent(where)}${refresh ? '&refresh=1' : ''}`);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
data = { servers: [], error: e.message };
|
|
28
|
+
} finally {
|
|
29
|
+
loading = false;
|
|
30
|
+
}
|
|
31
|
+
render();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function picker() {
|
|
35
|
+
const list = agents().filter((a) => a.workdir && a.status !== 'preparing');
|
|
36
|
+
return `<select id="mcp-where" title="Whose folder: an agent's workspace has its project's servers too">
|
|
37
|
+
<option value="home" ${where === 'home' ? 'selected' : ''}>Home folder (your servers and connectors)</option>
|
|
38
|
+
${list.map((a) => `<option value="${esc(a.id)}" ${where === a.id ? 'selected' : ''}>${esc(a.name)}</option>`).join('')}
|
|
39
|
+
</select>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function toolHtml(s, t) {
|
|
43
|
+
const key = `${where}:${t.id}`;
|
|
44
|
+
const r = results.get(key);
|
|
45
|
+
const agent = data.agent;
|
|
46
|
+
const canSession = agent && agent.engine === 'claude';
|
|
47
|
+
const open = forms.has(t.id);
|
|
48
|
+
const tags = `${t.readOnly ? '<span class="tag mcp-ok" title="The server says it only reads">read-only</span>' : ''}${t.destructive ? '<span class="tag fail" title="The server says it may change or delete things">destructive</span>' : ''}`;
|
|
49
|
+
const form = open
|
|
50
|
+
? `<div class="mcp-form">
|
|
51
|
+
<textarea data-mcp-input="${esc(t.id)}" rows="2" placeholder="What it should do, or its arguments in plain words (optional)"></textarea>
|
|
52
|
+
${sure.has(t.id) ? `<p class="hint error">${esc(t.name)} may change or delete things. Click again to run it.</p>` : ''}
|
|
53
|
+
<div class="mcp-actions">
|
|
54
|
+
${agent ? `<button type="button" class="small" data-mcp-run="session" data-server="${esc(s.name)}" data-tool="${esc(t.name)}" ${canSession ? '' : 'disabled'} title="${canSession ? `Tell ${esc(agent.name)} to use it, with its conversation and context${agent.running ? '' : ' (resumes the session)'}` : 'Works for Claude Code agents'}">Run in session</button>` : ''}
|
|
55
|
+
<button type="button" class="small primary" data-mcp-run="workspace" data-server="${esc(s.name)}" data-tool="${esc(t.name)}" ${r?.running ? 'disabled' : ''} title="A separate one-off Claude Code call in ${agent ? 'the workspace' : 'your home folder'} that may use only this tool; the agent is not interrupted">${r?.running ? 'Running…' : `Run once in ${agent ? 'workspace' : 'home folder'}`}</button>
|
|
56
|
+
</div>
|
|
57
|
+
</div>`
|
|
58
|
+
: '';
|
|
59
|
+
const out = r?.error
|
|
60
|
+
? `<p class="error">${esc(r.error)}</p>`
|
|
61
|
+
: r?.text
|
|
62
|
+
? `<div class="mcp-result"><p class="hint">Ran ${ago(r.at)} in ${(r.ms / 1000).toFixed(1)} s</p><div class="md">${md(r.text)}</div></div>`
|
|
63
|
+
: r?.told
|
|
64
|
+
? `<p class="hint">Sent to ${esc(r.told)}. Its answer is in the session.</p>`
|
|
65
|
+
: '';
|
|
66
|
+
return `<li class="mcp-tool">
|
|
67
|
+
<div class="mcp-tool-row"><code title="${esc(t.id)}">${esc(t.name)}</code>${t.title ? ` <span class="hint">${esc(t.title)}</span>` : ''} ${tags}
|
|
68
|
+
<span class="spacer"></span>${s.status === 'connected' ? `<button type="button" class="small ghost" data-mcp-form="${esc(t.id)}">${open ? 'Hide' : 'Run…'}</button>` : ''}</div>
|
|
69
|
+
${form}${out}
|
|
70
|
+
</li>`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function serverHtml(s) {
|
|
74
|
+
const q = query.toLowerCase();
|
|
75
|
+
const tools = s.tools.filter((t) => !q || s.name.toLowerCase().includes(q) || t.name.toLowerCase().includes(q) || (t.title ?? '').toLowerCase().includes(q));
|
|
76
|
+
if (q && !tools.length) return '';
|
|
77
|
+
return `<details class="mcp-server" ${q || s.tools.length <= 12 ? 'open' : ''}>
|
|
78
|
+
<summary><b>${esc(s.name)}</b> <span class="tag ${STATUS[s.status] ?? ''}">${esc(s.status)}</span> <span class="tag">${esc(sourceOf(s))}</span>
|
|
79
|
+
<span class="hint">${s.tools.length} tool${s.tools.length === 1 ? '' : 's'}</span></summary>
|
|
80
|
+
${s.target ? `<p class="hint mcp-target" title="${esc(s.transport ?? '')}">${esc(s.target)}</p>` : ''}
|
|
81
|
+
${s.error ? `<p class="error">${esc(s.error)}</p>` : ''}
|
|
82
|
+
${s.status === 'needs-auth' ? '<p class="hint">Sign in to it from Claude Code (/mcp) to use its tools.</p>' : ''}
|
|
83
|
+
${tools.length ? `<ul class="mcp-tools">${tools.map((t) => toolHtml(s, t)).join('')}</ul>` : s.status === 'connected' ? '<p class="hint">No tools.</p>' : ''}
|
|
84
|
+
</details>`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function render() {
|
|
88
|
+
if (!dialog.open) return;
|
|
89
|
+
const focus = document.activeElement?.dataset?.mcpInput;
|
|
90
|
+
const typed = Object.fromEntries([...body.querySelectorAll('[data-mcp-input]')].map((t) => [t.dataset.mcpInput, t.value]));
|
|
91
|
+
const n = data?.servers?.reduce((k, s) => k + s.tools.length, 0) ?? 0;
|
|
92
|
+
$('#mcp-head').innerHTML = `${picker()}<input id="mcp-filter" type="search" placeholder="Filter servers and tools" value="${esc(query)}" />
|
|
93
|
+
<button type="button" class="small" id="mcp-refresh" ${loading ? 'disabled' : ''} title="Ask Claude Code again (it connects to each server)">${loading ? 'Listing…' : 'Refresh'}</button>`;
|
|
94
|
+
body.innerHTML = loading && !data
|
|
95
|
+
? '<p class="hint">Asking Claude Code for its MCP servers here (it connects to each one)…</p>'
|
|
96
|
+
: !data
|
|
97
|
+
? ''
|
|
98
|
+
: `<p class="hint">${data.servers.length} server${data.servers.length === 1 ? '' : 's'}, ${n} tool${n === 1 ? '' : 's'}${data.at ? `, listed ${ago(data.at)}` : ''}${data.dir ? ` in <code>${esc(data.dir)}</code>` : ''}. The same servers Claude Code has there: your own, the project's .mcp.json, claude.ai connectors and plugins.</p>
|
|
99
|
+
${data.error ? `<p class="error">${esc(data.error)}</p>` : ''}
|
|
100
|
+
${data.servers.map(serverHtml).join('') || (data.error ? '' : '<p class="hint">No MCP servers here. Add one with <code>claude mcp add</code>, or a .mcp.json in the project.</p>')}`;
|
|
101
|
+
for (const [id, v] of Object.entries(typed)) {
|
|
102
|
+
const box = body.querySelector(`[data-mcp-input="${CSS.escape(id)}"]`);
|
|
103
|
+
if (box) box.value = v;
|
|
104
|
+
}
|
|
105
|
+
if (focus) body.querySelector(`[data-mcp-input="${CSS.escape(focus)}"]`)?.focus();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function run(btn) {
|
|
109
|
+
const how = btn.dataset.mcpRun;
|
|
110
|
+
const server = btn.dataset.server;
|
|
111
|
+
const tool = btn.dataset.tool;
|
|
112
|
+
const t = data.servers.find((s) => s.name === server)?.tools.find((x) => x.name === tool);
|
|
113
|
+
if (!t) return;
|
|
114
|
+
if (t.destructive && !sure.has(t.id)) {
|
|
115
|
+
sure.add(t.id);
|
|
116
|
+
return render();
|
|
117
|
+
}
|
|
118
|
+
sure.delete(t.id);
|
|
119
|
+
const input = body.querySelector(`[data-mcp-input="${CSS.escape(t.id)}"]`)?.value ?? '';
|
|
120
|
+
const key = `${where}:${t.id}`;
|
|
121
|
+
if (how === 'session') {
|
|
122
|
+
try {
|
|
123
|
+
await api('POST', '/mcp/run', { agent: where, server, tool, input, where: 'session' });
|
|
124
|
+
results.set(key, { told: data.agent.name });
|
|
125
|
+
toast(`Asked ${data.agent.name} to use ${tool}`);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
results.set(key, { error: e.message });
|
|
128
|
+
}
|
|
129
|
+
return render();
|
|
130
|
+
}
|
|
131
|
+
results.set(key, { running: true });
|
|
132
|
+
render();
|
|
133
|
+
try {
|
|
134
|
+
results.set(key, await api('POST', '/mcp/run', { agent: where, server, tool, input, where: 'workspace' }));
|
|
135
|
+
} catch (e) {
|
|
136
|
+
results.set(key, { error: e.message });
|
|
137
|
+
}
|
|
138
|
+
render();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
dialog.addEventListener('click', (e) => {
|
|
142
|
+
const b = e.target.closest('button');
|
|
143
|
+
if (!b) return;
|
|
144
|
+
if (b.id === 'mcp-close') return dialog.close();
|
|
145
|
+
if (b.id === 'mcp-refresh') return load(true);
|
|
146
|
+
if (b.dataset.mcpForm) {
|
|
147
|
+
if (forms.has(b.dataset.mcpForm)) forms.delete(b.dataset.mcpForm);
|
|
148
|
+
else forms.add(b.dataset.mcpForm);
|
|
149
|
+
sure.delete(b.dataset.mcpForm);
|
|
150
|
+
return render();
|
|
151
|
+
}
|
|
152
|
+
if (b.dataset.mcpRun) return run(b);
|
|
153
|
+
});
|
|
154
|
+
dialog.addEventListener('change', (e) => {
|
|
155
|
+
if (e.target.id !== 'mcp-where') return;
|
|
156
|
+
where = e.target.value;
|
|
157
|
+
data = null;
|
|
158
|
+
forms.clear();
|
|
159
|
+
load();
|
|
160
|
+
});
|
|
161
|
+
dialog.addEventListener('input', (e) => {
|
|
162
|
+
if (e.target.id !== 'mcp-filter') return;
|
|
163
|
+
query = e.target.value.trim();
|
|
164
|
+
const pos = e.target.selectionStart;
|
|
165
|
+
render();
|
|
166
|
+
const box = $('#mcp-filter');
|
|
167
|
+
box.focus();
|
|
168
|
+
box.setSelectionRange(pos, pos);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
/** Open for an agent's workspace, or the home folder. */
|
|
173
|
+
open(agentId = null) {
|
|
174
|
+
const next = agentId ?? 'home';
|
|
175
|
+
if (next !== where) {
|
|
176
|
+
where = next;
|
|
177
|
+
data = null;
|
|
178
|
+
forms.clear();
|
|
179
|
+
}
|
|
180
|
+
dialog.showModal();
|
|
181
|
+
render();
|
|
182
|
+
load();
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
package/public/side.js
CHANGED
package/public/style.css
CHANGED
|
@@ -731,6 +731,23 @@ pre.diff .meta { color: var(--muted); font-weight: 600; }
|
|
|
731
731
|
.needs-body .needs .needs { margin-top: 0; }
|
|
732
732
|
.needs-body h4 { margin: 16px 0 6px; }
|
|
733
733
|
.needs-body .answered { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
|
|
734
|
+
.mcp-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
|
|
735
|
+
.mcp-head select { max-width: 280px; }
|
|
736
|
+
.mcp-head input { width: 200px; }
|
|
737
|
+
.mcp-body > p:first-child { margin-top: 10px; }
|
|
738
|
+
.mcp-server { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin: 8px 0; }
|
|
739
|
+
.mcp-server summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
740
|
+
.mcp-target { margin: 4px 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }
|
|
741
|
+
.mcp-tools { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
|
|
742
|
+
.mcp-tool { border-top: 1px solid var(--border); padding-top: 4px; }
|
|
743
|
+
.mcp-tool-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
|
|
744
|
+
.mcp-tool-row .spacer { flex: 1; }
|
|
745
|
+
.mcp-form { display: grid; gap: 6px; margin: 6px 0; }
|
|
746
|
+
.mcp-form textarea { width: 100%; box-sizing: border-box; }
|
|
747
|
+
.mcp-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
|
|
748
|
+
.mcp-result { border-left: 3px solid var(--border); padding-left: 10px; margin: 6px 0; max-height: 320px; overflow: auto; }
|
|
749
|
+
.tag.mcp-ok { color: var(--green); }
|
|
750
|
+
.tag.mcp-wait { color: var(--yellow); }
|
|
734
751
|
.rv-summary { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
|
|
735
752
|
.rv-warn { margin: 0; color: var(--yellow); }
|
|
736
753
|
.rv-add { color: var(--green); font-family: var(--mono); font-size: 12px; }
|
package/src/brief.js
CHANGED
|
@@ -307,9 +307,52 @@ export const DOC_KINDS = {
|
|
|
307
307
|
],
|
|
308
308
|
diagram: 'Include one small diagram if it helps the decision.',
|
|
309
309
|
},
|
|
310
|
+
estimate: {
|
|
311
|
+
title: 'Human time estimate',
|
|
312
|
+
sections: [
|
|
313
|
+
['Summary', 'The total in hours and working days (6 focused hours a day) for one experienced developer who knows the codebase, the likely figure with its range, and how confident the estimate is.'],
|
|
314
|
+
[
|
|
315
|
+
'Breakdown',
|
|
316
|
+
'A Markdown table with columns: #, Task, What it covers, Optimistic (h), Likely (h), Pessimistic (h), Expected (h). Split the work into tasks of at most about 8 likely hours each: understanding the ticket and code, design, each part of the implementation (one row per component or module), tests (unit, integration, end-to-end), documentation, code review and fixes, QA and verification, release or rollout. Expected = (optimistic + 4 × likely + pessimistic) / 6, rounded to the nearest half hour. End with a bold Total row.',
|
|
317
|
+
],
|
|
318
|
+
['Suggested split', 'If the total is more than about 3 days, how to split it into tickets or sub-tasks that can be delivered and reviewed on their own: each with a one-line scope, its estimate and what it depends on. Otherwise say that one ticket is enough.'],
|
|
319
|
+
['Roles and skills', 'Who is needed (for example backend, frontend, QA, DevOps, a reviewer who knows a component) and the hours for each.'],
|
|
320
|
+
['Assumptions', 'What the estimate takes as given.'],
|
|
321
|
+
['Risks and unknowns', 'What could move the estimate, by how much, and how to reduce the uncertainty early.'],
|
|
322
|
+
],
|
|
323
|
+
diagram: 'No diagram unless a ```mermaid gantt chart of the tasks helps the plan.',
|
|
324
|
+
rules: [
|
|
325
|
+
'This is for planning: estimate the time a person would take to do this work by hand, without an AI agent. Never give the agent\'s own time.',
|
|
326
|
+
'Size it from the evidence: the ticket and intent, the files and lines changed so far (diffstat) and the brief. Where the work is not done yet, estimate what is left as well as what is done, and say which.',
|
|
327
|
+
'Use hours. Keep the numbers consistent: the Total row is the sum of the rows above it.',
|
|
328
|
+
],
|
|
329
|
+
words: '300-900',
|
|
330
|
+
},
|
|
331
|
+
documentation: {
|
|
332
|
+
title: 'Documentation',
|
|
333
|
+
diff: true,
|
|
334
|
+
sections: [
|
|
335
|
+
['Summary', 'What changed and who it is for, in two or three sentences.'],
|
|
336
|
+
['What is new or changed', 'The changes as users see them, as bullets.'],
|
|
337
|
+
['How to use it', 'Steps, commands, UI paths or code examples for the main uses.'],
|
|
338
|
+
['Configuration', 'Settings, environment variables, flags and their defaults that were added or changed, as a table; or "No configuration changes."'],
|
|
339
|
+
['Upgrade and operations notes', 'Migrations, compatibility, permissions, rollout and rollback, monitoring; or "None."'],
|
|
340
|
+
['Docs to add or update', 'Each documentation file or page in the repository (README, docs/, changelog, help text) that should be added or changed, with what goes in it.'],
|
|
341
|
+
[
|
|
342
|
+
'API changes',
|
|
343
|
+
'If the work adds, changes or removes HTTP API endpoints, parameters, request or response fields or status codes, a summary table of the endpoints (method, path, change), then one ```yaml block with an OpenAPI 3.0.3 document covering only those endpoints: paths, parameters, request bodies, responses and component schemas, with descriptions and examples. Mark removed or deprecated endpoints with deprecated: true. If there are no API changes, write "No API changes."',
|
|
344
|
+
],
|
|
345
|
+
],
|
|
346
|
+
diagram: 'No diagram unless one makes the usage clearer.',
|
|
347
|
+
rules: [
|
|
348
|
+
'Write it from the actual changes in <diff> and the brief: only document behaviour the code has. Read routes, handlers, schemas and validation in the diff to get the API right (paths, methods, field names and types).',
|
|
349
|
+
'The OpenAPI block must be valid YAML that an OpenAPI 3.0 tool can load on its own: openapi, info (title and version), paths and, when used, components.',
|
|
350
|
+
],
|
|
351
|
+
words: '400-1500',
|
|
352
|
+
},
|
|
310
353
|
};
|
|
311
354
|
|
|
312
|
-
export function docPrompt(kind, { intent, status, digest, repo, briefMarkdown, agentName }) {
|
|
355
|
+
export function docPrompt(kind, { intent, status, digest, repo, briefMarkdown, agentName, diff }) {
|
|
313
356
|
const d = DOC_KINDS[kind];
|
|
314
357
|
return [
|
|
315
358
|
`Write a ${d.title} document about an AI coding agent's work, for stakeholders who will review it.`,
|
|
@@ -323,7 +366,8 @@ export function docPrompt(kind, { intent, status, digest, repo, briefMarkdown, a
|
|
|
323
366
|
`- ${d.diagram} Diagrams go in \`\`\`mermaid code blocks with valid Mermaid syntax; keep node labels short and quote labels that contain punctuation.`,
|
|
324
367
|
'- Be specific: name the real files, components, tickets and documents from the context.',
|
|
325
368
|
'- Separate facts from proposals. Where the context does not say, write "To be confirmed" rather than guessing.',
|
|
326
|
-
|
|
369
|
+
...(d.rules ?? []).map((r) => `- ${r}`),
|
|
370
|
+
`- Clear, neutral, professional prose; bullets where they help. Roughly ${d.words ?? '400-900'} words${d.rules ? ' (not counting tables and code)' : ''}.`,
|
|
327
371
|
'- Output only the Markdown document.',
|
|
328
372
|
'',
|
|
329
373
|
'<agent_status>',
|
|
@@ -341,6 +385,7 @@ export function docPrompt(kind, { intent, status, digest, repo, briefMarkdown, a
|
|
|
341
385
|
'<brief>',
|
|
342
386
|
briefMarkdown || '(no brief yet)',
|
|
343
387
|
'</brief>',
|
|
388
|
+
...(diff == null ? [] : ['<diff>', diff || '(no changes yet)', '</diff>']),
|
|
344
389
|
].join('\n');
|
|
345
390
|
}
|
|
346
391
|
|
package/src/cli.js
CHANGED
|
@@ -475,18 +475,18 @@ export async function main(argv) {
|
|
|
475
475
|
|
|
476
476
|
program
|
|
477
477
|
.command('doc')
|
|
478
|
-
.description('Write a stakeholder document from the agent work: analysis, design, flow, proposal, humanai (Human vs AI), diagrams (diagrams only), walkthrough (its changes explained one by one) or scorecard (its changes scored for review)')
|
|
478
|
+
.description('Write a stakeholder document from the agent work: analysis, design, flow, proposal, humanai (Human vs AI), estimate (human time estimate for planning), documentation (user, developer and OpenAPI docs), diagrams (diagrams only), walkthrough (its changes explained one by one) or scorecard (its changes scored for review)')
|
|
479
479
|
.argument('<agent>')
|
|
480
|
-
.argument('<kind>', 'analysis, design, flow, proposal, humanai, diagrams, walkthrough, scorecard, or all (background; diagrams, walkthrough and scorecard not included)')
|
|
480
|
+
.argument('<kind>', 'analysis, design, flow, proposal, humanai, estimate, documentation, diagrams, walkthrough, scorecard, or all (background; diagrams, walkthrough and scorecard not included)')
|
|
481
481
|
.option('-o, --output <file>', 'also save the Markdown to this file')
|
|
482
482
|
.option('--cached', 'print the last version instead of writing a new one')
|
|
483
|
-
.option('-b, --background', 'start writing and return at once (kind "all" writes all
|
|
483
|
+
.option('-b, --background', 'start writing and return at once (kind "all" writes all seven)')
|
|
484
484
|
.action(async (ref, kind, opts) => {
|
|
485
485
|
await daemon();
|
|
486
486
|
const a = await resolveAgent(ref);
|
|
487
487
|
if (opts.background || kind === 'all') {
|
|
488
488
|
const res = await api('POST', `/agents/${a.id}/docs/${encodeURIComponent(kind)}?background=1`);
|
|
489
|
-
const kinds = kind === 'all' ? ['analysis', 'design', 'flow', 'proposal', 'humanai'] : [kind];
|
|
489
|
+
const kinds = kind === 'all' ? ['analysis', 'design', 'flow', 'proposal', 'humanai', 'estimate', 'documentation'] : [kind];
|
|
490
490
|
console.log(`${green('…')} writing ${kinds.join(', ')} for ${res.name} in the background`);
|
|
491
491
|
console.log(dim(` read it when ready: agentmgr doc ${a.id} ${kinds[0]} --cached (or open the agent in the UI)`));
|
|
492
492
|
return;
|
|
@@ -821,6 +821,43 @@ export async function main(argv) {
|
|
|
821
821
|
}
|
|
822
822
|
});
|
|
823
823
|
|
|
824
|
+
const mcp = program.command('mcp').description("MCP servers and their tools as Claude Code has them in an agent's folder (or your home folder), and running one");
|
|
825
|
+
mcp
|
|
826
|
+
.command('list', { isDefault: true })
|
|
827
|
+
.description('List the MCP servers, their status and tools')
|
|
828
|
+
.argument('[agent]', "an agent: its folder's servers too (default: your home folder)")
|
|
829
|
+
.option('-r, --refresh', 'ask Claude Code again instead of the list from the last 5 minutes')
|
|
830
|
+
.option('--json', 'print JSON')
|
|
831
|
+
.action(async (ref, opts) => {
|
|
832
|
+
await daemon();
|
|
833
|
+
const a = ref ? await resolveAgent(ref) : null;
|
|
834
|
+
const r = await api('GET', `/mcp?agent=${encodeURIComponent(a?.id ?? 'home')}${opts.refresh ? '&refresh=1' : ''}`);
|
|
835
|
+
if (opts.json) return console.log(JSON.stringify(r, null, 2));
|
|
836
|
+
if (r.error) console.log(red(r.error));
|
|
837
|
+
if (!r.servers.length) return console.log(dim(`No MCP servers in ${r.dir}.`));
|
|
838
|
+
console.log(dim(`In ${r.dir}:`));
|
|
839
|
+
for (const s of r.servers) {
|
|
840
|
+
console.log(`${bold(s.name)} ${s.status === 'connected' ? green(s.status) : yellow(s.status)} ${dim([s.source, s.target].filter(Boolean).join(' '))}`);
|
|
841
|
+
for (const t of s.tools) console.log(` ${t.name}${t.readOnly ? dim(' read-only') : ''}${t.destructive ? red(' destructive') : ''}`);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
mcp
|
|
845
|
+
.command('run')
|
|
846
|
+
.description("Run a tool once in the agent's folder (a separate call allowed only that tool), or in its session with --session")
|
|
847
|
+
.argument('<agent>', 'the agent, or "home" for your home folder')
|
|
848
|
+
.argument('<server>')
|
|
849
|
+
.argument('<tool>')
|
|
850
|
+
.argument('[request...]', 'what it should do, or its arguments in plain words')
|
|
851
|
+
.option('-s, --session', 'tell the agent to use it in its session instead')
|
|
852
|
+
.action(async (ref, server, tool, request, opts) => {
|
|
853
|
+
await daemon();
|
|
854
|
+
const agent = ref === 'home' ? 'home' : (await resolveAgent(ref)).id;
|
|
855
|
+
const r = await api('POST', '/mcp/run', { agent, server, tool, input: request.join(' '), where: opts.session ? 'session' : 'workspace' });
|
|
856
|
+
if (r.where === 'session') return console.log(`${green('✓')} asked ${r.agent.name} to use ${r.tool}; its answer is in the session`);
|
|
857
|
+
console.log(r.text);
|
|
858
|
+
console.log(dim(`(${r.tool}, ${(r.ms / 1000).toFixed(1)} s)`));
|
|
859
|
+
});
|
|
860
|
+
|
|
824
861
|
program
|
|
825
862
|
.command('review')
|
|
826
863
|
.description("Start a reviewer agent on someone else's pull request: it asks the critical questions and finds what blocks approval; nothing is posted")
|
package/src/drive.js
CHANGED
|
@@ -23,6 +23,8 @@ export const DRIVE_DOCS = [
|
|
|
23
23
|
['design', 'Design'],
|
|
24
24
|
['flow', 'Flow'],
|
|
25
25
|
['proposal', 'Proposal'],
|
|
26
|
+
['estimate', 'Human time estimate'],
|
|
27
|
+
['documentation', 'Documentation'],
|
|
26
28
|
['diagrams', 'Diagrams'],
|
|
27
29
|
['walkthrough', 'Change walkthrough'],
|
|
28
30
|
['scorecard', 'Review scorecard'],
|
package/src/manager.js
CHANGED
|
@@ -2407,7 +2407,7 @@ export class AgentManager extends EventEmitter {
|
|
|
2407
2407
|
return this.view(this.store.get(agent.id));
|
|
2408
2408
|
}
|
|
2409
2409
|
|
|
2410
|
-
/** A stakeholder document: analysis, design, flow or
|
|
2410
|
+
/** A stakeholder document: analysis, design, flow, proposal, estimate or documentation. */
|
|
2411
2411
|
document(ref, kind) {
|
|
2412
2412
|
if (!SUMMARIES[kind]?.doc) throw Object.assign(new Error(`Unknown document "${kind}"`), { status: 400 });
|
|
2413
2413
|
return this.summarize(ref, kind);
|
|
@@ -2422,6 +2422,7 @@ export class AgentManager extends EventEmitter {
|
|
|
2422
2422
|
const run = this.summarySlot()
|
|
2423
2423
|
.then((release) =>
|
|
2424
2424
|
this.explainContext(agent)
|
|
2425
|
+
.then(async (ctx) => (DOC_KINDS[kind]?.diff ? { ...ctx, diff: await this.docDiff(agent) } : ctx))
|
|
2425
2426
|
.then((ctx) => (SUMMARIES[kind].run ? this[SUMMARIES[kind].run](agent, ctx) : this.runExplain(agent, { ...ctx, agentName: agent.name }, kind)))
|
|
2426
2427
|
.finally(release),
|
|
2427
2428
|
)
|
|
@@ -2435,6 +2436,13 @@ export class AgentManager extends EventEmitter {
|
|
|
2435
2436
|
return run;
|
|
2436
2437
|
}
|
|
2437
2438
|
|
|
2439
|
+
/** The agent's changes for a document that needs the code itself (Documentation: the API), cut to fit a prompt. */
|
|
2440
|
+
async docDiff(agent, max = 80_000) {
|
|
2441
|
+
if (!this.changesSource || NO_REPO.has(agent.kind) || !agent.workdir) return null;
|
|
2442
|
+
const diff = (await this.changesSource(agent.id).catch(() => null))?.diff ?? '';
|
|
2443
|
+
return diff.length > max ? `${diff.slice(0, max)}\n… (the rest of the diff was cut)` : diff;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2438
2446
|
/** What the agent is actually doing: its session, repo changes, live status and brief. */
|
|
2439
2447
|
async explainContext(agent) {
|
|
2440
2448
|
const v = this.view(agent);
|
|
@@ -2514,16 +2522,17 @@ export class AgentManager extends EventEmitter {
|
|
|
2514
2522
|
}
|
|
2515
2523
|
|
|
2516
2524
|
/** One tool-less, read-only call to an engine; resolves to its text output. */
|
|
2517
|
-
oneShot(agent, text, { engine, model, timeoutMs = 300_000, tools }) {
|
|
2525
|
+
oneShot(agent, text, { engine, model, timeoutMs = 300_000, tools, cwd = paths.home }) {
|
|
2518
2526
|
// Some engines take the prompt as an argument instead of on stdin, and some need their extra
|
|
2519
2527
|
// arguments after a subcommand (oneShotExtra: they place them). `tools`: Claude Code only, a
|
|
2520
|
-
// call that may use just these connector tools (and none of its own).
|
|
2528
|
+
// call that may use just these connector tools (and none of its own). `cwd`: where it runs, which
|
|
2529
|
+
// decides the project MCP servers it loads.
|
|
2521
2530
|
const extra = engine.extraArgs(this.config);
|
|
2522
2531
|
const args = tools
|
|
2523
2532
|
? [...extra, ...engine.connectorArgs(this.config, { model, tools })]
|
|
2524
2533
|
: engine.oneShotExtra ? engine.oneShotArgs(this.config, { model, prompt: text, extra }) : [...extra, ...engine.oneShotArgs(this.config, { model, prompt: text })];
|
|
2525
2534
|
return new Promise((resolve, reject) => {
|
|
2526
|
-
const child = spawn(engine.bin(this.config), args, { cwd
|
|
2535
|
+
const child = spawn(engine.bin(this.config), args, { cwd, env: this.childEnv(agent), stdio: ['pipe', 'pipe', 'pipe'] });
|
|
2527
2536
|
let out = '';
|
|
2528
2537
|
let err = '';
|
|
2529
2538
|
const timer = setTimeout(() => child.kill('SIGTERM'), timeoutMs);
|
package/src/mcp.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// MCP servers and their tools as Claude Code sees them in a folder: user, project and local
|
|
2
|
+
// servers, claude.ai connectors and plugins' servers. Listed through Claude Code's own control
|
|
3
|
+
// protocol (no model call), and run in an agent's session, or once in its workspace with only
|
|
4
|
+
// that one tool allowed.
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { DEFAULT_ENGINE, ENGINES } from './engines/index.js';
|
|
8
|
+
|
|
9
|
+
export const LIST_TTL_MS = 5 * 60_000;
|
|
10
|
+
const RUN_TIMEOUT_MS = 5 * 60_000;
|
|
11
|
+
|
|
12
|
+
/** Claude Code's name for a tool: mcp__<server>__<tool>, other characters in the server name as "_". */
|
|
13
|
+
export const toolId = (server, tool) => `mcp__${String(server).replace(/[^\w-]/g, '_')}__${tool}`;
|
|
14
|
+
|
|
15
|
+
const SECRET = /key|token|secret|passw|auth|bearer|cookie|credential/i;
|
|
16
|
+
|
|
17
|
+
/** Where a server runs, without secrets: the command line (values of secret-looking flags hidden), or the URL without its query. */
|
|
18
|
+
export function targetOf(config = {}) {
|
|
19
|
+
if (config.url) {
|
|
20
|
+
try {
|
|
21
|
+
const u = new URL(config.url);
|
|
22
|
+
return `${u.origin}${u.pathname}`;
|
|
23
|
+
} catch {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!config.command) return '';
|
|
28
|
+
const args = (config.args ?? []).map(String);
|
|
29
|
+
const shown = args.map((a, i) => {
|
|
30
|
+
const flag = a.match(/^(--?[\w-]+)=/)?.[1];
|
|
31
|
+
if (flag) return SECRET.test(flag) ? `${flag}=•••` : a;
|
|
32
|
+
if (/^-/.test(args[i - 1] ?? '') && SECRET.test(args[i - 1])) return '•••';
|
|
33
|
+
return /^[\w-]{32,}$/.test(a) ? '•••' : a;
|
|
34
|
+
});
|
|
35
|
+
return [config.command, ...shown].join(' ');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One server for the UI: no env, headers or other config values. */
|
|
39
|
+
export function serverView(s) {
|
|
40
|
+
return {
|
|
41
|
+
name: String(s.name),
|
|
42
|
+
status: s.status ?? 'unknown',
|
|
43
|
+
scope: s.scope ?? null,
|
|
44
|
+
source: s.source ?? null,
|
|
45
|
+
transport: s.transport ?? s.config?.type ?? null,
|
|
46
|
+
target: targetOf(s.config),
|
|
47
|
+
version: s.serverInfo?.version ?? null,
|
|
48
|
+
error: s.error ? String(s.error).slice(0, 300) : null,
|
|
49
|
+
tools: (s.tools ?? []).map((t) => ({
|
|
50
|
+
name: String(t.name),
|
|
51
|
+
id: toolId(s.name, t.name),
|
|
52
|
+
title: t.annotations?.title ?? null,
|
|
53
|
+
readOnly: t.annotations?.readOnlyHint === true,
|
|
54
|
+
destructive: t.annotations?.destructiveHint === true,
|
|
55
|
+
})),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Ask Claude Code in `cwd` for its MCP servers: start it in stream-json mode, initialize, and ask
|
|
61
|
+
* for their status until none is still connecting. No message is sent, so no model call is made.
|
|
62
|
+
*/
|
|
63
|
+
export function mcpStatus({ bin, args = [], cwd, env, timeoutMs = 30_000 }) {
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
const child = spawn(bin, [...args, '-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose', '--no-session-persistence'], {
|
|
66
|
+
cwd,
|
|
67
|
+
env,
|
|
68
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
69
|
+
});
|
|
70
|
+
let buf = '';
|
|
71
|
+
let err = '';
|
|
72
|
+
let last = null;
|
|
73
|
+
let n = 0;
|
|
74
|
+
let done = false;
|
|
75
|
+
let poll = null;
|
|
76
|
+
const finish = (fn, value) => {
|
|
77
|
+
if (done) return;
|
|
78
|
+
done = true;
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
clearTimeout(poll);
|
|
81
|
+
child.kill();
|
|
82
|
+
fn(value);
|
|
83
|
+
};
|
|
84
|
+
const send = (request) => child.stdin.write(`${JSON.stringify({ type: 'control_request', request_id: `r${++n}`, request })}\n`);
|
|
85
|
+
const timer = setTimeout(() => (last ? finish(resolve, last) : finish(reject, new Error('Claude Code did not list its MCP servers in time'))), timeoutMs);
|
|
86
|
+
child.stdout.on('data', (d) => {
|
|
87
|
+
buf += d;
|
|
88
|
+
const lines = buf.split('\n');
|
|
89
|
+
buf = lines.pop();
|
|
90
|
+
for (const line of lines) {
|
|
91
|
+
let m;
|
|
92
|
+
try {
|
|
93
|
+
m = JSON.parse(line);
|
|
94
|
+
} catch {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (m.type !== 'control_response') continue;
|
|
98
|
+
const r = m.response ?? {};
|
|
99
|
+
if (r.subtype === 'error') return finish(reject, new Error(`Claude Code: ${r.error ?? 'error'}`));
|
|
100
|
+
if (r.request_id === 'r1') {
|
|
101
|
+
send({ subtype: 'mcp_status' });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const servers = r.response?.mcpServers;
|
|
105
|
+
if (!Array.isArray(servers)) continue;
|
|
106
|
+
last = servers;
|
|
107
|
+
if (servers.some((s) => s.status === 'pending')) poll = setTimeout(() => send({ subtype: 'mcp_status' }), 1000);
|
|
108
|
+
else finish(resolve, servers);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
child.stderr.on('data', (d) => (err += d));
|
|
112
|
+
child.stdin.on('error', () => {});
|
|
113
|
+
child.on('error', (e) => finish(reject, e));
|
|
114
|
+
child.on('close', (code) => (last ? finish(resolve, last) : finish(reject, new Error(`Claude Code stopped before listing its MCP servers (exit ${code}): ${err.trim().slice(-300)}`))));
|
|
115
|
+
send({ subtype: 'initialize' });
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The one-off call in a workspace: use the tool for the request, and report what it returned. */
|
|
120
|
+
export function runPrompt(id, input) {
|
|
121
|
+
return [
|
|
122
|
+
`Use the MCP tool ${id} for the request below, calling it as few times as needed (once if you can).`,
|
|
123
|
+
"Work out its arguments from the request and the tool's description.",
|
|
124
|
+
'',
|
|
125
|
+
`Request: ${input?.trim() || '(none: call it with no arguments, or the simplest valid ones)'}`,
|
|
126
|
+
'',
|
|
127
|
+
'Then reply with what the tool returned, as it is (for long output, the part that answers the request),',
|
|
128
|
+
'and one last line with the arguments you used. If the tool fails or is not available, say so and why.',
|
|
129
|
+
].join('\n');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** What an agent is told to run a tool in its session. */
|
|
133
|
+
export const sessionMessage = (id, input) => `Use the MCP tool ${id}${input?.trim() ? ` for this: ${input.trim()}` : ''}. Show me what it returned.`;
|
|
134
|
+
|
|
135
|
+
export class Mcp {
|
|
136
|
+
constructor({ manager, homeDir = os.homedir() }) {
|
|
137
|
+
this.manager = manager;
|
|
138
|
+
this.homeDir = homeDir;
|
|
139
|
+
this.cache = new Map(); // folder -> { at, servers } | { pending }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Where the tools run: an agent's folder, or the home folder (user servers and connectors). */
|
|
143
|
+
where(ref) {
|
|
144
|
+
if (!ref || ref === 'home') return { agent: null, dir: this.homeDir };
|
|
145
|
+
const agent = this.manager.mustGet(ref);
|
|
146
|
+
return { agent, dir: agent.workdir ?? agent.planning?.dir ?? this.homeDir };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async list(ref, { refresh = false } = {}) {
|
|
150
|
+
const { agent, dir } = this.where(ref);
|
|
151
|
+
let hit = this.cache.get(dir);
|
|
152
|
+
if (refresh || !hit || (hit.at && Date.now() - hit.at > LIST_TTL_MS) || hit.error) {
|
|
153
|
+
if (!hit?.pending) {
|
|
154
|
+
const engine = ENGINES[DEFAULT_ENGINE];
|
|
155
|
+
const pending = mcpStatus({ bin: engine.bin(this.manager.config), args: engine.extraArgs(this.manager.config), cwd: dir, env: this.manager.childEnv(agent) })
|
|
156
|
+
.then((servers) => ({ at: Date.now(), servers: servers.map(serverView).sort((a, b) => a.name.localeCompare(b.name)) }))
|
|
157
|
+
.catch((e) => ({ at: Date.now(), servers: [], error: e.message }));
|
|
158
|
+
hit = { pending };
|
|
159
|
+
this.cache.set(dir, hit);
|
|
160
|
+
pending.then((r) => this.cache.set(dir, r));
|
|
161
|
+
}
|
|
162
|
+
hit = await this.cache.get(dir).pending;
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
agent: agent ? { id: agent.id, name: agent.name, engine: agent.engine ?? DEFAULT_ENGINE, running: Boolean(this.manager.runtimes.get(agent.id)?.pty) } : null,
|
|
166
|
+
dir,
|
|
167
|
+
at: new Date(hit.at).toISOString(),
|
|
168
|
+
servers: hit.servers,
|
|
169
|
+
error: hit.error ?? null,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The tool, checked against the last list for that folder. */
|
|
174
|
+
tool(dir, server, tool) {
|
|
175
|
+
const s = this.cache.get(dir)?.servers?.find((x) => x.name === server);
|
|
176
|
+
const t = s?.tools.find((x) => x.name === tool);
|
|
177
|
+
if (!t) throw Object.assign(new Error(`No tool "${tool}" on the MCP server "${server}" here; refresh the list`), { status: 404 });
|
|
178
|
+
if (s.status !== 'connected') throw Object.assign(new Error(`The MCP server "${server}" is ${s.status}`), { status: 409 });
|
|
179
|
+
return t;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Run a tool: "session" tells the agent to use it; "workspace" runs it once, apart from the session. */
|
|
183
|
+
async run(ref, { server, tool, input = '', where = 'workspace' } = {}) {
|
|
184
|
+
const { agent, dir } = this.where(ref);
|
|
185
|
+
if (!this.cache.get(dir)?.servers) await this.list(ref);
|
|
186
|
+
const t = this.tool(dir, String(server ?? ''), String(tool ?? ''));
|
|
187
|
+
input = String(input ?? '').slice(0, 8000);
|
|
188
|
+
if (where === 'session') {
|
|
189
|
+
if (!agent) throw Object.assign(new Error('Pick an agent to run it in its session'), { status: 400 });
|
|
190
|
+
if ((agent.engine ?? DEFAULT_ENGINE) !== DEFAULT_ENGINE) throw Object.assign(new Error('Running MCP tools in the session works for Claude Code agents'), { status: 409 });
|
|
191
|
+
return { where, tool: t.id, agent: this.manager.tell(agent.id, sessionMessage(t.id, input), { source: 'mcp' }) };
|
|
192
|
+
}
|
|
193
|
+
if (where !== 'workspace') throw Object.assign(new Error('where must be "session" or "workspace"'), { status: 400 });
|
|
194
|
+
const scope = { agent: agent ? this.manager.auditView(agent) : null, dir, tool: t.id, input };
|
|
195
|
+
this.manager.plugins.check('mcp.run', scope);
|
|
196
|
+
this.manager.plugins.emit('mcp.run', scope);
|
|
197
|
+
const engine = ENGINES[DEFAULT_ENGINE];
|
|
198
|
+
const t0 = Date.now();
|
|
199
|
+
const text = await this.manager.oneShot(agent, runPrompt(t.id, input), {
|
|
200
|
+
engine,
|
|
201
|
+
model: this.manager.config.explainModel,
|
|
202
|
+
tools: [t.id],
|
|
203
|
+
cwd: dir,
|
|
204
|
+
timeoutMs: RUN_TIMEOUT_MS,
|
|
205
|
+
});
|
|
206
|
+
return { where, tool: t.id, text, ms: Date.now() - t0, at: new Date().toISOString() };
|
|
207
|
+
}
|
|
208
|
+
}
|
package/src/server.js
CHANGED
|
@@ -57,6 +57,7 @@ import { BugHunts } from './bughunt.js';
|
|
|
57
57
|
import { ModuleBenchmarks } from './benchmarks.js';
|
|
58
58
|
import { Evals, readTail, stateHash } from './eval.js';
|
|
59
59
|
import { engineOf } from './engines/index.js';
|
|
60
|
+
import { Mcp } from './mcp.js';
|
|
60
61
|
import * as git from './git.js';
|
|
61
62
|
|
|
62
63
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -181,6 +182,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
181
182
|
const review = new Review({ manager });
|
|
182
183
|
// The walkthrough explains the same diff the review screen shows.
|
|
183
184
|
manager.changesSource = (id) => review.get(id);
|
|
185
|
+
const mcp = new Mcp({ manager });
|
|
184
186
|
const studio = new Studio({ manager, review });
|
|
185
187
|
const teams = new Teams({ manager, store, config });
|
|
186
188
|
const cleanup = new Cleanup({ manager, store, config, teams });
|
|
@@ -396,7 +398,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
396
398
|
const bg = (req) => req.query.background === '1' || req.body?.background === true;
|
|
397
399
|
api.post('/agents/:id/explain', wrap((req) => (bg(req) ? manager.summarizeInBackground(req.params.id, ['explain']) : manager.explain(req.params.id))));
|
|
398
400
|
api.post('/agents/:id/insights', wrap((req) => (bg(req) ? manager.summarizeInBackground(req.params.id, ['insights']) : manager.insights(req.params.id))));
|
|
399
|
-
const DOC_LIST = ['analysis', 'design', 'flow', 'proposal', 'humanai'];
|
|
401
|
+
const DOC_LIST = ['analysis', 'design', 'flow', 'proposal', 'humanai', 'estimate', 'documentation'];
|
|
400
402
|
api.post('/agents/:id/humanai/answers', wrap((req) => manager.humanAiAnswers(req.params.id, req.body?.answers, { send: req.body?.send === true })));
|
|
401
403
|
api.post(
|
|
402
404
|
'/agents/:id/docs/:kind',
|
|
@@ -955,6 +957,9 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
955
957
|
// Your action on issues: assign (starts an agent from the proposal), skip, done, remove, or null to clear.
|
|
956
958
|
api.post('/issues/action', wrap((req) => proposed.setAction(Array.isArray(req.body?.keys) ? req.body.keys.map(String) : [], req.body?.action ?? null, { until: req.body?.until ?? null })));
|
|
957
959
|
// Design docs of all agents; the same ?group= and ?format=markdown.
|
|
960
|
+
// MCP servers and their tools as Claude Code sees them in an agent's folder (or the home folder), and running one.
|
|
961
|
+
api.get('/mcp', wrap((req) => mcp.list(req.query.agent, { refresh: req.query.refresh === '1' })));
|
|
962
|
+
api.post('/mcp/run', wrap((req) => mcp.run(req.body?.agent, req.body ?? {})));
|
|
958
963
|
api.get('/designs', wrap((req) => {
|
|
959
964
|
const v = manager.designs();
|
|
960
965
|
const group = req.query.group ? String(req.query.group) : null;
|