@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/cli.js
CHANGED
|
@@ -39771,8 +39771,27 @@ var agentAssignmentSchema = external_exports.object({
|
|
|
39771
39771
|
*/
|
|
39772
39772
|
prompt: external_exports.string().optional()
|
|
39773
39773
|
}).strict();
|
|
39774
|
+
var customRoleSchema = external_exports.object({
|
|
39775
|
+
id: external_exports.string().min(1),
|
|
39776
|
+
name: external_exports.string().min(1),
|
|
39777
|
+
summary: external_exports.string(),
|
|
39778
|
+
prompt: external_exports.string()
|
|
39779
|
+
});
|
|
39774
39780
|
var agentsConfigSchema = external_exports.object({
|
|
39775
39781
|
roles: external_exports.record(external_exports.string(), agentAssignmentSchema),
|
|
39782
|
+
/**
|
|
39783
|
+
* Roles the user invented, beyond the five built in.
|
|
39784
|
+
*
|
|
39785
|
+
* A role *is* its prompt, and the ones people ask for next are nearly always a reviewer with
|
|
39786
|
+
* a different one — security, performance, accessibility. Defining them here answers that
|
|
39787
|
+
* whole family without a code change each time, and without growing the fixed roster the
|
|
39788
|
+
* expert has to allocate from.
|
|
39789
|
+
*
|
|
39790
|
+
* Covered by the same user-scope rule as the rest of this block, and it is the sharpest part
|
|
39791
|
+
* of it: this is prose injected into a model that is then asked to advise on this
|
|
39792
|
+
* repository, so a workspace able to write it could define a reviewer that approves anything.
|
|
39793
|
+
*/
|
|
39794
|
+
definitions: external_exports.array(customRoleSchema),
|
|
39776
39795
|
/** Whether what a consultation costs is worth managing. See `agents/team.ts`. */
|
|
39777
39796
|
budgetMatters: external_exports.boolean(),
|
|
39778
39797
|
/** The Agent team mode instruction, when edited. The roster is always generated. */
|
|
@@ -43327,18 +43346,353 @@ var Conversation = class {
|
|
|
43327
43346
|
}
|
|
43328
43347
|
};
|
|
43329
43348
|
|
|
43349
|
+
// ../../packages/core/dist/agents/roles.js
|
|
43350
|
+
var AGENT_ROLES = ["expert", "programmer", "reviewer", "tester", "librarian"];
|
|
43351
|
+
function isAgentRole(value, custom2 = []) {
|
|
43352
|
+
return AGENT_ROLES.includes(value) || custom2.some((role) => role.id === value);
|
|
43353
|
+
}
|
|
43354
|
+
function knownRoles(custom2 = []) {
|
|
43355
|
+
return [...AGENT_ROLES, ...custom2.map((role) => role.id)];
|
|
43356
|
+
}
|
|
43357
|
+
var SHARED_TAIL = [
|
|
43358
|
+
"Your reply is advice. The assistant will check it against the real code before acting, and it",
|
|
43359
|
+
"is responsible for the result. Be concrete, say what you are unsure about, and say plainly when",
|
|
43360
|
+
"something must be verified rather than assumed.",
|
|
43361
|
+
"",
|
|
43362
|
+
"Answer in prose and short lists. No preamble about being happy to help."
|
|
43363
|
+
];
|
|
43364
|
+
var SHARED_WITH_TOOLS = [
|
|
43365
|
+
"You can read this workspace: open files, list them, and search. Use that rather than guessing,",
|
|
43366
|
+
"and rather than asking the assistant for something you can fetch yourself. You have a small",
|
|
43367
|
+
"budget of lookups, so go for what actually settles the question.",
|
|
43368
|
+
"",
|
|
43369
|
+
"You cannot edit anything, run anything, or reach the network. If something needs changing, say",
|
|
43370
|
+
"what and why \u2014 the assistant makes the change and is responsible for it.",
|
|
43371
|
+
"",
|
|
43372
|
+
...SHARED_TAIL
|
|
43373
|
+
].join("\n");
|
|
43374
|
+
var SHARED_BLIND = [
|
|
43375
|
+
"You have no tools and cannot see the workspace. Everything you have is in the question. If",
|
|
43376
|
+
"something essential is missing, say exactly what you need and why, then give the best answer you",
|
|
43377
|
+
"can without it \u2014 never refuse to answer.",
|
|
43378
|
+
"",
|
|
43379
|
+
...SHARED_TAIL
|
|
43380
|
+
].join("\n");
|
|
43381
|
+
function specialistPreamble(usesTools) {
|
|
43382
|
+
return usesTools ? SHARED_WITH_TOOLS : SHARED_BLIND;
|
|
43383
|
+
}
|
|
43384
|
+
var DEFINITIONS = {
|
|
43385
|
+
expert: {
|
|
43386
|
+
name: "Expert",
|
|
43387
|
+
summary: "Hard problems, architecture, and deciding what to do",
|
|
43388
|
+
/* Planning a change means knowing what is already there, and it spans files the asker
|
|
43389
|
+
* cannot paste all of. */
|
|
43390
|
+
usesTools: true,
|
|
43391
|
+
prompt: [
|
|
43392
|
+
"You are a senior engineer being consulted by another AI assistant that is doing the work.",
|
|
43393
|
+
"",
|
|
43394
|
+
"It has hit something hard: a change across several files to plan, a bug it has already",
|
|
43395
|
+
"failed to fix, or a design choice with no obvious answer. Give it your judgement.",
|
|
43396
|
+
"",
|
|
43397
|
+
"Decide *what* should happen and why. Leave the typing to the assistant \u2014 it is the one",
|
|
43398
|
+
"making the change and answering for it. Where there is a real trade-off, name both sides",
|
|
43399
|
+
"and then choose."
|
|
43400
|
+
].join("\n")
|
|
43401
|
+
},
|
|
43402
|
+
programmer: {
|
|
43403
|
+
name: "Programmer",
|
|
43404
|
+
summary: "Writes the code once the plan is settled",
|
|
43405
|
+
/* It is handed a spec and the surrounding code and asked to write. Looking around buys
|
|
43406
|
+
* a slower answer that is no better. */
|
|
43407
|
+
usesTools: false,
|
|
43408
|
+
prompt: [
|
|
43409
|
+
"You are an experienced programmer writing code for another AI assistant to apply.",
|
|
43410
|
+
"",
|
|
43411
|
+
"You are given a requirement and the surrounding code. Produce the change, matching the",
|
|
43412
|
+
"conventions of what you were shown rather than your own preferences \u2014 the naming, the error",
|
|
43413
|
+
"handling, the comment density, the way the existing code does this sort of thing.",
|
|
43414
|
+
"",
|
|
43415
|
+
"Return the code and a short note on anything non-obvious in it. Do not narrate what you are",
|
|
43416
|
+
"about to do, and do not rewrite things you were not asked to change.",
|
|
43417
|
+
"",
|
|
43418
|
+
/*
|
|
43419
|
+
* The programmer is the role that gets its own work handed back, so it is the one that has
|
|
43420
|
+
* to be told what to do with a review — including that it may disagree. Requested in those
|
|
43421
|
+
* terms: it is classified as the programmer, so fixing it is its job, and it should be able
|
|
43422
|
+
* to challenge a reviewer rather than obey one.
|
|
43423
|
+
*/
|
|
43424
|
+
"You may be given a review of code you wrote. Fix what is genuinely wrong and return the",
|
|
43425
|
+
"corrected code the same way. **Where the review is wrong, say so and say why** \u2014 a finding",
|
|
43426
|
+
"can be about a path that cannot happen, a convention this codebase does not follow, or a",
|
|
43427
|
+
"misreading of a fragment. Do not rewrite working code to satisfy an objection you think is",
|
|
43428
|
+
"mistaken; the assistant has the real file and will settle it. Changing something you believe",
|
|
43429
|
+
"is right, because you were told to, is the worse failure: it looks like agreement."
|
|
43430
|
+
].join("\n")
|
|
43431
|
+
},
|
|
43432
|
+
reviewer: {
|
|
43433
|
+
name: "Reviewer",
|
|
43434
|
+
summary: "Reads a change and says what is wrong with it",
|
|
43435
|
+
/* Most of what a review turns on is *around* the diff — the callers, the neighbouring
|
|
43436
|
+
* function, whether this convention is really the convention. */
|
|
43437
|
+
usesTools: true,
|
|
43438
|
+
prompt: [
|
|
43439
|
+
"You are reviewing a change written by another AI assistant.",
|
|
43440
|
+
"",
|
|
43441
|
+
"Your job is to find what is wrong with it. Say so plainly when something is fine, but do",
|
|
43442
|
+
"not pad the review with praise \u2014 an approving review that missed a bug is worse than no",
|
|
43443
|
+
"review, because it was believed.",
|
|
43444
|
+
"",
|
|
43445
|
+
"Look for, in this order: does it do what was asked; does it break something that used to",
|
|
43446
|
+
"work; what happens at the edges \u2014 empty, missing, concurrent, already-exists, fails halfway;",
|
|
43447
|
+
"and does it match the conventions of the code around it.",
|
|
43448
|
+
"",
|
|
43449
|
+
"For each finding say what breaks and under what input. A concern you cannot make concrete is",
|
|
43450
|
+
"worth one sentence, flagged as a hunch, not a paragraph.",
|
|
43451
|
+
"",
|
|
43452
|
+
// Findings go back to whoever wrote the code, which may disagree. Concrete ones can be
|
|
43453
|
+
// settled against the file; vague ones turn into an argument nobody can end.
|
|
43454
|
+
"Your findings may be put to the person who wrote the code, who can disagree with them. That",
|
|
43455
|
+
"is why each one needs an input and an outcome: a finding stated concretely can be checked",
|
|
43456
|
+
"against the real file and settled, and one stated as a preference cannot."
|
|
43457
|
+
].join("\n")
|
|
43458
|
+
},
|
|
43459
|
+
tester: {
|
|
43460
|
+
name: "Tester",
|
|
43461
|
+
summary: "Designs cases and finds what breaks it",
|
|
43462
|
+
/* The change is in front of it and the cases come from reasoning about it, not from
|
|
43463
|
+
* reading more of the codebase. */
|
|
43464
|
+
usesTools: false,
|
|
43465
|
+
prompt: [
|
|
43466
|
+
"You design tests for code written by another AI assistant.",
|
|
43467
|
+
"",
|
|
43468
|
+
"Given a change, say what should be tested and why each case earns its place. Prefer the",
|
|
43469
|
+
"cases that would actually fail: boundaries, empty and missing values, the error path, the",
|
|
43470
|
+
"second call, the concurrent one, the one that fails halfway and has to be recovered from.",
|
|
43471
|
+
"",
|
|
43472
|
+
"A test that cannot fail is worth nothing \u2014 for each case you propose, say what bug it would",
|
|
43473
|
+
"catch. If the change is untestable as written, say what would have to change to make it",
|
|
43474
|
+
"testable rather than proposing a test that only asserts the code was executed."
|
|
43475
|
+
].join("\n")
|
|
43476
|
+
},
|
|
43477
|
+
librarian: {
|
|
43478
|
+
name: "Librarian",
|
|
43479
|
+
summary: "Skills, internal documentation and house conventions",
|
|
43480
|
+
/* Its whole job is what has been written down here, so being unable to go and read it
|
|
43481
|
+
* left it answering from whatever happened to be pasted in. This is the role the flag
|
|
43482
|
+
* exists for. */
|
|
43483
|
+
usesTools: true,
|
|
43484
|
+
prompt: [
|
|
43485
|
+
"You answer questions about how things are done here: internal libraries, house conventions,",
|
|
43486
|
+
"the shape of existing code, and what has already been written down.",
|
|
43487
|
+
"",
|
|
43488
|
+
"You are given whatever documentation, skills and code the assistant could find. Answer from",
|
|
43489
|
+
"that, and be explicit about the difference between what the material actually says and what",
|
|
43490
|
+
"you are inferring \u2014 a convention you guessed at, stated confidently, becomes the convention.",
|
|
43491
|
+
"",
|
|
43492
|
+
"If the material does not answer the question, say so and say what would. Do not fill the gap",
|
|
43493
|
+
"with how it is usually done elsewhere unless you label it as exactly that."
|
|
43494
|
+
].join("\n")
|
|
43495
|
+
}
|
|
43496
|
+
};
|
|
43497
|
+
function roleInfo(role, custom2 = []) {
|
|
43498
|
+
const builtIn = DEFINITIONS[role];
|
|
43499
|
+
if (builtIn !== void 0)
|
|
43500
|
+
return { role, ...builtIn };
|
|
43501
|
+
const defined = custom2.find((candidate) => candidate.id === role);
|
|
43502
|
+
if (defined !== void 0) {
|
|
43503
|
+
return {
|
|
43504
|
+
role,
|
|
43505
|
+
name: defined.name,
|
|
43506
|
+
summary: defined.summary,
|
|
43507
|
+
prompt: defined.prompt.trim(),
|
|
43508
|
+
/*
|
|
43509
|
+
* Custom roles get tools by default.
|
|
43510
|
+
*
|
|
43511
|
+
* They are overwhelmingly reviewers of some particular kind — security, performance,
|
|
43512
|
+
* accessibility — and those all turn on code the asker did not think to paste. The flag is
|
|
43513
|
+
* there to turn it off for the ones that are really "write this to spec".
|
|
43514
|
+
*/
|
|
43515
|
+
usesTools: defined.usesTools !== false
|
|
43516
|
+
};
|
|
43517
|
+
}
|
|
43518
|
+
return {
|
|
43519
|
+
role,
|
|
43520
|
+
name: role,
|
|
43521
|
+
summary: "This role is no longer defined.",
|
|
43522
|
+
prompt: "",
|
|
43523
|
+
usesTools: false
|
|
43524
|
+
};
|
|
43525
|
+
}
|
|
43526
|
+
function allRoles(custom2 = []) {
|
|
43527
|
+
return knownRoles(custom2).map((role) => roleInfo(role, custom2));
|
|
43528
|
+
}
|
|
43529
|
+
function defaultPromptFor(role, custom2 = []) {
|
|
43530
|
+
return roleInfo(role, custom2).prompt;
|
|
43531
|
+
}
|
|
43532
|
+
function buildAgentPrompt(options) {
|
|
43533
|
+
const lines = [options.prompt.trim(), "", specialistPreamble(options.usesTools)];
|
|
43534
|
+
if (options.briefing !== void 0 && options.briefing.trim().length > 0) {
|
|
43535
|
+
lines.push("", options.briefing);
|
|
43536
|
+
}
|
|
43537
|
+
lines.push("", "---", "", options.question);
|
|
43538
|
+
if (options.files !== void 0 && options.files.length > 0) {
|
|
43539
|
+
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}`));
|
|
43540
|
+
}
|
|
43541
|
+
return lines.join("\n");
|
|
43542
|
+
}
|
|
43543
|
+
|
|
43544
|
+
// ../../packages/core/dist/agent/checkpoints.js
|
|
43545
|
+
var MAX_CHECKPOINTS = 50;
|
|
43546
|
+
var LIST_ITEM = /^(\s*)(?:([-*•])|(\d+)[.)])\s+(.+)$/;
|
|
43547
|
+
function idFor(text) {
|
|
43548
|
+
let hash2 = 2166136261;
|
|
43549
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
43550
|
+
hash2 ^= text.charCodeAt(index);
|
|
43551
|
+
hash2 = Math.imul(hash2, 16777619) >>> 0;
|
|
43552
|
+
}
|
|
43553
|
+
return hash2.toString(36);
|
|
43554
|
+
}
|
|
43555
|
+
function normalise(text) {
|
|
43556
|
+
return text.trim().toLowerCase().replace(/\s+/g, " ").replace(/[.;,:]+$/, "");
|
|
43557
|
+
}
|
|
43558
|
+
function parseCheckpoints(plan) {
|
|
43559
|
+
const lines = (plan ?? "").split(/\r?\n/);
|
|
43560
|
+
const items = [];
|
|
43561
|
+
lines.forEach((line, index) => {
|
|
43562
|
+
const match = LIST_ITEM.exec(line);
|
|
43563
|
+
if (match === null)
|
|
43564
|
+
return;
|
|
43565
|
+
const text = match[4]?.trim() ?? "";
|
|
43566
|
+
if (text.length === 0)
|
|
43567
|
+
return;
|
|
43568
|
+
items.push({
|
|
43569
|
+
indent: (match[1] ?? "").replace(/\t/g, " ").length,
|
|
43570
|
+
ordered: match[3] !== void 0,
|
|
43571
|
+
text,
|
|
43572
|
+
line: index
|
|
43573
|
+
});
|
|
43574
|
+
});
|
|
43575
|
+
const ordered = items.filter((item) => item.ordered);
|
|
43576
|
+
const candidates = ordered.length > 0 ? ordered : items;
|
|
43577
|
+
const shallowest = candidates.reduce((least, item) => Math.min(least, item.indent), Number.POSITIVE_INFINITY);
|
|
43578
|
+
const steps = candidates.filter((item) => item.indent === shallowest);
|
|
43579
|
+
const texts = steps.length > 0 ? steps : (
|
|
43580
|
+
// No list at all: plenty of people write a plan as bare lines, and a progress view that
|
|
43581
|
+
// only worked for bullet-point authors would read as broken.
|
|
43582
|
+
lines.map((line, index) => ({ indent: 0, ordered: false, text: line.trim(), line: index })).filter((item) => item.text.length > 0)
|
|
43583
|
+
);
|
|
43584
|
+
const chosen = texts.slice(0, MAX_CHECKPOINTS);
|
|
43585
|
+
const seen = /* @__PURE__ */ new Map();
|
|
43586
|
+
return chosen.map((item, position) => {
|
|
43587
|
+
const key = normalise(item.text);
|
|
43588
|
+
const occurrence = (seen.get(key) ?? 0) + 1;
|
|
43589
|
+
seen.set(key, occurrence);
|
|
43590
|
+
const until = chosen[position + 1]?.line ?? lines.length;
|
|
43591
|
+
return {
|
|
43592
|
+
id: occurrence === 1 ? idFor(key) : `${idFor(key)}-${String(occurrence)}`,
|
|
43593
|
+
index: position + 1,
|
|
43594
|
+
text: item.text,
|
|
43595
|
+
/*
|
|
43596
|
+
* Who the plan says should be involved, read from the step *and everything under it* —
|
|
43597
|
+
* which is where the allocation actually lives, since a specialist is usually named on a
|
|
43598
|
+
* continuation line ("Owner: reviewer") or inside a sub-point rather than in the heading.
|
|
43599
|
+
*/
|
|
43600
|
+
plannedRoles: rolesMentionedIn(lines.slice(item.line, until).join(" "))
|
|
43601
|
+
};
|
|
43602
|
+
});
|
|
43603
|
+
}
|
|
43604
|
+
function rolesMentionedIn(text) {
|
|
43605
|
+
const haystack = text.toLowerCase();
|
|
43606
|
+
return AGENT_ROLES.filter((role) => new RegExp(`\\b${role}\\b`).test(haystack));
|
|
43607
|
+
}
|
|
43608
|
+
function checkpointViews(plan, progress) {
|
|
43609
|
+
return parseCheckpoints(plan).map((checkpoint) => {
|
|
43610
|
+
const recorded = progress?.[checkpoint.id];
|
|
43611
|
+
return {
|
|
43612
|
+
...checkpoint,
|
|
43613
|
+
status: recorded?.status ?? "todo",
|
|
43614
|
+
roles: recorded?.roles ?? []
|
|
43615
|
+
};
|
|
43616
|
+
});
|
|
43617
|
+
}
|
|
43618
|
+
function pruneProgress(plan, progress) {
|
|
43619
|
+
if (progress === void 0)
|
|
43620
|
+
return {};
|
|
43621
|
+
const live = new Set(parseCheckpoints(plan).map((checkpoint) => checkpoint.id));
|
|
43622
|
+
const kept = {};
|
|
43623
|
+
for (const [id, entry] of Object.entries(progress))
|
|
43624
|
+
if (live.has(id))
|
|
43625
|
+
kept[id] = entry;
|
|
43626
|
+
return kept;
|
|
43627
|
+
}
|
|
43628
|
+
function markCheckpoint(plan, progress, index, status) {
|
|
43629
|
+
const checkpoint = parseCheckpoints(plan).find((candidate) => candidate.index === index);
|
|
43630
|
+
if (checkpoint === void 0)
|
|
43631
|
+
return void 0;
|
|
43632
|
+
const existing = progress[checkpoint.id];
|
|
43633
|
+
return {
|
|
43634
|
+
...progress,
|
|
43635
|
+
[checkpoint.id]: {
|
|
43636
|
+
status,
|
|
43637
|
+
// Kept across a start→done transition: the specialists consulted while the step was being
|
|
43638
|
+
// worked are exactly the ones that contributed to finishing it.
|
|
43639
|
+
roles: existing?.roles ?? [],
|
|
43640
|
+
at: Date.now()
|
|
43641
|
+
}
|
|
43642
|
+
};
|
|
43643
|
+
}
|
|
43644
|
+
function attributeConsultation(progress, role) {
|
|
43645
|
+
const entry = Object.entries(progress).find(([, value2]) => value2.status === "active");
|
|
43646
|
+
if (entry === void 0)
|
|
43647
|
+
return progress;
|
|
43648
|
+
const [id, value] = entry;
|
|
43649
|
+
if (value.roles.includes(role))
|
|
43650
|
+
return progress;
|
|
43651
|
+
return { ...progress, [id]: { ...value, roles: [...value.roles, role] } };
|
|
43652
|
+
}
|
|
43653
|
+
function progressSummary(views) {
|
|
43654
|
+
const done = views.filter((view) => view.status === "done").length;
|
|
43655
|
+
return `${String(done)}/${String(views.length)}`;
|
|
43656
|
+
}
|
|
43657
|
+
|
|
43330
43658
|
// ../../packages/core/dist/agent/plan.js
|
|
43331
43659
|
var PLAN_LIMIT = 4e3;
|
|
43332
43660
|
function buildPlanGuidance(plan) {
|
|
43333
43661
|
const trimmed = plan?.trim() ?? "";
|
|
43334
43662
|
if (trimmed.length === 0)
|
|
43335
43663
|
return "";
|
|
43664
|
+
const checkpoints = parseCheckpoints(trimmed);
|
|
43665
|
+
const numbered = checkpoints.length > 0 ? [
|
|
43666
|
+
"",
|
|
43667
|
+
"Its steps are numbered as follows. These numbers are what `plan_progress` takes, and",
|
|
43668
|
+
"they are what the user sees:",
|
|
43669
|
+
"",
|
|
43670
|
+
...checkpoints.map((checkpoint) => `${String(checkpoint.index)}. ${checkpoint.text}`)
|
|
43671
|
+
] : [];
|
|
43336
43672
|
return [
|
|
43337
43673
|
"# The plan for this conversation",
|
|
43338
43674
|
"",
|
|
43339
43675
|
"The user set this. It is what you are here to do:",
|
|
43340
43676
|
"",
|
|
43341
43677
|
trimmed,
|
|
43678
|
+
...numbered,
|
|
43679
|
+
"",
|
|
43680
|
+
"## Reporting where you are",
|
|
43681
|
+
"",
|
|
43682
|
+
"- **Call `plan_progress` with `active` when you start a step**, and with `done` when it is",
|
|
43683
|
+
" actually finished. The user watches this rather than reading the whole transcript, so a",
|
|
43684
|
+
" step marked done that is not done is worse than one never marked at all.",
|
|
43685
|
+
"- Work one step at a time. Marking three done at the end tells the user nothing while it",
|
|
43686
|
+
" matters, which is the only time it is useful.",
|
|
43687
|
+
"",
|
|
43688
|
+
"## Changing the plan",
|
|
43689
|
+
"",
|
|
43690
|
+
"- **You may propose a different plan with `update_plan`, and the user must approve it.**",
|
|
43691
|
+
" They are shown a diff of the plan they have against the one you are proposing. This is",
|
|
43692
|
+
" the only way the plan changes on your side \u2014 never act on a plan the user has not agreed.",
|
|
43693
|
+
"- Use it when you have worked out a better plan, including one a specialist drafted for you.",
|
|
43694
|
+
" Put the whole plan in it: it replaces what is there rather than adding to it.",
|
|
43695
|
+
"- If they decline, the existing plan still stands and you carry on with it.",
|
|
43342
43696
|
"",
|
|
43343
43697
|
"## Working to it",
|
|
43344
43698
|
"",
|
|
@@ -43798,130 +44152,6 @@ ${withBudget}` : withBudget;
|
|
|
43798
44152
|
};
|
|
43799
44153
|
}
|
|
43800
44154
|
|
|
43801
|
-
// ../../packages/core/dist/agents/roles.js
|
|
43802
|
-
var AGENT_ROLES = ["expert", "programmer", "reviewer", "tester", "librarian"];
|
|
43803
|
-
function isAgentRole(value) {
|
|
43804
|
-
return AGENT_ROLES.includes(value);
|
|
43805
|
-
}
|
|
43806
|
-
var SHARED = [
|
|
43807
|
-
"You cannot see the workspace and cannot read files, run commands or search. Everything you",
|
|
43808
|
-
"have is in the question. If something essential is missing, say exactly what you need and why,",
|
|
43809
|
-
"then give the best answer you can without it \u2014 never refuse to answer.",
|
|
43810
|
-
"",
|
|
43811
|
-
"Your reply is advice. The assistant will check it against the real code before acting, and it",
|
|
43812
|
-
"is responsible for the result. Be concrete, say what you are unsure about, and say plainly when",
|
|
43813
|
-
"something must be verified rather than assumed.",
|
|
43814
|
-
"",
|
|
43815
|
-
"Answer in prose and short lists. No preamble about being happy to help."
|
|
43816
|
-
].join("\n");
|
|
43817
|
-
var DEFINITIONS = {
|
|
43818
|
-
expert: {
|
|
43819
|
-
name: "Expert",
|
|
43820
|
-
summary: "Hard problems, architecture, and deciding what to do",
|
|
43821
|
-
prompt: [
|
|
43822
|
-
"You are a senior engineer being consulted by another AI assistant that is doing the work.",
|
|
43823
|
-
"",
|
|
43824
|
-
"It has hit something hard: a change across several files to plan, a bug it has already",
|
|
43825
|
-
"failed to fix, or a design choice with no obvious answer. Give it your judgement.",
|
|
43826
|
-
"",
|
|
43827
|
-
"Decide *what* should happen and why. Leave the typing to the assistant \u2014 it has the files",
|
|
43828
|
-
"open and you do not. Where there is a real trade-off, name both sides and then choose.",
|
|
43829
|
-
"",
|
|
43830
|
-
SHARED
|
|
43831
|
-
].join("\n")
|
|
43832
|
-
},
|
|
43833
|
-
programmer: {
|
|
43834
|
-
name: "Programmer",
|
|
43835
|
-
summary: "Writes the code once the plan is settled",
|
|
43836
|
-
prompt: [
|
|
43837
|
-
"You are an experienced programmer writing code for another AI assistant to apply.",
|
|
43838
|
-
"",
|
|
43839
|
-
"You are given a requirement and the surrounding code. Produce the change, matching the",
|
|
43840
|
-
"conventions of what you were shown rather than your own preferences \u2014 the naming, the error",
|
|
43841
|
-
"handling, the comment density, the way the existing code does this sort of thing.",
|
|
43842
|
-
"",
|
|
43843
|
-
"Return the code and a short note on anything non-obvious in it. Do not narrate what you are",
|
|
43844
|
-
"about to do, and do not rewrite things you were not asked to change.",
|
|
43845
|
-
"",
|
|
43846
|
-
SHARED
|
|
43847
|
-
].join("\n")
|
|
43848
|
-
},
|
|
43849
|
-
reviewer: {
|
|
43850
|
-
name: "Reviewer",
|
|
43851
|
-
summary: "Reads a change and says what is wrong with it",
|
|
43852
|
-
prompt: [
|
|
43853
|
-
"You are reviewing a change written by another AI assistant.",
|
|
43854
|
-
"",
|
|
43855
|
-
"Your job is to find what is wrong with it. Say so plainly when something is fine, but do",
|
|
43856
|
-
"not pad the review with praise \u2014 an approving review that missed a bug is worse than no",
|
|
43857
|
-
"review, because it was believed.",
|
|
43858
|
-
"",
|
|
43859
|
-
"Look for, in this order: does it do what was asked; does it break something that used to",
|
|
43860
|
-
"work; what happens at the edges \u2014 empty, missing, concurrent, already-exists, fails halfway;",
|
|
43861
|
-
"and does it match the conventions of the code around it.",
|
|
43862
|
-
"",
|
|
43863
|
-
"For each finding say what breaks and under what input. A concern you cannot make concrete is",
|
|
43864
|
-
"worth one sentence, flagged as a hunch, not a paragraph.",
|
|
43865
|
-
"",
|
|
43866
|
-
SHARED
|
|
43867
|
-
].join("\n")
|
|
43868
|
-
},
|
|
43869
|
-
tester: {
|
|
43870
|
-
name: "Tester",
|
|
43871
|
-
summary: "Designs cases and finds what breaks it",
|
|
43872
|
-
prompt: [
|
|
43873
|
-
"You design tests for code written by another AI assistant.",
|
|
43874
|
-
"",
|
|
43875
|
-
"Given a change, say what should be tested and why each case earns its place. Prefer the",
|
|
43876
|
-
"cases that would actually fail: boundaries, empty and missing values, the error path, the",
|
|
43877
|
-
"second call, the concurrent one, the one that fails halfway and has to be recovered from.",
|
|
43878
|
-
"",
|
|
43879
|
-
"A test that cannot fail is worth nothing \u2014 for each case you propose, say what bug it would",
|
|
43880
|
-
"catch. If the change is untestable as written, say what would have to change to make it",
|
|
43881
|
-
"testable rather than proposing a test that only asserts the code was executed.",
|
|
43882
|
-
"",
|
|
43883
|
-
SHARED
|
|
43884
|
-
].join("\n")
|
|
43885
|
-
},
|
|
43886
|
-
librarian: {
|
|
43887
|
-
name: "Librarian",
|
|
43888
|
-
summary: "Skills, internal documentation and house conventions",
|
|
43889
|
-
prompt: [
|
|
43890
|
-
"You answer questions about how things are done here: internal libraries, house conventions,",
|
|
43891
|
-
"the shape of existing code, and what has already been written down.",
|
|
43892
|
-
"",
|
|
43893
|
-
"You are given whatever documentation, skills and code the assistant could find. Answer from",
|
|
43894
|
-
"that, and be explicit about the difference between what the material actually says and what",
|
|
43895
|
-
"you are inferring \u2014 a convention you guessed at, stated confidently, becomes the convention.",
|
|
43896
|
-
"",
|
|
43897
|
-
"If the material does not answer the question, say so and say what would. Do not fill the gap",
|
|
43898
|
-
"with how it is usually done elsewhere unless you label it as exactly that.",
|
|
43899
|
-
"",
|
|
43900
|
-
SHARED
|
|
43901
|
-
].join("\n")
|
|
43902
|
-
}
|
|
43903
|
-
};
|
|
43904
|
-
function roleInfo(role) {
|
|
43905
|
-
return { role, ...DEFINITIONS[role] };
|
|
43906
|
-
}
|
|
43907
|
-
function allRoles() {
|
|
43908
|
-
return AGENT_ROLES.map(roleInfo);
|
|
43909
|
-
}
|
|
43910
|
-
function defaultPromptFor(role) {
|
|
43911
|
-
return DEFINITIONS[role].prompt;
|
|
43912
|
-
}
|
|
43913
|
-
function buildAgentPrompt(options) {
|
|
43914
|
-
const lines = [options.prompt];
|
|
43915
|
-
if (options.briefing !== void 0 && options.briefing.trim().length > 0) {
|
|
43916
|
-
lines.push("", options.briefing);
|
|
43917
|
-
}
|
|
43918
|
-
lines.push("", "---", "", options.question);
|
|
43919
|
-
if (options.files !== void 0 && options.files.length > 0) {
|
|
43920
|
-
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}`));
|
|
43921
|
-
}
|
|
43922
|
-
return lines.join("\n");
|
|
43923
|
-
}
|
|
43924
|
-
|
|
43925
44155
|
// ../../packages/core/dist/tools/askAgent.js
|
|
43926
44156
|
var paramsSchema3 = external_exports.object({
|
|
43927
44157
|
role: external_exports.string().describe(`Which specialist to ask: ${AGENT_ROLES.join(", ")}. Only the ones assigned in Settings \u2192 Agents can answer.`),
|
|
@@ -43991,7 +44221,7 @@ Files named as relevant: ${params.files.join(", ")}` : "")
|
|
|
43991
44221
|
|
|
43992
44222
|
---
|
|
43993
44223
|
|
|
43994
|
-
|
|
44224
|
+
${trailerFor(agent, team)}`
|
|
43995
44225
|
};
|
|
43996
44226
|
}
|
|
43997
44227
|
};
|
|
@@ -44007,6 +44237,19 @@ function describeTeam(team) {
|
|
|
44007
44237
|
const usable = team.filter((agent) => agent.available).map((agent) => agent.role);
|
|
44008
44238
|
return usable.length === 0 ? "None are assigned on this machine." : `Assigned here: ${usable.join(", ")}.`;
|
|
44009
44239
|
}
|
|
44240
|
+
function trailerFor(agent, team) {
|
|
44241
|
+
const lines = [
|
|
44242
|
+
`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."
|
|
44243
|
+
];
|
|
44244
|
+
const programmer = team.find((candidate) => candidate.role === "programmer" && candidate.available);
|
|
44245
|
+
if (agent.role === "reviewer" && programmer !== void 0) {
|
|
44246
|
+
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.");
|
|
44247
|
+
}
|
|
44248
|
+
if (agent.role === "programmer") {
|
|
44249
|
+
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.");
|
|
44250
|
+
}
|
|
44251
|
+
return lines.join("\n");
|
|
44252
|
+
}
|
|
44010
44253
|
|
|
44011
44254
|
// ../../packages/core/dist/agents/team.js
|
|
44012
44255
|
function defaultAssignment(role, context) {
|
|
@@ -44014,12 +44257,14 @@ function defaultAssignment(role, context) {
|
|
|
44014
44257
|
}
|
|
44015
44258
|
function resolveTeam(context) {
|
|
44016
44259
|
const resolved = [];
|
|
44017
|
-
|
|
44260
|
+
const custom2 = context.config?.definitions ?? [];
|
|
44261
|
+
for (const role of knownRoles(custom2)) {
|
|
44018
44262
|
const assignment = context.config?.roles?.[role] ?? defaultAssignment(role, context);
|
|
44019
44263
|
if (assignment === void 0)
|
|
44020
44264
|
continue;
|
|
44021
|
-
const info = roleInfo(role);
|
|
44022
|
-
const prompt = assignment.prompt ?? defaultPromptFor(role);
|
|
44265
|
+
const info = roleInfo(role, custom2);
|
|
44266
|
+
const prompt = assignment.prompt ?? defaultPromptFor(role, custom2);
|
|
44267
|
+
const usesTools = assignment.tools ?? info.usesTools;
|
|
44023
44268
|
if (assignment.kind === "cli") {
|
|
44024
44269
|
resolved.push({
|
|
44025
44270
|
role,
|
|
@@ -44028,6 +44273,7 @@ function resolveTeam(context) {
|
|
|
44028
44273
|
kind: "cli",
|
|
44029
44274
|
label: "Claude",
|
|
44030
44275
|
prompt,
|
|
44276
|
+
usesTools,
|
|
44031
44277
|
available: context.cliAvailable,
|
|
44032
44278
|
...context.cliAvailable ? {} : { reason: "The Claude CLI is not available on this machine." }
|
|
44033
44279
|
});
|
|
@@ -44042,6 +44288,7 @@ function resolveTeam(context) {
|
|
|
44042
44288
|
...assignment.profileId !== void 0 ? { profileId: assignment.profileId } : {},
|
|
44043
44289
|
label: profile?.label ?? assignment.profileId ?? "unassigned",
|
|
44044
44290
|
prompt,
|
|
44291
|
+
usesTools,
|
|
44045
44292
|
available: profile !== void 0,
|
|
44046
44293
|
/*
|
|
44047
44294
|
* A profile that has been deleted leaves the role unavailable and says so, rather than
|
|
@@ -44070,6 +44317,46 @@ var BUDGET_ADVICE = [
|
|
|
44070
44317
|
"out the specialist stops being available, and you finish the work alone, so spend it on the",
|
|
44071
44318
|
"parts where another reader genuinely changes what you do."
|
|
44072
44319
|
].join("\n");
|
|
44320
|
+
var PLAN_FIRST = [
|
|
44321
|
+
"",
|
|
44322
|
+
"## Start by planning. This comes before everything else.",
|
|
44323
|
+
"",
|
|
44324
|
+
"**This conversation has no plan yet, so making one is your first job.** Before reading widely,",
|
|
44325
|
+
"before editing anything, before running anything:",
|
|
44326
|
+
"",
|
|
44327
|
+
"1. **Look at almost nothing first.** One `list_files` of the workspace root is usually the",
|
|
44328
|
+
" whole of it, plus any file the user actually named. That is enough to ask a good question.",
|
|
44329
|
+
" Do **not** survey the codebase, search the documentation index, hunt for skills, or read",
|
|
44330
|
+
" files to get a feel for the style \u2014 not yet. The specialist cannot see any of it anyway,",
|
|
44331
|
+
" and if it needs something specific it will say so and you can fetch it and ask again.",
|
|
44332
|
+
' Announcing that you are "getting a sense of the workspace before proposing anything" is',
|
|
44333
|
+
" this instruction being broken, however reasonable it sounds.",
|
|
44334
|
+
"2. **Ask the expert for the plan** \u2014 give the task, the little you found and the constraints,",
|
|
44335
|
+
" and ask for numbered steps. A plan is the one thing worth asking for before the work rather",
|
|
44336
|
+
" than after it, and it is what the expert is for. An expert asked early enough to change the",
|
|
44337
|
+
" shape of the work is worth several times one asked to bless a direction already taken.",
|
|
44338
|
+
" **Ask it to say which specialist should be involved in which step**, from the team it is",
|
|
44339
|
+
" given. It knows who is available; it will not volunteer the allocation unless asked.",
|
|
44340
|
+
"3. **Propose it with `update_plan`.** The user sees a diff and approves it. Do not skip this:",
|
|
44341
|
+
" a plan held only in the conversation is forgotten as the chat grows, and it is not",
|
|
44342
|
+
" something the user has agreed to.",
|
|
44343
|
+
"4. Only once it is approved, start the work, reporting each step with `plan_progress`.",
|
|
44344
|
+
"",
|
|
44345
|
+
"If the user declines, ask what they want changed and propose a revised plan. If no expert is",
|
|
44346
|
+
"assigned, draft it yourself and propose it the same way \u2014 and say that is what you did, so",
|
|
44347
|
+
"nobody believes it was reviewed by somebody else.",
|
|
44348
|
+
"",
|
|
44349
|
+
"The exception is a question rather than a job. If the user asked something you can simply",
|
|
44350
|
+
"answer, answer it \u2014 do not plan a conversation."
|
|
44351
|
+
].join("\n");
|
|
44352
|
+
var PLAN_IN_PLACE = [
|
|
44353
|
+
"",
|
|
44354
|
+
"## This conversation already has a plan",
|
|
44355
|
+
"",
|
|
44356
|
+
"It is above, with its steps numbered. Work it, report each step with `plan_progress`, and if it",
|
|
44357
|
+
"turns out to be wrong, consult the expert and propose a replacement with `update_plan` rather",
|
|
44358
|
+
"than quietly working to a different one."
|
|
44359
|
+
].join("\n");
|
|
44073
44360
|
var DEFAULT_TEAM_GUIDANCE = [
|
|
44074
44361
|
"You lead a small team. You do the work \u2014 reading, searching, editing, running things \u2014 and you",
|
|
44075
44362
|
"consult specialists when another reader would genuinely change what you do.",
|
|
@@ -44085,17 +44372,39 @@ var DEFAULT_TEAM_GUIDANCE = [
|
|
|
44085
44372
|
"- you are about to call something done that has no tests \u2014 ask the **tester** what would break",
|
|
44086
44373
|
" it;",
|
|
44087
44374
|
"- you are guessing at how this codebase does something \u2014 ask the **librarian** rather than",
|
|
44088
|
-
" inventing a convention
|
|
44375
|
+
" inventing a convention;",
|
|
44376
|
+
/*
|
|
44377
|
+
* The programmer was missing from this list entirely, which is most of why it never got used.
|
|
44378
|
+
*
|
|
44379
|
+
* Every other bullet describes somebody *reading* what you have, and writing code is the one
|
|
44380
|
+
* thing the assistant can already do — so with no bullet of its own the role simply never came
|
|
44381
|
+
* up, and a plan drafted by the expert never allocated it either (the same omission, in the
|
|
44382
|
+
* briefing). Bounded deliberately: "hand everything to the programmer" would add a round trip
|
|
44383
|
+
* to every edit and put a second model's conventions into the file.
|
|
44384
|
+
*/
|
|
44385
|
+
"- a step is a self-contained piece of code with a clear spec \u2014 a parser, a schema, a set of",
|
|
44386
|
+
" pure functions \u2014 hand it to the **programmer** rather than writing it yourself out of habit,",
|
|
44387
|
+
" then check what comes back against the real file before applying it. Not for a two-line",
|
|
44388
|
+
" change, and not where the spec is still moving.",
|
|
44089
44389
|
"",
|
|
44090
44390
|
'The user can also ask directly ("ask the reviewer to look at this"), and then you consult that',
|
|
44091
44391
|
"role whatever you would have chosen.",
|
|
44092
44392
|
"",
|
|
44093
44393
|
"## What makes a consultation worth it",
|
|
44094
44394
|
"",
|
|
44095
|
-
|
|
44096
|
-
|
|
44097
|
-
|
|
44098
|
-
|
|
44395
|
+
/*
|
|
44396
|
+
* The last place still saying every specialist is blind.
|
|
44397
|
+
*
|
|
44398
|
+
* Some can read and search for themselves; the roster above marks which. But the advice does
|
|
44399
|
+
* not change much, because even one that can look things up starts from what you gave it — and
|
|
44400
|
+
* a question with nothing attached spends its whole lookup budget finding the file you already
|
|
44401
|
+
* had open.
|
|
44402
|
+
*/
|
|
44403
|
+
"**Paste the code**, the error, the failing output \u2014 the actual text. Some of them can read the",
|
|
44404
|
+
"workspace and some cannot, and the roster says which; but even the ones that can start from",
|
|
44405
|
+
"what you give them, and a question with nothing attached spends their whole lookup budget",
|
|
44406
|
+
'finding what you already had open. A question like "is my retry logic right?" with nothing',
|
|
44407
|
+
"attached comes back as a list of things retry logic usually gets wrong, which you already knew.",
|
|
44099
44408
|
"",
|
|
44100
44409
|
"Ask one full question rather than three thin ones. Each consultation is a fresh reader with no",
|
|
44101
44410
|
"memory of the last, so a follow-up has to carry its own context.",
|
|
@@ -44105,30 +44414,86 @@ var DEFAULT_TEAM_GUIDANCE = [
|
|
|
44105
44414
|
"- Do not consult on something you can settle by reading a file. Read it.",
|
|
44106
44415
|
"- Do not relay advice you have not checked. You have the code open and the specialist does not;",
|
|
44107
44416
|
" if it is wrong, say so and say why \u2014 to the user, and in your next question.",
|
|
44108
|
-
"- Do not consult the same role twice with the same question hoping for a better answer."
|
|
44417
|
+
"- Do not consult the same role twice with the same question hoping for a better answer.",
|
|
44418
|
+
"",
|
|
44419
|
+
"## When a review finds something in code the programmer wrote",
|
|
44420
|
+
"",
|
|
44421
|
+
"**Take it back to the programmer.** It wrote the code, it is the role picked for writing, and",
|
|
44422
|
+
"the fix is its job rather than yours \u2014 you are the one holding the files, not the one whose",
|
|
44423
|
+
"judgement was hired for this. Fixing it silently yourself wastes the specialist and hides the",
|
|
44424
|
+
"exchange from the user.",
|
|
44425
|
+
"",
|
|
44426
|
+
"A consultation remembers nothing, so the question has to carry everything: **the code as it",
|
|
44427
|
+
"stands, the finding in the reviewer's own words, and what you have checked yourself.** A",
|
|
44428
|
+
'programmer told only "the reviewer says this is wrong" will guess at which line and rewrite',
|
|
44429
|
+
"more than it should.",
|
|
44430
|
+
"",
|
|
44431
|
+
"**It may push back, and that is a real answer, not an obstacle.** Reviews are wrong often",
|
|
44432
|
+
"enough to matter \u2014 a finding can be about a path that cannot happen, a convention this",
|
|
44433
|
+
"codebase deliberately does not follow, or a misreading of code the reviewer only saw a fragment",
|
|
44434
|
+
"of. When the programmer disagrees, you settle it: you have the actual file and neither of them",
|
|
44435
|
+
"does. Say which way you went and why, in your reply, so the user sees the disagreement rather",
|
|
44436
|
+
"than only its outcome.",
|
|
44437
|
+
"",
|
|
44438
|
+
"**One lap, not a loop.** Review, fix, and re-review only when the fix was substantial enough",
|
|
44439
|
+
"that the first review no longer describes the code. If the two still disagree after that, stop",
|
|
44440
|
+
"and put it to the expert with both positions, or decide it yourself and say so. Ping-ponging a",
|
|
44441
|
+
"disagreement between two models that cannot see the file is how a turn is spent without",
|
|
44442
|
+
"anything being decided.",
|
|
44443
|
+
"",
|
|
44444
|
+
"## When the plan names a specialist",
|
|
44445
|
+
"",
|
|
44446
|
+
"Consult them **while that step is the active one**, not at the end in a batch. Two reasons, and",
|
|
44447
|
+
"the second is the one people notice: advice arriving after the work is done is a review nobody",
|
|
44448
|
+
"can act on without redoing it, and the progress panel attributes a consultation to whichever",
|
|
44449
|
+
"step was open when it happened \u2014 so a step worked in silence shows as nobody having helped with",
|
|
44450
|
+
"it, whatever you say afterwards.",
|
|
44451
|
+
"",
|
|
44452
|
+
"If a step names somebody and you decide against consulting them, say so and say why. A plan the",
|
|
44453
|
+
"user approved said that step would get another reader."
|
|
44109
44454
|
].join("\n");
|
|
44110
|
-
function buildTeamGuidance(agents, custom2, budgetMatters2) {
|
|
44455
|
+
function buildTeamGuidance(agents, custom2, budgetMatters2, hasPlan) {
|
|
44111
44456
|
const base = custom2 !== void 0 && custom2.trim().length > 0 ? custom2 : DEFAULT_TEAM_GUIDANCE;
|
|
44112
44457
|
const advice = budgetMatters2 === true ? `${base}
|
|
44113
44458
|
${BUDGET_ADVICE}` : base;
|
|
44114
|
-
|
|
44459
|
+
const planning = hasPlan === true ? PLAN_IN_PLACE : PLAN_FIRST;
|
|
44460
|
+
const usable = agents.filter((agent) => agent.available);
|
|
44461
|
+
const unusable = AGENT_ROLES.filter((role) => !usable.some((agent) => agent.role === role)).map((role) => {
|
|
44462
|
+
const assigned = agents.find((agent) => agent.role === role);
|
|
44463
|
+
return assigned === void 0 ? `- **${role}** \u2014 nobody assigned.` : `- **${role}** \u2014 ${assigned.reason ?? "assigned, but cannot be reached."}`;
|
|
44464
|
+
});
|
|
44465
|
+
const missing = unusable.length === 0 ? [] : [
|
|
44466
|
+
"",
|
|
44467
|
+
"**Not available, so do not ask for them and do not plan work for them:**",
|
|
44468
|
+
"",
|
|
44469
|
+
...unusable,
|
|
44470
|
+
"",
|
|
44471
|
+
"If something genuinely needs one of these, say so and say that assigning it in",
|
|
44472
|
+
"Settings \u2192 Agents would let you consult it \u2014 then carry on without it rather than",
|
|
44473
|
+
"leaving that part of the job unaccounted for."
|
|
44474
|
+
];
|
|
44475
|
+
if (usable.length === 0) {
|
|
44115
44476
|
return [
|
|
44116
44477
|
advice,
|
|
44478
|
+
planning,
|
|
44117
44479
|
"",
|
|
44118
44480
|
"## Your team",
|
|
44119
44481
|
"",
|
|
44120
44482
|
"**Nobody is assigned yet.** Until somebody is, do the work yourself and tell the user that",
|
|
44121
|
-
"assigning a specialist in Settings \u2192 Agents would let you consult one."
|
|
44483
|
+
"assigning a specialist in Settings \u2192 Agents would let you consult one.",
|
|
44484
|
+
...missing
|
|
44122
44485
|
].join("\n");
|
|
44123
44486
|
}
|
|
44124
44487
|
return [
|
|
44125
44488
|
advice,
|
|
44489
|
+
planning,
|
|
44126
44490
|
"",
|
|
44127
44491
|
"## Your team",
|
|
44128
44492
|
"",
|
|
44129
|
-
"Reach any of them with `ask_agent`, naming the role:",
|
|
44493
|
+
"Reach any of them with `ask_agent`, naming the role. These are the only ones that exist:",
|
|
44130
44494
|
"",
|
|
44131
|
-
...
|
|
44495
|
+
...usable.map((agent) => `- **${agent.role}** (${agent.label}) \u2014 ${agent.summary}`),
|
|
44496
|
+
...missing
|
|
44132
44497
|
].join("\n");
|
|
44133
44498
|
}
|
|
44134
44499
|
|
|
@@ -44138,20 +44503,131 @@ function firstLine(text, limit = DESCRIPTION_LIMIT) {
|
|
|
44138
44503
|
const line = text.split("\n").find((candidate) => candidate.trim().length > 0)?.trim() ?? "";
|
|
44139
44504
|
return line.length > limit ? `${line.slice(0, limit - 1).trimEnd()}\u2026` : line;
|
|
44140
44505
|
}
|
|
44506
|
+
function buildRoster(team, self) {
|
|
44507
|
+
const others = team.filter((agent) => agent.role !== self);
|
|
44508
|
+
const usable = others.filter((agent) => agent.available);
|
|
44509
|
+
const assigned = new Set(team.map((agent) => agent.role));
|
|
44510
|
+
const missing = [];
|
|
44511
|
+
for (const role of AGENT_ROLES) {
|
|
44512
|
+
if (role === self)
|
|
44513
|
+
continue;
|
|
44514
|
+
if (!assigned.has(role)) {
|
|
44515
|
+
missing.push(`- **${role}** \u2014 nobody is assigned to this role.`);
|
|
44516
|
+
continue;
|
|
44517
|
+
}
|
|
44518
|
+
const agent = others.find((candidate) => candidate.role === role);
|
|
44519
|
+
if (agent !== void 0 && !agent.available) {
|
|
44520
|
+
missing.push(`- **${role}** \u2014 ${agent.reason ?? "assigned, but cannot be reached."}`);
|
|
44521
|
+
}
|
|
44522
|
+
}
|
|
44523
|
+
const sections = ["## The rest of the team", ""];
|
|
44524
|
+
if (self !== void 0)
|
|
44525
|
+
sections.push(`You are the **${self}**.`, "");
|
|
44526
|
+
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.");
|
|
44527
|
+
if (usable.length > 0) {
|
|
44528
|
+
sections.push(
|
|
44529
|
+
"",
|
|
44530
|
+
/*
|
|
44531
|
+
* What the others can actually do — and this was wrong once, in the expensive direction.
|
|
44532
|
+
*
|
|
44533
|
+
* It first said "None of them can see the workspace", written to stop the expert giving the
|
|
44534
|
+
* librarian a lookup job. That was false: `agents/consult.ts` gives a specialist the read
|
|
44535
|
+
* tool group, and the CLI expert holds Claude's own Read/Grep/Glob. The instruction was
|
|
44536
|
+
* therefore telling the expert *not* to allocate the librarian the one kind of work the
|
|
44537
|
+
* librarian is equipped for, which made the weakest role weaker.
|
|
44538
|
+
*
|
|
44539
|
+
* The real distinction is per role and the user controls it, so it is rendered from the
|
|
44540
|
+
* team rather than asserted about all of them — and it sits *above* the list, because it is
|
|
44541
|
+
* how to read the marks in it.
|
|
44542
|
+
*/
|
|
44543
|
+
"**None of them can edit anything or run anything.** They read and advise; the assistant",
|
|
44544
|
+
"makes every change, and it is the one answerable for the result. Some can look things up",
|
|
44545
|
+
"for themselves, marked below; the rest know only what is in the question, so give those",
|
|
44546
|
+
"everything they need.",
|
|
44547
|
+
"",
|
|
44548
|
+
...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
|
|
44549
|
+
// needs pointing at a file, one that cannot needs the file pasted in.
|
|
44550
|
+
(agent.usesTools ? " *(can read and search the workspace)*" : "")),
|
|
44551
|
+
"",
|
|
44552
|
+
/*
|
|
44553
|
+
* Knowing who exists is not the same as being asked to use them.
|
|
44554
|
+
*
|
|
44555
|
+
* Reported with a plan that allocated nobody, on a machine where all four other roles were
|
|
44556
|
+
* assigned. The briefing told the expert who was available and told it not to name anyone
|
|
44557
|
+
* who was not — and it dutifully named nobody at all, writing a plan for the assistant
|
|
44558
|
+
* working alone, down to "I'll show you the code before moving on" where a reviewer was
|
|
44559
|
+
* sitting right there. An instruction that only says what *not* to do gets obeyed by doing
|
|
44560
|
+
* nothing.
|
|
44561
|
+
*
|
|
44562
|
+
* Deliberately not "use every specialist": that is four extra round trips on a task that
|
|
44563
|
+
* may not want any, and a plan routing every step through the whole team is worse than one
|
|
44564
|
+
* routing none — it reads as ceremony and people stop reading it.
|
|
44565
|
+
*/
|
|
44566
|
+
"**If you are asked for a plan, say who should be involved in which step.** Name the role in",
|
|
44567
|
+
'the step itself \u2014 "have the tester say what would break this", "get the reviewer onto the',
|
|
44568
|
+
'callback wiring", "hand the parser to the programmer" \u2014 so the assistant knows when to',
|
|
44569
|
+
"consult and the user can see who is doing what.",
|
|
44570
|
+
"",
|
|
44571
|
+
/*
|
|
44572
|
+
* Two kinds of specialist, said separately, because the first version only described one.
|
|
44573
|
+
*
|
|
44574
|
+
* It asked for allocation "where another reader would genuinely change the outcome" and
|
|
44575
|
+
* called it "another pair of eyes" — review framing throughout, with a reviewer and a
|
|
44576
|
+
* tester as the examples. The programmer does not read, it produces, so a plan written to
|
|
44577
|
+
* that instruction correctly never mentions it. Reported exactly that way: reviewer and
|
|
44578
|
+
* tester allocated across four steps, programmer nowhere, on a machine where it was
|
|
44579
|
+
* assigned. An instruction that names one mode of use gets obeyed in one mode.
|
|
44580
|
+
*/
|
|
44581
|
+
"They divide into two kinds, and both are worth allocating:",
|
|
44582
|
+
"",
|
|
44583
|
+
"- **Readers** \u2014 the reviewer, the tester, the librarian. Worth a step where another pair of",
|
|
44584
|
+
" eyes changes what happens: risky or fiddly code, a step that finishes something, a",
|
|
44585
|
+
" convention you would otherwise be guessing at.",
|
|
44586
|
+
"- **The programmer writes.** Where a step is a self-contained piece of code with a spec",
|
|
44587
|
+
" clear enough to hand over \u2014 a parser, a schema, a set of pure functions \u2014 say so and give",
|
|
44588
|
+
" it to the programmer. The assistant checks what comes back against the real file and",
|
|
44589
|
+
" applies it, so this is delegation rather than trust.",
|
|
44590
|
+
"",
|
|
44591
|
+
"Only where it genuinely changes the outcome: a plan that routes every step through all of",
|
|
44592
|
+
"them is ceremony, and one that routes none wastes a team that is sitting there."
|
|
44593
|
+
);
|
|
44594
|
+
}
|
|
44595
|
+
if (missing.length > 0) {
|
|
44596
|
+
sections.push(
|
|
44597
|
+
"",
|
|
44598
|
+
// "Not set up" would be wrong for a role that *is* assigned and whose profile has since
|
|
44599
|
+
// gone: the user did set it up, and telling them otherwise sends them to fix the wrong
|
|
44600
|
+
// thing. "Not available" is true of both, and the reason beside each says which it is.
|
|
44601
|
+
"**Not available, so the assistant cannot use them:**",
|
|
44602
|
+
"",
|
|
44603
|
+
...missing,
|
|
44604
|
+
"",
|
|
44605
|
+
"Do not give any of these work. Do not put them in a plan, a checklist or a next step \u2014 a",
|
|
44606
|
+
"plan naming a specialist who does not exist is a plan with a hole in it, and the user will",
|
|
44607
|
+
"have approved it without knowing. If a task genuinely needs one, say so in a sentence and",
|
|
44608
|
+
"say the user would have to assign it in Settings \u2192 Agents; then give the best advice you",
|
|
44609
|
+
"can for doing it without that role."
|
|
44610
|
+
);
|
|
44611
|
+
}
|
|
44612
|
+
return sections;
|
|
44613
|
+
}
|
|
44141
44614
|
function buildAgentBriefing(input) {
|
|
44142
44615
|
const tools = (input.tools ?? []).filter(
|
|
44143
44616
|
// Telling a specialist it can consult a specialist is noise at best and a loop at worst.
|
|
44144
44617
|
(tool) => tool.name !== "ask_agent" && tool.name !== "ask_expert"
|
|
44145
44618
|
);
|
|
44146
44619
|
const skills = input.skills ?? [];
|
|
44147
|
-
|
|
44620
|
+
const team = input.team;
|
|
44621
|
+
if (tools.length === 0 && skills.length === 0 && team === void 0)
|
|
44148
44622
|
return "";
|
|
44149
|
-
const sections = [
|
|
44150
|
-
|
|
44151
|
-
|
|
44152
|
-
|
|
44153
|
-
|
|
44154
|
-
|
|
44623
|
+
const sections = [];
|
|
44624
|
+
if (team !== void 0)
|
|
44625
|
+
sections.push(...buildRoster(team, input.self));
|
|
44626
|
+
if (tools.length > 0 || skills.length > 0) {
|
|
44627
|
+
if (sections.length > 0)
|
|
44628
|
+
sections.push("");
|
|
44629
|
+
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.");
|
|
44630
|
+
}
|
|
44155
44631
|
if (tools.length > 0) {
|
|
44156
44632
|
sections.push("", "### Tools it can call", "", ...tools.map((tool) => `- \`${tool.name}\` \u2014 ${firstLine(tool.description)}`));
|
|
44157
44633
|
}
|
|
@@ -48196,18 +48672,23 @@ var NEVER_AVAILABLE_TO_SCHEDULES = [
|
|
|
48196
48672
|
// section 13 requires approval showing the source, which cannot happen with nobody there.
|
|
48197
48673
|
"excel_write_macro",
|
|
48198
48674
|
// And running one: unattended execution of arbitrary VBA, with nobody to read the source.
|
|
48199
|
-
"excel_run_macro"
|
|
48675
|
+
"excel_run_macro",
|
|
48676
|
+
/*
|
|
48677
|
+
* Rewriting the plan it is being held to, with nobody there to approve the diff. Same ladder
|
|
48678
|
+
* as `schedule_prompt`: a run that can change its own instructions is bounded by nothing.
|
|
48679
|
+
*/
|
|
48680
|
+
"update_plan"
|
|
48200
48681
|
];
|
|
48201
48682
|
function scheduleAppliesHere(schedule, workspaceRoot) {
|
|
48202
48683
|
if (schedule.workspaceRoot === void 0)
|
|
48203
48684
|
return true;
|
|
48204
48685
|
if (workspaceRoot === void 0)
|
|
48205
48686
|
return false;
|
|
48206
|
-
const
|
|
48687
|
+
const normalise2 = (value) => {
|
|
48207
48688
|
const resolved = nodePath.resolve(value);
|
|
48208
48689
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
48209
48690
|
};
|
|
48210
|
-
return
|
|
48691
|
+
return normalise2(schedule.workspaceRoot) === normalise2(workspaceRoot);
|
|
48211
48692
|
}
|
|
48212
48693
|
function filterToolsForSchedule(all, schedule) {
|
|
48213
48694
|
const named = new Set(schedule.allowedTools);
|
|
@@ -49411,7 +49892,14 @@ var ALWAYS_ASK_TOOLS = /* @__PURE__ */ new Set([
|
|
|
49411
49892
|
* approval showing the actual source is the only thing standing between "run DoTheThing" and
|
|
49412
49893
|
* whatever DoTheThing does.
|
|
49413
49894
|
*/
|
|
49414
|
-
"excel_run_macro"
|
|
49895
|
+
"excel_run_macro",
|
|
49896
|
+
/*
|
|
49897
|
+
* The plan is what holds the assistant to work the user agreed, so a category toggle must
|
|
49898
|
+
* never stand in for reading the change. Auto-approving this would mean an agent could widen
|
|
49899
|
+
* its own instructions and then point at them as authority — and both the panel and the
|
|
49900
|
+
* prompt would look right afterwards, because both would be reading the new plan.
|
|
49901
|
+
*/
|
|
49902
|
+
"update_plan"
|
|
49415
49903
|
]);
|
|
49416
49904
|
function decideFromPolicy(request, approvals) {
|
|
49417
49905
|
if (!requiresApproval(request.group))
|
|
@@ -49526,6 +50014,65 @@ var ShadowGit = class {
|
|
|
49526
50014
|
}
|
|
49527
50015
|
};
|
|
49528
50016
|
|
|
50017
|
+
// ../../packages/core/dist/tools/planTools.js
|
|
50018
|
+
var updateParams = external_exports.object({
|
|
50019
|
+
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."),
|
|
50020
|
+
reason: external_exports.string().optional().describe("One line on why the plan should change, shown to the user with the diff.")
|
|
50021
|
+
});
|
|
50022
|
+
function createUpdatePlanTool(access) {
|
|
50023
|
+
return {
|
|
50024
|
+
name: "update_plan",
|
|
50025
|
+
group: "edit",
|
|
50026
|
+
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.",
|
|
50027
|
+
parametersSchema: updateParams,
|
|
50028
|
+
async preview(params) {
|
|
50029
|
+
const before = access.current() ?? "";
|
|
50030
|
+
return {
|
|
50031
|
+
kind: "diff",
|
|
50032
|
+
// Not a file. The approval UI labels the diff with this, and naming it for what it is
|
|
50033
|
+
// beats a made-up path that implies something on disk is about to change.
|
|
50034
|
+
path: "the plan for this conversation",
|
|
50035
|
+
before,
|
|
50036
|
+
after: params.plan.slice(0, PLAN_LIMIT).trim(),
|
|
50037
|
+
...params.reason !== void 0 && params.reason.trim().length > 0 ? { note: params.reason.trim() } : {}
|
|
50038
|
+
};
|
|
50039
|
+
},
|
|
50040
|
+
async execute(params) {
|
|
50041
|
+
const next = params.plan.slice(0, PLAN_LIMIT).trim();
|
|
50042
|
+
if (next.length === 0) {
|
|
50043
|
+
return { content: "A plan cannot be empty. To remove the plan, ask the user to clear it." };
|
|
50044
|
+
}
|
|
50045
|
+
await access.save(next);
|
|
50046
|
+
return {
|
|
50047
|
+
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."
|
|
50048
|
+
};
|
|
50049
|
+
}
|
|
50050
|
+
};
|
|
50051
|
+
}
|
|
50052
|
+
var progressParams = external_exports.object({
|
|
50053
|
+
checkpoint: external_exports.number().int().describe("The step number, as numbered in the plan you were given."),
|
|
50054
|
+
status: external_exports.enum(["active", "done"]).describe("`active` when you start the step, `done` when it is genuinely finished.")
|
|
50055
|
+
});
|
|
50056
|
+
function createPlanProgressTool(access) {
|
|
50057
|
+
return {
|
|
50058
|
+
name: "plan_progress",
|
|
50059
|
+
/*
|
|
50060
|
+
* Control flow, not an action: it records where you are and touches nothing else. Gating it
|
|
50061
|
+
* would mean an approval prompt between every step of every planned task, which nobody would
|
|
50062
|
+
* keep switched on for long.
|
|
50063
|
+
*/
|
|
50064
|
+
group: "always",
|
|
50065
|
+
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.",
|
|
50066
|
+
parametersSchema: progressParams,
|
|
50067
|
+
async execute(params) {
|
|
50068
|
+
const outcome = await access.mark(params.checkpoint, params.status);
|
|
50069
|
+
if (!outcome.ok)
|
|
50070
|
+
return { content: outcome.reason, isError: true };
|
|
50071
|
+
return { content: outcome.summary };
|
|
50072
|
+
}
|
|
50073
|
+
};
|
|
50074
|
+
}
|
|
50075
|
+
|
|
49529
50076
|
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
49530
50077
|
function isZ4Schema(s) {
|
|
49531
50078
|
const schema2 = s;
|
|
@@ -56775,6 +57322,8 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS)
|
|
|
56775
57322
|
|
|
56776
57323
|
// ../../packages/core/dist/agent/loop.js
|
|
56777
57324
|
var DEFAULT_MAX_ITERATIONS = 25;
|
|
57325
|
+
var BOOKKEEPING_TOOLS = /* @__PURE__ */ new Set(["plan_progress"]);
|
|
57326
|
+
var MAX_REFUNDED_STEPS = 20;
|
|
56778
57327
|
var MAX_CONSECUTIVE_MISTAKES = 3;
|
|
56779
57328
|
async function prepareModelMessages(conversation, provider, tools, options, events) {
|
|
56780
57329
|
const contextWindow = options.contextWindow ?? 0;
|
|
@@ -56956,6 +57505,7 @@ async function runWithTimeout(tool, params, context, options) {
|
|
|
56956
57505
|
async function runAgentTurn(provider, conversation, userMessage, toolRegistry, toolContext, events, options = {}) {
|
|
56957
57506
|
conversation.addUserMessage(userMessage, options.images);
|
|
56958
57507
|
const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
57508
|
+
let refunded = 0;
|
|
56959
57509
|
const mistakeCounts = /* @__PURE__ */ new Map();
|
|
56960
57510
|
let continueNudges = 0;
|
|
56961
57511
|
const mode = options.mode ?? CODE_MODE;
|
|
@@ -57025,6 +57575,10 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
57025
57575
|
events.onDone();
|
|
57026
57576
|
return;
|
|
57027
57577
|
}
|
|
57578
|
+
if (BOOKKEEPING_TOOLS.has(toolCall.name) && refunded < MAX_REFUNDED_STEPS) {
|
|
57579
|
+
refunded += 1;
|
|
57580
|
+
iteration -= 1;
|
|
57581
|
+
}
|
|
57028
57582
|
if (result.path !== void 0) {
|
|
57029
57583
|
if (result.isError === true) {
|
|
57030
57584
|
const count = (mistakeCounts.get(result.path) ?? 0) + 1;
|
|
@@ -60272,7 +60826,46 @@ ${preview.text}` } : {}
|
|
|
60272
60826
|
const ACTIVE_TASK_KEY = "lightCode.activeTaskId";
|
|
60273
60827
|
let activeTaskId = services.workspaceState.get(ACTIVE_TASK_KEY);
|
|
60274
60828
|
let activePlan;
|
|
60829
|
+
let activePlanProgress = {};
|
|
60275
60830
|
let activeTaskCreatedAt = Date.now();
|
|
60831
|
+
function planViews() {
|
|
60832
|
+
return checkpointViews(activePlan, activePlanProgress);
|
|
60833
|
+
}
|
|
60834
|
+
function postPlanProgress() {
|
|
60835
|
+
post({ type: "planProgress", checkpoints: planViews() });
|
|
60836
|
+
}
|
|
60837
|
+
async function applyPlan(next) {
|
|
60838
|
+
const trimmed = next?.slice(0, PLAN_LIMIT).trim();
|
|
60839
|
+
activePlan = trimmed !== void 0 && trimmed.length > 0 ? trimmed : void 0;
|
|
60840
|
+
activePlanProgress = pruneProgress(activePlan, activePlanProgress);
|
|
60841
|
+
await persistActiveTask();
|
|
60842
|
+
post({ type: "plan", plan: activePlan ?? "" });
|
|
60843
|
+
postPlanProgress();
|
|
60844
|
+
}
|
|
60845
|
+
const planAccess = {
|
|
60846
|
+
current: () => activePlan,
|
|
60847
|
+
save: async (nextPlan) => {
|
|
60848
|
+
await applyPlan(nextPlan);
|
|
60849
|
+
},
|
|
60850
|
+
mark: async (index, status) => {
|
|
60851
|
+
const updated = markCheckpoint(activePlan, activePlanProgress, index, status);
|
|
60852
|
+
if (updated === void 0) {
|
|
60853
|
+
const total = planViews().length;
|
|
60854
|
+
return {
|
|
60855
|
+
ok: false,
|
|
60856
|
+
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)}.`
|
|
60857
|
+
};
|
|
60858
|
+
}
|
|
60859
|
+
activePlanProgress = updated;
|
|
60860
|
+
await persistActiveTask();
|
|
60861
|
+
postPlanProgress();
|
|
60862
|
+
const views = planViews();
|
|
60863
|
+
return {
|
|
60864
|
+
ok: true,
|
|
60865
|
+
summary: `Step ${String(index)} is now ${status}. ${progressSummary(views)} steps complete.`
|
|
60866
|
+
};
|
|
60867
|
+
}
|
|
60868
|
+
};
|
|
60276
60869
|
async function setActiveTaskId(id) {
|
|
60277
60870
|
activeTaskId = id;
|
|
60278
60871
|
await services.workspaceState.set(ACTIVE_TASK_KEY, id);
|
|
@@ -60717,6 +61310,8 @@ ${preview.text}` } : {}
|
|
|
60717
61310
|
}
|
|
60718
61311
|
for (const tool of python.generatedTools())
|
|
60719
61312
|
combined.register(tool, { dispatchOnly: dispatcher });
|
|
61313
|
+
combined.register(createUpdatePlanTool(planAccess), { dispatchOnly: dispatcher });
|
|
61314
|
+
combined.register(createPlanProgressTool(planAccess), { dispatchOnly: dispatcher });
|
|
60720
61315
|
combined.register(createNotifyTool({
|
|
60721
61316
|
notify: (message3, level, details) => {
|
|
60722
61317
|
if (details !== void 0) {
|
|
@@ -60991,7 +61586,8 @@ ${preview.text}` } : {}
|
|
|
60991
61586
|
updatedAt: Date.now(),
|
|
60992
61587
|
messages,
|
|
60993
61588
|
resultHandles: truncationStore.spilledHandles(),
|
|
60994
|
-
...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {}
|
|
61589
|
+
...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {},
|
|
61590
|
+
...Object.keys(activePlanProgress).length > 0 ? { planProgress: activePlanProgress } : {}
|
|
60995
61591
|
};
|
|
60996
61592
|
try {
|
|
60997
61593
|
await taskStore.save(redactTask(task, await knownSecretValues()));
|
|
@@ -61020,9 +61616,11 @@ ${preview.text}` } : {}
|
|
|
61020
61616
|
activeTaskCreatedAt = task.createdAt;
|
|
61021
61617
|
truncationStore.startTask(task.resultHandles);
|
|
61022
61618
|
activePlan = task.plan;
|
|
61619
|
+
activePlanProgress = pruneProgress(activePlan, task.planProgress);
|
|
61023
61620
|
await setActiveTaskId(task.id);
|
|
61024
61621
|
post({ type: "taskRestored", taskId: task.id, entries: toTranscript(task.messages) });
|
|
61025
61622
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
61623
|
+
postPlanProgress();
|
|
61026
61624
|
await postTasks();
|
|
61027
61625
|
}
|
|
61028
61626
|
async function startNewTask() {
|
|
@@ -61033,9 +61631,11 @@ ${preview.text}` } : {}
|
|
|
61033
61631
|
activeTaskCreatedAt = Date.now();
|
|
61034
61632
|
truncationStore.startTask();
|
|
61035
61633
|
activePlan = void 0;
|
|
61634
|
+
activePlanProgress = {};
|
|
61036
61635
|
await setActiveTaskId(void 0);
|
|
61037
61636
|
post({ type: "taskRestored", taskId: void 0, entries: [] });
|
|
61038
61637
|
post({ type: "plan", plan: "" });
|
|
61638
|
+
postPlanProgress();
|
|
61039
61639
|
await postTasks();
|
|
61040
61640
|
}
|
|
61041
61641
|
async function deleteTask(id) {
|
|
@@ -61140,7 +61740,20 @@ ${preview.text}` } : {}
|
|
|
61140
61740
|
...(() => {
|
|
61141
61741
|
const parts = [];
|
|
61142
61742
|
if (activeMode.id === AGENT_TEAM_MODE.id) {
|
|
61143
|
-
parts.push(buildTeamGuidance(
|
|
61743
|
+
parts.push(buildTeamGuidance(
|
|
61744
|
+
// The whole team, not only the available ones: the roster names what is missing
|
|
61745
|
+
// as well as what is there, and it cannot do that from a pre-filtered list.
|
|
61746
|
+
cachedTeam,
|
|
61747
|
+
cachedTeamGuidance,
|
|
61748
|
+
cachedBudgetMatters,
|
|
61749
|
+
/*
|
|
61750
|
+
* Whether a plan already exists, which decides whether this mode is told to go
|
|
61751
|
+
* and make one. Passed rather than inferred from the prompt: the plan section is
|
|
61752
|
+
* assembled separately, and a mode guessing at whether it is there would be a
|
|
61753
|
+
* second reading of the same fact.
|
|
61754
|
+
*/
|
|
61755
|
+
activePlan !== void 0 && activePlan.trim().length > 0
|
|
61756
|
+
));
|
|
61144
61757
|
} else if (activeMode.guidance !== void 0 && (activeMode.requiresExpert !== true || expertCliInfo !== void 0)) {
|
|
61145
61758
|
parts.push(activeMode.guidance);
|
|
61146
61759
|
}
|
|
@@ -61314,8 +61927,14 @@ ${preview.text}` } : {}
|
|
|
61314
61927
|
cumulativeText = "";
|
|
61315
61928
|
cumulativeReasoning = "";
|
|
61316
61929
|
const consulting = consultationFromToolCall(toolCall.name, toolCall.arguments);
|
|
61317
|
-
if (consulting !== void 0)
|
|
61930
|
+
if (consulting !== void 0) {
|
|
61318
61931
|
informedBy = consulting;
|
|
61932
|
+
const attributed = attributeConsultation(activePlanProgress, consulting);
|
|
61933
|
+
if (attributed !== activePlanProgress) {
|
|
61934
|
+
activePlanProgress = attributed;
|
|
61935
|
+
postPlanProgress();
|
|
61936
|
+
}
|
|
61937
|
+
}
|
|
61319
61938
|
if (CONTROL_TOOLS.has(toolCall.name))
|
|
61320
61939
|
return;
|
|
61321
61940
|
if (chartFromToolCall(toolCall.name, toolCall.arguments) !== void 0)
|
|
@@ -63744,6 +64363,10 @@ ${preview.text}` } : {}
|
|
|
63744
64363
|
const prompt = buildAgentPrompt({
|
|
63745
64364
|
prompt: agent.prompt,
|
|
63746
64365
|
question: request.question,
|
|
64366
|
+
// Decides the preamble as well as whether tools are offered below, so the two can never
|
|
64367
|
+
// disagree — a specialist told it can read, and then given nothing to read with, wastes a
|
|
64368
|
+
// step discovering that.
|
|
64369
|
+
usesTools: agent.usesTools,
|
|
63747
64370
|
...request.files !== void 0 ? { files: request.files } : {},
|
|
63748
64371
|
/*
|
|
63749
64372
|
* What exists in this workspace.
|
|
@@ -63754,7 +64377,18 @@ ${preview.text}` } : {}
|
|
|
63754
64377
|
*/
|
|
63755
64378
|
briefing: buildAgentBriefing({
|
|
63756
64379
|
tools: agentBriefingTools?.() ?? [],
|
|
63757
|
-
skills
|
|
64380
|
+
skills,
|
|
64381
|
+
/*
|
|
64382
|
+
* Who else exists, so a plan cannot name a specialist nobody set up.
|
|
64383
|
+
*
|
|
64384
|
+
* Built here, above the `kind` branch, which is the point: the Claude CLI expert and a
|
|
64385
|
+
* provider-profile expert are given byte-identical briefings, so making a different model
|
|
64386
|
+
* the expert cannot change what it knows about the team. `briefing.test.ts` pins that,
|
|
64387
|
+
* because the two paths diverging is invisible until somebody switches expert and gets a
|
|
64388
|
+
* worse plan for no reason they could name.
|
|
64389
|
+
*/
|
|
64390
|
+
team: cachedTeam,
|
|
64391
|
+
self: agent.role
|
|
63758
64392
|
})
|
|
63759
64393
|
});
|
|
63760
64394
|
if (agent.kind === "cli") {
|
|
@@ -63781,7 +64415,7 @@ ${preview.text}` } : {}
|
|
|
63781
64415
|
throw new Error(`No profile "${agent.profileId ?? ""}" exists any more.`);
|
|
63782
64416
|
}
|
|
63783
64417
|
const provider = createChatProvider(profile, httpClient, authStrategyFor(config2, profile), logger);
|
|
63784
|
-
const readOnly = toolsForConsultation(agentBriefingTools?.() ?? []);
|
|
64418
|
+
const readOnly = agent.usesTools ? toolsForConsultation(agentBriefingTools?.() ?? []) : [];
|
|
63785
64419
|
const context = consultationContext?.();
|
|
63786
64420
|
const result = await runConsultation({
|
|
63787
64421
|
provider,
|
|
@@ -64543,12 +65177,12 @@ ${preview.text}` } : {}
|
|
|
64543
65177
|
} else if (message3.type === "requestExpert") {
|
|
64544
65178
|
void postExpert();
|
|
64545
65179
|
} else if (message3.type === "setPlan") {
|
|
64546
|
-
|
|
64547
|
-
activePlan = plan.length > 0 ? plan : void 0;
|
|
64548
|
-
void persistActiveTask();
|
|
64549
|
-
post({ type: "plan", plan: activePlan ?? "" });
|
|
65180
|
+
void applyPlan(message3.plan);
|
|
64550
65181
|
} else if (message3.type === "requestPlan") {
|
|
64551
65182
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
65183
|
+
postPlanProgress();
|
|
65184
|
+
} else if (message3.type === "requestPlanProgress") {
|
|
65185
|
+
postPlanProgress();
|
|
64552
65186
|
} else if (message3.type === "requestAgents") {
|
|
64553
65187
|
void postAgents();
|
|
64554
65188
|
} else if (message3.type === "setAgentRole") {
|
|
@@ -68707,7 +69341,7 @@ function respondJson(response, status, body) {
|
|
|
68707
69341
|
}
|
|
68708
69342
|
|
|
68709
69343
|
// src/cli.ts
|
|
68710
|
-
var VERSION = true ? "0.
|
|
69344
|
+
var VERSION = true ? "0.50.0" : "unknown (not a packaged build)";
|
|
68711
69345
|
var compat = installNodeCompat();
|
|
68712
69346
|
function lastMeaningfulLine(problem) {
|
|
68713
69347
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|