ai-agentmanager 1.17.0 → 1.18.1
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 +41 -3
- package/package.json +1 -1
- package/public/app.js +92 -7
- package/public/goals.js +153 -0
- package/public/index.html +39 -0
- 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 +101 -5
- package/src/config.js +1 -1
- package/src/goals.js +359 -0
- package/src/manager.js +42 -6
- package/src/reminders.js +58 -0
- package/src/server.js +47 -2
- package/src/worklog.js +265 -0
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>
|
|
@@ -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
|
};
|
package/src/cli.js
CHANGED
|
@@ -615,6 +615,25 @@ export async function main(argv) {
|
|
|
615
615
|
console.log(`${green('✓')} ${r.existing ? 'pushed to' : 'opened'} ${r.url ?? '(no URL printed by gh)'}`);
|
|
616
616
|
});
|
|
617
617
|
|
|
618
|
+
program
|
|
619
|
+
.command('worklog')
|
|
620
|
+
.description('Work record: pull requests opened and merged, bugs fixed, issues filed, agents finished; also appended to ~/.agentmanager/worklog.csv')
|
|
621
|
+
.option('-d, --days <n>', 'the last n days (0: all time)', '30')
|
|
622
|
+
.option('--summary', 'print the period as Markdown, for a review or status update')
|
|
623
|
+
.option('--json', 'print JSON')
|
|
624
|
+
.action(async (opts) => {
|
|
625
|
+
await daemon();
|
|
626
|
+
if (opts.summary) return console.log((await api('GET', `/worklog/summary?days=${Number(opts.days) || 0}`)).markdown);
|
|
627
|
+
const v = await api('GET', `/worklog?days=${Number(opts.days) || 0}`);
|
|
628
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
629
|
+
const t = v.totals;
|
|
630
|
+
console.log(bold(`Work record, ${v.days ? `last ${v.days} days` : 'all time'}`));
|
|
631
|
+
console.log(` PRs merged ${bold(t.prs_merged)} opened ${t.prs_opened}${t.prs_closed ? ` closed ${t.prs_closed}` : ''}${t.merge_rate != null ? ` merge rate ${Math.round(t.merge_rate * 100)}%` : ''}${t.median_hours_to_merge != null ? ` median ${t.median_hours_to_merge} h to merge` : ''}`);
|
|
632
|
+
console.log(` bugs fixed ${bold(t.bugs_fixed)} issues filed ${t.issues_filed} agents finished ${t.agents_finished}`);
|
|
633
|
+
for (const e of v.events.slice(0, 15)) console.log(dim(` ${e.date.slice(0, 10)} ${e.event.replace('_', ' ').padEnd(14)} ${truncate(e.title, 60)}${e.link ? ` ${e.link}` : ''}`));
|
|
634
|
+
console.log(dim(`\n ${v.files.events}\n ${v.files.weekly}`));
|
|
635
|
+
});
|
|
636
|
+
|
|
618
637
|
program
|
|
619
638
|
.command('stats')
|
|
620
639
|
.description('Results across agents: merge rate, time to a first PR and to merge, cost per merged PR, by engine and model')
|
|
@@ -888,7 +907,7 @@ export async function main(argv) {
|
|
|
888
907
|
await daemon();
|
|
889
908
|
const items = await api('GET', '/inbox');
|
|
890
909
|
if (!items.length) return console.log(dim('Nothing needs you right now.'));
|
|
891
|
-
const label = { prompt: red('needs input'), waiting: red('waiting'), question: cyan('question'), review: cyan('AI review'), stuck: yellow('stuck?'), conflict: yellow('overlap') };
|
|
910
|
+
const label = { prompt: red('needs input'), waiting: red('waiting'), question: cyan('question'), review: cyan('AI review'), stuck: yellow('stuck?'), conflict: yellow('overlap'), reminder: cyan('follow up') };
|
|
892
911
|
for (const it of items) {
|
|
893
912
|
if (it.kind === 'repeat') {
|
|
894
913
|
console.log(`${cyan('make it a playbook?')} asked ${it.count} times: ${it.intent}`);
|
|
@@ -915,6 +934,11 @@ export async function main(argv) {
|
|
|
915
934
|
if (it.kind === 'review') console.log(dim(` ${it.review.verdict.replace('_', ' ')}${it.review.missing.length ? `; missing: ${it.review.missing.join('; ')}` : ''}`));
|
|
916
935
|
if (it.kind === 'stuck') console.log(dim(` ${it.finding.detail}\n nudge: agentmgr tell ${it.agentId} "…"`));
|
|
917
936
|
if (it.kind === 'conflict') console.log(dim(` ${it.conflict.files.map((f) => f.file).join(', ')}`));
|
|
937
|
+
if (it.kind === 'reminder') {
|
|
938
|
+
const r = it.reminder;
|
|
939
|
+
const next = r.kind === 'close' ? `close: agentmgr close ${it.agentId}` : r.closed ? `resume: agentmgr start ${it.agentId}` : `nudge: agentmgr tell ${it.agentId} "…" · close: agentmgr close ${it.agentId}`;
|
|
940
|
+
console.log(dim(` ${r.detail ? `${r.detail}\n ` : ''}${next} · later: agentmgr remind ${it.agentId} later|dismiss`));
|
|
941
|
+
}
|
|
918
942
|
}
|
|
919
943
|
});
|
|
920
944
|
|
|
@@ -1270,6 +1294,65 @@ export async function main(argv) {
|
|
|
1270
1294
|
console.log(`removed ${sc}`);
|
|
1271
1295
|
});
|
|
1272
1296
|
|
|
1297
|
+
const goal = program.command('goal').description('Goals: outcomes for today or this week across projects, planned into tasks that agents see through');
|
|
1298
|
+
const printGoal = (g) => {
|
|
1299
|
+
const c = g.counts;
|
|
1300
|
+
console.log(`${bold(g.id)} ${g.title} ${dim(`[${g.status}${g.overdue ? ', overdue' : ''}]`)}`);
|
|
1301
|
+
console.log(dim(` ${g.projects.join(', ')}${g.due ? ` due ${g.due.slice(0, 10)}` : ''} ${c.completed} completed · ${c.pending} pending · ${c.followUps} follow-ups${g.error ? ` ${g.error}` : ''}`));
|
|
1302
|
+
};
|
|
1303
|
+
goal
|
|
1304
|
+
.command('add')
|
|
1305
|
+
.description('Plan an outcome into tasks and start agents on them')
|
|
1306
|
+
.argument('<outcome>', 'what should be true when it is done')
|
|
1307
|
+
.requiredOption('-p, --projects <shortcuts>', 'comma-separated project shortcuts (agentmgr project ls)')
|
|
1308
|
+
.option('--today', 'due today')
|
|
1309
|
+
.option('--no-deadline', 'no due date (default: this week)')
|
|
1310
|
+
.option('--review', 'show the plan first; start it with: agentmgr goal approve <id>')
|
|
1311
|
+
.option('--priority <p>', '0-3 (P0 highest)', '2')
|
|
1312
|
+
.action(async (text, opts) => {
|
|
1313
|
+
await daemon();
|
|
1314
|
+
const period = opts.today ? 'day' : opts.deadline === false ? 'none' : 'week';
|
|
1315
|
+
printGoal(await api('POST', '/goals', { text, projects: opts.projects.split(','), period, review: Boolean(opts.review), priority: Number(opts.priority) }));
|
|
1316
|
+
console.log(dim(` planning; see it with: agentmgr goal show <id>`));
|
|
1317
|
+
});
|
|
1318
|
+
goal
|
|
1319
|
+
.command('ls')
|
|
1320
|
+
.description('Goals with completed, pending and follow-ups')
|
|
1321
|
+
.action(async () => {
|
|
1322
|
+
await daemon();
|
|
1323
|
+
const list = await api('GET', '/goals');
|
|
1324
|
+
if (!list.length) return console.log(dim('No goals yet. Add one: agentmgr goal add "outcome" -p <project>'));
|
|
1325
|
+
list.forEach(printGoal);
|
|
1326
|
+
});
|
|
1327
|
+
goal
|
|
1328
|
+
.command('show')
|
|
1329
|
+
.description("A goal's summary: completed, pending and follow-ups (Markdown)")
|
|
1330
|
+
.argument('<id>')
|
|
1331
|
+
.action(async (id) => {
|
|
1332
|
+
await daemon();
|
|
1333
|
+
const g = (await api('GET', '/goals')).find((x) => x.id === id);
|
|
1334
|
+
if (g?.status === 'review') console.log(`Plan (start with: agentmgr goal approve ${id}):\n${g.plan.map((t, i) => ` ${i + 1}. [${t.project}] ${t.title}`).join('\n')}\n`);
|
|
1335
|
+
console.log((await api('GET', `/goals/${id}/summary`)).markdown);
|
|
1336
|
+
});
|
|
1337
|
+
for (const [name, desc, method, route] of [
|
|
1338
|
+
['approve', 'Start a goal whose plan you reviewed', 'POST', 'approve'],
|
|
1339
|
+
['replan', 'Plan a goal again', 'POST', 'replan'],
|
|
1340
|
+
['extend', 'Carry an overdue goal over to the next day or week', 'POST', 'extend'],
|
|
1341
|
+
['stop', 'Stop a goal: its queued tasks are cancelled', 'POST', 'stop'],
|
|
1342
|
+
['rm', 'Remove a stopped or finished goal', 'DELETE', ''],
|
|
1343
|
+
]) {
|
|
1344
|
+
goal
|
|
1345
|
+
.command(name)
|
|
1346
|
+
.description(desc)
|
|
1347
|
+
.argument('<id>')
|
|
1348
|
+
.action(async (id) => {
|
|
1349
|
+
await daemon();
|
|
1350
|
+
const r = await api(method, `/goals/${id}${route ? `/${route}` : ''}`);
|
|
1351
|
+
if (r.counts) printGoal(r);
|
|
1352
|
+
else console.log(`${green('✓')} removed`);
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1273
1356
|
const bl = program.command('backlog').description('Work orders that agents pick up one by one, per project, until done');
|
|
1274
1357
|
const ST = { queued: dim('queued'), active: green('active'), review: yellow('review'), blocked: red('blocked'), done: dim('done'), cancelled: dim('cancelled') };
|
|
1275
1358
|
const printBacklog = (v, { all = false } = {}) => {
|
|
@@ -1281,13 +1364,13 @@ export async function main(argv) {
|
|
|
1281
1364
|
for (const it of items) {
|
|
1282
1365
|
if (it.projectKey !== last) {
|
|
1283
1366
|
const p = proj[it.projectKey];
|
|
1284
|
-
const ap = p?.autopilot && p.autopilot !== 'off' ? `, autopilot: ${p.autopilot === 'merge' ? 'merge' : 'open PRs'}` : '';
|
|
1367
|
+
const ap = p?.autopilot && p.autopilot !== 'off' ? `, autopilot: ${p.autopilot === 'merge' ? 'merge' : 'open PRs'}${p.target ? ` at ${p.target}+` : ''}` : '';
|
|
1285
1368
|
console.log(`\n${bold(it.projectName)} ${dim(`(${p?.limit ?? v.defaultLimit} at a time${ap})`)}`);
|
|
1286
1369
|
last = it.projectKey;
|
|
1287
1370
|
}
|
|
1288
1371
|
const agent = it.agent ? dim(` → ${it.agent.name} (${it.agent.id})${it.agent.briefStatus ? ` brief: ${it.agent.briefStatus}` : ''}`) : '';
|
|
1289
1372
|
console.log(` ${it.id} P${it.priority} ${(ST[it.status] ?? it.status).padEnd(18)} ${truncate(it.title, 60)}${agent}`);
|
|
1290
|
-
if (it.status === 'review' && it.autopilot?.state) console.log(dim(` autopilot: ${it.autopilot.state}${it.autopilot.pr ? ` ${it.autopilot.pr}` : ''}${it.autopilot.note ? `: ${it.autopilot.note}` : ''}`));
|
|
1373
|
+
if (it.status === 'review' && it.autopilot?.state) console.log(dim(` autopilot: ${it.autopilot.state}${it.autopilot.pr ? ` ${it.autopilot.pr}` : ''}${it.autopilot.note ? `: ${it.autopilot.note}` : ''}${it.autopilot.scores?.length ? ` (scores ${it.autopilot.scores.join(' → ')})` : ''}`));
|
|
1291
1374
|
}
|
|
1292
1375
|
};
|
|
1293
1376
|
bl.command('ls')
|
|
@@ -1379,9 +1462,10 @@ export async function main(argv) {
|
|
|
1379
1462
|
.description("Take a project's finished items on by themselves when the review scorecard says ready: off, pr (open the pull request) or merge (and merge it once checks pass)")
|
|
1380
1463
|
.argument('<project>', 'project name as shown in "backlog ls"')
|
|
1381
1464
|
.argument('<level>', 'off, pr or merge')
|
|
1382
|
-
.
|
|
1465
|
+
.option('--target <score>', 'ship only at this review score or more (50-100), sending the work back to improve until then; "none" ships when ready')
|
|
1466
|
+
.action(async (project, level, opts) => {
|
|
1383
1467
|
await daemon();
|
|
1384
|
-
printBacklog(await api('POST', '/backlog/settings', { project, autopilot: level }));
|
|
1468
|
+
printBacklog(await api('POST', '/backlog/settings', { project, autopilot: level, ...(opts.target !== undefined ? { target: opts.target } : {}) }));
|
|
1385
1469
|
});
|
|
1386
1470
|
itemCmd('ship', 'Go ahead with an item autopilot held: open its pull request (and merge, at the merge level)', 'ship');
|
|
1387
1471
|
bl.command('pause')
|
|
@@ -2075,6 +2159,18 @@ export async function main(argv) {
|
|
|
2075
2159
|
}
|
|
2076
2160
|
});
|
|
2077
2161
|
|
|
2162
|
+
program
|
|
2163
|
+
.command('remind')
|
|
2164
|
+
.description('Snooze a follow-up reminder: later (a few hours) or dismiss (until the agent is used again)')
|
|
2165
|
+
.argument('<agent>')
|
|
2166
|
+
.argument('<action>', 'later or dismiss')
|
|
2167
|
+
.action(async (ref, action) => {
|
|
2168
|
+
await daemon();
|
|
2169
|
+
const a = await resolveAgent(ref);
|
|
2170
|
+
await api('POST', `/agents/${a.id}/reminder`, { action });
|
|
2171
|
+
console.log(`${green('✓')} ${action === 'later' ? 'reminding you later about' : 'no reminder until it is used again for'} ${a.name}`);
|
|
2172
|
+
});
|
|
2173
|
+
|
|
2078
2174
|
program
|
|
2079
2175
|
.command('rm')
|
|
2080
2176
|
.description('Forget agents (optionally deleting worktrees agentmgr created)')
|
package/src/config.js
CHANGED
|
@@ -63,7 +63,7 @@ const DEFAULTS = {
|
|
|
63
63
|
// Pre-accept Claude's "trust this folder" prompt for the folders agents run in.
|
|
64
64
|
trustAgentFolders: true,
|
|
65
65
|
// A planning session moves into the repo by itself once Claude has been idle this
|
|
66
|
-
// long and
|
|
66
|
+
// long (and, with its terminal open, you haven't typed for 15 seconds).
|
|
67
67
|
handoffIdleSec: 5,
|
|
68
68
|
// The AI judge (stuck, idle screens, reviews); see JUDGE_DEFAULTS in judge.js for every field.
|
|
69
69
|
judge: { enabled: true },
|