@chosengeneration/light-code 0.46.0 → 0.50.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/dist/cli.js +794 -160
- package/dist/client/client.js +36 -36
- package/dist/server.js +793 -159
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -39665,8 +39665,27 @@ var agentAssignmentSchema = external_exports.object({
|
|
|
39665
39665
|
*/
|
|
39666
39666
|
prompt: external_exports.string().optional()
|
|
39667
39667
|
}).strict();
|
|
39668
|
+
var customRoleSchema = external_exports.object({
|
|
39669
|
+
id: external_exports.string().min(1),
|
|
39670
|
+
name: external_exports.string().min(1),
|
|
39671
|
+
summary: external_exports.string(),
|
|
39672
|
+
prompt: external_exports.string()
|
|
39673
|
+
});
|
|
39668
39674
|
var agentsConfigSchema = external_exports.object({
|
|
39669
39675
|
roles: external_exports.record(external_exports.string(), agentAssignmentSchema),
|
|
39676
|
+
/**
|
|
39677
|
+
* Roles the user invented, beyond the five built in.
|
|
39678
|
+
*
|
|
39679
|
+
* A role *is* its prompt, and the ones people ask for next are nearly always a reviewer with
|
|
39680
|
+
* a different one — security, performance, accessibility. Defining them here answers that
|
|
39681
|
+
* whole family without a code change each time, and without growing the fixed roster the
|
|
39682
|
+
* expert has to allocate from.
|
|
39683
|
+
*
|
|
39684
|
+
* Covered by the same user-scope rule as the rest of this block, and it is the sharpest part
|
|
39685
|
+
* of it: this is prose injected into a model that is then asked to advise on this
|
|
39686
|
+
* repository, so a workspace able to write it could define a reviewer that approves anything.
|
|
39687
|
+
*/
|
|
39688
|
+
definitions: external_exports.array(customRoleSchema),
|
|
39670
39689
|
/** Whether what a consultation costs is worth managing. See `agents/team.ts`. */
|
|
39671
39690
|
budgetMatters: external_exports.boolean(),
|
|
39672
39691
|
/** The Agent team mode instruction, when edited. The roster is always generated. */
|
|
@@ -43228,18 +43247,353 @@ var Conversation = class {
|
|
|
43228
43247
|
}
|
|
43229
43248
|
};
|
|
43230
43249
|
|
|
43250
|
+
// ../../packages/core/dist/agents/roles.js
|
|
43251
|
+
var AGENT_ROLES = ["expert", "programmer", "reviewer", "tester", "librarian"];
|
|
43252
|
+
function isAgentRole(value, custom2 = []) {
|
|
43253
|
+
return AGENT_ROLES.includes(value) || custom2.some((role) => role.id === value);
|
|
43254
|
+
}
|
|
43255
|
+
function knownRoles(custom2 = []) {
|
|
43256
|
+
return [...AGENT_ROLES, ...custom2.map((role) => role.id)];
|
|
43257
|
+
}
|
|
43258
|
+
var SHARED_TAIL = [
|
|
43259
|
+
"Your reply is advice. The assistant will check it against the real code before acting, and it",
|
|
43260
|
+
"is responsible for the result. Be concrete, say what you are unsure about, and say plainly when",
|
|
43261
|
+
"something must be verified rather than assumed.",
|
|
43262
|
+
"",
|
|
43263
|
+
"Answer in prose and short lists. No preamble about being happy to help."
|
|
43264
|
+
];
|
|
43265
|
+
var SHARED_WITH_TOOLS = [
|
|
43266
|
+
"You can read this workspace: open files, list them, and search. Use that rather than guessing,",
|
|
43267
|
+
"and rather than asking the assistant for something you can fetch yourself. You have a small",
|
|
43268
|
+
"budget of lookups, so go for what actually settles the question.",
|
|
43269
|
+
"",
|
|
43270
|
+
"You cannot edit anything, run anything, or reach the network. If something needs changing, say",
|
|
43271
|
+
"what and why \u2014 the assistant makes the change and is responsible for it.",
|
|
43272
|
+
"",
|
|
43273
|
+
...SHARED_TAIL
|
|
43274
|
+
].join("\n");
|
|
43275
|
+
var SHARED_BLIND = [
|
|
43276
|
+
"You have no tools and cannot see the workspace. Everything you have is in the question. If",
|
|
43277
|
+
"something essential is missing, say exactly what you need and why, then give the best answer you",
|
|
43278
|
+
"can without it \u2014 never refuse to answer.",
|
|
43279
|
+
"",
|
|
43280
|
+
...SHARED_TAIL
|
|
43281
|
+
].join("\n");
|
|
43282
|
+
function specialistPreamble(usesTools) {
|
|
43283
|
+
return usesTools ? SHARED_WITH_TOOLS : SHARED_BLIND;
|
|
43284
|
+
}
|
|
43285
|
+
var DEFINITIONS = {
|
|
43286
|
+
expert: {
|
|
43287
|
+
name: "Expert",
|
|
43288
|
+
summary: "Hard problems, architecture, and deciding what to do",
|
|
43289
|
+
/* Planning a change means knowing what is already there, and it spans files the asker
|
|
43290
|
+
* cannot paste all of. */
|
|
43291
|
+
usesTools: true,
|
|
43292
|
+
prompt: [
|
|
43293
|
+
"You are a senior engineer being consulted by another AI assistant that is doing the work.",
|
|
43294
|
+
"",
|
|
43295
|
+
"It has hit something hard: a change across several files to plan, a bug it has already",
|
|
43296
|
+
"failed to fix, or a design choice with no obvious answer. Give it your judgement.",
|
|
43297
|
+
"",
|
|
43298
|
+
"Decide *what* should happen and why. Leave the typing to the assistant \u2014 it is the one",
|
|
43299
|
+
"making the change and answering for it. Where there is a real trade-off, name both sides",
|
|
43300
|
+
"and then choose."
|
|
43301
|
+
].join("\n")
|
|
43302
|
+
},
|
|
43303
|
+
programmer: {
|
|
43304
|
+
name: "Programmer",
|
|
43305
|
+
summary: "Writes the code once the plan is settled",
|
|
43306
|
+
/* It is handed a spec and the surrounding code and asked to write. Looking around buys
|
|
43307
|
+
* a slower answer that is no better. */
|
|
43308
|
+
usesTools: false,
|
|
43309
|
+
prompt: [
|
|
43310
|
+
"You are an experienced programmer writing code for another AI assistant to apply.",
|
|
43311
|
+
"",
|
|
43312
|
+
"You are given a requirement and the surrounding code. Produce the change, matching the",
|
|
43313
|
+
"conventions of what you were shown rather than your own preferences \u2014 the naming, the error",
|
|
43314
|
+
"handling, the comment density, the way the existing code does this sort of thing.",
|
|
43315
|
+
"",
|
|
43316
|
+
"Return the code and a short note on anything non-obvious in it. Do not narrate what you are",
|
|
43317
|
+
"about to do, and do not rewrite things you were not asked to change.",
|
|
43318
|
+
"",
|
|
43319
|
+
/*
|
|
43320
|
+
* The programmer is the role that gets its own work handed back, so it is the one that has
|
|
43321
|
+
* to be told what to do with a review — including that it may disagree. Requested in those
|
|
43322
|
+
* terms: it is classified as the programmer, so fixing it is its job, and it should be able
|
|
43323
|
+
* to challenge a reviewer rather than obey one.
|
|
43324
|
+
*/
|
|
43325
|
+
"You may be given a review of code you wrote. Fix what is genuinely wrong and return the",
|
|
43326
|
+
"corrected code the same way. **Where the review is wrong, say so and say why** \u2014 a finding",
|
|
43327
|
+
"can be about a path that cannot happen, a convention this codebase does not follow, or a",
|
|
43328
|
+
"misreading of a fragment. Do not rewrite working code to satisfy an objection you think is",
|
|
43329
|
+
"mistaken; the assistant has the real file and will settle it. Changing something you believe",
|
|
43330
|
+
"is right, because you were told to, is the worse failure: it looks like agreement."
|
|
43331
|
+
].join("\n")
|
|
43332
|
+
},
|
|
43333
|
+
reviewer: {
|
|
43334
|
+
name: "Reviewer",
|
|
43335
|
+
summary: "Reads a change and says what is wrong with it",
|
|
43336
|
+
/* Most of what a review turns on is *around* the diff — the callers, the neighbouring
|
|
43337
|
+
* function, whether this convention is really the convention. */
|
|
43338
|
+
usesTools: true,
|
|
43339
|
+
prompt: [
|
|
43340
|
+
"You are reviewing a change written by another AI assistant.",
|
|
43341
|
+
"",
|
|
43342
|
+
"Your job is to find what is wrong with it. Say so plainly when something is fine, but do",
|
|
43343
|
+
"not pad the review with praise \u2014 an approving review that missed a bug is worse than no",
|
|
43344
|
+
"review, because it was believed.",
|
|
43345
|
+
"",
|
|
43346
|
+
"Look for, in this order: does it do what was asked; does it break something that used to",
|
|
43347
|
+
"work; what happens at the edges \u2014 empty, missing, concurrent, already-exists, fails halfway;",
|
|
43348
|
+
"and does it match the conventions of the code around it.",
|
|
43349
|
+
"",
|
|
43350
|
+
"For each finding say what breaks and under what input. A concern you cannot make concrete is",
|
|
43351
|
+
"worth one sentence, flagged as a hunch, not a paragraph.",
|
|
43352
|
+
"",
|
|
43353
|
+
// Findings go back to whoever wrote the code, which may disagree. Concrete ones can be
|
|
43354
|
+
// settled against the file; vague ones turn into an argument nobody can end.
|
|
43355
|
+
"Your findings may be put to the person who wrote the code, who can disagree with them. That",
|
|
43356
|
+
"is why each one needs an input and an outcome: a finding stated concretely can be checked",
|
|
43357
|
+
"against the real file and settled, and one stated as a preference cannot."
|
|
43358
|
+
].join("\n")
|
|
43359
|
+
},
|
|
43360
|
+
tester: {
|
|
43361
|
+
name: "Tester",
|
|
43362
|
+
summary: "Designs cases and finds what breaks it",
|
|
43363
|
+
/* The change is in front of it and the cases come from reasoning about it, not from
|
|
43364
|
+
* reading more of the codebase. */
|
|
43365
|
+
usesTools: false,
|
|
43366
|
+
prompt: [
|
|
43367
|
+
"You design tests for code written by another AI assistant.",
|
|
43368
|
+
"",
|
|
43369
|
+
"Given a change, say what should be tested and why each case earns its place. Prefer the",
|
|
43370
|
+
"cases that would actually fail: boundaries, empty and missing values, the error path, the",
|
|
43371
|
+
"second call, the concurrent one, the one that fails halfway and has to be recovered from.",
|
|
43372
|
+
"",
|
|
43373
|
+
"A test that cannot fail is worth nothing \u2014 for each case you propose, say what bug it would",
|
|
43374
|
+
"catch. If the change is untestable as written, say what would have to change to make it",
|
|
43375
|
+
"testable rather than proposing a test that only asserts the code was executed."
|
|
43376
|
+
].join("\n")
|
|
43377
|
+
},
|
|
43378
|
+
librarian: {
|
|
43379
|
+
name: "Librarian",
|
|
43380
|
+
summary: "Skills, internal documentation and house conventions",
|
|
43381
|
+
/* Its whole job is what has been written down here, so being unable to go and read it
|
|
43382
|
+
* left it answering from whatever happened to be pasted in. This is the role the flag
|
|
43383
|
+
* exists for. */
|
|
43384
|
+
usesTools: true,
|
|
43385
|
+
prompt: [
|
|
43386
|
+
"You answer questions about how things are done here: internal libraries, house conventions,",
|
|
43387
|
+
"the shape of existing code, and what has already been written down.",
|
|
43388
|
+
"",
|
|
43389
|
+
"You are given whatever documentation, skills and code the assistant could find. Answer from",
|
|
43390
|
+
"that, and be explicit about the difference between what the material actually says and what",
|
|
43391
|
+
"you are inferring \u2014 a convention you guessed at, stated confidently, becomes the convention.",
|
|
43392
|
+
"",
|
|
43393
|
+
"If the material does not answer the question, say so and say what would. Do not fill the gap",
|
|
43394
|
+
"with how it is usually done elsewhere unless you label it as exactly that."
|
|
43395
|
+
].join("\n")
|
|
43396
|
+
}
|
|
43397
|
+
};
|
|
43398
|
+
function roleInfo(role, custom2 = []) {
|
|
43399
|
+
const builtIn = DEFINITIONS[role];
|
|
43400
|
+
if (builtIn !== void 0)
|
|
43401
|
+
return { role, ...builtIn };
|
|
43402
|
+
const defined = custom2.find((candidate) => candidate.id === role);
|
|
43403
|
+
if (defined !== void 0) {
|
|
43404
|
+
return {
|
|
43405
|
+
role,
|
|
43406
|
+
name: defined.name,
|
|
43407
|
+
summary: defined.summary,
|
|
43408
|
+
prompt: defined.prompt.trim(),
|
|
43409
|
+
/*
|
|
43410
|
+
* Custom roles get tools by default.
|
|
43411
|
+
*
|
|
43412
|
+
* They are overwhelmingly reviewers of some particular kind — security, performance,
|
|
43413
|
+
* accessibility — and those all turn on code the asker did not think to paste. The flag is
|
|
43414
|
+
* there to turn it off for the ones that are really "write this to spec".
|
|
43415
|
+
*/
|
|
43416
|
+
usesTools: defined.usesTools !== false
|
|
43417
|
+
};
|
|
43418
|
+
}
|
|
43419
|
+
return {
|
|
43420
|
+
role,
|
|
43421
|
+
name: role,
|
|
43422
|
+
summary: "This role is no longer defined.",
|
|
43423
|
+
prompt: "",
|
|
43424
|
+
usesTools: false
|
|
43425
|
+
};
|
|
43426
|
+
}
|
|
43427
|
+
function allRoles(custom2 = []) {
|
|
43428
|
+
return knownRoles(custom2).map((role) => roleInfo(role, custom2));
|
|
43429
|
+
}
|
|
43430
|
+
function defaultPromptFor(role, custom2 = []) {
|
|
43431
|
+
return roleInfo(role, custom2).prompt;
|
|
43432
|
+
}
|
|
43433
|
+
function buildAgentPrompt(options) {
|
|
43434
|
+
const lines = [options.prompt.trim(), "", specialistPreamble(options.usesTools)];
|
|
43435
|
+
if (options.briefing !== void 0 && options.briefing.trim().length > 0) {
|
|
43436
|
+
lines.push("", options.briefing);
|
|
43437
|
+
}
|
|
43438
|
+
lines.push("", "---", "", options.question);
|
|
43439
|
+
if (options.files !== void 0 && options.files.length > 0) {
|
|
43440
|
+
lines.push("", options.usesTools ? "The assistant named these files as relevant. Start there \u2014 you can open them yourself:" : "The assistant named these files as relevant. You cannot open them \u2014 they are listed so you know what it is looking at:", ...options.files.map((file2) => `- ${file2}`));
|
|
43441
|
+
}
|
|
43442
|
+
return lines.join("\n");
|
|
43443
|
+
}
|
|
43444
|
+
|
|
43445
|
+
// ../../packages/core/dist/agent/checkpoints.js
|
|
43446
|
+
var MAX_CHECKPOINTS = 50;
|
|
43447
|
+
var LIST_ITEM = /^(\s*)(?:([-*•])|(\d+)[.)])\s+(.+)$/;
|
|
43448
|
+
function idFor(text) {
|
|
43449
|
+
let hash2 = 2166136261;
|
|
43450
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
43451
|
+
hash2 ^= text.charCodeAt(index);
|
|
43452
|
+
hash2 = Math.imul(hash2, 16777619) >>> 0;
|
|
43453
|
+
}
|
|
43454
|
+
return hash2.toString(36);
|
|
43455
|
+
}
|
|
43456
|
+
function normalise(text) {
|
|
43457
|
+
return text.trim().toLowerCase().replace(/\s+/g, " ").replace(/[.;,:]+$/, "");
|
|
43458
|
+
}
|
|
43459
|
+
function parseCheckpoints(plan) {
|
|
43460
|
+
const lines = (plan ?? "").split(/\r?\n/);
|
|
43461
|
+
const items = [];
|
|
43462
|
+
lines.forEach((line, index) => {
|
|
43463
|
+
const match = LIST_ITEM.exec(line);
|
|
43464
|
+
if (match === null)
|
|
43465
|
+
return;
|
|
43466
|
+
const text = match[4]?.trim() ?? "";
|
|
43467
|
+
if (text.length === 0)
|
|
43468
|
+
return;
|
|
43469
|
+
items.push({
|
|
43470
|
+
indent: (match[1] ?? "").replace(/\t/g, " ").length,
|
|
43471
|
+
ordered: match[3] !== void 0,
|
|
43472
|
+
text,
|
|
43473
|
+
line: index
|
|
43474
|
+
});
|
|
43475
|
+
});
|
|
43476
|
+
const ordered = items.filter((item) => item.ordered);
|
|
43477
|
+
const candidates = ordered.length > 0 ? ordered : items;
|
|
43478
|
+
const shallowest = candidates.reduce((least, item) => Math.min(least, item.indent), Number.POSITIVE_INFINITY);
|
|
43479
|
+
const steps = candidates.filter((item) => item.indent === shallowest);
|
|
43480
|
+
const texts = steps.length > 0 ? steps : (
|
|
43481
|
+
// No list at all: plenty of people write a plan as bare lines, and a progress view that
|
|
43482
|
+
// only worked for bullet-point authors would read as broken.
|
|
43483
|
+
lines.map((line, index) => ({ indent: 0, ordered: false, text: line.trim(), line: index })).filter((item) => item.text.length > 0)
|
|
43484
|
+
);
|
|
43485
|
+
const chosen = texts.slice(0, MAX_CHECKPOINTS);
|
|
43486
|
+
const seen = /* @__PURE__ */ new Map();
|
|
43487
|
+
return chosen.map((item, position) => {
|
|
43488
|
+
const key = normalise(item.text);
|
|
43489
|
+
const occurrence = (seen.get(key) ?? 0) + 1;
|
|
43490
|
+
seen.set(key, occurrence);
|
|
43491
|
+
const until = chosen[position + 1]?.line ?? lines.length;
|
|
43492
|
+
return {
|
|
43493
|
+
id: occurrence === 1 ? idFor(key) : `${idFor(key)}-${String(occurrence)}`,
|
|
43494
|
+
index: position + 1,
|
|
43495
|
+
text: item.text,
|
|
43496
|
+
/*
|
|
43497
|
+
* Who the plan says should be involved, read from the step *and everything under it* —
|
|
43498
|
+
* which is where the allocation actually lives, since a specialist is usually named on a
|
|
43499
|
+
* continuation line ("Owner: reviewer") or inside a sub-point rather than in the heading.
|
|
43500
|
+
*/
|
|
43501
|
+
plannedRoles: rolesMentionedIn(lines.slice(item.line, until).join(" "))
|
|
43502
|
+
};
|
|
43503
|
+
});
|
|
43504
|
+
}
|
|
43505
|
+
function rolesMentionedIn(text) {
|
|
43506
|
+
const haystack = text.toLowerCase();
|
|
43507
|
+
return AGENT_ROLES.filter((role) => new RegExp(`\\b${role}\\b`).test(haystack));
|
|
43508
|
+
}
|
|
43509
|
+
function checkpointViews(plan, progress) {
|
|
43510
|
+
return parseCheckpoints(plan).map((checkpoint) => {
|
|
43511
|
+
const recorded = progress?.[checkpoint.id];
|
|
43512
|
+
return {
|
|
43513
|
+
...checkpoint,
|
|
43514
|
+
status: recorded?.status ?? "todo",
|
|
43515
|
+
roles: recorded?.roles ?? []
|
|
43516
|
+
};
|
|
43517
|
+
});
|
|
43518
|
+
}
|
|
43519
|
+
function pruneProgress(plan, progress) {
|
|
43520
|
+
if (progress === void 0)
|
|
43521
|
+
return {};
|
|
43522
|
+
const live = new Set(parseCheckpoints(plan).map((checkpoint) => checkpoint.id));
|
|
43523
|
+
const kept = {};
|
|
43524
|
+
for (const [id, entry] of Object.entries(progress))
|
|
43525
|
+
if (live.has(id))
|
|
43526
|
+
kept[id] = entry;
|
|
43527
|
+
return kept;
|
|
43528
|
+
}
|
|
43529
|
+
function markCheckpoint(plan, progress, index, status) {
|
|
43530
|
+
const checkpoint = parseCheckpoints(plan).find((candidate) => candidate.index === index);
|
|
43531
|
+
if (checkpoint === void 0)
|
|
43532
|
+
return void 0;
|
|
43533
|
+
const existing = progress[checkpoint.id];
|
|
43534
|
+
return {
|
|
43535
|
+
...progress,
|
|
43536
|
+
[checkpoint.id]: {
|
|
43537
|
+
status,
|
|
43538
|
+
// Kept across a start→done transition: the specialists consulted while the step was being
|
|
43539
|
+
// worked are exactly the ones that contributed to finishing it.
|
|
43540
|
+
roles: existing?.roles ?? [],
|
|
43541
|
+
at: Date.now()
|
|
43542
|
+
}
|
|
43543
|
+
};
|
|
43544
|
+
}
|
|
43545
|
+
function attributeConsultation(progress, role) {
|
|
43546
|
+
const entry = Object.entries(progress).find(([, value2]) => value2.status === "active");
|
|
43547
|
+
if (entry === void 0)
|
|
43548
|
+
return progress;
|
|
43549
|
+
const [id, value] = entry;
|
|
43550
|
+
if (value.roles.includes(role))
|
|
43551
|
+
return progress;
|
|
43552
|
+
return { ...progress, [id]: { ...value, roles: [...value.roles, role] } };
|
|
43553
|
+
}
|
|
43554
|
+
function progressSummary(views) {
|
|
43555
|
+
const done = views.filter((view) => view.status === "done").length;
|
|
43556
|
+
return `${String(done)}/${String(views.length)}`;
|
|
43557
|
+
}
|
|
43558
|
+
|
|
43231
43559
|
// ../../packages/core/dist/agent/plan.js
|
|
43232
43560
|
var PLAN_LIMIT = 4e3;
|
|
43233
43561
|
function buildPlanGuidance(plan) {
|
|
43234
43562
|
const trimmed = plan?.trim() ?? "";
|
|
43235
43563
|
if (trimmed.length === 0)
|
|
43236
43564
|
return "";
|
|
43565
|
+
const checkpoints = parseCheckpoints(trimmed);
|
|
43566
|
+
const numbered = checkpoints.length > 0 ? [
|
|
43567
|
+
"",
|
|
43568
|
+
"Its steps are numbered as follows. These numbers are what `plan_progress` takes, and",
|
|
43569
|
+
"they are what the user sees:",
|
|
43570
|
+
"",
|
|
43571
|
+
...checkpoints.map((checkpoint) => `${String(checkpoint.index)}. ${checkpoint.text}`)
|
|
43572
|
+
] : [];
|
|
43237
43573
|
return [
|
|
43238
43574
|
"# The plan for this conversation",
|
|
43239
43575
|
"",
|
|
43240
43576
|
"The user set this. It is what you are here to do:",
|
|
43241
43577
|
"",
|
|
43242
43578
|
trimmed,
|
|
43579
|
+
...numbered,
|
|
43580
|
+
"",
|
|
43581
|
+
"## Reporting where you are",
|
|
43582
|
+
"",
|
|
43583
|
+
"- **Call `plan_progress` with `active` when you start a step**, and with `done` when it is",
|
|
43584
|
+
" actually finished. The user watches this rather than reading the whole transcript, so a",
|
|
43585
|
+
" step marked done that is not done is worse than one never marked at all.",
|
|
43586
|
+
"- Work one step at a time. Marking three done at the end tells the user nothing while it",
|
|
43587
|
+
" matters, which is the only time it is useful.",
|
|
43588
|
+
"",
|
|
43589
|
+
"## Changing the plan",
|
|
43590
|
+
"",
|
|
43591
|
+
"- **You may propose a different plan with `update_plan`, and the user must approve it.**",
|
|
43592
|
+
" They are shown a diff of the plan they have against the one you are proposing. This is",
|
|
43593
|
+
" the only way the plan changes on your side \u2014 never act on a plan the user has not agreed.",
|
|
43594
|
+
"- Use it when you have worked out a better plan, including one a specialist drafted for you.",
|
|
43595
|
+
" Put the whole plan in it: it replaces what is there rather than adding to it.",
|
|
43596
|
+
"- If they decline, the existing plan still stands and you carry on with it.",
|
|
43243
43597
|
"",
|
|
43244
43598
|
"## Working to it",
|
|
43245
43599
|
"",
|
|
@@ -43699,130 +44053,6 @@ ${withBudget}` : withBudget;
|
|
|
43699
44053
|
};
|
|
43700
44054
|
}
|
|
43701
44055
|
|
|
43702
|
-
// ../../packages/core/dist/agents/roles.js
|
|
43703
|
-
var AGENT_ROLES = ["expert", "programmer", "reviewer", "tester", "librarian"];
|
|
43704
|
-
function isAgentRole(value) {
|
|
43705
|
-
return AGENT_ROLES.includes(value);
|
|
43706
|
-
}
|
|
43707
|
-
var SHARED = [
|
|
43708
|
-
"You cannot see the workspace and cannot read files, run commands or search. Everything you",
|
|
43709
|
-
"have is in the question. If something essential is missing, say exactly what you need and why,",
|
|
43710
|
-
"then give the best answer you can without it \u2014 never refuse to answer.",
|
|
43711
|
-
"",
|
|
43712
|
-
"Your reply is advice. The assistant will check it against the real code before acting, and it",
|
|
43713
|
-
"is responsible for the result. Be concrete, say what you are unsure about, and say plainly when",
|
|
43714
|
-
"something must be verified rather than assumed.",
|
|
43715
|
-
"",
|
|
43716
|
-
"Answer in prose and short lists. No preamble about being happy to help."
|
|
43717
|
-
].join("\n");
|
|
43718
|
-
var DEFINITIONS = {
|
|
43719
|
-
expert: {
|
|
43720
|
-
name: "Expert",
|
|
43721
|
-
summary: "Hard problems, architecture, and deciding what to do",
|
|
43722
|
-
prompt: [
|
|
43723
|
-
"You are a senior engineer being consulted by another AI assistant that is doing the work.",
|
|
43724
|
-
"",
|
|
43725
|
-
"It has hit something hard: a change across several files to plan, a bug it has already",
|
|
43726
|
-
"failed to fix, or a design choice with no obvious answer. Give it your judgement.",
|
|
43727
|
-
"",
|
|
43728
|
-
"Decide *what* should happen and why. Leave the typing to the assistant \u2014 it has the files",
|
|
43729
|
-
"open and you do not. Where there is a real trade-off, name both sides and then choose.",
|
|
43730
|
-
"",
|
|
43731
|
-
SHARED
|
|
43732
|
-
].join("\n")
|
|
43733
|
-
},
|
|
43734
|
-
programmer: {
|
|
43735
|
-
name: "Programmer",
|
|
43736
|
-
summary: "Writes the code once the plan is settled",
|
|
43737
|
-
prompt: [
|
|
43738
|
-
"You are an experienced programmer writing code for another AI assistant to apply.",
|
|
43739
|
-
"",
|
|
43740
|
-
"You are given a requirement and the surrounding code. Produce the change, matching the",
|
|
43741
|
-
"conventions of what you were shown rather than your own preferences \u2014 the naming, the error",
|
|
43742
|
-
"handling, the comment density, the way the existing code does this sort of thing.",
|
|
43743
|
-
"",
|
|
43744
|
-
"Return the code and a short note on anything non-obvious in it. Do not narrate what you are",
|
|
43745
|
-
"about to do, and do not rewrite things you were not asked to change.",
|
|
43746
|
-
"",
|
|
43747
|
-
SHARED
|
|
43748
|
-
].join("\n")
|
|
43749
|
-
},
|
|
43750
|
-
reviewer: {
|
|
43751
|
-
name: "Reviewer",
|
|
43752
|
-
summary: "Reads a change and says what is wrong with it",
|
|
43753
|
-
prompt: [
|
|
43754
|
-
"You are reviewing a change written by another AI assistant.",
|
|
43755
|
-
"",
|
|
43756
|
-
"Your job is to find what is wrong with it. Say so plainly when something is fine, but do",
|
|
43757
|
-
"not pad the review with praise \u2014 an approving review that missed a bug is worse than no",
|
|
43758
|
-
"review, because it was believed.",
|
|
43759
|
-
"",
|
|
43760
|
-
"Look for, in this order: does it do what was asked; does it break something that used to",
|
|
43761
|
-
"work; what happens at the edges \u2014 empty, missing, concurrent, already-exists, fails halfway;",
|
|
43762
|
-
"and does it match the conventions of the code around it.",
|
|
43763
|
-
"",
|
|
43764
|
-
"For each finding say what breaks and under what input. A concern you cannot make concrete is",
|
|
43765
|
-
"worth one sentence, flagged as a hunch, not a paragraph.",
|
|
43766
|
-
"",
|
|
43767
|
-
SHARED
|
|
43768
|
-
].join("\n")
|
|
43769
|
-
},
|
|
43770
|
-
tester: {
|
|
43771
|
-
name: "Tester",
|
|
43772
|
-
summary: "Designs cases and finds what breaks it",
|
|
43773
|
-
prompt: [
|
|
43774
|
-
"You design tests for code written by another AI assistant.",
|
|
43775
|
-
"",
|
|
43776
|
-
"Given a change, say what should be tested and why each case earns its place. Prefer the",
|
|
43777
|
-
"cases that would actually fail: boundaries, empty and missing values, the error path, the",
|
|
43778
|
-
"second call, the concurrent one, the one that fails halfway and has to be recovered from.",
|
|
43779
|
-
"",
|
|
43780
|
-
"A test that cannot fail is worth nothing \u2014 for each case you propose, say what bug it would",
|
|
43781
|
-
"catch. If the change is untestable as written, say what would have to change to make it",
|
|
43782
|
-
"testable rather than proposing a test that only asserts the code was executed.",
|
|
43783
|
-
"",
|
|
43784
|
-
SHARED
|
|
43785
|
-
].join("\n")
|
|
43786
|
-
},
|
|
43787
|
-
librarian: {
|
|
43788
|
-
name: "Librarian",
|
|
43789
|
-
summary: "Skills, internal documentation and house conventions",
|
|
43790
|
-
prompt: [
|
|
43791
|
-
"You answer questions about how things are done here: internal libraries, house conventions,",
|
|
43792
|
-
"the shape of existing code, and what has already been written down.",
|
|
43793
|
-
"",
|
|
43794
|
-
"You are given whatever documentation, skills and code the assistant could find. Answer from",
|
|
43795
|
-
"that, and be explicit about the difference between what the material actually says and what",
|
|
43796
|
-
"you are inferring \u2014 a convention you guessed at, stated confidently, becomes the convention.",
|
|
43797
|
-
"",
|
|
43798
|
-
"If the material does not answer the question, say so and say what would. Do not fill the gap",
|
|
43799
|
-
"with how it is usually done elsewhere unless you label it as exactly that.",
|
|
43800
|
-
"",
|
|
43801
|
-
SHARED
|
|
43802
|
-
].join("\n")
|
|
43803
|
-
}
|
|
43804
|
-
};
|
|
43805
|
-
function roleInfo(role) {
|
|
43806
|
-
return { role, ...DEFINITIONS[role] };
|
|
43807
|
-
}
|
|
43808
|
-
function allRoles() {
|
|
43809
|
-
return AGENT_ROLES.map(roleInfo);
|
|
43810
|
-
}
|
|
43811
|
-
function defaultPromptFor(role) {
|
|
43812
|
-
return DEFINITIONS[role].prompt;
|
|
43813
|
-
}
|
|
43814
|
-
function buildAgentPrompt(options) {
|
|
43815
|
-
const lines = [options.prompt];
|
|
43816
|
-
if (options.briefing !== void 0 && options.briefing.trim().length > 0) {
|
|
43817
|
-
lines.push("", options.briefing);
|
|
43818
|
-
}
|
|
43819
|
-
lines.push("", "---", "", options.question);
|
|
43820
|
-
if (options.files !== void 0 && options.files.length > 0) {
|
|
43821
|
-
lines.push("", "The assistant named these files as relevant. You cannot open them \u2014 they are listed so you", "know what it is looking at:", ...options.files.map((file2) => `- ${file2}`));
|
|
43822
|
-
}
|
|
43823
|
-
return lines.join("\n");
|
|
43824
|
-
}
|
|
43825
|
-
|
|
43826
44056
|
// ../../packages/core/dist/tools/askAgent.js
|
|
43827
44057
|
var paramsSchema3 = external_exports.object({
|
|
43828
44058
|
role: external_exports.string().describe(`Which specialist to ask: ${AGENT_ROLES.join(", ")}. Only the ones assigned in Settings \u2192 Agents can answer.`),
|
|
@@ -43892,7 +44122,7 @@ Files named as relevant: ${params.files.join(", ")}` : "")
|
|
|
43892
44122
|
|
|
43893
44123
|
---
|
|
43894
44124
|
|
|
43895
|
-
|
|
44125
|
+
${trailerFor(agent, team)}`
|
|
43896
44126
|
};
|
|
43897
44127
|
}
|
|
43898
44128
|
};
|
|
@@ -43908,6 +44138,19 @@ function describeTeam(team) {
|
|
|
43908
44138
|
const usable = team.filter((agent) => agent.available).map((agent) => agent.role);
|
|
43909
44139
|
return usable.length === 0 ? "None are assigned on this machine." : `Assigned here: ${usable.join(", ")}.`;
|
|
43910
44140
|
}
|
|
44141
|
+
function trailerFor(agent, team) {
|
|
44142
|
+
const lines = [
|
|
44143
|
+
`That is the ${agent.role}'s advice, from ${agent.label}. ` + (agent.usesTools ? "It could read this workspace but cannot change anything in it." : "It has not seen your workspace \u2014 it answered from what you pasted.") + " Check it against the actual code before acting on it, and say so if it turns out to be wrong."
|
|
44144
|
+
];
|
|
44145
|
+
const programmer = team.find((candidate) => candidate.role === "programmer" && candidate.available);
|
|
44146
|
+
if (agent.role === "reviewer" && programmer !== void 0) {
|
|
44147
|
+
lines.push("", "If the programmer wrote this code, take the findings back to it rather than fixing them yourself: paste the code as it stands, the findings in full, and anything you have already checked. It may disagree, and a disagreement is an answer \u2014 you have the real file and neither of them does, so you settle it and say which way you went. Re-review only if the fix was substantial enough that this review no longer describes the code.");
|
|
44148
|
+
}
|
|
44149
|
+
if (agent.role === "programmer") {
|
|
44150
|
+
lines.push("", "Check this against the real file before applying it \u2014 it was written from what you pasted, so it can miss a convention or a caller it was never shown.");
|
|
44151
|
+
}
|
|
44152
|
+
return lines.join("\n");
|
|
44153
|
+
}
|
|
43911
44154
|
|
|
43912
44155
|
// ../../packages/core/dist/agents/team.js
|
|
43913
44156
|
function defaultAssignment(role, context) {
|
|
@@ -43915,12 +44158,14 @@ function defaultAssignment(role, context) {
|
|
|
43915
44158
|
}
|
|
43916
44159
|
function resolveTeam(context) {
|
|
43917
44160
|
const resolved = [];
|
|
43918
|
-
|
|
44161
|
+
const custom2 = context.config?.definitions ?? [];
|
|
44162
|
+
for (const role of knownRoles(custom2)) {
|
|
43919
44163
|
const assignment = context.config?.roles?.[role] ?? defaultAssignment(role, context);
|
|
43920
44164
|
if (assignment === void 0)
|
|
43921
44165
|
continue;
|
|
43922
|
-
const info = roleInfo(role);
|
|
43923
|
-
const prompt = assignment.prompt ?? defaultPromptFor(role);
|
|
44166
|
+
const info = roleInfo(role, custom2);
|
|
44167
|
+
const prompt = assignment.prompt ?? defaultPromptFor(role, custom2);
|
|
44168
|
+
const usesTools = assignment.tools ?? info.usesTools;
|
|
43924
44169
|
if (assignment.kind === "cli") {
|
|
43925
44170
|
resolved.push({
|
|
43926
44171
|
role,
|
|
@@ -43929,6 +44174,7 @@ function resolveTeam(context) {
|
|
|
43929
44174
|
kind: "cli",
|
|
43930
44175
|
label: "Claude",
|
|
43931
44176
|
prompt,
|
|
44177
|
+
usesTools,
|
|
43932
44178
|
available: context.cliAvailable,
|
|
43933
44179
|
...context.cliAvailable ? {} : { reason: "The Claude CLI is not available on this machine." }
|
|
43934
44180
|
});
|
|
@@ -43943,6 +44189,7 @@ function resolveTeam(context) {
|
|
|
43943
44189
|
...assignment.profileId !== void 0 ? { profileId: assignment.profileId } : {},
|
|
43944
44190
|
label: profile?.label ?? assignment.profileId ?? "unassigned",
|
|
43945
44191
|
prompt,
|
|
44192
|
+
usesTools,
|
|
43946
44193
|
available: profile !== void 0,
|
|
43947
44194
|
/*
|
|
43948
44195
|
* A profile that has been deleted leaves the role unavailable and says so, rather than
|
|
@@ -43971,6 +44218,46 @@ var BUDGET_ADVICE = [
|
|
|
43971
44218
|
"out the specialist stops being available, and you finish the work alone, so spend it on the",
|
|
43972
44219
|
"parts where another reader genuinely changes what you do."
|
|
43973
44220
|
].join("\n");
|
|
44221
|
+
var PLAN_FIRST = [
|
|
44222
|
+
"",
|
|
44223
|
+
"## Start by planning. This comes before everything else.",
|
|
44224
|
+
"",
|
|
44225
|
+
"**This conversation has no plan yet, so making one is your first job.** Before reading widely,",
|
|
44226
|
+
"before editing anything, before running anything:",
|
|
44227
|
+
"",
|
|
44228
|
+
"1. **Look at almost nothing first.** One `list_files` of the workspace root is usually the",
|
|
44229
|
+
" whole of it, plus any file the user actually named. That is enough to ask a good question.",
|
|
44230
|
+
" Do **not** survey the codebase, search the documentation index, hunt for skills, or read",
|
|
44231
|
+
" files to get a feel for the style \u2014 not yet. The specialist cannot see any of it anyway,",
|
|
44232
|
+
" and if it needs something specific it will say so and you can fetch it and ask again.",
|
|
44233
|
+
' Announcing that you are "getting a sense of the workspace before proposing anything" is',
|
|
44234
|
+
" this instruction being broken, however reasonable it sounds.",
|
|
44235
|
+
"2. **Ask the expert for the plan** \u2014 give the task, the little you found and the constraints,",
|
|
44236
|
+
" and ask for numbered steps. A plan is the one thing worth asking for before the work rather",
|
|
44237
|
+
" than after it, and it is what the expert is for. An expert asked early enough to change the",
|
|
44238
|
+
" shape of the work is worth several times one asked to bless a direction already taken.",
|
|
44239
|
+
" **Ask it to say which specialist should be involved in which step**, from the team it is",
|
|
44240
|
+
" given. It knows who is available; it will not volunteer the allocation unless asked.",
|
|
44241
|
+
"3. **Propose it with `update_plan`.** The user sees a diff and approves it. Do not skip this:",
|
|
44242
|
+
" a plan held only in the conversation is forgotten as the chat grows, and it is not",
|
|
44243
|
+
" something the user has agreed to.",
|
|
44244
|
+
"4. Only once it is approved, start the work, reporting each step with `plan_progress`.",
|
|
44245
|
+
"",
|
|
44246
|
+
"If the user declines, ask what they want changed and propose a revised plan. If no expert is",
|
|
44247
|
+
"assigned, draft it yourself and propose it the same way \u2014 and say that is what you did, so",
|
|
44248
|
+
"nobody believes it was reviewed by somebody else.",
|
|
44249
|
+
"",
|
|
44250
|
+
"The exception is a question rather than a job. If the user asked something you can simply",
|
|
44251
|
+
"answer, answer it \u2014 do not plan a conversation."
|
|
44252
|
+
].join("\n");
|
|
44253
|
+
var PLAN_IN_PLACE = [
|
|
44254
|
+
"",
|
|
44255
|
+
"## This conversation already has a plan",
|
|
44256
|
+
"",
|
|
44257
|
+
"It is above, with its steps numbered. Work it, report each step with `plan_progress`, and if it",
|
|
44258
|
+
"turns out to be wrong, consult the expert and propose a replacement with `update_plan` rather",
|
|
44259
|
+
"than quietly working to a different one."
|
|
44260
|
+
].join("\n");
|
|
43974
44261
|
var DEFAULT_TEAM_GUIDANCE = [
|
|
43975
44262
|
"You lead a small team. You do the work \u2014 reading, searching, editing, running things \u2014 and you",
|
|
43976
44263
|
"consult specialists when another reader would genuinely change what you do.",
|
|
@@ -43986,17 +44273,39 @@ var DEFAULT_TEAM_GUIDANCE = [
|
|
|
43986
44273
|
"- you are about to call something done that has no tests \u2014 ask the **tester** what would break",
|
|
43987
44274
|
" it;",
|
|
43988
44275
|
"- you are guessing at how this codebase does something \u2014 ask the **librarian** rather than",
|
|
43989
|
-
" inventing a convention
|
|
44276
|
+
" inventing a convention;",
|
|
44277
|
+
/*
|
|
44278
|
+
* The programmer was missing from this list entirely, which is most of why it never got used.
|
|
44279
|
+
*
|
|
44280
|
+
* Every other bullet describes somebody *reading* what you have, and writing code is the one
|
|
44281
|
+
* thing the assistant can already do — so with no bullet of its own the role simply never came
|
|
44282
|
+
* up, and a plan drafted by the expert never allocated it either (the same omission, in the
|
|
44283
|
+
* briefing). Bounded deliberately: "hand everything to the programmer" would add a round trip
|
|
44284
|
+
* to every edit and put a second model's conventions into the file.
|
|
44285
|
+
*/
|
|
44286
|
+
"- a step is a self-contained piece of code with a clear spec \u2014 a parser, a schema, a set of",
|
|
44287
|
+
" pure functions \u2014 hand it to the **programmer** rather than writing it yourself out of habit,",
|
|
44288
|
+
" then check what comes back against the real file before applying it. Not for a two-line",
|
|
44289
|
+
" change, and not where the spec is still moving.",
|
|
43990
44290
|
"",
|
|
43991
44291
|
'The user can also ask directly ("ask the reviewer to look at this"), and then you consult that',
|
|
43992
44292
|
"role whatever you would have chosen.",
|
|
43993
44293
|
"",
|
|
43994
44294
|
"## What makes a consultation worth it",
|
|
43995
44295
|
"",
|
|
43996
|
-
|
|
43997
|
-
|
|
43998
|
-
|
|
43999
|
-
|
|
44296
|
+
/*
|
|
44297
|
+
* The last place still saying every specialist is blind.
|
|
44298
|
+
*
|
|
44299
|
+
* Some can read and search for themselves; the roster above marks which. But the advice does
|
|
44300
|
+
* not change much, because even one that can look things up starts from what you gave it — and
|
|
44301
|
+
* a question with nothing attached spends its whole lookup budget finding the file you already
|
|
44302
|
+
* had open.
|
|
44303
|
+
*/
|
|
44304
|
+
"**Paste the code**, the error, the failing output \u2014 the actual text. Some of them can read the",
|
|
44305
|
+
"workspace and some cannot, and the roster says which; but even the ones that can start from",
|
|
44306
|
+
"what you give them, and a question with nothing attached spends their whole lookup budget",
|
|
44307
|
+
'finding what you already had open. A question like "is my retry logic right?" with nothing',
|
|
44308
|
+
"attached comes back as a list of things retry logic usually gets wrong, which you already knew.",
|
|
44000
44309
|
"",
|
|
44001
44310
|
"Ask one full question rather than three thin ones. Each consultation is a fresh reader with no",
|
|
44002
44311
|
"memory of the last, so a follow-up has to carry its own context.",
|
|
@@ -44006,30 +44315,86 @@ var DEFAULT_TEAM_GUIDANCE = [
|
|
|
44006
44315
|
"- Do not consult on something you can settle by reading a file. Read it.",
|
|
44007
44316
|
"- Do not relay advice you have not checked. You have the code open and the specialist does not;",
|
|
44008
44317
|
" if it is wrong, say so and say why \u2014 to the user, and in your next question.",
|
|
44009
|
-
"- Do not consult the same role twice with the same question hoping for a better answer."
|
|
44318
|
+
"- Do not consult the same role twice with the same question hoping for a better answer.",
|
|
44319
|
+
"",
|
|
44320
|
+
"## When a review finds something in code the programmer wrote",
|
|
44321
|
+
"",
|
|
44322
|
+
"**Take it back to the programmer.** It wrote the code, it is the role picked for writing, and",
|
|
44323
|
+
"the fix is its job rather than yours \u2014 you are the one holding the files, not the one whose",
|
|
44324
|
+
"judgement was hired for this. Fixing it silently yourself wastes the specialist and hides the",
|
|
44325
|
+
"exchange from the user.",
|
|
44326
|
+
"",
|
|
44327
|
+
"A consultation remembers nothing, so the question has to carry everything: **the code as it",
|
|
44328
|
+
"stands, the finding in the reviewer's own words, and what you have checked yourself.** A",
|
|
44329
|
+
'programmer told only "the reviewer says this is wrong" will guess at which line and rewrite',
|
|
44330
|
+
"more than it should.",
|
|
44331
|
+
"",
|
|
44332
|
+
"**It may push back, and that is a real answer, not an obstacle.** Reviews are wrong often",
|
|
44333
|
+
"enough to matter \u2014 a finding can be about a path that cannot happen, a convention this",
|
|
44334
|
+
"codebase deliberately does not follow, or a misreading of code the reviewer only saw a fragment",
|
|
44335
|
+
"of. When the programmer disagrees, you settle it: you have the actual file and neither of them",
|
|
44336
|
+
"does. Say which way you went and why, in your reply, so the user sees the disagreement rather",
|
|
44337
|
+
"than only its outcome.",
|
|
44338
|
+
"",
|
|
44339
|
+
"**One lap, not a loop.** Review, fix, and re-review only when the fix was substantial enough",
|
|
44340
|
+
"that the first review no longer describes the code. If the two still disagree after that, stop",
|
|
44341
|
+
"and put it to the expert with both positions, or decide it yourself and say so. Ping-ponging a",
|
|
44342
|
+
"disagreement between two models that cannot see the file is how a turn is spent without",
|
|
44343
|
+
"anything being decided.",
|
|
44344
|
+
"",
|
|
44345
|
+
"## When the plan names a specialist",
|
|
44346
|
+
"",
|
|
44347
|
+
"Consult them **while that step is the active one**, not at the end in a batch. Two reasons, and",
|
|
44348
|
+
"the second is the one people notice: advice arriving after the work is done is a review nobody",
|
|
44349
|
+
"can act on without redoing it, and the progress panel attributes a consultation to whichever",
|
|
44350
|
+
"step was open when it happened \u2014 so a step worked in silence shows as nobody having helped with",
|
|
44351
|
+
"it, whatever you say afterwards.",
|
|
44352
|
+
"",
|
|
44353
|
+
"If a step names somebody and you decide against consulting them, say so and say why. A plan the",
|
|
44354
|
+
"user approved said that step would get another reader."
|
|
44010
44355
|
].join("\n");
|
|
44011
|
-
function buildTeamGuidance(agents, custom2, budgetMatters2) {
|
|
44356
|
+
function buildTeamGuidance(agents, custom2, budgetMatters2, hasPlan) {
|
|
44012
44357
|
const base = custom2 !== void 0 && custom2.trim().length > 0 ? custom2 : DEFAULT_TEAM_GUIDANCE;
|
|
44013
44358
|
const advice = budgetMatters2 === true ? `${base}
|
|
44014
44359
|
${BUDGET_ADVICE}` : base;
|
|
44015
|
-
|
|
44360
|
+
const planning = hasPlan === true ? PLAN_IN_PLACE : PLAN_FIRST;
|
|
44361
|
+
const usable = agents.filter((agent) => agent.available);
|
|
44362
|
+
const unusable = AGENT_ROLES.filter((role) => !usable.some((agent) => agent.role === role)).map((role) => {
|
|
44363
|
+
const assigned = agents.find((agent) => agent.role === role);
|
|
44364
|
+
return assigned === void 0 ? `- **${role}** \u2014 nobody assigned.` : `- **${role}** \u2014 ${assigned.reason ?? "assigned, but cannot be reached."}`;
|
|
44365
|
+
});
|
|
44366
|
+
const missing = unusable.length === 0 ? [] : [
|
|
44367
|
+
"",
|
|
44368
|
+
"**Not available, so do not ask for them and do not plan work for them:**",
|
|
44369
|
+
"",
|
|
44370
|
+
...unusable,
|
|
44371
|
+
"",
|
|
44372
|
+
"If something genuinely needs one of these, say so and say that assigning it in",
|
|
44373
|
+
"Settings \u2192 Agents would let you consult it \u2014 then carry on without it rather than",
|
|
44374
|
+
"leaving that part of the job unaccounted for."
|
|
44375
|
+
];
|
|
44376
|
+
if (usable.length === 0) {
|
|
44016
44377
|
return [
|
|
44017
44378
|
advice,
|
|
44379
|
+
planning,
|
|
44018
44380
|
"",
|
|
44019
44381
|
"## Your team",
|
|
44020
44382
|
"",
|
|
44021
44383
|
"**Nobody is assigned yet.** Until somebody is, do the work yourself and tell the user that",
|
|
44022
|
-
"assigning a specialist in Settings \u2192 Agents would let you consult one."
|
|
44384
|
+
"assigning a specialist in Settings \u2192 Agents would let you consult one.",
|
|
44385
|
+
...missing
|
|
44023
44386
|
].join("\n");
|
|
44024
44387
|
}
|
|
44025
44388
|
return [
|
|
44026
44389
|
advice,
|
|
44390
|
+
planning,
|
|
44027
44391
|
"",
|
|
44028
44392
|
"## Your team",
|
|
44029
44393
|
"",
|
|
44030
|
-
"Reach any of them with `ask_agent`, naming the role:",
|
|
44394
|
+
"Reach any of them with `ask_agent`, naming the role. These are the only ones that exist:",
|
|
44031
44395
|
"",
|
|
44032
|
-
...
|
|
44396
|
+
...usable.map((agent) => `- **${agent.role}** (${agent.label}) \u2014 ${agent.summary}`),
|
|
44397
|
+
...missing
|
|
44033
44398
|
].join("\n");
|
|
44034
44399
|
}
|
|
44035
44400
|
|
|
@@ -44039,20 +44404,131 @@ function firstLine(text, limit = DESCRIPTION_LIMIT) {
|
|
|
44039
44404
|
const line = text.split("\n").find((candidate) => candidate.trim().length > 0)?.trim() ?? "";
|
|
44040
44405
|
return line.length > limit ? `${line.slice(0, limit - 1).trimEnd()}\u2026` : line;
|
|
44041
44406
|
}
|
|
44407
|
+
function buildRoster(team, self) {
|
|
44408
|
+
const others = team.filter((agent) => agent.role !== self);
|
|
44409
|
+
const usable = others.filter((agent) => agent.available);
|
|
44410
|
+
const assigned = new Set(team.map((agent) => agent.role));
|
|
44411
|
+
const missing = [];
|
|
44412
|
+
for (const role of AGENT_ROLES) {
|
|
44413
|
+
if (role === self)
|
|
44414
|
+
continue;
|
|
44415
|
+
if (!assigned.has(role)) {
|
|
44416
|
+
missing.push(`- **${role}** \u2014 nobody is assigned to this role.`);
|
|
44417
|
+
continue;
|
|
44418
|
+
}
|
|
44419
|
+
const agent = others.find((candidate) => candidate.role === role);
|
|
44420
|
+
if (agent !== void 0 && !agent.available) {
|
|
44421
|
+
missing.push(`- **${role}** \u2014 ${agent.reason ?? "assigned, but cannot be reached."}`);
|
|
44422
|
+
}
|
|
44423
|
+
}
|
|
44424
|
+
const sections = ["## The rest of the team", ""];
|
|
44425
|
+
if (self !== void 0)
|
|
44426
|
+
sections.push(`You are the **${self}**.`, "");
|
|
44427
|
+
sections.push(usable.length > 0 ? "The assistant can also consult these specialists, and only these:" : "The assistant has **no other specialists available**. Whatever you propose, it does alone.");
|
|
44428
|
+
if (usable.length > 0) {
|
|
44429
|
+
sections.push(
|
|
44430
|
+
"",
|
|
44431
|
+
/*
|
|
44432
|
+
* What the others can actually do — and this was wrong once, in the expensive direction.
|
|
44433
|
+
*
|
|
44434
|
+
* It first said "None of them can see the workspace", written to stop the expert giving the
|
|
44435
|
+
* librarian a lookup job. That was false: `agents/consult.ts` gives a specialist the read
|
|
44436
|
+
* tool group, and the CLI expert holds Claude's own Read/Grep/Glob. The instruction was
|
|
44437
|
+
* therefore telling the expert *not* to allocate the librarian the one kind of work the
|
|
44438
|
+
* librarian is equipped for, which made the weakest role weaker.
|
|
44439
|
+
*
|
|
44440
|
+
* The real distinction is per role and the user controls it, so it is rendered from the
|
|
44441
|
+
* team rather than asserted about all of them — and it sits *above* the list, because it is
|
|
44442
|
+
* how to read the marks in it.
|
|
44443
|
+
*/
|
|
44444
|
+
"**None of them can edit anything or run anything.** They read and advise; the assistant",
|
|
44445
|
+
"makes every change, and it is the one answerable for the result. Some can look things up",
|
|
44446
|
+
"for themselves, marked below; the rest know only what is in the question, so give those",
|
|
44447
|
+
"everything they need.",
|
|
44448
|
+
"",
|
|
44449
|
+
...usable.map((agent) => `- **${agent.role}** (${agent.label}) \u2014 ${agent.summary}` + // Marked per role because it decides what is worth asking them: one that can read
|
|
44450
|
+
// needs pointing at a file, one that cannot needs the file pasted in.
|
|
44451
|
+
(agent.usesTools ? " *(can read and search the workspace)*" : "")),
|
|
44452
|
+
"",
|
|
44453
|
+
/*
|
|
44454
|
+
* Knowing who exists is not the same as being asked to use them.
|
|
44455
|
+
*
|
|
44456
|
+
* Reported with a plan that allocated nobody, on a machine where all four other roles were
|
|
44457
|
+
* assigned. The briefing told the expert who was available and told it not to name anyone
|
|
44458
|
+
* who was not — and it dutifully named nobody at all, writing a plan for the assistant
|
|
44459
|
+
* working alone, down to "I'll show you the code before moving on" where a reviewer was
|
|
44460
|
+
* sitting right there. An instruction that only says what *not* to do gets obeyed by doing
|
|
44461
|
+
* nothing.
|
|
44462
|
+
*
|
|
44463
|
+
* Deliberately not "use every specialist": that is four extra round trips on a task that
|
|
44464
|
+
* may not want any, and a plan routing every step through the whole team is worse than one
|
|
44465
|
+
* routing none — it reads as ceremony and people stop reading it.
|
|
44466
|
+
*/
|
|
44467
|
+
"**If you are asked for a plan, say who should be involved in which step.** Name the role in",
|
|
44468
|
+
'the step itself \u2014 "have the tester say what would break this", "get the reviewer onto the',
|
|
44469
|
+
'callback wiring", "hand the parser to the programmer" \u2014 so the assistant knows when to',
|
|
44470
|
+
"consult and the user can see who is doing what.",
|
|
44471
|
+
"",
|
|
44472
|
+
/*
|
|
44473
|
+
* Two kinds of specialist, said separately, because the first version only described one.
|
|
44474
|
+
*
|
|
44475
|
+
* It asked for allocation "where another reader would genuinely change the outcome" and
|
|
44476
|
+
* called it "another pair of eyes" — review framing throughout, with a reviewer and a
|
|
44477
|
+
* tester as the examples. The programmer does not read, it produces, so a plan written to
|
|
44478
|
+
* that instruction correctly never mentions it. Reported exactly that way: reviewer and
|
|
44479
|
+
* tester allocated across four steps, programmer nowhere, on a machine where it was
|
|
44480
|
+
* assigned. An instruction that names one mode of use gets obeyed in one mode.
|
|
44481
|
+
*/
|
|
44482
|
+
"They divide into two kinds, and both are worth allocating:",
|
|
44483
|
+
"",
|
|
44484
|
+
"- **Readers** \u2014 the reviewer, the tester, the librarian. Worth a step where another pair of",
|
|
44485
|
+
" eyes changes what happens: risky or fiddly code, a step that finishes something, a",
|
|
44486
|
+
" convention you would otherwise be guessing at.",
|
|
44487
|
+
"- **The programmer writes.** Where a step is a self-contained piece of code with a spec",
|
|
44488
|
+
" clear enough to hand over \u2014 a parser, a schema, a set of pure functions \u2014 say so and give",
|
|
44489
|
+
" it to the programmer. The assistant checks what comes back against the real file and",
|
|
44490
|
+
" applies it, so this is delegation rather than trust.",
|
|
44491
|
+
"",
|
|
44492
|
+
"Only where it genuinely changes the outcome: a plan that routes every step through all of",
|
|
44493
|
+
"them is ceremony, and one that routes none wastes a team that is sitting there."
|
|
44494
|
+
);
|
|
44495
|
+
}
|
|
44496
|
+
if (missing.length > 0) {
|
|
44497
|
+
sections.push(
|
|
44498
|
+
"",
|
|
44499
|
+
// "Not set up" would be wrong for a role that *is* assigned and whose profile has since
|
|
44500
|
+
// gone: the user did set it up, and telling them otherwise sends them to fix the wrong
|
|
44501
|
+
// thing. "Not available" is true of both, and the reason beside each says which it is.
|
|
44502
|
+
"**Not available, so the assistant cannot use them:**",
|
|
44503
|
+
"",
|
|
44504
|
+
...missing,
|
|
44505
|
+
"",
|
|
44506
|
+
"Do not give any of these work. Do not put them in a plan, a checklist or a next step \u2014 a",
|
|
44507
|
+
"plan naming a specialist who does not exist is a plan with a hole in it, and the user will",
|
|
44508
|
+
"have approved it without knowing. If a task genuinely needs one, say so in a sentence and",
|
|
44509
|
+
"say the user would have to assign it in Settings \u2192 Agents; then give the best advice you",
|
|
44510
|
+
"can for doing it without that role."
|
|
44511
|
+
);
|
|
44512
|
+
}
|
|
44513
|
+
return sections;
|
|
44514
|
+
}
|
|
44042
44515
|
function buildAgentBriefing(input) {
|
|
44043
44516
|
const tools = (input.tools ?? []).filter(
|
|
44044
44517
|
// Telling a specialist it can consult a specialist is noise at best and a loop at worst.
|
|
44045
44518
|
(tool) => tool.name !== "ask_agent" && tool.name !== "ask_expert"
|
|
44046
44519
|
);
|
|
44047
44520
|
const skills = input.skills ?? [];
|
|
44048
|
-
|
|
44521
|
+
const team = input.team;
|
|
44522
|
+
if (tools.length === 0 && skills.length === 0 && team === void 0)
|
|
44049
44523
|
return "";
|
|
44050
|
-
const sections = [
|
|
44051
|
-
|
|
44052
|
-
|
|
44053
|
-
|
|
44054
|
-
|
|
44055
|
-
|
|
44524
|
+
const sections = [];
|
|
44525
|
+
if (team !== void 0)
|
|
44526
|
+
sections.push(...buildRoster(team, input.self));
|
|
44527
|
+
if (tools.length > 0 || skills.length > 0) {
|
|
44528
|
+
if (sections.length > 0)
|
|
44529
|
+
sections.push("");
|
|
44530
|
+
sections.push("## What the assistant can do on your behalf", "", "You have no tools. The assistant asking you does, and will carry out whatever you recommend.", "Name the tool or skill you mean rather than describing a manual procedure that duplicates it.");
|
|
44531
|
+
}
|
|
44056
44532
|
if (tools.length > 0) {
|
|
44057
44533
|
sections.push("", "### Tools it can call", "", ...tools.map((tool) => `- \`${tool.name}\` \u2014 ${firstLine(tool.description)}`));
|
|
44058
44534
|
}
|
|
@@ -48097,18 +48573,23 @@ var NEVER_AVAILABLE_TO_SCHEDULES = [
|
|
|
48097
48573
|
// section 13 requires approval showing the source, which cannot happen with nobody there.
|
|
48098
48574
|
"excel_write_macro",
|
|
48099
48575
|
// And running one: unattended execution of arbitrary VBA, with nobody to read the source.
|
|
48100
|
-
"excel_run_macro"
|
|
48576
|
+
"excel_run_macro",
|
|
48577
|
+
/*
|
|
48578
|
+
* Rewriting the plan it is being held to, with nobody there to approve the diff. Same ladder
|
|
48579
|
+
* as `schedule_prompt`: a run that can change its own instructions is bounded by nothing.
|
|
48580
|
+
*/
|
|
48581
|
+
"update_plan"
|
|
48101
48582
|
];
|
|
48102
48583
|
function scheduleAppliesHere(schedule, workspaceRoot) {
|
|
48103
48584
|
if (schedule.workspaceRoot === void 0)
|
|
48104
48585
|
return true;
|
|
48105
48586
|
if (workspaceRoot === void 0)
|
|
48106
48587
|
return false;
|
|
48107
|
-
const
|
|
48588
|
+
const normalise2 = (value) => {
|
|
48108
48589
|
const resolved = nodePath.resolve(value);
|
|
48109
48590
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
48110
48591
|
};
|
|
48111
|
-
return
|
|
48592
|
+
return normalise2(schedule.workspaceRoot) === normalise2(workspaceRoot);
|
|
48112
48593
|
}
|
|
48113
48594
|
function filterToolsForSchedule(all, schedule) {
|
|
48114
48595
|
const named = new Set(schedule.allowedTools);
|
|
@@ -49312,7 +49793,14 @@ var ALWAYS_ASK_TOOLS = /* @__PURE__ */ new Set([
|
|
|
49312
49793
|
* approval showing the actual source is the only thing standing between "run DoTheThing" and
|
|
49313
49794
|
* whatever DoTheThing does.
|
|
49314
49795
|
*/
|
|
49315
|
-
"excel_run_macro"
|
|
49796
|
+
"excel_run_macro",
|
|
49797
|
+
/*
|
|
49798
|
+
* The plan is what holds the assistant to work the user agreed, so a category toggle must
|
|
49799
|
+
* never stand in for reading the change. Auto-approving this would mean an agent could widen
|
|
49800
|
+
* its own instructions and then point at them as authority — and both the panel and the
|
|
49801
|
+
* prompt would look right afterwards, because both would be reading the new plan.
|
|
49802
|
+
*/
|
|
49803
|
+
"update_plan"
|
|
49316
49804
|
]);
|
|
49317
49805
|
function decideFromPolicy(request, approvals) {
|
|
49318
49806
|
if (!requiresApproval(request.group))
|
|
@@ -49427,6 +49915,65 @@ var ShadowGit = class {
|
|
|
49427
49915
|
}
|
|
49428
49916
|
};
|
|
49429
49917
|
|
|
49918
|
+
// ../../packages/core/dist/tools/planTools.js
|
|
49919
|
+
var updateParams = external_exports.object({
|
|
49920
|
+
plan: external_exports.string().describe("The complete new plan, as numbered steps. This replaces the whole plan rather than being added to it, so include the steps that are staying."),
|
|
49921
|
+
reason: external_exports.string().optional().describe("One line on why the plan should change, shown to the user with the diff.")
|
|
49922
|
+
});
|
|
49923
|
+
function createUpdatePlanTool(access) {
|
|
49924
|
+
return {
|
|
49925
|
+
name: "update_plan",
|
|
49926
|
+
group: "edit",
|
|
49927
|
+
description: "Propose a new plan for this conversation, replacing the current one. The user is shown a diff and must approve it before anything changes. Use this after working out a plan \u2014 for example one a specialist drafted \u2014 rather than carrying it only in the conversation, which is forgotten as the chat grows. Give the whole plan as numbered steps; each step becomes a checkpoint the user can watch you complete.",
|
|
49928
|
+
parametersSchema: updateParams,
|
|
49929
|
+
async preview(params) {
|
|
49930
|
+
const before = access.current() ?? "";
|
|
49931
|
+
return {
|
|
49932
|
+
kind: "diff",
|
|
49933
|
+
// Not a file. The approval UI labels the diff with this, and naming it for what it is
|
|
49934
|
+
// beats a made-up path that implies something on disk is about to change.
|
|
49935
|
+
path: "the plan for this conversation",
|
|
49936
|
+
before,
|
|
49937
|
+
after: params.plan.slice(0, PLAN_LIMIT).trim(),
|
|
49938
|
+
...params.reason !== void 0 && params.reason.trim().length > 0 ? { note: params.reason.trim() } : {}
|
|
49939
|
+
};
|
|
49940
|
+
},
|
|
49941
|
+
async execute(params) {
|
|
49942
|
+
const next = params.plan.slice(0, PLAN_LIMIT).trim();
|
|
49943
|
+
if (next.length === 0) {
|
|
49944
|
+
return { content: "A plan cannot be empty. To remove the plan, ask the user to clear it." };
|
|
49945
|
+
}
|
|
49946
|
+
await access.save(next);
|
|
49947
|
+
return {
|
|
49948
|
+
content: "The plan is updated and the user approved it. It is now in front of you for the rest of this conversation, and its steps are the checkpoints to report against."
|
|
49949
|
+
};
|
|
49950
|
+
}
|
|
49951
|
+
};
|
|
49952
|
+
}
|
|
49953
|
+
var progressParams = external_exports.object({
|
|
49954
|
+
checkpoint: external_exports.number().int().describe("The step number, as numbered in the plan you were given."),
|
|
49955
|
+
status: external_exports.enum(["active", "done"]).describe("`active` when you start the step, `done` when it is genuinely finished.")
|
|
49956
|
+
});
|
|
49957
|
+
function createPlanProgressTool(access) {
|
|
49958
|
+
return {
|
|
49959
|
+
name: "plan_progress",
|
|
49960
|
+
/*
|
|
49961
|
+
* Control flow, not an action: it records where you are and touches nothing else. Gating it
|
|
49962
|
+
* would mean an approval prompt between every step of every planned task, which nobody would
|
|
49963
|
+
* keep switched on for long.
|
|
49964
|
+
*/
|
|
49965
|
+
group: "always",
|
|
49966
|
+
description: "Say which step of the plan you are on. Call it with `active` when you start a step and `done` when it is finished, so the user can watch progress without reading the whole transcript. Mark `done` only when the step is actually complete \u2014 a step you gave up on or half did should be reported in your reply instead.",
|
|
49967
|
+
parametersSchema: progressParams,
|
|
49968
|
+
async execute(params) {
|
|
49969
|
+
const outcome = await access.mark(params.checkpoint, params.status);
|
|
49970
|
+
if (!outcome.ok)
|
|
49971
|
+
return { content: outcome.reason, isError: true };
|
|
49972
|
+
return { content: outcome.summary };
|
|
49973
|
+
}
|
|
49974
|
+
};
|
|
49975
|
+
}
|
|
49976
|
+
|
|
49430
49977
|
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
49431
49978
|
function isZ4Schema(s) {
|
|
49432
49979
|
const schema2 = s;
|
|
@@ -56676,6 +57223,8 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS)
|
|
|
56676
57223
|
|
|
56677
57224
|
// ../../packages/core/dist/agent/loop.js
|
|
56678
57225
|
var DEFAULT_MAX_ITERATIONS = 25;
|
|
57226
|
+
var BOOKKEEPING_TOOLS = /* @__PURE__ */ new Set(["plan_progress"]);
|
|
57227
|
+
var MAX_REFUNDED_STEPS = 20;
|
|
56679
57228
|
var MAX_CONSECUTIVE_MISTAKES = 3;
|
|
56680
57229
|
async function prepareModelMessages(conversation, provider, tools, options, events) {
|
|
56681
57230
|
const contextWindow = options.contextWindow ?? 0;
|
|
@@ -56857,6 +57406,7 @@ async function runWithTimeout(tool, params, context, options) {
|
|
|
56857
57406
|
async function runAgentTurn(provider, conversation, userMessage, toolRegistry, toolContext, events, options = {}) {
|
|
56858
57407
|
conversation.addUserMessage(userMessage, options.images);
|
|
56859
57408
|
const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
57409
|
+
let refunded = 0;
|
|
56860
57410
|
const mistakeCounts = /* @__PURE__ */ new Map();
|
|
56861
57411
|
let continueNudges = 0;
|
|
56862
57412
|
const mode = options.mode ?? CODE_MODE;
|
|
@@ -56926,6 +57476,10 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
56926
57476
|
events.onDone();
|
|
56927
57477
|
return;
|
|
56928
57478
|
}
|
|
57479
|
+
if (BOOKKEEPING_TOOLS.has(toolCall.name) && refunded < MAX_REFUNDED_STEPS) {
|
|
57480
|
+
refunded += 1;
|
|
57481
|
+
iteration -= 1;
|
|
57482
|
+
}
|
|
56929
57483
|
if (result.path !== void 0) {
|
|
56930
57484
|
if (result.isError === true) {
|
|
56931
57485
|
const count = (mistakeCounts.get(result.path) ?? 0) + 1;
|
|
@@ -60173,7 +60727,46 @@ ${preview.text}` } : {}
|
|
|
60173
60727
|
const ACTIVE_TASK_KEY = "lightCode.activeTaskId";
|
|
60174
60728
|
let activeTaskId = services.workspaceState.get(ACTIVE_TASK_KEY);
|
|
60175
60729
|
let activePlan;
|
|
60730
|
+
let activePlanProgress = {};
|
|
60176
60731
|
let activeTaskCreatedAt = Date.now();
|
|
60732
|
+
function planViews() {
|
|
60733
|
+
return checkpointViews(activePlan, activePlanProgress);
|
|
60734
|
+
}
|
|
60735
|
+
function postPlanProgress() {
|
|
60736
|
+
post({ type: "planProgress", checkpoints: planViews() });
|
|
60737
|
+
}
|
|
60738
|
+
async function applyPlan(next) {
|
|
60739
|
+
const trimmed = next?.slice(0, PLAN_LIMIT).trim();
|
|
60740
|
+
activePlan = trimmed !== void 0 && trimmed.length > 0 ? trimmed : void 0;
|
|
60741
|
+
activePlanProgress = pruneProgress(activePlan, activePlanProgress);
|
|
60742
|
+
await persistActiveTask();
|
|
60743
|
+
post({ type: "plan", plan: activePlan ?? "" });
|
|
60744
|
+
postPlanProgress();
|
|
60745
|
+
}
|
|
60746
|
+
const planAccess = {
|
|
60747
|
+
current: () => activePlan,
|
|
60748
|
+
save: async (nextPlan) => {
|
|
60749
|
+
await applyPlan(nextPlan);
|
|
60750
|
+
},
|
|
60751
|
+
mark: async (index, status) => {
|
|
60752
|
+
const updated = markCheckpoint(activePlan, activePlanProgress, index, status);
|
|
60753
|
+
if (updated === void 0) {
|
|
60754
|
+
const total = planViews().length;
|
|
60755
|
+
return {
|
|
60756
|
+
ok: false,
|
|
60757
|
+
reason: total === 0 ? "There is no plan set for this conversation, so there is nothing to report against." : `There is no step ${String(index)}. The plan has ${String(total)} steps, numbered 1 to ${String(total)}.`
|
|
60758
|
+
};
|
|
60759
|
+
}
|
|
60760
|
+
activePlanProgress = updated;
|
|
60761
|
+
await persistActiveTask();
|
|
60762
|
+
postPlanProgress();
|
|
60763
|
+
const views = planViews();
|
|
60764
|
+
return {
|
|
60765
|
+
ok: true,
|
|
60766
|
+
summary: `Step ${String(index)} is now ${status}. ${progressSummary(views)} steps complete.`
|
|
60767
|
+
};
|
|
60768
|
+
}
|
|
60769
|
+
};
|
|
60177
60770
|
async function setActiveTaskId(id) {
|
|
60178
60771
|
activeTaskId = id;
|
|
60179
60772
|
await services.workspaceState.set(ACTIVE_TASK_KEY, id);
|
|
@@ -60618,6 +61211,8 @@ ${preview.text}` } : {}
|
|
|
60618
61211
|
}
|
|
60619
61212
|
for (const tool of python.generatedTools())
|
|
60620
61213
|
combined.register(tool, { dispatchOnly: dispatcher });
|
|
61214
|
+
combined.register(createUpdatePlanTool(planAccess), { dispatchOnly: dispatcher });
|
|
61215
|
+
combined.register(createPlanProgressTool(planAccess), { dispatchOnly: dispatcher });
|
|
60621
61216
|
combined.register(createNotifyTool({
|
|
60622
61217
|
notify: (message3, level, details) => {
|
|
60623
61218
|
if (details !== void 0) {
|
|
@@ -60892,7 +61487,8 @@ ${preview.text}` } : {}
|
|
|
60892
61487
|
updatedAt: Date.now(),
|
|
60893
61488
|
messages,
|
|
60894
61489
|
resultHandles: truncationStore.spilledHandles(),
|
|
60895
|
-
...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {}
|
|
61490
|
+
...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {},
|
|
61491
|
+
...Object.keys(activePlanProgress).length > 0 ? { planProgress: activePlanProgress } : {}
|
|
60896
61492
|
};
|
|
60897
61493
|
try {
|
|
60898
61494
|
await taskStore.save(redactTask(task, await knownSecretValues()));
|
|
@@ -60921,9 +61517,11 @@ ${preview.text}` } : {}
|
|
|
60921
61517
|
activeTaskCreatedAt = task.createdAt;
|
|
60922
61518
|
truncationStore.startTask(task.resultHandles);
|
|
60923
61519
|
activePlan = task.plan;
|
|
61520
|
+
activePlanProgress = pruneProgress(activePlan, task.planProgress);
|
|
60924
61521
|
await setActiveTaskId(task.id);
|
|
60925
61522
|
post({ type: "taskRestored", taskId: task.id, entries: toTranscript(task.messages) });
|
|
60926
61523
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
61524
|
+
postPlanProgress();
|
|
60927
61525
|
await postTasks();
|
|
60928
61526
|
}
|
|
60929
61527
|
async function startNewTask() {
|
|
@@ -60934,9 +61532,11 @@ ${preview.text}` } : {}
|
|
|
60934
61532
|
activeTaskCreatedAt = Date.now();
|
|
60935
61533
|
truncationStore.startTask();
|
|
60936
61534
|
activePlan = void 0;
|
|
61535
|
+
activePlanProgress = {};
|
|
60937
61536
|
await setActiveTaskId(void 0);
|
|
60938
61537
|
post({ type: "taskRestored", taskId: void 0, entries: [] });
|
|
60939
61538
|
post({ type: "plan", plan: "" });
|
|
61539
|
+
postPlanProgress();
|
|
60940
61540
|
await postTasks();
|
|
60941
61541
|
}
|
|
60942
61542
|
async function deleteTask(id) {
|
|
@@ -61041,7 +61641,20 @@ ${preview.text}` } : {}
|
|
|
61041
61641
|
...(() => {
|
|
61042
61642
|
const parts = [];
|
|
61043
61643
|
if (activeMode.id === AGENT_TEAM_MODE.id) {
|
|
61044
|
-
parts.push(buildTeamGuidance(
|
|
61644
|
+
parts.push(buildTeamGuidance(
|
|
61645
|
+
// The whole team, not only the available ones: the roster names what is missing
|
|
61646
|
+
// as well as what is there, and it cannot do that from a pre-filtered list.
|
|
61647
|
+
cachedTeam,
|
|
61648
|
+
cachedTeamGuidance,
|
|
61649
|
+
cachedBudgetMatters,
|
|
61650
|
+
/*
|
|
61651
|
+
* Whether a plan already exists, which decides whether this mode is told to go
|
|
61652
|
+
* and make one. Passed rather than inferred from the prompt: the plan section is
|
|
61653
|
+
* assembled separately, and a mode guessing at whether it is there would be a
|
|
61654
|
+
* second reading of the same fact.
|
|
61655
|
+
*/
|
|
61656
|
+
activePlan !== void 0 && activePlan.trim().length > 0
|
|
61657
|
+
));
|
|
61045
61658
|
} else if (activeMode.guidance !== void 0 && (activeMode.requiresExpert !== true || expertCliInfo !== void 0)) {
|
|
61046
61659
|
parts.push(activeMode.guidance);
|
|
61047
61660
|
}
|
|
@@ -61215,8 +61828,14 @@ ${preview.text}` } : {}
|
|
|
61215
61828
|
cumulativeText = "";
|
|
61216
61829
|
cumulativeReasoning = "";
|
|
61217
61830
|
const consulting = consultationFromToolCall(toolCall.name, toolCall.arguments);
|
|
61218
|
-
if (consulting !== void 0)
|
|
61831
|
+
if (consulting !== void 0) {
|
|
61219
61832
|
informedBy = consulting;
|
|
61833
|
+
const attributed = attributeConsultation(activePlanProgress, consulting);
|
|
61834
|
+
if (attributed !== activePlanProgress) {
|
|
61835
|
+
activePlanProgress = attributed;
|
|
61836
|
+
postPlanProgress();
|
|
61837
|
+
}
|
|
61838
|
+
}
|
|
61220
61839
|
if (CONTROL_TOOLS.has(toolCall.name))
|
|
61221
61840
|
return;
|
|
61222
61841
|
if (chartFromToolCall(toolCall.name, toolCall.arguments) !== void 0)
|
|
@@ -63645,6 +64264,10 @@ ${preview.text}` } : {}
|
|
|
63645
64264
|
const prompt = buildAgentPrompt({
|
|
63646
64265
|
prompt: agent.prompt,
|
|
63647
64266
|
question: request.question,
|
|
64267
|
+
// Decides the preamble as well as whether tools are offered below, so the two can never
|
|
64268
|
+
// disagree — a specialist told it can read, and then given nothing to read with, wastes a
|
|
64269
|
+
// step discovering that.
|
|
64270
|
+
usesTools: agent.usesTools,
|
|
63648
64271
|
...request.files !== void 0 ? { files: request.files } : {},
|
|
63649
64272
|
/*
|
|
63650
64273
|
* What exists in this workspace.
|
|
@@ -63655,7 +64278,18 @@ ${preview.text}` } : {}
|
|
|
63655
64278
|
*/
|
|
63656
64279
|
briefing: buildAgentBriefing({
|
|
63657
64280
|
tools: agentBriefingTools?.() ?? [],
|
|
63658
|
-
skills
|
|
64281
|
+
skills,
|
|
64282
|
+
/*
|
|
64283
|
+
* Who else exists, so a plan cannot name a specialist nobody set up.
|
|
64284
|
+
*
|
|
64285
|
+
* Built here, above the `kind` branch, which is the point: the Claude CLI expert and a
|
|
64286
|
+
* provider-profile expert are given byte-identical briefings, so making a different model
|
|
64287
|
+
* the expert cannot change what it knows about the team. `briefing.test.ts` pins that,
|
|
64288
|
+
* because the two paths diverging is invisible until somebody switches expert and gets a
|
|
64289
|
+
* worse plan for no reason they could name.
|
|
64290
|
+
*/
|
|
64291
|
+
team: cachedTeam,
|
|
64292
|
+
self: agent.role
|
|
63659
64293
|
})
|
|
63660
64294
|
});
|
|
63661
64295
|
if (agent.kind === "cli") {
|
|
@@ -63682,7 +64316,7 @@ ${preview.text}` } : {}
|
|
|
63682
64316
|
throw new Error(`No profile "${agent.profileId ?? ""}" exists any more.`);
|
|
63683
64317
|
}
|
|
63684
64318
|
const provider = createChatProvider(profile, httpClient, authStrategyFor(config2, profile), logger);
|
|
63685
|
-
const readOnly = toolsForConsultation(agentBriefingTools?.() ?? []);
|
|
64319
|
+
const readOnly = agent.usesTools ? toolsForConsultation(agentBriefingTools?.() ?? []) : [];
|
|
63686
64320
|
const context = consultationContext?.();
|
|
63687
64321
|
const result = await runConsultation({
|
|
63688
64322
|
provider,
|
|
@@ -64444,12 +65078,12 @@ ${preview.text}` } : {}
|
|
|
64444
65078
|
} else if (message3.type === "requestExpert") {
|
|
64445
65079
|
void postExpert();
|
|
64446
65080
|
} else if (message3.type === "setPlan") {
|
|
64447
|
-
|
|
64448
|
-
activePlan = plan.length > 0 ? plan : void 0;
|
|
64449
|
-
void persistActiveTask();
|
|
64450
|
-
post({ type: "plan", plan: activePlan ?? "" });
|
|
65081
|
+
void applyPlan(message3.plan);
|
|
64451
65082
|
} else if (message3.type === "requestPlan") {
|
|
64452
65083
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
65084
|
+
postPlanProgress();
|
|
65085
|
+
} else if (message3.type === "requestPlanProgress") {
|
|
65086
|
+
postPlanProgress();
|
|
64453
65087
|
} else if (message3.type === "requestAgents") {
|
|
64454
65088
|
void postAgents();
|
|
64455
65089
|
} else if (message3.type === "setAgentRole") {
|