ai-agentmanager 1.17.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/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 those reasons, a couple of times at most. Anything else
9
- // ("look at these first", a failed step, a closed pull request) waits for you in the inbox, with
10
- // Ship it to go ahead anyway. An item whose pull request merges is done.
11
- import { RECOMMENDATION } from './scorecard.js';
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 RETURNS = 2; // times not-ready work goes back to the agent before it waits for you
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.returns = config.autopilot?.returns ?? RETURNS;
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
- if (sc.recommendation === 'ready') return this.ship(it, agent, level);
122
- if (sc.recommendation === 'not_ready' && (ap.returns ?? 0) < this.returns) {
123
- this.note(it, { state: 'returned', returns: (ap.returns ?? 0) + 1, note: sc.reasons.join('; ') });
124
- this.backlog.reopen(it.id, { note: returnMessage(sc) });
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 why = sc.recommendation === 'look' ? `The scorecard says to look first (${sc.overall ?? '?'}/100)${sc.look?.length ? `: ${sc.look.map((l) => l.file).join(', ')}` : ''}.` : `Still not ready after ${ap.returns ?? 0} tr${ap.returns === 1 ? 'y' : 'ies'}: ${sc.reasons.join('; ')}.`;
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. Keep it current; it is what reviewers read first.\n' +
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
- .action(async (project, level) => {
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)')