ai-agentmanager 1.16.0 → 1.18.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 +14 -0
- package/README.md +50 -6
- package/package.json +1 -1
- package/public/app.js +105 -9
- package/public/goals.js +153 -0
- package/public/index.html +40 -1
- package/public/style.css +28 -0
- package/public/worklog.js +67 -0
- package/src/autopilot.js +27 -18
- package/src/backlog.js +14 -2
- package/src/brief.js +4 -2
- package/src/cli.js +112 -5
- package/src/goals.js +359 -0
- package/src/manager.js +82 -6
- package/src/reminders.js +58 -0
- package/src/server.js +48 -2
- package/src/sessions.js +54 -6
- package/src/worklog.js +265 -0
package/public/goals.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Goals (top of the Backlog tab): outcomes for today or this week across projects, planned into
|
|
2
|
+
// backlog tasks and seen through by agents, with completed / pending / follow-ups kept current.
|
|
3
|
+
|
|
4
|
+
const STATUS = { planning: 'planning…', review: 'plan ready', running: 'in progress', checking: 'checking the outcome…', done: 'done', stopped: 'stopped', error: "couldn't plan" };
|
|
5
|
+
const PERIOD = { day: 'Today', week: 'This week', none: 'No deadline' };
|
|
6
|
+
|
|
7
|
+
export function initGoals({ api, esc, toast, $, ago, getProjects, rerender }) {
|
|
8
|
+
let goals = [];
|
|
9
|
+
const openGoals = new Set(); // cards expanded in this browser session
|
|
10
|
+
|
|
11
|
+
const due = (g) => {
|
|
12
|
+
if (!g.due) return '';
|
|
13
|
+
const d = new Date(g.due);
|
|
14
|
+
const label = g.period === 'day' ? 'today' : `by ${d.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' })}`;
|
|
15
|
+
return `<span class="${g.overdue ? 'fail' : 'hint'}">${g.overdue ? `overdue (was due ${esc(d.toLocaleDateString())})` : esc(label)}</span>`;
|
|
16
|
+
};
|
|
17
|
+
const prLinks = (r) => r.prs.map((p) => `<a href="${esc(p.url)}" target="_blank" rel="noopener">#${esc(p.url.split('/').pop())}${p.state && p.state !== 'OPEN' ? ` ${esc(p.state.toLowerCase())}` : ''}</a>`).join(' ');
|
|
18
|
+
const row = (r, extra = '') => `<li><span class="goal-task">${esc(r.title.split('\n')[0])}</span> <span class="hint">${esc(r.project ?? '')}${r.agentId ? ` · <a href="#${esc(r.agentId)}">${esc(r.agentName ?? r.agentId)}</a>` : ''}</span> ${prLinks(r)}${extra}</li>`;
|
|
19
|
+
|
|
20
|
+
function card(g) {
|
|
21
|
+
const c = g.counts;
|
|
22
|
+
const open = openGoals.has(g.id) || g.status === 'review' || g.status === 'error';
|
|
23
|
+
const pct = c.total ? Math.round((c.completed / c.total) * 100) : 0;
|
|
24
|
+
const s = g.summary;
|
|
25
|
+
const body = [];
|
|
26
|
+
if (g.status === 'error') body.push(`<p class="error">${esc(g.error ?? '')}</p><div class="need-actions"><button class="small primary" data-goal-act="replan">Plan again</button><button class="small ghost" data-goal-act="remove">Remove</button></div>`);
|
|
27
|
+
if (g.status === 'review') {
|
|
28
|
+
body.push(`<p class="hint">The plan: one agent per task. Untick what you don't want, then start.${g.note ? ` ${esc(g.note)}` : ''}</p>
|
|
29
|
+
<ul class="goal-plan">${g.plan.map((t, i) => `<li><label><input type="checkbox" data-goal-task="${i}" checked> <span class="tag">${esc(t.project)}</span> ${esc(t.title)}</label></li>`).join('')}</ul>
|
|
30
|
+
<div class="need-actions"><button class="small primary" data-goal-act="approve">Start ${g.plan.length} agent${g.plan.length === 1 ? '' : 's'}</button><button class="small ghost" data-goal-act="replan">Plan again</button><button class="small ghost" data-goal-act="remove">Remove</button></div>`);
|
|
31
|
+
}
|
|
32
|
+
if (c.total) {
|
|
33
|
+
if (s.followUps.length) body.push(`<p class="goal-h fail">Follow-ups (${s.followUps.length})</p><ul class="goal-list">${s.followUps.map((r) => row(r, `<div class="hint">${esc(r.why)}</div>`)).join('')}</ul>`);
|
|
34
|
+
if (s.pending.length) body.push(`<p class="goal-h">Pending (${s.pending.length})</p><ul class="goal-list">${s.pending.map((r) => row(r, ` <span class="tag">${esc(r.state)}</span>`)).join('')}</ul>`);
|
|
35
|
+
if (s.completed.length) body.push(`<p class="goal-h">Completed (${s.completed.length})</p><ul class="goal-list">${s.completed.map((r) => row(r)).join('')}</ul>`);
|
|
36
|
+
}
|
|
37
|
+
const last = g.checks?.at(-1);
|
|
38
|
+
if (last) body.push(`<p class="hint">Outcome check ${last.met === false ? `found more to do (${last.tasks} task${last.tasks === 1 ? '' : 's'} added)` : last.met ? 'says it is met' : ''}${last.reason ? `: ${esc(last.reason)}` : ''}</p>`);
|
|
39
|
+
const actions = [
|
|
40
|
+
c.total ? '<button class="small ghost" data-goal-act="copy" title="Completed, pending and follow-ups as Markdown">Copy summary</button>' : '',
|
|
41
|
+
g.period !== 'none' && g.overdue ? `<button class="small ghost" data-goal-act="extend">Carry over to ${g.period === 'day' ? 'tomorrow' : 'next week'}</button>` : '',
|
|
42
|
+
['running', 'checking', 'planning'].includes(g.status) ? '<button class="small ghost" data-goal-act="stop" title="Cancel its queued tasks; work in progress goes on">Stop</button>' : '',
|
|
43
|
+
['done', 'stopped'].includes(g.status) ? '<button class="small ghost" data-goal-act="remove">Remove</button>' : '',
|
|
44
|
+
].join('');
|
|
45
|
+
return `<li class="goal ${esc(g.status)} ${g.overdue ? 'overdue' : ''}" data-goal="${esc(g.id)}">
|
|
46
|
+
<button class="goal-head" data-goal-act="toggle" aria-expanded="${open}">
|
|
47
|
+
<span class="caret">${open ? '▾' : '▸'}</span><span class="goal-title">🎯 ${esc(g.title)}</span>
|
|
48
|
+
<span class="pill ${g.status === 'done' ? 'done' : g.status === 'error' ? 'error' : c.followUps ? 'attention' : 'working'}">${STATUS[g.status] ?? esc(g.status)}</span>
|
|
49
|
+
</button>
|
|
50
|
+
<div class="goal-meta">${due(g)} <span class="hint">${esc(g.projects.join(', '))}</span>
|
|
51
|
+
${c.total ? `<span class="goal-bar" title="${pct}% completed"><span style="width:${pct}%"></span></span><span>${c.completed} completed · ${c.pending} pending · <span class="${c.followUps ? 'fail' : ''}">${c.followUps} follow-up${c.followUps === 1 ? '' : 's'}</span></span>` : ''}</div>
|
|
52
|
+
${open ? `<div class="goal-body">${body.join('')}${actions ? `<div class="need-actions">${actions}</div>` : ''}</div>` : ''}
|
|
53
|
+
</li>`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function html() {
|
|
57
|
+
const shown = goals.filter((g) => g.status !== 'done' || Date.now() - Date.parse(g.doneAt ?? 0) < 3 * 86_400_000);
|
|
58
|
+
return `<div class="goals">
|
|
59
|
+
<div class="goals-head"><b>Goals</b><span class="hint">outcomes agents work toward until they're done</span><span class="spacer"></span><button class="link" data-goal-act="new">+ Goal</button></div>
|
|
60
|
+
${shown.length ? `<ul class="goal-cards">${shown.map(card).join('')}</ul>` : ''}
|
|
61
|
+
</div>`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// New goal dialog.
|
|
65
|
+
const dlg = $('#goal-dialog');
|
|
66
|
+
const f = $('#goal-form');
|
|
67
|
+
function openNew() {
|
|
68
|
+
const projects = getProjects();
|
|
69
|
+
$('#goal-projects').innerHTML = projects.length
|
|
70
|
+
? projects.map((p) => `<label class="goal-proj"><input type="checkbox" name="project" value="${esc(p.shortcut)}"> <span class="shortcut">${esc(p.shortcut)}</span> ${esc(p.name)}</label>`).join('')
|
|
71
|
+
: '<p class="hint">No projects yet: start an agent in a repo or folder first, or add one with <code>agentmgr project add</code>.</p>';
|
|
72
|
+
if (projects.length === 1) $('#goal-projects input').checked = true;
|
|
73
|
+
$('#goal-error').hidden = true;
|
|
74
|
+
dlg.showModal();
|
|
75
|
+
f.text.focus();
|
|
76
|
+
}
|
|
77
|
+
f.addEventListener('submit', async (e) => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
const projects = [...f.querySelectorAll('input[name="project"]:checked')].map((x) => x.value);
|
|
80
|
+
try {
|
|
81
|
+
const g = await api('POST', '/goals', { text: f.text.value, period: f.period.value, projects, review: f.review.checked, priority: Number(f.priority.value) });
|
|
82
|
+
goals = [g, ...goals.filter((x) => x.id !== g.id)];
|
|
83
|
+
openGoals.add(g.id);
|
|
84
|
+
dlg.close();
|
|
85
|
+
f.text.value = '';
|
|
86
|
+
toast(f.review.checked ? 'Planning it; the plan shows here for you to start' : 'Planning it; agents start as tasks are queued');
|
|
87
|
+
rerender();
|
|
88
|
+
} catch (err) {
|
|
89
|
+
$('#goal-error').hidden = false;
|
|
90
|
+
$('#goal-error').textContent = err.message;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
$('#goal-cancel').onclick = () => dlg.close();
|
|
94
|
+
|
|
95
|
+
async function onClick(e) {
|
|
96
|
+
const el = e.target.closest('[data-goal-act]');
|
|
97
|
+
if (!el) return false;
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
const act = el.dataset.goalAct;
|
|
100
|
+
if (act === 'new') return openNew(), true;
|
|
101
|
+
const id = el.closest('[data-goal]')?.dataset.goal;
|
|
102
|
+
const g = goals.find((x) => x.id === id);
|
|
103
|
+
if (!g) return true;
|
|
104
|
+
const run = async (fn, msg) => {
|
|
105
|
+
try {
|
|
106
|
+
const v = await fn();
|
|
107
|
+
if (v?.id) goals = goals.map((x) => (x.id === v.id ? v : x));
|
|
108
|
+
if (msg) toast(msg);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
toast(`Error: ${err.message}`, 5000);
|
|
111
|
+
}
|
|
112
|
+
rerender();
|
|
113
|
+
};
|
|
114
|
+
switch (act) {
|
|
115
|
+
case 'toggle':
|
|
116
|
+
openGoals.has(id) ? openGoals.delete(id) : openGoals.add(id);
|
|
117
|
+
return rerender(), true;
|
|
118
|
+
case 'approve': {
|
|
119
|
+
const keep = [...el.closest('[data-goal]').querySelectorAll('[data-goal-task]')].filter((x) => x.checked).map((x) => g.plan[Number(x.dataset.goalTask)]);
|
|
120
|
+
return run(() => api('POST', `/goals/${id}/approve`, { tasks: keep }), `Started ${keep.length} agent${keep.length === 1 ? '' : 's'}`), true;
|
|
121
|
+
}
|
|
122
|
+
case 'replan':
|
|
123
|
+
return run(() => api('POST', `/goals/${id}/replan`), 'Planning it again'), true;
|
|
124
|
+
case 'extend':
|
|
125
|
+
return run(() => api('POST', `/goals/${id}/extend`), 'Carried over'), true;
|
|
126
|
+
case 'stop':
|
|
127
|
+
if (!confirm('Stop this goal? Its queued tasks are cancelled; agents already working go on.')) return true;
|
|
128
|
+
return run(() => api('POST', `/goals/${id}/stop`), 'Goal stopped'), true;
|
|
129
|
+
case 'remove':
|
|
130
|
+
await run(() => api('DELETE', `/goals/${id}`));
|
|
131
|
+
goals = goals.filter((x) => x.id !== id);
|
|
132
|
+
return rerender(), true;
|
|
133
|
+
case 'copy':
|
|
134
|
+
try {
|
|
135
|
+
await navigator.clipboard.writeText((await api('GET', `/goals/${id}/summary`)).markdown);
|
|
136
|
+
toast('Summary copied (Markdown)');
|
|
137
|
+
} catch (err) {
|
|
138
|
+
toast(`Couldn't copy: ${err.message}`, 4000);
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
set(list) {
|
|
147
|
+
goals = list ?? [];
|
|
148
|
+
},
|
|
149
|
+
html,
|
|
150
|
+
onClick,
|
|
151
|
+
count: () => goals.filter((g) => g.counts?.followUps || g.status === 'review').length,
|
|
152
|
+
};
|
|
153
|
+
}
|
package/public/index.html
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
<span id="me-where" class="hint"></span>
|
|
46
46
|
</div>
|
|
47
47
|
<button role="menuitem" id="settings-btn">Settings…</button>
|
|
48
|
+
<button role="menuitem" id="worklog-btn" title="What your agents got done: pull requests, bugs fixed, issues filed; kept in a spreadsheet for reviews">Work record…</button>
|
|
48
49
|
<button role="menuitem" id="cleanup-btn" title="Close agents idle for a while, and delete old closed ones">Clean up…</button>
|
|
49
50
|
<button role="menuitem" id="alerts-btn" class="local-only" title="Slack alerts when an agent needs you">Alerts…</button>
|
|
50
51
|
<button role="menuitem" id="remote-btn" class="local-only" title="Open AI Agent Manager from your phone">Remote access…</button>
|
|
@@ -74,6 +75,11 @@
|
|
|
74
75
|
</label>
|
|
75
76
|
<input type="number" id="recent-days" min="1" max="3650" value="7" aria-label="Days"> days
|
|
76
77
|
<span class="spacer"></span><span id="recent-hidden"></span>
|
|
78
|
+
<select id="list-order" aria-label="Order" title="Recently used: one list, the agents created or worked in most recently on top. Running first: running agents on top, most recently used first, then the rest. By project: grouped, busiest and most urgent first.">
|
|
79
|
+
<option value="recent">Recently used</option>
|
|
80
|
+
<option value="running">Running first</option>
|
|
81
|
+
<option value="project">By project</option>
|
|
82
|
+
</select>
|
|
77
83
|
</div>
|
|
78
84
|
<ul id="agent-list" class="agent-list" aria-label="Agents"></ul>
|
|
79
85
|
</div>
|
|
@@ -429,7 +435,7 @@
|
|
|
429
435
|
<button type="button" id="import-close" class="small ghost">Close</button>
|
|
430
436
|
</div>
|
|
431
437
|
<div class="import-body">
|
|
432
|
-
<p class="hint">Sessions you started with <code>claude</code> in a terminal on this machine. Each one you pick becomes an agent in the same folder that continues the same conversation, with the brief, inbox, PRs and usage tracked here.</p>
|
|
438
|
+
<p class="hint">Sessions you started with <code>claude</code> in a terminal, or in the Claude desktop app, on this machine. Each one you pick becomes an agent in the same folder that continues the same conversation, with the brief, inbox, PRs and usage tracked here.</p>
|
|
433
439
|
<input id="import-filter" placeholder="Filter by folder, title or what you asked" autocomplete="off">
|
|
434
440
|
<div id="import-list" class="import-list"></div>
|
|
435
441
|
</div>
|
|
@@ -688,6 +694,39 @@
|
|
|
688
694
|
</form>
|
|
689
695
|
</dialog>
|
|
690
696
|
|
|
697
|
+
<dialog id="goal-dialog">
|
|
698
|
+
<form id="goal-form" class="alerts-body">
|
|
699
|
+
<h2>New goal</h2>
|
|
700
|
+
<p class="hint">An outcome to reach, in one or more projects. It's planned into tasks, one agent each; they go to the backlog and run until the goal is done. Where a project's autopilot is on, finished work ships by itself.</p>
|
|
701
|
+
<label>The outcome
|
|
702
|
+
<textarea name="text" rows="5" required placeholder="By Friday: users can sign in with SSO on web, and the API returns paginated results for /orders. Both with tests."></textarea>
|
|
703
|
+
</label>
|
|
704
|
+
<div class="row">
|
|
705
|
+
<label>When <select name="period"><option value="day">Today</option><option value="week" selected>This week</option><option value="none">No deadline</option></select></label>
|
|
706
|
+
<label>Priority <select name="priority"><option value="0">P0</option><option value="1">P1</option><option value="2" selected>P2</option><option value="3">P3</option></select></label>
|
|
707
|
+
</div>
|
|
708
|
+
<div>Projects<div id="goal-projects" class="goal-projects"></div></div>
|
|
709
|
+
<label class="check"><input type="checkbox" name="review"> Show me the plan before agents start</label>
|
|
710
|
+
<p id="goal-error" class="error" hidden></p>
|
|
711
|
+
<div class="dialog-actions"><span class="spacer"></span><button type="button" id="goal-cancel" class="ghost">Cancel</button><button class="primary">Plan and start</button></div>
|
|
712
|
+
</form>
|
|
713
|
+
</dialog>
|
|
714
|
+
|
|
715
|
+
<dialog id="worklog-dialog">
|
|
716
|
+
<form method="dialog" class="alerts-body">
|
|
717
|
+
<h2>Work record <select id="worklog-days" class="inline-select"><option value="7">last 7 days</option><option value="30" selected>last 30 days</option><option value="90">last 90 days</option><option value="365">last year</option><option value="0">all time</option></select></h2>
|
|
718
|
+
<div id="worklog-body"></div>
|
|
719
|
+
<p id="worklog-files" class="hint"></p>
|
|
720
|
+
<div class="dialog-actions">
|
|
721
|
+
<button type="button" id="worklog-copy" title="The period's totals and what was merged, fixed and filed, with links, as Markdown for a review or status update">Copy summary</button>
|
|
722
|
+
<button type="button" id="worklog-csv" class="ghost">Download events</button>
|
|
723
|
+
<button type="button" id="worklog-weekly" class="ghost">Download weekly</button>
|
|
724
|
+
<span class="spacer"></span>
|
|
725
|
+
<button type="button" id="worklog-close" class="ghost">Close</button>
|
|
726
|
+
</div>
|
|
727
|
+
</form>
|
|
728
|
+
</dialog>
|
|
729
|
+
|
|
691
730
|
<dialog id="cleanup-dialog">
|
|
692
731
|
<form id="cleanup-form" method="dialog" class="alerts-body">
|
|
693
732
|
<h2>Clean up old agents</h2>
|
package/public/style.css
CHANGED
|
@@ -168,6 +168,8 @@ body.term-max .layout { grid-template-columns: 1fr; }
|
|
|
168
168
|
.recent-switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; margin: 0; font-weight: normal; }
|
|
169
169
|
.recent-switch input { width: auto; margin: 0; }
|
|
170
170
|
.recent-bar input[type="number"] { width: 56px; flex: none; padding: 2px 6px; font-size: 12px; }
|
|
171
|
+
#list-order { width: auto; flex: none; padding: 1px 4px; font-size: 12px; }
|
|
172
|
+
.agent-list li.agent .tag.proj { cursor: default; }
|
|
171
173
|
.agent-list { list-style: none; margin: 0; padding: 0; }
|
|
172
174
|
.agent-list li.project { border-bottom: 1px solid var(--border); }
|
|
173
175
|
.agent-list li.agent[draggable='true'] { cursor: grab; }
|
|
@@ -578,6 +580,7 @@ pre.diff .meta { color: var(--muted); font-weight: 600; }
|
|
|
578
580
|
.tag.plan-approved { color: #2f9e55; }
|
|
579
581
|
.tag.plan-changes { color: #c08a1e; }
|
|
580
582
|
.need-kind.plan { background: var(--accent); color: #fff; }
|
|
583
|
+
.need-kind.reminder, .need-kind.close { color: var(--accent); }
|
|
581
584
|
|
|
582
585
|
.bl-ai { margin: 4px 0 0; }
|
|
583
586
|
.bl-ai ul { margin: 2px 0 4px 18px; padding: 0; }
|
|
@@ -744,6 +747,10 @@ input.inline { display: inline-block; width: 80px; padding: 1px 4px; }
|
|
|
744
747
|
.kpi { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
|
|
745
748
|
.kpi-v { font-size: 20px; font-weight: 700; }
|
|
746
749
|
.kpi-l { font-size: 12px; color: var(--muted); }
|
|
750
|
+
#worklog-body .kpis { grid-template-columns: repeat(4, 1fr); }
|
|
751
|
+
@media (max-width: 560px) { #worklog-body .kpis { grid-template-columns: repeat(2, 1fr); } }
|
|
752
|
+
.worklog-events td { vertical-align: top; }
|
|
753
|
+
.worklog-events td:first-child { white-space: nowrap; }
|
|
747
754
|
.stats-table { margin: 6px 0; }
|
|
748
755
|
.stats-table summary { cursor: pointer; font-size: 13px; color: var(--muted); }
|
|
749
756
|
.spend-h { margin: 14px 0 4px; font-size: 14px; }
|
|
@@ -998,3 +1005,24 @@ body.remote .settings-links .local-only { display: none; }
|
|
|
998
1005
|
|
|
999
1006
|
/* ?perf: redraw timings */
|
|
1000
1007
|
.perf { position: fixed; right: 8px; bottom: 8px; z-index: 1000; padding: 3px 8px; border-radius: 6px; background: var(--panel, #1a1d27); color: var(--muted); font: 11px ui-monospace, Menlo, monospace; pointer-events: none; opacity: 0.9; }
|
|
1008
|
+
|
|
1009
|
+
/* Goals, at the top of the Backlog tab */
|
|
1010
|
+
.goals { border-bottom: 1px solid var(--border); padding: 6px 14px 8px; }
|
|
1011
|
+
.goals-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
|
|
1012
|
+
.goals-head .spacer { flex: 1; }
|
|
1013
|
+
.goal-cards { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
1014
|
+
.goal { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
|
|
1015
|
+
.goal.overdue { border-color: var(--red); }
|
|
1016
|
+
.goal-head { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
1017
|
+
.goal-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1018
|
+
.goal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; margin-top: 4px; }
|
|
1019
|
+
.goal-bar { display: inline-block; width: 80px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
|
|
1020
|
+
.goal-bar span { display: block; height: 100%; background: var(--green, #2da44e); }
|
|
1021
|
+
.goal-body { margin-top: 6px; font-size: 13px; }
|
|
1022
|
+
.goal-h { margin: 8px 0 2px; font-weight: 600; font-size: 12px; }
|
|
1023
|
+
.goal-list, .goal-plan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
|
|
1024
|
+
.goal-plan label { display: flex; gap: 6px; align-items: baseline; font-weight: normal; }
|
|
1025
|
+
.goal-plan input { width: auto; }
|
|
1026
|
+
.goal-projects { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 8px; }
|
|
1027
|
+
.goal-proj { display: inline-flex; align-items: center; gap: 4px; font-weight: normal; }
|
|
1028
|
+
.goal-proj input { width: auto; margin: 0; }
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Work record (menu → Work record…): what the agents got done, kept in a spreadsheet for reviews.
|
|
2
|
+
// Totals for a period, the weeks, the events, a summary to copy, and the CSV files to download.
|
|
3
|
+
|
|
4
|
+
const LABEL = { pr_opened: 'PR opened', pr_merged: 'PR merged', pr_closed: 'PR closed', bug_fixed: 'Bug fixed', issue_filed: 'Issue filed', agent_finished: 'Agent finished' };
|
|
5
|
+
|
|
6
|
+
export function initWorklog({ api, esc, toast, $ }) {
|
|
7
|
+
const dlg = $('#worklog-dialog');
|
|
8
|
+
const days = () => $('#worklog-days').value;
|
|
9
|
+
const pct = (r) => (r == null || r === '' ? '—' : `${Math.round(r * 100)}%`);
|
|
10
|
+
const hours = (h) => (h == null || h === '' ? '—' : Number(h) < 48 ? `${Number(h).toFixed(1)} h` : `${(Number(h) / 24).toFixed(1)} days`);
|
|
11
|
+
|
|
12
|
+
function fill(v) {
|
|
13
|
+
const t = v.totals;
|
|
14
|
+
const kpi = (label, value, hint = '') => `<div class="kpi"><div class="kpi-v">${value}</div><div class="kpi-l">${label}</div>${hint ? `<div class="hint">${hint}</div>` : ''}</div>`;
|
|
15
|
+
$('#worklog-body').innerHTML = `<div class="kpis">
|
|
16
|
+
${kpi('PRs merged', t.prs_merged, `${t.prs_opened} opened${t.prs_closed ? `, ${t.prs_closed} closed` : ''}`)}
|
|
17
|
+
${kpi('merge rate', pct(t.merge_rate), `median ${hours(t.median_hours_to_merge)} to merge`)}
|
|
18
|
+
${kpi('bugs fixed', t.bugs_fixed, `${t.issues_filed} issue${t.issues_filed === 1 ? '' : 's'} filed`)}
|
|
19
|
+
${kpi('agents finished', t.agents_finished)}
|
|
20
|
+
</div>
|
|
21
|
+
${v.weeks.length ? `<details class="stats-table" open><summary>By week</summary><table class="spend-table">
|
|
22
|
+
<tr><th>Week of</th><th>Merged</th><th>Opened</th><th>Bugs fixed</th><th>Filed</th><th>Finished</th><th>Cost</th></tr>
|
|
23
|
+
${v.weeks.map((w) => `<tr><td>${esc(w.week_start)}${w.current ? ' <span class="hint">so far</span>' : ''}</td><td>${w.prs_merged}</td><td>${w.prs_opened}</td><td>${w.bugs_fixed}</td><td>${w.issues_filed}</td><td>${w.agents_finished}</td><td>${w.cost_usd ? `$${Number(w.cost_usd).toFixed(2)}` : '—'}</td></tr>`).join('')}
|
|
24
|
+
</table></details>` : ''}
|
|
25
|
+
${v.events.length ? `<details class="stats-table" open><summary>What happened (${v.events.length})</summary><table class="spend-table worklog-events">
|
|
26
|
+
${v.events.slice(0, 200).map((e) => `<tr><td class="hint">${esc(e.date.slice(0, 10))}</td><td><span class="tag">${LABEL[e.event] ?? esc(e.event)}</span></td><td>${e.link ? `<a href="${esc(e.link)}" target="_blank" rel="noopener">${esc(e.title)}</a>` : esc(e.title)}<div class="hint">${esc(e.project || '')}${e.agent ? ` · <a href="#${esc(e.agent_id)}">${esc(e.agent)}</a>` : ''}</div></td></tr>`).join('')}
|
|
27
|
+
</table></details>` : '<p class="hint">Nothing recorded in this period yet. Pull requests your agents open and merge, bugs they fix, issues they file and agents that finish show up here as they happen.</p>'}`;
|
|
28
|
+
$('#worklog-files').textContent = `Appended as it happens to ${v.files.events} (one row per event) and ${v.files.weekly} (one row per week, once it's over).`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function refresh() {
|
|
32
|
+
try {
|
|
33
|
+
fill(await api('GET', `/worklog?days=${days()}`));
|
|
34
|
+
} catch (err) {
|
|
35
|
+
$('#worklog-body').innerHTML = `<p class="error">${esc(err.message)}</p>`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function download(name) {
|
|
40
|
+
const res = await fetch(`/api/worklog/${name}`, { headers: { 'x-agentmgr': '1' } });
|
|
41
|
+
if (!res.ok) return toast((await res.json().catch(() => ({}))).error || `HTTP ${res.status}`, 4000);
|
|
42
|
+
const url = URL.createObjectURL(await res.blob());
|
|
43
|
+
Object.assign(document.createElement('a'), { href: url, download: name }).click();
|
|
44
|
+
setTimeout(() => URL.revokeObjectURL(url), 10_000);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
$('#worklog-btn').onclick = async () => {
|
|
48
|
+
dlg.showModal();
|
|
49
|
+
await refresh();
|
|
50
|
+
};
|
|
51
|
+
$('#worklog-days').onchange = () => refresh();
|
|
52
|
+
$('#worklog-close').onclick = () => dlg.close();
|
|
53
|
+
$('#worklog-csv').onclick = () => download('worklog.csv');
|
|
54
|
+
$('#worklog-weekly').onclick = () => download('worklog-weekly.csv');
|
|
55
|
+
$('#worklog-copy').onclick = async () => {
|
|
56
|
+
try {
|
|
57
|
+
const { markdown } = await api('GET', `/worklog/summary?days=${days()}`);
|
|
58
|
+
await navigator.clipboard.writeText(markdown);
|
|
59
|
+
toast('Summary copied (Markdown)');
|
|
60
|
+
} catch (err) {
|
|
61
|
+
toast(`Couldn't copy: ${err.message}`, 4000);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
dlg.addEventListener('click', (e) => {
|
|
65
|
+
if (e.target.closest('a[href^="#"]')) dlg.close();
|
|
66
|
+
});
|
|
67
|
+
}
|
package/src/autopilot.js
CHANGED
|
@@ -5,30 +5,25 @@
|
|
|
5
5
|
// merge - and the pull request is merged once its checks pass and GitHub allows it (a branch that
|
|
6
6
|
// fell behind is brought up to date first; failing checks go back to the agent through Landing).
|
|
7
7
|
// Work the scorecard finds not ready for a concrete reason (failing CI, criteria not met, barely
|
|
8
|
-
// verified) goes back to the agent with
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
8
|
+
// verified) goes back to the agent with its scorecard (as Improve does), a few times at most. With a
|
|
9
|
+
// target score set for the project, work also goes back until it is ready and scores at least that,
|
|
10
|
+
// and stops early once a round no longer raises the score. Anything else ("look at these first"
|
|
11
|
+
// without a target, a failed step, a closed pull request) waits for you in the inbox, with Ship it to
|
|
12
|
+
// go ahead anyway. An item whose pull request merges is done.
|
|
12
13
|
import { landState } from './tracker.js';
|
|
13
14
|
|
|
14
15
|
export const AUTOPILOT_LEVELS = ['off', 'pr', 'merge'];
|
|
15
16
|
export const AUTOPILOT_LABEL = { off: 'Off', pr: 'Open pull requests', merge: 'Merge' };
|
|
16
|
-
const
|
|
17
|
+
const ROUNDS = 3; // times work goes back to the agent before it waits for you
|
|
18
|
+
const MIN_GAIN = 3; // with a target: a round that raised the score less than this stops the rounds
|
|
17
19
|
|
|
18
20
|
const now = () => new Date().toISOString();
|
|
19
21
|
const err = (status, message) => Object.assign(new Error(message), { status });
|
|
20
22
|
|
|
21
|
-
/** The message that sends not-ready work back to its agent. */
|
|
22
|
-
export function returnMessage(sc) {
|
|
23
|
-
const reasons = sc.reasons?.length ? sc.reasons.join('; ') : RECOMMENDATION[sc.recommendation];
|
|
24
|
-
const notMet = (sc.criteria ?? []).filter((c) => c.status === 'not_met').map((c) => `- ${c.criterion}${c.evidence ? ` (${c.evidence})` : ''}`);
|
|
25
|
-
return [`Autopilot: the review scorecard says this isn't ready yet: ${reasons}.`, notMet.length ? `Acceptance criteria not met:\n${notMet.join('\n')}` : '', 'Fix these and make sure the checks pass'].filter(Boolean).join('\n\n');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
export class Autopilot {
|
|
29
24
|
constructor({ manager, store, backlog, review, landing, config = {}, log = (m) => console.log(`[agentmgr] ${m}`) }) {
|
|
30
25
|
Object.assign(this, { manager, store, backlog, review, landing, config, log });
|
|
31
|
-
this.
|
|
26
|
+
this.rounds = config.autopilot?.rounds ?? config.autopilot?.returns ?? ROUNDS;
|
|
32
27
|
this.working = new Set(); // item ids with a step in progress
|
|
33
28
|
this.queued = null;
|
|
34
29
|
this.kick = () => this.schedule();
|
|
@@ -118,13 +113,27 @@ export class Autopilot {
|
|
|
118
113
|
return this.schedule();
|
|
119
114
|
}
|
|
120
115
|
const sc = card.data;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
const target = this.backlog.targetFor(it.projectKey);
|
|
117
|
+
const score = sc.overall ?? 0;
|
|
118
|
+
if (sc.recommendation === 'ready' && (!target || score >= target)) return this.ship(it, agent, level);
|
|
119
|
+
const rounds = ap.returns ?? 0;
|
|
120
|
+
const last = ap.scores?.at(-1); // the score when it last went back
|
|
121
|
+
const stalled = target && last != null && score - last < MIN_GAIN;
|
|
122
|
+
if ((target || sc.recommendation === 'not_ready') && rounds < this.rounds && !stalled) {
|
|
123
|
+
this.note(it, { state: 'returned', returns: rounds + 1, scores: [...(ap.scores ?? []), sc.overall], note: target ? `${sc.overall ?? '?'}/100, ships at ${target}` : sc.reasons.join('; ') });
|
|
124
|
+
const why = target ? `this ships when the review scorecard says ready and rates it ${target}/100 or more` : "the review scorecard says this isn't ready yet";
|
|
125
|
+
this.manager.improve(agent.id, { send: (text) => this.backlog.reopen(it.id, { note: `Autopilot: ${why}.\n\n${text}` }) });
|
|
125
126
|
return;
|
|
126
127
|
}
|
|
127
|
-
const
|
|
128
|
+
const tries = `${rounds} tr${rounds === 1 ? 'y' : 'ies'}`;
|
|
129
|
+
const reasons = sc.reasons.length ? `: ${sc.reasons.join('; ')}` : '';
|
|
130
|
+
const why = stalled
|
|
131
|
+
? `Stopped improving at ${sc.overall ?? '?'}/100 (was ${last} before the last try; ships at ${target})${reasons}.`
|
|
132
|
+
: target
|
|
133
|
+
? `${sc.overall ?? '?'}/100 after ${tries}; ships at ${target}${reasons}.`
|
|
134
|
+
: sc.recommendation === 'look'
|
|
135
|
+
? `The scorecard says to look first (${sc.overall ?? '?'}/100)${sc.look?.length ? `: ${sc.look.map((l) => l.file).join(', ')}` : ''}.`
|
|
136
|
+
: `Still not ready after ${tries}${reasons}.`;
|
|
128
137
|
this.hold(it, why);
|
|
129
138
|
}
|
|
130
139
|
|
package/src/backlog.js
CHANGED
|
@@ -21,6 +21,7 @@ export class Backlog extends EventEmitter {
|
|
|
21
21
|
store.data.backlog ??= { items: {}, limits: {}, autoRun: true };
|
|
22
22
|
this.data = store.data.backlog;
|
|
23
23
|
this.data.autopilot ??= {};
|
|
24
|
+
this.data.targets ??= {};
|
|
24
25
|
this.dispatching = false;
|
|
25
26
|
this.plan = null; // the AI judge's dispatch plan: { hash, data, pending }
|
|
26
27
|
|
|
@@ -46,6 +47,12 @@ export class Backlog extends EventEmitter {
|
|
|
46
47
|
return AUTOPILOT_LEVELS.includes(level) ? level : 'off';
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
/** The score autopilot ships at (50-100), or null: whenever the scorecard says ready. */
|
|
51
|
+
targetFor(projectKey) {
|
|
52
|
+
const n = Number(this.data.targets[projectKey] ?? this.config.autopilot?.target);
|
|
53
|
+
return n >= 50 && n <= 100 ? n : null;
|
|
54
|
+
}
|
|
55
|
+
|
|
49
56
|
items() {
|
|
50
57
|
return Object.values(this.data.items).sort(
|
|
51
58
|
(a, b) => a.priority - b.priority || a.order - b.order || a.createdAt.localeCompare(b.createdAt),
|
|
@@ -71,7 +78,7 @@ export class Backlog extends EventEmitter {
|
|
|
71
78
|
const projects = {};
|
|
72
79
|
for (const it of items) {
|
|
73
80
|
const shortcut = Object.values(this.store.data.projects ?? {}).find((x) => x.key === it.projectKey)?.shortcut ?? null;
|
|
74
|
-
const p = (projects[it.projectKey] ??= { key: it.projectKey, name: it.projectName, shortcut, limit: this.limitFor(it.projectKey), autopilot: this.autopilotFor(it.projectKey), counts: {} });
|
|
81
|
+
const p = (projects[it.projectKey] ??= { key: it.projectKey, name: it.projectName, shortcut, limit: this.limitFor(it.projectKey), autopilot: this.autopilotFor(it.projectKey), target: this.targetFor(it.projectKey), counts: {} });
|
|
75
82
|
p.counts[it.status] = (p.counts[it.status] ?? 0) + 1;
|
|
76
83
|
}
|
|
77
84
|
return {
|
|
@@ -188,7 +195,7 @@ export class Backlog extends EventEmitter {
|
|
|
188
195
|
return { id };
|
|
189
196
|
}
|
|
190
197
|
|
|
191
|
-
settings({ autoRun, limits, project, limit, autopilot } = {}) {
|
|
198
|
+
settings({ autoRun, limits, project, limit, autopilot, target } = {}) {
|
|
192
199
|
if (typeof autoRun === 'boolean') this.data.autoRun = autoRun;
|
|
193
200
|
if (limits && typeof limits === 'object') Object.assign(this.data.limits, limits);
|
|
194
201
|
const key =
|
|
@@ -199,6 +206,11 @@ export class Backlog extends EventEmitter {
|
|
|
199
206
|
if (!AUTOPILOT_LEVELS.includes(autopilot)) throw err(400, `autopilot must be one of ${AUTOPILOT_LEVELS.join(', ')}`);
|
|
200
207
|
this.data.autopilot[key] = autopilot;
|
|
201
208
|
}
|
|
209
|
+
if (key && target !== undefined) {
|
|
210
|
+
const n = target === null || target === '' || target === 'none' ? 0 : Number(target);
|
|
211
|
+
if (!(n === 0 || (n >= 50 && n <= 100))) throw err(400, 'target must be 50-100, or none');
|
|
212
|
+
this.data.targets[key] = n; // 0: none, even with a default in config.json
|
|
213
|
+
}
|
|
202
214
|
if (key && limit !== undefined) {
|
|
203
215
|
const n = Number(limit);
|
|
204
216
|
if (!(n >= 0 && n <= 20)) throw err(400, 'limit must be 0-20');
|
package/src/brief.js
CHANGED
|
@@ -27,7 +27,8 @@ export const briefPrompt = (file) =>
|
|
|
27
27
|
'"- [ ]" pending, "- [~]" running, "- [x]" passed, "- [!]" failed.\n' +
|
|
28
28
|
'## Results\nThe end result so far. First line "Outcome: in progress | partial | done | blocked". Then bullets:\n' +
|
|
29
29
|
'"- Delivered: ..." for each concrete result (PR or commit links, files, documents, answers), and\n' +
|
|
30
|
-
'"- Blocked by: ... (needs: who or what)" for anything blocking progress
|
|
30
|
+
'"- Blocked by: ... (needs: who or what)" for anything blocking progress, and\n' +
|
|
31
|
+
'"- Filed: <issue link> <title>" for each bug or issue you opened (GitHub, Jira, ...). Keep it current; it is what reviewers read first.\n' +
|
|
31
32
|
'Add a fifth section only when the task links Jira issues (or other tickets):\n' +
|
|
32
33
|
'## References\nLook each linked issue up (use your Jira / Atlassian tools if you have them) and list the ' +
|
|
33
34
|
'documents its fields point to, above all its PRD and Tech Spec fields, plus design docs or Confluence pages. ' +
|
|
@@ -94,8 +95,9 @@ export function parseBrief(markdown) {
|
|
|
94
95
|
// Tolerates "Delivered:", "**Delivered:**" and "**Delivered**:".
|
|
95
96
|
delivered: pick(/^\s*[-*]\s+\**\s*delivered\s*\**\s*:\s*\**\s*(.+)$/i),
|
|
96
97
|
blockers: pick(/^\s*[-*]\s+\**\s*blocked by\s*\**\s*:\s*\**\s*(.+)$/i),
|
|
98
|
+
filed: pick(/^\s*[-*]\s+\**\s*filed\s*\**\s*:\s*\**\s*(.+)$/i),
|
|
97
99
|
notes: lines
|
|
98
|
-
.filter((l) => !/^\s*\**\s*outcome\s*\**\s*:/i.test(l) && !/^\s*[-*]\s+\**\s*(delivered|blocked by)\s*\**\s*:/i.test(l))
|
|
100
|
+
.filter((l) => !/^\s*\**\s*outcome\s*\**\s*:/i.test(l) && !/^\s*[-*]\s+\**\s*(delivered|blocked by|filed)\s*\**\s*:/i.test(l))
|
|
99
101
|
.join('\n')
|
|
100
102
|
.trim(),
|
|
101
103
|
};
|