@chosengeneration/light-code 0.151.0 → 0.155.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.
Files changed (3) hide show
  1. package/dist/cli.cjs +415 -69
  2. package/dist/server.cjs +406 -66
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -13963,11 +13963,11 @@ var require_util4 = __commonJS({
13963
13963
  dataURL += serializeAMimeType(parsed);
13964
13964
  }
13965
13965
  dataURL += ";base64,";
13966
- const decoder = new StringDecoder2("latin1");
13966
+ const decoder2 = new StringDecoder2("latin1");
13967
13967
  for (const chunk of bytes) {
13968
- dataURL += btoa2(decoder.write(chunk));
13968
+ dataURL += btoa2(decoder2.write(chunk));
13969
13969
  }
13970
- dataURL += btoa2(decoder.end());
13970
+ dataURL += btoa2(decoder2.end());
13971
13971
  return dataURL;
13972
13972
  }
13973
13973
  case "Text": {
@@ -13992,11 +13992,11 @@ var require_util4 = __commonJS({
13992
13992
  }
13993
13993
  case "BinaryString": {
13994
13994
  let binaryString = "";
13995
- const decoder = new StringDecoder2("latin1");
13995
+ const decoder2 = new StringDecoder2("latin1");
13996
13996
  for (const chunk of bytes) {
13997
- binaryString += decoder.write(chunk);
13997
+ binaryString += decoder2.write(chunk);
13998
13998
  }
13999
- binaryString += decoder.end();
13999
+ binaryString += decoder2.end();
14000
14000
  return binaryString;
14001
14001
  }
14002
14002
  }
@@ -43275,7 +43275,7 @@ function* completedToolCalls(accumulators) {
43275
43275
  }
43276
43276
  async function* parseSseStream(body, url2, signal, logger) {
43277
43277
  const reader = body.getReader();
43278
- const decoder = new TextDecoder();
43278
+ const decoder2 = new TextDecoder();
43279
43279
  let buffer = "";
43280
43280
  const thinking = new ThinkTagSplitter();
43281
43281
  const toolCallAccumulators = /* @__PURE__ */ new Map();
@@ -43284,7 +43284,7 @@ async function* parseSseStream(body, url2, signal, logger) {
43284
43284
  const { done, value } = await reader.read();
43285
43285
  if (done)
43286
43286
  break;
43287
- buffer += decoder.decode(value, { stream: true });
43287
+ buffer += decoder2.decode(value, { stream: true });
43288
43288
  const lines2 = buffer.split("\n");
43289
43289
  buffer = lines2.pop() ?? "";
43290
43290
  for (const line of lines2) {
@@ -43483,7 +43483,7 @@ function safeParseArguments(raw) {
43483
43483
  }
43484
43484
  async function* parseAnthropicStream(body, url2, signal, logger) {
43485
43485
  const reader = body.getReader();
43486
- const decoder = new TextDecoder();
43486
+ const decoder2 = new TextDecoder();
43487
43487
  let buffer = "";
43488
43488
  const toolUses = /* @__PURE__ */ new Map();
43489
43489
  const completed = [];
@@ -43492,7 +43492,7 @@ async function* parseAnthropicStream(body, url2, signal, logger) {
43492
43492
  const { done, value } = await reader.read();
43493
43493
  if (done)
43494
43494
  break;
43495
- buffer += decoder.decode(value, { stream: true });
43495
+ buffer += decoder2.decode(value, { stream: true });
43496
43496
  const lines2 = buffer.split("\n");
43497
43497
  buffer = lines2.pop() ?? "";
43498
43498
  for (const line of lines2) {
@@ -43722,7 +43722,7 @@ function safeParseArguments2(raw) {
43722
43722
  }
43723
43723
  async function* parseGeminiStream(body, url2, signal) {
43724
43724
  const reader = body.getReader();
43725
- const decoder = new TextDecoder();
43725
+ const decoder2 = new TextDecoder();
43726
43726
  let buffer = "";
43727
43727
  const toolCalls = [];
43728
43728
  try {
@@ -43730,7 +43730,7 @@ async function* parseGeminiStream(body, url2, signal) {
43730
43730
  const { done, value } = await reader.read();
43731
43731
  if (done)
43732
43732
  break;
43733
- buffer += decoder.decode(value, { stream: true });
43733
+ buffer += decoder2.decode(value, { stream: true });
43734
43734
  const lines2 = buffer.split("\n");
43735
43735
  buffer = lines2.pop() ?? "";
43736
43736
  for (const line of lines2) {
@@ -52689,8 +52689,8 @@ async function readTail(fs42, path62, size, count3) {
52689
52689
  let start;
52690
52690
  for (; ; ) {
52691
52691
  start = Math.max(0, size - span);
52692
- const decoder = new import_node_string_decoder.StringDecoder("utf8");
52693
- text2 = decoder.write(await fs42.readBytesSlice(path62, start, size)) + decoder.end();
52692
+ const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
52693
+ text2 = decoder2.write(await fs42.readBytesSlice(path62, start, size)) + decoder2.end();
52694
52694
  const enough = text2.split("\n").length > count3;
52695
52695
  if (enough || start === 0 || span >= size)
52696
52696
  break;
@@ -52709,7 +52709,7 @@ async function readTail(fs42, path62, size, count3) {
52709
52709
  };
52710
52710
  }
52711
52711
  async function readLineWindow(fs42, path62, size, from, count3) {
52712
- const decoder = new import_node_string_decoder.StringDecoder("utf8");
52712
+ const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
52713
52713
  const lines2 = [];
52714
52714
  let pending = "";
52715
52715
  let lineNumber = 1;
@@ -52723,7 +52723,7 @@ async function readLineWindow(fs42, path62, size, from, count3) {
52723
52723
  };
52724
52724
  scan: while (position < size) {
52725
52725
  const end = Math.min(size, position + CHUNK);
52726
- pending += decoder.write(await fs42.readBytesSlice(path62, position, end));
52726
+ pending += decoder2.write(await fs42.readBytesSlice(path62, position, end));
52727
52727
  position = end;
52728
52728
  const parts = pending.split(/\r\n|\r|\n/);
52729
52729
  pending = parts.pop() ?? "";
@@ -52735,7 +52735,7 @@ async function readLineWindow(fs42, path62, size, from, count3) {
52735
52735
  }
52736
52736
  }
52737
52737
  if (reachedEnd) {
52738
- pending += decoder.end();
52738
+ pending += decoder2.end();
52739
52739
  if (pending.length > 0)
52740
52740
  take(pending);
52741
52741
  }
@@ -57137,11 +57137,11 @@ var EventSource = class extends EventTarget {
57137
57137
  __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status2), this.close();
57138
57138
  return;
57139
57139
  }
57140
- const decoder = new TextDecoder(), reader = body.getReader();
57140
+ const decoder2 = new TextDecoder(), reader = body.getReader();
57141
57141
  let open = true;
57142
57142
  do {
57143
57143
  const { done, value } = await reader.read();
57144
- value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
57144
+ value && __privateGet(this, _parser).feed(decoder2.decode(value, { stream: !done })), done && (open = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
57145
57145
  } while (open);
57146
57146
  }), __privateAdd(this, _onFetchError, (err) => {
57147
57147
  __privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError2(err));
@@ -60152,11 +60152,29 @@ async function listSkillFiles(skillFilePath, fs42) {
60152
60152
  }
60153
60153
 
60154
60154
  // ../../packages/core/dist/skills/tools.js
60155
+ async function folderFor(context, name, audience) {
60156
+ const personal = context.personalSkillsDir;
60157
+ if (audience === "me") {
60158
+ if (personal === void 0)
60159
+ throw new Error("Keeping a skill to yourself is not available here (a shared server has no personal folder).");
60160
+ return { dir: personal, personal: true };
60161
+ }
60162
+ if (audience === "team" || personal === void 0)
60163
+ return { dir: context.skillsDir, personal: false };
60164
+ const there = await exists(import_node_path24.default.join(personal, skillFileName(name))) || await exists(import_node_path24.default.join(personal, name, "SKILL.md"));
60165
+ return there ? { dir: personal, personal: true } : { dir: context.skillsDir, personal: false };
60166
+ }
60167
+ function audienceNote(context, personal) {
60168
+ if (context.personalSkillsDir === void 0)
60169
+ return void 0;
60170
+ return personal ? "For: only you - kept in your personal skills on this computer, used in every project, never uploaded or committed" : `For: the team - ${context.sharedWith?.() ?? "saved in this project"}`;
60171
+ }
60155
60172
  var MAX_SKILL_IMAGES = 12;
60156
60173
  var writeParams = external_exports.object({
60157
60174
  name: external_exports.string().describe('Short kebab-case identifier, e.g. "internal-http-client". Becomes the filename.'),
60158
60175
  description: external_exports.string().describe("One line, and the only part loaded into every future conversation \u2014 so write it as the trigger for reading the skill: what subject it covers, not what it says."),
60159
60176
  body: external_exports.string().describe("The markdown content. Be concrete: package names, import paths, function signatures, a short example. This is read only when relevant, so length costs nothing."),
60177
+ audience: external_exports.enum(["me", "team"]).optional().describe('Who the skill is for. "me": kept only for this user, on this computer, in every project - never shared. "team": saved where the team shares skills. For a NEW skill, if the user has not said, ask them first (ask_user_form, a choice of "Only me" or "The team") - never guess. Omit when updating: the skill stays where it is.'),
60160
60178
  images: external_exports.array(external_exports.object({
60161
60179
  source: external_exports.string().min(1).describe("The picture as it is now, relative to the workspace root."),
60162
60180
  name: external_exports.string().optional().describe("What to call it inside the skill. Defaults to the source file name."),
@@ -60288,11 +60306,14 @@ function createWriteSkillTool(context) {
60288
60306
  description: "Record durable knowledge about this workspace so it survives into future conversations \u2014 internal libraries and how to use them, project conventions, in-house APIs, anything you were told once and would otherwise have to be told again. Creates or replaces the skill of that name; send the whole body, not a patch. Only the description is loaded into future prompts, so the cost of a long body is nothing. The user approves the exact text before it is written.",
60289
60307
  parametersSchema: writeParams,
60290
60308
  async preview(params3) {
60291
- const filePath = await resolveSkillPath(context.skillsDir, params3.name);
60309
+ const target = await folderFor(context, params3.name, params3.audience);
60310
+ const filePath = await resolveSkillPath(target.dir, params3.name);
60292
60311
  const before = await readIfPresent(filePath);
60312
+ const note = audienceNote(context, target.personal);
60293
60313
  return {
60294
60314
  kind: "diff",
60295
60315
  path: filePath,
60316
+ ...note !== void 0 ? { note } : {},
60296
60317
  before,
60297
60318
  // Rendered here, so the diff is exactly the bytes that get written rather than an
60298
60319
  // approximation of them.
@@ -60307,7 +60328,8 @@ function createWriteSkillTool(context) {
60307
60328
  async execute(params3, toolContext) {
60308
60329
  try {
60309
60330
  const wantsFolder = (params3.images ?? []).length > 0 || (params3.files ?? []).length > 0;
60310
- const filePath = await resolveSkillPath(context.skillsDir, params3.name, wantsFolder);
60331
+ const target = await folderFor(context, params3.name, params3.audience);
60332
+ const filePath = await resolveSkillPath(target.dir, params3.name, wantsFolder);
60311
60333
  const before = await readIfPresent(filePath);
60312
60334
  const existed = before.length > 0;
60313
60335
  const stored = wantsFolder && context.submitForReview === void 0 ? await copySkillImages(import_node_path24.default.dirname(filePath), params3.images ?? [], toolContext) : plannedImages(params3);
@@ -60324,15 +60346,15 @@ function createWriteSkillTool(context) {
60324
60346
  }
60325
60347
  await import_promises11.default.writeFile(filePath, rendered, "utf8");
60326
60348
  if (wantsFolder) {
60327
- const flat = import_node_path24.default.join(context.skillsDir, skillFileName(params3.name));
60349
+ const flat = import_node_path24.default.join(target.dir, skillFileName(params3.name));
60328
60350
  if (await exists(flat))
60329
60351
  await import_promises11.default.rm(flat).catch(() => void 0);
60330
60352
  }
60331
60353
  await context.onChanged();
60332
60354
  let publishProblem;
60333
- if (context.onSaved !== void 0) {
60355
+ if (context.onSaved !== void 0 && !target.personal) {
60334
60356
  try {
60335
- await context.onSaved(params3.name, rendered, import_node_path24.default.relative(context.skillsDir, filePath).split(import_node_path24.default.sep).join("/"));
60357
+ await context.onSaved(params3.name, rendered, import_node_path24.default.relative(target.dir, filePath).split(import_node_path24.default.sep).join("/"));
60336
60358
  } catch (error51) {
60337
60359
  publishProblem = error51 instanceof Error ? error51.message : String(error51);
60338
60360
  }
@@ -60425,6 +60447,14 @@ function createUseSkillFileTool(context) {
60425
60447
  }
60426
60448
  };
60427
60449
  }
60450
+ async function deletableFolder(context, name) {
60451
+ const has2 = async (dir) => await exists(import_node_path24.default.join(dir, skillFileName(name))) || await exists(import_node_path24.default.join(dir, name, "SKILL.md"));
60452
+ if (await has2(context.skillsDir))
60453
+ return context.skillsDir;
60454
+ if (context.personalSkillsDir !== void 0 && await has2(context.personalSkillsDir))
60455
+ return context.personalSkillsDir;
60456
+ return context.skillsDir;
60457
+ }
60428
60458
  function createDeleteSkillTool(context) {
60429
60459
  return {
60430
60460
  name: "delete_skill",
@@ -60432,16 +60462,17 @@ function createDeleteSkillTool(context) {
60432
60462
  description: "Remove a recorded skill.",
60433
60463
  parametersSchema: deleteParams,
60434
60464
  async preview(params3) {
60435
- const filePath = await resolveSkillPath(context.skillsDir, params3.name);
60465
+ const filePath = await resolveSkillPath(await deletableFolder(context, params3.name), params3.name);
60436
60466
  return { kind: "diff", path: filePath, before: await readIfPresent(filePath), after: "" };
60437
60467
  },
60438
60468
  async execute(params3) {
60439
60469
  try {
60440
- const filePath = await resolveSkillPath(context.skillsDir, params3.name);
60470
+ const root = await deletableFolder(context, params3.name);
60471
+ const filePath = await resolveSkillPath(root, params3.name);
60441
60472
  const folder = import_node_path24.default.dirname(filePath);
60442
- const isFolderSkill = import_node_path24.default.resolve(folder) !== import_node_path24.default.resolve(context.skillsDir);
60473
+ const isFolderSkill = import_node_path24.default.resolve(folder) !== import_node_path24.default.resolve(root);
60443
60474
  if (isFolderSkill) {
60444
- await import_promises11.default.rm(await confine(folder, context.skillsDir), { recursive: true, force: true });
60475
+ await import_promises11.default.rm(await confine(folder, root), { recursive: true, force: true });
60445
60476
  } else {
60446
60477
  await import_promises11.default.rm(filePath, { force: true });
60447
60478
  }
@@ -61271,12 +61302,34 @@ function isInstallableRequirement(requirement) {
61271
61302
  }
61272
61303
 
61273
61304
  // ../../packages/core/dist/python/tools.js
61305
+ var audienceParam = external_exports.enum(["me", "team"]).optional().describe('Who the tool is for. "me": kept only for this user, on this computer, in every project - never shared. "team": saved where the team shares tools. For a NEW tool, if the user has not said, ask them first (ask_user_form, a choice of "Only me" or "The team") - never guess. Omit when updating: the tool stays where it is.');
61306
+ function toolFolder(context, name, audience) {
61307
+ const personal = context.personalToolsDir;
61308
+ if (audience === "me") {
61309
+ if (personal === void 0)
61310
+ throw new Error("Keeping a tool to yourself is not available here (a shared server has no personal folder).");
61311
+ return { dir: personal, personal: true };
61312
+ }
61313
+ if (audience === void 0 && personal !== void 0) {
61314
+ const existing = context.findTool?.(name);
61315
+ if (existing !== void 0 && import_node_path26.default.resolve(existing.sourceDir) === import_node_path26.default.resolve(personal))
61316
+ return { dir: personal, personal: true };
61317
+ }
61318
+ return { dir: context.toolsDir, personal: false };
61319
+ }
61320
+ function toolAudienceNote(context, personal) {
61321
+ if (context.personalToolsDir === void 0)
61322
+ return void 0;
61323
+ return personal ? "For: only you - kept in your personal tools on this computer, used in every project, never uploaded or committed" : "For: the team - " + (context.sharedWith?.() ?? "saved in this project");
61324
+ }
61274
61325
  var createParams = external_exports.object({
61275
61326
  name: external_exports.string().describe("Tool name: lowercase letters, digits and underscores. Becomes py__<name> and <name>.py."),
61327
+ audience: audienceParam,
61276
61328
  source: external_exports.string().describe("The complete Python file. Must define `run`. Use type hints \u2014 the parameter schema is derived from them. The module docstring becomes the tool description; document parameters in a Google-style Args: block. Declare dependencies in a PEP 723 inline block if you need any. Read a host, account or token from os.environ rather than writing it into the file \u2014 the user sets those once in Settings \u2192 Python and every tool gets them. Say which variable you expect if it is not already set.")
61277
61329
  });
61278
61330
  var specifyParams = external_exports.object({
61279
61331
  name: external_exports.string().describe("Tool name: lowercase letters, digits and underscores. Becomes py__<name> and <name>.py."),
61332
+ audience: audienceParam,
61280
61333
  specification: external_exports.string().describe("What the tool must do, in prose. A model configured for code writes the file from this; you do not write Python here. Say what it takes, what it returns, and any library or endpoint it must use. The user approves the generated source before anything runs.")
61281
61334
  });
61282
61335
  var deleteParams2 = external_exports.object({
@@ -61306,7 +61359,7 @@ function makeWriteTool(context, options) {
61306
61359
  const key2 = `${params3.name}::${params3.specification}`;
61307
61360
  let inFlight = pending.get(key2);
61308
61361
  if (inFlight === void 0) {
61309
- const toolPath = resolveToolPath2(context.toolsDir, params3.name);
61362
+ const toolPath = resolveToolPath2(toolFolder(context, params3.name, params3.audience).dir, params3.name);
61310
61363
  inFlight = (async () => {
61311
61364
  const before = await readIfPresent2(await toolPath);
61312
61365
  const generated = await generator({
@@ -61345,7 +61398,8 @@ function makeWriteTool(context, options) {
61345
61398
  * later hashed, so what was reviewed is what can run.
61346
61399
  */
61347
61400
  async preview(params3) {
61348
- const filePath = await resolveToolPath2(context.toolsDir, params3.name);
61401
+ const target = toolFolder(context, params3.name, params3.audience);
61402
+ const filePath = await resolveToolPath2(target.dir, params3.name);
61349
61403
  const before = await readIfPresent2(filePath);
61350
61404
  const generated = await sourceFor(params3);
61351
61405
  const source = label(params3.name, generated.source, before);
@@ -61354,7 +61408,8 @@ function makeWriteTool(context, options) {
61354
61408
  const notes = [
61355
61409
  ...producedBy !== void 0 ? [`Written by ${producedBy}`] : [],
61356
61410
  ...reads.length > 0 ? [`Reads saved credentials: ${reads.join(", ")}`] : [],
61357
- ...declaresAlwaysAsk(source) ? ["Always asks before every run, for everyone who has this tool (__always_ask__ = True)"] : []
61411
+ ...declaresAlwaysAsk(source) ? ["Always asks before every run, for everyone who has this tool (__always_ask__ = True)"] : [],
61412
+ ...[toolAudienceNote(context, target.personal)].filter((note) => note !== void 0)
61358
61413
  ];
61359
61414
  return {
61360
61415
  kind: "diff",
@@ -61366,7 +61421,8 @@ function makeWriteTool(context, options) {
61366
61421
  },
61367
61422
  async execute(params3) {
61368
61423
  try {
61369
- const filePath = await resolveToolPath2(context.toolsDir, params3.name);
61424
+ const target = toolFolder(context, params3.name, params3.audience);
61425
+ const filePath = await resolveToolPath2(target.dir, params3.name);
61370
61426
  const before = await readIfPresent2(filePath);
61371
61427
  if (options.mustExist && before.length === 0) {
61372
61428
  return {
@@ -61393,7 +61449,7 @@ function makeWriteTool(context, options) {
61393
61449
  })
61394
61450
  };
61395
61451
  }
61396
- await import_promises13.default.mkdir(context.toolsDir, { recursive: true });
61452
+ await import_promises13.default.mkdir(target.dir, { recursive: true });
61397
61453
  await import_promises13.default.writeFile(filePath, source, "utf8");
61398
61454
  const restore = async () => {
61399
61455
  if (before.length > 0)
@@ -61443,10 +61499,10 @@ ${outcome.reject}`, isError: true };
61443
61499
  }
61444
61500
  verifyWarning = outcome?.warn;
61445
61501
  }
61446
- await approveTool(context.toolsDir, params3.name, source, described);
61502
+ await approveTool(target.dir, params3.name, source, described);
61447
61503
  await context.onChanged();
61448
61504
  let publishProblem;
61449
- if (context.onSaved !== void 0) {
61505
+ if (context.onSaved !== void 0 && !target.personal) {
61450
61506
  try {
61451
61507
  await context.onSaved(params3.name, source);
61452
61508
  } catch (error51) {
@@ -61534,6 +61590,13 @@ function createInstallPackagesTool(context) {
61534
61590
  }
61535
61591
  };
61536
61592
  }
61593
+ function deletableToolFolder(context, name) {
61594
+ const existing = context.findTool?.(name);
61595
+ const personal = context.personalToolsDir;
61596
+ if (existing !== void 0 && personal !== void 0 && import_node_path26.default.resolve(existing.sourceDir) === import_node_path26.default.resolve(personal))
61597
+ return personal;
61598
+ return context.toolsDir;
61599
+ }
61537
61600
  function createDeletePythonTool(context) {
61538
61601
  return {
61539
61602
  name: "delete_python_tool",
@@ -61541,21 +61604,22 @@ function createDeletePythonTool(context) {
61541
61604
  description: "Remove a Python tool and its registration.",
61542
61605
  parametersSchema: deleteParams2,
61543
61606
  async preview(params3) {
61544
- const filePath = await resolveToolPath2(context.toolsDir, params3.name);
61607
+ const filePath = await resolveToolPath2(deletableToolFolder(context, params3.name), params3.name);
61545
61608
  return { kind: "diff", path: filePath, before: await readIfPresent2(filePath), after: "" };
61546
61609
  },
61547
61610
  async execute(params3) {
61548
61611
  try {
61549
61612
  const existing = context.findTool?.(params3.name);
61550
- if (existing !== void 0 && import_node_path26.default.resolve(existing.sourceDir) !== import_node_path26.default.resolve(context.toolsDir)) {
61613
+ const own = deletableToolFolder(context, params3.name);
61614
+ if (existing !== void 0 && import_node_path26.default.resolve(existing.sourceDir) !== import_node_path26.default.resolve(own)) {
61551
61615
  return {
61552
61616
  content: `py__${params3.name} lives in ${existing.sourceDir}, which is a read-only tools folder. Delete it where it is published, or remove the folder in Settings.`,
61553
61617
  isError: true
61554
61618
  };
61555
61619
  }
61556
- const filePath = await resolveToolPath2(context.toolsDir, params3.name);
61620
+ const filePath = await resolveToolPath2(own, params3.name);
61557
61621
  await import_promises13.default.rm(filePath, { force: true });
61558
- await forgetTool(context.toolsDir, params3.name);
61622
+ await forgetTool(own, params3.name);
61559
61623
  await context.onChanged();
61560
61624
  return { content: `Removed py__${params3.name}.`, path: filePath };
61561
61625
  } catch (error51) {
@@ -62024,6 +62088,8 @@ var PythonManager = class {
62024
62088
  findTool: (name) => this.findTool(name),
62025
62089
  ...this.options.onToolSaved !== void 0 ? { onSaved: this.options.onToolSaved } : {},
62026
62090
  ...this.options.attribution !== void 0 ? { attribution: this.options.attribution } : {},
62091
+ ...this.options.personalToolsDir !== void 0 ? { personalToolsDir: this.options.personalToolsDir } : {},
62092
+ ...this.options.sharedWith !== void 0 ? { sharedWith: this.options.sharedWith } : {},
62027
62093
  /*
62028
62094
  * No installing against an interpreter we do not own.
62029
62095
  *
@@ -63003,7 +63069,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
63003
63069
  if (streamError !== void 0 && assistantText.length === 0 && toolCall === void 0 && options.autoCompact === false && isContextOverflow(streamError)) {
63004
63070
  events.onError(`${streamError}
63005
63071
 
63006
- The conversation is longer than this model accepts. Press **Compact now** under the token bar to summarise the older part (the saved transcript keeps everything), then send again - or tick "Compact automatically" there to have this done for you. Starting a new chat with + also works.`);
63072
+ The conversation is longer than this model accepts. Press **Compact now** under the token bar to summarise the older part (the saved transcript keeps everything), then send again - or tick "Compact automatically" there to have this done for you. Or press **New chat with a handoff** (beside + at the top): the assistant writes up this chat - goal, decisions, what is done, next steps - and a new chat starts from it, a clean start that keeps the thread.`);
63007
63073
  return;
63008
63074
  }
63009
63075
  if (streamError !== void 0 && assistantText.length === 0 && toolCall === void 0 && !compactedForOverflow && options.compactionEnabled !== false && isContextOverflow(streamError)) {
@@ -63019,7 +63085,7 @@ The conversation is longer than this model accepts. Press **Compact now** under
63019
63085
  }
63020
63086
  events.onError(`${streamError}
63021
63087
 
63022
- The conversation is longer than this model accepts, and it could not be shortened enough (the most recent messages, or one very large tool result, are too big on their own). Start a new chat with +, or choose a model with a larger context window.`);
63088
+ The conversation is longer than this model accepts, and it could not be shortened enough (the most recent messages, or one very large tool result, are too big on their own). Press **New chat with a handoff** (beside + at the top): the assistant writes up this chat and a new chat starts from it, so the work carries on. Or start an empty chat with +, or choose a model with a larger context window.`);
63023
63089
  return;
63024
63090
  }
63025
63091
  if (streamError !== void 0) {
@@ -72708,7 +72774,7 @@ ${text2.slice(-2e4)}`);
72708
72774
  const text2 = await response.text();
72709
72775
  return { text: text2.slice(-options.tailBytes), totalBytes: text2.length, truncated: text2.length > options.tailBytes };
72710
72776
  }
72711
- const decoder = new TextDecoder();
72777
+ const decoder2 = new TextDecoder();
72712
72778
  let totalBytes = 0;
72713
72779
  let tail = "";
72714
72780
  let partial2 = "";
@@ -72748,7 +72814,7 @@ ${text2.slice(-2e4)}`);
72748
72814
  if (done)
72749
72815
  break;
72750
72816
  totalBytes += value.byteLength;
72751
- const chunk = decoder.decode(value, { stream: true });
72817
+ const chunk = decoder2.decode(value, { stream: true });
72752
72818
  if (options.pattern === void 0) {
72753
72819
  tail = (tail + chunk).slice(-options.tailBytes);
72754
72820
  } else {
@@ -74620,7 +74686,23 @@ var import_node_crypto15 = require("node:crypto");
74620
74686
  var import_promises25 = __toESM(require("node:fs/promises"), 1);
74621
74687
  var import_node_path45 = __toESM(require("node:path"), 1);
74622
74688
  var TEAM_REPO_STATE_FILE = ".lightcode-teamrepo.json";
74623
- var hash2 = (bytes) => (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
74689
+ var decoder = new TextDecoder("utf-8", { fatal: true });
74690
+ function contentHash(bytes) {
74691
+ let text2;
74692
+ if (!bytes.includes(0)) {
74693
+ try {
74694
+ text2 = decoder.decode(bytes);
74695
+ } catch {
74696
+ text2 = void 0;
74697
+ }
74698
+ }
74699
+ const digest = (0, import_node_crypto15.createHash)("sha256");
74700
+ if (text2 === void 0)
74701
+ return digest.update(bytes).digest("hex");
74702
+ return digest.update(text2.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n").replace(/\s+$/, "")).digest("hex");
74703
+ }
74704
+ var hash2 = contentHash;
74705
+ var rawHash = (bytes) => (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
74624
74706
  function repoPathFor(folder, kind, relative) {
74625
74707
  const base = folder.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
74626
74708
  return [base, kind, relative.replace(/\\/g, "/")].filter((part) => part.length > 0).join("/");
@@ -74640,14 +74722,32 @@ function classifyRepoPath(folder, repoPath) {
74640
74722
  }
74641
74723
  return void 0;
74642
74724
  }
74643
- async function readState(file2) {
74725
+ async function readState(file2, mirrorFile) {
74644
74726
  try {
74645
74727
  const parsed = JSON.parse(await import_promises25.default.readFile(file2, "utf8"));
74646
- if (parsed.version === 1)
74647
- return { version: 1, files: parsed.files ?? {}, pushed: parsed.pushed ?? {}, ...parsed.head !== void 0 ? { head: parsed.head } : {} };
74728
+ const head = parsed.head !== void 0 ? { head: parsed.head } : {};
74729
+ if (parsed.version === 2) {
74730
+ return { version: 2, files: parsed.files ?? {}, pushed: parsed.pushed ?? {}, ...head, ...parsed.released !== void 0 ? { released: parsed.released } : {} };
74731
+ }
74732
+ if (parsed.version === 1) {
74733
+ const files = {};
74734
+ const pushed = {};
74735
+ for (const [repoPath, entry] of Object.entries(parsed.files ?? {})) {
74736
+ const local = mirrorFile(repoPath);
74737
+ if (local === void 0)
74738
+ continue;
74739
+ const bytes = await import_promises25.default.readFile(local).catch(() => void 0);
74740
+ if (bytes === void 0 || rawHash(bytes) !== entry.hash)
74741
+ continue;
74742
+ files[repoPath] = { commit: entry.commit, hash: contentHash(bytes) };
74743
+ if (parsed.pushed?.[repoPath] === entry.hash)
74744
+ pushed[repoPath] = contentHash(bytes);
74745
+ }
74746
+ return { version: 2, files, pushed, ...head };
74747
+ }
74648
74748
  } catch {
74649
74749
  }
74650
- return { version: 1, files: {}, pushed: {} };
74750
+ return { version: 2, files: {}, pushed: {} };
74651
74751
  }
74652
74752
  async function writeWhole2(file2, bytes) {
74653
74753
  await import_promises25.default.mkdir(import_node_path45.default.dirname(file2), { recursive: true });
@@ -74683,9 +74783,12 @@ async function localFiles(dir, kind) {
74683
74783
  }
74684
74784
  async function syncTeamRepo(options) {
74685
74785
  const { api, branch, folder } = options;
74686
- const state = await readState(options.stateFile);
74687
- const report = { branch, pulled: [], removed: [], pushed: [], conflicts: [], deletedHere: [] };
74688
74786
  const mirrorFile = (kind, relative) => import_node_path45.default.join(options.mirror[kind], ...relative.split("/"));
74787
+ const state = await readState(options.stateFile, (repoPath) => {
74788
+ const target = classifyRepoPath(folder, repoPath);
74789
+ return target === void 0 ? void 0 : mirrorFile(target.kind, target.relative);
74790
+ });
74791
+ const report = { branch, pulled: [], removed: [], pushed: [], conflicts: [], behind: [], deletedHere: [] };
74689
74792
  let head = await api.branchHead(branch);
74690
74793
  if (head !== void 0 && head !== state.head) {
74691
74794
  const changed = state.head !== void 0 ? await api.changes(state.head, head) : (await api.listFiles(folder.replace(/^\/+|\/+$/g, ""), head)).map((relative) => ({
@@ -74772,6 +74875,9 @@ async function syncTeamRepo(options) {
74772
74875
  }
74773
74876
  } else if (known.hash === state.pushed[repoPath]) {
74774
74877
  sourceCommitId = known.commit;
74878
+ } else if (mine === state.pushed[repoPath]) {
74879
+ report.behind.push(repoPath);
74880
+ continue;
74775
74881
  } else {
74776
74882
  report.conflicts.push({
74777
74883
  path: repoPath,
@@ -74808,8 +74914,22 @@ async function syncTeamRepo(options) {
74808
74914
  });
74809
74915
  }
74810
74916
  }
74917
+ const released = new Set(state.released ?? []);
74918
+ for (const repoPath of [...released]) {
74919
+ if (present2.has(repoPath))
74920
+ released.delete(repoPath);
74921
+ else {
74922
+ const known = state.files[repoPath];
74923
+ if (known !== void 0)
74924
+ state.pushed[repoPath] = known.hash;
74925
+ }
74926
+ }
74927
+ if (released.size > 0)
74928
+ state.released = [...released].sort();
74929
+ else
74930
+ delete state.released;
74811
74931
  for (const repoPath of Object.keys(state.pushed)) {
74812
- if (!present2.has(repoPath) && state.files[repoPath] !== void 0)
74932
+ if (!present2.has(repoPath) && !released.has(repoPath) && state.files[repoPath] !== void 0)
74813
74933
  report.deletedHere.push(repoPath);
74814
74934
  }
74815
74935
  }
@@ -74817,6 +74937,44 @@ async function syncTeamRepo(options) {
74817
74937
  await writeWhole2(options.stateFile, JSON.stringify(state, null, 1));
74818
74938
  return report;
74819
74939
  }
74940
+ async function checkCoverage(options) {
74941
+ const { folder } = options;
74942
+ const state = await readState(options.stateFile, (repoPath) => {
74943
+ const target = classifyRepoPath(folder, repoPath);
74944
+ return target === void 0 ? void 0 : import_node_path45.default.join(options.mirror[target.kind], ...target.relative.split("/"));
74945
+ });
74946
+ const covered = { skills: 0, tools: 0 };
74947
+ const problems = [];
74948
+ const repoPaths = [];
74949
+ for (const kind of ["skills", "tools"]) {
74950
+ for (const dir of new Set(options.dirs[kind].map((entry) => import_node_path45.default.resolve(entry)))) {
74951
+ for (const entry of await localFiles(dir, kind)) {
74952
+ const repoPath = repoPathFor(folder, kind, entry.relative);
74953
+ const mine = hash2(new Uint8Array(await import_promises25.default.readFile(entry.file)));
74954
+ const known = state.files[repoPath];
74955
+ if (known === void 0)
74956
+ problems.push(`${entry.file} - not in the repository yet`);
74957
+ else if (known.hash !== mine && state.pushed[repoPath] !== mine)
74958
+ problems.push(`${entry.file} - differs from the repository's copy`);
74959
+ else {
74960
+ covered[kind] += 1;
74961
+ repoPaths.push(repoPath);
74962
+ }
74963
+ }
74964
+ }
74965
+ }
74966
+ return { covered, problems, repoPaths: [...new Set(repoPaths)] };
74967
+ }
74968
+ async function releaseFromRecord(stateFile, repoPaths) {
74969
+ let parsed;
74970
+ try {
74971
+ parsed = JSON.parse(await import_promises25.default.readFile(stateFile, "utf8"));
74972
+ } catch {
74973
+ return;
74974
+ }
74975
+ parsed.released = [.../* @__PURE__ */ new Set([...parsed.released ?? [], ...repoPaths])].sort();
74976
+ await writeWhole2(stateFile, JSON.stringify(parsed, null, 1));
74977
+ }
74820
74978
 
74821
74979
  // ../../packages/core/dist/platform/httpTrace.js
74822
74980
  var SECRET_NAME = /secret|password|passwd|token|api[-_]?key|assertion|credential|session|signature|cookie/i;
@@ -78923,6 +79081,8 @@ function wireChatBridge(services) {
78923
79081
  const { transport, secrets, ui, workspaceRoot, storageDir } = services;
78924
79082
  const machineApprovals = services.machineApprovalsFile !== void 0 ? new FileMachineApprovals(services.machineApprovalsFile) : void 0;
78925
79083
  const mirrorRoot = services.mirrorRoot ?? storageDir;
79084
+ const personalSkillsDir = services.personalDir !== void 0 ? import_node_path51.default.join(services.personalDir, "skills") : void 0;
79085
+ const personalToolsDir = services.personalDir !== void 0 ? import_node_path51.default.join(services.personalDir, "tools") : void 0;
78926
79086
  const logger = new Logger({ level: "debug", sink: services.logSink });
78927
79087
  let fastFsOps;
78928
79088
  if (services.fastFs !== void 0) {
@@ -78949,6 +79109,7 @@ function wireChatBridge(services) {
78949
79109
  const python = new PythonManager({
78950
79110
  workspaceRoot,
78951
79111
  storageDir,
79112
+ ...personalToolsDir !== void 0 ? { personalToolsDir, sharedWith: () => sharedWith("tools") } : {},
78952
79113
  ...services.codebaseDir !== void 0 ? { venvRoot: services.codebaseDir } : {},
78953
79114
  logger,
78954
79115
  // Fire Code: one review per tool's code on this machine, however many codebases hold it.
@@ -79170,6 +79331,7 @@ ${preview.text}` } : {}
79170
79331
  ...files.length > 0 ? { files } : {},
79171
79332
  ...skill.sourceDir !== void 0 ? { sourceDir: skill.sourceDir } : {},
79172
79333
  ...placeholders.length > 0 ? { placeholders } : {},
79334
+ ...isPersonalSkill(skill) ? { personal: true } : {},
79173
79335
  ...skill.always === true ? { always: true } : {},
79174
79336
  ...skill.author !== void 0 ? { author: skill.author } : {},
79175
79337
  ...skill.project !== void 0 ? { project: skill.project } : {},
@@ -79185,7 +79347,7 @@ ${preview.text}` } : {}
79185
79347
  issues: skillIssues,
79186
79348
  ...skillsDir !== void 0 ? { skillsDir } : {},
79187
79349
  extraDirs: extraSkillDirs,
79188
- keepPrivate: skillsConfig.teamSkills?.keepPrivate ?? [],
79350
+ keepPrivate: [.../* @__PURE__ */ new Set([...skillsConfig.teamSkills?.keepPrivate ?? [], ...skills.filter(isPersonalSkill).map((skill) => skill.name)])],
79189
79351
  skillDefaults: skillsConfig.skillDefaults ?? {}
79190
79352
  });
79191
79353
  scheduleDocsReindex("skills changed");
@@ -79385,13 +79547,16 @@ ${preview.text}` } : {}
79385
79547
  }
79386
79548
  function pythonFolders(config2) {
79387
79549
  const configured = config2.python?.toolsDir?.trim();
79388
- const publish = configured !== void 0 && configured.length > 0 ? void 0 : publishFolder("tools", config2.s3?.tools ?? []);
79550
+ const chosen = configured !== void 0 && configured.length > 0;
79551
+ const team = chosen ? void 0 : teamRepoPlan(config2);
79552
+ const publish = chosen ? void 0 : publishFolder("tools", config2.s3?.tools ?? []) ?? (team !== void 0 && "own" in team ? team.own.tools : void 0);
79553
+ const personal = personalToolsDir !== void 0 ? [personalToolsDir] : [];
79389
79554
  if (publish === void 0)
79390
- return { extraToolDirs: mirroredToolsDirs };
79555
+ return { extraToolDirs: [...personal, ...mirroredToolsDirs] };
79391
79556
  const local = localToolsDir(config2);
79392
79557
  return {
79393
79558
  toolsDir: publish,
79394
- extraToolDirs: [...local !== void 0 ? [local] : [], ...mirroredToolsDirs.filter((dir) => !samePath(dir, publish))]
79559
+ extraToolDirs: [...personal, ...local !== void 0 ? [local] : [], ...mirroredToolsDirs.filter((dir) => !samePath(dir, publish))]
79395
79560
  };
79396
79561
  }
79397
79562
  function noFolderMessage(kind) {
@@ -79736,10 +79901,12 @@ ${preview.text}` } : {}
79736
79901
  if (!isValidSkillName(name))
79737
79902
  throw new Error(`"${name}" is not a valid skill name.`);
79738
79903
  const existing = skills.find((skill) => skill.name === name);
79739
- if (existing !== void 0 && existing.sourceDir !== void 0 && existing.sourceDir !== skillsDir) {
79904
+ if (existing !== void 0 && existing.sourceDir !== void 0 && existing.sourceDir !== skillsDir && // The user's own skills are theirs to delete.
79905
+ !samePath(existing.sourceDir, personalSkillsDir)) {
79740
79906
  throw new Error(`"${name}" lives in ${existing.sourceDir}, which is a read-only skills folder. Delete the file there, or remove the folder in Settings.`);
79741
79907
  }
79742
- await import_promises28.default.rm(import_node_path51.default.join(skillsDir, skillFileName(name)), { force: true });
79908
+ const from = existing?.sourceDir !== void 0 && samePath(existing.sourceDir, personalSkillsDir) ? existing.sourceDir : skillsDir;
79909
+ await import_promises28.default.rm(import_node_path51.default.join(from, skillFileName(name)), { force: true });
79743
79910
  await postSkills();
79744
79911
  } catch (error51) {
79745
79912
  post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
@@ -80363,10 +80530,17 @@ ${preview.text}` } : {}
80363
80530
  ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
80364
80531
  }));
80365
80532
  const team = teamRepoPlan(config2);
80533
+ cachedTeamRepoLabel = "dirs" in team ? `${team.settings.project}/${team.settings.repo} (${team.settings.branch})` : void 0;
80366
80534
  if ("dirs" in team) {
80367
80535
  extraSkillDirs.push(team.dirs.skills);
80368
80536
  mirroredToolsDirs.push(team.dirs.tools);
80537
+ if (config2.skills?.dir === void 0 && publishSkills === void 0) {
80538
+ skillsDir = team.own.skills;
80539
+ extraSkillDirs.unshift(...localSkillsDir !== void 0 ? [localSkillsDir] : []);
80540
+ }
80369
80541
  }
80542
+ if (personalSkillsDir !== void 0)
80543
+ extraSkillDirs.unshift(personalSkillsDir);
80370
80544
  return config2;
80371
80545
  }
80372
80546
  function announceConfigRecovery() {
@@ -80679,6 +80853,8 @@ ${preview.text}` } : {}
80679
80853
  skillsDir,
80680
80854
  onChanged: refreshSkills,
80681
80855
  attribution: () => cachedAttribution,
80856
+ // "Only me": the user's own skills, never shared. Absent on a shared server.
80857
+ ...personalSkillsDir !== void 0 ? { personalSkillsDir, sharedWith: () => sharedWith("skills") } : {},
80682
80858
  /*
80683
80859
  * Every loaded skill, so `use_skill_file` can reach a template in a read-only shared
80684
80860
  * folder. A closure over the live array rather than a copy: the folders are watched, and
@@ -81662,6 +81838,15 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
81662
81838
  // read_file must reach them without asking, or the rest of a cut-off file is out of reach.
81663
81839
  readRoots: [
81664
81840
  ...cachedReadRoots,
81841
+ /*
81842
+ * Every folder skills and Python tools load from. A skill's body is read with read_file, and
81843
+ * skills outside the project - S3 bucket folders, the team repository's copy and the folder new
81844
+ * ones are saved in while it is on - were outside every root: VS Code asked to read each one, and
81845
+ * Fire Code refused them as inside its own data folder. Reading only; they are written through
81846
+ * write_skill and the Python tools, which ask with the content shown.
81847
+ */
81848
+ ...skillSearchPath(),
81849
+ ...python.toolDirectories(),
81665
81850
  ...(services.siblings ?? []).map((s) => s.path),
81666
81851
  droppedFilesRoot2,
81667
81852
  mailAttachmentsRoot2,
@@ -84096,7 +84281,13 @@ ${redact(shown2, cachedSecretValues)}` }
84096
84281
  return { reason: "Enter the project key and repository slug." };
84097
84282
  const digest = (0, import_node_crypto16.createHash)("sha256").update(JSON.stringify([bitbucket.baseUrl, settings.project, settings.repo, settings.branch, settings.folder]).toLowerCase()).digest("hex").slice(0, 12);
84098
84283
  const root = import_node_path51.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
84099
- return { dirs: { skills: import_node_path51.default.join(root, "skills"), tools: import_node_path51.default.join(root, "tools") }, stateFile: import_node_path51.default.join(root, TEAM_REPO_STATE_FILE), settings };
84284
+ return {
84285
+ dirs: { skills: import_node_path51.default.join(root, "skills"), tools: import_node_path51.default.join(root, "tools") },
84286
+ // Where new skills and tools are saved while the repository is on - see loadSettings and pythonFolders.
84287
+ own: { skills: import_node_path51.default.join(root, "saved-here", "skills"), tools: import_node_path51.default.join(root, "saved-here", "tools") },
84288
+ stateFile: import_node_path51.default.join(root, TEAM_REPO_STATE_FILE),
84289
+ settings
84290
+ };
84100
84291
  }
84101
84292
  let teamRepoStatus;
84102
84293
  let teamRepoSyncing = false;
@@ -84113,9 +84304,114 @@ ${redact(shown2, cachedSecretValues)}` }
84113
84304
  ..."reason" in plan2 ? { reason: plan2.reason } : {},
84114
84305
  ...teamRepoStatus !== void 0 ? { status: teamRepoStatus } : {},
84115
84306
  syncing: teamRepoSyncing,
84116
- ...saveError !== void 0 ? { saveError } : {}
84307
+ ...saveError !== void 0 ? { saveError } : {},
84308
+ bucketFolders: bucketFolderLabels(config2),
84309
+ // Where new skills and tools land while it is on - outside the project, unless a folder was chosen.
84310
+ ..."dirs" in plan2 ? { savedIn: { ...skillsDir !== void 0 ? { skills: skillsDir } : {}, ...(pythonFolders(config2).toolsDir ?? localToolsDir(config2)) !== void 0 ? { tools: pythonFolders(config2).toolsDir ?? localToolsDir(config2) } : {} } } : {},
84311
+ ...teamRepoRetire !== void 0 ? { retire: teamRepoRetire } : {}
84117
84312
  });
84118
84313
  }
84314
+ let cachedTeamRepoLabel;
84315
+ function sharedWith(kind) {
84316
+ const mirrors = kind === "skills" ? cachedSkillMirrors : cachedToolMirrors;
84317
+ const publish = mirrors.find((mirror) => mirror.enabled === true && mirror.publish === true);
84318
+ const bucket = publish !== void 0 ? targetById(cachedS3, publish.connectionId) : void 0;
84319
+ const parts = [
84320
+ ...bucket !== void 0 && bucket.readOnly !== true ? [`uploaded to the S3 bucket ${bucket.label}${publish?.prefix !== void 0 ? ` / ${publish.prefix}` : ""}`] : [],
84321
+ ...cachedTeamRepoLabel !== void 0 ? [`committed to the team repository ${cachedTeamRepoLabel}`] : []
84322
+ ];
84323
+ return parts.length > 0 ? parts.join(", and ") : "saved in this project's folder - no team sharing is set up, so nobody else gets it yet";
84324
+ }
84325
+ function isPersonalSkill(skill) {
84326
+ if (personalSkillsDir === void 0)
84327
+ return false;
84328
+ const norm2 = (value) => process.platform === "win32" ? import_node_path51.default.resolve(value).toLowerCase() : import_node_path51.default.resolve(value);
84329
+ return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path51.default.sep);
84330
+ }
84331
+ function bucketFolderLabels(config2) {
84332
+ const label = (kind, mirror) => {
84333
+ const name = targetById(cachedS3, mirror.connectionId)?.label ?? mirror.connectionId;
84334
+ return `${kind}: ${name}${mirror.prefix !== void 0 ? ` / ${mirror.prefix}` : ""}`;
84335
+ };
84336
+ return [
84337
+ ...(config2.s3?.skills ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => label("Skills", mirror)),
84338
+ ...(config2.s3?.tools ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => label("Tools", mirror))
84339
+ ];
84340
+ }
84341
+ let teamRepoRetire;
84342
+ async function handleRetireS3Buckets(confirm) {
84343
+ const config2 = await loadSettings();
84344
+ const plan2 = teamRepoPlan(config2);
84345
+ const folders = bucketFolderLabels(config2);
84346
+ const refuse = async (problems) => {
84347
+ teamRepoRetire = { ready: false, folders, covered: { skills: 0, tools: 0 }, problems };
84348
+ await postTeamRepo();
84349
+ };
84350
+ if ("reason" in plan2)
84351
+ return refuse([`The team repository is not set up: ${plan2.reason}`]);
84352
+ if (folders.length === 0)
84353
+ return refuse(["No S3 bucket folders are switched on for skills or tools."]);
84354
+ teamRepoRetire = { ready: false, folders, covered: { skills: 0, tools: 0 }, problems: [], checking: true };
84355
+ await postTeamRepo();
84356
+ await Promise.all([handleSyncS3("skills"), handleSyncS3("tools")]).catch(() => void 0);
84357
+ await handleTeamRepoSync(confirm ? "switching bucket folders off" : "checking before switching bucket folders off");
84358
+ const status2 = teamRepoStatus;
84359
+ if (status2?.error !== void 0)
84360
+ return refuse([`The sync failed: ${status2.error}`]);
84361
+ if (status2 !== void 0 && status2.conflicts.length > 0) {
84362
+ return refuse(status2.conflicts.map((conflict) => `${conflict.path} - ${conflict.reason}`));
84363
+ }
84364
+ const bucketDirs = {
84365
+ skills: mirroredSkillsDirs.filter((dir) => !samePath(dir, plan2.dirs.skills)),
84366
+ tools: mirroredToolsDirs.filter((dir) => !samePath(dir, plan2.dirs.tools))
84367
+ };
84368
+ const coverage = await checkCoverage({ folder: plan2.settings.folder, stateFile: plan2.stateFile, mirror: plan2.dirs, dirs: bucketDirs });
84369
+ if (coverage.problems.length > 0) {
84370
+ teamRepoRetire = { ready: false, folders, covered: coverage.covered, problems: coverage.problems };
84371
+ await postTeamRepo();
84372
+ return;
84373
+ }
84374
+ if (!confirm) {
84375
+ teamRepoRetire = { ready: true, folders, covered: coverage.covered, problems: [] };
84376
+ await postTeamRepo();
84377
+ return;
84378
+ }
84379
+ const off = (mirrors) => mirrors?.map((mirror) => {
84380
+ const rest = { ...mirror };
84381
+ delete rest.enabled;
84382
+ return rest;
84383
+ });
84384
+ const s3 = { ...config2.s3 ?? {} };
84385
+ const skillMirrors = off(s3.skills);
84386
+ const toolMirrors = off(s3.tools);
84387
+ if (skillMirrors !== void 0)
84388
+ s3.skills = skillMirrors;
84389
+ if (toolMirrors !== void 0)
84390
+ s3.tools = toolMirrors;
84391
+ await configManager.save("user", { s3 });
84392
+ const stillHere = await checkCoverage({
84393
+ folder: plan2.settings.folder,
84394
+ stateFile: plan2.stateFile,
84395
+ mirror: plan2.dirs,
84396
+ dirs: { skills: [localSkillsDir].filter((dir) => dir !== void 0), tools: [localToolsDir(config2)].filter((dir) => dir !== void 0) }
84397
+ });
84398
+ await releaseFromRecord(plan2.stateFile, coverage.repoPaths.filter((repoPath) => !stillHere.repoPaths.includes(repoPath)));
84399
+ await loadSettings();
84400
+ await configurePythonFromSettings();
84401
+ await refreshSkills();
84402
+ void postSkills();
84403
+ await postPython();
84404
+ await postS3();
84405
+ teamRepoRetire = {
84406
+ ready: false,
84407
+ folders,
84408
+ covered: coverage.covered,
84409
+ problems: [],
84410
+ done: `Switched off: ${folders.join("; ")}. ${String(coverage.covered.skills)} skill file(s) and ${String(coverage.covered.tools)} tool(s) now load from the team repository. Nothing was deleted - tick the folders in Settings -> S3 to switch them back on.`
84411
+ };
84412
+ logger.info(`team repository: S3 bucket folders switched off (${folders.join("; ")})`);
84413
+ await handleTeamRepoSync("bucket folders switched off");
84414
+ }
84119
84415
  async function handleSaveTeamRepo(input) {
84120
84416
  const project = input.project.trim();
84121
84417
  const repo = input.repo.trim().toLowerCase();
@@ -84198,6 +84494,7 @@ ${redact(shown2, cachedSecretValues)}` }
84198
84494
  pulled: report.pulled,
84199
84495
  removed: report.removed,
84200
84496
  conflicts: report.conflicts,
84497
+ behind: report.behind,
84201
84498
  deletedHere: report.deletedHere
84202
84499
  };
84203
84500
  logger.info(`team repository sync (${reason}): ${String(report.pushed.length)} pushed, ${String(report.pulled.length)} pulled, ${String(report.conflicts.length)} conflict(s)`);
@@ -84497,7 +84794,7 @@ ${redact(shown2, cachedSecretValues)}` }
84497
84794
  if (keepPrivateNow !== void 0)
84498
84795
  await saveKeepPrivate(keepPrivateNow);
84499
84796
  const config2 = await loadSettings();
84500
- const keepPrivate = new Set(config2.teamSkills?.keepPrivate ?? []);
84797
+ const keepPrivate = /* @__PURE__ */ new Set([...config2.teamSkills?.keepPrivate ?? [], ...skills.filter(isPersonalSkill).map((skill) => skill.name)]);
84501
84798
  const collection = skillsIndexName(config2);
84502
84799
  const search = await resolveSearch(config2);
84503
84800
  const embedder = await resolveEmbedder(config2);
@@ -84618,7 +84915,7 @@ ${redact(shown2, cachedSecretValues)}` }
84618
84915
  stored.set(document.path, document.text);
84619
84916
  cursor = page.next;
84620
84917
  } while (cursor !== void 0);
84621
- const keepPrivate = new Set(config2.teamSkills?.keepPrivate ?? []);
84918
+ const keepPrivate = /* @__PURE__ */ new Set([...config2.teamSkills?.keepPrivate ?? [], ...skills.filter(isPersonalSkill).map((skill) => skill.name)]);
84622
84919
  const entries = await Promise.all(skills.map(async (skill) => {
84623
84920
  const sent = stored.get(teamSkillPath(skill));
84624
84921
  if (keepPrivate.has(skill.name))
@@ -85907,7 +86204,7 @@ ${redact(shown2, cachedSecretValues)}` }
85907
86204
  },
85908
86205
  save: saveUsageProfile
85909
86206
  });
85910
- async function contentHash(file2) {
86207
+ async function contentHash2(file2) {
85911
86208
  try {
85912
86209
  const text2 = (await import_promises28.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
85913
86210
  const meaningful = text2.split("\n").filter((line) => !/^(author|project|version|updated)\s*:/i.test(line) && !/^__(author|project|version|updated)__\s*=/.test(line)).join("\n").trim();
@@ -85926,7 +86223,7 @@ ${redact(shown2, cachedSecretValues)}` }
85926
86223
  return bucket !== void 0 ? `bucket ${bucket.label}` : "shared folder";
85927
86224
  };
85928
86225
  for (const skill of skills) {
85929
- const hash3 = await contentHash(skill.filePath);
86226
+ const hash3 = await contentHash2(skill.filePath);
85930
86227
  items.push({
85931
86228
  kind: "skill",
85932
86229
  name: skill.name,
@@ -85946,7 +86243,7 @@ ${redact(shown2, cachedSecretValues)}` }
85946
86243
  for (const skill of loaded.skills) {
85947
86244
  if (items.some((item) => item.kind === "skill" && samePath(item.filePath, skill.filePath)))
85948
86245
  continue;
85949
- const hash3 = await contentHash(skill.filePath);
86246
+ const hash3 = await contentHash2(skill.filePath);
85950
86247
  items.push({
85951
86248
  kind: "skill",
85952
86249
  name: skill.name,
@@ -85962,7 +86259,7 @@ ${redact(shown2, cachedSecretValues)}` }
85962
86259
  }
85963
86260
  const status2 = python.status();
85964
86261
  for (const tool of status2.tools) {
85965
- const hash3 = await contentHash(tool.filePath);
86262
+ const hash3 = await contentHash2(tool.filePath);
85966
86263
  items.push({
85967
86264
  kind: "tool",
85968
86265
  name: tool.name,
@@ -87787,6 +88084,8 @@ ${redact(shown2, cachedSecretValues)}` }
87787
88084
  reportFailure("handleSaveTeamRepo", handleSaveTeamRepo(message4.settings));
87788
88085
  } else if (message4.type === "syncTeamRepo") {
87789
88086
  reportFailure("handleTeamRepoSync", handleTeamRepoSync("asked"));
88087
+ } else if (message4.type === "retireS3Buckets") {
88088
+ reportFailure("handleRetireS3Buckets", handleRetireS3Buckets(message4.confirm));
87790
88089
  } else if (message4.type === "saveTeamSkillSelection") {
87791
88090
  reportFailure("saveTeamSkillSelection", saveKeepPrivate(message4.keepPrivate).then(postSkills));
87792
88091
  } else if (message4.type === "saveSkillDefaults") {
@@ -90168,6 +90467,15 @@ and the assistant copies it into the workspace with \`use_skill_file\` rather th
90168
90467
  bytes into the conversation. Describe each file in one line in the skill body; a file nobody
90169
90468
  described is one the assistant will never know to reach for.
90170
90469
 
90470
+ **Only me, or the team.** When a skill or Python tool is created, the assistant asks who it is for
90471
+ (unless you said). **Only me** keeps it in your personal folder on this computer
90472
+ (%LOCALAPPDATA%\\light-code\\personal) - used in every project, in VS Code, Fire Code and the Node host
90473
+ alike, and never uploaded to a bucket, committed to the team repository or sent to the team skills
90474
+ pool. **The team** saves it where your team shares: committed to the team repository and/or uploaded
90475
+ to the bucket folder marked "Publish" - the approval prompt names the destination before anything is
90476
+ written. Updating one keeps it where it is. Personal skills show **only you** in the Skills tab and can
90477
+ be removed there. Not offered on a shared server, where every user is the same account.
90478
+
90171
90479
  **Moving them.** Changed where skills live, or turned a bucket on after you already had some?
90172
90480
  Settings -> Skills -> "Bring skills in from another folder" copies them in. Nothing is moved and
90173
90481
  nothing is overwritten: the old folder is untouched and a name already present is skipped and
@@ -90966,6 +91274,36 @@ identical content, which is agreement, not a conflict; an edit someone makes in
90966
91274
  by the next sync. The same name in two folders here is one file when identical; when the copies differ,
90967
91275
  the one Light Code uses is committed and the other is listed.
90968
91276
 
91277
+ **Where new ones are saved.** While the repository is on, new skills and Python tools are saved in a
91278
+ folder of its own outside the project (the panel shows the path), so they never land in the project's git.
91279
+ A folder you chose in Settings -> Skills or Settings -> Python, or an S3 bucket folder marked "Publish",
91280
+ still wins. Skills and tools already in the project's .lightcode folders keep loading and are committed
91281
+ too. The agent can read every skill and tool folder, wherever it is, without asking.
91282
+
91283
+ **Starting with the repository alone** needs no S3 bucket: set up Bitbucket, fill in this panel and press
91284
+ Sync now. Everyone's skills and tools come down; yours are committed as you create them.
91285
+
91286
+ **Python tools from the repository** need approving once on each machine, like any shared tool. Tool code
91287
+ approved before (from a bucket, say) with exactly the same content is recognised and not asked again.
91288
+
91289
+ **"Newer in the repository"** (grey, not red): a colleague's change reached the repository before your
91290
+ bucket sync brought it here. Your copy is unchanged, so nothing clashes; it clears once the bucket syncs.
91291
+ **"Not synced - changed both here and in the repository"** (red) means both sides really changed. Compare
91292
+ your copy with the team copy, keep one, and the next sync agrees. Line-ending differences (Windows CRLF
91293
+ against LF) are not counted as changes.
91294
+
91295
+ **Do I still need the S3 bucket?** Either is enough to share: the bucket delivers files to everyone's
91296
+ machine, and the repository does too while keeping history and diffs. With both on, the same file in both
91297
+ is one file. A team can switch the bucket folders off and use the repository alone: **Use the repository
91298
+ instead of the S3 bucket**, in the same panel. **Check** syncs the bucket and the repository, then makes sure
91299
+ every skill and tool in the bucket folders is in the repository with the same content, listing anything that
91300
+ is not. Only after a clean check can **Switch bucket folders off** be pressed, and it checks once more first.
91301
+ It switches the skills and tools bucket folders off together and only unticks them - nothing is deleted in the bucket or on this computer, and ticking them again in
91302
+ Settings -> S3 undoes it. Afterwards new skills and tools are saved in the project's folders and committed to
91303
+ the repository, and what came from the bucket loads from the team copy (tools approved before stay approved
91304
+ when their content is the same). Colleagues still using only the bucket stop receiving yours, so switch over
91305
+ together.
91306
+
90969
91307
  Problems from syncing in the background (the repository, buckets, tools that did not load) show in
90970
91308
  **Settings \u2192 Usage \u2192 Needs attention**.
90971
91309
  `
@@ -92281,7 +92619,9 @@ is done and decided, the current state, open questions and next steps - and a ne
92281
92619
  its first message. Your own messages are quoted word for word, and the files read and changed and the
92282
92620
  commands run are listed from the actual tool calls, so nothing important rests on the summary alone. A
92283
92621
  progress panel shows each step and how much has been written; Cancel stops it, and a failure leaves the
92284
- chat as it was. The old chat stays in History.
92622
+ chat as it was. The old chat stays in History. When a reply fails because the conversation is too long
92623
+ for the model, the error offers this too - it still works then, because the write-up is made from a
92624
+ shortened transcript.
92285
92625
 
92286
92626
  **History is compacted only when you say so.** **Compact now** under the token bar summarises the
92287
92627
  older part (highlighted near the limit); the stored transcript keeps everything, only what is sent to