ai-agentmanager 1.18.2 → 1.19.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 +6 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/public/app.js +25 -5
- package/public/index.html +4 -0
- package/src/backlog.js +5 -3
- package/src/brief.js +32 -6
- package/src/cli.js +26 -0
- package/src/config.js +3 -0
- package/src/drive.js +74 -0
- package/src/engines/claude.js +7 -0
- package/src/livebrowser.js +18 -0
- package/src/manager.js +66 -4
- package/src/server.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.19.0 (2026-11-05)
|
|
4
|
+
|
|
5
|
+
- **Design docs, written automatically.** Once its plan is settled, a task agent writes a short design doc and publishes it as a claude.ai Artifact; the link goes in its brief. The doc covers a summary, the architecture, the design, the data flow and the decisions and risks, with at most three small diagrams and no repeats of the spec or plan. When the work is done, the agent brings it up to date at the same link. It's on by default; untick **Design doc** on the new-agent form, use `agentmgr add --no-design-doc`, or set `"designDoc": false`. View it under **Design doc** next to Intent · Spec · Plan; it's also folded into the pull request description.
|
|
6
|
+
- **Publish to Google Drive.** One button (or `agentmgr publish <agent>`) puts all of an agent's documents in a Google Drive folder, one Google Doc each: the brief, intent, spec, plan, design doc and any documents written. It goes through your Claude account's Google Drive connector. Publishing again replaces them with the latest, moving the earlier ones to the trash.
|
|
7
|
+
- A live browser tab you open always shows the page: when the page is holding still and Chrome sends no picture, a screenshot is taken instead of leaving the view blank. Its title is fresh too.
|
|
8
|
+
|
|
3
9
|
## 1.18.2 (2026-11-05)
|
|
4
10
|
|
|
5
11
|
- **Show one project's agents.** A project picker above the agents list shows only that project's agents (**All projects** for everyone). Each browser remembers it.
|
package/README.md
CHANGED
|
@@ -399,6 +399,8 @@ Each card has at most **three points of about 12 words each**, so they're easy t
|
|
|
399
399
|
- **Explain changes** explains each change one by one: a title, what it changes, why (from the request and the conversation), the risk and what to check, in the order a reviewer should read them. Each explanation sits above its hunk, and **◀ / ▶** (or **[** and **]**) step through them, opening folded files on the way. When the agent changes the code afterwards, the page says so and **Explain again** brings it up to date. From the CLI: `agentmgr doc <agent> walkthrough`.
|
|
400
400
|
- **Commit all** commits everything in the worktree, new files included, with your git name and email.
|
|
401
401
|
- **Intent, spec and plan.** Each agent keeps INTENT.md (what was asked, written by AI Agent Manager), SPEC.md (requirements and acceptance criteria, written by the agent before it changes code) and PLAN.md (steps, ticked off as it goes) next to its brief. Open them with **Intent · Spec · Plan** or in the split view's Docs; Explain, the documents and AI review read them too. `"specs": false` in config.json stops asking agents for the spec and plan.
|
|
402
|
+
- **Design doc.** Once its plan is settled (approved, with plan review on), each task agent writes DESIGN.md next to its brief and publishes it, without waiting for you, as a **claude.ai Artifact** with the diagrams drawn (its Artifact tool). The link goes in its brief's References as **Design page**. It's short on purpose, about 300-700 words: a summary, the architecture, the design, the data flow and the decisions and risks, with at most three small diagrams and nothing repeated from the spec, plan or brief. When the work is done, the agent brings it up to date and republishes the Artifact at the same link. If the tool is missing, the agent notes it and carries on. Open it with **Design doc** next to Intent · Spec · Plan; it also goes, folded, into the pull request description. It's on by default: untick **Design doc** on the new-agent form (`agentmgr add --no-design-doc`) for small fixes, or set `"designDoc": false` in config.json.
|
|
403
|
+
- **Publish to Google Drive.** One click (or `agentmgr publish <agent>`) puts all of an agent's documents in a Google Drive folder named after it, one Google Doc each: the brief, intent, spec, plan, design doc and any documents written for it (analysis, design, flow, proposal, diagrams and so on). It goes through the Google Drive connector of your Claude account, so AI Agent Manager holds no Google credentials. The call can use only the Drive tools that create and trash files. **Google Drive ↗** opens the folder. Publishing again puts the latest versions in the same folder and moves the earlier ones to the trash, because the connector can't edit a doc's content. Mermaid diagrams stay as code in the Google Docs, with a pointer to where they're drawn.
|
|
402
404
|
- **Push & open PR** pushes the branch and opens a pull request with `gh`, against the branch the agent started from (title from your text, or from the commits; **Draft** if you like). Its description carries the intent, and the spec and plan in folded sections. With a pull request already open, it pushes to it. The pull request is linked to the agent.
|
|
403
405
|
|
|
404
406
|
The same from the API: `GET /api/agents/:id/changes`, `POST …/changes/comments`, `…/changes/commit`, `…/changes/pr`. Plugins can refuse a commit or a pull request (`agent.commit`, `agent.pr`).
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -310,9 +310,9 @@ const INSIGHT_ICONS = { why: '🎯', what: '📦', how: '🛠', now: '📍' };
|
|
|
310
310
|
const DOCS = { analysis: 'Analysis', design: 'Design', flow: 'Flow', proposal: 'Proposal', humanai: 'Human vs AI', diagrams: 'Diagrams', scorecard: 'Scorecard' };
|
|
311
311
|
// Optional extras that "Write all" leaves out.
|
|
312
312
|
const DOC_EXTRAS = new Set(['diagrams', 'scorecard']);
|
|
313
|
-
const DOC_TITLES = { ...DOCS, plan: 'Plan', intent: 'Intent', spec: 'Spec' };
|
|
313
|
+
const DOC_TITLES = { ...DOCS, plan: 'Plan', intent: 'Intent', spec: 'Spec', designdoc: 'Design doc' };
|
|
314
314
|
// The agent's intent, spec and plan files (read from the daemon when opened; kept here by agent and kind).
|
|
315
|
-
const SPEC_KINDS = { intent: 'Intent', spec: 'Spec', plan: 'Plan' };
|
|
315
|
+
const SPEC_KINDS = { intent: 'Intent', spec: 'Spec', plan: 'Plan', designdoc: 'Design doc' };
|
|
316
316
|
const specCache = new Map(); // "<agent>:<kind>" -> { markdown, at }
|
|
317
317
|
const isSpecKind = (a, kind) => Boolean(SPEC_KINDS[kind]) && !(kind === 'plan' && a?.planReview);
|
|
318
318
|
async function loadSpec(agentId, kind) {
|
|
@@ -392,16 +392,26 @@ function docButtons(a) {
|
|
|
392
392
|
return `<button class="small doc-btn ${d?.markdown ? 'has' : ''}" data-doc="${k}" ${d?.pending ? 'disabled' : ''}
|
|
393
393
|
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>`;
|
|
394
394
|
})
|
|
395
|
-
.join('')}</span>${specButtons(a)}`;
|
|
395
|
+
.join('')}</span>${specButtons(a)}${driveButton(a)}`;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Publish to Google Drive: all the agent's documents, one Google Doc each, in one folder (again: replaced). */
|
|
399
|
+
function driveButton(a) {
|
|
400
|
+
if (!a.specDocs) return '';
|
|
401
|
+
const d = a.drive ?? {};
|
|
402
|
+
const n = Object.keys(d.files ?? {}).length;
|
|
403
|
+
const tip = 'Put all of this agent\'s documents (brief, intent, spec, plan, design doc and any documents written) in a Google Drive folder, one Google Doc each, through the Google Drive connector of your Claude account. Publishing again replaces them with the latest (the earlier ones go to the trash)';
|
|
404
|
+
return `<span class="doc-buttons drive-buttons">${d.folderUrl ? `<a class="small doc-btn has" href="${esc(d.folderUrl)}" target="_blank" rel="noopener" title="${n} document${n === 1 ? '' : 's'} published ${ago(d.at)}">Google Drive ↗</a>` : ''}<button class="small doc-btn" data-act="drive" ${d.pending ? 'disabled' : ''} title="${esc(tip)}">${d.pending ? 'Publishing…' : d.folderUrl ? 'Publish again' : 'Publish to Google Drive'}</button>${d.error && !d.pending ? `<span class="hint error" title="${esc(d.error)}">Publish: ${esc(d.error.slice(0, 80))}</span>` : ''}</span>`;
|
|
396
405
|
}
|
|
397
406
|
|
|
398
407
|
/** Intent · Spec · Plan: the files kept for reviewers (and put in the pull request's description). */
|
|
399
408
|
function specButtons(a) {
|
|
400
409
|
if (!a.specDocs) return '';
|
|
401
410
|
return `<span class="doc-buttons spec-buttons" title="For reviewers, people and agents: what was asked, what done means, and the plan. Push & open PR puts them in the description">${Object.entries(SPEC_KINDS)
|
|
411
|
+
.filter(([k]) => k !== 'designdoc' || a.designDoc || a.specDocs.designdoc)
|
|
402
412
|
.map(([k, label]) => {
|
|
403
413
|
const at = a.specDocs[k] ?? (k === 'plan' ? a.planReview?.updatedAt : null);
|
|
404
|
-
return `<button class="small doc-btn ${at ? 'has' : ''}" data-doc="${k}" title="${at ? `Open ${label} (updated ${ago(at)})` : k === 'intent' ? 'Written when the agent is created' : `The agent writes it ${k === 'spec' ? 'before changing code' : 'and keeps it current'}`}">${label}${at ? ' ✓' : ''}</button>`;
|
|
414
|
+
return `<button class="small doc-btn ${at ? 'has' : ''}" data-doc="${k}" title="${at ? `Open ${label} (updated ${ago(at)})` : k === 'intent' ? 'Written when the agent is created' : k === 'designdoc' ? 'The agent writes it once its plan is settled, publishes it as an Artifact (the link is in its brief) and updates it when done' : `The agent writes it ${k === 'spec' ? 'before changing code' : 'and keeps it current'}`}">${label}${at ? ' ✓' : ''}</button>`;
|
|
405
415
|
})
|
|
406
416
|
.join('')}</span>`;
|
|
407
417
|
}
|
|
@@ -425,7 +435,7 @@ function renderDocDialog() {
|
|
|
425
435
|
} else if (d?.error) body.innerHTML = `<p class="error">Couldn't write it: ${esc(d.error)}</p>`;
|
|
426
436
|
else if (plan && !d?.markdown) body.innerHTML = '<p class="hint">The agent is investigating and hasn\'t written its plan yet. You\'ll see it here (and in the inbox) when it has.</p>';
|
|
427
437
|
else if (specKind && !d?.loaded) body.innerHTML = '<p class="hint">Loading…</p>';
|
|
428
|
-
else if (specKind && !d?.markdown) body.innerHTML = `<p class="hint">${docView.kind === 'intent' ? 'No intent file for this agent (agents created before 1.9 have none).' : `The agent hasn't written its ${label.toLowerCase()} yet. It writes ${docView.kind === 'spec' ? 'the spec before changing code' : 'the plan and keeps it current'}.`}</p>`;
|
|
438
|
+
else if (specKind && !d?.markdown) body.innerHTML = `<p class="hint">${docView.kind === 'intent' ? 'No intent file for this agent (agents created before 1.9 have none).' : `The agent hasn't written its ${label.toLowerCase()} yet. It writes ${docView.kind === 'spec' ? 'the spec before changing code' : docView.kind === 'designdoc' ? 'the design doc once its plan is settled and publishes it as an Artifact' : 'the plan and keeps it current'}.`}</p>`;
|
|
429
439
|
else if (d?.markdown) {
|
|
430
440
|
// The scorecard's Improve button follows the agent being improved.
|
|
431
441
|
const version = docView.kind === 'scorecard' ? `${d.at}:${Boolean(a.improving)}` : d.at;
|
|
@@ -3484,6 +3494,14 @@ $('#detail-body').addEventListener('click', async (e) => {
|
|
|
3484
3494
|
btn.textContent = 'Reviewing…';
|
|
3485
3495
|
act(async () => upsert(await api('POST', `/agents/${a.id}/review`)));
|
|
3486
3496
|
break;
|
|
3497
|
+
case 'drive':
|
|
3498
|
+
btn.disabled = true;
|
|
3499
|
+
btn.textContent = 'Publishing…';
|
|
3500
|
+
act(async () => {
|
|
3501
|
+
upsert(await api('POST', `/agents/${a.id}/drive`));
|
|
3502
|
+
toast('Publishing to Google Drive: the documents appear in its folder in a minute or two');
|
|
3503
|
+
});
|
|
3504
|
+
break;
|
|
3487
3505
|
case 'explain':
|
|
3488
3506
|
btn.disabled = true;
|
|
3489
3507
|
btn.textContent = 'Explaining…';
|
|
@@ -3795,6 +3813,7 @@ $('#new-form').addEventListener('submit', async (e) => {
|
|
|
3795
3813
|
...containerChoice(e.target),
|
|
3796
3814
|
plan: Boolean(f.get('plan')),
|
|
3797
3815
|
planReview: Boolean(f.get('planReview')),
|
|
3816
|
+
designDoc: Boolean(f.get('designDoc')),
|
|
3798
3817
|
priority: Number(f.get('priority')),
|
|
3799
3818
|
});
|
|
3800
3819
|
dialog.close();
|
|
@@ -3823,6 +3842,7 @@ $('#new-form').addEventListener('submit', async (e) => {
|
|
|
3823
3842
|
project: f.get('project') || undefined,
|
|
3824
3843
|
plan: Boolean(f.get('plan')),
|
|
3825
3844
|
planReview: Boolean(f.get('planReview')),
|
|
3845
|
+
designDoc: Boolean(f.get('designDoc')),
|
|
3826
3846
|
start: Boolean(f.get('start')),
|
|
3827
3847
|
...containerChoice(e.target),
|
|
3828
3848
|
});
|
package/public/index.html
CHANGED
|
@@ -269,6 +269,10 @@
|
|
|
269
269
|
<input type="checkbox" name="planReview" />
|
|
270
270
|
Review the implementation plan first <span class="hint">(the agent writes a plan and waits for your approval before changing anything)</span>
|
|
271
271
|
</label>
|
|
272
|
+
<label class="check">
|
|
273
|
+
<input type="checkbox" name="designDoc" checked />
|
|
274
|
+
Design doc <span class="hint">(after the plan: architecture, design and data flow, viewable here and published as an Artifact; updated when done)</span>
|
|
275
|
+
</label>
|
|
272
276
|
<div class="row when">
|
|
273
277
|
<label class="check"><input type="radio" name="when" value="now" checked /> Start now</label>
|
|
274
278
|
<label class="check"><input type="radio" name="when" value="backlog" /> Queue in backlog</label>
|
package/src/backlog.js
CHANGED
|
@@ -104,7 +104,7 @@ export class Backlog extends EventEmitter {
|
|
|
104
104
|
// ------------------------------------------------------------ editing
|
|
105
105
|
|
|
106
106
|
/** Queue one item per title. Options are what an agent would take (repo, dir, base, project, ...). */
|
|
107
|
-
add(titles, { repo, dir, base, project, worktree, permissionMode, model, plan, planReview, engine, attachments, isolation, priority = 2 } = {}) {
|
|
107
|
+
add(titles, { repo, dir, base, project, worktree, permissionMode, model, plan, planReview, designDoc, engine, attachments, isolation, priority = 2 } = {}) {
|
|
108
108
|
const list = titles.map((t) => String(t ?? '').trim()).filter(Boolean);
|
|
109
109
|
if (!list.length) throw err(400, 'At least one item is required');
|
|
110
110
|
const pr = parsePriority(priority);
|
|
@@ -141,6 +141,7 @@ export class Backlog extends EventEmitter {
|
|
|
141
141
|
isolation: isolation === undefined ? undefined : isolation || '',
|
|
142
142
|
plan: Boolean(plan),
|
|
143
143
|
planReview: planReview ?? null,
|
|
144
|
+
designDoc: designDoc ?? null,
|
|
144
145
|
priority: pr,
|
|
145
146
|
order: order + i,
|
|
146
147
|
status: 'queued',
|
|
@@ -251,6 +252,7 @@ export class Backlog extends EventEmitter {
|
|
|
251
252
|
isolation: it.isolation,
|
|
252
253
|
plan: it.plan,
|
|
253
254
|
planReview: it.planReview ?? undefined,
|
|
255
|
+
designDoc: it.designDoc ?? undefined,
|
|
254
256
|
priority: it.priority,
|
|
255
257
|
name: undefined,
|
|
256
258
|
});
|
|
@@ -397,8 +399,8 @@ export class Backlog extends EventEmitter {
|
|
|
397
399
|
if (it.status !== 'queued') throw err(409, 'Only queued items can be split');
|
|
398
400
|
const titles = (Array.isArray(parts) ? parts : it.aiSplit?.parts ?? []).map((t) => String(t).trim()).filter(Boolean);
|
|
399
401
|
if (titles.length < 2) throw err(400, 'Give at least two parts');
|
|
400
|
-
const { repo, dir, base, project, worktree, permissionMode, model, plan, planReview, engine, priority } = it;
|
|
401
|
-
const added = this.add(titles, { repo, dir, base, project, worktree, permissionMode, model, plan, planReview, engine, priority });
|
|
402
|
+
const { repo, dir, base, project, worktree, permissionMode, model, plan, planReview, designDoc, engine, priority } = it;
|
|
403
|
+
const added = this.add(titles, { repo, dir, base, project, worktree, permissionMode, model, plan, planReview, designDoc, engine, priority });
|
|
402
404
|
this.manager.judge?.feedback('dispatch', { summary: `split "${it.title}"`, verdict: it.aiSplit ? 'split suggested' : 'not suggested', outcome: 'split it' });
|
|
403
405
|
delete this.data.items[id];
|
|
404
406
|
this.changed();
|
package/src/brief.js
CHANGED
|
@@ -668,7 +668,9 @@ export const INTENT_FILE = 'INTENT.md';
|
|
|
668
668
|
export const SPEC_FILE = 'SPEC.md';
|
|
669
669
|
export const intentPath = (agentId) => path.join(briefDir(agentId), INTENT_FILE);
|
|
670
670
|
export const specPath = (agentId) => path.join(briefDir(agentId), SPEC_FILE);
|
|
671
|
-
export const
|
|
671
|
+
export const DESIGN_FILE = 'DESIGN.md';
|
|
672
|
+
export const designPath = (agentId) => path.join(briefDir(agentId), DESIGN_FILE);
|
|
673
|
+
export const SPEC_DOCS = { intent: intentPath, spec: specPath, plan: planPath, designdoc: designPath };
|
|
672
674
|
|
|
673
675
|
/** INTENT.md: the request as given, and where it came from. */
|
|
674
676
|
export function intentMarkdown(agent) {
|
|
@@ -698,7 +700,31 @@ export const specPrompt = (specFile, planFile, { withPlan = true } = {}) =>
|
|
|
698
700
|
: 'Keep it current if the requirements change (say why). ') +
|
|
699
701
|
'Both files are outside the repository: never copy them into the repo or commit them.';
|
|
700
702
|
|
|
701
|
-
/**
|
|
703
|
+
/**
|
|
704
|
+
* The agent's instructions for DESIGN.md: a short design doc once the plan is settled, published as a
|
|
705
|
+
* claude.ai Artifact with the agent's own tool, and brought up to date when it's done. (Google Drive
|
|
706
|
+
* is the person's choice: Publish to Google Drive takes all the agent's documents there.)
|
|
707
|
+
*/
|
|
708
|
+
export const designDocPrompt = (file, { afterApproval = false } = {}) =>
|
|
709
|
+
`Once your plan is settled${afterApproval ? ' and approved' : ''}, before most of the code changes, write a design doc to ${file} (Markdown) and publish it. ` +
|
|
710
|
+
'Keep it precise and simple, about 300-700 words: architecture, design and data flow only. Do not repeat the spec, plan or brief, ' +
|
|
711
|
+
'and no filler, history or restated requirements. Use these sections:\n' +
|
|
712
|
+
'# Design: <short name>\n## Summary\nTwo or three sentences: what is built and the key decision.\n' +
|
|
713
|
+
'## Architecture\nOne ```mermaid flowchart of the components and how they connect, with what this work adds or changes marked; then a few bullets.\n' +
|
|
714
|
+
'## Design\nThe components, interfaces and data that change, as short bullets. Add one classDiagram or erDiagram only if types or data change in a way bullets cannot show.\n' +
|
|
715
|
+
'## Data flow\nOne ```mermaid flowchart LR or sequenceDiagram of the main path.\n' +
|
|
716
|
+
'## Decisions and risks\nBullets: what was chosen over what and why; the main risks.\n' +
|
|
717
|
+
'Diagrams: valid Mermaid, at most about 12 nodes each, short labels (quote labels with punctuation).\n' +
|
|
718
|
+
'Always write and publish it, even for a small or one-line change (then keep it short); this is not optional and not your call to skip. ' +
|
|
719
|
+
'Publish it without asking, and without waiting for the user, as a claude.ai Artifact with your Artifact tool: a page that renders ' +
|
|
720
|
+
'the Markdown and draws the Mermaid diagrams. Then add its link to the References section of your brief (add the section if it is not there): ' +
|
|
721
|
+
'"- **Design page**: [Artifact](<url>)". Do not publish it anywhere else; the user publishes to Google Drive from AI Agent Manager.\n' +
|
|
722
|
+
`When the work is done, before you set the brief's status to done, bring ${file} up to date with what was actually built (same length limits) ` +
|
|
723
|
+
'and republish the Artifact to the same URL. If the Artifact tool is missing or fails, say so in one line instead of the link ' +
|
|
724
|
+
'("- **Design page**: not published: <why>"; only for a missing or failing tool, never because the change is small) and carry on; never hold up the task for it. ' +
|
|
725
|
+
'The file is outside the repository: never copy it into the repo or commit it.';
|
|
726
|
+
|
|
727
|
+
/** One of the agent's files (intent, spec, plan, design doc): its Markdown and when it changed, or null. */
|
|
702
728
|
export function readSpecDoc(agentId, name) {
|
|
703
729
|
const file = SPEC_DOCS[name]?.(agentId);
|
|
704
730
|
if (!file) return null;
|
|
@@ -721,17 +747,17 @@ export function specDocsInfo(agentId) {
|
|
|
721
747
|
return out;
|
|
722
748
|
}
|
|
723
749
|
|
|
724
|
-
/** The pull request description's sections: the intent in full, the spec and
|
|
750
|
+
/** The pull request description's sections: the intent in full, the spec, plan and design doc folded. */
|
|
725
751
|
export function prSections(agentId, read = (n) => readSpecDoc(agentId, n)?.markdown) {
|
|
726
752
|
const doc = (n) => read(n)?.trim();
|
|
727
753
|
// Demote the files' own headings under the description's.
|
|
728
|
-
const demote = (md) => md.replace(/^(#{1,4}) /gm, '#$1 ').replace(/^## (Intent|Spec|Plan): .*\n+/m, '');
|
|
754
|
+
const demote = (md) => md.replace(/^(#{1,4}) /gm, '#$1 ').replace(/^## (Intent|Spec|Plan|Design): .*\n+/m, '');
|
|
729
755
|
const parts = [];
|
|
730
756
|
const intent = doc('intent');
|
|
731
757
|
if (intent) parts.push('## Intent', '', demote(intent), '');
|
|
732
|
-
for (const [name, label] of [['spec', 'Spec'], ['plan', 'Plan']]) {
|
|
758
|
+
for (const [name, label] of [['spec', 'Spec'], ['plan', 'Plan'], ['designdoc', 'Design']]) {
|
|
733
759
|
const md = doc(name);
|
|
734
760
|
if (md) parts.push(`<details><summary><b>${label}</b></summary>`, '', demote(md), '', '</details>', '');
|
|
735
761
|
}
|
|
736
|
-
return parts.length ? [...parts,
|
|
762
|
+
return parts.length ? [...parts, `<sub>Intent, spec${doc('designdoc') ? ', plan and design doc' : ' and plan'} kept by AI Agent Manager.</sub>`].join('\n') : '';
|
|
737
763
|
}
|
package/src/cli.js
CHANGED
|
@@ -346,6 +346,7 @@ export async function main(argv) {
|
|
|
346
346
|
.option('--container', 'run each agent in its own Docker container (see agentmgr sandbox)')
|
|
347
347
|
.option('--no-container', 'run on this computer even if containers are the default')
|
|
348
348
|
.option('--plan', 'while a repo URL clones, plan the task with Claude (moves into the repo when ready)')
|
|
349
|
+
.option('--no-design-doc', 'no design doc for this agent (on by default: "designDoc" in config.json)')
|
|
349
350
|
.option('--no-start', 'create without launching')
|
|
350
351
|
.option('-a, --attach', 'attach to the agent after launch (single intent only)')
|
|
351
352
|
.action(async (intents, opts, cmd) => {
|
|
@@ -372,6 +373,7 @@ export async function main(argv) {
|
|
|
372
373
|
engine: opts.engine,
|
|
373
374
|
start: opts.start,
|
|
374
375
|
plan: opts.plan,
|
|
376
|
+
designDoc: cmd.getOptionValueSource('designDoc') === 'cli' ? opts.designDoc : undefined,
|
|
375
377
|
});
|
|
376
378
|
for (const a of created) console.log(`${green('+')} ${bold(a.name)} ${dim(a.id)} session ${cyan(a.sessionId)}`);
|
|
377
379
|
console.log(dim(`Workspace setup and launch continue in the background. "agentmgr ls" shows status.`));
|
|
@@ -2171,6 +2173,30 @@ export async function main(argv) {
|
|
|
2171
2173
|
console.log(`${green('✓')} ${action === 'later' ? 'reminding you later about' : 'no reminder until it is used again for'} ${a.name}`);
|
|
2172
2174
|
});
|
|
2173
2175
|
|
|
2176
|
+
program
|
|
2177
|
+
.command('publish')
|
|
2178
|
+
.description("Put all of an agent's documents in Google Drive: one folder, one Google Doc each (again: replaced with the latest)")
|
|
2179
|
+
.argument('<agent>')
|
|
2180
|
+
.action(async (ref) => {
|
|
2181
|
+
await daemon();
|
|
2182
|
+
const a = await resolveAgent(ref);
|
|
2183
|
+
await api('POST', `/agents/${a.id}/drive`);
|
|
2184
|
+
process.stdout.write(dim('Publishing to Google Drive (through your Claude account)…'));
|
|
2185
|
+
let d;
|
|
2186
|
+
for (let i = 0; i < 300; i++) {
|
|
2187
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
2188
|
+
d = (await api('GET', `/agents/${a.id}`)).drive;
|
|
2189
|
+
if (!d?.pending) break;
|
|
2190
|
+
process.stdout.write(dim('.'));
|
|
2191
|
+
}
|
|
2192
|
+
console.log('');
|
|
2193
|
+
if (d?.pending) return console.log(dim('Still publishing; "agentmgr show" has the link when it is done.'));
|
|
2194
|
+
if (!d?.folderUrl) throw new Error(d?.error ?? 'Publishing failed');
|
|
2195
|
+
console.log(`${green('✓')} ${Object.keys(d.files ?? {}).length} document(s) in ${cyan(d.folderUrl)}`);
|
|
2196
|
+
for (const f of Object.values(d.files ?? {})) console.log(` ${f.title} ${dim(f.url)}`);
|
|
2197
|
+
if (d.error) console.log(dim(`Note: ${d.error}`));
|
|
2198
|
+
});
|
|
2199
|
+
|
|
2174
2200
|
program
|
|
2175
2201
|
.command('rm')
|
|
2176
2202
|
.description('Forget agents (optionally deleting worktrees agentmgr created)')
|
package/src/config.js
CHANGED
|
@@ -65,6 +65,9 @@ const DEFAULTS = {
|
|
|
65
65
|
// A planning session moves into the repo by itself once Claude has been idle this
|
|
66
66
|
// long (and, with its terminal open, you haven't typed for 15 seconds).
|
|
67
67
|
handoffIdleSec: 5,
|
|
68
|
+
// Task agents write a short design doc once their plan is settled and publish it as a claude.ai
|
|
69
|
+
// Artifact, updated when the work is done. Per agent: designDoc. (Publish to Google Drive is a button.)
|
|
70
|
+
designDoc: true,
|
|
68
71
|
// The AI judge (stuck, idle screens, reviews); see JUDGE_DEFAULTS in judge.js for every field.
|
|
69
72
|
judge: { enabled: true },
|
|
70
73
|
// Clean up old agents: "close-delete", "close" (delete by hand), "manual" or "off"; see cleanup.js.
|
package/src/drive.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Publishing an agent's documents to Google Drive: one folder per agent, one Google Doc per document.
|
|
2
|
+
// It goes through the Google Drive connector of the person's Claude account (a headless Claude call
|
|
3
|
+
// that may use only the two Drive tools below), so AI Agent Manager holds no Google credentials.
|
|
4
|
+
// The connector can create files but not change their content: publishing again creates new
|
|
5
|
+
// versions and moves the earlier ones to the trash.
|
|
6
|
+
import { marked } from 'marked';
|
|
7
|
+
|
|
8
|
+
export const DRIVE_TOOLS = ['mcp__claude_ai_Google_Drive__create_file', 'mcp__claude_ai_Google_Drive__trash_file'];
|
|
9
|
+
export const DRIVE_PROMPT_START = 'Publish documents to Google Drive';
|
|
10
|
+
|
|
11
|
+
export const docUrl = (id) => `https://docs.google.com/document/d/${encodeURIComponent(id)}/edit`;
|
|
12
|
+
export const folderUrl = (id) => `https://drive.google.com/drive/folders/${encodeURIComponent(id)}`;
|
|
13
|
+
|
|
14
|
+
/** What gets published, in folder order: the agent's files, then any documents written for it. */
|
|
15
|
+
export const DRIVE_DOCS = [
|
|
16
|
+
['brief', 'Brief'],
|
|
17
|
+
['intent', 'Intent'],
|
|
18
|
+
['spec', 'Spec'],
|
|
19
|
+
['plan', 'Plan'],
|
|
20
|
+
['designdoc', 'Design doc'],
|
|
21
|
+
['analysis', 'Analysis'],
|
|
22
|
+
['design', 'Design'],
|
|
23
|
+
['flow', 'Flow'],
|
|
24
|
+
['proposal', 'Proposal'],
|
|
25
|
+
['diagrams', 'Diagrams'],
|
|
26
|
+
['walkthrough', 'Change walkthrough'],
|
|
27
|
+
['scorecard', 'Review scorecard'],
|
|
28
|
+
['humanai', 'Human vs AI'],
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const escHtml = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
|
32
|
+
|
|
33
|
+
/** A document as HTML that Google Drive converts to a Google Doc (Mermaid stays as code, with a pointer to where it's drawn). */
|
|
34
|
+
export function driveHtml(title, markdown, { designPage } = {}) {
|
|
35
|
+
const body = marked.parse(String(markdown ?? ''), { async: false });
|
|
36
|
+
const drawn = /```\s*mermaid/i.test(markdown)
|
|
37
|
+
? `<p><i>Diagrams are in Mermaid below; see them drawn in AI Agent Manager${designPage ? ` or on the <a href="${escHtml(designPage)}">design page</a>` : ''}.</i></p>`
|
|
38
|
+
: '';
|
|
39
|
+
return `<html><head><meta charset="utf-8"><title>${escHtml(title)}</title></head><body>${drawn}${body}</body></html>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The instructions for the headless call that does the publishing. */
|
|
43
|
+
export function drivePrompt({ folderTitle, folderId, docs, trash }) {
|
|
44
|
+
return [
|
|
45
|
+
`${DRIVE_PROMPT_START} with your Google Drive tools. Do exactly this, without asking:`,
|
|
46
|
+
folderId
|
|
47
|
+
? `1. Folder: use the existing folder with id "${folderId}". Only if creating a file in it fails because it is gone, create a new folder as below and use that.`
|
|
48
|
+
: '1. Folder: create one with create_file: no content, mime type application/vnd.google-apps.folder,',
|
|
49
|
+
` title "${folderTitle}".`,
|
|
50
|
+
'2. For each <document> below, call create_file once: parentId = the folder id, title = its title attribute,',
|
|
51
|
+
' contentMimeType "text/html", textContent = the HTML inside the tag exactly as given. Do not edit, shorten or reformat it.',
|
|
52
|
+
trash.length
|
|
53
|
+
? `3. Then, for each earlier version below whose document you created again in step 2, move it to the trash with trash_file:\n${trash.map((t) => ` - ${t.key}: ${t.id}`).join('\n')}`
|
|
54
|
+
: '3. There are no earlier versions to trash.',
|
|
55
|
+
'4. Reply with only this JSON, no prose and no code fence:',
|
|
56
|
+
' {"folderId": "<folder id>", "files": [{"key": "<key attribute>", "id": "<new file id>"}], "trashed": ["<id>"], "errors": ["<what failed and why>"]}',
|
|
57
|
+
'',
|
|
58
|
+
...docs.map((d) => `<document key="${d.key}" title="${escHtml(d.title)}">\n${d.html}\n</document>`),
|
|
59
|
+
].join('\n');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const ID = /^[\w-]{6,200}$/;
|
|
63
|
+
|
|
64
|
+
/** The reply, checked: only ids that look like Drive ids, only for documents that were sent. */
|
|
65
|
+
export function parseDrive(reply, keys) {
|
|
66
|
+
const m = String(reply ?? '').match(/\{[\s\S]*\}/);
|
|
67
|
+
if (!m) throw new Error(`No result from the Google Drive publish: ${String(reply ?? '').trim().slice(0, 200)}`);
|
|
68
|
+
const data = JSON.parse(m[0]);
|
|
69
|
+
const folderId = ID.test(data.folderId ?? '') ? data.folderId : null;
|
|
70
|
+
const files = {};
|
|
71
|
+
for (const f of Array.isArray(data.files) ? data.files : []) if (keys.includes(f?.key) && ID.test(f?.id ?? '')) files[f.key] = f.id;
|
|
72
|
+
const strings = (a) => (Array.isArray(a) ? a.map(String).filter(Boolean).slice(0, 50) : []);
|
|
73
|
+
return { folderId, files, trashed: strings(data.trashed).filter((id) => ID.test(id)), errors: strings(data.errors).map((e) => e.slice(0, 300)) };
|
|
74
|
+
}
|
package/src/engines/claude.js
CHANGED
|
@@ -112,6 +112,13 @@ export default {
|
|
|
112
112
|
return args;
|
|
113
113
|
},
|
|
114
114
|
|
|
115
|
+
/** A one-shot call that may use only these connector (MCP) tools: none of Claude Code's own. */
|
|
116
|
+
connectorArgs: (config, { model, tools } = {}) => {
|
|
117
|
+
const args = ['-p', '--tools', '', '--allowedTools', tools.join(','), '--no-session-persistence', '--output-format', 'text'];
|
|
118
|
+
if (model) args.push('--model', model);
|
|
119
|
+
return args;
|
|
120
|
+
},
|
|
121
|
+
|
|
115
122
|
/** Variables a nested Claude session would otherwise inherit from a parent one. */
|
|
116
123
|
stripEnv: ['CLAUDECODE', 'CLAUDE_CODE_CHILD_SESSION', 'CLAUDE_CODE_ENTRYPOINT'],
|
|
117
124
|
};
|
package/src/livebrowser.js
CHANGED
|
@@ -407,7 +407,10 @@ export class LiveBrowser extends EventEmitter {
|
|
|
407
407
|
client.send({ t: 'state', url: tab.url, title: tab.title, viewport: tab.viewport });
|
|
408
408
|
if (tab.frame) client.send(tab.frame);
|
|
409
409
|
// Restart the stream so the newcomer gets a fresh frame (Chrome only sends on changes).
|
|
410
|
+
const asked = Date.now();
|
|
410
411
|
await this.cast(tab, true).catch(() => {});
|
|
412
|
+
this.refresh(tab).catch(() => {}); // the title may have changed while nobody watched
|
|
413
|
+
this.firstFrame(tab, client, asked);
|
|
411
414
|
return () => {
|
|
412
415
|
tab.clients.delete(client);
|
|
413
416
|
tab.lastSeen = Date.now();
|
|
@@ -415,6 +418,19 @@ export class LiveBrowser extends EventEmitter {
|
|
|
415
418
|
};
|
|
416
419
|
}
|
|
417
420
|
|
|
421
|
+
/**
|
|
422
|
+
* A page holding still may never paint for the restarted stream (slow machines,
|
|
423
|
+
* a tab in the background): if no frame came, take one, retrying while it loads.
|
|
424
|
+
*/
|
|
425
|
+
firstFrame(tab, client, asked, tries = 3) {
|
|
426
|
+
setTimeout(() => {
|
|
427
|
+
if (!tab.clients.has(client) || (tab.frameAt ?? 0) >= asked) return;
|
|
428
|
+
this.sharpen(tab).catch(() => {}).finally(() => {
|
|
429
|
+
if (tries > 1) this.firstFrame(tab, client, asked, tries - 1);
|
|
430
|
+
});
|
|
431
|
+
}, 1000);
|
|
432
|
+
}
|
|
433
|
+
|
|
418
434
|
push(tab, msg) {
|
|
419
435
|
for (const c of tab.clients) c.send(msg);
|
|
420
436
|
}
|
|
@@ -557,6 +573,7 @@ export class LiveBrowser extends EventEmitter {
|
|
|
557
573
|
if (Date.now() - (tab.sharpenedAt ?? 0) < 400) return;
|
|
558
574
|
const m = params.metadata;
|
|
559
575
|
tab.frame = { t: 'frame', d: params.data, w: m.deviceWidth, h: m.deviceHeight };
|
|
576
|
+
tab.frameAt = Date.now();
|
|
560
577
|
this.push(tab, tab.frame);
|
|
561
578
|
// Moving frames are compressed for speed; once the page holds still, send a sharp one.
|
|
562
579
|
clearTimeout(tab.sharpen);
|
|
@@ -611,6 +628,7 @@ export class LiveBrowser extends EventEmitter {
|
|
|
611
628
|
const { data } = await this.cdp.send('Page.captureScreenshot', { format: 'jpeg', quality: 90 }, tab.sessionId);
|
|
612
629
|
tab.sharpenedAt = Date.now();
|
|
613
630
|
tab.frame = { t: 'frame', d: data, w: tab.viewport.width, h: tab.viewport.height, sharp: true };
|
|
631
|
+
tab.frameAt = Date.now();
|
|
614
632
|
this.push(tab, tab.frame);
|
|
615
633
|
}
|
|
616
634
|
|
package/src/manager.js
CHANGED
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
specPrompt,
|
|
38
38
|
planPath,
|
|
39
39
|
planReviewPrompt,
|
|
40
|
+
designPath,
|
|
41
|
+
designDocPrompt,
|
|
40
42
|
} from './brief.js';
|
|
41
43
|
|
|
42
44
|
// One-off summaries / documents built from an agent's live context.
|
|
@@ -116,6 +118,7 @@ import { learnCommand, memoryKey, memoryPrompt, memoryText } from './memory.js';
|
|
|
116
118
|
import { Rules, describeTool } from './rules.js';
|
|
117
119
|
import { runningClaude, scanClaudeSessions } from './sessions.js';
|
|
118
120
|
import { builderAllowedTools, builderPrompt } from './builder.js';
|
|
121
|
+
import { DRIVE_DOCS, DRIVE_TOOLS, docUrl, driveHtml, drivePrompt, folderUrl, parseDrive } from './drive.js';
|
|
119
122
|
import {
|
|
120
123
|
bugFromRef,
|
|
121
124
|
extractRefs,
|
|
@@ -596,6 +599,7 @@ export class AgentManager extends EventEmitter {
|
|
|
596
599
|
start = true,
|
|
597
600
|
plan = false,
|
|
598
601
|
planReview,
|
|
602
|
+
designDoc,
|
|
599
603
|
project,
|
|
600
604
|
priority,
|
|
601
605
|
workspace,
|
|
@@ -680,6 +684,8 @@ export class AgentManager extends EventEmitter {
|
|
|
680
684
|
// Review the implementation plan before the agent implements it: null = no review.
|
|
681
685
|
// Team members get their review from the team instead.
|
|
682
686
|
planReview: !general && !team && !builds && (planReview ?? this.config.planReview ?? false) ? { status: 'writing' } : null,
|
|
687
|
+
// Write and publish a design doc (Google Doc + Artifact) after the plan, updated at the end.
|
|
688
|
+
designDoc: !general && !team && !builds && Boolean(designDoc ?? this.config.designDoc ?? true),
|
|
683
689
|
status: 'preparing',
|
|
684
690
|
desired: start ? 'running' : 'stopped',
|
|
685
691
|
error: null,
|
|
@@ -753,7 +759,7 @@ export class AgentManager extends EventEmitter {
|
|
|
753
759
|
/** One of an agent's intent, spec and plan files. */
|
|
754
760
|
specDoc(ref, name) {
|
|
755
761
|
const agent = this.mustGet(ref);
|
|
756
|
-
if (!['intent', 'spec', 'plan'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec or
|
|
762
|
+
if (!['intent', 'spec', 'plan', 'designdoc'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec, plan or designdoc)'), { status: 400 });
|
|
757
763
|
return readSpecDoc(agent.id, name) ?? { name, markdown: null };
|
|
758
764
|
}
|
|
759
765
|
|
|
@@ -1071,6 +1077,12 @@ export class AgentManager extends EventEmitter {
|
|
|
1071
1077
|
writableDir ??= path.dirname(file);
|
|
1072
1078
|
prompts.push(agent.planReview.status === 'approved' ? planApprovedPrompt(file) : planReviewPrompt(file));
|
|
1073
1079
|
}
|
|
1080
|
+
if (agent.designDoc && task && !planning) {
|
|
1081
|
+
fs.mkdirSync(briefDir(agent.id), { recursive: true });
|
|
1082
|
+
const file = path.join(fs.realpathSync(briefDir(agent.id)), path.basename(designPath(agent.id)));
|
|
1083
|
+
writableDir ??= path.dirname(file);
|
|
1084
|
+
prompts.push(designDocPrompt(file, { afterApproval: Boolean(agent.planReview) }));
|
|
1085
|
+
}
|
|
1074
1086
|
if (planning) prompts.push(planningPrompt(agent));
|
|
1075
1087
|
// What earlier agents learned in this repo, and the one command to add to it.
|
|
1076
1088
|
let allowedTools = null;
|
|
@@ -2242,11 +2254,14 @@ export class AgentManager extends EventEmitter {
|
|
|
2242
2254
|
}
|
|
2243
2255
|
|
|
2244
2256
|
/** One tool-less, read-only call to an engine; resolves to its text output. */
|
|
2245
|
-
oneShot(agent, text, { engine, model, timeoutMs = 300_000 }) {
|
|
2257
|
+
oneShot(agent, text, { engine, model, timeoutMs = 300_000, tools }) {
|
|
2246
2258
|
// Some engines take the prompt as an argument instead of on stdin, and some need their extra
|
|
2247
|
-
// arguments after a subcommand (oneShotExtra: they place them).
|
|
2259
|
+
// arguments after a subcommand (oneShotExtra: they place them). `tools`: Claude Code only, a
|
|
2260
|
+
// call that may use just these connector tools (and none of its own).
|
|
2248
2261
|
const extra = engine.extraArgs(this.config);
|
|
2249
|
-
const args =
|
|
2262
|
+
const args = tools
|
|
2263
|
+
? [...extra, ...engine.connectorArgs(this.config, { model, tools })]
|
|
2264
|
+
: engine.oneShotExtra ? engine.oneShotArgs(this.config, { model, prompt: text, extra }) : [...extra, ...engine.oneShotArgs(this.config, { model, prompt: text })];
|
|
2250
2265
|
return new Promise((resolve, reject) => {
|
|
2251
2266
|
const child = spawn(engine.bin(this.config), args, { cwd: paths.home, env: this.childEnv(agent), stdio: ['pipe', 'pipe', 'pipe'] });
|
|
2252
2267
|
let out = '';
|
|
@@ -2349,12 +2364,59 @@ export class AgentManager extends EventEmitter {
|
|
|
2349
2364
|
return this.view(this.patch(agent.id, { improving: { from: doc.data.overall, at: now(), briefAt: agent.brief?.updatedAt ?? null } }));
|
|
2350
2365
|
}
|
|
2351
2366
|
|
|
2367
|
+
/** Every document this agent has, for publishing: its brief and files, then the documents written for it. */
|
|
2368
|
+
driveDocuments(agent) {
|
|
2369
|
+
const file = (name) => readSpecDoc(agent.id, name)?.markdown;
|
|
2370
|
+
const md = {
|
|
2371
|
+
brief: fs.existsSync(briefPath(agent.id)) ? fs.readFileSync(briefPath(agent.id), 'utf8') : null,
|
|
2372
|
+
intent: file('intent'),
|
|
2373
|
+
spec: file('spec'),
|
|
2374
|
+
plan: file('plan') ?? agent.planReview?.markdown,
|
|
2375
|
+
designdoc: file('designdoc'),
|
|
2376
|
+
};
|
|
2377
|
+
return DRIVE_DOCS.map(([key, label]) => ({ key, label, markdown: (md[key] ?? (key in md ? null : agent.docs?.[key]?.markdown))?.trim() })).filter((d) => d.markdown);
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
/**
|
|
2381
|
+
* Publish all of an agent's documents to Google Drive (one folder, one Google Doc each) through the
|
|
2382
|
+
* Google Drive connector of the Claude account. Again: new versions, the earlier ones to the trash.
|
|
2383
|
+
* Returns at once; the result (or error) lands on the agent as `drive`.
|
|
2384
|
+
*/
|
|
2385
|
+
publishToDrive(ref) {
|
|
2386
|
+
const agent = this.mustGet(ref);
|
|
2387
|
+
if (NO_REPO.has(agent.kind)) throw Object.assign(new Error('Only task agents have documents to publish'), { status: 400 });
|
|
2388
|
+
if (agent.drive?.pending) return this.view(agent);
|
|
2389
|
+
const docs = this.driveDocuments(agent);
|
|
2390
|
+
if (!docs.length) throw Object.assign(new Error('Nothing written yet: no brief, spec, plan or documents to publish'), { status: 409 });
|
|
2391
|
+
this.patch(agent.id, { drive: { ...agent.drive, pending: true, error: null } });
|
|
2392
|
+
(async () => {
|
|
2393
|
+
const prev = this.store.get(agent.id)?.drive ?? {};
|
|
2394
|
+
const designPage = agent.brief?.references?.find((r) => /design page/i.test(r.label))?.url ?? null;
|
|
2395
|
+
const sent = docs.map((d) => ({ key: d.key, title: `${d.label}: ${agent.name}`, html: driveHtml(`${d.label}: ${agent.name}`, d.markdown, { designPage }) }));
|
|
2396
|
+
const trash = sent.filter((d) => prev.files?.[d.key]?.id).map((d) => ({ key: d.key, id: prev.files[d.key].id }));
|
|
2397
|
+
const prompt = drivePrompt({ folderTitle: `${agent.name} (AI Agent Manager)`, folderId: prev.folderId ?? null, docs: sent, trash });
|
|
2398
|
+
const reply = await this.oneShot(agent, prompt, { engine: engineOf('claude'), tools: DRIVE_TOOLS, timeoutMs: 600_000 });
|
|
2399
|
+
const r = parseDrive(reply, sent.map((d) => d.key));
|
|
2400
|
+
if (!r.folderId || !Object.keys(r.files).length) throw new Error(r.errors[0] ?? 'Google Drive returned no documents (is the Google Drive connector linked to your Claude account?)');
|
|
2401
|
+
const at = now();
|
|
2402
|
+
const files = { ...(r.folderId === prev.folderId ? prev.files : {}) };
|
|
2403
|
+
for (const d of sent) if (r.files[d.key]) files[d.key] = { id: r.files[d.key], url: docUrl(r.files[d.key]), title: d.title, at };
|
|
2404
|
+
const cur = this.store.get(agent.id);
|
|
2405
|
+
if (cur) this.patch(agent.id, { drive: { pending: false, error: r.errors.length ? r.errors.join('; ') : null, at, folderId: r.folderId, folderUrl: folderUrl(r.folderId), files, trashed: r.trashed.length } });
|
|
2406
|
+
})().catch((e) => {
|
|
2407
|
+
const cur = this.store.get(agent.id);
|
|
2408
|
+
if (cur) this.patch(agent.id, { drive: { ...cur.drive, pending: false, error: e.message } });
|
|
2409
|
+
});
|
|
2410
|
+
return this.view(this.store.get(agent.id));
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2352
2413
|
/** Diagrams only: the problem and its solution drawn from the documents already written and the live context. */
|
|
2353
2414
|
async runDiagrams(agent, ctx) {
|
|
2354
2415
|
const cur0 = this.store.get(agent.id) ?? agent;
|
|
2355
2416
|
const written = [
|
|
2356
2417
|
...['analysis', 'design', 'flow', 'proposal'].map((k) => [DOC_KINDS[k].title, cur0.docs?.[k]?.markdown]),
|
|
2357
2418
|
['Implementation plan', cur0.planReview?.markdown],
|
|
2419
|
+
['Design doc', readSpecDoc(agent.id, 'designdoc')?.markdown],
|
|
2358
2420
|
['Explanation', cur0.explanation?.markdown],
|
|
2359
2421
|
].filter(([, md]) => md);
|
|
2360
2422
|
const documents = written.map(([title, md]) => `<document title="${title}">\n${md.slice(0, 12_000)}\n</document>`).join('\n');
|
package/src/server.js
CHANGED
|
@@ -274,6 +274,8 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
274
274
|
}),
|
|
275
275
|
);
|
|
276
276
|
api.get('/agents/:id/specs/:name', wrap((req) => manager.specDoc(req.params.id, req.params.name)));
|
|
277
|
+
// All of an agent's documents to Google Drive (through the Claude account's Google Drive connector).
|
|
278
|
+
api.post('/agents/:id/drive', wrap((req) => manager.publishToDrive(req.params.id)));
|
|
277
279
|
api.post('/agents/:id/scorecard/post', wrap((req) => review.postScorecard(req.params.id)));
|
|
278
280
|
// Improve: its scorecard goes back to the agent; a backlog item in review is reopened with it.
|
|
279
281
|
api.post(
|