@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/server.js CHANGED
@@ -46881,6 +46881,14 @@ function merge2(single, many) {
46881
46881
  }
46882
46882
  return out;
46883
46883
  }
46884
+ function aliasFields(names) {
46885
+ const cleaned = merge2(void 0, names);
46886
+ const [primary, ...rest] = cleaned;
46887
+ return {
46888
+ primary,
46889
+ rest: rest.length > 0 ? rest : void 0
46890
+ };
46891
+ }
46884
46892
 
46885
46893
  // ../../packages/core/dist/tools/searchCodebase.js
46886
46894
  var paramsSchema6 = external_exports.object({
@@ -47056,16 +47064,44 @@ function toHit(match, self) {
47056
47064
  }
47057
47065
  async function searchTeamSkills(options, query, size = 5, signal) {
47058
47066
  const vector = await options.embedder.embed(query);
47059
- const matches = await options.searcher.searchByVector(options.collection, vector, {
47060
- size,
47061
- ...signal !== void 0 ? { signal } : {}
47062
- });
47063
- return matches.map((match) => toHit(match, options.owner));
47067
+ const tried = [];
47068
+ let firstError;
47069
+ for (const collection of options.collections) {
47070
+ tried.push(collection);
47071
+ let matches;
47072
+ try {
47073
+ matches = await options.searcher.searchByVector(collection, vector, {
47074
+ size,
47075
+ ...signal !== void 0 ? { signal } : {}
47076
+ });
47077
+ } catch (error51) {
47078
+ firstError ??= error51 instanceof Error ? error51 : new Error(String(error51));
47079
+ continue;
47080
+ }
47081
+ if (matches.length > 0) {
47082
+ return { hits: matches.map((match) => toHit(match, options.owner)), collection, tried };
47083
+ }
47084
+ }
47085
+ if (firstError !== void 0)
47086
+ throw firstError;
47087
+ return { hits: [], collection: void 0, tried };
47064
47088
  }
47065
47089
  async function findTeamSkillsNamed(options, name, signal) {
47066
- const candidates = await searchTeamSkills(options, name, 25, signal);
47067
47090
  const wanted = name.trim().toLowerCase();
47068
- return candidates.filter((hit) => hit.name.trim().toLowerCase() === wanted);
47091
+ const found = /* @__PURE__ */ new Map();
47092
+ for (const collection of options.collections) {
47093
+ let result;
47094
+ try {
47095
+ result = await searchTeamSkills({ ...options, collections: [collection] }, name, 25, signal);
47096
+ } catch {
47097
+ continue;
47098
+ }
47099
+ for (const hit of result.hits) {
47100
+ if (hit.name.trim().toLowerCase() === wanted)
47101
+ found.set(`${hit.owner ?? "?"}/${hit.name}`, hit);
47102
+ }
47103
+ }
47104
+ return [...found.values()];
47069
47105
  }
47070
47106
  function describeTeamSkillCollision(name, hits) {
47071
47107
  const others = hits.filter((hit) => !hit.isMine);
@@ -47081,11 +47117,13 @@ function describeTeamSkillCollision(name, hits) {
47081
47117
  " name and does not overwrite theirs."
47082
47118
  ].join("\n");
47083
47119
  }
47084
- function renderTeamSkillHits(hits, query) {
47120
+ function renderTeamSkillHits(found, query) {
47121
+ const { hits, collection, tried } = found;
47085
47122
  if (hits.length === 0) {
47086
47123
  return `No team skills match: ${query}
47087
- 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.`;
47124
+ ` + (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.";
47088
47125
  }
47126
+ 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;
47089
47127
  const rendered = hits.map((hit, position) => {
47090
47128
  const who = hit.isMine ? "yours" : hit.owner ?? "unknown owner";
47091
47129
  const where = hit.project === void 0 ? who : `${who} / ${hit.project}`;
@@ -47094,6 +47132,7 @@ ${hit.text}`;
47094
47132
  }).join("\n\n---\n\n");
47095
47133
  return [
47096
47134
  `${hits.length} team skill(s) matching: ${query}`,
47135
+ ...widened !== void 0 ? [widened] : [],
47097
47136
  'Anything not marked "yours" is a colleague\u2019s and has no file on this machine \u2014 the text',
47098
47137
  "above is the whole of it, so do not try to read_file it. To keep one, write your own copy",
47099
47138
  "with write_skill; that stores it under your name and leaves theirs alone.",
@@ -47136,24 +47175,27 @@ function createSearchTeamSkillsTool(options) {
47136
47175
  async execute(params) {
47137
47176
  const startedAt = Date.now();
47138
47177
  try {
47139
- const hits = await searchTeamSkills(options, params.query, params.size ?? 5);
47178
+ const found = await searchTeamSkills(options, params.query, params.size ?? 5);
47140
47179
  options.observer?.record({
47141
47180
  at: startedAt,
47142
47181
  source: "search_team_skills",
47182
+ // The one that answered, not the one that was asked first — the log is evidence about
47183
+ // what happened, and a widened search is exactly what somebody would want to see.
47184
+ collection: found.collection ?? found.tried.join(" \u2192 "),
47143
47185
  query: params.query,
47144
- collection: options.collection,
47145
- hits: hits.length,
47186
+ hits: found.hits.length,
47146
47187
  elapsedMs: Date.now() - startedAt,
47147
47188
  via: "index"
47148
47189
  });
47149
- return { content: renderTeamSkillHits(hits, params.query) };
47190
+ return { content: renderTeamSkillHits(found, params.query) };
47150
47191
  } catch (error51) {
47151
47192
  const message3 = error51 instanceof Error ? error51.message : String(error51);
47152
47193
  options.observer?.record({
47153
47194
  at: startedAt,
47154
47195
  source: "search_team_skills",
47155
47196
  query: params.query,
47156
- collection: options.collection,
47197
+ // Every name that would have been tried: the search failed before one could answer.
47198
+ collection: options.collections.join(" \u2192 "),
47157
47199
  hits: 0,
47158
47200
  elapsedMs: Date.now() - startedAt,
47159
47201
  error: message3
@@ -56133,6 +56175,7 @@ var McpConnection = class {
56133
56175
  if (transport instanceof StdioClientTransport) {
56134
56176
  this.attachStderr(transport);
56135
56177
  }
56178
+ this.onLog(await describeMcpRequest(this.config, this.secrets));
56136
56179
  try {
56137
56180
  await client.connect(transport);
56138
56181
  } catch (error51) {
@@ -56216,6 +56259,20 @@ function renderToolResult(result) {
56216
56259
  function describeError(error51) {
56217
56260
  return error51 instanceof Error ? error51.message : String(error51);
56218
56261
  }
56262
+ async function describeMcpRequest(config2, secrets) {
56263
+ if (isStdioServer(config2))
56264
+ return `Starting ${config2.command}`;
56265
+ const kind = config2.type ?? "streamable-http (no type set; SSE is the fallback)";
56266
+ let names;
56267
+ try {
56268
+ const resolved = await interpolateSecrets(config2.headers, secrets);
56269
+ names = Object.entries(resolved).map(([name, value]) => value.trim().length === 0 ? `${name} (EMPTY)` : name);
56270
+ } catch (error51) {
56271
+ return `Connecting to ${config2.url} as ${kind}; headers unresolved: ${describeError(error51)}`;
56272
+ }
56273
+ const headers = names.length === 0 ? "no headers configured" : `headers: ${names.join(", ")}`;
56274
+ return `Connecting to ${config2.url} as ${kind}; ${headers}`;
56275
+ }
56219
56276
 
56220
56277
  // ../../packages/core/dist/mcp/registry.js
56221
56278
  function adaptTool(serverName, toolName, description, inputSchema, call) {
@@ -58327,6 +58384,8 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS)
58327
58384
  var DEFAULT_MAX_ITERATIONS = 25;
58328
58385
  var BOOKKEEPING_TOOLS = /* @__PURE__ */ new Set(["plan_progress"]);
58329
58386
  var MAX_REFUNDED_STEPS = 20;
58387
+ var FORM_DISMISSED = "The user dismissed the form without answering.";
58388
+ var MAX_FORM_RESETS = 5;
58330
58389
  var MAX_CONSECUTIVE_MISTAKES = 3;
58331
58390
  async function prepareModelMessages(conversation, provider, tools, options, events) {
58332
58391
  const contextWindow = options.contextWindow ?? 0;
@@ -58509,6 +58568,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58509
58568
  conversation.addUserMessage(userMessage, options.images);
58510
58569
  const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
58511
58570
  let refunded = 0;
58571
+ let formResets = 0;
58512
58572
  const mistakeCounts = /* @__PURE__ */ new Map();
58513
58573
  let continueNudges = 0;
58514
58574
  const mode = options.mode ?? CODE_MODE;
@@ -58582,6 +58642,10 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58582
58642
  conversation.addUserMessage(message3);
58583
58643
  events.onQueuedMessageConsumed?.(message3);
58584
58644
  }
58645
+ if (queued.length > 0) {
58646
+ iteration = -1;
58647
+ refunded = 0;
58648
+ }
58585
58649
  if (toolCall.name === "attempt_completion" || toolCall.name === "ask_followup_question") {
58586
58650
  events.onDone();
58587
58651
  return;
@@ -58590,6 +58654,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58590
58654
  refunded += 1;
58591
58655
  iteration -= 1;
58592
58656
  }
58657
+ if (toolCall.name === "ask_user_form" && result.isError !== true && !result.content.startsWith(FORM_DISMISSED) && formResets < MAX_FORM_RESETS) {
58658
+ formResets += 1;
58659
+ iteration = -1;
58660
+ refunded = 0;
58661
+ }
58593
58662
  if (result.path !== void 0) {
58594
58663
  if (result.isError === true) {
58595
58664
  const count = (mistakeCounts.get(result.path) ?? 0) + 1;
@@ -58603,7 +58672,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58603
58672
  }
58604
58673
  }
58605
58674
  }
58606
- events.onError(`Stopped after ${maxIterations} steps in one turn. 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.`);
58675
+ 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.`);
58607
58676
  }
58608
58677
 
58609
58678
  // ../../packages/core/dist/host/bridge.js
@@ -63324,8 +63393,12 @@ ${direction}` : attachMentions(text, mentions);
63324
63393
  skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
63325
63394
  searcher: search.searcher,
63326
63395
  embedder,
63327
- // The first is the default circle, exactly as it is for the codebase index.
63328
- collection: skillAliases(config2)[0],
63396
+ /*
63397
+ * All of them, in order — the first is the ordinary circle and the rest are what a
63398
+ * search widens into when it holds nothing. Handing over only the first is what
63399
+ * made the extra names typed in the panel do nothing at all for skills.
63400
+ */
63401
+ collections: skillAliases(config2),
63329
63402
  ...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
63330
63403
  } : void 0,
63331
63404
  /*
@@ -64955,15 +65028,19 @@ ${direction}` : attachMentions(text, mentions);
64955
65028
  const digest = createHash3("sha256").update(path23.resolve(workspaceRoot).toLowerCase()).digest("hex").slice(0, 16);
64956
65029
  return `${config2?.embedder?.indexPrefix ?? DEFAULT_INDEX_PREFIX}-${digest}`;
64957
65030
  }
64958
- async function handleSaveSkillsAlias(alias) {
65031
+ async function handleSaveSkillsAlias(aliases) {
64959
65032
  try {
64960
65033
  const { config: config2 } = await configManager.load();
64961
- const trimmed = alias.trim();
64962
65034
  const embedder = { ...config2.embedder ?? {} };
64963
- if (trimmed.length > 0)
64964
- embedder.skillsAlias = trimmed;
65035
+ const { primary, rest } = aliasFields(aliases);
65036
+ if (primary !== void 0)
65037
+ embedder.skillsAlias = primary;
64965
65038
  else
64966
65039
  delete embedder.skillsAlias;
65040
+ if (rest !== void 0)
65041
+ embedder.skillsAliases = rest;
65042
+ else
65043
+ delete embedder.skillsAliases;
64967
65044
  await configManager.save("user", { embedder });
64968
65045
  const { config: next } = await configManager.load();
64969
65046
  await postEmbedder(next);
@@ -65685,26 +65762,50 @@ ${direction}` : attachMentions(text, mentions);
65685
65762
  // rather than replacing a blank with the default and looking like it was set.
65686
65763
  ...config2.embedder?.indexPrefix !== void 0 ? { indexPrefix: config2.embedder.indexPrefix } : {},
65687
65764
  ...config2.embedder?.indexAlias !== void 0 ? { indexAlias: config2.embedder.indexAlias } : {},
65765
+ /*
65766
+ * Both spellings of both, because the panel shows the merged list and cannot merge what it
65767
+ * was never sent. The singular halves stay for older configs and older builds; the panel
65768
+ * runs them through `codebaseAliases`/`skillAliases`, which is the one place that knows how
65769
+ * the two fit together.
65770
+ */
65771
+ ...config2.embedder?.indexAliases !== void 0 ? { indexAliases: config2.embedder.indexAliases } : {},
65772
+ ...config2.embedder?.skillsAliases !== void 0 ? { skillsAliases: config2.embedder.skillsAliases } : {},
65688
65773
  ...config2.embedder?.skillsAlias !== void 0 ? { skillsAlias: config2.embedder.skillsAlias } : {},
65689
65774
  defaultIndexPrefix: DEFAULT_INDEX_PREFIX,
65690
65775
  indexedFiles
65691
65776
  });
65692
65777
  }
65693
- async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAlias) {
65778
+ async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAliases) {
65694
65779
  try {
65695
- await configManager.save("user", {
65696
- embedder: {
65697
- profileId,
65698
- model,
65699
- dimensions,
65700
- ...indexName !== void 0 && indexName.trim().length > 0 ? { indexName: indexName.trim() } : {},
65701
- // Absent rather than empty when cleared, so the default applies instead of a name
65702
- // beginning with a stray dash.
65703
- ...indexPrefix !== void 0 && indexPrefix.trim().length > 0 ? { indexPrefix: indexPrefix.trim() } : {},
65704
- // Same treatment: cleared means absent, which is what turns team scope back off.
65705
- ...indexAlias !== void 0 && indexAlias.trim().length > 0 ? { indexAlias: indexAlias.trim() } : {}
65706
- }
65707
- });
65780
+ const { config: current } = await configManager.load();
65781
+ const embedder = {
65782
+ ...current.embedder ?? {},
65783
+ profileId,
65784
+ model,
65785
+ dimensions
65786
+ };
65787
+ const put = (key, value) => {
65788
+ if (value === void 0)
65789
+ return;
65790
+ if (value.trim().length > 0)
65791
+ embedder[key] = value.trim();
65792
+ else
65793
+ delete embedder[key];
65794
+ };
65795
+ put("indexName", indexName);
65796
+ put("indexPrefix", indexPrefix);
65797
+ if (indexAliases !== void 0) {
65798
+ const { primary, rest } = aliasFields(indexAliases);
65799
+ if (primary !== void 0)
65800
+ embedder["indexAlias"] = primary;
65801
+ else
65802
+ delete embedder["indexAlias"];
65803
+ if (rest !== void 0)
65804
+ embedder["indexAliases"] = rest;
65805
+ else
65806
+ delete embedder["indexAliases"];
65807
+ }
65808
+ await configManager.save("user", { embedder });
65708
65809
  const { config: config2 } = await configManager.load();
65709
65810
  await postEmbedder(config2);
65710
65811
  scheduleDocsReindex("index prefix changed");
@@ -66743,7 +66844,7 @@ ${direction}` : attachMentions(text, mentions);
66743
66844
  } else if (message3.type === "clearMailIndex") {
66744
66845
  void handleClearMailIndex(message3.resync === true);
66745
66846
  } else if (message3.type === "saveSkillsAlias") {
66746
- void handleSaveSkillsAlias(message3.alias);
66847
+ void handleSaveSkillsAlias(message3.aliases);
66747
66848
  } else if (message3.type === "cancelIndexing") {
66748
66849
  if (message3.kind === void 0) {
66749
66850
  indexingAbort?.abort();
@@ -66755,7 +66856,7 @@ ${direction}` : attachMentions(text, mentions);
66755
66856
  indexingAborts.get(message3.kind)?.abort();
66756
66857
  }
66757
66858
  } else if (message3.type === "saveEmbedder") {
66758
- void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAlias);
66859
+ void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAliases);
66759
66860
  } else if (message3.type === "requestEmbedderModels") {
66760
66861
  void handleRequestEmbedderModels(message3.profileId);
66761
66862
  } else if (message3.type === "openWalkthrough") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.70.0",
3
+ "version": "0.74.0",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",