@chosengeneration/light-code 0.70.0 → 0.74.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 +139 -38
- package/dist/client/client.js +37 -37
- package/dist/server.js +138 -37
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -47023,6 +47023,14 @@ function merge2(single, many) {
|
|
|
47023
47023
|
}
|
|
47024
47024
|
return out;
|
|
47025
47025
|
}
|
|
47026
|
+
function aliasFields(names) {
|
|
47027
|
+
const cleaned = merge2(void 0, names);
|
|
47028
|
+
const [primary, ...rest] = cleaned;
|
|
47029
|
+
return {
|
|
47030
|
+
primary,
|
|
47031
|
+
rest: rest.length > 0 ? rest : void 0
|
|
47032
|
+
};
|
|
47033
|
+
}
|
|
47026
47034
|
|
|
47027
47035
|
// ../../packages/core/dist/tools/searchCodebase.js
|
|
47028
47036
|
var paramsSchema6 = external_exports.object({
|
|
@@ -47198,16 +47206,44 @@ function toHit(match, self) {
|
|
|
47198
47206
|
}
|
|
47199
47207
|
async function searchTeamSkills(options, query, size = 5, signal) {
|
|
47200
47208
|
const vector = await options.embedder.embed(query);
|
|
47201
|
-
const
|
|
47202
|
-
|
|
47203
|
-
|
|
47204
|
-
|
|
47205
|
-
|
|
47209
|
+
const tried = [];
|
|
47210
|
+
let firstError;
|
|
47211
|
+
for (const collection of options.collections) {
|
|
47212
|
+
tried.push(collection);
|
|
47213
|
+
let matches;
|
|
47214
|
+
try {
|
|
47215
|
+
matches = await options.searcher.searchByVector(collection, vector, {
|
|
47216
|
+
size,
|
|
47217
|
+
...signal !== void 0 ? { signal } : {}
|
|
47218
|
+
});
|
|
47219
|
+
} catch (error51) {
|
|
47220
|
+
firstError ??= error51 instanceof Error ? error51 : new Error(String(error51));
|
|
47221
|
+
continue;
|
|
47222
|
+
}
|
|
47223
|
+
if (matches.length > 0) {
|
|
47224
|
+
return { hits: matches.map((match) => toHit(match, options.owner)), collection, tried };
|
|
47225
|
+
}
|
|
47226
|
+
}
|
|
47227
|
+
if (firstError !== void 0)
|
|
47228
|
+
throw firstError;
|
|
47229
|
+
return { hits: [], collection: void 0, tried };
|
|
47206
47230
|
}
|
|
47207
47231
|
async function findTeamSkillsNamed(options, name, signal) {
|
|
47208
|
-
const candidates = await searchTeamSkills(options, name, 25, signal);
|
|
47209
47232
|
const wanted = name.trim().toLowerCase();
|
|
47210
|
-
|
|
47233
|
+
const found = /* @__PURE__ */ new Map();
|
|
47234
|
+
for (const collection of options.collections) {
|
|
47235
|
+
let result;
|
|
47236
|
+
try {
|
|
47237
|
+
result = await searchTeamSkills({ ...options, collections: [collection] }, name, 25, signal);
|
|
47238
|
+
} catch {
|
|
47239
|
+
continue;
|
|
47240
|
+
}
|
|
47241
|
+
for (const hit of result.hits) {
|
|
47242
|
+
if (hit.name.trim().toLowerCase() === wanted)
|
|
47243
|
+
found.set(`${hit.owner ?? "?"}/${hit.name}`, hit);
|
|
47244
|
+
}
|
|
47245
|
+
}
|
|
47246
|
+
return [...found.values()];
|
|
47211
47247
|
}
|
|
47212
47248
|
function describeTeamSkillCollision(name, hits) {
|
|
47213
47249
|
const others = hits.filter((hit) => !hit.isMine);
|
|
@@ -47223,11 +47259,13 @@ function describeTeamSkillCollision(name, hits) {
|
|
|
47223
47259
|
" name and does not overwrite theirs."
|
|
47224
47260
|
].join("\n");
|
|
47225
47261
|
}
|
|
47226
|
-
function renderTeamSkillHits(
|
|
47262
|
+
function renderTeamSkillHits(found, query) {
|
|
47263
|
+
const { hits, collection, tried } = found;
|
|
47227
47264
|
if (hits.length === 0) {
|
|
47228
47265
|
return `No team skills match: ${query}
|
|
47229
|
-
Either nobody has written one, or the shared skills index has not been built yet (Settings \u2192 Skills). This does not mean the subject is undocumented
|
|
47266
|
+
` + (tried.length > 0 ? "Looked in " + tried.join(", ") + ". " : "") + "Either nobody has written one, or the shared skills index has not been built yet (Settings \u2192 Skills). This does not mean the subject is undocumented.";
|
|
47230
47267
|
}
|
|
47268
|
+
const widened = collection !== void 0 && tried.length > 1 && tried[0] !== collection ? "Nothing in " + tried.slice(0, tried.indexOf(collection)).join(", ") + "; these are from " + collection + "." : void 0;
|
|
47231
47269
|
const rendered = hits.map((hit, position) => {
|
|
47232
47270
|
const who = hit.isMine ? "yours" : hit.owner ?? "unknown owner";
|
|
47233
47271
|
const where = hit.project === void 0 ? who : `${who} / ${hit.project}`;
|
|
@@ -47236,6 +47274,7 @@ ${hit.text}`;
|
|
|
47236
47274
|
}).join("\n\n---\n\n");
|
|
47237
47275
|
return [
|
|
47238
47276
|
`${hits.length} team skill(s) matching: ${query}`,
|
|
47277
|
+
...widened !== void 0 ? [widened] : [],
|
|
47239
47278
|
'Anything not marked "yours" is a colleague\u2019s and has no file on this machine \u2014 the text',
|
|
47240
47279
|
"above is the whole of it, so do not try to read_file it. To keep one, write your own copy",
|
|
47241
47280
|
"with write_skill; that stores it under your name and leaves theirs alone.",
|
|
@@ -47278,24 +47317,27 @@ function createSearchTeamSkillsTool(options) {
|
|
|
47278
47317
|
async execute(params) {
|
|
47279
47318
|
const startedAt = Date.now();
|
|
47280
47319
|
try {
|
|
47281
|
-
const
|
|
47320
|
+
const found = await searchTeamSkills(options, params.query, params.size ?? 5);
|
|
47282
47321
|
options.observer?.record({
|
|
47283
47322
|
at: startedAt,
|
|
47284
47323
|
source: "search_team_skills",
|
|
47324
|
+
// The one that answered, not the one that was asked first — the log is evidence about
|
|
47325
|
+
// what happened, and a widened search is exactly what somebody would want to see.
|
|
47326
|
+
collection: found.collection ?? found.tried.join(" \u2192 "),
|
|
47285
47327
|
query: params.query,
|
|
47286
|
-
|
|
47287
|
-
hits: hits.length,
|
|
47328
|
+
hits: found.hits.length,
|
|
47288
47329
|
elapsedMs: Date.now() - startedAt,
|
|
47289
47330
|
via: "index"
|
|
47290
47331
|
});
|
|
47291
|
-
return { content: renderTeamSkillHits(
|
|
47332
|
+
return { content: renderTeamSkillHits(found, params.query) };
|
|
47292
47333
|
} catch (error51) {
|
|
47293
47334
|
const message3 = error51 instanceof Error ? error51.message : String(error51);
|
|
47294
47335
|
options.observer?.record({
|
|
47295
47336
|
at: startedAt,
|
|
47296
47337
|
source: "search_team_skills",
|
|
47297
47338
|
query: params.query,
|
|
47298
|
-
|
|
47339
|
+
// Every name that would have been tried: the search failed before one could answer.
|
|
47340
|
+
collection: options.collections.join(" \u2192 "),
|
|
47299
47341
|
hits: 0,
|
|
47300
47342
|
elapsedMs: Date.now() - startedAt,
|
|
47301
47343
|
error: message3
|
|
@@ -56275,6 +56317,7 @@ var McpConnection = class {
|
|
|
56275
56317
|
if (transport instanceof StdioClientTransport) {
|
|
56276
56318
|
this.attachStderr(transport);
|
|
56277
56319
|
}
|
|
56320
|
+
this.onLog(await describeMcpRequest(this.config, this.secrets));
|
|
56278
56321
|
try {
|
|
56279
56322
|
await client.connect(transport);
|
|
56280
56323
|
} catch (error51) {
|
|
@@ -56358,6 +56401,20 @@ function renderToolResult(result) {
|
|
|
56358
56401
|
function describeError(error51) {
|
|
56359
56402
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
56360
56403
|
}
|
|
56404
|
+
async function describeMcpRequest(config2, secrets) {
|
|
56405
|
+
if (isStdioServer(config2))
|
|
56406
|
+
return `Starting ${config2.command}`;
|
|
56407
|
+
const kind = config2.type ?? "streamable-http (no type set; SSE is the fallback)";
|
|
56408
|
+
let names;
|
|
56409
|
+
try {
|
|
56410
|
+
const resolved = await interpolateSecrets(config2.headers, secrets);
|
|
56411
|
+
names = Object.entries(resolved).map(([name, value]) => value.trim().length === 0 ? `${name} (EMPTY)` : name);
|
|
56412
|
+
} catch (error51) {
|
|
56413
|
+
return `Connecting to ${config2.url} as ${kind}; headers unresolved: ${describeError(error51)}`;
|
|
56414
|
+
}
|
|
56415
|
+
const headers = names.length === 0 ? "no headers configured" : `headers: ${names.join(", ")}`;
|
|
56416
|
+
return `Connecting to ${config2.url} as ${kind}; ${headers}`;
|
|
56417
|
+
}
|
|
56361
56418
|
|
|
56362
56419
|
// ../../packages/core/dist/mcp/registry.js
|
|
56363
56420
|
function adaptTool(serverName, toolName, description, inputSchema, call) {
|
|
@@ -58469,6 +58526,8 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS)
|
|
|
58469
58526
|
var DEFAULT_MAX_ITERATIONS = 25;
|
|
58470
58527
|
var BOOKKEEPING_TOOLS = /* @__PURE__ */ new Set(["plan_progress"]);
|
|
58471
58528
|
var MAX_REFUNDED_STEPS = 20;
|
|
58529
|
+
var FORM_DISMISSED = "The user dismissed the form without answering.";
|
|
58530
|
+
var MAX_FORM_RESETS = 5;
|
|
58472
58531
|
var MAX_CONSECUTIVE_MISTAKES = 3;
|
|
58473
58532
|
async function prepareModelMessages(conversation, provider, tools, options, events) {
|
|
58474
58533
|
const contextWindow = options.contextWindow ?? 0;
|
|
@@ -58651,6 +58710,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58651
58710
|
conversation.addUserMessage(userMessage, options.images);
|
|
58652
58711
|
const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
58653
58712
|
let refunded = 0;
|
|
58713
|
+
let formResets = 0;
|
|
58654
58714
|
const mistakeCounts = /* @__PURE__ */ new Map();
|
|
58655
58715
|
let continueNudges = 0;
|
|
58656
58716
|
const mode = options.mode ?? CODE_MODE;
|
|
@@ -58724,6 +58784,10 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58724
58784
|
conversation.addUserMessage(message3);
|
|
58725
58785
|
events.onQueuedMessageConsumed?.(message3);
|
|
58726
58786
|
}
|
|
58787
|
+
if (queued.length > 0) {
|
|
58788
|
+
iteration = -1;
|
|
58789
|
+
refunded = 0;
|
|
58790
|
+
}
|
|
58727
58791
|
if (toolCall.name === "attempt_completion" || toolCall.name === "ask_followup_question") {
|
|
58728
58792
|
events.onDone();
|
|
58729
58793
|
return;
|
|
@@ -58732,6 +58796,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58732
58796
|
refunded += 1;
|
|
58733
58797
|
iteration -= 1;
|
|
58734
58798
|
}
|
|
58799
|
+
if (toolCall.name === "ask_user_form" && result.isError !== true && !result.content.startsWith(FORM_DISMISSED) && formResets < MAX_FORM_RESETS) {
|
|
58800
|
+
formResets += 1;
|
|
58801
|
+
iteration = -1;
|
|
58802
|
+
refunded = 0;
|
|
58803
|
+
}
|
|
58735
58804
|
if (result.path !== void 0) {
|
|
58736
58805
|
if (result.isError === true) {
|
|
58737
58806
|
const count = (mistakeCounts.get(result.path) ?? 0) + 1;
|
|
@@ -58745,7 +58814,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58745
58814
|
}
|
|
58746
58815
|
}
|
|
58747
58816
|
}
|
|
58748
|
-
events.onError(`Stopped after ${maxIterations} steps
|
|
58817
|
+
events.onError(`Stopped after ${maxIterations} steps since your last message. Nothing is lost \u2014 send another message (for example "continue") to carry on from here. Raise the limit in Settings \u2192 Approvals if this task legitimately needs more.`);
|
|
58749
58818
|
}
|
|
58750
58819
|
|
|
58751
58820
|
// ../../packages/core/dist/host/bridge.js
|
|
@@ -63466,8 +63535,12 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63466
63535
|
skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
|
|
63467
63536
|
searcher: search.searcher,
|
|
63468
63537
|
embedder,
|
|
63469
|
-
|
|
63470
|
-
|
|
63538
|
+
/*
|
|
63539
|
+
* All of them, in order — the first is the ordinary circle and the rest are what a
|
|
63540
|
+
* search widens into when it holds nothing. Handing over only the first is what
|
|
63541
|
+
* made the extra names typed in the panel do nothing at all for skills.
|
|
63542
|
+
*/
|
|
63543
|
+
collections: skillAliases(config2),
|
|
63471
63544
|
...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
|
|
63472
63545
|
} : void 0,
|
|
63473
63546
|
/*
|
|
@@ -65097,15 +65170,19 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
65097
65170
|
const digest = createHash3("sha256").update(path24.resolve(workspaceRoot).toLowerCase()).digest("hex").slice(0, 16);
|
|
65098
65171
|
return `${config2?.embedder?.indexPrefix ?? DEFAULT_INDEX_PREFIX}-${digest}`;
|
|
65099
65172
|
}
|
|
65100
|
-
async function handleSaveSkillsAlias(
|
|
65173
|
+
async function handleSaveSkillsAlias(aliases) {
|
|
65101
65174
|
try {
|
|
65102
65175
|
const { config: config2 } = await configManager.load();
|
|
65103
|
-
const trimmed = alias.trim();
|
|
65104
65176
|
const embedder = { ...config2.embedder ?? {} };
|
|
65105
|
-
|
|
65106
|
-
|
|
65177
|
+
const { primary, rest } = aliasFields(aliases);
|
|
65178
|
+
if (primary !== void 0)
|
|
65179
|
+
embedder.skillsAlias = primary;
|
|
65107
65180
|
else
|
|
65108
65181
|
delete embedder.skillsAlias;
|
|
65182
|
+
if (rest !== void 0)
|
|
65183
|
+
embedder.skillsAliases = rest;
|
|
65184
|
+
else
|
|
65185
|
+
delete embedder.skillsAliases;
|
|
65109
65186
|
await configManager.save("user", { embedder });
|
|
65110
65187
|
const { config: next } = await configManager.load();
|
|
65111
65188
|
await postEmbedder(next);
|
|
@@ -65827,26 +65904,50 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
65827
65904
|
// rather than replacing a blank with the default and looking like it was set.
|
|
65828
65905
|
...config2.embedder?.indexPrefix !== void 0 ? { indexPrefix: config2.embedder.indexPrefix } : {},
|
|
65829
65906
|
...config2.embedder?.indexAlias !== void 0 ? { indexAlias: config2.embedder.indexAlias } : {},
|
|
65907
|
+
/*
|
|
65908
|
+
* Both spellings of both, because the panel shows the merged list and cannot merge what it
|
|
65909
|
+
* was never sent. The singular halves stay for older configs and older builds; the panel
|
|
65910
|
+
* runs them through `codebaseAliases`/`skillAliases`, which is the one place that knows how
|
|
65911
|
+
* the two fit together.
|
|
65912
|
+
*/
|
|
65913
|
+
...config2.embedder?.indexAliases !== void 0 ? { indexAliases: config2.embedder.indexAliases } : {},
|
|
65914
|
+
...config2.embedder?.skillsAliases !== void 0 ? { skillsAliases: config2.embedder.skillsAliases } : {},
|
|
65830
65915
|
...config2.embedder?.skillsAlias !== void 0 ? { skillsAlias: config2.embedder.skillsAlias } : {},
|
|
65831
65916
|
defaultIndexPrefix: DEFAULT_INDEX_PREFIX,
|
|
65832
65917
|
indexedFiles
|
|
65833
65918
|
});
|
|
65834
65919
|
}
|
|
65835
|
-
async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix,
|
|
65920
|
+
async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAliases) {
|
|
65836
65921
|
try {
|
|
65837
|
-
await configManager.
|
|
65838
|
-
|
|
65839
|
-
|
|
65840
|
-
|
|
65841
|
-
|
|
65842
|
-
|
|
65843
|
-
|
|
65844
|
-
|
|
65845
|
-
|
|
65846
|
-
|
|
65847
|
-
|
|
65848
|
-
|
|
65849
|
-
|
|
65922
|
+
const { config: current } = await configManager.load();
|
|
65923
|
+
const embedder = {
|
|
65924
|
+
...current.embedder ?? {},
|
|
65925
|
+
profileId,
|
|
65926
|
+
model,
|
|
65927
|
+
dimensions
|
|
65928
|
+
};
|
|
65929
|
+
const put = (key, value) => {
|
|
65930
|
+
if (value === void 0)
|
|
65931
|
+
return;
|
|
65932
|
+
if (value.trim().length > 0)
|
|
65933
|
+
embedder[key] = value.trim();
|
|
65934
|
+
else
|
|
65935
|
+
delete embedder[key];
|
|
65936
|
+
};
|
|
65937
|
+
put("indexName", indexName);
|
|
65938
|
+
put("indexPrefix", indexPrefix);
|
|
65939
|
+
if (indexAliases !== void 0) {
|
|
65940
|
+
const { primary, rest } = aliasFields(indexAliases);
|
|
65941
|
+
if (primary !== void 0)
|
|
65942
|
+
embedder["indexAlias"] = primary;
|
|
65943
|
+
else
|
|
65944
|
+
delete embedder["indexAlias"];
|
|
65945
|
+
if (rest !== void 0)
|
|
65946
|
+
embedder["indexAliases"] = rest;
|
|
65947
|
+
else
|
|
65948
|
+
delete embedder["indexAliases"];
|
|
65949
|
+
}
|
|
65950
|
+
await configManager.save("user", { embedder });
|
|
65850
65951
|
const { config: config2 } = await configManager.load();
|
|
65851
65952
|
await postEmbedder(config2);
|
|
65852
65953
|
scheduleDocsReindex("index prefix changed");
|
|
@@ -66885,7 +66986,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66885
66986
|
} else if (message3.type === "clearMailIndex") {
|
|
66886
66987
|
void handleClearMailIndex(message3.resync === true);
|
|
66887
66988
|
} else if (message3.type === "saveSkillsAlias") {
|
|
66888
|
-
void handleSaveSkillsAlias(message3.
|
|
66989
|
+
void handleSaveSkillsAlias(message3.aliases);
|
|
66889
66990
|
} else if (message3.type === "cancelIndexing") {
|
|
66890
66991
|
if (message3.kind === void 0) {
|
|
66891
66992
|
indexingAbort?.abort();
|
|
@@ -66897,7 +66998,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66897
66998
|
indexingAborts.get(message3.kind)?.abort();
|
|
66898
66999
|
}
|
|
66899
67000
|
} else if (message3.type === "saveEmbedder") {
|
|
66900
|
-
void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.
|
|
67001
|
+
void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAliases);
|
|
66901
67002
|
} else if (message3.type === "requestEmbedderModels") {
|
|
66902
67003
|
void handleRequestEmbedderModels(message3.profileId);
|
|
66903
67004
|
} else if (message3.type === "openWalkthrough") {
|
|
@@ -71733,7 +71834,7 @@ function respondJson(response, status, body) {
|
|
|
71733
71834
|
}
|
|
71734
71835
|
|
|
71735
71836
|
// src/cli.ts
|
|
71736
|
-
var VERSION = true ? "0.
|
|
71837
|
+
var VERSION = true ? "0.74.0" : "unknown (not a packaged build)";
|
|
71737
71838
|
var compat = installNodeCompat();
|
|
71738
71839
|
function lastMeaningfulLine(problem) {
|
|
71739
71840
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|