ai-agentmanager 1.61.0 → 1.63.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 +30 -0
- package/README.md +124 -0
- package/package.json +1 -1
- package/public/acceptance.js +194 -0
- package/public/announce.js +9 -1
- package/public/app.js +82 -10
- package/public/attach.js +4 -0
- package/public/autonomy.js +140 -0
- package/public/boardcols.js +1 -0
- package/public/claims.js +65 -0
- package/public/dropzone.js +203 -0
- package/public/index.html +56 -0
- package/public/menu.js +20 -0
- package/public/scorecard.js +1 -1
- package/public/standup.js +1 -0
- package/public/style.css +64 -1
- package/src/acceptance.js +123 -0
- package/src/advisor.js +30 -8
- package/src/autonomy.js +624 -0
- package/src/autopilot.js +7 -1
- package/src/backlog.js +16 -3
- package/src/brief.js +21 -3
- package/src/bughunt.js +1 -0
- package/src/claims.js +239 -0
- package/src/cli.js +164 -2
- package/src/config.js +3 -0
- package/src/decisions.js +5 -1
- package/src/groundrules.js +97 -0
- package/src/judge.js +1 -1
- package/src/manager.js +257 -6
- package/src/notify.js +16 -0
- package/src/prereview.js +7 -2
- package/src/scorecard.js +27 -10
- package/src/server.js +67 -4
- package/src/standup.js +1 -0
package/src/advisor.js
CHANGED
|
@@ -57,7 +57,7 @@ const pastLines = (past) =>
|
|
|
57
57
|
const lessonLines = (lessons) => (lessons.length ? `What earlier decisions taught:\n${lessons.map((l) => `- ${clip(l, 200)}`).join('\n')}` : '');
|
|
58
58
|
|
|
59
59
|
/** The prompt for one thing waiting on the person: a plan to review, or an agent's question. */
|
|
60
|
-
export function briefPrompt(item, { standing = [], past = [], lessons = [], dates = '' } = {}) {
|
|
60
|
+
export function briefPrompt(item, { standing = [], past = [], lessons = [], dates = '', points = [], groundRules = [], repoLessons = [] } = {}) {
|
|
61
61
|
const head =
|
|
62
62
|
'You advise a senior engineer who supervises AI coding agents. Something waits for their decision. ' +
|
|
63
63
|
'Lay out the real options, recommend one, and say why in terms of this project. Be concrete and brief; do not flatter; when the evidence is thin, say so with a low confidence.';
|
|
@@ -73,6 +73,9 @@ export function briefPrompt(item, { standing = [], past = [], lessons = [], date
|
|
|
73
73
|
head,
|
|
74
74
|
`Project: ${item.project}.${dates ? ` ${dates}` : ''}`,
|
|
75
75
|
body,
|
|
76
|
+
points.length ? `What done means for this task, as agreed with the person (a recommendation must serve these):\n${points.map((p) => `- ${p.id ? `${p.id}: ` : ''}${clip(p.text ?? p, 300)}`).join('\n')}` : '',
|
|
77
|
+
groundRules.length ? `The person's ground rules for every agent (never recommend breaking one):\n${groundRules.map((r) => `- ${clip(r, 300)}`).join('\n')}` : '',
|
|
78
|
+
repoLessons.length ? `Lessons of this repository:\n${repoLessons.map((r) => `- ${clip(r, 240)}`).join('\n')}` : '',
|
|
76
79
|
standingLines(standing),
|
|
77
80
|
pastLines(past),
|
|
78
81
|
lessonLines(lessons),
|
|
@@ -257,8 +260,11 @@ export class Advisor {
|
|
|
257
260
|
* backlog, milestones, decisions, races: the other parts it reads and acts through;
|
|
258
261
|
* questions(agent): its questions; projectOf(agent): its project.
|
|
259
262
|
*/
|
|
260
|
-
constructor({ store, manager, backlog, milestones, decisions, races, questions, projectOf, bugs = () => 0, enabled = () => true, notify = null, onChange = () => {}, now = () => Date.now(), log = (m) => console.log(`[agentmgr] ${m}`), timer = true }) {
|
|
261
|
-
|
|
263
|
+
constructor({ store, manager, backlog, milestones, decisions, races, questions, projectOf, bugs = () => 0, enabled = () => true, notify = null, onChange = () => {}, now = () => Date.now(), log = (m) => console.log(`[agentmgr] ${m}`), timer = true, autonomous = () => false, guard = () => null, context = () => ({}), onAuto = null }) {
|
|
264
|
+
// autonomous(agentId): the agent runs without the person (autonomy.js), so "most" may be decided for it.
|
|
265
|
+
// guard(item): why an item is the person's whatever the recommendation (deleting, publishing, money...), or null.
|
|
266
|
+
// context(item): { points, groundRules, repoLessons } for its brief. onAuto(handled): told what was decided for the person.
|
|
267
|
+
Object.assign(this, { store, manager, backlog, milestones, decisions, races, questions, projectOf, bugs, enabled, notify, onChange, now, log, autonomous, guard, context, onAuto });
|
|
262
268
|
this.pending = new Set();
|
|
263
269
|
if (timer) {
|
|
264
270
|
this.timer = setInterval(() => this.tick().catch(() => {}), 20_000);
|
|
@@ -296,6 +302,17 @@ export class Advisor {
|
|
|
296
302
|
return this.state.autonomy[projectKey] ?? 'standing';
|
|
297
303
|
}
|
|
298
304
|
|
|
305
|
+
/** How much may be decided for one item: its project's level, or "most" when its agent runs without the person. */
|
|
306
|
+
levelOfItem(item) {
|
|
307
|
+
const p = this.levelFor(item.projectKey);
|
|
308
|
+
return this.autonomous(item.agentId) && LEVELS.indexOf(p) < LEVELS.indexOf('most') ? 'most' : p;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** May this brief be carried out without asking? Never when the item is about what cannot be taken back. */
|
|
312
|
+
mayActOn(item, b) {
|
|
313
|
+
return mayAct(this.levelOfItem(item), b) && !this.guard(item);
|
|
314
|
+
}
|
|
315
|
+
|
|
299
316
|
setAutonomy(projectKey, level) {
|
|
300
317
|
if (!LEVELS.includes(level)) throw err(400, `level must be one of ${LEVELS.join(', ')}`);
|
|
301
318
|
if (!projectKey) throw err(400, 'Pick a project');
|
|
@@ -357,8 +374,9 @@ export class Advisor {
|
|
|
357
374
|
const jobs = [];
|
|
358
375
|
for (const item of items) {
|
|
359
376
|
const have = st.briefs[item.key];
|
|
360
|
-
|
|
361
|
-
|
|
377
|
+
// A brief written before its agent was set to run without the person is written again, on the models chosen for that.
|
|
378
|
+
if (have?.hash === item.hash && have.status !== 'stale' && !(have.status === 'open' && this.autonomous(item.agentId) && !have.own)) {
|
|
379
|
+
if (have.status === 'open' && this.mayActOn(item, have)) jobs.push(this.apply(item.key, have.recommend, { by: 'auto' }).catch((e) => this.log(`decide: ${e.message}`)));
|
|
362
380
|
continue;
|
|
363
381
|
}
|
|
364
382
|
if (this.pending.has(item.key)) continue;
|
|
@@ -372,17 +390,18 @@ export class Advisor {
|
|
|
372
390
|
async write(item) {
|
|
373
391
|
const standing = this.rulesFor(item);
|
|
374
392
|
const past = this.state.history.filter((h) => h.kind === item.kind).slice(-6);
|
|
375
|
-
const
|
|
393
|
+
const own = Boolean(this.autonomous(item.agentId));
|
|
394
|
+
const prompt = briefPrompt(item, { standing, past, lessons: this.state.lessons.slice(-5), dates: this.datesFor(item.projectKey).words, ...this.context(item) });
|
|
376
395
|
const agent = this.store.get(item.agentId) ?? null;
|
|
377
396
|
const d = normalizeBrief(await this.judge.ask(`advise:${item.key}:${item.hash}`, agent, prompt, (x) => Array.isArray(x.options)), item, standing);
|
|
378
397
|
const still = this.waiting().find((i) => i.key === item.key);
|
|
379
398
|
if (!still || still.hash !== item.hash) return;
|
|
380
|
-
const base = { key: item.key, kind: item.kind, agentId: item.agentId, agentName: item.agentName, project: item.project, projectKey: item.projectKey, title: clip(item.title, 300), qid: item.qid ?? null, hash: item.hash, at: this.iso(), status: 'open' };
|
|
399
|
+
const base = { key: item.key, kind: item.kind, agentId: item.agentId, agentName: item.agentName, project: item.project, projectKey: item.projectKey, title: clip(item.title, 300), qid: item.qid ?? null, hash: item.hash, at: this.iso(), status: 'open', ...(own ? { own: true } : {}) };
|
|
381
400
|
// No judge (off, over budget, or no usable reply): the card says so instead of guessing.
|
|
382
401
|
this.state.briefs[item.key] = d ? { ...base, ...d } : { ...base, options: [], recommend: null, why: '', evidence: [], risk: '', undo: 'easy', confidence: 0, standing: null, none: this.judge.enabled ? 'No recommendation could be written (the AI judge gave no usable answer, or is over its daily budget).' : 'The AI judge is off, so there is no recommendation.' };
|
|
383
402
|
this.save();
|
|
384
403
|
const b = this.state.briefs[item.key];
|
|
385
|
-
if (
|
|
404
|
+
if (this.mayActOn(item, b)) await this.apply(item.key, b.recommend, { by: 'auto' }).catch((e) => this.log(`decide: ${e.message}`));
|
|
386
405
|
}
|
|
387
406
|
|
|
388
407
|
/** Ask for the brief again (the judge was off, or you want a second look). */
|
|
@@ -413,6 +432,9 @@ export class Advisor {
|
|
|
413
432
|
this.state.handled.push({ at: b.decidedAt, key, kind: b.kind, agentId: b.agentId, agentName: b.agentName, project: b.project, projectKey: b.projectKey, title: b.title, did: opt.action === 'answer' ? `Answered: ${clip(say, 200)}` : opt.action === 'approve' ? 'Approved the plan' : `Sent the plan back: ${clip(say, 200)}`, why: b.why, standing: b.standing, standingWhen: rule?.when ?? null, confidence: b.confidence });
|
|
414
433
|
if (this.state.handled.length > 200) this.state.handled.splice(0, this.state.handled.length - 200);
|
|
415
434
|
if (rule) Object.assign(rule, { uses: (rule.uses ?? 0) + 1, lastUsedAt: b.decidedAt });
|
|
435
|
+
try {
|
|
436
|
+
this.onAuto?.({ ...this.state.handled.at(-1), qid: b.qid ?? null, action: opt.action, text: say });
|
|
437
|
+
} catch {}
|
|
416
438
|
this.notify?.(`Decided for you on *${b.project}*: ${clip(b.title, 120)} → ${this.state.handled.at(-1).did}`, `Decided for you on ${b.project}: ${clip(b.title, 120)}: ${this.state.handled.at(-1).did}`)?.catch?.(() => {});
|
|
417
439
|
}
|
|
418
440
|
this.log2decisions(b, { by, followed });
|