ai-agentmanager 1.51.1 → 1.54.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 +15 -0
- package/README.md +56 -2
- package/package.json +1 -1
- package/public/app.js +41 -8
- package/public/board.js +177 -0
- package/public/boardcols.js +54 -0
- package/public/eval.js +2 -2
- package/public/index.html +9 -0
- package/public/keys.js +3 -2
- package/public/side.js +20 -3
- package/public/skills.js +215 -0
- package/public/style.css +60 -1
- package/public/system.js +31 -4
- package/public/usage.js +6 -0
- package/src/brief.js +74 -1
- package/src/cli.js +96 -2
- package/src/config.js +2 -0
- package/src/engines/claude.js +15 -1
- package/src/eval.js +45 -8
- package/src/lanes.js +156 -0
- package/src/lean.js +151 -0
- package/src/manager.js +71 -5
- package/src/races.js +21 -12
- package/src/server.js +58 -5
- package/src/skills.js +339 -0
- package/src/system.js +18 -9
package/public/keys.js
CHANGED
|
@@ -30,6 +30,7 @@ export const SHORTCUTS = [
|
|
|
30
30
|
[['l'], 'AI News: the latest frontier releases', 'news'],
|
|
31
31
|
[['c'], 'Plan: project dates, decisions and tech debt', 'plan'],
|
|
32
32
|
[['u'], 'OS: this computer and its load', 'os'],
|
|
33
|
+
[['B'], 'Board: every agent as a card, by where its work stands', 'board'],
|
|
33
34
|
[['q'], 'Decide: recommendations, standing decisions, impact, dates at risk', 'decide'],
|
|
34
35
|
[['z'], "Usage: each engine's plan limits, used and left", 'usage'],
|
|
35
36
|
[['1'], 'Agents tab', 'tab:agents'],
|
|
@@ -75,11 +76,11 @@ export const SHORTCUTS = [
|
|
|
75
76
|
// A single key, as an event names it, to its action.
|
|
76
77
|
export const SINGLE = {
|
|
77
78
|
j: 'next', k: 'prev', Enter: 'terminal', t: 'terminal',
|
|
78
|
-
r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', o: 'actions', h: 'assistant', ',': 'settings', d: 'designs', g: 'reviews', v: 'value', l: 'news', c: 'plan', u: 'os', q: 'decide', z: 'usage', y: 'today', b: 'bugs', '?': 'help',
|
|
79
|
+
r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', o: 'actions', h: 'assistant', ',': 'settings', d: 'designs', g: 'reviews', v: 'value', l: 'news', c: 'plan', u: 'os', B: 'board', q: 'decide', z: 'usage', y: 'today', b: 'bugs', '?': 'help',
|
|
79
80
|
1: 'tab:agents', 2: 'tab:inbox', 3: 'tab:backlog', 4: 'tab:land', 5: 'tab:built',
|
|
80
81
|
};
|
|
81
82
|
// While Watch is open: only what makes sense there.
|
|
82
|
-
const ON_WATCH = new Set(['today', 'new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'news', 'plan', 'os', 'decide', 'usage', 'bugs', 'help']);
|
|
83
|
+
const ON_WATCH = new Set(['today', 'new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'news', 'plan', 'os', 'board', 'decide', 'usage', 'bugs', 'help']);
|
|
83
84
|
|
|
84
85
|
/** Typing somewhere: a field, an editor or a terminal (xterm types through a textarea). */
|
|
85
86
|
const typing = (el) => Boolean(el?.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"], .xterm, .cm-editor'));
|
package/public/side.js
CHANGED
|
@@ -68,6 +68,7 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
|
|
|
68
68
|
else if (st.tab === 'docs') renderDocs(true);
|
|
69
69
|
else if (st.tab === 'debug') renderDebug(true);
|
|
70
70
|
else if (st.tab === 'reverse') renderReverse(true);
|
|
71
|
+
else if (st.tab === 'security') renderAsk('security', true);
|
|
71
72
|
else renderChanges(true);
|
|
72
73
|
refit();
|
|
73
74
|
}
|
|
@@ -88,6 +89,18 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
|
|
|
88
89
|
waiting: 'the report shows here once it has the code path',
|
|
89
90
|
empty: 'Say what is going wrong: a failure, instability at scale, slowness under load. The agent investigates in its session (it reads the code and logs, reproduces and measures where it can) and writes a report here: animated diagrams of the code path and the data flow with where it breaks, what it found with evidence, the likely causes, and the fixes it recommends. It changes no code until you ask for a fix.',
|
|
90
91
|
},
|
|
92
|
+
security: {
|
|
93
|
+
ideas: ['The whole project', 'Everything reachable without signing in', 'File uploads and downloads', 'Who can see whose data', 'Secrets and how they are stored'],
|
|
94
|
+
first: 'What should it audit? Leave empty for the whole project, or name a part: the import API, the login flow',
|
|
95
|
+
more: 'A follow-up: where to look next, a finding to check again, or which findings to fix',
|
|
96
|
+
go: 'Audit',
|
|
97
|
+
short: 'Say what to look at next',
|
|
98
|
+
optional: true,
|
|
99
|
+
sent: 'Sent to the agent: it audits in its session',
|
|
100
|
+
then: { key: 'fix', label: 'Fix findings', sent: 'Asked the agent to fix the findings', title: 'Ask the agent to fix the findings, each with a test that fails without the fix, and record it in the report. Name the ones you want in the box (for example: 1 and 3), or leave it empty for the verified ones in the recommended order' },
|
|
101
|
+
waiting: 'the report shows here once it has mapped what is exposed',
|
|
102
|
+
empty: 'A defensive review of your own code. The agent maps where untrusted input comes in, follows it through the code looking for each class of weakness, runs the project\'s own dependency audit, and checks every finding a second time before listing it. The report shows here: the attack surface as an animated diagram, findings by severity with the evidence and the fix, what was checked and found sound, and what was not covered. It changes no code until you ask for fixes, and it finds what a careful reader finds: it does not replace a penetration test.',
|
|
103
|
+
},
|
|
91
104
|
reverse: {
|
|
92
105
|
ideas: ['How does search work?', 'How is data stored and synced?', 'What does it send over the network?', 'How does the plugin system load code?', 'What file format does it save?'],
|
|
93
106
|
first: 'What do you want to understand? For example: how does search work in this app',
|
|
@@ -309,6 +322,7 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
|
|
|
309
322
|
return text.focus();
|
|
310
323
|
}
|
|
311
324
|
if (e.target.closest('[data-debug-fix]')) return sendAsk('debug', { fix: body.querySelector('[data-debug-text]').value.trim() || true });
|
|
325
|
+
if (e.target.closest('[data-security-fix]')) return sendAsk('security', { fix: body.querySelector('[data-security-text]').value.trim() || true });
|
|
312
326
|
if (e.target.closest('[data-reverse-build]')) return sendAsk('reverse', { build: body.querySelector('[data-reverse-text]').value.trim() || true });
|
|
313
327
|
if (e.target.closest('[data-reverse-recheck]')) return loadRea();
|
|
314
328
|
try {
|
|
@@ -330,15 +344,17 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
|
|
|
330
344
|
if (!ASK[kind]) return;
|
|
331
345
|
e.preventDefault();
|
|
332
346
|
const question = body.querySelector(`[data-${kind}-text]`).value.trim();
|
|
333
|
-
|
|
334
|
-
|
|
347
|
+
// An audit with nothing named is of the whole project; a follow-up says what.
|
|
348
|
+
const whole = ASK[kind].optional && !question && !body.querySelector(`[data-${kind}-fix]`);
|
|
349
|
+
if (question.length < 3 && !whole) return toast(ASK[kind].short, 3000);
|
|
350
|
+
if (kind !== 'reverse') return sendAsk(kind, { question });
|
|
335
351
|
const target = body.querySelector('[data-reverse-target]').value.trim();
|
|
336
352
|
if (!target) return toast("Name the target: an app's folder, a binary's path, or a website's address", 4000);
|
|
337
353
|
sendAsk('reverse', { question, target });
|
|
338
354
|
});
|
|
339
355
|
// Enter sends; Shift+Enter is a new line.
|
|
340
356
|
pane.addEventListener('keydown', (e) => {
|
|
341
|
-
if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.target.matches('[data-debug-text], [data-reverse-text]')) {
|
|
357
|
+
if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.target.matches('[data-debug-text], [data-reverse-text], [data-security-text]')) {
|
|
342
358
|
e.preventDefault();
|
|
343
359
|
e.target.form.requestSubmit();
|
|
344
360
|
}
|
|
@@ -406,6 +422,7 @@ export function initSide({ api, esc, toast, $, agents, codeUi, docHtml, renderDi
|
|
|
406
422
|
if (st.tab === 'docs') renderDocs(false);
|
|
407
423
|
else if (st.tab === 'debug') renderDebug(false);
|
|
408
424
|
else if (st.tab === 'reverse') renderReverse(false);
|
|
425
|
+
else if (st.tab === 'security') renderAsk('security', false);
|
|
409
426
|
else if (st.tab === 'changes') renderChanges(false);
|
|
410
427
|
},
|
|
411
428
|
};
|
package/public/skills.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// Skills: the Agent Skills Claude Code has here (yours, and each project's), what each one is and
|
|
2
|
+
// which agents used it, and adding more from a git repository: a look at what it offers first,
|
|
3
|
+
// then a copy. A skill added here remembers where it came from, so it can be checked and updated.
|
|
4
|
+
|
|
5
|
+
export function initSkills({ api, $, esc, ago, md, toast, openAgent }) {
|
|
6
|
+
const dialog = $('#skills-dialog');
|
|
7
|
+
const body = $('#skills-body');
|
|
8
|
+
let data = null;
|
|
9
|
+
let problem = null;
|
|
10
|
+
let shown = null; // a skill opened to read
|
|
11
|
+
let offer = null; // what a repository offers: { repo, commit, skills }
|
|
12
|
+
let busy = null; // what is being fetched, in words
|
|
13
|
+
const checks = new Map(); // skill id -> what a check for a newer version said
|
|
14
|
+
const drafts = { repo: '', place: 'personal', picked: new Set() };
|
|
15
|
+
|
|
16
|
+
const size = (n) => (n >= 1024 * 1024 ? `${(n / 1024 / 1024).toFixed(1)} MB` : n >= 1024 ? `${Math.round(n / 1024)} KB` : `${n} B`);
|
|
17
|
+
const short = (repo) => String(repo ?? '').replace(/^https:\/\/github\.com\//, '').replace(/\.git$/, '');
|
|
18
|
+
|
|
19
|
+
async function load({ quiet = false } = {}) {
|
|
20
|
+
try {
|
|
21
|
+
data = await api('GET', '/skills');
|
|
22
|
+
problem = null;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
problem = e.message;
|
|
25
|
+
if (!quiet) toast?.(e.message, 5000);
|
|
26
|
+
}
|
|
27
|
+
if (dialog.open) draw();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function skillHtml(s) {
|
|
31
|
+
const c = checks.get(s.id);
|
|
32
|
+
const used = s.usedBy.length ? `<span class="hint" title="${esc(s.usedBy.map((u) => `${u.name} (${u.times}×)`).join(', '))}">used by ${s.usedBy.slice(0, 3).map((u) => `<button class="link" data-skill-agent="${esc(u.id)}">${esc(u.name)}</button>`).join(', ')}${s.usedBy.length > 3 ? ` and ${s.usedBy.length - 3} more` : ''}</span>` : '';
|
|
33
|
+
const from = s.source
|
|
34
|
+
? `<span class="hint">from ${esc(short(s.source.repo))}${s.source.commit ? ` at ${esc(s.source.commit)}` : ''}, added ${esc(ago(s.source.installedAt))}</span>`
|
|
35
|
+
: '<span class="hint">added by hand</span>';
|
|
36
|
+
const checked = !c
|
|
37
|
+
? ''
|
|
38
|
+
: c.error
|
|
39
|
+
? `<span class="hint skills-warn">${esc(c.error)}</span>`
|
|
40
|
+
: c.gone
|
|
41
|
+
? '<span class="hint skills-warn">no longer in its repository</span>'
|
|
42
|
+
: c.changed
|
|
43
|
+
? `<span class="hint skills-warn">a newer version is there (${esc(c.latest ?? '')})</span>`
|
|
44
|
+
: '<span class="hint skills-ok">up to date</span>';
|
|
45
|
+
return `<div class="skills-row" data-skill="${esc(s.id)}">
|
|
46
|
+
<div class="skills-row-head"><b>${esc(s.name)}</b>${s.scripts.length ? `<span class="tag skills-warn" title="It comes with files that can be run: ${esc(s.scripts.join(', '))}">${s.scripts.length} script${s.scripts.length === 1 ? '' : 's'}</span>` : ''}${s.edited ? '<span class="tag" title="Changed here since it was added: an update replaces your changes">edited here</span>' : ''}
|
|
47
|
+
<span class="spacer"></span>
|
|
48
|
+
<button class="small" data-skill-show="${esc(s.id)}">Read</button>
|
|
49
|
+
${s.source ? `<button class="small" data-skill-check="${esc(s.id)}" title="Look at its repository for a newer version">Check</button>` : ''}
|
|
50
|
+
${c?.changed ? `<button class="small primary" data-skill-update="${esc(s.id)}" title="Replace it with its repository's current version${s.edited ? '. Your changes to it go' : ''}">Update</button>` : ''}
|
|
51
|
+
<button class="small ghost" data-skill-remove="${esc(s.id)}" title="Delete this skill's folder">Remove</button></div>
|
|
52
|
+
<p class="skills-desc">${esc(s.description ?? 'No description: Claude Code cannot tell when to use it.')}</p>
|
|
53
|
+
<div class="skills-meta">${from}<span class="hint">${s.files} file${s.files === 1 ? '' : 's'}, ${size(s.size)}</span>${used}${checked}</div>
|
|
54
|
+
</div>`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function offerHtml() {
|
|
58
|
+
if (!offer) return '';
|
|
59
|
+
const places = data?.places ?? [];
|
|
60
|
+
if (!offer.skills.length) return `<div class="skills-offer"><p class="hint">No skill (a folder with a SKILL.md) was found in ${esc(short(offer.repo))}.</p></div>`;
|
|
61
|
+
return `<div class="skills-offer">
|
|
62
|
+
<p><b>${esc(short(offer.repo))}</b>${offer.commit ? ` at ${esc(offer.commit)}` : ''} has ${offer.skills.length} skill${offer.skills.length === 1 ? '' : 's'}. Pick the ones to add:</p>
|
|
63
|
+
<div class="skills-pick">${offer.skills
|
|
64
|
+
.map((s) => `<label class="skills-pick-row"><input type="checkbox" data-skill-pick="${esc(s.folder)}" ${drafts.picked.has(s.folder) ? 'checked' : ''} /><span><b>${esc(s.name)}</b>${s.scripts.length ? ` <span class="tag skills-warn" title="${esc(s.scripts.join(', '))}">${s.scripts.length} script${s.scripts.length === 1 ? '' : 's'}</span>` : ''}${s.installedIn.length ? ' <span class="tag">already here</span>' : ''} <span class="hint">${s.files} file${s.files === 1 ? '' : 's'}, ${size(s.size)}</span><br /><span class="hint">${esc(s.description ?? 'No description')}</span></span></label>`)
|
|
65
|
+
.join('')}</div>
|
|
66
|
+
<p class="hint skills-warn">A skill is instructions an agent follows, and its scripts are run on this computer with your access. Add skills only from people you trust, and read one before you add it: its repository is at <a href="${esc(offer.repo.replace(/\.git$/, ''))}" target="_blank" rel="noopener">${esc(short(offer.repo))}</a>.</p>
|
|
67
|
+
<div class="skills-add-actions">
|
|
68
|
+
<label>Add to <select data-skill-place>${places.map((p) => `<option value="${esc(p.id)}" ${drafts.place === p.id ? 'selected' : ''}>${esc(p.label)}</option>`).join('')}</select></label>
|
|
69
|
+
<span class="spacer"></span>
|
|
70
|
+
<button class="small" data-skill-cancel>Cancel</button>
|
|
71
|
+
<button class="small primary" data-skill-install ${drafts.picked.size && !busy ? '' : 'disabled'}>Add ${drafts.picked.size || ''} skill${drafts.picked.size === 1 ? '' : 's'}</button>
|
|
72
|
+
</div>
|
|
73
|
+
</div>`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function draw() {
|
|
77
|
+
const head = `<div class="issues-head"><h2>Skills</h2><span class="hint">What Claude Code's agents know how to do here</span><span class="spacer"></span><button class="small" data-skills="refresh" title="Read again">↻</button><button class="small" data-skills="close" title="Close (Esc)">Close</button></div>`;
|
|
78
|
+
if (shown) {
|
|
79
|
+
body.innerHTML = `<div class="issues-head"><button class="small" data-skills="back">← Skills</button><h2>${esc(shown.name)}</h2><span class="spacer"></span><button class="small" data-skills="close">Close</button></div>
|
|
80
|
+
<div class="issues-scroll skills-scroll">
|
|
81
|
+
<p class="hint">${esc(shown.dir)}</p>
|
|
82
|
+
<details class="skills-files"><summary>${shown.list.length} file${shown.list.length === 1 ? '' : 's'}${shown.scripts.length ? `, ${shown.scripts.length} of them script${shown.scripts.length === 1 ? '' : 's'}` : ''}</summary><ul>${shown.list.map((f) => `<li>${esc(f.path)} <span class="hint">${size(f.size)}${f.script ? ' · script' : ''}</span></li>`).join('')}</ul></details>
|
|
83
|
+
<div class="md">${md(shown.markdown.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, ''))}</div>
|
|
84
|
+
</div>`;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!data) return (body.innerHTML = `${head}<p class="hint">${problem ? esc(problem) : 'Loading…'}</p>`);
|
|
88
|
+
body.innerHTML = `${head}
|
|
89
|
+
<div class="issues-scroll skills-scroll">
|
|
90
|
+
<form class="skills-add" data-skills-form>
|
|
91
|
+
<input name="repo" value="${esc(drafts.repo)}" placeholder="Add skills from a repository: anthropics/skills, or https://github.com/owner/name" aria-label="A repository of skills" ${busy ? 'disabled' : ''} />
|
|
92
|
+
<button class="small primary" ${busy ? 'disabled' : ''}>${busy ? esc(busy) : 'Look'}</button>
|
|
93
|
+
</form>
|
|
94
|
+
${offerHtml()}
|
|
95
|
+
${data.places
|
|
96
|
+
.map((p) => `<div class="plan-project skills-place" data-skills-place="${esc(p.id)}"><div class="plan-project-head"><h3>${esc(p.label)}</h3><span class="tag">${p.skills.length}</span><span class="spacer"></span><span class="hint">${esc(p.dir)}</span></div>
|
|
97
|
+
${p.skills.map(skillHtml).join('') || '<p class="hint">No skills here.</p>'}</div>`)
|
|
98
|
+
.join('')}
|
|
99
|
+
<p class="hint">A skill is a folder with a SKILL.md: when to use it, and what to do. Claude Code offers yours to every agent and a project's to the agents in that project; an agent picks one up when the task fits its description. A project's skills are files in its repository: commit them for agents working in their own worktrees to get them. Sessions already open see a new skill after a restart.</p>
|
|
100
|
+
</div>`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const act = async (words, fn) => {
|
|
104
|
+
busy = words;
|
|
105
|
+
draw();
|
|
106
|
+
try {
|
|
107
|
+
await fn();
|
|
108
|
+
} catch (e) {
|
|
109
|
+
toast?.(e.message, 7000);
|
|
110
|
+
}
|
|
111
|
+
busy = null;
|
|
112
|
+
draw();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
body.addEventListener('submit', (e) => {
|
|
116
|
+
if (!e.target.matches('[data-skills-form]')) return;
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
drafts.repo = e.target.repo.value.trim();
|
|
119
|
+
if (!drafts.repo) return toast?.('Give a repository: owner/name on GitHub, or an https git address', 4000);
|
|
120
|
+
act('Looking…', async () => {
|
|
121
|
+
offer = await api('POST', '/skills/preview', { repo: drafts.repo });
|
|
122
|
+
drafts.picked = new Set(offer.skills.length === 1 ? [offer.skills[0].folder] : []);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
body.addEventListener('change', (e) => {
|
|
126
|
+
const pick = e.target.closest('[data-skill-pick]');
|
|
127
|
+
if (pick) {
|
|
128
|
+
pick.checked ? drafts.picked.add(pick.dataset.skillPick) : drafts.picked.delete(pick.dataset.skillPick);
|
|
129
|
+
return draw();
|
|
130
|
+
}
|
|
131
|
+
if (e.target.matches('[data-skill-place]')) drafts.place = e.target.value;
|
|
132
|
+
});
|
|
133
|
+
body.addEventListener('input', (e) => {
|
|
134
|
+
if (e.target.name === 'repo') drafts.repo = e.target.value;
|
|
135
|
+
});
|
|
136
|
+
body.addEventListener('click', async (e) => {
|
|
137
|
+
const b = e.target.closest('[data-skills]')?.dataset.skills;
|
|
138
|
+
if (b === 'close') return dialog.close();
|
|
139
|
+
if (b === 'refresh') return load();
|
|
140
|
+
if (b === 'back') {
|
|
141
|
+
shown = null;
|
|
142
|
+
return draw();
|
|
143
|
+
}
|
|
144
|
+
const agent = e.target.closest('[data-skill-agent]');
|
|
145
|
+
if (agent) {
|
|
146
|
+
dialog.close();
|
|
147
|
+
return openAgent?.(agent.dataset.skillAgent);
|
|
148
|
+
}
|
|
149
|
+
if (e.target.closest('[data-skill-cancel]')) {
|
|
150
|
+
offer = null;
|
|
151
|
+
return draw();
|
|
152
|
+
}
|
|
153
|
+
if (e.target.closest('[data-skill-install]')) {
|
|
154
|
+
const names = [...drafts.picked];
|
|
155
|
+
const again = offer.skills.filter((s) => drafts.picked.has(s.folder) && s.installedIn.includes(drafts.place)).map((s) => s.name);
|
|
156
|
+
if (again.length && !confirm(`${again.join(', ')} ${again.length === 1 ? 'is' : 'are'} already there. Replace ${again.length === 1 ? 'it' : 'them'}?`)) return;
|
|
157
|
+
return act('Adding…', async () => {
|
|
158
|
+
const r = await api('POST', '/skills', { repo: offer.repo, names, place: drafts.place, replace: true });
|
|
159
|
+
data = r;
|
|
160
|
+
offer = null;
|
|
161
|
+
drafts.repo = '';
|
|
162
|
+
toast?.(`Added ${r.added.join(', ')}. Agents see ${r.added.length === 1 ? 'it' : 'them'} in sessions started from now on`, 5000);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const show = e.target.closest('[data-skill-show]');
|
|
166
|
+
if (show) {
|
|
167
|
+
try {
|
|
168
|
+
shown = await api('GET', `/skills/one?id=${encodeURIComponent(show.dataset.skillShow)}`);
|
|
169
|
+
} catch (err) {
|
|
170
|
+
toast?.(err.message, 5000);
|
|
171
|
+
}
|
|
172
|
+
return draw();
|
|
173
|
+
}
|
|
174
|
+
const check = e.target.closest('[data-skill-check]');
|
|
175
|
+
if (check) {
|
|
176
|
+
const id = check.dataset.skillCheck;
|
|
177
|
+
return act('Checking…', async () => {
|
|
178
|
+
checks.set(id, await api('POST', '/skills/check', { id }).catch((err) => ({ error: err.message })));
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const update = e.target.closest('[data-skill-update]');
|
|
182
|
+
if (update) {
|
|
183
|
+
const id = update.dataset.skillUpdate;
|
|
184
|
+
const s = data.places.flatMap((p) => p.skills).find((x) => x.id === id);
|
|
185
|
+
if (s?.edited && !confirm(`${s.name} was changed here since it was added. Updating replaces your changes. Update?`)) return;
|
|
186
|
+
return act('Updating…', async () => {
|
|
187
|
+
data = await api('POST', '/skills/update', { id });
|
|
188
|
+
checks.delete(id);
|
|
189
|
+
toast?.('Updated', 3000);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const remove = e.target.closest('[data-skill-remove]');
|
|
193
|
+
if (remove) {
|
|
194
|
+
const id = remove.dataset.skillRemove;
|
|
195
|
+
const s = data.places.flatMap((p) => p.skills).find((x) => x.id === id);
|
|
196
|
+
if (!confirm(`Remove ${s?.name ?? 'this skill'}? Its folder (${s?.dir ?? ''}) is deleted.`)) return;
|
|
197
|
+
try {
|
|
198
|
+
data = await api('DELETE', `/skills?id=${encodeURIComponent(id)}`);
|
|
199
|
+
checks.delete(id);
|
|
200
|
+
} catch (err) {
|
|
201
|
+
toast?.(err.message, 6000);
|
|
202
|
+
}
|
|
203
|
+
return draw();
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
function open() {
|
|
208
|
+
if (dialog.open) return dialog.close();
|
|
209
|
+
shown = null;
|
|
210
|
+
dialog.showModal();
|
|
211
|
+
draw();
|
|
212
|
+
load();
|
|
213
|
+
}
|
|
214
|
+
return { open, isOpen: () => dialog.open };
|
|
215
|
+
}
|
package/public/style.css
CHANGED
|
@@ -621,6 +621,7 @@ dialog::backdrop { background: rgba(0, 0, 0, .45); }
|
|
|
621
621
|
.del { color: var(--red); }
|
|
622
622
|
.test.passed { color: var(--green); }
|
|
623
623
|
.test.failed, .test.error { color: var(--red); }
|
|
624
|
+
.test.flaky { color: var(--yellow); }
|
|
624
625
|
.test.running, .test.queued { color: var(--yellow); }
|
|
625
626
|
.race-diff { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
|
|
626
627
|
pre.diff { margin: 6px 0 0; max-height: 50vh; overflow: auto; font: 12px/1.45 var(--mono); background: var(--panel-2); padding: 8px 10px; border-radius: 6px; }
|
|
@@ -1295,7 +1296,7 @@ table.bench-cases tr.faster td:nth-child(5) { color: var(--green); font-weight:
|
|
|
1295
1296
|
.issues-dialog { width: min(1100px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 16px; }
|
|
1296
1297
|
/* Only while open: a display on the dialog itself would keep a closed one on screen. */
|
|
1297
1298
|
.issues-dialog[open] { display: flex; flex-direction: column; }
|
|
1298
|
-
#issues-body, #actions-body, #designs-body, #reviews-body, #bugs-body, #plan-body, #news-body, #os-body, #decide-body, #usage-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
1299
|
+
#issues-body, #actions-body, #designs-body, #reviews-body, #bugs-body, #plan-body, #news-body, #os-body, #decide-body, #usage-body, #skills-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
1299
1300
|
/* The lists: drag the corner to any size, or fill the window (⤢ or f). */
|
|
1300
1301
|
.issues-dialog { resize: both; overflow: hidden; min-width: min(520px, calc(100% - 32px)); min-height: 240px; max-width: calc(100% - 16px); max-height: calc(100% - 16px); }
|
|
1301
1302
|
.issues-dialog.expanded { width: calc(100% - 16px); height: calc(100% - 16px); }
|
|
@@ -1468,6 +1469,28 @@ table.plan-debt code { overflow-wrap: anywhere; }
|
|
|
1468
1469
|
.usage-level.warn { color: var(--yellow); border-color: var(--yellow); }
|
|
1469
1470
|
.usage-level.high, .usage-level.held, .usage-level.limited { color: var(--red); border-color: var(--red); }
|
|
1470
1471
|
.usage-default-on, .usage-default-on:hover { color: var(--green); border-color: var(--green); }
|
|
1472
|
+
.skills-dialog { width: min(860px, calc(100% - 32px)); }
|
|
1473
|
+
.skills-scroll { border: 0; }
|
|
1474
|
+
.skills-add { display: flex; gap: 8px; margin: 0 0 10px; }
|
|
1475
|
+
.skills-add input { flex: 1; min-width: 0; }
|
|
1476
|
+
.skills-offer { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
|
|
1477
|
+
.skills-offer p { margin: 0 0 8px; }
|
|
1478
|
+
.skills-pick { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; margin: 0 0 8px; }
|
|
1479
|
+
.skills-pick-row { display: flex; flex-direction: row; gap: 8px; align-items: baseline; margin: 0; font-weight: 400; }
|
|
1480
|
+
.skills-pick-row input { width: auto; }
|
|
1481
|
+
.skills-add-actions { display: flex; gap: 8px; align-items: center; }
|
|
1482
|
+
.skills-add-actions label { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; }
|
|
1483
|
+
.skills-add-actions select { width: auto; }
|
|
1484
|
+
.skills-row { padding: 8px 0; border-top: 1px solid var(--border); }
|
|
1485
|
+
.skills-row-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
1486
|
+
.skills-desc { margin: 4px 0; font-size: 13px; }
|
|
1487
|
+
.skills-meta { display: flex; gap: 14px; flex-wrap: wrap; }
|
|
1488
|
+
.skills-warn { color: var(--yellow); border-color: var(--yellow); }
|
|
1489
|
+
.skills-ok { color: var(--green); }
|
|
1490
|
+
.skills-files ul { margin: 6px 0 10px; padding-left: 18px; font-size: 13px; }
|
|
1491
|
+
.usage-lean { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 10px; font-size: 13px; }
|
|
1492
|
+
.usage-lean label { margin: 0; display: flex; gap: 8px; align-items: baseline; font-weight: 400; }
|
|
1493
|
+
.usage-lean label input { width: auto; }
|
|
1471
1494
|
.usage-settings { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 8px; font-size: 13px; }
|
|
1472
1495
|
.usage-settings label { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; }
|
|
1473
1496
|
.usage-settings select { width: auto; }
|
|
@@ -1724,4 +1747,40 @@ table.eval-items tr.eval-na td { color: var(--muted); }
|
|
|
1724
1747
|
.eval-tail { margin: 4px 0 0 1.2em; text-indent: 0; max-height: 160px; overflow: auto; font-size: 11.5px; white-space: pre-wrap; }
|
|
1725
1748
|
.eval-command { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
|
|
1726
1749
|
.eval-command input { min-width: 220px; }
|
|
1750
|
+
.eval-command input[type='number'], .race-tests input[type='number'] { min-width: 0; width: 56px; }
|
|
1727
1751
|
@media (max-width: 600px) { table.eval-items td:nth-child(2) { white-space: normal; } .eval-acts { margin-left: 0; } }
|
|
1752
|
+
|
|
1753
|
+
/* OS: an agent's lane of ports and what it listens on. */
|
|
1754
|
+
.os-ports { white-space: normal; font-variant-numeric: tabular-nums; }
|
|
1755
|
+
.os-port-out { color: var(--yellow); }
|
|
1756
|
+
.os-lanes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 8px 0 14px; font-size: 13px; }
|
|
1757
|
+
.os-lanes label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
|
|
1758
|
+
.os-lanes input { width: auto; flex: none; margin: 0; }
|
|
1759
|
+
|
|
1760
|
+
/* Board: agents as cards in columns by where their work stands. */
|
|
1761
|
+
.board-dialog { width: min(1500px, calc(100% - 32px)); height: min(820px, calc(100% - 32px)); }
|
|
1762
|
+
#board-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
1763
|
+
.board-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); gap: 10px; flex: 1; min-height: 0; overflow-x: auto; padding-bottom: 6px; }
|
|
1764
|
+
.board-col { display: flex; flex-direction: column; min-height: 0; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
|
|
1765
|
+
.board-col.drop { border-color: var(--accent); outline: 1px dashed var(--accent); }
|
|
1766
|
+
.board-col h3 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: baseline; }
|
|
1767
|
+
.board-col.col-needs h3 { color: var(--red); }
|
|
1768
|
+
.board-col.col-working h3 { color: var(--green); }
|
|
1769
|
+
.board-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 40px; flex: 1; }
|
|
1770
|
+
.board-card { padding: 8px; border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 6px; background: var(--panel); cursor: pointer; font-size: 13px; }
|
|
1771
|
+
.board-card:hover, .board-card:focus-visible { border-color: var(--accent); outline: none; }
|
|
1772
|
+
.board-card.pr0 { border-left-color: var(--red); }
|
|
1773
|
+
.board-card.pr1 { border-left-color: var(--yellow); }
|
|
1774
|
+
.board-card.dragging { opacity: .5; }
|
|
1775
|
+
.board-card-head { display: flex; gap: 6px; align-items: center; min-width: 0; }
|
|
1776
|
+
.board-card-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1777
|
+
.board-need { color: var(--red); margin-top: 2px; }
|
|
1778
|
+
.board-pr { margin-top: 2px; color: var(--muted); }
|
|
1779
|
+
.board-pr.ready, .board-pr.merged { color: var(--green); }
|
|
1780
|
+
.board-pr.fix { color: var(--red); }
|
|
1781
|
+
.board-pr.behind { color: var(--yellow); }
|
|
1782
|
+
.board-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; }
|
|
1783
|
+
.board-meta .fail { color: var(--red); }
|
|
1784
|
+
@media (max-width: 720px) {
|
|
1785
|
+
.board-cols { grid-auto-columns: minmax(220px, 80%); }
|
|
1786
|
+
}
|
package/public/system.js
CHANGED
|
@@ -13,7 +13,7 @@ export const bytes = (n) => (n >= 1024 ** 3 ? `${(n / 1024 ** 3).toFixed(1)} GB`
|
|
|
13
13
|
/** 3d 4h, 5h 12m, 9m. */
|
|
14
14
|
export const span = (sec) => (sec >= 86400 ? `${Math.floor(sec / 86400)}d ${Math.floor((sec % 86400) / 3600)}h` : sec >= 3600 ? `${Math.floor(sec / 3600)}h ${Math.floor((sec % 3600) / 60)}m` : `${Math.floor(sec / 60)}m`);
|
|
15
15
|
|
|
16
|
-
export function initSystem({ api, $, esc, toast, openAgent }) {
|
|
16
|
+
export function initSystem({ api, $, esc, toast, openAgent, openPort }) {
|
|
17
17
|
const dialog = $('#os-dialog');
|
|
18
18
|
const body = $('#os-body');
|
|
19
19
|
let data = null;
|
|
@@ -33,6 +33,14 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
|
|
|
33
33
|
const tone = (p) => (p >= 90 ? 'heavy' : p >= 70 ? 'busy' : 'light');
|
|
34
34
|
const meter = (p) => `<div class="os-meter ${tone(p)}" role="img" aria-label="${p}%"><span style="width:${Math.min(100, Math.max(0, p))}%"></span></div>`;
|
|
35
35
|
|
|
36
|
+
/** An agent's lane, what it listens on (a port outside its lane marked), and who else holds a port of its lane. */
|
|
37
|
+
function portsCell(a) {
|
|
38
|
+
const open = (a.ports ?? []).map((p) => `<button class="link${a.lane && !p.inLane ? ' os-port-out' : ''}" data-os-port="${p.port}" data-os-port-agent="${esc(a.id)}" title="${esc(p.name)} (PID ${p.pid}) listens on ${p.port}${a.lane && !p.inLane ? ': outside its lane' : ''}. Open it">${p.port}</button>`).join(' ');
|
|
39
|
+
const taken = (a.taken ?? []).map((t) => `<span class="os-port-out" title="${esc(t.name)} (PID ${t.pid})${t.by ? ', started by another agent,' : ''} holds ${t.port}, a port of this agent's lane">${t.port} taken</span>`).join(' ');
|
|
40
|
+
const lane = a.lane ? `<span class="hint" title="Lane ${a.lane.n}: its own ports. Names it creates end with ${esc(a.lane.suffix)}">${a.lane.first}–${a.lane.last}</span>` : '';
|
|
41
|
+
return [lane, open, taken].filter(Boolean).join(' · ') || '<span class="hint">—</span>';
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
/** The last ten minutes of one measure (0 to 100) as a small line. */
|
|
37
45
|
function spark(points, label) {
|
|
38
46
|
if (points.length < 2) return '<div class="os-spark hint">Its last ten minutes are drawn as they pass.</div>';
|
|
@@ -48,7 +56,7 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
|
|
|
48
56
|
|
|
49
57
|
function draw() {
|
|
50
58
|
if (!data) return `<div class="issues-head"><h2>OS</h2><span class="spacer"></span><button class="small" data-os="close">Close</button></div><p class="hint">${problem ? esc(problem) : 'Loading…'}</p>`;
|
|
51
|
-
const { host, cpu, memory: mem, disks, agents, processes, app, history } = data;
|
|
59
|
+
const { host, cpu, memory: mem, disks, agents, processes, app, history, lanes } = data;
|
|
52
60
|
const minutes = Math.max(1, Math.round((history.length * data.sampleSeconds) / 60));
|
|
53
61
|
return `
|
|
54
62
|
<div class="issues-head">
|
|
@@ -107,10 +115,11 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
|
|
|
107
115
|
<section>
|
|
108
116
|
<h3>Agent sessions <span class="hint">${agents.open}</span></h3>
|
|
109
117
|
${agents.list.length
|
|
110
|
-
? `<table class="issues os-table"><thead><tr><th>Agent</th><th class="num" title="Of one core: 200% is two cores busy">Processor</th><th class="num">Memory</th><th class="num" title="The session and everything it started">Processes</th></tr></thead><tbody>
|
|
111
|
-
${agents.list.map((a) => `<tr><td><button class="link" data-os-agent="${esc(a.id)}">${esc(a.name)}</button></td><td class="num">${a.cpu}%</td><td class="num">${bytes(a.mem)}</td><td class="num">${a.count}</td></tr>`).join('')}
|
|
118
|
+
? `<table class="issues os-table"><thead><tr><th>Agent</th><th class="num" title="Of one core: 200% is two cores busy">Processor</th><th class="num">Memory</th><th class="num" title="The session and everything it started">Processes</th><th title="Its own range of ports, and what it listens on now">Ports</th></tr></thead><tbody>
|
|
119
|
+
${agents.list.map((a) => `<tr><td><button class="link" data-os-agent="${esc(a.id)}">${esc(a.name)}</button></td><td class="num">${a.cpu}%</td><td class="num">${bytes(a.mem)}</td><td class="num">${a.count}</td><td class="os-ports">${portsCell(a)}</td></tr>`).join('')}
|
|
112
120
|
</tbody></table>`
|
|
113
121
|
: '<p class="hint">No agent session is open.</p>'}
|
|
122
|
+
${lanes ? `<div class="os-lanes"><label title="Each agent gets a range of ports and a name ending no other agent has, in its environment (AGENT_PORTS, AGENT_SUFFIX) and its instructions, so dev servers and test databases of agents working side by side don't collide. For sessions started from now on"><input type="checkbox" data-os-lanes="enabled" ${lanes.enabled ? 'checked' : ''} /> A lane of ports for each agent</label>${lanes.enabled ? `<label title="Many dev servers listen on PORT when it is set. Turn off if your projects use PORT for something else"><input type="checkbox" data-os-lanes="port" ${lanes.port ? 'checked' : ''} /> Set PORT to its first port</label><span class="hint">${lanes.size} port${lanes.size === 1 ? '' : 's'} each, from ${lanes.base}</span>` : ''}</div>` : ''}
|
|
114
123
|
<h3>Busiest processes <span class="hint">of ${processes.count}</span></h3>
|
|
115
124
|
<table class="issues os-table"><thead><tr><th>Process</th><th class="num" title="Of one core: 200% is two cores busy">Processor</th><th class="num">Memory</th><th class="num">PID</th></tr></thead><tbody>
|
|
116
125
|
${processes.top.map((p) => `<tr><td title="${esc(p.command)}">${esc(p.name)}</td><td class="num">${p.cpu}%</td><td class="num">${bytes(p.mem)}</td><td class="num hint">${p.pid}</td></tr>`).join('')}
|
|
@@ -126,12 +135,30 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
|
|
|
126
135
|
|
|
127
136
|
body.addEventListener('click', (e) => {
|
|
128
137
|
if (e.target.closest('[data-os="close"]')) return dialog.close();
|
|
138
|
+
const port = e.target.closest('[data-os-port]');
|
|
139
|
+
if (port) {
|
|
140
|
+
dialog.close();
|
|
141
|
+
return openPort?.(port.dataset.osPortAgent, Number(port.dataset.osPort));
|
|
142
|
+
}
|
|
129
143
|
const a = e.target.closest('[data-os-agent]');
|
|
130
144
|
if (a) {
|
|
131
145
|
dialog.close();
|
|
132
146
|
openAgent?.(a.dataset.osAgent);
|
|
133
147
|
}
|
|
134
148
|
});
|
|
149
|
+
// Lanes on or off, and PORT with them: for the sessions started from now on.
|
|
150
|
+
body.addEventListener('change', async (e) => {
|
|
151
|
+
const key = e.target.dataset?.osLanes;
|
|
152
|
+
if (!key) return;
|
|
153
|
+
try {
|
|
154
|
+
const { enabled, base, size, port } = await api('PUT', '/lanes', { [key]: e.target.checked });
|
|
155
|
+
if (data) data.lanes = { enabled, base, size, port };
|
|
156
|
+
toast?.(key === 'port' ? (port ? 'PORT is set for sessions started from now on' : 'PORT is left alone in sessions started from now on') : enabled ? 'Each agent gets its own ports, in sessions started from now on' : 'No lanes for sessions started from now on', 4000);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
toast?.(err.message, 5000);
|
|
159
|
+
}
|
|
160
|
+
render();
|
|
161
|
+
});
|
|
135
162
|
|
|
136
163
|
dialog.addEventListener('close', () => {
|
|
137
164
|
clearInterval(timer);
|
package/public/usage.js
CHANGED
|
@@ -74,6 +74,10 @@ export function initUsage({ api, $, esc, ago, toast }) {
|
|
|
74
74
|
<label>Alert me at ${level('warnAt', s.warnAt, 'never')}</label>
|
|
75
75
|
<label title="No new agent starts on an engine at or past this much of a limit (the backlog waits, and New agents says why). Agents already running carry on.">Hold new work at ${level('holdAt', s.holdAt, 'never')}</label>
|
|
76
76
|
</div>
|
|
77
|
+
<div class="usage-lean">
|
|
78
|
+
<label class="check" title="Long command output (test runs, installs, builds) is trimmed before the agent reads it: colours and progress redraws go, runs of near-identical lines are folded, and of a long middle only the lines that look like errors or warnings stay. The start and end are kept, and the whole output is saved to a file the agent can read. Claude Code only; applies to sessions started from now on"><input type="checkbox" data-usage-lean ${data.lean?.enabled ? 'checked' : ''} /> <b>Lean output</b>: trim long command output before the agent reads it</label>
|
|
79
|
+
<span class="hint">${data.lean?.calls ? `${data.lean.calls.toLocaleString()} output${data.lean.calls === 1 ? '' : 's'} trimmed, about ${data.lean.tokens >= 1000 ? `${Math.round(data.lean.tokens / 1000).toLocaleString()}k` : data.lean.tokens} tokens not read` : data.lean?.enabled ? 'Nothing long enough to trim yet. Sessions started from now on use it.' : 'Makes a limit last longer. Nothing is lost: the whole output is kept in a file the agent can read.'}</span>
|
|
80
|
+
</div>
|
|
77
81
|
<p class="hint">These are numbers the engines hand out on this computer: Claude Code gives them to the status line of the sessions started here, Codex writes them in its session logs, so a reading is as old as the last reply of a session started here; Claude Code you use elsewhere moves the real numbers on meanwhile. <b>Read now</b> brings them up to date with a one-word session on Claude Code's smallest model. A limit an agent actually hits is shown for any engine until it resets, and the agent carries on by itself when it does.</p>
|
|
78
82
|
</div>`;
|
|
79
83
|
}
|
|
@@ -115,6 +119,8 @@ export function initUsage({ api, $, esc, ago, toast }) {
|
|
|
115
119
|
else if (b === 'refresh') readNow();
|
|
116
120
|
});
|
|
117
121
|
body.addEventListener('change', (e) => {
|
|
122
|
+
const lean = e.target.closest('[data-usage-lean]');
|
|
123
|
+
if (lean) return save({ lean: lean.checked }, lean.checked ? 'Lean output is on for sessions started from now on' : 'Lean output is off for sessions started from now on');
|
|
118
124
|
const s = e.target.closest('[data-usage-set]');
|
|
119
125
|
if (s) save({ [s.dataset.usageSet]: s.value }, 'Saved');
|
|
120
126
|
});
|
package/src/brief.js
CHANGED
|
@@ -723,7 +723,9 @@ export const DEBUG_FILE = 'DEBUG.md';
|
|
|
723
723
|
export const debugPath = (agentId) => path.join(briefDir(agentId), DEBUG_FILE);
|
|
724
724
|
export const REVERSE_FILE = 'REVERSE.md';
|
|
725
725
|
export const reversePath = (agentId) => path.join(briefDir(agentId), REVERSE_FILE);
|
|
726
|
-
export const
|
|
726
|
+
export const SECURITY_FILE = 'SECURITY-AUDIT.md';
|
|
727
|
+
export const securityPath = (agentId) => path.join(briefDir(agentId), SECURITY_FILE);
|
|
728
|
+
export const SPEC_DOCS = { intent: intentPath, spec: specPath, plan: planPath, designdoc: designPath, benchmark: benchPath, demo: demoPath, debug: debugPath, reverse: reversePath, security: securityPath };
|
|
727
729
|
|
|
728
730
|
// ------------------------------------------------------------------ debug
|
|
729
731
|
|
|
@@ -863,6 +865,77 @@ export function reverseBuildPrompt(file, what) {
|
|
|
863
865
|
);
|
|
864
866
|
}
|
|
865
867
|
|
|
868
|
+
// ------------------------------------------------------------------ security audit
|
|
869
|
+
|
|
870
|
+
// Security audit: you say what to audit (or nothing, for the whole project); the agent goes through
|
|
871
|
+
// the code in its own session in phases (what is exposed, then each class of weakness on the paths
|
|
872
|
+
// from there), checks every finding a second time before it is listed, and keeps a report at
|
|
873
|
+
// SECURITY-AUDIT.md: the attack surface as a diagram, the findings by severity with evidence, what
|
|
874
|
+
// was checked and found sound, and what was not covered. It changes no code until you ask for fixes.
|
|
875
|
+
|
|
876
|
+
const SECURITY_SHAPE = [
|
|
877
|
+
'# Security audit: <what was audited>',
|
|
878
|
+
'## Summary',
|
|
879
|
+
'Two or three sentences: the overall state, the most serious finding, and how much of the scope was covered. Then one line of counts: critical, high, medium, low.',
|
|
880
|
+
'## Scope',
|
|
881
|
+
'What was audited (folders, services, the commit), what was left out, and what the project is and who can reach it (the internet, signed-in users, the local network, only this computer).',
|
|
882
|
+
'## Attack surface',
|
|
883
|
+
'One ```mermaid flowchart of where untrusted input enters (HTTP routes, webhooks, files, CLI arguments, queues, other services) and the path it takes to what matters (the database, the file system, a shell, secrets, other users\' data), with the trust boundaries. Real names from the code.',
|
|
884
|
+
'## Findings',
|
|
885
|
+
'A Markdown table first: #, Severity, Title, Where (file:line), Status. Then one "### <#>. <title>" section a finding, most severe first, each with: Severity (critical, high, medium or low) and why that level here; Where (file:line and function); What is wrong, in two or three sentences; Evidence (the lines of code, and the path from the input to the weak spot); Impact (what someone could do, and who: anyone, a signed-in user, someone on the network); Status: "verified" (the second check confirmed the path is reachable) or "needs a look" (plausible, not confirmed, and why); Fix (the change, where, effort S, M or L, and how to test it).',
|
|
886
|
+
'## Checked and sound',
|
|
887
|
+
'What you looked for and did not find, by class (for example: SQL built from input, secrets in the repository, path traversal), with where you looked. So the next audit knows what was covered.',
|
|
888
|
+
'## Not covered',
|
|
889
|
+
'What was out of reach or out of time: dependencies not scanned, infrastructure, a service whose code is not here. And what you need from the user to cover it.',
|
|
890
|
+
'## Recommended order',
|
|
891
|
+
'The fixes in the order to make them, with the reason (severity, how exposed, how cheap).',
|
|
892
|
+
].join('\n');
|
|
893
|
+
|
|
894
|
+
const SECURITY_METHOD =
|
|
895
|
+
'Work in phases. 1) Map it: what the project is, how it is reached, and every place untrusted input comes in. ' +
|
|
896
|
+
'2) Follow the input: along each path from there, look for injection (SQL, shell, template, path), missing or wrong authentication and authorization (including one user reaching another\'s data), secrets in code, config or logs, unsafe deserialization and file handling, server-side requests to addresses the input names, cross-site scripting and request forgery, weak or home-made cryptography, unsafe defaults, and missing limits on size, rate or cost. ' +
|
|
897
|
+
'3) Dependencies and configuration: run the project\'s own audit command if it has one (npm audit, pip-audit, cargo audit, govulncheck and the like, read-only), and read the deployment and CI configuration that is in the repository. ' +
|
|
898
|
+
'4) Check every finding again, independently, before it goes in the report: start from the weak spot and prove the path back to input an attacker controls, looking for the validation, the framework default or the caller that would stop it. With subagents available, give each finding to a fresh one with only the claim and the file, and ask it to disprove it. A finding that does not survive is dropped; one you could not settle is listed as "needs a look". No finding is listed on a pattern match alone.';
|
|
899
|
+
|
|
900
|
+
const SECURITY_RULES =
|
|
901
|
+
'Rules: this is a defensive review of our own code, read-only. Do not change the repository yet, do not send requests to systems that are running in production or belong to someone else, and do not write working exploit code: the evidence is the code path, described precisely enough for the fix. ' +
|
|
902
|
+
'Secrets you come across are named by where they are, never copied into the report. Severity is for this project as it is deployed, not for the class of bug in general.';
|
|
903
|
+
|
|
904
|
+
const SECURITY_DIAGRAMS =
|
|
905
|
+
'The diagram: valid Mermaid, at most about 18 nodes, labels of five words or fewer (quote labels with punctuation, e.g. A["POST /api/import"]), no HTML in labels. Animate the paths untrusted input takes: give those edges ids and animate them, e.g.\n' +
|
|
906
|
+
' A e1@--> B\n e1@{ animate: true }\n' +
|
|
907
|
+
'Mark where a verified finding is: `classDef fault stroke:#ef4444,stroke-width:3px`, then `class X fault`; and one that needs a look: `classDef suspect stroke:#f59e0b,stroke-width:3px,stroke-dasharray:4`, then `class Y suspect`.';
|
|
908
|
+
|
|
909
|
+
/** The message that starts (or continues) a security audit in the agent's session. */
|
|
910
|
+
export function securityPrompt(file, question, { again = false } = {}) {
|
|
911
|
+
const q = String(question ?? '').trim();
|
|
912
|
+
if (again) {
|
|
913
|
+
return (
|
|
914
|
+
`Security audit, continued: ${q}\n` +
|
|
915
|
+
`Carry on and bring the report at ${file} up to date: same sections, the diagram redrawn where the picture changed, each finding's status re-marked, the counts in the summary corrected. ` +
|
|
916
|
+
'The same rules: read-only, every new finding checked a second time before it is listed, and no changes to the repository unless I ask for fixes. Answer me here in a few lines, and say what changed in the report.'
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
return (
|
|
920
|
+
`Security audit: ${q || 'this whole project, the most exposed parts first'}\n` +
|
|
921
|
+
`${SECURITY_METHOD}\n${SECURITY_RULES}\n` +
|
|
922
|
+
`Keep a report at ${file} (Markdown; the file is outside the repository: never copy it in or commit it). Write a first version once the attack surface is mapped, and update it as each phase finishes. Short and specific, in these sections:\n` +
|
|
923
|
+
`${SECURITY_SHAPE}\n${SECURITY_DIAGRAMS}\n` +
|
|
924
|
+
'When the report is written, tell me in a few lines what you found, most serious first, and what you could not cover.'
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/** The message that asks for the report's fixes to be made. */
|
|
929
|
+
export function securityFixPrompt(file, which) {
|
|
930
|
+
const w = String(which ?? '').trim();
|
|
931
|
+
return (
|
|
932
|
+
`Fix the findings from your security audit at ${file}: ${w || 'the verified ones, in the recommended order'}.\n` +
|
|
933
|
+
'For each: make the smallest change that closes it, add a test that fails without the fix (the unsafe input is refused, the other user is turned away), and run the tests. Fix the cause, not the one call site: look for the same pattern elsewhere and say where you found it. ' +
|
|
934
|
+
'Leave the findings marked "needs a look" alone unless I named them. ' +
|
|
935
|
+
'Then update the report: mark each finding fixed (the commit or the files, and the test that covers it) or say why it was left, and correct the counts in the summary.'
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
|
|
866
939
|
/** INTENT.md: the request as given, and where it came from. */
|
|
867
940
|
export function intentMarkdown(agent) {
|
|
868
941
|
const by = agent.startedBy ? 'the assistant' : agent.trigger ? (agent.trigger.source === 'github' ? 'a labeled GitHub issue' : 'a webhook') : agent.playbook ? `the playbook ${agent.playbook.name}` : agent.team ? `team ${agent.team.id} (${agent.team.role})` : agent.raceId ? `race ${agent.raceId}` : 'you';
|