ai-agentmanager 1.59.0 → 1.61.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 +21 -0
- package/README.md +63 -1
- package/docs/architecture.md +1 -1
- package/package.json +1 -1
- package/public/app.js +14 -1
- package/public/index.html +5 -1
- package/public/keys.js +3 -2
- package/public/quality.js +274 -0
- package/public/scorecard.js +11 -1
- package/public/standards.js +159 -0
- package/public/style.css +23 -0
- package/public/value.js +12 -4
- package/src/autopilot.js +10 -3
- package/src/cli.js +147 -4
- package/src/landing.js +3 -0
- package/src/manager.js +10 -3
- package/src/prereview.js +10 -4
- package/src/quality.js +383 -0
- package/src/scorecard.js +46 -7
- package/src/server.js +32 -1
- package/src/standards.js +572 -0
- package/src/value.js +48 -6
package/src/value.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// model call: the hours a person would have needed without AI, savings beyond that labor,
|
|
4
4
|
// potential revenue, and strategic value, each with a reason. You can correct any figure; yours
|
|
5
5
|
// win and are marked as yours. Totals by day, week, month and quarter set the value against the
|
|
6
|
-
// AI cost and your own time, and a report goes to Slack (and Google Drive) on a schedule.
|
|
6
|
+
// AI cost and your own time, and a report goes to Slack (and Google Drive) on a schedule. Next to
|
|
7
|
+
// the value: how many pull requests merged in each day, week, month, quarter and year.
|
|
7
8
|
|
|
8
9
|
import fs from 'node:fs';
|
|
9
10
|
import path from 'node:path';
|
|
@@ -80,6 +81,23 @@ export function deliveredAt(a) {
|
|
|
80
81
|
return Number.isFinite(at) ? new Date(at).toISOString() : null;
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
/** An agent's merged pull requests (its own, not ones it only mentioned), with when each merged. */
|
|
85
|
+
export function mergedPrs(a) {
|
|
86
|
+
return Object.values(a.prs ?? {})
|
|
87
|
+
.filter((p) => p.source !== 'mentioned' && p.state === 'MERGED')
|
|
88
|
+
.map((p) => ({ url: p.url ?? null, number: p.number ?? null, mergedAt: Number.isFinite(Date.parse(p.mergedAt)) ? new Date(p.mergedAt).toISOString() : null }));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* When each of an item's pull requests merged, as times. One merged without a time counts at the
|
|
93
|
+
* item's delivery; an item from before pull requests were kept on it counts its link as one.
|
|
94
|
+
*/
|
|
95
|
+
export function prTimes(it) {
|
|
96
|
+
const at = Date.parse(it.deliveredAt);
|
|
97
|
+
if (!Array.isArray(it.prs)) return it.link ? [at] : [];
|
|
98
|
+
return it.prs.map((p) => (p.mergedAt ? Date.parse(p.mergedAt) : at));
|
|
99
|
+
}
|
|
100
|
+
|
|
83
101
|
/** What the estimate is based on, from what agentmgr tracks. */
|
|
84
102
|
export function valueFacts(a, { project = null, designSummary = null, files = null } = {}) {
|
|
85
103
|
const prs = Object.values(a.prs ?? {}).filter((p) => p.source !== 'mentioned' && p.state === 'MERGED');
|
|
@@ -231,11 +249,26 @@ export const PERIODS = {
|
|
|
231
249
|
label: (s) => `Q${Math.floor(new Date(s).getMonth() / 3) + 1} ${new Date(s).getFullYear()}`,
|
|
232
250
|
count: 8,
|
|
233
251
|
},
|
|
252
|
+
year: {
|
|
253
|
+
start: (t) => {
|
|
254
|
+
const d = startOfDay(t);
|
|
255
|
+
d.setMonth(0, 1);
|
|
256
|
+
return d.getTime();
|
|
257
|
+
},
|
|
258
|
+
next: (s) => {
|
|
259
|
+
const d = new Date(s);
|
|
260
|
+
d.setFullYear(d.getFullYear() + 1);
|
|
261
|
+
return d.getTime();
|
|
262
|
+
},
|
|
263
|
+
key: (s) => String(new Date(s).getFullYear()),
|
|
264
|
+
label: (s) => String(new Date(s).getFullYear()),
|
|
265
|
+
count: 5,
|
|
266
|
+
},
|
|
234
267
|
};
|
|
235
268
|
|
|
236
269
|
/** Totals for a set of items. */
|
|
237
270
|
export function totals(items, s) {
|
|
238
|
-
const t = { items: items.length, estimated: 0, humanHours: 0, laborUsd: 0, savingsUsd: 0, revenueUsd: 0, valueUsd: 0, aiCostUsd: 0, yourHours: 0, strategicHigh: 0 };
|
|
271
|
+
const t = { items: items.length, prs: 0, estimated: 0, humanHours: 0, laborUsd: 0, savingsUsd: 0, revenueUsd: 0, valueUsd: 0, aiCostUsd: 0, yourHours: 0, strategicHigh: 0 };
|
|
239
272
|
for (const it of items) {
|
|
240
273
|
const v = itemValue(it, s);
|
|
241
274
|
if (v.humanHours != null) t.estimated += 1;
|
|
@@ -257,12 +290,16 @@ export function totals(items, s) {
|
|
|
257
290
|
return t;
|
|
258
291
|
}
|
|
259
292
|
|
|
260
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* The last `count` periods of a kind, newest first, each with its totals and items. Pull requests
|
|
295
|
+
* count in the period they merged in, which for an item's later ones can be after its own.
|
|
296
|
+
*/
|
|
261
297
|
export function aggregate(items, s, { period = 'week', count, t = Date.now() } = {}) {
|
|
262
298
|
const P = PERIODS[period];
|
|
263
299
|
if (!P) throw err(400, `period is one of ${Object.keys(PERIODS).join(', ')}`);
|
|
264
300
|
const n = count ?? P.count;
|
|
265
301
|
const out = [];
|
|
302
|
+
const merged = items.flatMap(prTimes);
|
|
266
303
|
let start = P.start(t);
|
|
267
304
|
for (let i = 0; i < n; i++) {
|
|
268
305
|
const end = P.next(start);
|
|
@@ -270,7 +307,9 @@ export function aggregate(items, s, { period = 'week', count, t = Date.now() } =
|
|
|
270
307
|
const at = Date.parse(it.deliveredAt);
|
|
271
308
|
return at >= start && at < end;
|
|
272
309
|
});
|
|
273
|
-
|
|
310
|
+
const from = start;
|
|
311
|
+
const sums = { ...totals(inside, s), prs: merged.filter((at) => at >= from && at < end).length };
|
|
312
|
+
out.push({ key: P.key(start), label: P.label(start), start: new Date(start).toISOString(), end: new Date(end).toISOString(), current: i === 0, totals: sums, items: inside.map((it) => it.agentId) });
|
|
274
313
|
start = P.start(start - 1);
|
|
275
314
|
}
|
|
276
315
|
return out;
|
|
@@ -291,6 +330,7 @@ export function valueMarkdown(p, items, s, { who = '', prev = null } = {}) {
|
|
|
291
330
|
'',
|
|
292
331
|
`${t.items} piece${t.items === 1 ? '' : 's'} of work delivered with AI agents.`,
|
|
293
332
|
'',
|
|
333
|
+
`- **Pull requests merged**: ${t.prs}${change('prs')}`,
|
|
294
334
|
`- **Value delivered**: ${money(t.valueUsd, s.currency)}${change('valueUsd')}: ${money(t.laborUsd, s.currency)} of engineering time (${t.humanHours} hours at ${money(s.hourlyRate, s.currency)}/hour) and ${money(t.savingsUsd, s.currency)} in other savings`,
|
|
295
335
|
`- **Potential revenue**: ${money(t.revenueUsd, s.currency)} in the first year`,
|
|
296
336
|
`- **Strategic**: ${t.strategicHigh} high-impact item${t.strategicHigh === 1 ? '' : 's'} (4 or 5 of 5)`,
|
|
@@ -318,7 +358,7 @@ export function valueMarkdown(p, items, s, { who = '', prev = null } = {}) {
|
|
|
318
358
|
export function valueSlack(p, s, link) {
|
|
319
359
|
const t = p.totals;
|
|
320
360
|
const head = `Value delivered, ${p.label}`;
|
|
321
|
-
const line1 = `${money(t.valueUsd, s.currency)} (${t.humanHours} engineering hours) from ${t.items} item${t.items === 1 ? '' : 's'}`;
|
|
361
|
+
const line1 = `${money(t.valueUsd, s.currency)} (${t.humanHours} engineering hours) from ${t.items} item${t.items === 1 ? '' : 's'}, ${t.prs} pull request${t.prs === 1 ? '' : 's'} merged`;
|
|
322
362
|
const line2 = [`Potential revenue ${money(t.revenueUsd, s.currency)}`, `${t.strategicHigh} high-impact`, t.leverage ? `${t.leverage}× leverage on my time` : null, t.roi ? `${t.roi}× per AI dollar` : null].filter(Boolean).join(' · ');
|
|
323
363
|
return {
|
|
324
364
|
text: [`:chart_with_upwards_trend: *${head}*: ${line1}`, line2, link ? `<${link}|Open the report>` : ''].filter(Boolean).join('\n'),
|
|
@@ -326,7 +366,7 @@ export function valueSlack(p, s, link) {
|
|
|
326
366
|
};
|
|
327
367
|
}
|
|
328
368
|
|
|
329
|
-
export const CSV_COLUMNS = ['delivered', 'project', 'title', 'issue', 'link', 'category', 'human_hours', 'labor_usd', 'savings_usd', 'value_usd', 'revenue_usd', 'strategic', 'your_hours', 'ai_cost_usd', 'summary', 'set_by_you', 'confidence', 'agent_id'];
|
|
369
|
+
export const CSV_COLUMNS = ['delivered', 'project', 'title', 'issue', 'link', 'category', 'human_hours', 'labor_usd', 'savings_usd', 'value_usd', 'revenue_usd', 'strategic', 'your_hours', 'ai_cost_usd', 'summary', 'set_by_you', 'confidence', 'agent_id', 'pull_requests'];
|
|
330
370
|
|
|
331
371
|
/** The previous complete period of a kind before t: its start. */
|
|
332
372
|
const lastComplete = (kind, t) => PERIODS[kind].start(PERIODS[kind].start(t) - 1);
|
|
@@ -376,6 +416,7 @@ export class Value {
|
|
|
376
416
|
project: v.projectInfo?.name ?? null,
|
|
377
417
|
issue: a.synopsis?.key ?? leadingJiraKey(a.intent) ?? null,
|
|
378
418
|
link: pr?.url ?? null,
|
|
419
|
+
prs: mergedPrs(a),
|
|
379
420
|
deliveredAt: at,
|
|
380
421
|
aiCostUsd: round(costOf(a), 2),
|
|
381
422
|
};
|
|
@@ -566,6 +607,7 @@ export class Value {
|
|
|
566
607
|
set_by_you: v.yours.join(' '),
|
|
567
608
|
confidence: it.est?.confidence ?? '',
|
|
568
609
|
agent_id: it.agentId,
|
|
610
|
+
pull_requests: prTimes(it).length,
|
|
569
611
|
};
|
|
570
612
|
});
|
|
571
613
|
fs.mkdirSync(this.dir, { recursive: true });
|