@chosengeneration/light-code 0.153.0 → 0.156.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.cjs +502 -53
- package/dist/server.cjs +493 -50
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -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" (the default - leave this out): saved where the team shares skills. Use "me" ONLY when the user explicitly says the skill is personal, private or just for them; do not ask. 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
|
|
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
|
|
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(
|
|
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(
|
|
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.
|
|
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
|
|
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(
|
|
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,
|
|
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" (the default - leave this out): saved where the team shares tools. Use "me" ONLY when the user explicitly says the tool is personal, private or just for them; do not ask. 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.
|
|
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
|
|
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
|
|
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(
|
|
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(
|
|
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.
|
|
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
|
-
|
|
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(
|
|
61620
|
+
const filePath = await resolveToolPath2(own, params3.name);
|
|
61557
61621
|
await import_promises13.default.rm(filePath, { force: true });
|
|
61558
|
-
await forgetTool(
|
|
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.
|
|
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).
|
|
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) {
|
|
@@ -74619,6 +74685,15 @@ function toolsForAccess(tools, readOnly, label) {
|
|
|
74619
74685
|
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);
|
|
74688
|
+
var TOMBSTONE_PREFIX = "LIGHT-CODE-DELETED:";
|
|
74689
|
+
function tombstoneText(who, when3) {
|
|
74690
|
+
return `${TOMBSTONE_PREFIX} removed for the team by ${who} on ${when3.toISOString().slice(0, 10)}. Light Code no longer loads this file; writing a new one of the same name brings it back.
|
|
74691
|
+
`;
|
|
74692
|
+
}
|
|
74693
|
+
function isTombstone(bytes) {
|
|
74694
|
+
const head = new TextDecoder().decode(bytes.slice(0, 64)).replace(/^\uFEFF/, "");
|
|
74695
|
+
return head.startsWith(TOMBSTONE_PREFIX);
|
|
74696
|
+
}
|
|
74622
74697
|
var TEAM_REPO_STATE_FILE = ".lightcode-teamrepo.json";
|
|
74623
74698
|
var decoder = new TextDecoder("utf-8", { fatal: true });
|
|
74624
74699
|
function contentHash(bytes) {
|
|
@@ -74660,8 +74735,9 @@ async function readState(file2, mirrorFile) {
|
|
|
74660
74735
|
try {
|
|
74661
74736
|
const parsed = JSON.parse(await import_promises25.default.readFile(file2, "utf8"));
|
|
74662
74737
|
const head = parsed.head !== void 0 ? { head: parsed.head } : {};
|
|
74663
|
-
if (parsed.version === 2)
|
|
74664
|
-
return { version: 2, files: parsed.files ?? {}, pushed: parsed.pushed ?? {}, ...head };
|
|
74738
|
+
if (parsed.version === 2) {
|
|
74739
|
+
return { version: 2, files: parsed.files ?? {}, pushed: parsed.pushed ?? {}, ...head, ...parsed.released !== void 0 ? { released: parsed.released } : {} };
|
|
74740
|
+
}
|
|
74665
74741
|
if (parsed.version === 1) {
|
|
74666
74742
|
const files = {};
|
|
74667
74743
|
const pushed = {};
|
|
@@ -74748,6 +74824,14 @@ async function syncTeamRepo(options) {
|
|
|
74748
74824
|
continue;
|
|
74749
74825
|
const fetched = hash2(bytes);
|
|
74750
74826
|
const before = state.files[change.path];
|
|
74827
|
+
if (isTombstone(bytes)) {
|
|
74828
|
+
state.files[change.path] = { commit: head, hash: fetched, deleted: true };
|
|
74829
|
+
if (before?.deleted !== true) {
|
|
74830
|
+
await import_promises25.default.rm(mirrorFile(target.kind, target.relative), { force: true });
|
|
74831
|
+
report.removed.push(change.path);
|
|
74832
|
+
}
|
|
74833
|
+
continue;
|
|
74834
|
+
}
|
|
74751
74835
|
state.files[change.path] = { commit: head, hash: fetched };
|
|
74752
74836
|
if (before?.hash === fetched)
|
|
74753
74837
|
continue;
|
|
@@ -74782,6 +74866,27 @@ async function syncTeamRepo(options) {
|
|
|
74782
74866
|
}
|
|
74783
74867
|
chosen.set(repoPath, { hash: mine, file: entry.file });
|
|
74784
74868
|
const known = state.files[repoPath];
|
|
74869
|
+
if (known?.deleted === true && state.pushed[repoPath] !== known.hash) {
|
|
74870
|
+
if (mine === state.pushed[repoPath]) {
|
|
74871
|
+
const inside = (options.removable ?? []).some((dir) => entry.file.toLowerCase().startsWith(import_node_path45.default.resolve(dir).toLowerCase() + import_node_path45.default.sep));
|
|
74872
|
+
if (inside) {
|
|
74873
|
+
await import_promises25.default.rm(entry.file, { force: true });
|
|
74874
|
+
state.pushed[repoPath] = known.hash;
|
|
74875
|
+
report.removed.push(`${repoPath} (copy on this computer)`);
|
|
74876
|
+
} else {
|
|
74877
|
+
report.conflicts.push({
|
|
74878
|
+
path: repoPath,
|
|
74879
|
+
reason: `deleted for the team in the repository, but an unchanged copy still loads here from ${entry.file} - delete it there if it should go`
|
|
74880
|
+
});
|
|
74881
|
+
}
|
|
74882
|
+
} else {
|
|
74883
|
+
report.conflicts.push({
|
|
74884
|
+
path: repoPath,
|
|
74885
|
+
reason: "deleted for the team in the repository, but changed here since - not re-added; delete yours, or write it again to bring it back"
|
|
74886
|
+
});
|
|
74887
|
+
}
|
|
74888
|
+
continue;
|
|
74889
|
+
}
|
|
74785
74890
|
if (known?.hash === mine) {
|
|
74786
74891
|
state.pushed[repoPath] = mine;
|
|
74787
74892
|
continue;
|
|
@@ -74847,8 +74952,22 @@ async function syncTeamRepo(options) {
|
|
|
74847
74952
|
});
|
|
74848
74953
|
}
|
|
74849
74954
|
}
|
|
74955
|
+
const released = new Set(state.released ?? []);
|
|
74956
|
+
for (const repoPath of [...released]) {
|
|
74957
|
+
if (present2.has(repoPath))
|
|
74958
|
+
released.delete(repoPath);
|
|
74959
|
+
else {
|
|
74960
|
+
const known = state.files[repoPath];
|
|
74961
|
+
if (known !== void 0)
|
|
74962
|
+
state.pushed[repoPath] = known.hash;
|
|
74963
|
+
}
|
|
74964
|
+
}
|
|
74965
|
+
if (released.size > 0)
|
|
74966
|
+
state.released = [...released].sort();
|
|
74967
|
+
else
|
|
74968
|
+
delete state.released;
|
|
74850
74969
|
for (const repoPath of Object.keys(state.pushed)) {
|
|
74851
|
-
if (!present2.has(repoPath) && state.files[repoPath] !== void 0)
|
|
74970
|
+
if (!present2.has(repoPath) && !released.has(repoPath) && state.files[repoPath] !== void 0 && state.files[repoPath]?.deleted !== true)
|
|
74852
74971
|
report.deletedHere.push(repoPath);
|
|
74853
74972
|
}
|
|
74854
74973
|
}
|
|
@@ -74871,6 +74990,8 @@ async function checkCoverage(options) {
|
|
|
74871
74990
|
const repoPath = repoPathFor(folder, kind, entry.relative);
|
|
74872
74991
|
const mine = hash2(new Uint8Array(await import_promises25.default.readFile(entry.file)));
|
|
74873
74992
|
const known = state.files[repoPath];
|
|
74993
|
+
if (known?.deleted === true)
|
|
74994
|
+
continue;
|
|
74874
74995
|
if (known === void 0)
|
|
74875
74996
|
problems.push(`${entry.file} - not in the repository yet`);
|
|
74876
74997
|
else if (known.hash !== mine && state.pushed[repoPath] !== mine)
|
|
@@ -74891,10 +75012,62 @@ async function releaseFromRecord(stateFile, repoPaths) {
|
|
|
74891
75012
|
} catch {
|
|
74892
75013
|
return;
|
|
74893
75014
|
}
|
|
74894
|
-
|
|
74895
|
-
delete parsed.pushed[repoPath];
|
|
75015
|
+
parsed.released = [.../* @__PURE__ */ new Set([...parsed.released ?? [], ...repoPaths])].sort();
|
|
74896
75016
|
await writeWhole2(stateFile, JSON.stringify(parsed, null, 1));
|
|
74897
75017
|
}
|
|
75018
|
+
async function tombstoneInRepo(options) {
|
|
75019
|
+
const { folder } = options;
|
|
75020
|
+
const mirrorFile = (repoPath) => {
|
|
75021
|
+
const target = classifyRepoPath(folder, repoPath);
|
|
75022
|
+
return target === void 0 ? void 0 : import_node_path45.default.join(options.mirror[target.kind], ...target.relative.split("/"));
|
|
75023
|
+
};
|
|
75024
|
+
const state = await readState(options.stateFile, mirrorFile);
|
|
75025
|
+
const bytes = new TextEncoder().encode(tombstoneText(options.who, options.now ?? /* @__PURE__ */ new Date()));
|
|
75026
|
+
const marker = hash2(bytes);
|
|
75027
|
+
const done = [];
|
|
75028
|
+
let failed2;
|
|
75029
|
+
for (const repoPath of options.repoPaths) {
|
|
75030
|
+
const known = state.files[repoPath];
|
|
75031
|
+
if (known === void 0 || known.deleted === true)
|
|
75032
|
+
continue;
|
|
75033
|
+
const kind = classifyRepoPath(folder, repoPath)?.kind ?? "skills";
|
|
75034
|
+
try {
|
|
75035
|
+
const commit = await options.api.commitFile({
|
|
75036
|
+
path: repoPath,
|
|
75037
|
+
bytes,
|
|
75038
|
+
branch: options.branch,
|
|
75039
|
+
message: `Light Code: delete ${kind}/${repoPath.split("/").pop() ?? repoPath} for the team (${options.who})`,
|
|
75040
|
+
sourceCommitId: known.commit
|
|
75041
|
+
});
|
|
75042
|
+
state.files[repoPath] = { commit: commit ?? known.commit, hash: marker, deleted: true };
|
|
75043
|
+
state.pushed[repoPath] = marker;
|
|
75044
|
+
const local = mirrorFile(repoPath);
|
|
75045
|
+
if (local !== void 0)
|
|
75046
|
+
await import_promises25.default.rm(local, { force: true });
|
|
75047
|
+
done.push(repoPath);
|
|
75048
|
+
} catch (error51) {
|
|
75049
|
+
const status2 = error51.status;
|
|
75050
|
+
failed2 = {
|
|
75051
|
+
path: repoPath,
|
|
75052
|
+
problem: status2 === 409 ? "changed in the repository since the last sync - press Sync now and try again" : error51 instanceof Error ? error51.message : String(error51)
|
|
75053
|
+
};
|
|
75054
|
+
break;
|
|
75055
|
+
}
|
|
75056
|
+
}
|
|
75057
|
+
await writeWhole2(options.stateFile, JSON.stringify(state, null, 1));
|
|
75058
|
+
return { done, ...failed2 !== void 0 ? { failed: failed2 } : {} };
|
|
75059
|
+
}
|
|
75060
|
+
async function repoFilesOf(options) {
|
|
75061
|
+
const state = await readState(options.stateFile, () => void 0);
|
|
75062
|
+
return Object.entries(state.files).filter(([repoPath, entry]) => {
|
|
75063
|
+
if (entry.deleted === true)
|
|
75064
|
+
return false;
|
|
75065
|
+
const target = classifyRepoPath(options.folder, repoPath);
|
|
75066
|
+
if (target === void 0 || target.kind !== options.kind)
|
|
75067
|
+
return false;
|
|
75068
|
+
return options.kind === "tools" ? target.relative === `${options.name}.py` : target.relative.toLowerCase() === `${options.name.toLowerCase()}.md` || target.relative.toLowerCase().startsWith(`${options.name.toLowerCase()}/`);
|
|
75069
|
+
}).map(([repoPath]) => repoPath).sort();
|
|
75070
|
+
}
|
|
74898
75071
|
|
|
74899
75072
|
// ../../packages/core/dist/platform/httpTrace.js
|
|
74900
75073
|
var SECRET_NAME = /secret|password|passwd|token|api[-_]?key|assertion|credential|session|signature|cookie/i;
|
|
@@ -79001,6 +79174,8 @@ function wireChatBridge(services) {
|
|
|
79001
79174
|
const { transport, secrets, ui, workspaceRoot, storageDir } = services;
|
|
79002
79175
|
const machineApprovals = services.machineApprovalsFile !== void 0 ? new FileMachineApprovals(services.machineApprovalsFile) : void 0;
|
|
79003
79176
|
const mirrorRoot = services.mirrorRoot ?? storageDir;
|
|
79177
|
+
const personalSkillsDir = services.personalDir !== void 0 ? import_node_path51.default.join(services.personalDir, "skills") : void 0;
|
|
79178
|
+
const personalToolsDir = services.personalDir !== void 0 ? import_node_path51.default.join(services.personalDir, "tools") : void 0;
|
|
79004
79179
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
79005
79180
|
let fastFsOps;
|
|
79006
79181
|
if (services.fastFs !== void 0) {
|
|
@@ -79027,6 +79202,7 @@ function wireChatBridge(services) {
|
|
|
79027
79202
|
const python = new PythonManager({
|
|
79028
79203
|
workspaceRoot,
|
|
79029
79204
|
storageDir,
|
|
79205
|
+
...personalToolsDir !== void 0 ? { personalToolsDir, sharedWith: () => sharedWith("tools") } : {},
|
|
79030
79206
|
...services.codebaseDir !== void 0 ? { venvRoot: services.codebaseDir } : {},
|
|
79031
79207
|
logger,
|
|
79032
79208
|
// Fire Code: one review per tool's code on this machine, however many codebases hold it.
|
|
@@ -79248,6 +79424,7 @@ ${preview.text}` } : {}
|
|
|
79248
79424
|
...files.length > 0 ? { files } : {},
|
|
79249
79425
|
...skill.sourceDir !== void 0 ? { sourceDir: skill.sourceDir } : {},
|
|
79250
79426
|
...placeholders.length > 0 ? { placeholders } : {},
|
|
79427
|
+
...isPersonalSkill(skill) ? { personal: true } : {},
|
|
79251
79428
|
...skill.always === true ? { always: true } : {},
|
|
79252
79429
|
...skill.author !== void 0 ? { author: skill.author } : {},
|
|
79253
79430
|
...skill.project !== void 0 ? { project: skill.project } : {},
|
|
@@ -79263,7 +79440,7 @@ ${preview.text}` } : {}
|
|
|
79263
79440
|
issues: skillIssues,
|
|
79264
79441
|
...skillsDir !== void 0 ? { skillsDir } : {},
|
|
79265
79442
|
extraDirs: extraSkillDirs,
|
|
79266
|
-
keepPrivate: skillsConfig.teamSkills?.keepPrivate ?? [],
|
|
79443
|
+
keepPrivate: [.../* @__PURE__ */ new Set([...skillsConfig.teamSkills?.keepPrivate ?? [], ...skills.filter(isPersonalSkill).map((skill) => skill.name)])],
|
|
79267
79444
|
skillDefaults: skillsConfig.skillDefaults ?? {}
|
|
79268
79445
|
});
|
|
79269
79446
|
scheduleDocsReindex("skills changed");
|
|
@@ -79463,13 +79640,16 @@ ${preview.text}` } : {}
|
|
|
79463
79640
|
}
|
|
79464
79641
|
function pythonFolders(config2) {
|
|
79465
79642
|
const configured = config2.python?.toolsDir?.trim();
|
|
79466
|
-
const
|
|
79643
|
+
const chosen = configured !== void 0 && configured.length > 0;
|
|
79644
|
+
const team = chosen ? void 0 : teamRepoPlan(config2);
|
|
79645
|
+
const publish = chosen ? void 0 : publishFolder("tools", config2.s3?.tools ?? []) ?? (team !== void 0 && "own" in team ? team.own.tools : void 0);
|
|
79646
|
+
const personal = personalToolsDir !== void 0 ? [personalToolsDir] : [];
|
|
79467
79647
|
if (publish === void 0)
|
|
79468
|
-
return { extraToolDirs: mirroredToolsDirs };
|
|
79648
|
+
return { extraToolDirs: [...personal, ...mirroredToolsDirs] };
|
|
79469
79649
|
const local = localToolsDir(config2);
|
|
79470
79650
|
return {
|
|
79471
79651
|
toolsDir: publish,
|
|
79472
|
-
extraToolDirs: [...local !== void 0 ? [local] : [], ...mirroredToolsDirs.filter((dir) => !samePath(dir, publish))]
|
|
79652
|
+
extraToolDirs: [...personal, ...local !== void 0 ? [local] : [], ...mirroredToolsDirs.filter((dir) => !samePath(dir, publish))]
|
|
79473
79653
|
};
|
|
79474
79654
|
}
|
|
79475
79655
|
function noFolderMessage(kind) {
|
|
@@ -79814,10 +79994,12 @@ ${preview.text}` } : {}
|
|
|
79814
79994
|
if (!isValidSkillName(name))
|
|
79815
79995
|
throw new Error(`"${name}" is not a valid skill name.`);
|
|
79816
79996
|
const existing = skills.find((skill) => skill.name === name);
|
|
79817
|
-
if (existing !== void 0 && existing.sourceDir !== void 0 && existing.sourceDir !== skillsDir
|
|
79997
|
+
if (existing !== void 0 && existing.sourceDir !== void 0 && existing.sourceDir !== skillsDir && // The user's own skills are theirs to delete.
|
|
79998
|
+
!samePath(existing.sourceDir, personalSkillsDir)) {
|
|
79818
79999
|
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.`);
|
|
79819
80000
|
}
|
|
79820
|
-
|
|
80001
|
+
const from = existing?.sourceDir !== void 0 && samePath(existing.sourceDir, personalSkillsDir) ? existing.sourceDir : skillsDir;
|
|
80002
|
+
await import_promises28.default.rm(import_node_path51.default.join(from, skillFileName(name)), { force: true });
|
|
79821
80003
|
await postSkills();
|
|
79822
80004
|
} catch (error51) {
|
|
79823
80005
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -80441,10 +80623,17 @@ ${preview.text}` } : {}
|
|
|
80441
80623
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
80442
80624
|
}));
|
|
80443
80625
|
const team = teamRepoPlan(config2);
|
|
80626
|
+
cachedTeamRepoLabel = "dirs" in team ? `${team.settings.project}/${team.settings.repo} (${team.settings.branch})` : void 0;
|
|
80444
80627
|
if ("dirs" in team) {
|
|
80445
80628
|
extraSkillDirs.push(team.dirs.skills);
|
|
80446
80629
|
mirroredToolsDirs.push(team.dirs.tools);
|
|
80630
|
+
if (config2.skills?.dir === void 0 && publishSkills === void 0) {
|
|
80631
|
+
skillsDir = team.own.skills;
|
|
80632
|
+
extraSkillDirs.unshift(...localSkillsDir !== void 0 ? [localSkillsDir] : []);
|
|
80633
|
+
}
|
|
80447
80634
|
}
|
|
80635
|
+
if (personalSkillsDir !== void 0)
|
|
80636
|
+
extraSkillDirs.unshift(personalSkillsDir);
|
|
80448
80637
|
return config2;
|
|
80449
80638
|
}
|
|
80450
80639
|
function announceConfigRecovery() {
|
|
@@ -80757,6 +80946,8 @@ ${preview.text}` } : {}
|
|
|
80757
80946
|
skillsDir,
|
|
80758
80947
|
onChanged: refreshSkills,
|
|
80759
80948
|
attribution: () => cachedAttribution,
|
|
80949
|
+
// "Only me": the user's own skills, never shared. Absent on a shared server.
|
|
80950
|
+
...personalSkillsDir !== void 0 ? { personalSkillsDir, sharedWith: () => sharedWith("skills") } : {},
|
|
80760
80951
|
/*
|
|
80761
80952
|
* Every loaded skill, so `use_skill_file` can reach a template in a read-only shared
|
|
80762
80953
|
* folder. A closure over the live array rather than a copy: the folders are watched, and
|
|
@@ -81740,6 +81931,15 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
81740
81931
|
// read_file must reach them without asking, or the rest of a cut-off file is out of reach.
|
|
81741
81932
|
readRoots: [
|
|
81742
81933
|
...cachedReadRoots,
|
|
81934
|
+
/*
|
|
81935
|
+
* Every folder skills and Python tools load from. A skill's body is read with read_file, and
|
|
81936
|
+
* skills outside the project - S3 bucket folders, the team repository's copy and the folder new
|
|
81937
|
+
* ones are saved in while it is on - were outside every root: VS Code asked to read each one, and
|
|
81938
|
+
* Fire Code refused them as inside its own data folder. Reading only; they are written through
|
|
81939
|
+
* write_skill and the Python tools, which ask with the content shown.
|
|
81940
|
+
*/
|
|
81941
|
+
...skillSearchPath(),
|
|
81942
|
+
...python.toolDirectories(),
|
|
81743
81943
|
...(services.siblings ?? []).map((s) => s.path),
|
|
81744
81944
|
droppedFilesRoot2,
|
|
81745
81945
|
mailAttachmentsRoot2,
|
|
@@ -84174,7 +84374,13 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84174
84374
|
return { reason: "Enter the project key and repository slug." };
|
|
84175
84375
|
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);
|
|
84176
84376
|
const root = import_node_path51.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
|
|
84177
|
-
return {
|
|
84377
|
+
return {
|
|
84378
|
+
dirs: { skills: import_node_path51.default.join(root, "skills"), tools: import_node_path51.default.join(root, "tools") },
|
|
84379
|
+
// Where new skills and tools are saved while the repository is on - see loadSettings and pythonFolders.
|
|
84380
|
+
own: { skills: import_node_path51.default.join(root, "saved-here", "skills"), tools: import_node_path51.default.join(root, "saved-here", "tools") },
|
|
84381
|
+
stateFile: import_node_path51.default.join(root, TEAM_REPO_STATE_FILE),
|
|
84382
|
+
settings
|
|
84383
|
+
};
|
|
84178
84384
|
}
|
|
84179
84385
|
let teamRepoStatus;
|
|
84180
84386
|
let teamRepoSyncing = false;
|
|
@@ -84193,9 +84399,177 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84193
84399
|
syncing: teamRepoSyncing,
|
|
84194
84400
|
...saveError !== void 0 ? { saveError } : {},
|
|
84195
84401
|
bucketFolders: bucketFolderLabels(config2),
|
|
84402
|
+
// Where new skills and tools land while it is on - outside the project, unless a folder was chosen.
|
|
84403
|
+
..."dirs" in plan2 ? { savedIn: { ...skillsDir !== void 0 ? { skills: skillsDir } : {}, ...(pythonFolders(config2).toolsDir ?? localToolsDir(config2)) !== void 0 ? { tools: pythonFolders(config2).toolsDir ?? localToolsDir(config2) } : {} } } : {},
|
|
84196
84404
|
...teamRepoRetire !== void 0 ? { retire: teamRepoRetire } : {}
|
|
84197
84405
|
});
|
|
84198
84406
|
}
|
|
84407
|
+
async function teamRepoFiles(settings) {
|
|
84408
|
+
const repoRef = { project: settings.project, repo: settings.repo };
|
|
84409
|
+
const client = await bitbucketClient();
|
|
84410
|
+
return {
|
|
84411
|
+
branchHead: (branch) => client.branchHead(repoRef, branch),
|
|
84412
|
+
defaultBranch: () => client.defaultBranch(repoRef),
|
|
84413
|
+
createBranch: (name, startPoint) => client.createBranch(repoRef, name, startPoint),
|
|
84414
|
+
listFiles: (folder, at) => client.listFiles(repoRef, folder, at),
|
|
84415
|
+
changes: (since2, until) => client.changes(repoRef, since2, until),
|
|
84416
|
+
readBytes: (file2, at) => client.readBytes(repoRef, file2, at),
|
|
84417
|
+
commitFile: (file2) => client.commitFile(repoRef, file2)
|
|
84418
|
+
};
|
|
84419
|
+
}
|
|
84420
|
+
async function planDeleteEverywhere(kind, name) {
|
|
84421
|
+
const plan2 = { kind, name, local: [], buckets: [], repo: [], notes: [] };
|
|
84422
|
+
const valid = kind === "skill" ? isValidSkillName(name) : isValidToolName(name);
|
|
84423
|
+
if (!valid)
|
|
84424
|
+
return { ...plan2, error: `"${name}" is not a valid ${kind} name.` };
|
|
84425
|
+
const config2 = await loadSettings();
|
|
84426
|
+
const team = teamRepoPlan(config2);
|
|
84427
|
+
const teamCopy = "dirs" in team ? kind === "skill" ? team.dirs.skills : team.dirs.tools : void 0;
|
|
84428
|
+
const unique = (dirs) => {
|
|
84429
|
+
const out = [];
|
|
84430
|
+
for (const dir of dirs)
|
|
84431
|
+
if (dir !== void 0 && !samePath(dir, teamCopy) && !out.some((seen) => samePath(seen, dir)))
|
|
84432
|
+
out.push(dir);
|
|
84433
|
+
return out;
|
|
84434
|
+
};
|
|
84435
|
+
const has2 = async (target) => import_promises28.default.stat(target).then(() => true, () => false);
|
|
84436
|
+
if (kind === "skill") {
|
|
84437
|
+
for (const dir of unique([skillsDir, localSkillsDir, personalSkillsDir, ...mirroredSkillsDirs])) {
|
|
84438
|
+
if (await has2(import_node_path51.default.join(dir, skillFileName(name))))
|
|
84439
|
+
plan2.local.push(import_node_path51.default.join(dir, skillFileName(name)));
|
|
84440
|
+
if (await has2(import_node_path51.default.join(dir, name, "SKILL.md")))
|
|
84441
|
+
plan2.local.push(import_node_path51.default.join(dir, name));
|
|
84442
|
+
}
|
|
84443
|
+
for (const extra of config2.skills?.paths ?? []) {
|
|
84444
|
+
const dir = resolveSkillDir(extra);
|
|
84445
|
+
if (dir !== void 0 && (await has2(import_node_path51.default.join(dir, skillFileName(name))) || await has2(import_node_path51.default.join(dir, name, "SKILL.md")))) {
|
|
84446
|
+
plan2.notes.push(`Also in ${dir}, a folder you added in Settings -> Skills - not removed; delete it there.`);
|
|
84447
|
+
}
|
|
84448
|
+
}
|
|
84449
|
+
} else {
|
|
84450
|
+
for (const dir of unique([pythonFolders(config2).toolsDir, localToolsDir(config2), personalToolsDir, ...mirroredToolsDirs])) {
|
|
84451
|
+
if (await has2(import_node_path51.default.join(dir, toolFileName(name))))
|
|
84452
|
+
plan2.local.push(import_node_path51.default.join(dir, toolFileName(name)));
|
|
84453
|
+
}
|
|
84454
|
+
}
|
|
84455
|
+
const mirrors = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).filter((mirror) => mirror.enabled === true);
|
|
84456
|
+
for (const mirror of mirrors) {
|
|
84457
|
+
const target = targetById(cachedS3, mirror.connectionId);
|
|
84458
|
+
if (target === void 0) {
|
|
84459
|
+
plan2.notes.push(`The bucket connection "${mirror.connectionId}" is unusable - its copy, if any, cannot be checked.`);
|
|
84460
|
+
continue;
|
|
84461
|
+
}
|
|
84462
|
+
try {
|
|
84463
|
+
const options = { target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, name };
|
|
84464
|
+
const keys = kind === "skill" ? await skillKeysInBucket(options) : await toolKeysInBucket(options);
|
|
84465
|
+
if (keys.length === 0)
|
|
84466
|
+
continue;
|
|
84467
|
+
if (target.readOnly === true) {
|
|
84468
|
+
plan2.notes.push(`In ${target.label}, which is configured read-only - not removed there.`);
|
|
84469
|
+
continue;
|
|
84470
|
+
}
|
|
84471
|
+
plan2.buckets.push({ connectionId: mirror.connectionId, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, label: target.label, keys });
|
|
84472
|
+
} catch (error51) {
|
|
84473
|
+
plan2.notes.push(`${target.label} could not be listed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
84474
|
+
}
|
|
84475
|
+
}
|
|
84476
|
+
if ("dirs" in team) {
|
|
84477
|
+
plan2.repo = await repoFilesOf({ folder: team.settings.folder, stateFile: team.stateFile, mirror: team.dirs, kind: kind === "skill" ? "skills" : "tools", name });
|
|
84478
|
+
plan2.repoLabel = `${team.settings.project}/${team.settings.repo} (${team.settings.branch})`;
|
|
84479
|
+
}
|
|
84480
|
+
if (plan2.local.length === 0 && plan2.buckets.length === 0 && plan2.repo.length === 0)
|
|
84481
|
+
plan2.error = `No ${kind} called "${name}" was found to delete.`;
|
|
84482
|
+
return plan2;
|
|
84483
|
+
}
|
|
84484
|
+
async function handlePreviewDeleteEverywhere(kind, name) {
|
|
84485
|
+
post({ type: "deleteEverywherePlan", plan: await planDeleteEverywhere(kind, name) });
|
|
84486
|
+
}
|
|
84487
|
+
async function handleDeleteEverywhere(requested2) {
|
|
84488
|
+
const { kind, name } = requested2;
|
|
84489
|
+
const done = (ok, message4) => post({ type: "deleteEverywhereDone", kind, name, ok, message: message4 });
|
|
84490
|
+
try {
|
|
84491
|
+
const config2 = await loadSettings();
|
|
84492
|
+
const team = teamRepoPlan(config2);
|
|
84493
|
+
if ("dirs" in team && requested2.repo.length > 0)
|
|
84494
|
+
await handleTeamRepoSync("before deleting everywhere");
|
|
84495
|
+
const fresh = await planDeleteEverywhere(kind, name);
|
|
84496
|
+
const parts = [];
|
|
84497
|
+
if ("dirs" in team) {
|
|
84498
|
+
const repoPaths = requested2.repo.filter((repoPath) => fresh.repo.includes(repoPath));
|
|
84499
|
+
if (repoPaths.length > 0) {
|
|
84500
|
+
const result = await tombstoneInRepo({
|
|
84501
|
+
api: await teamRepoFiles(team.settings),
|
|
84502
|
+
branch: team.settings.branch,
|
|
84503
|
+
folder: team.settings.folder,
|
|
84504
|
+
stateFile: team.stateFile,
|
|
84505
|
+
mirror: team.dirs,
|
|
84506
|
+
repoPaths,
|
|
84507
|
+
who: cachedAttribution.author ?? "someone"
|
|
84508
|
+
});
|
|
84509
|
+
if (result.failed !== void 0) {
|
|
84510
|
+
done(false, `Not deleted: the repository refused ${result.failed.path} (${result.failed.problem}). Nothing else was removed, so it stays consistent - try again.`);
|
|
84511
|
+
return;
|
|
84512
|
+
}
|
|
84513
|
+
parts.push(`Marked deleted in the team repository ${fresh.repoLabel ?? ""} (${String(result.done.length)} file(s)); colleagues' copies go at their next sync.`);
|
|
84514
|
+
}
|
|
84515
|
+
}
|
|
84516
|
+
for (const bucket of requested2.buckets) {
|
|
84517
|
+
const mirror = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).find((entry) => entry.connectionId === bucket.connectionId && (entry.prefix ?? "") === (bucket.prefix ?? ""));
|
|
84518
|
+
const target = mirror !== void 0 ? targetById(cachedS3, mirror.connectionId) : void 0;
|
|
84519
|
+
if (mirror === void 0 || target === void 0) {
|
|
84520
|
+
parts.push(`${bucket.label}: no longer configured - skipped.`);
|
|
84521
|
+
continue;
|
|
84522
|
+
}
|
|
84523
|
+
const options = { target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, name, keys: bucket.keys };
|
|
84524
|
+
const result = kind === "skill" ? await removeSkillFromBucket(options) : await removeToolFromBucket(options);
|
|
84525
|
+
parts.push(`${target.label}: removed ${String(result.removed.length)} object(s)${result.failed.length > 0 ? `, ${String(result.failed.length)} failed (${result.failed.map((each) => each.key).join(", ")})` : ""}.`);
|
|
84526
|
+
}
|
|
84527
|
+
const local = requested2.local.filter((entry) => fresh.local.some((allowed) => samePath(allowed, entry)));
|
|
84528
|
+
const localProblems = [];
|
|
84529
|
+
for (const entry of local) {
|
|
84530
|
+
try {
|
|
84531
|
+
await import_promises28.default.rm(entry, { recursive: true, force: true });
|
|
84532
|
+
if (kind === "tool")
|
|
84533
|
+
await forgetTool(import_node_path51.default.dirname(entry), name).catch(() => void 0);
|
|
84534
|
+
} catch (error51) {
|
|
84535
|
+
localProblems.push(`${entry} (${error51 instanceof Error ? error51.message : String(error51)})`);
|
|
84536
|
+
}
|
|
84537
|
+
}
|
|
84538
|
+
if (local.length > 0)
|
|
84539
|
+
parts.push(`Removed ${String(local.length - localProblems.length)} cop${local.length === 1 ? "y" : "ies"} on this computer.`);
|
|
84540
|
+
if (localProblems.length > 0)
|
|
84541
|
+
parts.push(`Could not remove: ${localProblems.join("; ")}.`);
|
|
84542
|
+
if (kind === "skill") {
|
|
84543
|
+
await refreshSkills();
|
|
84544
|
+
void postSkills();
|
|
84545
|
+
} else {
|
|
84546
|
+
await python.refresh();
|
|
84547
|
+
await postPython();
|
|
84548
|
+
}
|
|
84549
|
+
await postTeamRepo();
|
|
84550
|
+
logger.info(`delete everywhere: ${kind} ${name} - ${parts.join(" ")}`);
|
|
84551
|
+
done(localProblems.length === 0, parts.length > 0 ? parts.join(" ") : "Nothing was left to remove.");
|
|
84552
|
+
} catch (error51) {
|
|
84553
|
+
done(false, error51 instanceof Error ? error51.message : String(error51));
|
|
84554
|
+
}
|
|
84555
|
+
}
|
|
84556
|
+
let cachedTeamRepoLabel;
|
|
84557
|
+
function sharedWith(kind) {
|
|
84558
|
+
const mirrors = kind === "skills" ? cachedSkillMirrors : cachedToolMirrors;
|
|
84559
|
+
const publish = mirrors.find((mirror) => mirror.enabled === true && mirror.publish === true);
|
|
84560
|
+
const bucket = publish !== void 0 ? targetById(cachedS3, publish.connectionId) : void 0;
|
|
84561
|
+
const parts = [
|
|
84562
|
+
...bucket !== void 0 && bucket.readOnly !== true ? [`uploaded to the S3 bucket ${bucket.label}${publish?.prefix !== void 0 ? ` / ${publish.prefix}` : ""}`] : [],
|
|
84563
|
+
...cachedTeamRepoLabel !== void 0 ? [`committed to the team repository ${cachedTeamRepoLabel}`] : []
|
|
84564
|
+
];
|
|
84565
|
+
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";
|
|
84566
|
+
}
|
|
84567
|
+
function isPersonalSkill(skill) {
|
|
84568
|
+
if (personalSkillsDir === void 0)
|
|
84569
|
+
return false;
|
|
84570
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path51.default.resolve(value).toLowerCase() : import_node_path51.default.resolve(value);
|
|
84571
|
+
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path51.default.sep);
|
|
84572
|
+
}
|
|
84199
84573
|
function bucketFolderLabels(config2) {
|
|
84200
84574
|
const label = (kind, mirror) => {
|
|
84201
84575
|
const name = targetById(cachedS3, mirror.connectionId)?.label ?? mirror.connectionId;
|
|
@@ -84327,18 +84701,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84327
84701
|
}
|
|
84328
84702
|
teamRepoSyncing = true;
|
|
84329
84703
|
await postTeamRepo();
|
|
84330
|
-
const repoRef = { project: plan2.settings.project, repo: plan2.settings.repo };
|
|
84331
84704
|
try {
|
|
84332
|
-
const
|
|
84333
|
-
const api = {
|
|
84334
|
-
branchHead: (branch) => client.branchHead(repoRef, branch),
|
|
84335
|
-
defaultBranch: () => client.defaultBranch(repoRef),
|
|
84336
|
-
createBranch: (name, startPoint) => client.createBranch(repoRef, name, startPoint),
|
|
84337
|
-
listFiles: (folder, at) => client.listFiles(repoRef, folder, at),
|
|
84338
|
-
changes: (since2, until) => client.changes(repoRef, since2, until),
|
|
84339
|
-
readBytes: (file2, at) => client.readBytes(repoRef, file2, at),
|
|
84340
|
-
commitFile: (file2) => client.commitFile(repoRef, file2)
|
|
84341
|
-
};
|
|
84705
|
+
const api = await teamRepoFiles(plan2.settings);
|
|
84342
84706
|
const report = await syncTeamRepo({
|
|
84343
84707
|
api,
|
|
84344
84708
|
branch: plan2.settings.branch,
|
|
@@ -84351,7 +84715,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84351
84715
|
},
|
|
84352
84716
|
mirror: plan2.dirs,
|
|
84353
84717
|
stateFile: plan2.stateFile,
|
|
84354
|
-
author: cachedAttribution.author ?? "someone"
|
|
84718
|
+
author: cachedAttribution.author ?? "someone",
|
|
84719
|
+
// Folders Light Code syncs itself: an unchanged copy there of something deleted for the team goes.
|
|
84720
|
+
removable: [
|
|
84721
|
+
...mirroredSkillsDirs.filter((dir) => !samePath(dir, plan2.dirs.skills)),
|
|
84722
|
+
...mirroredToolsDirs.filter((dir) => !samePath(dir, plan2.dirs.tools)),
|
|
84723
|
+
plan2.own.skills,
|
|
84724
|
+
plan2.own.tools
|
|
84725
|
+
]
|
|
84355
84726
|
});
|
|
84356
84727
|
lastTeamRepoSync = Date.now();
|
|
84357
84728
|
teamRepoStatus = {
|
|
@@ -84662,7 +85033,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84662
85033
|
if (keepPrivateNow !== void 0)
|
|
84663
85034
|
await saveKeepPrivate(keepPrivateNow);
|
|
84664
85035
|
const config2 = await loadSettings();
|
|
84665
|
-
const keepPrivate = new Set(config2.teamSkills?.keepPrivate ?? []);
|
|
85036
|
+
const keepPrivate = /* @__PURE__ */ new Set([...config2.teamSkills?.keepPrivate ?? [], ...skills.filter(isPersonalSkill).map((skill) => skill.name)]);
|
|
84666
85037
|
const collection = skillsIndexName(config2);
|
|
84667
85038
|
const search = await resolveSearch(config2);
|
|
84668
85039
|
const embedder = await resolveEmbedder(config2);
|
|
@@ -84783,7 +85154,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84783
85154
|
stored.set(document.path, document.text);
|
|
84784
85155
|
cursor = page.next;
|
|
84785
85156
|
} while (cursor !== void 0);
|
|
84786
|
-
const keepPrivate = new Set(config2.teamSkills?.keepPrivate ?? []);
|
|
85157
|
+
const keepPrivate = /* @__PURE__ */ new Set([...config2.teamSkills?.keepPrivate ?? [], ...skills.filter(isPersonalSkill).map((skill) => skill.name)]);
|
|
84787
85158
|
const entries = await Promise.all(skills.map(async (skill) => {
|
|
84788
85159
|
const sent = stored.get(teamSkillPath(skill));
|
|
84789
85160
|
if (keepPrivate.has(skill.name))
|
|
@@ -87952,6 +88323,10 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
87952
88323
|
reportFailure("handleSaveTeamRepo", handleSaveTeamRepo(message4.settings));
|
|
87953
88324
|
} else if (message4.type === "syncTeamRepo") {
|
|
87954
88325
|
reportFailure("handleTeamRepoSync", handleTeamRepoSync("asked"));
|
|
88326
|
+
} else if (message4.type === "previewDeleteEverywhere") {
|
|
88327
|
+
reportFailure("handlePreviewDeleteEverywhere", handlePreviewDeleteEverywhere(message4.kind, message4.name));
|
|
88328
|
+
} else if (message4.type === "deleteEverywhere") {
|
|
88329
|
+
reportFailure("handleDeleteEverywhere", handleDeleteEverywhere(message4.plan));
|
|
87955
88330
|
} else if (message4.type === "retireS3Buckets") {
|
|
87956
88331
|
reportFailure("handleRetireS3Buckets", handleRetireS3Buckets(message4.confirm));
|
|
87957
88332
|
} else if (message4.type === "saveTeamSkillSelection") {
|
|
@@ -90303,7 +90678,7 @@ alert about.
|
|
|
90303
90678
|
{
|
|
90304
90679
|
id: "skills",
|
|
90305
90680
|
title: "Skills: teaching it things it cannot work out",
|
|
90306
|
-
keywords: ["skill", "teach", "instructions", "standing", "always", "master skill", "markdown", "edit skill", "editor", "edit standing instructions", "standing instructions", "edit a skill", "placeholder", "placeholders", "skill defaults", "default values", "skill inputs", "stop asking", "keep skill private", "which skills to send", "keep to myself"],
|
|
90681
|
+
keywords: ["skill", "teach", "instructions", "standing", "always", "master skill", "markdown", "edit skill", "editor", "edit standing instructions", "standing instructions", "edit a skill", "placeholder", "placeholders", "skill defaults", "default values", "skill inputs", "stop asking", "keep skill private", "which skills to send", "keep to myself", "delete everywhere", "force delete", "delete a skill for the team", "only me", "personal skill"],
|
|
90307
90682
|
body: `
|
|
90308
90683
|
A skill is markdown with frontmatter (\`name\`, \`description\`), kept in the workspace so it lands
|
|
90309
90684
|
in git and gets reviewed. **Settings \u2192 Skills.**
|
|
@@ -90335,6 +90710,26 @@ and the assistant copies it into the workspace with \`use_skill_file\` rather th
|
|
|
90335
90710
|
bytes into the conversation. Describe each file in one line in the skill body; a file nobody
|
|
90336
90711
|
described is one the assistant will never know to reach for.
|
|
90337
90712
|
|
|
90713
|
+
**Delete everywhere.** Each skill in Settings -> Skills, and each tool in Settings -> Python, has
|
|
90714
|
+
**Delete everywhere**: it first lists exactly what will go - every copy on this computer, the objects in
|
|
90715
|
+
each S3 bucket folder, and its files in the team repository - and only the second press removes them. The
|
|
90716
|
+
repository cannot delete a file over Bitbucket's REST API, so each file is replaced by a one-line
|
|
90717
|
+
"deleted by you on <date>" marker; history keeps the old version, and every Light Code treats it as gone:
|
|
90718
|
+
colleagues' unchanged copies in folders Light Code syncs are removed at their next sync, and a copy someone
|
|
90719
|
+
changed, or keeps in their own project folder, is reported rather than removed. The repository goes first:
|
|
90720
|
+
if it refuses (someone changed the file meanwhile), nothing else is removed - press Sync now and try again.
|
|
90721
|
+
Writing a new skill or tool of the same name brings it back. It is a button only: the assistant cannot
|
|
90722
|
+
delete for the team. On a shared server only an admin may.
|
|
90723
|
+
|
|
90724
|
+
**Only me, or the team.** A new skill or Python tool is **for the team** unless you say it is personal
|
|
90725
|
+
("just for me", "keep it private") - the assistant does not ask. **Only me** keeps it in your personal folder on this computer
|
|
90726
|
+
(%LOCALAPPDATA%\\light-code\\personal) - used in every project, in VS Code, Fire Code and the Node host
|
|
90727
|
+
alike, and never uploaded to a bucket, committed to the team repository or sent to the team skills
|
|
90728
|
+
pool. **The team** saves it where your team shares: committed to the team repository and/or uploaded
|
|
90729
|
+
to the bucket folder marked "Publish" - the approval prompt names the destination before anything is
|
|
90730
|
+
written. Updating one keeps it where it is. Personal skills show **only you** in the Skills tab and can
|
|
90731
|
+
be removed there. Not offered on a shared server, where every user is the same account.
|
|
90732
|
+
|
|
90338
90733
|
**Moving them.** Changed where skills live, or turned a bucket on after you already had some?
|
|
90339
90734
|
Settings -> Skills -> "Bring skills in from another folder" copies them in. Nothing is moved and
|
|
90340
90735
|
nothing is overwritten: the old folder is untouched and a name already present is skipped and
|
|
@@ -91133,6 +91528,20 @@ identical content, which is agreement, not a conflict; an edit someone makes in
|
|
|
91133
91528
|
by the next sync. The same name in two folders here is one file when identical; when the copies differ,
|
|
91134
91529
|
the one Light Code uses is committed and the other is listed.
|
|
91135
91530
|
|
|
91531
|
+
**Deleting one for the team.** Use **Delete everywhere** on the skill (Settings -> Skills) or tool (Settings -> Python): it lists every copy - this computer, S3 bucket folders, the repository - before removing them, and replaces the repository file with a "deleted" marker that every Light Code honours. See the skills topic for the details.
|
|
91532
|
+
|
|
91533
|
+
**Where new ones are saved.** While the repository is on, new skills and Python tools are saved in a
|
|
91534
|
+
folder of its own outside the project (the panel shows the path), so they never land in the project's git.
|
|
91535
|
+
A folder you chose in Settings -> Skills or Settings -> Python, or an S3 bucket folder marked "Publish",
|
|
91536
|
+
still wins. Skills and tools already in the project's .lightcode folders keep loading and are committed
|
|
91537
|
+
too. The agent can read every skill and tool folder, wherever it is, without asking.
|
|
91538
|
+
|
|
91539
|
+
**Starting with the repository alone** needs no S3 bucket: set up Bitbucket, fill in this panel and press
|
|
91540
|
+
Sync now. Everyone's skills and tools come down; yours are committed as you create them.
|
|
91541
|
+
|
|
91542
|
+
**Python tools from the repository** need approving once on each machine, like any shared tool. Tool code
|
|
91543
|
+
approved before (from a bucket, say) with exactly the same content is recognised and not asked again.
|
|
91544
|
+
|
|
91136
91545
|
**"Newer in the repository"** (grey, not red): a colleague's change reached the repository before your
|
|
91137
91546
|
bucket sync brought it here. Your copy is unchanged, so nothing clashes; it clears once the bucket syncs.
|
|
91138
91547
|
**"Not synced - changed both here and in the repository"** (red) means both sides really changed. Compare
|
|
@@ -92466,7 +92875,9 @@ is done and decided, the current state, open questions and next steps - and a ne
|
|
|
92466
92875
|
its first message. Your own messages are quoted word for word, and the files read and changed and the
|
|
92467
92876
|
commands run are listed from the actual tool calls, so nothing important rests on the summary alone. A
|
|
92468
92877
|
progress panel shows each step and how much has been written; Cancel stops it, and a failure leaves the
|
|
92469
|
-
chat as it was. The old chat stays in History.
|
|
92878
|
+
chat as it was. The old chat stays in History. When a reply fails because the conversation is too long
|
|
92879
|
+
for the model, the error offers this too - it still works then, because the write-up is made from a
|
|
92880
|
+
shortened transcript.
|
|
92470
92881
|
|
|
92471
92882
|
**History is compacted only when you say so.** **Compact now** under the token bar summarises the
|
|
92472
92883
|
older part (highlighted near the limit); the stored transcript keeps everything, only what is sent to
|
|
@@ -94604,6 +95015,36 @@ async function removeSkillFromBucket(options) {
|
|
|
94604
95015
|
}
|
|
94605
95016
|
return result;
|
|
94606
95017
|
}
|
|
95018
|
+
function belongsToTool(key2, where, name) {
|
|
95019
|
+
return key2.startsWith(where) && key2.slice(where.length) === `${name}.py`;
|
|
95020
|
+
}
|
|
95021
|
+
async function toolKeysInBucket(options) {
|
|
95022
|
+
const base = normalisePrefix(options.target.prefix);
|
|
95023
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
95024
|
+
const objects = await options.target.client.list(where, 1e3, options.signal);
|
|
95025
|
+
return objects.map((object3) => object3.key).filter((key2) => belongsToTool(key2, where, options.name)).sort();
|
|
95026
|
+
}
|
|
95027
|
+
async function removeToolFromBucket(options) {
|
|
95028
|
+
if (options.target.readOnly === true) {
|
|
95029
|
+
throw new Error(`${options.target.label} is configured read-only, so nothing can be deleted from it.`);
|
|
95030
|
+
}
|
|
95031
|
+
const base = normalisePrefix(options.target.prefix);
|
|
95032
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
95033
|
+
const result = { removed: [], failed: [], rejected: [] };
|
|
95034
|
+
for (const key2 of options.keys) {
|
|
95035
|
+
if (!belongsToTool(key2, where, options.name)) {
|
|
95036
|
+
result.rejected.push(key2);
|
|
95037
|
+
continue;
|
|
95038
|
+
}
|
|
95039
|
+
try {
|
|
95040
|
+
await options.target.client.remove(key2, options.signal);
|
|
95041
|
+
result.removed.push(key2);
|
|
95042
|
+
} catch (error51) {
|
|
95043
|
+
result.failed.push({ key: key2, problem: error51 instanceof Error ? error51.message : String(error51) });
|
|
95044
|
+
}
|
|
95045
|
+
}
|
|
95046
|
+
return result;
|
|
95047
|
+
}
|
|
94607
95048
|
|
|
94608
95049
|
// src/reachableHosts.ts
|
|
94609
95050
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
@@ -94800,6 +95241,8 @@ var ADMIN_ONLY_MESSAGES = [
|
|
|
94800
95241
|
* else's bucket folder is not a normal user's business either.
|
|
94801
95242
|
*/
|
|
94802
95243
|
"previewBucketSkillDelete",
|
|
95244
|
+
// Lists what "Delete everywhere" would remove from shared buckets and the team repository.
|
|
95245
|
+
"previewDeleteEverywhere",
|
|
94803
95246
|
// Processes this machine will spawn.
|
|
94804
95247
|
"saveMcpServer",
|
|
94805
95248
|
"saveMcpServers",
|