ai-agentmanager 1.46.0 → 1.47.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 +9 -0
- package/README.md +64 -0
- package/package.json +1 -1
- package/public/app.js +29 -1
- package/public/index.html +5 -0
- package/public/keys.js +3 -2
- package/public/plan.js +323 -0
- package/public/style.css +59 -0
- package/public/today.js +102 -2
- package/src/calendar.js +385 -0
- package/src/cli.js +92 -0
- package/src/config.js +4 -0
- package/src/debt.js +276 -0
- package/src/decisions.js +188 -0
- package/src/milestones.js +282 -0
- package/src/notify.js +1 -0
- package/src/server.js +98 -3
- package/src/today.js +3 -1
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// Dates: a project's commitments (code complete, release candidate, GA) and what stands between
|
|
2
|
+
// now and each. For every date it plans the reminders (14, 7, 3 and 1 days before, and the day)
|
|
3
|
+
// and keeps a checklist: what the app can see for itself (agents still working, backlog not done,
|
|
4
|
+
// pull requests open or failing, serious bugs open) and what only you can tick (release notes, the
|
|
5
|
+
// RC cut, docs), each of which an agent can be asked to do. A date close with work still open is
|
|
6
|
+
// "at risk"; one that has passed is "late". Reminders go to Slack (when alerts are on) and the
|
|
7
|
+
// dates show in Today as they come near.
|
|
8
|
+
|
|
9
|
+
const DAY = 86_400_000;
|
|
10
|
+
export const STAGES = [
|
|
11
|
+
['codeComplete', 'Code complete'],
|
|
12
|
+
['rc', 'Release candidate'],
|
|
13
|
+
['ga', 'GA'],
|
|
14
|
+
];
|
|
15
|
+
export const REMIND_DAYS = [14, 7, 3, 1, 0];
|
|
16
|
+
const OPEN_BACKLOG = new Set(['queued', 'active', 'review', 'blocked']);
|
|
17
|
+
|
|
18
|
+
const err = (status, message) => Object.assign(new Error(message), { status });
|
|
19
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
20
|
+
|
|
21
|
+
/** "2026-12-01" as that local day, or null. */
|
|
22
|
+
export function dayOf(s) {
|
|
23
|
+
const m = String(s ?? '').match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
24
|
+
if (!m) return null;
|
|
25
|
+
const d = new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]));
|
|
26
|
+
return d.getMonth() === Number(m[2]) - 1 && d.getDate() === Number(m[3]) ? d : null;
|
|
27
|
+
}
|
|
28
|
+
const dayIndex = (d) => Math.round(new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime() / DAY);
|
|
29
|
+
/** Whole days from `now` to the date: 0 today, negative once it has passed. */
|
|
30
|
+
export const daysLeft = (date, now = new Date()) => dayIndex(dayOf(date)) - dayIndex(now);
|
|
31
|
+
|
|
32
|
+
/** "in 12 days", "tomorrow", "today", "3 days late". */
|
|
33
|
+
export function leftWords(n) {
|
|
34
|
+
if (n < 0) return `${plural(-n, 'day')} late`;
|
|
35
|
+
if (n === 0) return 'today';
|
|
36
|
+
if (n === 1) return 'tomorrow';
|
|
37
|
+
return `in ${n} days`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The reminders planned for a date: [{ offset, on: "YYYY-MM-DD", label }], soonest last. */
|
|
41
|
+
export function remindersFor(date) {
|
|
42
|
+
const d = dayOf(date);
|
|
43
|
+
if (!d) return [];
|
|
44
|
+
return REMIND_DAYS.map((offset) => {
|
|
45
|
+
const on = new Date(d.getFullYear(), d.getMonth(), d.getDate() - offset);
|
|
46
|
+
const iso = `${on.getFullYear()}-${String(on.getMonth() + 1).padStart(2, '0')}-${String(on.getDate()).padStart(2, '0')}`;
|
|
47
|
+
return { offset, on: iso, label: offset === 0 ? 'the day' : offset === 1 ? 'the day before' : `${offset} days before` };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A stage's checklist from the project's facts. `auto` items are counted by the app (ok at 0);
|
|
53
|
+
* the others are yours to tick, and `task` is what an agent is asked when you hand one over.
|
|
54
|
+
*/
|
|
55
|
+
export function checklistFor(stage, f, { name = 'the project', date = '' } = {}) {
|
|
56
|
+
const auto = (key, n, text, zero, names = [], go = null) => ({ key, auto: true, count: n, ok: n === 0, text: n ? text : zero, names: names.slice(0, 6), go });
|
|
57
|
+
const manual = (key, text, task) => ({ key, auto: false, text, task });
|
|
58
|
+
const serious = auto('bugs', f.bugs.length, `${plural(f.bugs.length, 'critical or high bug')} open`, 'No critical or high bugs open', f.bugs.map((b) => b.title), 'bugs');
|
|
59
|
+
if (stage === 'codeComplete') {
|
|
60
|
+
return [
|
|
61
|
+
auto('working', f.working.length, `${plural(f.working.length, 'agent')} still working`, 'No agent still working', f.working.map((a) => a.name), 'agents'),
|
|
62
|
+
auto('backlog', f.backlog.length, `${plural(f.backlog.length, 'backlog item')} not finished`, 'The backlog is finished', f.backlog.map((b) => b.title), 'backlog'),
|
|
63
|
+
auto('waiting', f.waiting.length, `${plural(f.waiting.length, 'thing')} waiting on you (plans, questions, prompts)`, 'Nothing waiting on you', f.waiting.map((a) => a.name), 'inbox'),
|
|
64
|
+
manual('scope', 'Scope agreed: what is in and what moved out', null),
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
if (stage === 'rc') {
|
|
68
|
+
return [
|
|
69
|
+
auto('prs', f.prs.length, `${plural(f.prs.length, 'pull request')} still open`, 'No pull requests open', f.prs.map((p) => `#${p.number ?? '?'} ${p.title ?? ''}`.trim()), 'land'),
|
|
70
|
+
auto('checks', f.failing.length, `${plural(f.failing.length, 'pull request')} with failing checks`, 'No failing checks', f.failing.map((p) => `#${p.number ?? '?'} ${p.title ?? ''}`.trim()), 'land'),
|
|
71
|
+
serious,
|
|
72
|
+
manual('notes', 'Release notes and changelog drafted', `Draft the release notes and the changelog entry for the ${name} release candidate${date ? ` (RC on ${date})` : ''}: read what was merged since the last release, group it by what users will notice, and call out breaking changes and upgrade steps. Open a pull request with the changelog.`),
|
|
73
|
+
manual('cut', 'Release candidate cut and smoke-tested', null),
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
return [
|
|
77
|
+
serious,
|
|
78
|
+
auto('prs', f.prs.length, `${plural(f.prs.length, 'pull request')} still open`, 'No pull requests open', f.prs.map((p) => `#${p.number ?? '?'} ${p.title ?? ''}`.trim()), 'land'),
|
|
79
|
+
manual('docs', 'Docs and upgrade notes up to date', `Bring the docs of ${name} up to date for the GA release${date ? ` on ${date}` : ''}: compare the README and docs with what changed since the last release, fix what is out of date, and add upgrade notes for anything that changes behaviour. Open a pull request.`),
|
|
80
|
+
manual('final-notes', 'Release notes final', `Finish the release notes of ${name} for GA${date ? ` on ${date}` : ''}: check every entry against what was actually merged, in the words a user would use, with the breaking changes first. Open a pull request.`),
|
|
81
|
+
manual('publish', 'Version bumped, tagged and published', null),
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Where a date stands: reached, late, at-risk (a week or less with counted work open) or on-track. */
|
|
86
|
+
export function stageStatus({ n, reached, open }) {
|
|
87
|
+
if (reached) return 'reached';
|
|
88
|
+
if (n < 0) return 'late';
|
|
89
|
+
if (n <= 7 && open > 0) return 'at-risk';
|
|
90
|
+
return 'on-track';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The reminder that is due now: the nearest offset the date is within, or "late"; null when none yet. */
|
|
94
|
+
export function dueReminder(n) {
|
|
95
|
+
if (n < 0) return 'late';
|
|
96
|
+
const o = [...REMIND_DAYS].sort((a, b) => a - b).find((x) => n <= x);
|
|
97
|
+
return o === undefined ? null : String(o);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class Milestones {
|
|
101
|
+
/** `facts(project)` gathers what's open in a project; `notify(text, plain)` sends a reminder; `queue(project, title)` hands a task to an agent. */
|
|
102
|
+
constructor({ store, projects, facts, notify = null, queue = null, onChange = () => {}, log = (m) => console.log(`[agentmgr] ${m}`), now = () => new Date(), timer = true }) {
|
|
103
|
+
Object.assign(this, { store, projects, facts, notify, queue, onChange, log, now });
|
|
104
|
+
if (timer) {
|
|
105
|
+
this.timer = setInterval(() => this.tick().catch((e) => this.log(`dates: ${e.message}`)), 30 * 60_000);
|
|
106
|
+
this.first = setTimeout(() => this.tick().catch(() => {}), 45_000);
|
|
107
|
+
this.timer.unref?.();
|
|
108
|
+
this.first.unref?.();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
close() {
|
|
113
|
+
clearInterval(this.timer);
|
|
114
|
+
clearTimeout(this.first);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get all() {
|
|
118
|
+
return (this.store.data.milestones ??= {});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
project(ref) {
|
|
122
|
+
const r = String(ref ?? '').trim().replace(/^@/, '').toLowerCase();
|
|
123
|
+
const p = this.projects().find((x) => x.shortcut === r || x.key === ref || x.name.toLowerCase() === r);
|
|
124
|
+
if (!p) throw err(404, `No project matches "${ref}"`);
|
|
125
|
+
return p;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Set (or with null, clear) a project's dates: { codeComplete, rc, ga } as "YYYY-MM-DD", in that order. */
|
|
129
|
+
set(ref, dates = {}) {
|
|
130
|
+
const p = this.project(ref);
|
|
131
|
+
const rec = (this.all[p.key] ??= { dates: {}, done: {}, reached: {}, sent: {} });
|
|
132
|
+
const next = { ...rec.dates };
|
|
133
|
+
for (const [id, label] of STAGES) {
|
|
134
|
+
if (!(id in dates)) continue;
|
|
135
|
+
const v = dates[id];
|
|
136
|
+
if (v === null || v === '') delete next[id];
|
|
137
|
+
else if (!dayOf(v)) throw err(400, `${label}: a date like 2026-12-01`);
|
|
138
|
+
else next[id] = v;
|
|
139
|
+
}
|
|
140
|
+
const order = STAGES.map(([id]) => next[id]).filter(Boolean);
|
|
141
|
+
if (order.some((d, i) => i && d < order[i - 1])) throw err(400, 'The dates go in order: code complete, then the release candidate, then GA');
|
|
142
|
+
// A date that moved gets its reminders again.
|
|
143
|
+
for (const [id] of STAGES) if (next[id] !== rec.dates[id]) delete rec.sent[id];
|
|
144
|
+
rec.dates = next;
|
|
145
|
+
if (!Object.keys(next).length) delete this.all[p.key];
|
|
146
|
+
this.store.save();
|
|
147
|
+
this.onChange();
|
|
148
|
+
return this.view();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Tick (or untick) one of your checklist items. */
|
|
152
|
+
check(ref, stage, key, done = true) {
|
|
153
|
+
const rec = this.rec(ref, stage);
|
|
154
|
+
rec.done[`${stage}:${key}`] = done ? this.now().toISOString() : undefined;
|
|
155
|
+
this.store.save();
|
|
156
|
+
this.onChange();
|
|
157
|
+
return this.view();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** The date was met (or, with false, not after all): no more reminders for it. */
|
|
161
|
+
reach(ref, stage, reached = true) {
|
|
162
|
+
const rec = this.rec(ref, stage);
|
|
163
|
+
rec.reached[stage] = reached ? this.now().toISOString() : undefined;
|
|
164
|
+
this.store.save();
|
|
165
|
+
this.onChange();
|
|
166
|
+
return this.view();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
rec(ref, stage) {
|
|
170
|
+
const p = this.project(ref);
|
|
171
|
+
const rec = this.all[p.key];
|
|
172
|
+
if (!rec?.dates?.[stage]) throw err(404, 'That date is not set for this project');
|
|
173
|
+
return rec;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Hand one of your checklist items to an agent (through the backlog). */
|
|
177
|
+
task(ref, stage, key) {
|
|
178
|
+
const p = this.project(ref);
|
|
179
|
+
const rec = this.rec(ref, stage);
|
|
180
|
+
const item = checklistFor(stage, this.facts(p), { name: p.name, date: rec.dates[stage] }).find((i) => i.key === key);
|
|
181
|
+
if (!item?.task) throw err(400, 'That item has nothing an agent can do');
|
|
182
|
+
if (!this.queue) throw err(409, 'The backlog is not available');
|
|
183
|
+
const added = this.queue(p, item.task);
|
|
184
|
+
rec.tasks = { ...rec.tasks, [`${stage}:${key}`]: { at: this.now().toISOString(), id: added?.id ?? null } };
|
|
185
|
+
this.store.save();
|
|
186
|
+
this.onChange();
|
|
187
|
+
return this.view();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
stages(p, now = this.now()) {
|
|
191
|
+
const rec = this.all[p.key];
|
|
192
|
+
if (!rec) return [];
|
|
193
|
+
const f = this.facts(p);
|
|
194
|
+
return STAGES.filter(([id]) => rec.dates[id]).map(([id, label]) => {
|
|
195
|
+
const date = rec.dates[id];
|
|
196
|
+
const n = daysLeft(date, now);
|
|
197
|
+
const reached = rec.reached?.[id] ?? null;
|
|
198
|
+
const checklist = checklistFor(id, f, { name: p.name, date }).map((i) => (i.auto ? i : { ...i, done: Boolean(rec.done?.[`${id}:${i.key}`]), asked: rec.tasks?.[`${id}:${i.key}`]?.at ?? null, task: Boolean(i.task) }));
|
|
199
|
+
const open = checklist.filter((i) => i.auto && !i.ok).reduce((s, i) => s + i.count, 0);
|
|
200
|
+
const todo = checklist.filter((i) => !i.auto && !i.done).length;
|
|
201
|
+
return {
|
|
202
|
+
id,
|
|
203
|
+
label,
|
|
204
|
+
date,
|
|
205
|
+
daysLeft: n,
|
|
206
|
+
words: reached ? 'reached' : leftWords(n),
|
|
207
|
+
status: stageStatus({ n, reached, open }),
|
|
208
|
+
reached,
|
|
209
|
+
open,
|
|
210
|
+
todo,
|
|
211
|
+
checklist,
|
|
212
|
+
reminders: remindersFor(date).map((r) => ({ ...r, sent: Boolean(rec.sent?.[id]?.[String(r.offset)]), past: daysLeft(r.on, now) < 0 })),
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
view() {
|
|
218
|
+
const now = this.now();
|
|
219
|
+
const list = this.projects();
|
|
220
|
+
const projects = list
|
|
221
|
+
.filter((p) => this.all[p.key])
|
|
222
|
+
.map((p) => {
|
|
223
|
+
const stages = this.stages(p, now);
|
|
224
|
+
return { key: p.key, shortcut: p.shortcut, name: p.name, stages, next: stages.find((s) => !s.reached) ?? null };
|
|
225
|
+
})
|
|
226
|
+
.sort((a, b) => (a.next?.daysLeft ?? 1e9) - (b.next?.daysLeft ?? 1e9) || a.name.localeCompare(b.name));
|
|
227
|
+
return { projects, others: list.filter((p) => !this.all[p.key]).map((p) => ({ key: p.key, shortcut: p.shortcut, name: p.name })), stages: STAGES.map(([id, label]) => ({ id, label })), remindDays: REMIND_DAYS };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** What's open for a date, in a few words: "2 agents still working, 3 pull requests still open". */
|
|
231
|
+
openWords(s) {
|
|
232
|
+
const parts = s.checklist.filter((i) => i.auto && !i.ok).map((i) => i.text);
|
|
233
|
+
const mine = s.checklist.filter((i) => !i.auto && !i.done).map((i) => i.text);
|
|
234
|
+
return [...parts, ...(mine.length ? [`yours: ${mine.join('; ')}`] : [])].join(', ');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** For Today: the dates within two weeks, and the late ones. */
|
|
238
|
+
todayItems() {
|
|
239
|
+
const out = [];
|
|
240
|
+
for (const p of this.view().projects) {
|
|
241
|
+
for (const s of p.stages) {
|
|
242
|
+
if (s.reached || s.daysLeft > 14) continue;
|
|
243
|
+
const score = s.daysLeft < 0 ? 12 : s.daysLeft <= 1 ? 18 : s.daysLeft <= 3 ? 30 : s.daysLeft <= 7 ? 46 : 58;
|
|
244
|
+
const open = this.openWords(s);
|
|
245
|
+
out.push({ id: `milestone:${p.key}:${s.id}`, kind: 'milestone', label: s.status === 'late' ? 'Late' : s.status === 'at-risk' ? 'At risk' : 'Date', title: `${p.name}: ${s.label} ${s.words} (${s.date})`, why: open || 'Nothing open that the app can see', score, at: null, due: dayOf(s.date).toISOString(), project: p.shortcut, stage: s.id });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Send the reminders that are due: one per date, for the nearest offset it has come within. */
|
|
252
|
+
async tick() {
|
|
253
|
+
const now = this.now();
|
|
254
|
+
if (now.getHours() < 8 || now.getHours() >= 20) return [];
|
|
255
|
+
const sent = [];
|
|
256
|
+
for (const p of this.projects()) {
|
|
257
|
+
const rec = this.all[p.key];
|
|
258
|
+
if (!rec) continue;
|
|
259
|
+
for (const s of this.stages(p, now)) {
|
|
260
|
+
if (s.reached) continue;
|
|
261
|
+
const due = dueReminder(s.daysLeft);
|
|
262
|
+
const had = (rec.sent[s.id] ??= {});
|
|
263
|
+
if (!due || had[due]) continue;
|
|
264
|
+
// Being within a nearer offset covers the further ones: they aren't sent late.
|
|
265
|
+
for (const o of REMIND_DAYS) if (due === 'late' || o >= Number(due)) had[String(o)] ??= now.toISOString();
|
|
266
|
+
had[due] = now.toISOString();
|
|
267
|
+
this.store.save();
|
|
268
|
+
const open = this.openWords(s);
|
|
269
|
+
const head = `${p.name}: ${s.label} ${s.words} (${s.date})`;
|
|
270
|
+
const mark = s.status === 'late' ? ':rotating_light:' : s.status === 'at-risk' ? ':warning:' : ':calendar:';
|
|
271
|
+
sent.push({ project: p.shortcut, stage: s.id, reminder: due });
|
|
272
|
+
try {
|
|
273
|
+
await this.notify?.(`${mark} *${head}*${open ? `\n${open}` : '\nNothing open that the app can see.'}`, `${head}${open ? `\n${open}` : ''}`);
|
|
274
|
+
} catch (e) {
|
|
275
|
+
this.log(`dates: ${head}: not sent: ${e.message}`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (sent.length) this.onChange();
|
|
280
|
+
return sent;
|
|
281
|
+
}
|
|
282
|
+
}
|
package/src/notify.js
CHANGED
|
@@ -20,6 +20,7 @@ export const EVENT_DEFAULTS = {
|
|
|
20
20
|
budget: true, // an agent neared or reached its budget, or today's spend reached the daily limit
|
|
21
21
|
standup: true, // the daily standup is ready to play
|
|
22
22
|
value: true, // a scheduled value report (week, month, quarter)
|
|
23
|
+
milestone: true, // a project's date (code complete, RC, GA) is coming up, at risk or late
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
// Alerts the AI judge may hold for the digest or drop; the rest are always sent at once.
|
package/src/server.js
CHANGED
|
@@ -9,7 +9,7 @@ import { spawn } from 'node:child_process';
|
|
|
9
9
|
import express from 'express';
|
|
10
10
|
import { WebSocketServer } from 'ws';
|
|
11
11
|
import { ensureHome, HOST, loadConfig, paths, PORT, saveConfig } from './config.js';
|
|
12
|
-
import { AgentManager, MACHINE, projectOf, shellNumber } from './manager.js';
|
|
12
|
+
import { AgentManager, MACHINE, NO_REPO, projectOf, repoCacheDir, shellNumber } from './manager.js';
|
|
13
13
|
import { Backlog } from './backlog.js';
|
|
14
14
|
import { Races } from './races.js';
|
|
15
15
|
import { Review } from './review.js';
|
|
@@ -50,6 +50,12 @@ import { Builder } from './builder.js';
|
|
|
50
50
|
import { Standup } from './standup.js';
|
|
51
51
|
import { Value, valueSlack } from './value.js';
|
|
52
52
|
import { News } from './news.js';
|
|
53
|
+
import { Milestones } from './milestones.js';
|
|
54
|
+
import { Decisions } from './decisions.js';
|
|
55
|
+
import { Debt } from './debt.js';
|
|
56
|
+
import { Calendar } from './calendar.js';
|
|
57
|
+
import { loadQuestions } from './inbox.js';
|
|
58
|
+
import { readSpecDoc } from './brief.js';
|
|
53
59
|
import { Store } from './store.js';
|
|
54
60
|
import { about, latestRelease } from './about.js';
|
|
55
61
|
import { Support } from './support.js';
|
|
@@ -256,6 +262,54 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
256
262
|
onChange: () => pushNews(),
|
|
257
263
|
oneShot: (prompt, { web, timeoutMs } = {}) => manager.oneShot(null, prompt, { ...manager.writerFor({}), web, timeoutMs }),
|
|
258
264
|
});
|
|
265
|
+
// Plan: a project's dates with their reminders and checklists, the decision log, the tech debt
|
|
266
|
+
// radar, and the calendar Today is planned around (milestones.js, decisions.js, debt.js, calendar.js).
|
|
267
|
+
let pushPlan = () => {};
|
|
268
|
+
const openFindings = (p) => hunts.list().findings.filter((f) => ['open', 'fixing', 'pr'].includes(f.status) && manager.resolveProject(f.project)?.key === p.key);
|
|
269
|
+
const queueTask = (p, title) => backlog.add([title], { project: p.shortcut })[0];
|
|
270
|
+
const milestones = new Milestones({
|
|
271
|
+
store,
|
|
272
|
+
projects: () => manager.listProjects(),
|
|
273
|
+
onChange: () => pushPlan(),
|
|
274
|
+
queue: queueTask,
|
|
275
|
+
facts: (p) => {
|
|
276
|
+
const mine = store.list().filter((a) => projectOf(a).key === p.key && !NO_REPO.has(a.kind) && !a.hunting && !a.reviewing);
|
|
277
|
+
const views = mine.map((a) => manager.view(a));
|
|
278
|
+
const prs = mine.flatMap((a) => Object.values(a.prs ?? {}).filter((x) => x.state === 'OPEN' && x.source !== 'mentioned'));
|
|
279
|
+
return {
|
|
280
|
+
working: views.filter((v) => ['planning', 'working', 'blocked'].includes(v.brief?.status) || (v.runtime.running && v.brief?.status !== 'done')),
|
|
281
|
+
backlog: backlog.view().items.filter((it) => it.projectKey === p.key && ['queued', 'active', 'review', 'blocked'].includes(it.status)),
|
|
282
|
+
waiting: views.filter((v) => v.runtime.attention || v.runtime.waiting || v.planReview?.status === 'review' || (v.questions ?? []).some((q) => !q.answer)),
|
|
283
|
+
prs,
|
|
284
|
+
failing: prs.filter((x) => x.checks?.state === 'failed'),
|
|
285
|
+
bugs: openFindings(p).filter((f) => ['critical', 'high'].includes(f.severity)),
|
|
286
|
+
};
|
|
287
|
+
},
|
|
288
|
+
notify: async (text, plain) => {
|
|
289
|
+
const n = loadNotify();
|
|
290
|
+
if (!n.enabled || !n.events.milestone) return;
|
|
291
|
+
await sendSlack(text, n, plain);
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
const decisions = new Decisions({
|
|
295
|
+
store,
|
|
296
|
+
agents: () => store.list(),
|
|
297
|
+
projectOf,
|
|
298
|
+
questions: (a) => (NO_REPO.has(a.kind) ? [] : loadQuestions(a.id)),
|
|
299
|
+
designDoc: (id) => readSpecDoc(id, 'designdoc'),
|
|
300
|
+
onChange: () => pushPlan(),
|
|
301
|
+
});
|
|
302
|
+
const debt = new Debt({
|
|
303
|
+
store,
|
|
304
|
+
config,
|
|
305
|
+
projects: () => manager.listProjects(),
|
|
306
|
+
// The project's folder, or the shared clone its agents' worktrees come from.
|
|
307
|
+
dirOf: (p) => p.dir ?? (p.repo && git.isRemoteUrl(p.repo) ? repoCacheDir(p.repo) : p.repo ?? null),
|
|
308
|
+
bugs: (p) => openFindings(p).map((f) => f.file),
|
|
309
|
+
queue: queueTask,
|
|
310
|
+
onChange: () => pushPlan(),
|
|
311
|
+
});
|
|
312
|
+
const calendar = new Calendar({ config });
|
|
259
313
|
const triggers = new Triggers({ manager, store, config, notifier });
|
|
260
314
|
const budgets = new Budgets({ manager, store, config, notifier });
|
|
261
315
|
const playbooks = new Playbooks({ manager, store });
|
|
@@ -1011,6 +1065,39 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
1011
1065
|
api.patch('/value/items/:id', wrap((req) => value.edit(req.params.id, req.body ?? {})));
|
|
1012
1066
|
api.post('/value/items/:id/estimate', wrap((req) => value.estimate(req.params.id).then((it) => value.itemView(it))));
|
|
1013
1067
|
api.post('/value/items/:id/exclude', wrap((req) => value.exclude(req.params.id, req.body?.excluded !== false)));
|
|
1068
|
+
// Plan → Dates: a project's code complete, RC and GA dates, their checklists and reminders.
|
|
1069
|
+
api.get('/milestones', wrap(() => milestones.view()));
|
|
1070
|
+
api.put('/milestones/:project', wrap((req) => milestones.set(req.params.project, req.body ?? {})));
|
|
1071
|
+
api.post('/milestones/:project/check', wrap((req) => milestones.check(req.params.project, req.body?.stage, req.body?.item, req.body?.done !== false)));
|
|
1072
|
+
api.post('/milestones/:project/reach', wrap((req) => milestones.reach(req.params.project, req.body?.stage, req.body?.reached !== false)));
|
|
1073
|
+
api.post('/milestones/:project/task', wrap((req) => milestones.task(req.params.project, req.body?.stage, req.body?.item)));
|
|
1074
|
+
// Plan → Decisions: the log (?project=<key>&q=<words>; ?format=markdown), one of your own, and removal.
|
|
1075
|
+
api.get('/decisions', (req, res) => {
|
|
1076
|
+
try {
|
|
1077
|
+
const project = req.query.project ? String(req.query.project) : null;
|
|
1078
|
+
if (req.query.format === 'markdown') return res.type('text/markdown').send(decisions.markdown({ project }));
|
|
1079
|
+
res.json(decisions.view({ project, q: String(req.query.q ?? '') }));
|
|
1080
|
+
} catch (e) {
|
|
1081
|
+
res.status(e.status ?? 500).json({ error: e.message });
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
api.post('/decisions', wrap((req) => {
|
|
1085
|
+
const p = manager.resolveProject(req.body?.project) ?? manager.listProjects().find((x) => x.key === req.body?.project);
|
|
1086
|
+
return decisions.add({ ...req.body, project: p ? { key: p.key, name: p.name } : null });
|
|
1087
|
+
}));
|
|
1088
|
+
api.delete('/decisions/:id', wrap((req) => decisions.remove(req.params.id)));
|
|
1089
|
+
// Plan → Debt: each project's hot spots; a scan answers at once and the page hears when it's done.
|
|
1090
|
+
api.get('/debt', wrap(() => debt.view()));
|
|
1091
|
+
api.post('/debt/:project/scan', wrap((req) => {
|
|
1092
|
+
debt.project(req.params.project);
|
|
1093
|
+
debt.scan(req.params.project).catch(() => {});
|
|
1094
|
+
return debt.view();
|
|
1095
|
+
}));
|
|
1096
|
+
api.post('/debt/:project/queue', wrap((req) => debt.queueSpot(req.params.project, String(req.body?.file ?? ''))));
|
|
1097
|
+
api.post('/debt/:project/dismiss', wrap((req) => debt.dismiss(req.params.project, String(req.body?.file ?? ''), req.body?.dismissed !== false)));
|
|
1098
|
+
// The calendar Today is planned around: its private iCal addresses (never sent back) and working hours.
|
|
1099
|
+
api.get('/calendar', wrap(() => calendar.status()));
|
|
1100
|
+
api.put('/calendar', wrap((req) => calendar.set(req.body ?? {}, saveConfig)));
|
|
1014
1101
|
// AI News: the entries, a refresh now (answers at once; the page hears when it's done), and "seen".
|
|
1015
1102
|
api.get('/news', wrap(() => news.view()));
|
|
1016
1103
|
api.post('/news/refresh', wrap((req) => {
|
|
@@ -1059,8 +1146,12 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
1059
1146
|
got('reviews', () => reviews.rows()),
|
|
1060
1147
|
]);
|
|
1061
1148
|
const findings = hunts.list().findings.filter((x) => x.status === 'open' || x.status === 'pr');
|
|
1062
|
-
const items = todayItems({ inbox, issues, actions, reviews: prs, findings, slower: benches.slower(), unsure: evals.unsure().map((a) => ({ id: a.id, name: a.name, issue: manager.issueKey(a), confidence: a.eval.confidence, pending: a.eval.pending, at: a.eval.at })) });
|
|
1063
|
-
|
|
1149
|
+
const items = todayItems({ inbox, issues, actions, reviews: prs, findings, slower: benches.slower(), milestones: milestones.todayItems(), unsure: evals.unsure().map((a) => ({ id: a.id, name: a.name, issue: manager.issueKey(a), confidence: a.eval.confidence, pending: a.eval.pending, at: a.eval.at })) });
|
|
1150
|
+
// The day around your meetings: what needs you, placed in the free time (calendar.js).
|
|
1151
|
+
const day = await calendar
|
|
1152
|
+
.day({ items, agents: store.list().filter((a) => !NO_REPO.has(a.kind)).map((a) => ({ id: a.id, name: a.name, status: a.status, issue: manager.issueKey(a), prs: Object.values(a.prs ?? {}), project: projectOf(a).name })) })
|
|
1153
|
+
.catch((e) => ({ connected: true, error: e.message }));
|
|
1154
|
+
return { items, day, aside: todayAside({ issues, actions }), speech: todaySpeech(items), features: f, errors };
|
|
1064
1155
|
}));
|
|
1065
1156
|
// Support tickets: kept on this computer, each with a filled-in link to a new GitHub issue.
|
|
1066
1157
|
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
@@ -1366,6 +1457,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
1366
1457
|
pushStandup = (latest) => broadcast({ t: 'standup', latest });
|
|
1367
1458
|
pushValue = () => broadcast({ t: 'value' });
|
|
1368
1459
|
pushNews = () => broadcast({ t: 'news' });
|
|
1460
|
+
pushPlan = () => broadcast({ t: 'plan' });
|
|
1369
1461
|
reports.on('change', () => broadcast({ t: 'built', reports: reports.list() }));
|
|
1370
1462
|
manager.rules.on('change', (rules) => broadcast({ t: 'rules', rules }));
|
|
1371
1463
|
repeats.on('change', (view) => broadcast({ t: 'repeats', repeats: view }));
|
|
@@ -1504,6 +1596,9 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
1504
1596
|
standup.close();
|
|
1505
1597
|
value.close();
|
|
1506
1598
|
news.close();
|
|
1599
|
+
milestones.close();
|
|
1600
|
+
decisions.close();
|
|
1601
|
+
debt.close();
|
|
1507
1602
|
reviews.close();
|
|
1508
1603
|
hunts.close();
|
|
1509
1604
|
benches.close();
|
package/src/today.js
CHANGED
|
@@ -68,7 +68,7 @@ const INBOX = {
|
|
|
68
68
|
* The list: [{ id, kind, label, title, why, score, at, agentId?, url?, actionId?, issueKey?, reviewUrl? }],
|
|
69
69
|
* most pressing first. Each source may be missing (turned off, or it couldn't be had).
|
|
70
70
|
*/
|
|
71
|
-
export function todayItems({ inbox = [], issues = [], actions = [], reviews = [], findings = [], slower = [], unsure = [], now = new Date() } = {}) {
|
|
71
|
+
export function todayItems({ inbox = [], issues = [], actions = [], reviews = [], findings = [], slower = [], unsure = [], milestones = [], now = new Date() } = {}) {
|
|
72
72
|
const items = [];
|
|
73
73
|
// The issue each agent works on: named on its questions, and not listed twice.
|
|
74
74
|
const issueOfAgent = new Map(issues.filter((r) => r.agent?.id).map((r) => [r.agent.id, r]));
|
|
@@ -141,6 +141,8 @@ export function todayItems({ inbox = [], issues = [], actions = [], reviews = []
|
|
|
141
141
|
const why = `Micro benchmarks${r.agent && r.agent !== r.issue ? ` by ${r.agent}` : ''}${worst ? `: ${worst.name} ${worst.before} → ${worst.after}${worst.unit ? ` ${worst.unit}` : ''}` : ''}${worst?.note ? ` · its note: ${worst.note}` : ''}`;
|
|
142
142
|
items.push({ id: `bench:${r.id}`, kind: 'bench', label: 'Slower', title, why, score: r.worst > 20 ? 27 : 36, at: r.at ?? null, agentId: r.agentId, runId: r.id, issueKey: r.issue ?? null });
|
|
143
143
|
}
|
|
144
|
+
// A project's dates coming up, at risk or late (milestones.js), already scored.
|
|
145
|
+
items.push(...milestones);
|
|
144
146
|
return items.sort((x, y) => x.score - y.score || String(y.at ?? '').localeCompare(String(x.at ?? '')));
|
|
145
147
|
}
|
|
146
148
|
|